Aquila  2.0 prealpha
Cognitive Robotics Architecture
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
mainWindow.h
Go to the documentation of this file.
1 //##############################################################################################################################################################################################################//
2 //Aquila - An Open-Source GPU-Accelerated Toolkit for Cognitive and Neuro-Robotics Research //
3 // //
4 //Copyright (c) <2012>, <Martin Peniak - www.martinpeniak.com> //
5 //All rights reserved. //
6 // //
7 //Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: //
8 // //
9 // - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. //
10 // - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. //
11 // //
12 //THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR //
13 //A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT //
14 //LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR //
15 //TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. //
16 // //
17 //The views and conclusions contained in the software and documentation are those of the authors and should not be interpreted //
18 //as representing official policies,either expressed or implied, of the FreeBSD Project. //
19 //##############################################################################################################################################################################################################//
20 
21 #ifndef MAIN_WINDOW_H
22 #define MAIN_WINDOW_H
23 
24 #include <QtGui>
25 
26 #if defined _WIN64 || defined _WIN32
27 #include <Windows.h>
28 #endif
29 
30 #ifdef NTDDI_WIN7
31 #include "win7progressBar.h"
32 #endif
33 
34 #include "moduleGenerator.h"
35 
36 #define MAX_MODULE_INSTANCES 20
37 #define MAX_SERVERS 10
38 #define MAX_TIMEOUT_ATTEMPTS 100
39 #define MAX_GPU_DEVICES 4
40 #define MAX_TOOLS 20
41 
42 namespace Ui
43 {
44  class MainWindow;
45 }
46 
47 class SOM;
48 class MTRNN;
49 class Tracker;
50 class ESN;
51 class xxxxxxxxx;
52 //ModuleGenerator:write:0 - add new module class forward declaration
53 
55 class TabWidget : public QTabWidget
56 {
57  Q_OBJECT
58 
59 private:
60  QLabel *infoLabel;
61  QHBoxLayout *infoLayout;
62 
63 public:
64  TabWidget();
65  QTabBar* tabBar();
66  QToolButton *addModuleButton;
67  int newTabID;
68  bool removed;
69 
70  void duplicateSelectedTab();
71  void removeSelectedTab();
72  void addInfoLabel();
73  void removeInfoLabel();
74 
75 signals:
76  void tabRemoved(int id);
77  void removeRequested(int id);
78  void duplicateRequested(int id);
79 };
80 
81 class MainWindow : public QMainWindow
82 {
83  Q_OBJECT
84 
85 public:
86  MainWindow(QWidget *parent=0, QString aquilaVersion=0, QString hostName=0, QString yarpVersion=0);
87  ~MainWindow();
88 
89  Ui::MainWindow *ui;
92 
93  #ifdef NTDDI_WIN7
94  Win7ProgressBar *win7progressBar;
95  #endif
96 
97  struct Server
98  {
99  QString id;
100  QString info;
101  QString portName;
102  QStringList modules;
104  };
105 
106  void createViewMenu();
107  void createToolsMenu();
108  void createHelpMenu();
109  void showProgressBar();
110  void hideProgressBar();
111  void probeServers(bool useRemoteServers);
112  void addLocalModules(QStringList requestedModule);
113  void addRemoteModules(QVector<Server> requestedModules);
114  void setProgressBarValue(int currentValue);
115  bool progressBarVisible();
116  bool addModule(QString module, QString server);
117 
118  #ifdef NTDDI_WIN7
119  virtual bool winEvent(MSG *message, long *result);
120  #endif
121 
122 private:
123  //pointers to module objects
125  MTRNN *mtrnn[MAX_MODULE_INSTANCES];
126  Tracker *tracker[MAX_MODULE_INSTANCES];
128  Xxxxxxxxx *xxxxxxxxx[MAX_MODULE_INSTANCES];
129  //ModuleGenerator:write:1 - add new module array of pointers to instances
130 
131  QSignalMapper *toolsSignalMapper;
132  QProgressBar *progressBar;
133  QTabWidget *serverTabWidget;
134  QComboBox *moduleCombobox;
135  QComboBox *serverCombobox;
136  QDialog *newTabDialog;
137  QProcess *serverProcess;
138  QAction *viewServersAct;
139  QAction *addTabAct;
140  QAction *quitAct;
141  QAction *toolsAct[MAX_TOOLS];
142  QAction *aboutAct;
143  QMenu *fileMenu;
144  QMenu *viewMenu;
145  QMenu *toolsMenu;
146  QMenu *helpMenu;
147  QString localHostName;
148  QString minimumYarpVersion;
149  QString program;
150  QStringList servers;
151  QStringList modules;
152  QStringList arguments;
153 
154  Server server[MAX_SERVERS];
155 
156  bool serverProcessRunning;
157 
158  void initialiseTabWidget();
159  void initialiseProgressBar();
160  void initialiseModules();
161  void initialiseServer();
162  void createFileMenu();
163  int getModuleID(QString portPrefix);
164 
165 private slots:
166  void about();
167  void aboutToQuit();
168  void quit();
169  void createMenu();
170  void showMenu();
171  void showNewTabDialog();
172  void refreshServerDialog();
173  void refreshNewTabDialog();
174  void readServerOutput();
175  void viewServers();
176  void startTool(int toolID);
177  void showContextMenu(const QPoint& cursorPosition);
178  void serverComboboxChanged(int serverID);
179 
180 public slots:
181  bool addModule();
182 
183 signals:
184  void quitting();
185 };
186 
187 #endif//MAIN_WINDOW_H