viewCtrl.hpp
Go to the documentation of this file.
1 
9 #ifndef QTCTRL_GUI_CTRL_VIEW
10 #define QTCTRL_GUI_CTRL_VIEW
11 
12 #include <gui/ctrlWdgt.hpp>
13 
24 class ViewCtrlWdgt : private QWidget, public ControlWidget {
25  Q_OBJECT // This macro is needed to handle graphical events
26 
27 protected:
28  QPointF velocities;
29  QPointF commands;
30 
35  QPoint plot(const QPointF& velocities) const;
36 
40  QRect region(const QPointF& vel) const {
41  static const int offset = 2; // +/- 2 px, diameter = 5 px
42  const QPoint intVel = plot(vel);
43  return QRect(intVel, intVel).adjusted(-offset, -offset,
44  offset, offset);
45  }
46 
50  void modify(QPointF& variable, const QPointF& value) {
51  // region modified in the drawing (union of two regions)
52  const QRect change = region(variable) | region(value);
53  variable = value; // update the variable
54  update(change); // update the drawing
55  }
56 
57 protected Q_SLOTS:
62  void paintEvent(QPaintEvent *event);
63 
64 public:
72  ViewCtrlWdgt(QWidget& parent, Controller& control,
73  const MotionModel& motion_model);
74 
77 
82  QWidget& widget() { return *this; }
83 
84  // Cf ControlWidget::updateState(const State&)
85  void updateState(const State& state)
86  { modify( velocities, QPointF( state.translationVelocity(),
87  state.rotationVelocity() ) ); }
88 
89  // Cf ControlWidget::updateCommands(const double&, const double&)
90  void updateCommands(const double& trans_vel, const double& rot_vel)
91  { modify( commands, QPointF(trans_vel, rot_vel) ); }
92 
93 }; // end of class ViewCtrlWdgt
94 
95 #endif // QTCTRL_CTRL_VIEW
void updateState(const State &state)
Update the display of the odometry.
Definition: viewCtrl.hpp:85
Controller is the abstract class inherited by all the implemented controllers.
Definition: controller.hpp:28
~ViewCtrlWdgt()
The destructor needs to be redefined.
Definition: viewCtrl.hpp:76
QPoint plot(const QPointF &velocities) const
Returns the graphical point corresponding to a couple of velocities.
Definition: viewCtrl.cpp:17
const double & rotationVelocity() const
Gives the rotation velocity of the state.
Definition: state.hpp:81
void modify(QPointF &variable, const QPointF &value)
Memorizes a new value in a variable and redraw.
Definition: viewCtrl.hpp:50
This abstract class is inherited by all those containing a Qt widget intended to show the controller&#39;...
Definition: ctrlWdgt.hpp:24
This class is a Qt widget which allows to show the controller&#39;s behaviour (current and aimed velociti...
Definition: viewCtrl.hpp:24
QWidget & widget()
Returns the widget used to display the behaviour.
Definition: viewCtrl.hpp:82
void updateCommands(const double &trans_vel, const double &rot_vel)
Update the display of the ROS node.
Definition: viewCtrl.hpp:90
const double & translationVelocity() const
Gives the translation velocity of the state.
Definition: state.hpp:74
ViewCtrlWdgt(QWidget &parent, Controller &control, const MotionModel &motion_model)
The constructor needs the containing graphical object, the motion model and the related controller...
Definition: viewCtrl.cpp:66
This class defines a state, i.e. a configuration and its (translation and rotation) velocities...
Definition: state.hpp:22
void paintEvent(QPaintEvent *event)
Draws the controller&#39;s velocities and their evolution.
Definition: viewCtrl.cpp:33
Qt based control widget for qt_ctrl.
This class defines a motion model, with the motion limits.
Definition: motion.hpp:28
QRect region(const QPointF &vel) const
Returns the graphical region drawn around velocities.
Definition: viewCtrl.hpp:40
QPointF commands
The velocities sent as commands.
Definition: viewCtrl.hpp:29
QPointF velocities
The velocities from the odometry.
Definition: viewCtrl.hpp:28


qt_ctrl
Author(s): Alexis Scheuer
autogenerated on Wed Dec 16 2020 15:51:32