SchematicViewWidget.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015-2016 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 
18 #ifndef _GAZEBO_SCHEMATIC_VIEW_WIDGET_HH_
19 #define _GAZEBO_SCHEMATIC_VIEW_WIDGET_HH_
20 
21 #include <utility>
22 #include <map>
23 #include <string>
24 #include <vector>
25 
27 #include "gazebo/gui/qt.h"
28 
29 class QGVNode;
30 class QGVEdge;
31 
32 namespace gazebo
33 {
34  namespace gui
35  {
36  class GraphView;
37  class GraphScene;
38 
41  class GZ_GUI_VISIBLE SchematicViewWidget : public QWidget
42  {
43  Q_OBJECT
44 
47  public: SchematicViewWidget(QWidget *_parent = 0);
48 
50  public: ~SchematicViewWidget() = default;
51 
53  public: void Init();
54 
56  public: void Reset();
57 
60  public: void AddNode(const std::string &_node);
61 
64  public: void RemoveNode(const std::string &_node);
65 
69  public: bool HasNode(const std::string &_name) const;
70 
77  public: void AddEdge(const std::string &_id, const std::string &_name,
78  const std::string &_type, const std::string &_parent,
79  const std::string &_child);
80 
83  public: void RemoveEdge(const std::string &_id);
84 
91  public: void UpdateEdge(const std::string &_id, const std::string &_name,
92  const std::string &_type, const std::string &_parent,
93  const std::string &_child);
94 
98  public: bool HasEdge(const std::string &_id) const;
99 
102  public: unsigned int GetNodeCount() const;
103 
106  public: unsigned int GetEdgeCount() const;
107 
109  public: void FitInView();
110 
116  private: std::string UnscopedName(const std::string &_scopedName) const;
117 
123  private: std::string TopLevelName(const std::string &_scopedName) const;
124 
129  private: void OnSetSelectedEntity(const std::string &_name,
130  bool _selected);
131 
136  private: void OnSetSelectedJoint(const std::string &_id,
137  bool _selected);
138 
142  private: void OnDeselectAll(const std::string &_name,
143  const std::string &_mode);
144 
147  private: void resizeEvent(QResizeEvent *_event);
148 
151  private slots: void OnCustomContextMenu(const QString &_id);
152 
155  private slots: void OnItemDoubleClicked(const QString &_id);
156 
158  private slots: void OnSelectionChanged();
159 
161  private: GraphScene *scene;
162 
164  private: GraphView *view;
165 
167  private: int minimumWidth;
168 
170  private: int minimumHeight;
171 
173  private: std::map<std::string, QGVEdge *> edges;
174 
176  private: std::map<std::string, QGVNode *> nodes;
177 
179  private: std::vector<event::ConnectionPtr> connections;
180 
182  private: QList<QGraphicsItem *> selectedItems;
183  };
184  }
185 }
186 
187 #endif
Forward declarations for the common classes.
Definition: Animation.hh:33
A scene of 2D graph nodes and edges.
Definition: GraphScene.hh:34
A view for the graph scene.
Definition: GraphView.hh:29
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:41