SchematicViewWidget.hh
Go to the documentation of this file.
1/*
2 * Copyright (C) 2015 Open Source Robotics Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16*/
17#ifndef GAZEBO_GUI_MODEL_SCHEMATICVIEWWIDGET_HH_
18#define GAZEBO_GUI_MODEL_SCHEMATICVIEWWIDGET_HH_
19
20#include <utility>
21#include <map>
22#include <string>
23#include <vector>
24
26#include "gazebo/gui/qt.h"
27
28class QGVNode;
29class QGVEdge;
30
31namespace gazebo
32{
33 namespace gui
34 {
35 class GraphView;
36 class GraphScene;
37
40 class GZ_GUI_VISIBLE SchematicViewWidget : public QWidget
41 {
42 Q_OBJECT
43
46 public: explicit SchematicViewWidget(QWidget *_parent = 0);
47
49 public: ~SchematicViewWidget() = default;
50
52 public: void Init();
53
55 public: void Reset();
56
59 public: void AddNode(const std::string &_node);
60
63 public: void RemoveNode(const std::string &_node);
64
68 public: bool HasNode(const std::string &_name) const;
69
76 public: void AddEdge(const std::string &_id, const std::string &_name,
77 const std::string &_type, const std::string &_parent,
78 const std::string &_child);
79
82 public: void RemoveEdge(const std::string &_id);
83
90 public: void UpdateEdge(const std::string &_id, const std::string &_name,
91 const std::string &_type, const std::string &_parent,
92 const std::string &_child);
93
97 public: bool HasEdge(const std::string &_id) const;
98
101 public: unsigned int GetNodeCount() const;
102
105 public: unsigned int GetEdgeCount() const;
106
108 public: void FitInView();
109
115 private: std::string UnscopedName(const std::string &_scopedName) const;
116
122 private: std::string TopLevelName(const std::string &_scopedName) const;
123
128 private: void OnSetSelectedEntity(const std::string &_name,
129 bool _selected);
130
135 private: void OnSetSelectedJoint(const std::string &_id,
136 bool _selected);
137
141 private: void OnDeselectAll(const std::string &_name,
142 const std::string &_mode);
143
146 private: void resizeEvent(QResizeEvent *_event);
147
150 private slots: void OnCustomContextMenu(const QString &_id);
151
154 private slots: void OnItemDoubleClicked(const QString &_id);
155
157 private slots: void OnSelectionChanged();
158
160 private: GraphScene *scene;
161
163 private: GraphView *view;
164
166 private: int minimumWidth;
167
169 private: int minimumHeight;
170
172 private: std::map<std::string, QGVEdge *> edges;
173
175 private: std::map<std::string, QGVNode *> nodes;
176
178 private: std::vector<event::ConnectionPtr> connections;
179
181 private: QList<QGraphicsItem *> selectedItems;
182 };
183 }
184}
185
186#endif
gui
Definition KeyEventHandler.hh:29
A scene of 2D graph nodes and edges.
Definition GraphScene.hh:34
A view for the graph scene.
Definition GraphView.hh:29
The parent widget of the CML editor.
Definition SchematicViewWidget.hh:41
void AddEdge(const std::string &_id, const std::string &_name, const std::string &_type, const std::string &_parent, const std::string &_child)
Add an edge to the scene in the widget.
SchematicViewWidget(QWidget *_parent=0)
Constructor.
void Init()
Initialize the widget to listen to events/topics.
void Reset()
Reset the widget and clear the scene.
void AddNode(const std::string &_node)
Add a node to the scene in the widget.
void RemoveNode(const std::string &_node)
Remove a node from the scene in the widget.
unsigned int GetNodeCount() const
Get number of nodes in the scene.
void RemoveEdge(const std::string &_id)
Remove an edge from the scene in the widget.
void FitInView()
Scales the view to ensure the items of the scene are visible.
bool HasNode(const std::string &_name) const
Check if a node exists in the scene in the widget.
~SchematicViewWidget()=default
Destructor.
void UpdateEdge(const std::string &_id, const std::string &_name, const std::string &_type, const std::string &_parent, const std::string &_child)
Update an edge in the scene.
unsigned int GetEdgeCount() const
Get number of edges in the scene.
bool HasEdge(const std::string &_id) const
Check if an edge exists in the scene in the widget.
Forward declarations for the common classes.
Definition Animation.hh:27