overview.cpp
Go to the documentation of this file.
1 
9 #include <gui/overview.hpp>
10 #include <QGraphicsView>
11 #include <QVBoxLayout>
12 
13 QtMotionGUI::QtMotionGUI() : motion_window(), not_first_state(false) {
14  // Set the window's properties
15  motion_window.setWindowTitle("Robot's Motion Overview");
16  motion_window.setGeometry(200, 100, 800, 600);
17  motion_window.setVisible(false);
18  // Add the path scene in a first tab
19  motion_window.addTab(new QGraphicsView(&path_scene),
20  "Motion's Path");
21  // Add the velocities scenes in a second tab
22  QWidget *vel_wdgt = new QWidget();
23  QLayout *vel_layout = new QVBoxLayout(vel_wdgt);
24  vel_layout->addWidget( new QGraphicsView(&trans_vel_scene) );
25  vel_layout->addWidget( new QGraphicsView(&rot_vel_scene) );
26  motion_window.addTab(vel_wdgt, "Motion's Velocities");
27 } // end of QtMotionGUI::QtMotionGUI() -------------------------------
28 
29 void QtMotionGUI::addTrajectory(const std::list<State*>& trajectory) {
30  static const Qt::GlobalColor traj_color = Qt::green;
31  // adds each state of the trajectory, using traj_color
32  for(std::list<State*>::const_iterator it = trajectory.begin();
33  it != trajectory.end(); it++) {
34  addState(**it, traj_color);
35  } // end of for (each state of the trajectory)
36  not_first_state = false;
37 } // end of void QtMotionGUI::addTrajectory(const std::list<State*>&)-
38 
39 void QtMotionGUI::addState(const State& state,
40  const Qt::GlobalColor motion_color) {
41  static const int abscIdx = 0, ordoIdx = abscIdx + 1,
42  timeIdx = ordoIdx + 1, tranIdx = timeIdx + 1, // was previously
43  rotaIdx = tranIdx + 1, nmbrIdx = rotaIdx + 1; // an enum
44  if (not_first_state) {
45  // Setting the color
46  const QPen motion_pen = QColor(motion_color);
47  // Scalling factors
48  static const double factors[nmbrIdx]
49  = {50, 50, 25, 100, 300 / M_PI};
50  // extract the data from the state
51  const iSeeML::rob::OrPtConfig old_q = last_state.configuration(),
52  q = state.configuration();
53  const iSeeML::geom::Point old_P = old_q.position(),
54  P = q.position();
55  // add a new line to the path (and redraw it)
56  path_scene.addLine
57  ( factors[abscIdx] * old_P.xCoord(), - factors[ordoIdx]
58  * old_P.yCoord(), factors[abscIdx] * P.xCoord(),
59  - factors[ordoIdx] * P.yCoord(), motion_pen );
60  // add a new line to the translation velocity profile
61  trans_vel_scene.addLine
62  (factors[timeIdx] * last_state.date(),
63  - factors[tranIdx] * last_state.translationVelocity(),
64  factors[timeIdx] * state.date(),
65  - factors[tranIdx] * state.translationVelocity(), motion_pen);
66  // add a new line to the rotation velocity profile
67  rot_vel_scene.addLine
68  (factors[timeIdx] * last_state.date(),
69  - factors[rotaIdx] * last_state.rotationVelocity(),
70  factors[timeIdx] * state.date(),
71  - factors[rotaIdx] * state.rotationVelocity(), motion_pen);
72  } // end of if (not first state)
73  else {
74  not_first_state = true;
75  } // end of else (first state)
76  // memorize the last state for future drawing
77  last_state = state;
78 } // end of void QtMotionGUI::addState(double[]) ---------------------
79 
81  path_scene.clear();
82  trans_vel_scene.clear();
83  rot_vel_scene.clear();
84  not_first_state = false;
85 } // end of void QtMotionGUI::clear() --------------------------------
QGraphicsScene rot_vel_scene
The scene containing the rotation velocity profile.
Definition: overview.hpp:32
const double & rotationVelocity() const
Gives the rotation velocity of the state.
Definition: state.hpp:81
const iSeeML::rob::OrPtConfig & configuration() const
Gives the configuration of the state.
Definition: state.hpp:67
void addTrajectory(const std::list< State * > &trajectory)
Definition: overview.cpp:29
const double & translationVelocity() const
Gives the translation velocity of the state.
Definition: state.hpp:74
const double & date() const
Gives the configuration of the state.
Definition: state.hpp:61
This class defines a state, i.e. a configuration and its (translation and rotation) velocities...
Definition: state.hpp:22
void addState(const State &state, const Qt::GlobalColor motion_color=Qt::blue)
Definition: overview.cpp:39
QGraphicsScene path_scene
Definition: overview.hpp:28
bool not_first_state
Is next state the first one?
Definition: overview.hpp:34
void clear()
Definition: overview.cpp:80
QTabWidget motion_window
The window containing the displays.
Definition: overview.hpp:27
State last_state
Last state added.
Definition: overview.hpp:35
Qt based overview of the robot&#39;s motion.
QGraphicsScene trans_vel_scene
The scene containing the translation velocity profile.
Definition: overview.hpp:30


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