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 
114  private: std::string UnscopedName(const std::string &_scopedName);
115 
120  private: void OnSetSelectedLink(const std::string &_name, bool _selected);
121 
126  private: void OnSetSelectedJoint(const std::string &_id,
127  bool _selected);
128 
132  private: void OnSetSelectedEntity(const std::string &_name,
133  const std::string &_mode);
134 
137  private: void resizeEvent(QResizeEvent *_event);
138 
141  private slots: void OnCustomContextMenu(const QString &_id);
142 
145  private slots: void OnItemDoubleClicked(const QString &_id);
146 
148  private slots: void OnSelectionChanged();
149 
151  private: GraphScene *scene;
152 
154  private: GraphView *view;
155 
157  private: int minimumWidth;
158 
160  private: int minimumHeight;
161 
163  private: std::map<std::string, QGVEdge *> edges;
164 
166  private: std::map<std::string, QGVNode *> nodes;
167 
169  private: std::vector<event::ConnectionPtr> connections;
170 
172  private: QList<QGraphicsItem *> selectedItems;
173  };
174  }
175 }
176 
177 #endif
#define GZ_GUI_VISIBLE
Definition: system.hh:284
Node item.
Definition: QGVNode.h:34
Edge item.
Definition: QGVEdge.h:36
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