##

SchematicViewWidget.hh
Go to the documentation of this file.
/*
* Copyright (C) 2015 Open Source Robotics Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef GAZEBO_GUI_MODEL_SCHEMATICVIEWWIDGET_HH_
#define GAZEBO_GUI_MODEL_SCHEMATICVIEWWIDGET_HH_
#include <utility>
#include <map>
#include <string>
#include <vector>
#include "gazebo/common/CommonTypes.hh"
#include "gazebo/gui/qt.h"
class QGVNode;
class QGVEdge;
namespace gazebo
{
namespace gui
{
class GraphView;
class GraphScene;
class GZ_GUI_VISIBLE SchematicViewWidget : public QWidget
{
Q_OBJECT
public: explicit SchematicViewWidget(QWidget *_parent = 0);
public: ~SchematicViewWidget() = default;
public: void Init();
public: void Reset();
public: void AddNode(const std::string &_node);
public: void RemoveNode(const std::string &_node);
public: bool HasNode(const std::string &_name) const;
public: void AddEdge(const std::string &_id, const std::string &_name,
const std::string &_type, const std::string &_parent,
const std::string &_child);
public: void RemoveEdge(const std::string &_id);
public: void UpdateEdge(const std::string &_id, const std::string &_name,
const std::string &_type, const std::string &_parent,
const std::string &_child);
public: bool HasEdge(const std::string &_id) const;
public: unsigned int GetNodeCount() const;
public: unsigned int GetEdgeCount() const;
public: void FitInView();
private: std::string UnscopedName(const std::string &_scopedName) const;
private: std::string TopLevelName(const std::string &_scopedName) const;
private: void OnSetSelectedEntity(const std::string &_name,
bool _selected);
private: void OnSetSelectedJoint(const std::string &_id,
bool _selected);
private: void OnDeselectAll(const std::string &_name,
const std::string &_mode);
private: void resizeEvent(QResizeEvent *_event);
private slots: void OnCustomContextMenu(const QString &_id);
private slots: void OnItemDoubleClicked(const QString &_id);
private slots: void OnSelectionChanged();
private: GraphScene *scene;
private: GraphView *view;
private: int minimumWidth;
private: int minimumHeight;
private: std::map<std::string, QGVEdge *> edges;
private: std::map<std::string, QGVNode *> nodes;
private: std::vector<event::ConnectionPtr> connections;
private: QList<QGraphicsItem *> selectedItems;
};
}
}
#endif
gazebo::gui::SchematicViewWidget::HasEdge
bool HasEdge(const std::string &_id) const
Check if an edge exists in the scene in the widget.
gazebo::gui::SchematicViewWidget
The parent widget of the CML editor.
Definition: SchematicViewWidget.hh:40
gazebo
Forward declarations for the common classes.
Definition: Animation.hh:26
qt.h
gazebo::gui::SchematicViewWidget::UpdateEdge
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.
gazebo::gui::SchematicViewWidget::GetNodeCount
unsigned int GetNodeCount() const
Get number of nodes in the scene.
gazebo::gui::SchematicViewWidget::Init
void Init()
Initialize the widget to listen to events/topics.
gazebo::gui::SchematicViewWidget::AddNode
void AddNode(const std::string &_node)
Add a node to the scene in the widget.
CommonTypes.hh
gazebo::gui::SchematicViewWidget::~SchematicViewWidget
~SchematicViewWidget()=default
Destructor.
gazebo::gui::SchematicViewWidget::AddEdge
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.
gazebo::gui::SchematicViewWidget::FitInView
void FitInView()
Scales the view to ensure the items of the scene are visible.
gazebo::gui::SchematicViewWidget::Reset
void Reset()
Reset the widget and clear the scene.
gazebo::gui::GraphScene
A scene of 2D graph nodes and edges.
Definition: GraphScene.hh:33
gazebo::gui::SchematicViewWidget::RemoveNode
void RemoveNode(const std::string &_node)
Remove a node from the scene in the widget.
gazebo::gui::SchematicViewWidget::SchematicViewWidget
SchematicViewWidget(QWidget *_parent=0)
Constructor.
gazebo::gui::SchematicViewWidget::HasNode
bool HasNode(const std::string &_name) const
Check if a node exists in the scene in the widget.
gazebo::gui::GraphView
A view for the graph scene.
Definition: GraphView.hh:28
gazebo::msgs::Init
GAZEBO_VISIBLE void Init(google::protobuf::Message &_message, const std::string &_id="")
Initialize a message.
gui
gui
Definition: KeyEventHandler.hh:29
gazebo::gui::SchematicViewWidget::RemoveEdge
void RemoveEdge(const std::string &_id)
Remove an edge from the scene in the widget.
gazebo::gui::SchematicViewWidget::GetEdgeCount
unsigned int GetEdgeCount() const
Get number of edges in the scene.