ARGoS  3
A parallel, multi-engine simulator for swarm robotics
qtopengl_main_window.cpp
Go to the documentation of this file.
1 
7 #include "qtopengl_widget.h"
8 #include "qtopengl_log_stream.h"
10 #include "qtopengl_main_window.h"
11 
12 #include <argos3/core/config.h>
13 #include <argos3/core/utility/plugins/dynamic_loading.h>
14 #include <argos3/core/utility/logging/argos_log.h>
15 #include <argos3/core/simulator/simulator.h>
16 #include <argos3/core/simulator/loop_functions.h>
17 
18 #include <QtCore/QVariant>
19 #include <QtWidgets/QAction>
20 #include <QtWidgets/QApplication>
21 #include <QtWidgets/QDockWidget>
22 #include <QtWidgets/QHeaderView>
23 #include <QtWidgets/QLCDNumber>
24 #include <QtWidgets/QPushButton>
25 #include <QtWidgets/QSpinBox>
26 #include <QtWidgets/QDoubleSpinBox>
27 #include <QtWidgets/QStatusBar>
28 #include <QtWidgets/QWidget>
29 #include <QLabel>
30 #include <QCloseEvent>
31 #include <QMessageBox>
32 #include <QDir>
33 #include <QFile>
34 #include <QTextStream>
35 #include <QToolBar>
36 #include <QLayout>
37 #include <QMenuBar>
38 #include <QSettings>
39 
40 namespace argos {
41 
42  /****************************************/
43  /****************************************/
44 
45  class CQTOpenGLLayout : public QLayout {
46 
47  public:
48 
50  m_pcQTOpenGLItem(NULL) {
51  setContentsMargins(0, 0, 0, 0);
52  }
53 
54  virtual ~CQTOpenGLLayout() {
55  if(m_pcQTOpenGLItem != NULL) {
56  delete m_pcQTOpenGLItem;
57  }
58  }
59 
60  virtual void addItem(QLayoutItem* item) {
61  if(m_pcQTOpenGLItem != NULL) {
62  delete m_pcQTOpenGLItem;
63  }
64  m_pcQTOpenGLItem = item;
65  }
66  virtual int count() const {
67  return (m_pcQTOpenGLItem != NULL) ? 1 : 0;
68  }
69 
70  virtual QLayoutItem* itemAt(int index) const {
71  return (index == 0) ? m_pcQTOpenGLItem : NULL;
72  }
73 
74  virtual QLayoutItem* takeAt(int index) {
75  if(index == 0) {
76  QLayoutItem* pcRetVal = m_pcQTOpenGLItem;
77  m_pcQTOpenGLItem = NULL;
78  return pcRetVal;
79  }
80  else {
81  return NULL;
82  }
83  }
84 
85  virtual QSize minimumSize () const {
86  return QSize(320,240);
87  }
88 
89  virtual QSize sizeHint () const {
90  return QSize(640,480);
91  }
92 
93  virtual void setGeometry(const QRect& r) {
94  /* Set the layout geometry */
95  QLayout::setGeometry(r);
96  if(m_pcQTOpenGLItem != NULL) {
97  /* Calculate the candidate sizes for the QTOpenGL widget */
98  /* One is height-driven */
99  QRect cCandidate1(r.x(), r.y(), (r.height() * 4) / 3, r.height());
100  /* The other is width-driven */
101  QRect cCandidate2(r.x(), r.y(), r.width(), (r.width() * 3) / 4);
102  /* Pick the one that fits the rectangle better */
103  if(r.contains(cCandidate1)) {
104  /* Horizontal padding needed */
105  int nPadding = (r.width() - cCandidate1.width()) / 2;
106  cCandidate1.translate(nPadding, 0);
107  m_pcQTOpenGLItem->setGeometry(cCandidate1);
108  }
109  else {
110  /* Vertical padding needed */
111  int nPadding = (r.height() - cCandidate2.height()) / 2;
112  cCandidate2.translate(0, nPadding);
113  m_pcQTOpenGLItem->setGeometry(cCandidate2);
114  }
115  }
116  }
117 
118  private:
119 
120  QLayoutItem* m_pcQTOpenGLItem;
121 
122  };
123 
124  /****************************************/
125  /****************************************/
126 
128  m_pcUserFunctions(NULL) {
129  /* Main window settings */
130  std::string strTitle;
131  GetNodeAttributeOrDefault<std::string>(t_tree, "title", strTitle, "ARGoS v" ARGOS_VERSION "-" ARGOS_RELEASE);
132  setWindowTitle(tr(strTitle.c_str()));
133  /* Restore settings, if any */
134  ReadSettingsPreCreation();
135  /* Add a status bar */
136  m_pcStatusbar = new QStatusBar(this);
137  setStatusBar(m_pcStatusbar);
138  /* Create actions */
139  CreateExperimentActions();
140  CreateCameraActions();
141  // CreatePOVRayActions();
142  CreateHelpActions();
143  /* Create user functions */
144  CreateUserFunctions(t_tree);
145  /* Create the central widget */
146  CreateOpenGLWidget(t_tree);
147  /* Create menus */
148  CreateExperimentMenu();
149  CreateCameraMenu();
150  // CreatePOVRayMenu();
151  CreateHelpMenu();
152  /* Create toolbars */
153  CreateExperimentToolBar();
154  CreateCameraToolBar();
155  /* Create the message dock window */
156  CreateLogMessageDock();
157  /* Restore settings, if any */
158  ReadSettingsPostCreation();
159  /* Creates the signal/slot connections */
160  CreateConnections();
161  /* Set experiment state */
162  m_eExperimentState = EXPERIMENT_INITIALIZED;
163  /* Should we play instantly? */
164  bool bAutoPlay = false;
165  GetNodeAttributeOrDefault(t_tree, "autoplay", bAutoPlay, bAutoPlay);
166  if(bAutoPlay) {
167  PlayExperiment();
168  }
169  }
170 
171  /****************************************/
172  /****************************************/
173 
175  delete m_pcUserFunctions;
176  delete m_pcLogStream;
177  delete m_pcLogErrStream;
178  if(m_bWasLogColored) {
181  }
182  }
183 
184  /****************************************/
185  /****************************************/
186 
187  void CQTOpenGLMainWindow::ReadSettingsPreCreation() {
188  QSettings cSettings;
189  cSettings.beginGroup("MainWindow");
190  resize(cSettings.value("size", QSize(640,480)).toSize());
191  move(cSettings.value("position", QPoint(0,0)).toPoint());
192  if(cSettings.contains("icon_dir")) {
193  m_strIconDir = cSettings.value("icon_dir").toString();
194  if(m_strIconDir.at(m_strIconDir.length()-1) != '/') {
195  m_strIconDir.append("/");
196  }
197  }
198  else {
199  m_strIconDir = QString::fromStdString(CSimulator::GetInstance().GetInstallationDirectory());
200  m_strIconDir += "/include/argos3/plugins/simulator/visualizations/qt-opengl/icons/";
201  }
202  if(cSettings.contains("texture_dir")) {
203  m_strTextureDir = cSettings.value("texture_dir").toString();
204  if(m_strTextureDir.at(m_strTextureDir.length()-1) != '/') {
205  m_strTextureDir.append("/");
206  }
207  }
208  else {
209  m_strTextureDir = QString::fromStdString(CSimulator::GetInstance().GetInstallationDirectory());
210  m_strTextureDir += "/include/argos3/plugins/simulator/visualizations/qt-opengl/textures/";
211  }
212  cSettings.endGroup();
213  }
214 
215  /****************************************/
216  /****************************************/
217 
218  void CQTOpenGLMainWindow::ReadSettingsPostCreation() {
219  QSettings cSettings;
220  cSettings.beginGroup("MainWindow");
221  restoreState(cSettings.value("docks").toByteArray());
222  cSettings.endGroup();
223  }
224 
225  /****************************************/
226  /****************************************/
227 
228  void CQTOpenGLMainWindow::WriteSettings() {
229  QSettings cSettings;
230  cSettings.beginGroup("MainWindow");
231  cSettings.setValue("docks", saveState());
232  cSettings.setValue("size", size());
233  cSettings.setValue("position", pos());
234  cSettings.setValue("icon_dir", m_strIconDir);
235  cSettings.setValue("texture_dir", m_strTextureDir);
236  cSettings.endGroup();
237  }
238 
239  /****************************************/
240  /****************************************/
241 
242  void CQTOpenGLMainWindow::CreateExperimentActions() {
243  /* Add the play action */
244  QIcon cPlayIcon;
245  cPlayIcon. addPixmap(QPixmap(m_strIconDir + "/play.png"));
246  m_pcPlayAction = new QAction(cPlayIcon, tr("&Play"), this);
247  m_pcPlayAction->setShortcut(Qt::Key_P);
248  m_pcPlayAction->setToolTip(tr("Play experiment"));
249  m_pcPlayAction->setStatusTip(tr("Play experiment"));
250  if(! CSimulator::GetInstance().IsRealTimeClock()) {
251  /* Add the step action */
252  QIcon cStepIcon;
253  cStepIcon.addPixmap(QPixmap(m_strIconDir + "/step.png"));
254  m_pcStepAction = new QAction(cStepIcon, tr("&Step"), this);
255  m_pcStepAction->setToolTip(tr("Step experiment"));
256  m_pcStepAction->setStatusTip(tr("Step experiment"));
257  m_pcStepAction->setShortcut(Qt::Key_X);
258  /* Add the fast forward action */
259  QIcon cFastForwardIcon;
260  cFastForwardIcon.addPixmap(QPixmap(m_strIconDir + "/fast_forward.png"));
261  m_pcFastForwardAction = new QAction(cFastForwardIcon, tr("&Fast Forward"), this);
262  m_pcFastForwardAction->setToolTip(tr("Fast forward experiment"));
263  m_pcFastForwardAction->setStatusTip(tr("Fast forward experiment"));
264  m_pcFastForwardAction->setShortcut(Qt::Key_F);
265  /* Add the pause action */
266  QIcon cPauseIcon;
267  cPauseIcon. addPixmap(QPixmap(m_strIconDir + "/pause.png"));
268  m_pcPauseAction = new QAction(cPauseIcon, tr("&Pause"), this);
269  m_pcPauseAction->setShortcut(Qt::Key_O);
270  m_pcPauseAction->setToolTip(tr("Pause experiment"));
271  m_pcPauseAction->setStatusTip(tr("Pause experiment"));
272  m_pcPauseAction->setEnabled(false);
273  }
274  /* Add the terminate action */
275  QIcon cTerminateIcon;
276  cTerminateIcon.addPixmap(QPixmap(m_strIconDir + "/stop.png"));
277  m_pcTerminateAction = new QAction(cTerminateIcon, tr("&Terminate"), this);
278  m_pcTerminateAction->setShortcut(Qt::Key_T);
279  m_pcTerminateAction->setToolTip(tr("Terminate experiment"));
280  m_pcTerminateAction->setStatusTip(tr("Terminate experiment"));
281  m_pcTerminateAction->setEnabled(false);
282  /* Add the reset action */
283  QIcon cResetIcon;
284  cResetIcon.addPixmap(QPixmap(m_strIconDir + "/reset.png"));
285  m_pcResetAction = new QAction(cResetIcon, tr("&Reset"), this);
286  m_pcResetAction->setToolTip(tr("Reset experiment"));
287  m_pcResetAction->setStatusTip(tr("Reset experiment"));
288  m_pcResetAction->setShortcut(Qt::Key_R);
289  m_pcResetAction->setEnabled(false);
290  /* Add the capture action */
291  QIcon cCaptureIcon;
292  cCaptureIcon.addPixmap(QPixmap(m_strIconDir + "/record.png"));
293  m_pcCaptureAction = new QAction(cCaptureIcon, tr("&Capture"), this);
294  m_pcCaptureAction->setToolTip(tr("Capture frames"));
295  m_pcCaptureAction->setStatusTip(tr("Capture frames"));
296  m_pcCaptureAction->setCheckable(true);
297  m_pcCaptureAction->setShortcut(Qt::Key_C);
298  /* Add the quit action */
299  m_pcQuitAction = new QAction(tr("&Quit"), this);
300  m_pcQuitAction->setStatusTip(tr("Quit the simulator"));
301  }
302 
303  /****************************************/
304  /****************************************/
305 
306  void CQTOpenGLMainWindow::CreateCameraActions() {
307  /* Add the switch camera buttons */
308  m_pcSwitchCameraActionGroup = new QActionGroup(this);
309  QIcon cCameraIcon;
310  cCameraIcon.addPixmap(QPixmap(m_strIconDir + "/camera.png"));
311  for(UInt32 i = 0; i < 12; ++i) {
312  QAction* pcAction = new QAction(cCameraIcon, tr(QString("Camera %1").arg(i+1).toLatin1().data()), m_pcSwitchCameraActionGroup);
313  pcAction->setToolTip(tr(QString("Switch to camera %1").arg(i+1).toLatin1().data()));
314  pcAction->setStatusTip(tr(QString("Switch to camera %1").arg(i+1).toLatin1().data()));
315  pcAction->setCheckable(true);
316  pcAction->setShortcut(Qt::Key_F1 + i);
317  pcAction->setData(i);
318  m_pcSwitchCameraActions.push_back(pcAction);
319  }
320  m_pcSwitchCameraActions.first()->setChecked(true);
321  /* Add the show camera XML button */
322  m_pcShowCameraXMLAction = new QAction(tr("&Show XML..."), this);
323  m_pcShowCameraXMLAction->setStatusTip(tr("Show XML configuration for all cameras"));
324  }
325 
326  /****************************************/
327  /****************************************/
328 
329  // void CQTOpenGLMainWindow::CreatePOVRayActions() {
330  // /* Add the POVRay XML button */
331  // QIcon cPOVRayXMLIcon;
332  // m_pcPOVRayXMLAction = new QAction(cPOVRayXMLIcon, tr("&Edit XML"), this);
333  // m_pcPOVRayXMLAction->setToolTip(tr("Edit POV-Ray XML configuration"));
334  // m_pcPOVRayXMLAction->setStatusTip(tr("Edit POV-Ray XML configuration"));
335  // /* Add the POVRay Preview button */
336  // QIcon cPOVRayPreviewIcon;
337  // m_pcPOVRayPreviewAction = new QAction(cPOVRayPreviewIcon, tr("&Preview"), this);
338  // m_pcPOVRayPreviewAction->setToolTip(tr("Preview POV-Ray rendering of this scene"));
339  // m_pcPOVRayPreviewAction->setStatusTip(tr("Preview POV-Ray rendering of this scene"));
340  // }
341 
342  /****************************************/
343  /****************************************/
344 
345  void CQTOpenGLMainWindow::CreateHelpActions() {
346  /* Add the 'about qt' button */
347  m_pcAboutQTAction = new QAction(tr("About &Qt"), this);
348  m_pcAboutQTAction->setStatusTip(tr("Show the Qt library's About box"));
349  }
350 
351  /****************************************/
352  /****************************************/
353 
354  void CQTOpenGLMainWindow::CreateExperimentToolBar() {
355  m_pcExperimentToolBar = addToolBar(tr("Experiment"));
356  m_pcExperimentToolBar->setObjectName("ExperimentToolBar");
357  m_pcExperimentToolBar->setIconSize(QSize(32,32));
358  m_pcCurrentStepLCD = new QLCDNumber(m_pcExperimentToolBar);
359  m_pcCurrentStepLCD->setToolTip(tr("Current step"));
360  m_pcCurrentStepLCD->setDigitCount(6);
361  m_pcCurrentStepLCD->setSegmentStyle(QLCDNumber::Flat);
362  m_pcExperimentToolBar->addWidget(m_pcCurrentStepLCD);
363  m_pcExperimentToolBar->addSeparator();
364  if(! CSimulator::GetInstance().IsRealTimeClock()) {
365  m_pcExperimentToolBar->addAction(m_pcStepAction);
366  }
367  m_pcExperimentToolBar->addAction(m_pcPlayAction);
368  if(! CSimulator::GetInstance().IsRealTimeClock()) {
369  m_pcExperimentToolBar->addAction(m_pcPauseAction);
370  m_pcExperimentToolBar->addAction(m_pcFastForwardAction);
371  m_pcDrawFrameEvery = new QSpinBox(m_pcExperimentToolBar);
372  m_pcDrawFrameEvery->setToolTip(tr("Draw frame every X steps when in fast-forward"));
373  m_pcDrawFrameEvery->setMinimum(1);
374  m_pcDrawFrameEvery->setMaximum(999);
375  m_pcDrawFrameEvery->setValue(1);
376  m_pcExperimentToolBar->addWidget(m_pcDrawFrameEvery);
377  }
378  m_pcExperimentToolBar->addSeparator();
379  m_pcExperimentToolBar->addAction(m_pcTerminateAction);
380  m_pcExperimentToolBar->addAction(m_pcResetAction);
381  m_pcExperimentToolBar->addSeparator();
382  m_pcExperimentToolBar->addAction(m_pcCaptureAction);
383  }
384 
385  /****************************************/
386  /****************************************/
387 
388  void CQTOpenGLMainWindow::CreateExperimentMenu() {
389  m_pcExperimentMenu = menuBar()->addMenu(tr("&Experiment"));
390  m_pcExperimentMenu->addAction(m_pcPlayAction);
391  if(! CSimulator::GetInstance().IsRealTimeClock()) {
392  m_pcExperimentMenu->addAction(m_pcPauseAction);
393  m_pcExperimentMenu->addAction(m_pcFastForwardAction);
394  m_pcExperimentMenu->addAction(m_pcStepAction);
395  }
396  m_pcExperimentMenu->addSeparator();
397  m_pcExperimentMenu->addAction(m_pcTerminateAction);
398  m_pcExperimentMenu->addAction(m_pcResetAction);
399  m_pcExperimentMenu->addSeparator();
400  m_pcExperimentMenu->addAction(m_pcCaptureAction);
401  m_pcExperimentMenu->addSeparator();
402  m_pcExperimentMenu->addAction(m_pcQuitAction);
403  }
404 
405  /****************************************/
406  /****************************************/
407 
408  void CQTOpenGLMainWindow::CreateCameraToolBar() {
409  m_pcCameraToolBar = new QToolBar(tr("Camera"));
410  m_pcCameraToolBar->setAllowedAreas(Qt::LeftToolBarArea |
411  Qt::RightToolBarArea |
412  Qt::BottomToolBarArea);
413  m_pcCameraToolBar->setObjectName("CameraToolBar");
414  m_pcCameraToolBar->setIconSize(QSize(32,32));
415  m_pcCameraToolBar->addActions(m_pcSwitchCameraActions);
416  m_pcCameraToolBar->addSeparator();
417  m_pcFocalLength = new QDoubleSpinBox(m_pcCameraToolBar);
418  m_pcFocalLength->setToolTip(tr("Set the focal length of the current camera"));
419  m_pcFocalLength->setSuffix("mm");
420  m_pcFocalLength->setDecimals(1);
421  m_pcFocalLength->setSingleStep(1.0f);
422  m_pcFocalLength->setRange(1.0f, 999.0f);
423  m_pcFocalLength->setValue(m_pcOpenGLWidget->GetCamera().GetSetting(0).LensFocalLength * 1000.0f);
424  m_pcCameraToolBar->addWidget(m_pcFocalLength);
425  addToolBar(Qt::LeftToolBarArea, m_pcCameraToolBar);
426  }
427 
428  /****************************************/
429  /****************************************/
430 
431  void CQTOpenGLMainWindow::CreateCameraMenu() {
432  m_pcCameraMenu = menuBar()->addMenu(tr("&Camera"));
433  m_pcCameraMenu->addActions(m_pcSwitchCameraActions);
434  m_pcCameraMenu->addAction(m_pcShowCameraXMLAction);
435  }
436 
437  /****************************************/
438  /****************************************/
439 
440  // void CQTOpenGLMainWindow::CreatePOVRayMenu() {
441  // m_pcPOVRayMenu = menuBar()->addMenu(tr("&POVRay"));
442  // m_pcPOVRayMenu->addAction(m_pcPOVRayPreviewAction);
443  // m_pcPOVRayMenu->addAction(m_pcPOVRayXMLAction);
444  // }
445 
446  /****************************************/
447  /****************************************/
448 
449  void CQTOpenGLMainWindow::CreateHelpMenu() {
450  m_pcHelpMenu = menuBar()->addMenu(tr("&?"));
451  m_pcHelpMenu->addAction(m_pcAboutQTAction);
452  }
453 
454  /****************************************/
455  /****************************************/
456 
457  void CQTOpenGLMainWindow::CreateOpenGLWidget(TConfigurationNode& t_tree) {
458  /* Create the surface format */
459  QSurfaceFormat cFormat = QSurfaceFormat::defaultFormat();
460  cFormat.setSamples(4);
461  cFormat.setDepthBufferSize(24);
462  /* Create the widget */
463  QWidget* pcPlaceHolder = new QWidget(this);
464  m_pcOpenGLWidget = new CQTOpenGLWidget(pcPlaceHolder, *this, *m_pcUserFunctions);
465  m_pcOpenGLWidget->setFormat(cFormat);
466  m_pcOpenGLWidget->setCursor(QCursor(Qt::OpenHandCursor));
467  m_pcOpenGLWidget->GetCamera().Init(t_tree);
468  m_pcOpenGLWidget->GetFrameGrabData().Init(t_tree);
469  /* Invert mouse controls? */
470  bool bInvertMouse;
471  GetNodeAttributeOrDefault(t_tree, "invert_mouse", bInvertMouse, false);
472  m_pcOpenGLWidget->SetInvertMouse(bInvertMouse);
473  /* Set the window as the central widget */
474  CQTOpenGLLayout* pcQTOpenGLLayout = new CQTOpenGLLayout();
475  pcQTOpenGLLayout->addWidget(m_pcOpenGLWidget);
476  pcPlaceHolder->setLayout(pcQTOpenGLLayout);
477  setCentralWidget(pcPlaceHolder);
478  /* Initialize the user functions */
479  if(NodeExists(t_tree, "user_functions")) {
480  /* Use the passed user functions */
481  /* Get data from XML */
482  TConfigurationNode tNode = GetNode(t_tree, "user_functions");
483  m_pcUserFunctions->Init(tNode);
484  }
485  }
486 
487  /****************************************/
488  /****************************************/
489 
490  void CQTOpenGLMainWindow::CreateLogMessageDock() {
491  /* Store the log color flag to be able to restore at exit */
492  m_bWasLogColored = LOG.IsColoredOutput();
493  /* Create a dockable window */
494  m_pcLogDock = new QDockWidget(tr("Log"), this);
495  m_pcLogDock->setObjectName("LogDockWindow");
496  m_pcLogDock->setFeatures(QDockWidget::DockWidgetMovable |
497  QDockWidget::DockWidgetFloatable);
498  m_pcLogDock->setAllowedAreas(Qt::LeftDockWidgetArea |
499  Qt::RightDockWidgetArea |
500  Qt::BottomDockWidgetArea);
501  /* Create a textual window to be used as a buffer */
502  m_pcDockLogBuffer = new QTextEdit();
503  m_pcDockLogBuffer->setReadOnly(true);
504  LOG.Flush(); /* Write all the pending stuff */
505  LOG.DisableColoredOutput(); /* Colors are not necessary */
506  m_pcDockLogBuffer->append("<b>[t=0]</b> Log started."); /* Write something in the buffer */
507  /* Redirect stdout to the buffer */
508  m_pcLogStream = new CQTOpenGLLogStream(LOG.GetStream(), m_pcDockLogBuffer);
509  /* Add the dockable window to the main widget */
510  m_pcLogDock->setWidget(m_pcDockLogBuffer);
511  addDockWidget(Qt::RightDockWidgetArea, m_pcLogDock);
512  /* Create a dockable window */
513  m_pcLogErrDock = new QDockWidget(tr("LogErr"), this);
514  m_pcLogErrDock->setObjectName("LogErrDockWindow");
515  m_pcLogErrDock->setFeatures(QDockWidget::DockWidgetMovable |
516  QDockWidget::DockWidgetFloatable);
517  m_pcLogErrDock->setAllowedAreas(Qt::LeftDockWidgetArea |
518  Qt::RightDockWidgetArea |
519  Qt::BottomDockWidgetArea);
520  /* Create a textual window to be used as a buffer */
521  m_pcDockLogErrBuffer = new QTextEdit();
522  m_pcDockLogErrBuffer->setReadOnly(true);
523  LOGERR.Flush(); /* Write all the pending stuff */
524  LOGERR.DisableColoredOutput(); /* Colors are not necessary */
525  m_pcDockLogErrBuffer->append("<b>[t=0]</b> LogErr started."); /* Write something in the buffer */
526  /* Redirect stderr to the buffer */
527  m_pcLogErrStream = new CQTOpenGLLogStream(LOGERR.GetStream(), m_pcDockLogErrBuffer);
528  m_pcLogErrDock->setWidget(m_pcDockLogErrBuffer);
529  /* Add the dockable window to the main widget */
530  addDockWidget(Qt::RightDockWidgetArea, m_pcLogErrDock);
531 
532  }
533 
534  /****************************************/
535  /****************************************/
536 
537  void CQTOpenGLMainWindow::CreateConnections() {
538  /* Play button pressed */
539  connect(m_pcPlayAction, SIGNAL(triggered()),
540  this, SLOT(PlayExperiment()));
541  /* Reset button pressed */
542  connect(m_pcResetAction, SIGNAL(triggered()),
543  this, SLOT(ResetExperiment()));
544  /* A experiment step has been completed */
545  connect(m_pcOpenGLWidget, SIGNAL(StepDone(int)),
546  m_pcCurrentStepLCD, SLOT(display(int)));
547  /* The experiment has been completed */
548  connect(m_pcOpenGLWidget, SIGNAL(ExperimentDone()),
549  this, SLOT(TerminateExperiment()));
550  /* The experiment has been completed */
551  connect(m_pcTerminateAction, SIGNAL(triggered()),
552  this, SLOT(TerminateExperiment()));
553  if(! CSimulator::GetInstance().IsRealTimeClock()) {
554  /* Pause button pressed */
555  connect(m_pcPauseAction, SIGNAL(triggered()),
556  this, SLOT(PauseExperiment()));
557  /* Step button pressed */
558  connect(m_pcStepAction, SIGNAL(triggered()),
559  this, SLOT(StepExperiment()));
560  /* Fast forward button pressed */
561  connect(m_pcFastForwardAction, SIGNAL(triggered()),
562  this, SLOT(FastForwardExperiment()));
563  /* 'Draw frame every' spin box value changed */
564  connect(m_pcDrawFrameEvery, SIGNAL(valueChanged(int)),
565  m_pcOpenGLWidget, SLOT(SetDrawFrameEvery(int)));
566  }
567  // /* POV-Ray XML button pressed */
568  // connect(m_pcPOVRayXMLAction, SIGNAL(triggered()),
569  // this, SLOT(POVRaySceneXMLPopUp()));
570  // /* POV-Ray XML button pressed */
571  // connect(m_pcPOVRayPreviewAction, SIGNAL(triggered()),
572  // this, SLOT(POVRayScenePreview()));
573  /* Capture button toggled */
574  connect(m_pcCaptureAction, SIGNAL(triggered(bool)),
575  m_pcOpenGLWidget, SLOT(SetGrabFrame(bool)));
576  /* Quit the simulator */
577  connect(m_pcQuitAction, SIGNAL(triggered()),
578  qApp, SLOT(quit()));
579  /* Show the 'About Qt' dialog */
580  connect(m_pcAboutQTAction, SIGNAL(triggered()),
581  qApp, SLOT(aboutQt()));
582  /* Toggle the camera */
583  connect(m_pcSwitchCameraActionGroup, SIGNAL(triggered(QAction*)),
584  this, SLOT(SwitchCamera(QAction*)));
585  connect(this, SIGNAL(CameraSwitched(int)),
586  m_pcOpenGLWidget, SLOT(SetCamera(int)));
587  /* Camera focal length */
588  connect(m_pcFocalLength, SIGNAL(valueChanged(double)),
589  m_pcOpenGLWidget, SLOT(SetCameraFocalLength(double)));
590  /* POV-Ray XML button pressed */
591  connect(m_pcShowCameraXMLAction, SIGNAL(triggered()),
592  this, SLOT(CameraXMLPopUp()));
593  }
594 
595  /****************************************/
596  /****************************************/
597 
598  void CQTOpenGLMainWindow::CreateUserFunctions(TConfigurationNode& t_tree) {
599  /* Parse XML for user functions */
600  if(NodeExists(t_tree, "user_functions")) {
601  /* Use the passed user functions */
602  /* Get data from XML */
603  TConfigurationNode tNode = GetNode(t_tree, "user_functions");
604  std::string strLabel, strLibrary;
605  GetNodeAttribute(tNode, "label", strLabel);
606  GetNodeAttributeOrDefault(tNode, "library", strLibrary, strLibrary);
607  try {
608  /* Load the library */
609  if(strLibrary != "") {
610  CDynamicLoading::LoadLibrary(strLibrary);
611  }
612  /* Create the user functions */
613  m_pcUserFunctions = CFactory<CQTOpenGLUserFunctions>::New(strLabel);
614  m_pcUserFunctions->SetMainWindow(*this);
615  }
616  catch(CARGoSException& ex) {
617  THROW_ARGOSEXCEPTION_NESTED("Failed opening QTOpenGL user function library", ex);
618  }
619  }
620  else {
621  /* Use standard (empty) user functions */
622  m_pcUserFunctions = new CQTOpenGLUserFunctions;
623  m_pcUserFunctions->SetMainWindow(*this);
624  }
625  }
626 
627  /****************************************/
628  /****************************************/
629 
630  void CQTOpenGLMainWindow::closeEvent(QCloseEvent* pc_event) {
631  m_pcUserFunctions->Destroy();
632  WriteSettings();
633  pc_event->accept();
634  }
635 
636  /****************************************/
637  /****************************************/
638 
640  /* Make sure we are in the right state */
641  if(m_eExperimentState != EXPERIMENT_INITIALIZED &&
642  m_eExperimentState != EXPERIMENT_PAUSED) {
643  LOGERR << "[BUG] CQTOpenGLMainWindow::PlayExperiment() called in wrong state: "
644  << m_eExperimentState
645  << std::endl;
646  LOGERR.Flush();
647  return;
648  }
649  /* Toggle action states */
650  m_pcPlayAction->setEnabled(false);
651  m_pcResetAction->setEnabled(false);
652  m_pcTerminateAction->setEnabled(true);
653  if(! CSimulator::GetInstance().IsRealTimeClock()) {
654  m_pcPauseAction->setEnabled(true);
655  m_pcFastForwardAction->setEnabled(false);
656  m_pcStepAction->setEnabled(false);
657  }
658  /* Call OpenGL widget */
659  m_pcOpenGLWidget->PlayExperiment();
660  /* Change state and emit signals */
661  m_eExperimentState = EXPERIMENT_PLAYING;
662  if(m_eExperimentState == EXPERIMENT_INITIALIZED) {
663  /* The experiment has just been started */
664  emit ExperimentStarted();
665  }
666  emit ExperimentPlaying();
667  }
668 
669  /****************************************/
670  /****************************************/
671 
673  /* Make sure we are in the right state */
674  if(m_eExperimentState != EXPERIMENT_INITIALIZED &&
675  m_eExperimentState != EXPERIMENT_PAUSED) {
676  LOGERR << "[BUG] CQTOpenGLMainWindow::FastForwardExperiment() called in wrong state: "
677  << m_eExperimentState
678  << std::endl;
679  LOGERR.Flush();
680  return;
681  }
682  /* Toggle action states */
683  m_pcPlayAction->setEnabled(false);
684  m_pcPauseAction->setEnabled(true);
685  m_pcResetAction->setEnabled(false);
686  m_pcTerminateAction->setEnabled(true);
687  m_pcFastForwardAction->setEnabled(false);
688  m_pcStepAction->setEnabled(false);
689  /* Call OpenGL widget */
690  m_pcOpenGLWidget->FastForwardExperiment();
691  /* Change state and emit signals */
692  m_eExperimentState = EXPERIMENT_FAST_FORWARDING;
693  if(m_eExperimentState == EXPERIMENT_INITIALIZED) {
694  /* The experiment has just been started */
695  emit ExperimentStarted();
696  }
698  }
699 
700  /****************************************/
701  /****************************************/
702 
704  /* Make sure we are in the right state */
705  if(m_eExperimentState != EXPERIMENT_INITIALIZED &&
706  m_eExperimentState != EXPERIMENT_PAUSED) {
707  LOGERR << "[BUG] CQTOpenGLMainWindow::StepExperiment() called in wrong state: "
708  << m_eExperimentState
709  << std::endl;
710  LOGERR.Flush();
711  return;
712  }
713  /* Toggle action states */
714  m_pcPlayAction->setEnabled(true);
715  m_pcResetAction->setEnabled(false);
716  m_pcTerminateAction->setEnabled(true);
717  m_pcFastForwardAction->setEnabled(true);
718  m_pcStepAction->setEnabled(true);
719  /* Call OpenGL widget */
720  m_pcOpenGLWidget->StepExperiment();
721  /* Change state and emit signals */
722  m_eExperimentState = EXPERIMENT_PAUSED;
723  emit ExperimentPaused();
724  }
725 
726  /****************************************/
727  /****************************************/
728 
730  /* Make sure we are in the right state */
731  if(m_eExperimentState != EXPERIMENT_PLAYING &&
732  m_eExperimentState != EXPERIMENT_FAST_FORWARDING) {
733  LOGERR << "[BUG] CQTOpenGLMainWindow::PauseExperiment() called in wrong state: "
734  << m_eExperimentState
735  << std::endl;
736  LOGERR.Flush();
737  return;
738  }
739  /* Toggle action states */
740  m_pcPlayAction->setEnabled(true);
741  m_pcResetAction->setEnabled(false);
742  m_pcTerminateAction->setEnabled(true);
743  if(! CSimulator::GetInstance().IsRealTimeClock()) {
744  m_pcPauseAction->setEnabled(false);
745  m_pcFastForwardAction->setEnabled(true);
746  m_pcStepAction->setEnabled(true);
747  }
748  /* Call OpenGL widget */
749  m_pcOpenGLWidget->PauseExperiment();
750  /* Change state and emit signals */
751  m_eExperimentState = EXPERIMENT_PAUSED;
752  emit ExperimentPaused();
753  }
754 
755  /****************************************/
756  /****************************************/
757 
759  /* Make sure we are in the right state */
760  if(m_eExperimentState != EXPERIMENT_PLAYING &&
761  m_eExperimentState != EXPERIMENT_PAUSED &&
762  m_eExperimentState != EXPERIMENT_FAST_FORWARDING &&
763  m_eExperimentState != EXPERIMENT_SUSPENDED) {
764  LOGERR << "[BUG] CQTOpenGLMainWindow::TerminateExperiment() called in wrong state: "
765  << m_eExperimentState
766  << std::endl;
767  LOGERR.Flush();
768  return;
769  }
770  /* Call OpenGL widget */
771  m_pcOpenGLWidget->PauseExperiment();
772  /* Toggle action states */
773  m_pcPlayAction->setEnabled(false);
774  m_pcResetAction->setEnabled(true);
775  m_pcTerminateAction->setEnabled(false);
776  m_pcCaptureAction->setEnabled(false);
777  m_pcCaptureAction->setChecked(false);
778  if(! CSimulator::GetInstance().IsRealTimeClock()) {
779  m_pcPauseAction->setEnabled(false);
780  m_pcStepAction->setEnabled(false);
781  m_pcFastForwardAction->setEnabled(false);
782  }
783  /* Call ARGoS to terminate the experiment */
786  LOG.Flush();
787  LOGERR.Flush();
788  /* Change state and emit signal */
789  m_eExperimentState = EXPERIMENT_DONE;
790  emit ExperimentDone();
791  }
792 
793  /****************************************/
794  /****************************************/
795 
797  /* Make sure we are in the right state */
798  if(m_eExperimentState != EXPERIMENT_SUSPENDED &&
799  m_eExperimentState != EXPERIMENT_DONE) {
800  LOGERR << "[BUG] CQTOpenGLMainWindow::ResetExperiment() called in wrong state: "
801  << m_eExperimentState
802  << std::endl;
803  LOGERR.Flush();
804  return;
805  }
806  /* Toggle action states */
807  m_pcPlayAction->setEnabled(true);
808  m_pcResetAction->setEnabled(false);
809  m_pcTerminateAction->setEnabled(false);
810  m_pcCaptureAction->setEnabled(true);
811  m_pcCaptureAction->setChecked(false);
812  if(! CSimulator::GetInstance().IsRealTimeClock()) {
813  m_pcPauseAction->setEnabled(false);
814  m_pcStepAction->setEnabled(true);
815  m_pcFastForwardAction->setEnabled(true);
816  }
817  /* Reset step counter and log */
818  m_pcCurrentStepLCD->display(0);
819  m_pcDockLogBuffer->setHtml("<b>[t=0]</b> Log restarted.");
820  m_pcDockLogErrBuffer->setHtml("<b>[t=0]</b> LogErr restarted.");
821  /* Call OpenGL widget */
822  m_pcOpenGLWidget->ResetExperiment();
823  m_pcUserFunctions->Reset();
824  /* Change state and emit signal */
825  m_eExperimentState = EXPERIMENT_INITIALIZED;
826  emit ExperimentReset();
827  }
828 
829  /****************************************/
830  /****************************************/
831 
833  /* Toggle action states */
834  m_pcPlayAction->setEnabled(false);
835  m_pcResetAction->setEnabled(true);
836  m_pcTerminateAction->setEnabled(true);
837  m_pcCaptureAction->setEnabled(false);
838  m_pcCaptureAction->setChecked(false);
839  if(! CSimulator::GetInstance().IsRealTimeClock()) {
840  m_pcPauseAction->setEnabled(false);
841  m_pcStepAction->setEnabled(false);
842  m_pcFastForwardAction->setEnabled(false);
843  }
844  /* Call OpenGL widget */
845  m_pcOpenGLWidget->PauseExperiment();
846  /* Change state and emit signal */
847  m_eExperimentState = EXPERIMENT_SUSPENDED;
848  emit ExperimentSuspended();
849  }
850 
851  /****************************************/
852  /****************************************/
853 
855  /* Make sure we are in the right state */
856  if(m_eExperimentState != EXPERIMENT_SUSPENDED) {
857  LOGERR << "[BUG] CQTOpenGLMainWindow::ResumeExperiment() called in wrong state: "
858  << m_eExperimentState
859  << std::endl;
860  LOGERR.Flush();
861  return;
862  }
863  /* Toggle action states */
864  m_pcPlayAction->setEnabled(true);
865  m_pcResetAction->setEnabled(false);
866  m_pcTerminateAction->setEnabled(false);
867  m_pcCaptureAction->setEnabled(true);
868  if(! CSimulator::GetInstance().IsRealTimeClock()) {
869  m_pcStepAction->setEnabled(true);
870  m_pcFastForwardAction->setEnabled(true);
871  }
872  /* Change state and emit signal */
873  m_eExperimentState = EXPERIMENT_PAUSED;
874  emit ExperimentResumed();
875  }
876 
877  /****************************************/
878  /****************************************/
879 
881  /* Set the text window up */
882  QTextEdit* pcXMLOutput = new QTextEdit();
883  /* Calculate the geometry of the window so that it's 1/4 of the main window
884  and placed in the exact center of it */
885  QRect cGeom = geometry();
886  cGeom.setBottomRight(geometry().center());
887  cGeom.moveCenter(geometry().center());
888  pcXMLOutput->setGeometry(cGeom);
889  /* This window steals all input */
890  pcXMLOutput->setWindowModality(Qt::ApplicationModal);
891  /* You can't modify its contents (but can copy-paste them) */
892  pcXMLOutput->setReadOnly(true);
893  /* Set nice document name and window title */
894  pcXMLOutput->setDocumentTitle("ARGoS XML camera config");
895  pcXMLOutput->setWindowTitle("ARGoS XML camera config");
896  /* Set the actual text to visualize */
897  pcXMLOutput->setPlainText(GetCameraXMLData());
898  /* Finally, show the resulting window */
899  pcXMLOutput->show();
900  }
901 
902  /****************************************/
903  /****************************************/
904 
905  // void CQTOpenGLMainWindow::POVRaySceneXMLPopUp() {
906  // /* Set the text window up */
907  // QTextEdit* pcPOVRayOutput = new QTextEdit();
908  // /* Calculate the geometry of the window so that it's 1/4 of the main window
909  // and placed in the exact center of it */
910  // QRect cGeom = geometry();
911  // cGeom.setBottomRight(geometry().center());
912  // cGeom.moveCenter(geometry().center());
913  // pcPOVRayOutput->setGeometry(cGeom);
914  // /* This window steals all input */
915  // pcPOVRayOutput->setWindowModality(Qt::ApplicationModal);
916  // /* You can't modify its contents (but can copy-paste them) */
917  // pcPOVRayOutput->setReadOnly(true);
918  // /* Set nice document name and window title */
919  // pcPOVRayOutput->setDocumentTitle("ARGoS-POVRay XML camera config");
920  // pcPOVRayOutput->setWindowTitle("ARGoS-POVRay XML camera config");
921  // /* Set the actual text to visualize */
922  // pcPOVRayOutput->setPlainText(GetPOVRaySceneXMLData());
923  // /* Finally, show the resulting window */
924  // pcPOVRayOutput->show();
925  // }
926 
927  /****************************************/
928  /****************************************/
929 
931  QString strResult("<camera>\n");
932  /* Get a reference to the camera */
933  CQTOpenGLCamera& cCamera = m_pcOpenGLWidget->GetCamera();
934  for(UInt32 i = 0; i < 12; ++i) {
935  /* Get its position and target */
936  const CQTOpenGLCamera::SSettings& sSettings = cCamera.GetSetting(i);
937  const CVector3& cPos = sSettings.Position;
938  const CVector3& cLookAt = sSettings.Target;
939  const CVector3& cUp = sSettings.Up;
940  strResult.append(
941  QString(" <placement idx=\"%1\" position=\"%2,%3,%4\" look_at=\"%5,%6,%7\" up=\"%8,%9,%10\" lens_focal_length=\"%11\" />\n")
942  .arg(i)
943  .arg(cPos.GetX())
944  .arg(cPos.GetY())
945  .arg(cPos.GetZ())
946  .arg(cLookAt.GetX())
947  .arg(cLookAt.GetY())
948  .arg(cLookAt.GetZ())
949  .arg(cUp.GetX())
950  .arg(cUp.GetY())
951  .arg(cUp.GetZ())
952  .arg(sSettings.LensFocalLength * 1000.0f));
953  }
954  strResult.append("</camera>\n");
955  return strResult;
956  }
957 
958  /****************************************/
959  /****************************************/
960 
961  // QString CQTOpenGLMainWindow::GetPOVRaySceneXMLData() {
962  // /* Get the current experiment step */
963  // UInt32 unStep = CSimulator::GetInstance().GetSpace().GetExperimentClock();
964  // /* Get a reference to the camera */
965  // const CQTOpenGLCamera& cCamera = m_pcOpenGLWidget->GetCamera();
966  // /* Get its current position and target */
967  // const CVector3& cPos = cCamera.GetPosition();
968  // const CVector3& cLookAt = cCamera.GetTarget();
969  // /* Get the environment node and its contents from the 'povray_render', if defined */
970  // TConfigurationNode& tExperiment = CSimulator::GetInstance().GetConfigurationRoot();
971  // TConfigurationNode& tVisualization = GetNode(tExperiment, "visualization");
972  // QString strPOVRayEnvironment;
973  // if(NodeExists(tVisualization,"povray_render")) {
974  // TConfigurationNode& tPOVRayVisualization = GetNode(tVisualization, "povray_render");
975  // TConfigurationNode& tPOVRayEnvironment = GetNode(tPOVRayVisualization, "environment");
976  // std::string strPOVRayEnvironmentNodeContent = tPOVRayEnvironment.ToString(tPOVRayEnvironment);
977  // strPOVRayEnvironment = strPOVRayEnvironmentNodeContent.c_str();
978  // }
979 
980  // /* Return the XML portion */
981  // return QString(
982  // "%1\n"
983  // "<scene step=\"%2\">\n"
984  // " <camera type=\"normal\"\n"
985  // " position=\"%3,%4,%5\"\n"
986  // " look_at=\"%6,%7,%8\"\n"
987  // " focal_length=\"%9\" />\n"
988  // "</scene>\n"
989  // )
990  // .arg(strPOVRayEnvironment)
991  // .arg(unStep)
992  // .arg(cPos.GetX())
993  // .arg(cPos.GetY())
994  // .arg(cPos.GetZ())
995  // .arg(cLookAt.GetX())
996  // .arg(cLookAt.GetY())
997  // .arg(cLookAt.GetZ())
998  // .arg(cCamera.GetLensFocalLength() * 1000.0f);
999  // }
1000 
1001  /****************************************/
1002  /****************************************/
1003 
1004  // void CQTOpenGLMainWindow::POVRayScenePreview() {
1005  // try {
1006  // /* Initialize the POV-Ray working directory */
1007  // QDir cDirectory(QDir::tempPath() + "/argos-povray");
1008  // /* Erase it if it exists */
1009  // if(cDirectory.exists()) {
1010  // if(::system(QString("rm -rf %1").arg(cDirectory.absolutePath()).toAscii().data()) != 0) {
1011  // THROW_ARGOSEXCEPTION("Could not remove directory \"" <<
1012  // cDirectory.absolutePath().toAscii().data() << "\".");
1013  // }
1014  // }
1015  // /* Create the directory */
1016  // if(::system(QString("mkdir %1").arg(cDirectory.absolutePath()).toAscii().data()) != 0) {
1017  // THROW_ARGOSEXCEPTION("Could not create directory \"" <<
1018  // cDirectory.absolutePath().toAscii().data() << "\".");
1019  // }
1020  // /* Now create the XML file that will contain the POV-Ray scene configuration */
1021  // QFile cPOVRayXMLConf(cDirectory.absolutePath() + "/argos-povray.xml");
1022  // cPOVRayXMLConf.open(QFile::WriteOnly | QFile::Truncate);
1023  // /* Associate a text stream to perform writing to it */
1024  // QTextStream cPOVRayXMLConfStream(&cPOVRayXMLConf);
1025  // /* Write the configuration */
1026  // cPOVRayXMLConfStream << "<povray_render id=\"pov\" output_folder=\"" << cDirectory.absolutePath() << "\">\n";
1027  // cPOVRayXMLConfStream << GetPOVRaySceneXMLData();
1028  // cPOVRayXMLConfStream << "</povray_render>\n";
1029  // cPOVRayXMLConf.close();
1030  // /* Now parse this file as an ARGoS TConfigurationTree */
1031  // ticpp::Document tPOVRayXMLConfTree(cPOVRayXMLConf.fileName().toAscii().data());
1032  // tPOVRayXMLConfTree.LoadFile();
1033  // /* It's time to create the POV-Ray visualization */
1034  // CPovrayRender cPOVRayRender;
1035  // cPOVRayRender.Init(*tPOVRayXMLConfTree.FirstChildElement());
1036  // /* Write the .pov frame file */
1037  // cPOVRayRender.WriteOneFrame(cDirectory.absolutePath().append("/pov/frame.pov").toAscii().data());
1038  // /* Eventually, call POV-Ray to render the file */
1039  // if(::system(QString("cd %1 && ")
1040  // .arg(cDirectory.absolutePath())
1041  // .append("./render_single_frame_on_pc.sh pov/frame.pov")
1042  // .toAscii().data()) !=0) {
1043  // THROW_ARGOSEXCEPTION("Could not create POV-Ray preview");
1044  // }
1045  // }
1046  // catch(CARGoSException& ex) {
1047  // QString strError = QString("Error creating POV-Ray preview\n%1").arg(QString(ex.what()));
1048  // QMessageBox::critical(this,
1049  // tr("ARGoS v2.0"),
1050  // strError,
1051  // QMessageBox::Ok);
1052  // }
1053  // }
1054 
1055  /****************************************/
1056  /****************************************/
1057 
1058  void CQTOpenGLMainWindow::SwitchCamera(QAction* pc_action) {
1059  emit CameraSwitched(pc_action->data().toInt());
1060  m_pcFocalLength->setValue(m_pcOpenGLWidget->GetCamera().GetActiveSettings().LensFocalLength * 1000.0f);
1061  }
1062 
1063  /****************************************/
1064  /****************************************/
1065 
1066 }
argos::CQTOpenGLCamera::SSettings::LensFocalLength
Real LensFocalLength
The focal length of the lens (if this was a real camera)
Definition: qtopengl_camera.h:49
argos::CQTOpenGLUserFunctions::Destroy
virtual void Destroy()
Undoes whatever was done by Init().
Definition: qtopengl_user_functions.h:90
argos::CVector3::GetZ
Real GetZ() const
Returns the z coordinate of this vector.
Definition: vector3.h:125
argos::CQTOpenGLWidget::SFrameGrabData::Init
void Init(TConfigurationNode &t_tree)
Definition: qtopengl_widget.cpp:1055
argos::CQTOpenGLMainWindow::ResumeExperiment
void ResumeExperiment()
Resumes a suspended experiment.
Definition: qtopengl_main_window.cpp:854
argos::CQTOpenGLWidget::PauseExperiment
void PauseExperiment()
Pauses the experiment.
Definition: qtopengl_widget.cpp:613
argos::CSimulator::GetInstance
static CSimulator & GetInstance()
Returns the instance to the CSimulator class.
Definition: simulator.cpp:87
argos::CQTOpenGLLayout::itemAt
virtual QLayoutItem * itemAt(int index) const
Definition: qtopengl_main_window.cpp:70
argos::CQTOpenGLLayout::takeAt
virtual QLayoutItem * takeAt(int index)
Definition: qtopengl_main_window.cpp:74
argos::LOG
CARGoSLog LOG(std::cout, SLogColor(ARGOS_LOG_ATTRIBUTE_BRIGHT, ARGOS_LOG_COLOR_GREEN))
Definition: argos_log.h:179
argos::CSimulator::Terminate
void Terminate()
Puts an end to the simulation.
Definition: simulator.h:283
argos
The namespace containing all the ARGoS related code.
Definition: ci_actuator.h:12
argos::CVector3
A 3D vector class.
Definition: vector3.h:29
qtopengl_log_stream.h
argos::CQTOpenGLMainWindow::ExperimentPaused
void ExperimentPaused()
Emitted when the experiment has been paused.
argos::CQTOpenGLLayout::~CQTOpenGLLayout
virtual ~CQTOpenGLLayout()
Definition: qtopengl_main_window.cpp:54
argos::CQTOpenGLMainWindow::~CQTOpenGLMainWindow
virtual ~CQTOpenGLMainWindow()
Definition: qtopengl_main_window.cpp:174
argos::CQTOpenGLCamera
Definition: qtopengl_camera.h:31
argos::GetNode
TConfigurationNode & GetNode(TConfigurationNode &t_node, const std::string &str_tag)
Given a tree root node, returns the first of its child nodes with the wanted name.
Definition: argos_configuration.h:63
argos::CQTOpenGLLayout::setGeometry
virtual void setGeometry(const QRect &r)
Definition: qtopengl_main_window.cpp:93
argos::CQTOpenGLMainWindow::FastForwardExperiment
void FastForwardExperiment()
Fast forwards the experiment.
Definition: qtopengl_main_window.cpp:672
argos::CQTOpenGLCamera::SSettings::Up
CVector3 Up
The local Z axis of the camera in the global reference frame.
Definition: qtopengl_camera.h:43
argos::CARGoSLog::GetStream
std::ostream & GetStream()
Definition: argos_log.h:122
argos::CQTOpenGLMainWindow::ExperimentSuspended
void ExperimentSuspended()
Emitted when the experiment has been suspended.
argos::LOGERR
CARGoSLog LOGERR(std::cerr, SLogColor(ARGOS_LOG_ATTRIBUTE_BRIGHT, ARGOS_LOG_COLOR_RED))
Definition: argos_log.h:180
argos::CQTOpenGLMainWindow::TerminateExperiment
void TerminateExperiment()
Terminates the execution of the experiment.
Definition: qtopengl_main_window.cpp:758
argos::TConfigurationNode
ticpp::Element TConfigurationNode
The ARGoS configuration XML node.
Definition: argos_configuration.h:27
argos::CDynamicLoading::LoadLibrary
static TDLHandle LoadLibrary(const std::string &str_lib)
Loads a dynamic library.
Definition: dynamic_loading.cpp:66
argos::CVector3::GetX
Real GetX() const
Returns the x coordinate of this vector.
Definition: vector3.h:93
argos::CARGoSLog::EnableColoredOutput
void EnableColoredOutput()
Definition: argos_log.h:110
argos::CFactory::New
static TYPE * New(const std::string &str_label)
Creates a new object of type TYPE
Definition: factory_impl.h:48
argos::CQTOpenGLCamera::SSettings::Position
CVector3 Position
The position of the camera in the global reference frame.
Definition: qtopengl_camera.h:39
argos::CQTOpenGLMainWindow::ResetExperiment
void ResetExperiment()
Resets the state of the experiment to its state right after initialization.
Definition: qtopengl_main_window.cpp:796
argos::CQTOpenGLWidget::FastForwardExperiment
void FastForwardExperiment()
Fast forwards the experiment.
Definition: qtopengl_widget.cpp:603
argos::CARGoSLog::Flush
void Flush()
Definition: argos_log.h:147
argos::CQTOpenGLMainWindow::CQTOpenGLMainWindow
CQTOpenGLMainWindow(TConfigurationNode &t_tree)
Definition: qtopengl_main_window.cpp:127
THROW_ARGOSEXCEPTION_NESTED
#define THROW_ARGOSEXCEPTION_NESTED(message, nested)
This macro throws an ARGoS exception with the passed message and nesting the passed exception.
Definition: argos_exception.h:115
argos::CQTOpenGLMainWindow::StepExperiment
void StepExperiment()
Executes one experiment time step.
Definition: qtopengl_main_window.cpp:703
argos::CQTOpenGLLayout::sizeHint
virtual QSize sizeHint() const
Definition: qtopengl_main_window.cpp:89
argos::CQTOpenGLCamera::GetActiveSettings
SSettings & GetActiveSettings()
Definition: qtopengl_camera.h:116
argos::CLoopFunctions::PostExperiment
virtual void PostExperiment()
Executes user-defined logic when the experiment finishes.
Definition: loop_functions.h:149
argos::CQTOpenGLUserFunctions::SetMainWindow
void SetMainWindow(CQTOpenGLMainWindow &c_main_win)
Sets the QTOpenGL main window for these user functions.
Definition: qtopengl_user_functions.cpp:100
argos::CQTOpenGLMainWindow::ExperimentReset
void ExperimentReset()
Emitted when the experiment has been reset.
argos::CQTOpenGLMainWindow::ExperimentPlaying
void ExperimentPlaying()
Emitted when the experiment has (re)started playing.
argos::CQTOpenGLMainWindow::SwitchCamera
void SwitchCamera(QAction *)
Definition: qtopengl_main_window.cpp:1058
argos::CQTOpenGLMainWindow::ExperimentFastForwarding
void ExperimentFastForwarding()
Emitted when the experiment has (re)started fast-forwarding.
argos::CARGoSLog::DisableColoredOutput
void DisableColoredOutput()
Definition: argos_log.h:114
argos::CQTOpenGLMainWindow::CameraSwitched
void CameraSwitched(int n_camera)
Emitted whenever the user presses a camera button to switch camera.
argos::CSimulator::GetLoopFunctions
CLoopFunctions & GetLoopFunctions()
Returns a reference to the loop functions associated to the current experiment.
Definition: simulator.h:236
argos::NodeExists
bool NodeExists(TConfigurationNode &t_node, const std::string &str_tag)
Given a tree root node, returns true if one of its child nodes has the wanted name.
Definition: argos_configuration.h:44
argos::CQTOpenGLLayout::count
virtual int count() const
Definition: qtopengl_main_window.cpp:66
qtopengl_widget.h
argos::CQTOpenGLUserFunctions::Reset
virtual void Reset()
Resets the resource.
Definition: qtopengl_user_functions.h:89
argos::CQTOpenGLMainWindow::ExperimentResumed
void ExperimentResumed()
Emitted when the experiment has just been resumed.
argos::CQTOpenGLUserFunctions::Init
virtual void Init(TConfigurationNode &t_tree)
Initializes the resource.
Definition: qtopengl_user_functions.h:88
argos::CARGoSLog::IsColoredOutput
bool IsColoredOutput() const
Definition: argos_log.h:118
argos::CQTOpenGLCamera::Init
void Init(TConfigurationNode &t_tree)
Definition: qtopengl_camera.cpp:20
argos::CQTOpenGLCamera::SSettings::Target
CVector3 Target
The direction of sight of the camera in the global reference frame.
Definition: qtopengl_camera.h:47
argos::CQTOpenGLCamera::SSettings
Definition: qtopengl_camera.h:37
argos::CQTOpenGLMainWindow::GetCameraXMLData
QString GetCameraXMLData()
Definition: qtopengl_main_window.cpp:930
argos::CQTOpenGLWidget::StepExperiment
void StepExperiment()
Executes one experiment time step.
Definition: qtopengl_widget.cpp:622
argos::CQTOpenGLWidget::ResetExperiment
void ResetExperiment()
Resets the state of the experiment to its state right after initialization.
Definition: qtopengl_widget.cpp:646
UInt32
unsigned int UInt32
32-bit unsigned integer.
Definition: datatypes.h:97
argos::GetNodeAttributeOrDefault
void GetNodeAttributeOrDefault(TConfigurationNode &t_node, const std::string &str_attribute, T &t_buffer, const T &t_default)
Returns the value of a node's attribute, or the passed default value.
Definition: argos_configuration.h:318
argos::CQTOpenGLMainWindow::ExperimentStarted
void ExperimentStarted()
Emitted when the experiment has just been started.
argos::CQTOpenGLWidget::SetInvertMouse
void SetInvertMouse(bool b_InvertMouse)
Sets whether the mouse should be inverted when moving.
Definition: qtopengl_widget.h:226
qtopengl_user_functions.h
argos::GetNodeAttribute
void GetNodeAttribute(TConfigurationNode &t_node, const std::string &str_attribute, T &t_buffer)
Returns the value of a node's attribute.
Definition: argos_configuration.h:208
argos::CQTOpenGLWidget::PlayExperiment
void PlayExperiment()
Plays the experiment.
Definition: qtopengl_widget.cpp:594
argos::CQTOpenGLMainWindow::PauseExperiment
void PauseExperiment()
Pauses the experiment.
Definition: qtopengl_main_window.cpp:729
argos::CQTOpenGLLayout
Definition: qtopengl_main_window.cpp:45
qtopengl_main_window.h
argos::CQTOpenGLMainWindow::CameraXMLPopUp
void CameraXMLPopUp()
Definition: qtopengl_main_window.cpp:880
argos::CQTOpenGLWidget::GetCamera
CQTOpenGLCamera & GetCamera()
Returns a reference to the camera.
Definition: qtopengl_widget.h:212
argos::CQTOpenGLLayout::addItem
virtual void addItem(QLayoutItem *item)
Definition: qtopengl_main_window.cpp:60
argos::CVector3::GetY
Real GetY() const
Returns the y coordinate of this vector.
Definition: vector3.h:109
argos::CQTOpenGLMainWindow::SuspendExperiment
void SuspendExperiment()
Suspends an experiment due to an error.
Definition: qtopengl_main_window.cpp:832
argos::CQTOpenGLCamera::GetSetting
SSettings & GetSetting(UInt32 n_index)
Definition: qtopengl_camera.h:128
argos::CQTOpenGLLayout::minimumSize
virtual QSize minimumSize() const
Definition: qtopengl_main_window.cpp:85
argos::CQTOpenGLMainWindow::PlayExperiment
void PlayExperiment()
Plays the experiment.
Definition: qtopengl_main_window.cpp:639
argos::CQTOpenGLWidget::GetFrameGrabData
SFrameGrabData & GetFrameGrabData()
Returns the current frame grabbing data.
Definition: qtopengl_widget.h:219
argos::CQTOpenGLMainWindow::ExperimentDone
void ExperimentDone()
Emitted when the experiment is finished.
argos::CQTOpenGLLayout::CQTOpenGLLayout
CQTOpenGLLayout()
Definition: qtopengl_main_window.cpp:49