baseexperimentgui.h
1 /********************************************************************************
2  * FARSA *
3  * Copyright (C) 2007-2012 *
4  * Gianluca Massera <emmegian@yahoo.it> *
5  * Stefano Nolfi <stefano.nolfi@istc.cnr.it> *
6  * Tomassino Ferrauto <tomassino.ferrauto@istc.cnr.it> *
7  * *
8  * This program is free software; you can redistribute it and/or modify *
9  * it under the terms of the GNU General Public License as published by *
10  * the Free Software Foundation; either version 2 of the License, or *
11  * (at your option) any later version. *
12  * *
13  * This program is distributed in the hope that it will be useful, *
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16  * GNU General Public License for more details. *
17  * *
18  * You should have received a copy of the GNU General Public License *
19  * along with this program; if not, write to the Free Software *
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
21  ********************************************************************************/
22 
23 #ifndef BASEEXPERIMENTGUI_H
24 #define BASEEXPERIMENTGUI_H
25 
26 #include "experimentsconfig.h"
27 #include "dataexchange.h"
28 #include "baseexperiment.h"
29 #include <QWidget>
30 #include <QGroupBox>
31 #include <QLabel>
32 #include <QComboBox>
33 #include <QPushButton>
34 #include <QSlider>
35 
36 namespace farsa {
37 
47 class FARSA_EXPERIMENTS_API BaseExperimentGUI : public QWidget, public DataUploaderDownloader<__BaseExperiment_internal::OperationControl, __BaseExperiment_internal::OperationStatus>
48 {
49  Q_OBJECT
50 
51 public:
59  BaseExperimentGUI(BaseExperiment* experiment, QWidget* parent = NULL, Qt::WindowFlags flags = 0);
60 
64  virtual ~BaseExperimentGUI();
65 
74  virtual bool event(QEvent* e);
75 
76 private slots:
82  void currentOperationChanged(int index);
83 
87  void startOperation();
88 
92  void stopOperation();
93 
97  void pauseOperation(bool pause);
98 
102  void stepOperation();
103 
109  void changeDelay(int delay);
110 
111 private:
116  void updateOperationsList();
117 
126  void enableWidgets(bool enableStart, bool enableStop, bool enablePause, bool enableDelay);
127 
136  QString describeOperation(int id, QString prefix = "") const;
137 
143  unsigned long sliderValueToDelay(int value) const;
144 
151  int delayToSliderValue(unsigned long interval) const;
152 
156  BaseExperiment* const m_experiment;
157 
161  QVector<BaseExperiment::AbstractOperationWrapper*> m_operations;
162 
166  QGroupBox* m_operationSelectionGroup;
167 
171  QLabel* m_operationsListLabel;
172 
176  QComboBox* m_operationsList;
177 
182  QLabel* m_selectedOperationInfo;
183 
187  QPushButton* m_startSelectedOperationButton;
188 
192  QGroupBox* m_currentOperationControlGroup;
193 
197  QLabel* m_currentOperationInfo;
198 
202  QPushButton* m_stopCurrentOperationButton;
203 
207  QGroupBox* m_steppableOperationControlGroup;
208 
212  QPushButton* m_pauseOperationButton;
213 
217  QPushButton* m_stepOperationButton;
218 
222  QLabel* m_delaySliderLabel;
223 
228  QSlider* m_delaySlider;
229 
234  int m_runningOperationID;
235 };
236 
237 } // End namespace farsa
238 
239 #endif
The GUI to control a BaseExperiment subclass.
This file contains the common type defitions used on the whole framework.
The base class for experiments.