ARGoS  3
A parallel, multi-engine simulator for swarm robotics
qtopengl_main_window.h
Go to the documentation of this file.
1 
7 #ifndef QTOPENGL_MAIN_WINDOW_H
8 #define QTOPENGL_MAIN_WINDOW_H
9 
10 namespace argos {
11  class CQTOpenGLMainWindow;
12  class CQTOpenGLWidget;
13  class CQTOpenGLLogStream;
14  class CQTOpenGLUserFunctions;
15 }
16 
17 class QMainWindow;
18 class QWidget;
19 class QHBoxLayout;
20 class QPushButton;
21 class QLCDNumber;
22 class QStatusBar;
23 class QDockWidget;
24 class QTextEdit;
25 class QButtonGroup;
26 class QSpinBox;
27 class QDoubleSpinBox;
28 class QActionGroup;
29 
30 #include <argos3/core/utility/configuration/argos_configuration.h>
31 #include <argos3/core/simulator/visualization/visualization.h>
32 #include <QMainWindow>
33 
34 namespace argos {
35 
36  class CQTOpenGLMainWindow : public QMainWindow {
37 
38  Q_OBJECT
39 
40  public:
41 
43  virtual ~CQTOpenGLMainWindow();
44 
46  return *m_pcOpenGLWidget;
47  }
48 
49  inline const CQTOpenGLWidget& GetOpenGLWidget() const {
50  return *m_pcOpenGLWidget;
51  }
52 
54  return *m_pcUserFunctions;
55  }
56 
57  inline const CQTOpenGLUserFunctions& GetUserFunctions() const {
58  return *m_pcUserFunctions;
59  }
60 
61  inline const QString& GetIconDir() const {
62  return m_strIconDir;
63  }
64 
65  inline const QString& GetTextureDir() const {
66  return m_strTextureDir;
67  }
68 
69  private:
70 
71  void ReadSettingsPreCreation();
72  void ReadSettingsPostCreation();
73  void WriteSettings();
74 
75  void CreateExperimentActions();
76  void CreateCameraActions();
77  void CreatePOVRayActions();
78  void CreateHelpActions();
79 
80  void CreateExperimentToolBar();
81  void CreateExperimentMenu();
82  void CreateCameraToolBar();
83  void CreateCameraMenu();
84  void CreatePOVRayMenu();
85  void CreateHelpMenu();
86 
87  void CreateOpenGLWidget(TConfigurationNode& t_tree);
88  void CreateLogMessageDock();
89  void CreateConnections();
90 
91  void CreateUserFunctions(TConfigurationNode& t_tree);
92 
93  virtual void closeEvent(QCloseEvent* pc_event);
94 
95  signals:
96 
101  void CameraSwitched(int n_camera);
102 
106  void ExperimentStarted();
107 
111  void ExperimentPlaying();
112 
117 
125  void ExperimentPaused();
126 
134  void ExperimentSuspended();
135 
140  void ExperimentResumed();
141 
147  void ExperimentDone();
148 
152  void ExperimentReset();
153 
154  public slots:
155 
161  void PlayExperiment();
162 
167  void FastForwardExperiment();
168 
172  void StepExperiment();
173 
179  void PauseExperiment();
180 
184  void TerminateExperiment();
185 
190  void ResetExperiment();
191 
195  void SuspendExperiment();
196 
200  void ResumeExperiment();
201 
202  void CameraXMLPopUp();
203 
204  QString GetCameraXMLData();
205 
206  void SwitchCamera(QAction*);
207 
208  // void POVRaySceneXMLPopUp();
209  // QString GetPOVRaySceneXMLData();
210  // void POVRayScenePreview();
211 
212  private:
213 
214  enum EExperimentState {
215  EXPERIMENT_INITIALIZED = 0,
216  EXPERIMENT_PLAYING,
217  EXPERIMENT_FAST_FORWARDING,
218  EXPERIMENT_PAUSED,
219  EXPERIMENT_SUSPENDED,
220  EXPERIMENT_DONE
221  };
222 
223  private:
224 
225  CQTOpenGLWidget* m_pcOpenGLWidget;
226  QString m_strIconDir;
227  QString m_strTextureDir;
228 
229  EExperimentState m_eExperimentState;
230 
231  QAction* m_pcPlayAction;
232  QAction* m_pcFastForwardAction;
233  QAction* m_pcStepAction;
234  QAction* m_pcResetAction;
235  QAction* m_pcTerminateAction;
236  QAction* m_pcPauseAction;
237  QAction* m_pcCaptureAction;
238  QAction* m_pcQuitAction;
239  QSpinBox* m_pcDrawFrameEvery;
240  QLCDNumber* m_pcCurrentStepLCD;
241  QToolBar* m_pcExperimentToolBar;
242  QMenu* m_pcExperimentMenu;
243 
244  QAction* m_pcShowCameraXMLAction;
245  QList<QAction*> m_pcSwitchCameraActions;
246  QActionGroup* m_pcSwitchCameraActionGroup;
247  QDoubleSpinBox* m_pcFocalLength;
248  QToolBar* m_pcCameraToolBar;
249  QMenu* m_pcCameraMenu;
250 
251  QAction* m_pcPOVRayXMLAction;
252  QAction* m_pcPOVRayPreviewAction;
253  QMenu* m_pcPOVRayMenu;
254 
255  QAction* m_pcAboutQTAction;
256  QMenu* m_pcHelpMenu;
257 
258  QStatusBar* m_pcStatusbar;
259 
260  QDockWidget* m_pcLogDock;
261  QDockWidget* m_pcLogErrDock;
262  QTextEdit* m_pcDockLogBuffer;
263  QTextEdit* m_pcDockLogErrBuffer;
264  CQTOpenGLLogStream* m_pcLogStream;
265  CQTOpenGLLogStream* m_pcLogErrStream;
266 
267  bool m_bWasLogColored;
268 
269  CQTOpenGLUserFunctions* m_pcUserFunctions;
270  };
271 
272 }
273 
274 #endif
argos::CQTOpenGLMainWindow::ResumeExperiment
void ResumeExperiment()
Resumes a suspended experiment.
Definition: qtopengl_main_window.cpp:854
argos
The namespace containing all the ARGoS related code.
Definition: ci_actuator.h:12
argos::CQTOpenGLMainWindow::ExperimentPaused
void ExperimentPaused()
Emitted when the experiment has been paused.
argos::CQTOpenGLMainWindow::~CQTOpenGLMainWindow
virtual ~CQTOpenGLMainWindow()
Definition: qtopengl_main_window.cpp:174
argos::CQTOpenGLWidget
Definition: qtopengl_widget.h:56
argos::CQTOpenGLMainWindow::FastForwardExperiment
void FastForwardExperiment()
Fast forwards the experiment.
Definition: qtopengl_main_window.cpp:672
argos::CQTOpenGLMainWindow::ExperimentSuspended
void ExperimentSuspended()
Emitted when the experiment has been suspended.
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::CQTOpenGLMainWindow::ResetExperiment
void ResetExperiment()
Resets the state of the experiment to its state right after initialization.
Definition: qtopengl_main_window.cpp:796
argos::CQTOpenGLMainWindow::CQTOpenGLMainWindow
CQTOpenGLMainWindow(TConfigurationNode &t_tree)
Definition: qtopengl_main_window.cpp:127
argos::CQTOpenGLMainWindow::StepExperiment
void StepExperiment()
Executes one experiment time step.
Definition: qtopengl_main_window.cpp:703
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::CQTOpenGLMainWindow::GetIconDir
const QString & GetIconDir() const
Definition: qtopengl_main_window.h:61
argos::CQTOpenGLMainWindow::GetTextureDir
const QString & GetTextureDir() const
Definition: qtopengl_main_window.h:65
argos::CQTOpenGLUserFunctions
The QTOpenGL user functions.
Definition: qtopengl_user_functions.h:74
argos::CQTOpenGLMainWindow::CameraSwitched
void CameraSwitched(int n_camera)
Emitted whenever the user presses a camera button to switch camera.
argos::CQTOpenGLMainWindow::ExperimentResumed
void ExperimentResumed()
Emitted when the experiment has just been resumed.
argos::CQTOpenGLMainWindow
Definition: qtopengl_main_window.h:36
argos::CQTOpenGLMainWindow::GetOpenGLWidget
const CQTOpenGLWidget & GetOpenGLWidget() const
Definition: qtopengl_main_window.h:49
argos::CQTOpenGLMainWindow::GetCameraXMLData
QString GetCameraXMLData()
Definition: qtopengl_main_window.cpp:930
argos::CQTOpenGLMainWindow::ExperimentStarted
void ExperimentStarted()
Emitted when the experiment has just been started.
argos::CQTOpenGLMainWindow::PauseExperiment
void PauseExperiment()
Pauses the experiment.
Definition: qtopengl_main_window.cpp:729
argos::CQTOpenGLMainWindow::CameraXMLPopUp
void CameraXMLPopUp()
Definition: qtopengl_main_window.cpp:880
argos::CQTOpenGLMainWindow::SuspendExperiment
void SuspendExperiment()
Suspends an experiment due to an error.
Definition: qtopengl_main_window.cpp:832
argos::CQTOpenGLMainWindow::GetUserFunctions
const CQTOpenGLUserFunctions & GetUserFunctions() const
Definition: qtopengl_main_window.h:57
argos::CQTOpenGLMainWindow::PlayExperiment
void PlayExperiment()
Plays the experiment.
Definition: qtopengl_main_window.cpp:639
argos::CQTOpenGLMainWindow::GetOpenGLWidget
CQTOpenGLWidget & GetOpenGLWidget()
Definition: qtopengl_main_window.h:45
argos::CQTOpenGLMainWindow::ExperimentDone
void ExperimentDone()
Emitted when the experiment is finished.
argos::CQTOpenGLMainWindow::GetUserFunctions
CQTOpenGLUserFunctions & GetUserFunctions()
Definition: qtopengl_main_window.h:53