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>
18 #include <QtCore/QVariant>
20 #include <QActionGroup>
21 #include <QtWidgets/QApplication>
22 #include <QtWidgets/QDockWidget>
23 #include <QtWidgets/QHeaderView>
24 #include <QtWidgets/QLCDNumber>
25 #include <QtWidgets/QPushButton>
26 #include <QtWidgets/QSpinBox>
27 #include <QtWidgets/QDoubleSpinBox>
28 #include <QtWidgets/QStatusBar>
29 #include <QtWidgets/QWidget>
31 #include <QCloseEvent>
32 #include <QMessageBox>
35 #include <QTextStream>
51 m_pcQTOpenGLItem(nullptr) {
52 setContentsMargins(0, 0, 0, 0);
56 if(m_pcQTOpenGLItem !=
nullptr) {
57 delete m_pcQTOpenGLItem;
62 if(m_pcQTOpenGLItem !=
nullptr) {
63 delete m_pcQTOpenGLItem;
65 m_pcQTOpenGLItem = item;
68 return (m_pcQTOpenGLItem !=
nullptr) ? 1 : 0;
71 virtual QLayoutItem*
itemAt(
int index)
const {
72 return (index == 0) ? m_pcQTOpenGLItem :
nullptr;
75 virtual QLayoutItem*
takeAt(
int index) {
77 QLayoutItem* pcRetVal = m_pcQTOpenGLItem;
78 m_pcQTOpenGLItem =
nullptr;
87 return QSize(640,480);
91 QLayout::setGeometry(r);
92 if(m_pcQTOpenGLItem !=
nullptr) {
95 QRect cCandidate1(r.x(), r.y(), (r.height() * 4) / 3, r.height());
97 QRect cCandidate2(r.x(), r.y(), r.width(), (r.width() * 3) / 4);
99 if(r.contains(cCandidate1)) {
101 int nPadding = (r.width() - cCandidate1.width()) / 2;
102 cCandidate1.translate(nPadding, 0);
103 m_pcQTOpenGLItem->setGeometry(cCandidate1);
107 int nPadding = (r.height() - cCandidate2.height()) / 2;
108 cCandidate2.translate(0, nPadding);
109 m_pcQTOpenGLItem->setGeometry(cCandidate2);
116 QLayoutItem* m_pcQTOpenGLItem;
124 m_pcUserFunctions(nullptr) {
126 std::string strTitle;
127 GetNodeAttributeOrDefault<std::string>(t_tree,
"title", strTitle,
"ARGoS v" ARGOS_VERSION
"-" ARGOS_RELEASE);
128 setWindowTitle(tr(strTitle.c_str()));
130 ReadSettingsPreCreation();
132 m_pcStatusbar =
new QStatusBar(
this);
133 setStatusBar(m_pcStatusbar);
135 CreateExperimentActions();
136 CreateCameraActions();
140 CreateUserFunctions(t_tree);
142 CreateOpenGLWidget(t_tree);
144 CreateExperimentMenu();
149 CreateExperimentToolBar();
150 CreateCameraToolBar();
152 CreateLogMessageDock();
154 ReadSettingsPostCreation();
158 m_eExperimentState = EXPERIMENT_INITIALIZED;
160 bool bAutoPlay =
false;
175 delete m_pcUserFunctions;
176 delete m_pcLogStream;
177 delete m_pcLogErrStream;
178 if(m_bWasLogColored) {
187 void CQTOpenGLMainWindow::ReadSettingsPreCreation() {
189 cSettings.beginGroup(
"MainWindow");
190 resize(cSettings.value(
"size", QSize(640,480)).toSize());
191 move(cSettings.value(
"position", QPoint(0,0)).toPoint());
193 m_strIconDir +=
"/include/argos3/plugins/simulator/visualizations/qt-opengl/icons/";
195 m_strTextureDir +=
"/include/argos3/plugins/simulator/visualizations/qt-opengl/textures/";
197 m_strModelDir +=
"/include/argos3/plugins/simulator/visualizations/qt-opengl/models/";
198 cSettings.endGroup();
204 void CQTOpenGLMainWindow::ReadSettingsPostCreation() {
206 cSettings.beginGroup(
"MainWindow");
207 restoreState(cSettings.value(
"docks").toByteArray());
208 cSettings.endGroup();
214 void CQTOpenGLMainWindow::WriteSettings() {
216 cSettings.beginGroup(
"MainWindow");
217 cSettings.setValue(
"docks", saveState());
218 cSettings.setValue(
"size", size());
219 cSettings.setValue(
"position", pos());
220 cSettings.endGroup();
226 void CQTOpenGLMainWindow::CreateExperimentActions() {
229 cPlayIcon. addPixmap(QPixmap(m_strIconDir +
"/play.png"));
230 m_pcPlayAction =
new QAction(cPlayIcon, tr(
"&Play"),
this);
231 m_pcPlayAction->setShortcut(Qt::Key_P);
232 m_pcPlayAction->setToolTip(tr(
"Play experiment"));
233 m_pcPlayAction->setStatusTip(tr(
"Play experiment"));
237 cStepIcon.addPixmap(QPixmap(m_strIconDir +
"/step.png"));
238 m_pcStepAction =
new QAction(cStepIcon, tr(
"&Step"),
this);
239 m_pcStepAction->setToolTip(tr(
"Step experiment"));
240 m_pcStepAction->setStatusTip(tr(
"Step experiment"));
241 m_pcStepAction->setShortcut(Qt::Key_X);
243 QIcon cFastForwardIcon;
244 cFastForwardIcon.addPixmap(QPixmap(m_strIconDir +
"/fast_forward.png"));
245 m_pcFastForwardAction =
new QAction(cFastForwardIcon, tr(
"&Fast Forward"),
this);
246 m_pcFastForwardAction->setToolTip(tr(
"Fast forward experiment"));
247 m_pcFastForwardAction->setStatusTip(tr(
"Fast forward experiment"));
248 m_pcFastForwardAction->setShortcut(Qt::Key_F);
251 cPauseIcon. addPixmap(QPixmap(m_strIconDir +
"/pause.png"));
252 m_pcPauseAction =
new QAction(cPauseIcon, tr(
"&Pause"),
this);
253 m_pcPauseAction->setShortcut(Qt::Key_O);
254 m_pcPauseAction->setToolTip(tr(
"Pause experiment"));
255 m_pcPauseAction->setStatusTip(tr(
"Pause experiment"));
256 m_pcPauseAction->setEnabled(
false);
259 QIcon cTerminateIcon;
260 cTerminateIcon.addPixmap(QPixmap(m_strIconDir +
"/stop.png"));
261 m_pcTerminateAction =
new QAction(cTerminateIcon, tr(
"&Terminate"),
this);
262 m_pcTerminateAction->setShortcut(Qt::Key_T);
263 m_pcTerminateAction->setToolTip(tr(
"Terminate experiment"));
264 m_pcTerminateAction->setStatusTip(tr(
"Terminate experiment"));
265 m_pcTerminateAction->setEnabled(
false);
268 cResetIcon.addPixmap(QPixmap(m_strIconDir +
"/reset.png"));
269 m_pcResetAction =
new QAction(cResetIcon, tr(
"&Reset"),
this);
270 m_pcResetAction->setToolTip(tr(
"Reset experiment"));
271 m_pcResetAction->setStatusTip(tr(
"Reset experiment"));
272 m_pcResetAction->setShortcut(Qt::Key_R);
273 m_pcResetAction->setEnabled(
false);
276 cCaptureIcon.addPixmap(QPixmap(m_strIconDir +
"/record.png"));
277 m_pcCaptureAction =
new QAction(cCaptureIcon, tr(
"&Capture"),
this);
278 m_pcCaptureAction->setToolTip(tr(
"Capture frames"));
279 m_pcCaptureAction->setStatusTip(tr(
"Capture frames"));
280 m_pcCaptureAction->setCheckable(
true);
281 m_pcCaptureAction->setShortcut(Qt::Key_C);
283 m_pcQuitAction =
new QAction(tr(
"&Quit"),
this);
284 m_pcQuitAction->setStatusTip(tr(
"Quit the simulator"));
290 void CQTOpenGLMainWindow::CreateCameraActions() {
292 m_pcSwitchCameraActionGroup =
new QActionGroup(
this);
294 cCameraIcon.addPixmap(QPixmap(m_strIconDir +
"/camera.png"));
295 for(
UInt32 i = 0; i < 12; ++i) {
296 QAction* pcAction =
new QAction(cCameraIcon, tr(QString(
"Camera %1").arg(i+1).toLatin1().data()), m_pcSwitchCameraActionGroup);
297 pcAction->setToolTip(tr(QString(
"Switch to camera %1").arg(i+1).toLatin1().data()));
298 pcAction->setStatusTip(tr(QString(
"Switch to camera %1").arg(i+1).toLatin1().data()));
299 pcAction->setCheckable(
true);
300 pcAction->setShortcut(Qt::Key_F1 + i);
301 pcAction->setData(i);
302 m_pcSwitchCameraActions.push_back(pcAction);
304 m_pcSwitchCameraActions.first()->setChecked(
true);
306 m_pcShowCameraXMLAction =
new QAction(tr(
"&Show XML..."),
this);
307 m_pcShowCameraXMLAction->setStatusTip(tr(
"Show XML configuration for all cameras"));
329 void CQTOpenGLMainWindow::CreateHelpActions() {
331 m_pcAboutQTAction =
new QAction(tr(
"About &Qt"),
this);
332 m_pcAboutQTAction->setStatusTip(tr(
"Show the Qt library's About box"));
338 void CQTOpenGLMainWindow::CreateExperimentToolBar() {
339 m_pcExperimentToolBar = addToolBar(tr(
"Experiment"));
340 m_pcExperimentToolBar->setObjectName(
"ExperimentToolBar");
341 m_pcExperimentToolBar->setIconSize(QSize(32,32));
342 m_pcCurrentStepLCD =
new QLCDNumber(m_pcExperimentToolBar);
343 m_pcCurrentStepLCD->setToolTip(tr(
"Current step"));
344 m_pcCurrentStepLCD->setDigitCount(6);
345 m_pcCurrentStepLCD->setSegmentStyle(QLCDNumber::Flat);
346 m_pcExperimentToolBar->addWidget(m_pcCurrentStepLCD);
347 m_pcExperimentToolBar->addSeparator();
349 m_pcExperimentToolBar->addAction(m_pcStepAction);
351 m_pcExperimentToolBar->addAction(m_pcPlayAction);
353 m_pcExperimentToolBar->addAction(m_pcPauseAction);
354 m_pcExperimentToolBar->addAction(m_pcFastForwardAction);
355 m_pcDrawFrameEvery =
new QSpinBox(m_pcExperimentToolBar);
356 m_pcDrawFrameEvery->setToolTip(tr(
"Draw frame every X steps when in fast-forward"));
357 m_pcDrawFrameEvery->setMinimum(1);
358 m_pcDrawFrameEvery->setMaximum(999);
359 m_pcDrawFrameEvery->setValue(1);
360 m_pcExperimentToolBar->addWidget(m_pcDrawFrameEvery);
362 m_pcExperimentToolBar->addSeparator();
363 m_pcExperimentToolBar->addAction(m_pcTerminateAction);
364 m_pcExperimentToolBar->addAction(m_pcResetAction);
365 m_pcExperimentToolBar->addSeparator();
366 m_pcExperimentToolBar->addAction(m_pcCaptureAction);
372 void CQTOpenGLMainWindow::CreateExperimentMenu() {
373 m_pcExperimentMenu = menuBar()->addMenu(tr(
"&Experiment"));
374 m_pcExperimentMenu->addAction(m_pcPlayAction);
376 m_pcExperimentMenu->addAction(m_pcPauseAction);
377 m_pcExperimentMenu->addAction(m_pcFastForwardAction);
378 m_pcExperimentMenu->addAction(m_pcStepAction);
380 m_pcExperimentMenu->addSeparator();
381 m_pcExperimentMenu->addAction(m_pcTerminateAction);
382 m_pcExperimentMenu->addAction(m_pcResetAction);
383 m_pcExperimentMenu->addSeparator();
384 m_pcExperimentMenu->addAction(m_pcCaptureAction);
385 m_pcExperimentMenu->addSeparator();
386 m_pcExperimentMenu->addAction(m_pcQuitAction);
392 void CQTOpenGLMainWindow::CreateCameraToolBar() {
393 m_pcCameraToolBar =
new QToolBar(tr(
"Camera"));
394 m_pcCameraToolBar->setAllowedAreas(Qt::LeftToolBarArea |
395 Qt::RightToolBarArea |
396 Qt::BottomToolBarArea);
397 m_pcCameraToolBar->setObjectName(
"CameraToolBar");
398 m_pcCameraToolBar->setIconSize(QSize(32,32));
399 m_pcCameraToolBar->addActions(m_pcSwitchCameraActions);
400 m_pcCameraToolBar->addSeparator();
401 m_pcFocalLength =
new QDoubleSpinBox(m_pcCameraToolBar);
402 m_pcFocalLength->setToolTip(tr(
"Set the focal length of the current camera"));
403 m_pcFocalLength->setSuffix(
"mm");
404 m_pcFocalLength->setDecimals(1);
405 m_pcFocalLength->setSingleStep(1.0f);
406 m_pcFocalLength->setRange(1.0f, 999.0f);
408 m_pcCameraToolBar->addWidget(m_pcFocalLength);
409 addToolBar(Qt::LeftToolBarArea, m_pcCameraToolBar);
415 void CQTOpenGLMainWindow::CreateCameraMenu() {
416 m_pcCameraMenu = menuBar()->addMenu(tr(
"&Camera"));
417 m_pcCameraMenu->addActions(m_pcSwitchCameraActions);
418 m_pcCameraMenu->addAction(m_pcShowCameraXMLAction);
433 void CQTOpenGLMainWindow::CreateHelpMenu() {
434 m_pcHelpMenu = menuBar()->addMenu(tr(
"&?"));
435 m_pcHelpMenu->addAction(m_pcAboutQTAction);
443 QSurfaceFormat cFormat = QSurfaceFormat::defaultFormat();
444 cFormat.setSamples(4);
445 cFormat.setDepthBufferSize(24);
447 QWidget* pcPlaceHolder =
new QWidget(
this);
448 m_pcOpenGLWidget =
new CQTOpenGLWidget(pcPlaceHolder, *
this, *m_pcUserFunctions);
449 m_pcOpenGLWidget->setFormat(cFormat);
450 m_pcOpenGLWidget->setCursor(QCursor(Qt::OpenHandCursor));
463 setMinimumSize(QSize(320, 240));
474 auto* pcQTOpenGLLayout =
new CQTOpenGLLayout();
475 pcQTOpenGLLayout->addWidget(m_pcOpenGLWidget);
476 pcPlaceHolder->setLayout(pcQTOpenGLLayout);
477 setCentralWidget(pcPlaceHolder);
483 m_pcUserFunctions->
Init(tNode);
490 void CQTOpenGLMainWindow::CreateLogMessageDock() {
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);
502 m_pcDockLogBuffer =
new QTextEdit();
503 m_pcDockLogBuffer->setReadOnly(
true);
506 m_pcDockLogBuffer->append(
"<b>[t=0]</b> Log started.");
508 m_pcLogStream =
new CQTOpenGLLogStream(
LOG.
GetStream(), m_pcDockLogBuffer);
510 m_pcLogDock->setWidget(m_pcDockLogBuffer);
511 addDockWidget(Qt::RightDockWidgetArea, m_pcLogDock);
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);
521 m_pcDockLogErrBuffer =
new QTextEdit();
522 m_pcDockLogErrBuffer->setReadOnly(
true);
525 m_pcDockLogErrBuffer->append(
"<b>[t=0]</b> LogErr started.");
527 m_pcLogErrStream =
new CQTOpenGLLogStream(
LOGERR.
GetStream(), m_pcDockLogErrBuffer);
528 m_pcLogErrDock->setWidget(m_pcDockLogErrBuffer);
530 addDockWidget(Qt::RightDockWidgetArea, m_pcLogErrDock);
537 void CQTOpenGLMainWindow::CreateConnections() {
539 connect(m_pcPlayAction, SIGNAL(triggered()),
542 connect(m_pcResetAction, SIGNAL(triggered()),
545 connect(m_pcOpenGLWidget, SIGNAL(StepDone(
int)),
546 m_pcCurrentStepLCD, SLOT(display(
int)));
551 connect(m_pcTerminateAction, SIGNAL(triggered()),
555 connect(m_pcPauseAction, SIGNAL(triggered()),
558 connect(m_pcStepAction, SIGNAL(triggered()),
561 connect(m_pcFastForwardAction, SIGNAL(triggered()),
564 connect(m_pcDrawFrameEvery, SIGNAL(valueChanged(
int)),
565 m_pcOpenGLWidget, SLOT(SetDrawFrameEvery(
int)));
574 connect(m_pcCaptureAction, SIGNAL(triggered(
bool)),
575 m_pcOpenGLWidget, SLOT(SetGrabFrame(
bool)));
577 connect(m_pcQuitAction, SIGNAL(triggered()),
580 connect(m_pcAboutQTAction, SIGNAL(triggered()),
581 qApp, SLOT(aboutQt()));
583 connect(m_pcSwitchCameraActionGroup, SIGNAL(triggered(QAction*)),
586 m_pcOpenGLWidget, SLOT(SetCamera(
int)));
588 connect(m_pcFocalLength, SIGNAL(valueChanged(
double)),
589 m_pcOpenGLWidget, SLOT(SetCameraFocalLength(
double)));
591 connect(m_pcShowCameraXMLAction, SIGNAL(triggered()),
604 std::string strLabel, strLibrary;
609 if(strLibrary !=
"") {
616 catch(CARGoSException& ex) {
622 m_pcUserFunctions =
new CQTOpenGLUserFunctions;
630 void CQTOpenGLMainWindow::closeEvent(QCloseEvent* pc_event) {
641 if(m_eExperimentState != EXPERIMENT_INITIALIZED &&
642 m_eExperimentState != EXPERIMENT_PAUSED) {
643 LOGERR <<
"[BUG] CQTOpenGLMainWindow::PlayExperiment() called in wrong state: "
644 << m_eExperimentState
650 m_pcPlayAction->setEnabled(
false);
651 m_pcResetAction->setEnabled(
false);
652 m_pcTerminateAction->setEnabled(
true);
654 m_pcPauseAction->setEnabled(
true);
655 m_pcFastForwardAction->setEnabled(
false);
656 m_pcStepAction->setEnabled(
false);
661 m_eExperimentState = EXPERIMENT_PLAYING;
662 if(m_eExperimentState == EXPERIMENT_INITIALIZED) {
674 if(m_eExperimentState != EXPERIMENT_INITIALIZED &&
675 m_eExperimentState != EXPERIMENT_PAUSED) {
676 LOGERR <<
"[BUG] CQTOpenGLMainWindow::FastForwardExperiment() called in wrong state: "
677 << m_eExperimentState
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);
692 m_eExperimentState = EXPERIMENT_FAST_FORWARDING;
693 if(m_eExperimentState == EXPERIMENT_INITIALIZED) {
705 if(m_eExperimentState != EXPERIMENT_INITIALIZED &&
706 m_eExperimentState != EXPERIMENT_PAUSED) {
707 LOGERR <<
"[BUG] CQTOpenGLMainWindow::StepExperiment() called in wrong state: "
708 << m_eExperimentState
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);
722 m_eExperimentState = EXPERIMENT_PAUSED;
731 if(m_eExperimentState != EXPERIMENT_PLAYING &&
732 m_eExperimentState != EXPERIMENT_FAST_FORWARDING) {
733 LOGERR <<
"[BUG] CQTOpenGLMainWindow::PauseExperiment() called in wrong state: "
734 << m_eExperimentState
740 m_pcPlayAction->setEnabled(
true);
741 m_pcResetAction->setEnabled(
false);
742 m_pcTerminateAction->setEnabled(
true);
744 m_pcPauseAction->setEnabled(
false);
745 m_pcFastForwardAction->setEnabled(
true);
746 m_pcStepAction->setEnabled(
true);
751 m_eExperimentState = EXPERIMENT_PAUSED;
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
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);
779 m_pcPauseAction->setEnabled(
false);
780 m_pcStepAction->setEnabled(
false);
781 m_pcFastForwardAction->setEnabled(
false);
789 m_eExperimentState = EXPERIMENT_DONE;
805 if(m_eExperimentState != EXPERIMENT_SUSPENDED &&
806 m_eExperimentState != EXPERIMENT_DONE) {
807 LOGERR <<
"[BUG] CQTOpenGLMainWindow::ResetExperiment() called in wrong state: "
808 << m_eExperimentState
814 m_pcPlayAction->setEnabled(
true);
815 m_pcResetAction->setEnabled(
false);
816 m_pcTerminateAction->setEnabled(
false);
817 m_pcCaptureAction->setEnabled(
true);
818 m_pcCaptureAction->setChecked(
false);
820 m_pcPauseAction->setEnabled(
false);
821 m_pcStepAction->setEnabled(
true);
822 m_pcFastForwardAction->setEnabled(
true);
825 m_pcCurrentStepLCD->display(0);
826 m_pcDockLogBuffer->setHtml(
"<b>[t=0]</b> Log restarted.");
827 m_pcDockLogErrBuffer->setHtml(
"<b>[t=0]</b> LogErr restarted.");
830 m_pcUserFunctions->
Reset();
832 m_eExperimentState = EXPERIMENT_INITIALIZED;
841 m_pcPlayAction->setEnabled(
false);
842 m_pcResetAction->setEnabled(
true);
843 m_pcTerminateAction->setEnabled(
true);
844 m_pcCaptureAction->setEnabled(
false);
845 m_pcCaptureAction->setChecked(
false);
847 m_pcPauseAction->setEnabled(
false);
848 m_pcStepAction->setEnabled(
false);
849 m_pcFastForwardAction->setEnabled(
false);
854 m_eExperimentState = EXPERIMENT_SUSPENDED;
863 if(m_eExperimentState != EXPERIMENT_SUSPENDED) {
864 LOGERR <<
"[BUG] CQTOpenGLMainWindow::ResumeExperiment() called in wrong state: "
865 << m_eExperimentState
871 m_pcPlayAction->setEnabled(
true);
872 m_pcResetAction->setEnabled(
false);
873 m_pcTerminateAction->setEnabled(
false);
874 m_pcCaptureAction->setEnabled(
true);
876 m_pcStepAction->setEnabled(
true);
877 m_pcFastForwardAction->setEnabled(
true);
880 m_eExperimentState = EXPERIMENT_PAUSED;
889 auto* pcXMLOutput =
new QTextEdit();
892 QRect cGeom = geometry();
893 cGeom.setBottomRight(geometry().center());
894 cGeom.moveCenter(geometry().center());
895 pcXMLOutput->setGeometry(cGeom);
897 pcXMLOutput->setWindowModality(Qt::ApplicationModal);
899 pcXMLOutput->setReadOnly(
true);
901 pcXMLOutput->setDocumentTitle(
"Active camera configuration");
902 pcXMLOutput->setWindowTitle(
"Active camera configuration");
938 QString strResult(
"<camera>\n <placements>\n");
947 QString(
" <placement index=\"0\" position=\"%2,%3,%4\" look_at=\"%5,%6,%7\" up=\"%8,%9,%10\" lens_focal_length=\"%11\" />\n")
958 strResult.append(
" </placements>\n</camera>\n");
#define THROW_ARGOSEXCEPTION_NESTED(message, nested)
This macro throws an ARGoS exception with the passed message and nesting the passed exception.
unsigned int UInt32
32-bit unsigned integer.
The namespace containing all the ARGoS related code.
CARGoSLog LOGERR(std::cerr, SLogColor(ARGOS_LOG_ATTRIBUTE_BRIGHT, ARGOS_LOG_COLOR_RED))
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.
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.
ticpp::Element TConfigurationNode
The ARGoS configuration XML node.
CARGoSLog LOG(std::cout, SLogColor(ARGOS_LOG_ATTRIBUTE_BRIGHT, ARGOS_LOG_COLOR_GREEN))
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.
void GetNodeAttribute(TConfigurationNode &t_node, const std::string &str_attribute, T &t_buffer)
Returns the value of a node's attribute.
virtual void PostExperiment()
Executes user-defined logic when the experiment finishes.
CLoopFunctions & GetLoopFunctions()
Returns a reference to the loop functions associated to the current experiment.
void Terminate()
Puts an end to the simulation.
static CSimulator & GetInstance()
Returns the instance to the CSimulator class.
bool IsColoredOutput() const
std::ostream & GetStream()
void DisableColoredOutput()
void EnableColoredOutput()
Real GetX() const
Returns the x coordinate of this vector.
Real GetY() const
Returns the y coordinate of this vector.
Real GetZ() const
Returns the z coordinate of this vector.
static TDLHandle LoadLibrary(const std::string &str_lib)
Loads a dynamic library.
static TYPE * New(const std::string &str_label)
Creates a new object of type TYPE
SPlacement & GetPlacement(UInt32 n_index)
void Init(TConfigurationNode &t_tree)
SPlacement & GetActivePlacement()
CVector3 Up
The local Z axis of the camera in the global reference frame.
CVector3 Position
The position of the camera in the global reference frame.
Real LensFocalLength
The focal length of the lens (if this was a real camera)
CVector3 Target
What we are looking at in the global reference frame.
virtual QSize sizeHint() const
virtual int count() const
virtual ~CQTOpenGLLayout()
virtual void setGeometry(const QRect &r)
virtual QLayoutItem * itemAt(int index) const
virtual QLayoutItem * takeAt(int index)
virtual void addItem(QLayoutItem *item)
void FastForwardExperiment()
Fast forwards the experiment.
void SuspendExperiment()
Suspends an experiment due to an error.
void ExperimentReset()
Emitted when the experiment has been reset.
void StepExperiment()
Executes one experiment time step.
void PlayExperiment()
Plays the experiment.
void ExperimentSuspended()
Emitted when the experiment has been suspended.
virtual ~CQTOpenGLMainWindow()
void ExperimentDone()
Emitted when the experiment is finished.
void ExperimentStarted()
Emitted when the experiment has just been started.
void ExperimentResumed()
Emitted when the experiment has just been resumed.
void ResumeExperiment()
Resumes a suspended experiment.
void CameraSwitched(int n_camera)
Emitted whenever the user presses a camera button to switch camera.
void SwitchCamera(QAction *)
void ExperimentPaused()
Emitted when the experiment has been paused.
void ExperimentPlaying()
Emitted when the experiment has (re)started playing.
void ResetExperiment()
Resets the state of the experiment to its state right after initialization.
void PauseExperiment()
Pauses the experiment.
QString GetCameraXMLData()
CQTOpenGLMainWindow(TConfigurationNode &t_tree)
void ExperimentFastForwarding()
Emitted when the experiment has (re)started fast-forwarding.
void TerminateExperiment()
Terminates the execution of the experiment.
void SetMainWindow(CQTOpenGLMainWindow &c_main_win)
Sets the QTOpenGL main window for these user functions.
virtual void Destroy()
Undoes whatever was done by Init().
virtual void Init(TConfigurationNode &t_tree)
Initializes the resource.
virtual void Reset()
Resets the resource.
void StepExperiment()
Executes one experiment time step.
void SetShowBoundary(bool b_show_boundary)
Sets whether the boundary walls should be rendered.
void FastForwardExperiment()
Fast forwards the experiment.
void PlayExperiment()
Plays the experiment.
void ResetExperiment()
Resets the state of the experiment to its state right after initialization.
CQTOpenGLCamera & GetCamera()
Returns a reference to the camera.
void SetInvertMouse(bool b_invert_mouse)
Sets whether the mouse should be inverted when moving.
SFrameGrabData & GetFrameGrabData()
Returns the current frame grabbing data.
void SetDrawFrameEvery(int n_every)
When fast-forwarding, sets every how many steps a frame must be drawn.
void PauseExperiment()
Pauses the experiment.
void Init(TConfigurationNode &t_tree)