evorobotviewer.h
1 /********************************************************************************
2  * FARSA Experiments Library *
3  * Copyright (C) 2007-2012 *
4  * Stefano Nolfi <stefano.nolfi@istc.cnr.it> *
5  * Onofrio Gigliotta <onofrio.gigliotta@istc.cnr.it> *
6  * Gianluca Massera <emmegian@yahoo.it> *
7  * Tomassino Ferrauto <tomassino.ferrauto@istc.cnr.it> *
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  * This program is distributed in the hope that it will be useful, *
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
17  * GNU General Public License for more details. *
18  * *
19  * You should have received a copy of the GNU General Public License *
20  * along with this program; if not, write to the Free Software *
21  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
22  ********************************************************************************/
23 
24 #ifndef EVOROBOTVIEWER_H
25 #define EVOROBOTVIEWER_H
26 
27 #include "evorobotcomponent.h"
28 #include "parametersettableui.h"
29 #include "evoga.h"
30 #include "renderworld.h"
31 #include "evodataviewer.h"
32 
33 #include <QWidget>
34 #include <QMenu>
35 #include <QAction>
36 #include <QMenuBar>
37 #include <QFileDialog>
38 #include <QLabel>
39 #include <QList>
40 #include <QString>
41 #include <QWidget>
42 #include <QMenuBar>
43 #include <QVBoxLayout>
44 #include <QComboBox>
45 #include <QObject>
46 
47 namespace farsa {
48 
49 class PhyiCub;
50 // class VisionMapSensorGui;
51 class EvoRobotExperiment;
52 class TestIndividual;
53 class RenderWorldWrapperWidget;
54 
55 class FARSA_EXPERIMENTS_API EvoRobotViewer : public QObject, public ParameterSettableUI, public ConcurrentResourcesUser {
56  Q_OBJECT
57 public:
61  EvoRobotViewer( EvoRobotComponent* component );
63  ~EvoRobotViewer();
69  void fillActionsMenu( QMenu* actionsMenu );
75  QList<ParameterSettableUIViewer> getViewers( QWidget* parent, Qt::WindowFlags flags );
79  void addAdditionalMenus( QMenuBar* menuBar );
80 
81 private:
82 
83  ParameterSettableUIViewer evogaControls( QWidget* parent, Qt::WindowFlags flags );
84 // ParameterSettableUIViewer icubview( QWidget* parent, Qt::WindowFlags flags );
85  ParameterSettableUIViewer fitview( QWidget* parent, Qt::WindowFlags flags );
86  ParameterSettableUIViewer statview( QWidget* parent, Qt::WindowFlags flags );
87  ParameterSettableUIViewer renderWorld( QWidget* parent, Qt::WindowFlags flags );
88  ParameterSettableUIViewer testIndividualUI( TestIndividual* test, QWidget* parent, Qt::WindowFlags flags );
89 
90  EvoRobotComponent* evorobot;
91  Evoga* ga;
93  QWidget* statViewer;
94  FitViewer* ftv;
95 // VisionMapSensorGui *m_icubview; //! widget that visualize icub's camera content
96  RenderWorldWrapperWidget* renderworldwrapper;
97 
98  QLabel* infoEvoga;
100  QSlider* simulationThrottle;
102  QLabel* simulationSpeed;
104  QTimer* timer;
105 
106 private slots:
108  void onWorldAdvance();
112  void onEvogaStartingReplication( int replication );
116  void onEvogaRecoveredInterruptedEvolution( QString statfile );
123  void onEvogaEndGeneration( int generation, double fmax, double faverage, double fmin );
124 
126  void onActionFinished();
127 
129  void evogaNextTrial();
130 
132  void onSimulationThrottleChanges( int newvalue );
133 
135  void loadStat();
137  void loadAllStat();
138 };
139 
140 // namespace VisionMapSensorGuiInternal {
141 // class ImageDisplayer;
142 // }
143 //
144 // /**
145 // * \brief A gui visualizing the camera and the projection of objects on the
146 // * retina
147 // *
148 // * This keeps the current image and adds marks on it. If you set a new image
149 // * all previous marks are lost
150 // */
151 // class FARSA_EXPERIMENTS_API VisionMapSensorGui : public QWidget
152 // {
153 // Q_OBJECT
154 //
155 // public:
156 // /**
157 // * \brief Constructor
158 // *
159 // * \param mapWidth the width of the neural map
160 // * \param mapHeight the height of the neural map
161 // * \param parent the parent of this widget
162 // */
163 // VisionMapSensorGui(QWidget* parent=0, Qt::WindowFlags flags=0);
164 //
165 // /**
166 // * \brief Destructor
167 // */
168 // virtual ~VisionMapSensorGui();
169 //
170 // /**
171 // * \brief Sets the new image to display
172 // *
173 // * This resets the old image and also changes the dimension of the
174 // * widget to match that of the image
175 // * \param image the new image
176 // */
177 // void setImage(PhyiCub *icub, bool useRightCamera=true);
178 //
179 // /**
180 // * \brief Adds a mark on the image at the given position
181 // *
182 // * x and y are normalized (i.e. within 0 and 1) coordinates. They are
183 // * converted to the actual image coordinates by this function
184 // * \param x the x coordinate of the mark (must be between 0 and 1)
185 // * \param y the y coordinate of the mark (must be between 0 and 1)
186 // * \param markCenter the color of the central part of the mark
187 // * \param markSurrounding the color of the surrounding part of the mark
188 // */
189 // void addMark(double x, double y, QColor markCenter = Qt::black, QColor markSurrounding = Qt::white);
190 //
191 // private:
192 // /**
193 // * \brief The image with marks
194 // */
195 // QImage m_image;
196 //
197 // /**
198 // * \brief The helper widget displaying the image
199 // */
200 // VisionMapSensorGuiInternal::ImageDisplayer* m_imageDisplayer;
201 // };
202 
206 class FARSA_EXPERIMENTS_API TestIndividualGUI : public QWidget
207 {
208  Q_OBJECT
209 private:
210  TestIndividual* test;
211  QStringList fileList;
212  QComboBox* combo;
213  QListWidget* list;
214 public:
215  TestIndividualGUI(TestIndividual* tb, QWidget *parent = NULL, Qt::WindowFlags flags=0);
216 private slots:
217  void agentClicked();
218  void populateCombo();
219  void seedWasChosen();
220 };
221 
222 } //end namespace farsa
223 
224 #endif
225 
The wrapper widget for RenderWorld.
A gui visualizing the camera and the projection of objects on the retina.
Genetic algorithm from evorobot more or less (spare parts)
Definition: evoga.h:50
This class setup an evolutionary experiment.
Test a specific individual taken from evolutionary data.
Definition: tests.h:78