hpp-gui  4.12.0
Graphical interface for HPP
joint-tree-item.hh
Go to the documentation of this file.
1 //
2 // Copyright (c) CNRS
3 // Authors: Joseph Mirabel
4 //
5 
6 #ifndef HPP_GUI_JOINTTREEITEM_HH
7 #define HPP_GUI_JOINTTREEITEM_HH
8 
9 #include <QItemDelegate>
10 #include <QSlider>
11 #include <QStandardItem>
12 
13 //#include <hpp/corbaserver/robot.hh>
14 #include <gepetto/gui/fwd.hh>
15 #include <gepetto/viewer/node.h>
16 
18 
19 class QDoubleSpinBox;
20 class QMenu;
21 class QPushButton;
22 
23 namespace hpp {
24  namespace gui {
25  class JointTreeItem : public QStandardItem
26  {
27  public:
28  typedef CORBA::ULong ULong;
29  typedef gepetto::viewer::NodePtr_t NodePtr_t;
30  typedef std::vector<NodePtr_t> NodesPtr_t;
31 
32  static const int IndexRole ;
33  static const int LowerBoundRole;
34  static const int UpperBoundRole;
35  static const int TypeRole ;
36 
37  enum ItemType {
38  SkipType = 0,
43  };
44 
45  JointTreeItem (const char* name,
46  const ULong& idxQ,
47  const ULong& idxV,
48  const hpp::floatSeq& q,
49  const hpp::floatSeq& b,
50  const ULong& nbDof,
51  const NodesPtr_t& node);
52 
53  ~JointTreeItem ();
54 
55  virtual QStandardItem* clone () const;
56 
57  virtual int type() {
58  return QStandardItem::UserType+3;
59  }
60 
61  const std::string& name () const {
62  return name_;
63  }
64 
65  hpp::floatSeq config () const;
66 
67  hpp::floatSeq bounds () const;
68 
69  ULong rankInConfig () const { return idxQ_; }
70 
71  ULong rankInVelocity () const { return idxV_; }
72 
73  ULong configSize () const { return nq_; }
74 
75  ULong numberDof () const { return nv_; }
76 
77  void updateBounds (const hpp::floatSeq &b);
78 
79  void updateConfig (const hpp::floatSeq &c);
80 
81  void updateFromRobotConfig (const hpp::floatSeq &c);
82 
83  void updateTypeRole ();
84 
85  void setupActions(HppWidgetsPlugin* plugin);
86 
87  const QList<QAction*>& actions () const;
88 
89  private:
90  typedef QList<QStandardItem*> StandardItemList;
91 
92  std::string name_;
93  ULong idxQ_, idxV_, nq_, nv_;
94  NodesPtr_t nodes_;
95  QVector<StandardItemList> value_;
96  QList<QAction*> actions_;
97  };
98 
99  class IntegratorWheel : public QSlider
100  {
101  Q_OBJECT
102 
103  public:
104  IntegratorWheel (Qt::Orientation o, HppWidgetsPlugin* plugin, QWidget *parent,
105  gepetto::gui::MainWindow *main, JointTreeItem const* item, int index);
106 
107  protected:
108  void timerEvent(QTimerEvent *);
109 
110  protected slots:
111  void reset ();
112  void updateIntegrator (int value);
113 
114  private:
115  int rate_; // in millisecond
116  int timerId_;
117  gepetto::gui::MainWindow* main_;
118  HppWidgetsPlugin* plugin_;
119  JointTreeItem const* item_;
120 
121  const int bound_;
122  const double maxVelocity_;
123  hpp::floatSeq q_, dq_;
124  int index_;
125  };
126 
127  class SliderBoundedJoint : public QSlider
128  {
129  Q_OBJECT
130 
131  public:
132  SliderBoundedJoint (Qt::Orientation orientation, HppWidgetsPlugin* plugin, QWidget* parent,
133  gepetto::gui::MainWindow *main, JointTreeItem const* item, int index);
134 
135  double getValue ();
136 
137  private slots:
138  void updateConfig (int value);
139 
140  private:
141  gepetto::gui::MainWindow* main_;
142  HppWidgetsPlugin* plugin_;
143  JointTreeItem const* item_;
144  double value_;
145  int index_;
146  double m_, M_;
147  };
148 
149  class JointItemDelegate : public QItemDelegate
150  {
151  Q_OBJECT
152 
153  public:
154  JointItemDelegate (QPushButton* forceVelocity, HppWidgetsPlugin* plugin, gepetto::gui::MainWindow* parent);
155 
156  void updateTypeRole (JointTreeItem::ItemType& type) const;
157 
158  QWidget* createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const;
159  void setEditorData(QWidget *editor, const QModelIndex &index) const;
160  void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const;
161  void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const;
162 
163  private:
164  gepetto::gui::MainWindow* main_;
165  HppWidgetsPlugin* plugin_;
166  QPushButton* forceIntegrator_;
167  };
168  } // namespace gui
169 } // namespace hpp
170 
171 #endif // HPP_GUI_JOINTTREEITEM_HH
void updateIntegrator(int value)
QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
Definition: joint-tree-item.hh:42
Definition: joint-tree-item.hh:99
std::vector< NodePtr_t > NodesPtr_t
Definition: joint-tree-item.hh:30
virtual int type()
Definition: joint-tree-item.hh:57
ULong numberDof() const
Definition: joint-tree-item.hh:75
namespace that encapsulate all the softwares of humanoid-path-planner
Definition: __init__.py:1
Definition: joint-tree-item.hh:149
gepetto::viewer::NodePtr_t NodePtr_t
Definition: joint-tree-item.hh:29
virtual QStandardItem * clone() const
Definition: joint-tree-item.hh:38
JointItemDelegate(QPushButton *forceVelocity, HppWidgetsPlugin *plugin, gepetto::gui::MainWindow *parent)
IntegratorWheel(Qt::Orientation o, HppWidgetsPlugin *plugin, QWidget *parent, gepetto::gui::MainWindow *main, JointTreeItem const *item, int index)
void setEditorData(QWidget *editor, const QModelIndex &index) const
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
const std::string & name() const
Definition: joint-tree-item.hh:61
void updateConfig(const hpp::floatSeq &c)
ItemType
Definition: joint-tree-item.hh:37
CORBA::ULong ULong
Definition: joint-tree-item.hh:28
ULong rankInVelocity() const
Definition: joint-tree-item.hh:71
Definition: joint-tree-item.hh:39
void updateBounds(const hpp::floatSeq &b)
Definition: joint-tree-item.hh:25
hpp::floatSeq bounds() const
Definition: joint-tree-item.hh:40
void setupActions(HppWidgetsPlugin *plugin)
JointTreeItem(const char *name, const ULong &idxQ, const ULong &idxV, const hpp::floatSeq &q, const hpp::floatSeq &b, const ULong &nbDof, const NodesPtr_t &node)
Definition: joint-tree-item.hh:127
static const int IndexRole
Definition: joint-tree-item.hh:32
ULong configSize() const
Definition: joint-tree-item.hh:73
static const int TypeRole
Definition: joint-tree-item.hh:35
void updateFromRobotConfig(const hpp::floatSeq &c)
SliderBoundedJoint(Qt::Orientation orientation, HppWidgetsPlugin *plugin, QWidget *parent, gepetto::gui::MainWindow *main, JointTreeItem const *item, int index)
ULong rankInConfig() const
Definition: joint-tree-item.hh:69
void updateTypeRole(JointTreeItem::ItemType &type) const
hpp::floatSeq config() const
Definition: joint-tree-item.hh:41
void timerEvent(QTimerEvent *)
static const int LowerBoundRole
Definition: joint-tree-item.hh:33
static const int UpperBoundRole
Definition: joint-tree-item.hh:34
const QList< QAction * > & actions() const
void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const
Plugin that add a lot of features to work with hpp.
Definition: hppwidgetsplugin.hh:29