hpp-plot  4.9.0
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 
38 #include <hpp/corbaserver/manipulation/client.hh>
39 
40 #include <hpp/plot/graph-widget.hh>
41 
42 namespace hpp {
43  namespace corbaServer {
44  namespace manipulation {
45  class Client;
46  }
47  }
48  namespace plot {
49  class HppManipulationGraphWidget;
50 
51  class GraphAction : public QAction
52  {
53  Q_OBJECT
54 
55  public:
57 
58  signals:
59  void activated (hpp::ID id);
60 
61  private slots:
62  void transferSignal ();
63 
64  private:
66  };
67 
69  {
70  Q_OBJECT
71 
72  public:
73  HppManipulationGraphWidget (corbaServer::manipulation::Client* hpp_, QWidget* parent);
74 
76 
77  void addNodeContextMenuAction (GraphAction* action);
78  void addEdgeContextMenuAction (GraphAction* action);
79 
80  void client (corbaServer::manipulation::Client* hpp);
81 
82  bool selectionID (hpp::ID& id);
83  void showEdge (const hpp::ID& edgeId);
84  const std::string& graphName () const
85  {
86  return graphName_;
87  }
88 
89  protected:
90  void fillScene ();
91 
92  public slots:
93  void updateStatistics ();
94  void showNodeOfConfiguration (const hpp::floatSeq& cfg);
95  void displayNodeConstraint(hpp::ID id);
96  void displayEdgeConstraint(hpp::ID id);
97  void displayEdgeTargetConstraint(hpp::ID id);
98 
99  protected slots:
100  virtual void nodeContextMenu(QGVNode* node);
101  virtual void nodeDoubleClick(QGVNode* node);
102  virtual void edgeContextMenu(QGVEdge* edge);
103  virtual void edgeDoubleClick(QGVEdge* edge);
104 
105  void selectionChanged ();
106 
107  private slots:
108  void startStopUpdateStats (bool start);
109 
110  private:
111  corbaServer::manipulation::Client* manip_;
112 
113  struct GraphInfo {
114  ::hpp::ID id;
115  QString constraintStr;
116  } graphInfo_;
117  struct NodeInfo {
118  ::hpp::ID id;
119  QString constraintStr;
120  QGVNode* node;
121 
122  ::hpp::ConfigProjStat_var configStat, pathStat;
123  ::CORBA::Long freq;
124  ::hpp::intSeq_var freqPerCC;
125  NodeInfo ();
126  };
127  struct EdgeInfo {
128  ::hpp::ID id;
129  QString name, containingNodeName;
130  ::CORBA::Long weight;
131  QString constraintStr;
132  QString shortStr;
133  QGVEdge* edge;
134 
135  ::hpp::ConfigProjStat_var configStat, pathStat;
136  ::hpp::Names_t_var errors;
137  ::hpp::intSeq_var freqs;
138 
139  EdgeInfo ();
140  };
141 
142  void updateWeight (EdgeInfo& ei, bool get = true);
143  void updateWeight (EdgeInfo& ei, const ::CORBA::Long w);
144 
145  QString getConstraints(hpp::ID id);
146 
147  std::string graphName_;
148  QList <GraphAction*> nodeContextMenuActions_;
149  QList <GraphAction*> edgeContextMenuActions_;
150  QMap <QGVNode*, NodeInfo> nodeInfos_;
151  QMap <QGVEdge*, EdgeInfo> edgeInfos_;
152  QMap <hpp::ID, QGVNode*> nodes_;
153  QMap <hpp::ID, QGVEdge*> edges_;
154 
155  QPushButton* showWaypoints_, *statButton_;
156  QTimer* updateStatsTimer_;
157 
158  hpp::ID currentId_, showNodeId_, showEdgeId_;
159  };
160  }
161 }
162 
163 #endif // HPP_PLOT_HPP_MANIPULATION_GRAPH_HH
Definition: graph-widget.hh:55
const std::string & graphName() const
Definition: hpp-manipulation-graph.hh:84
Definition: hpp-manipulation-graph.hh:68
sequence< double > floatSeq
Definition: hpp-manipulation-graph.hh:51