11 #include <QPaintEvent> 18 const double &v = vel.x(), &om = vel.y(),
21 const QSize &sz = size();
25 return QPoint( (
int)( (1 - om / maxOm) / 2 * sz.width() ),
26 (
int)( (maxV - v) / (maxV - minV) * sz.height() ) );
34 static const int nb_points = 2;
35 static const Qt::GlobalColor colors[nb_points]
36 = {Qt::green, Qt::blue};
37 QPainter painter(
this);
38 const QRect& drawing_rect =
event->rect();
39 const QSize& sz = size();
40 const QPoint origin =
plot( QPointF() );
42 const double &xOrig = origin.x(), &yOrig = origin.y();
44 painter.eraseRect(drawing_rect);
46 painter.drawLine( xOrig, 0, xOrig, sz.height() );
47 painter.drawLine( 0, yOrig, sz.width(), yOrig );
49 for(
int i = 0; i < nb_points; i++) {
50 painter.setPen(colors[i]);
51 painter.setBrush(colors[i]);
52 painter.drawPie(
region(*points[i]), 0, 360 * 16);
70 setBackgroundRole(QPalette::Base);
72 setMinimumSize(200, 200);
Controller is the abstract class inherited by all the implemented controllers.
Qt control widget showing current and aimed velocities.
QPoint plot(const QPointF &velocities) const
Returns the graphical point corresponding to a couple of velocities.
const double & maxRotVel() const
Descriptive method, giving the maximum rotation velocity.
ViewCtrlWdgt(QWidget &parent, Controller &control, const MotionModel &motion_model)
The constructor needs the containing graphical object, the motion model and the related controller...
const double & maxTranslVel() const
Descriptive method, giving the maximum translation velocity.
void paintEvent(QPaintEvent *event)
Draws the controller's velocities and their evolution.
This class defines a motion model, with the motion limits.
const double & minTranslVel() const
Descriptive method, giving the minimum translation velocity.
QRect region(const QPointF &vel) const
Returns the graphical region drawn around velocities.
QPointF commands
The velocities sent as commands.
QPointF velocities
The velocities from the odometry.