hpp-plot: include/hpp/plot/hpp-manipulation-graph.hh Source File

hpp-plot 9.0.2 Plotting tools for HPP

hpp-manipulation-graph.hh
Go to the documentation of this file.
1 // BSD 2-Clause License
2
3 // Copyright (c) 2015 - 2018, hpp-plot
4 // Authors: Heidy Dallard, Joseph Mirabel
5 // All rights reserved.
6
7 // Redistribution and use in source and binary forms, with or without
8 // modification, are permitted provided that the following conditions
9 // are met:
10
11 // * Redistributions of source code must retain the above copyright
12 // notice, this list of conditions and the following disclaimer.
13
14 // * Redistributions in binary form must reproduce the above copyright
15 // notice, this list of conditions and the following disclaimer in
16 // the documentation and/or other materials provided with the
17 // distribution.
18
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
22 // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23 // COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
24 // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28 // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
30 // OF THE POSSIBILITY OF SUCH DAMAGE.
31
32 #ifndef HPP_PLOT_HPP_MANIPULATION_GRAPH_HH
33 #define HPP_PLOT_HPP_MANIPULATION_GRAPH_HH
34
35 #include <QAction>
36 #include <QPushButton>
37 #include <hpp/corbaserver/manipulation/client.hh>
38 #include <hpp/plot/graph-widget.hh>
39
40 namespace hpp {
41 namespace corbaServer {
42 namespace manipulation {
43 class Client;
44 }
45 } // namespace corbaServer
46 namespace plot {
47 class HppManipulationGraphWidget;
48
49 class GraphAction : public QAction {
50 Q_OBJECT
51
52 public:
53 GraphAction(HppManipulationGraphWidget* parent);
54
55 Q_SIGNALS:
56 void activated(hpp::ID id);
57
58 private Q_SLOTS:
59 void transferSignal();
60
61 private:
62 HppManipulationGraphWidget* gw_;
63 };
64
65 class HppManipulationGraphWidget : public GraphWidget {
66 Q_OBJECT
67
68 public:
69 HppManipulationGraphWidget(corbaServer::manipulation::Client* hpp_,
70 QWidget* parent);
71
72 ~HppManipulationGraphWidget();
73
74 void addNodeContextMenuAction(GraphAction* action);
75 void addEdgeContextMenuAction(GraphAction* action);
76
77 void client(corbaServer::manipulation::Client* hpp);
78
79 bool selectionID(hpp::ID& id);
80 void showEdge(const hpp::ID& edgeId);
81 const std::string& graphName() const { return graphName_; }
82
83 protected:
84 void fillScene();
85
86 public Q_SLOTS:
87 void updateStatistics();
88 void showNodeOfConfiguration(const hpp::floatSeq& cfg);
89 void displayNodeConstraint(hpp::ID id);
90 void displayEdgeConstraint(hpp::ID id);
91 void displayEdgeTargetConstraint(hpp::ID id);
92
93 protected Q_SLOTS:
94 virtual void nodeContextMenu(QGVNode* node);
95 virtual void nodeDoubleClick(QGVNode* node);
96 virtual void edgeContextMenu(QGVEdge* edge);
97 virtual void edgeDoubleClick(QGVEdge* edge);
98
99 void selectionChanged();
100
101 private Q_SLOTS:
102 void startStopUpdateStats(bool start);
103
104 private:
105 corbaServer::manipulation::Client* manip_;
106
107 struct GraphInfo {
108 ::hpp::ID id;
109 QString constraintStr;
110 } graphInfo_;
111 struct NodeInfo {
112 ::hpp::ID id;
113 QString constraintStr;
114 QGVNode* node;
115
116 ::hpp::ConfigProjStat configStat, pathStat;
117 ::CORBA::Long freq;
118 ::hpp::intSeq_var freqPerCC;
119 NodeInfo();
120 };
121 struct EdgeInfo {
122 ::hpp::ID id;
123 QString name, containingNodeName;
124 ::CORBA::Long weight;
125 QString constraintStr;
126 QString shortStr;
127 QGVEdge* edge;
128
129 ::hpp::ConfigProjStat configStat, pathStat;
130 ::hpp::Names_t_var errors;
131 ::hpp::intSeq_var freqs;
132
133 EdgeInfo();
134 };
135
136 void updateWeight(EdgeInfo& ei, bool get = true);
137 void updateWeight(EdgeInfo& ei, const ::CORBA::Long w);
138
139 QString getConstraints(hpp::ID id);
140
141 std::string graphName_;
142 QList<GraphAction*> nodeContextMenuActions_;
143 QList<GraphAction*> edgeContextMenuActions_;
144 QMap<QGVNode*, NodeInfo> nodeInfos_;
145 QMap<QGVEdge*, EdgeInfo> edgeInfos_;
146 QMap<hpp::ID, QGVNode*> nodes_;
147 QMap<hpp::ID, QGVEdge*> edges_;
148
149 QPushButton *showWaypoints_, *statButton_;
150 QTimer* updateStatsTimer_;
151
152 hpp::ID currentId_, showNodeId_, showEdgeId_;
153 };
154 } // namespace plot
155 } // namespace hpp
156
157 #endif // HPP_PLOT_HPP_MANIPULATION_GRAPH_HH
QGVEdge
QGVNode
hpp::corbaServer::manipulation::Client
hpp::plot::GraphAction
Definition: hpp-manipulation-graph.hh:49
hpp::plot::GraphAction::GraphAction
GraphAction(HppManipulationGraphWidget *parent)
Definition: hpp-manipulation-graph.cc:67
hpp::plot::GraphAction::activated
void activated(hpp::ID id)
Definition: moc_hpp-manipulation-graph.cpp:139
hpp::plot::GraphWidget
Definition: graph-widget.hh:54
hpp::plot::HppManipulationGraphWidget
Definition: hpp-manipulation-graph.hh:65
hpp::plot::HppManipulationGraphWidget::showEdge
void showEdge(const hpp::ID &edgeId)
Definition: hpp-manipulation-graph.cc:351
hpp::plot::HppManipulationGraphWidget::nodeContextMenu
virtual void nodeContextMenu(QGVNode *node)
Definition: hpp-manipulation-graph.cc:368
hpp::plot::HppManipulationGraphWidget::~HppManipulationGraphWidget
~HppManipulationGraphWidget()
Definition: hpp-manipulation-graph.cc:103
hpp::plot::HppManipulationGraphWidget::nodeDoubleClick
virtual void nodeDoubleClick(QGVNode *node)
Definition: hpp-manipulation-graph.cc:382
hpp::plot::HppManipulationGraphWidget::fillScene
void fillScene()
Definition: hpp-manipulation-graph.cc:127
hpp::plot::HppManipulationGraphWidget::selectionID
bool selectionID(hpp::ID &id)
Definition: hpp-manipulation-graph.cc:122
hpp::plot::HppManipulationGraphWidget::edgeContextMenu
virtual void edgeContextMenu(QGVEdge *edge)
Definition: hpp-manipulation-graph.cc:411
hpp::plot::HppManipulationGraphWidget::edgeDoubleClick
virtual void edgeDoubleClick(QGVEdge *edge)
Definition: hpp-manipulation-graph.cc:425
hpp::plot::HppManipulationGraphWidget::selectionChanged
void selectionChanged()
Definition: hpp-manipulation-graph.cc:437
hpp::plot::HppManipulationGraphWidget::addNodeContextMenuAction
void addNodeContextMenuAction(GraphAction *action)
Definition: hpp-manipulation-graph.cc:109
hpp::plot::HppManipulationGraphWidget::client
void client(corbaServer::manipulation::Client *hpp)
Definition: hpp-manipulation-graph.cc:117
hpp::plot::HppManipulationGraphWidget::showNodeOfConfiguration
void showNodeOfConfiguration(const hpp::floatSeq &cfg)
Definition: hpp-manipulation-graph.cc:321
hpp::plot::HppManipulationGraphWidget::graphName
const std::string & graphName() const
Definition: hpp-manipulation-graph.hh:81
hpp::plot::HppManipulationGraphWidget::displayNodeConstraint
void displayNodeConstraint(hpp::ID id)
Definition: hpp-manipulation-graph.cc:387
hpp::plot::HppManipulationGraphWidget::HppManipulationGraphWidget
HppManipulationGraphWidget(corbaServer::manipulation::Client *hpp_, QWidget *parent)
Definition: hpp-manipulation-graph.cc:77
hpp::plot::HppManipulationGraphWidget::displayEdgeTargetConstraint
void displayEdgeTargetConstraint(hpp::ID id)
Definition: hpp-manipulation-graph.cc:403
hpp::plot::HppManipulationGraphWidget::addEdgeContextMenuAction
void addEdgeContextMenuAction(GraphAction *action)
Definition: hpp-manipulation-graph.cc:113
hpp::plot::HppManipulationGraphWidget::updateStatistics
void updateStatistics()
Definition: hpp-manipulation-graph.cc:263
hpp::plot::HppManipulationGraphWidget::displayEdgeConstraint
void displayEdgeConstraint(hpp::ID id)
Definition: hpp-manipulation-graph.cc:395
client.hh
graph-widget.hh
hpp
hpp::ID
long ID
hpp::floatSeq
sequence< double > floatSeq
manipulation
hpp::ConfigProjStat