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 
28 class QGVNode;
29 class QGVEdge;
30 
31 namespace 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: 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
Forward declarations for the common classes.
Definition: Animation.hh:33
A scene of 2D graph nodes and edges.
Definition: GraphScene.hh:33
A view for the graph scene.
Definition: GraphView.hh:28
GAZEBO_VISIBLE void Init(google::protobuf::Message &_message, const std::string &_id="")
Initialize a message.
The parent widget of the CML editor.
Definition: SchematicViewWidget.hh:40