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