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 //ModuleGenerator:write:0 - add new module class forward declaration
52 
54 class TabWidget : public QTabWidget
55 {
56  Q_OBJECT
57 
58 private:
59  QLabel *infoLabel;
60  QHBoxLayout *infoLayout;
61 
62 public:
63  TabWidget();
64  QTabBar* tabBar();
65  QToolButton *addModuleButton;
66  int newTabID;
67  bool removed;
68 
69  void duplicateSelectedTab();
70  void removeSelectedTab();
71  void addInfoLabel();
72  void removeInfoLabel();
73 
74 signals:
75  void tabRemoved(int id);
76  void removeRequested(int id);
77  void duplicateRequested(int id);
78 };
79 
80 class MainWindow : public QMainWindow
81 {
82  Q_OBJECT
83 
84 public:
85  MainWindow(QWidget *parent=0, QString aquilaVersion=0, QString hostName=0, QString yarpVersion=0);
86  ~MainWindow();
87 
88  Ui::MainWindow *ui;
91 
92  #ifdef NTDDI_WIN7
93  Win7ProgressBar *win7progressBar;
94  #endif
95 
96  struct Server
97  {
98  QString id;
99  QString info;
100  QString portName;
101  QStringList modules;
103  };
104 
105  void createViewMenu();
106  void createToolsMenu();
107  void createHelpMenu();
108  void showProgressBar();
109  void hideProgressBar();
110  void probeServers(bool useRemoteServers);
111  void addLocalModules(QStringList requestedModule);
112  void addRemoteModules(QVector<Server> requestedModules);
113  void setProgressBarValue(int currentValue);
114  bool progressBarVisible();
115  bool addModule(QString module, QString server);
116 
117  #ifdef NTDDI_WIN7
118  virtual bool winEvent(MSG *message, long *result);
119  #endif
120 
121 private:
122  //pointers to module objects
124  MTRNN *mtrnn[MAX_MODULE_INSTANCES];
125  Tracker *tracker[MAX_MODULE_INSTANCES];
127  //ModuleGenerator:write:1 - add new module array of pointers to instances
128 
129  QSignalMapper *toolsSignalMapper;
130  QProgressBar *progressBar;
131  QTabWidget *serverTabWidget;
132  QComboBox *moduleCombobox;
133  QComboBox *serverCombobox;
134  QDialog *newTabDialog;
135  QProcess *serverProcess;
136  QAction *viewServersAct;
137  QAction *addTabAct;
138  QAction *quitAct;
139  QAction *toolsAct[MAX_TOOLS];
140  QAction *aboutAct;
141  QMenu *fileMenu;
142  QMenu *viewMenu;
143  QMenu *toolsMenu;
144  QMenu *helpMenu;
145  QString localHostName;
146  QString minimumYarpVersion;
147  QString program;
148  QStringList servers;
149  QStringList modules;
150  QStringList arguments;
151 
152  Server server[MAX_SERVERS];
153 
154  bool serverProcessRunning;
155 
156  void initialiseTabWidget();
157  void initialiseProgressBar();
158  void initialiseModules();
159  void initialiseServer();
160  void createFileMenu();
161  int getModuleID(QString portPrefix);
162 
163 private slots:
164  void about();
165  void aboutToQuit();
166  void quit();
167  void createMenu();
168  void showMenu();
169  void showNewTabDialog();
170  void refreshServerDialog();
171  void refreshNewTabDialog();
172  void readServerOutput();
173  void viewServers();
174  void startTool(int toolID);
175  void showContextMenu(const QPoint& cursorPosition);
176  void serverComboboxChanged(int serverID);
177 
178 public slots:
179  bool addModule();
180 
181 signals:
182  void quitting();
183 };
184 
185 #endif//MAIN_WINDOW_H