File: mainWindow.h

package info (click to toggle)
ball 1.4.3~beta1-3
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 318,984 kB
  • sloc: cpp: 346,579; ansic: 4,097; python: 2,664; yacc: 1,778; lex: 1,099; xml: 964; sh: 688; sql: 316; awk: 118; makefile: 108
file content (309 lines) | stat: -rw-r--r-- 9,009 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309

#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QtGui/QMainWindow>
#include <QtGui/QMenu>
#include <QtGui/QDialog>
#include <QtGui/QToolBar>
#include <QtGui/QAction>
#include <QtGui/QContextMenuEvent>
#include <QtGui/QProgressBar>

#include <dataItemView.h>
#include <dataItemScene.h>
#include <dataItem.h>
#include <modelItem.h>
#include <inputDataItem.h>
#include <CSVInputDataItem.h>
#include <featureSelectionItem.h>
#include <validationItem.h>
#include <predictionItem.h>
#include <SDFInputDialog.h>
#include <fileBrowser.h>
#include <modelConfigurationDialog.h>
#include <featureSelectionDialog.h>
#include <validationDialog.h>
#include <partitioningItem.h>
#include <inputPartitionItem.h>
#include <pipeline.h>

#include <BALL/QSAR/registry.h>
#include <BALL/SYSTEM/path.h>


namespace BALL
{
	namespace VIEW
	{
		
		BALL::String valueToString(double value);
		
		
		class ModelConfigurationDialog;

		/** @class MainWindow
		* @brief the main application
		*
		* @todo
		*/
		class MainWindow : public QMainWindow
		{
			Q_OBJECT
			
			public:
				
				/** @name Constructors and Destructors*/
	
				/** constructor*/
				MainWindow();
				
				MainWindow(char* executable_directory);

				/** destructor */
				~MainWindow();
			

				/** creation of items*/
				SDFInputDataItem* createSDFInput(QString filename);
				CSVInputDataItem* createCSVInput(QString filename);
				CSVInputDataItem* createCSVInput(BALL::QSAR::QSARData* data);
				
				ModelItem* createModel(ModelItem* model, InputDataItem* input=NULL);
				FeatureSelectionItem* createFeatureSelection(FeatureSelectionItem* fs, ModelItem* model=0, ModelItem* in_model=0);
				ValidationItem* createValidation(ValidationItem* val, ModelItem* model=0);
				PredictionItem* createPrediction(InputDataItem* input, ModelItem* model);
				
				int chooseValidationStatisticDialog(ModelItem* modelitem);
				
				//void changeModelItem(ModelItem* model, InputDataItem* input);

				BALL::QSAR::Registry* registry();
				Pipeline<ModelItem*> getModelPipeline();

				/**add items to pipeline */
				//void addInputToPipeline(InputDataItem* item);
				//void addModelToPipeline(ModelItem* item);
				//void addPredictionToPipeline(PredictionItem* item);
// 				void addFeatureSelectionToPipeline(FeatureSelectionItem* item);
// 				void addValidationToPipeline(ValidationItem* item);
				void addDisconnectedItem(DataItem* item);
				

				Pipeline<DataItem*> disconnectedItems();
				
				/** submits the pipeline that was saved into configfile to a cluster */
				void submitToCluster(String configfile);
				
				String getDataDirectory();
				
				/** @name Attributes */
				/** pointer to the item that is currently being dragged */
				DataItem* dragged_item;
				
				/** name of the widget from which the current drag originated, i.e. "source_list", "model_list" or "view" */
				string drag_source;
				PreciseTime drag_start_time;
				
				/* shortest desired duration of a mouse drag in units of seconds */
				double min_drag_time;
				
				void setLastUsedPath(String path);
				
				/** checks whether the given item exists in any of this MainWindow's pipelines */
				bool itemExists(DataItem* item);
				
				 /** before calling QGraphicsScene-update, checks for all models whether they are to be disabled and sets pixmaps accordingly */
				void updatePipelineScene();

				Pipeline<SDFInputDataItem*> sdf_input_pipeline_;
				Pipeline<CSVInputDataItem*> csv_input_pipeline_;
				Pipeline<ModelItem*> model_pipeline_;
				Pipeline<FeatureSelectionItem*> fs_pipeline_;
				Pipeline<ValidationItem*> val_pipeline_;
				Pipeline<PredictionItem*> prediction_pipeline_;
				Pipeline<DataItem*> disconnected_items_;
				Pipeline<PartitioningItem*> partitioning_pipeline_;
				Pipeline<InputPartitionItem*> partition_pipeline_;
				
				Pipeline<DataItem*> all_items_pipeline_;
				
				const String* getDescriptorExplanation(String descriptor_name);
				
			
			private slots:
				
				/** @name private slots
				*/
				void about();	
				void clearDesktop();
				void restoreDesktop(QString filename);
				void deleteItem();
				void restoreDesktop();
				void executePipeline();
				void zoomIn();
				void zoomOut();
				
				/** exports the pipeline to files and return the name of the created config-file */
				String exportPipeline();
				
			//	void exportPipeline(QString filename, bool ext);
				void exportPipeline(QString filename);
				void print();
				void printToFile();
				
				/** submits the current pipeline to a cluster */
				void submit();
				
				/** displays a preferences dialog that allow setting the cluster's queue parameters */
				void preferencesDialog();
				
				/** switches to fullscreen and from fullscreen back to normal view */
				void fullscreen();
				
				void showDocumentation();
				
				
			private:
				
				struct Settings
				{			
					String input_data_path;
					String config_path;
					int size_x;
					int size_y;
					int pos_x;
					int pos_y;
					
					/** the prefix for submitting a job to the cluster, \n
					  e.g. "qsub -cwd" or "bsub" or "qsub -q long.q" ... **/
					String submit_prefix;
					
					/** path to the installation of QSARPipelinePackage */
					String tools_path;
					
					/** determines whether an email is to be send after completion of a submitted job */
					bool send_email;
					
					/** determines to which email address a notification of job completion should be send */
					String email_address;
					
					/** a folder where data may be stored temporarily */
					String tmp_folder;
					
					/** The character separating directories in a path. \n
					By default BALL::FileSystem::PATH_SEPARATOR is used */
					String path_separator;
					
					/** names of files containing explanations for descriptors */
					list<String> descriptor_explanation_files;
					
					/** determines whether the documentation is to be shown at start-up */
					bool show_documentation;
					
					MainWindow* main_window;
					
					void saveToFile(String file);
					
					void readFromFile(String file);
				};
				
				 /// the last used paths settings
				Settings settings;
		
				void init();
				void createMenus();
				void createToolBars();
				void createStatusBar();
				void createActions();
				void createDockWindows();
				void createDialogs();
				
				/** saves the data of all InputItems and ModelItems to files.
				@param archive if specified, the created files are compressed and saved as an archive (e.g. *.tar.gz) */
				void saveItemsToFiles(String directory, String archive="", String configfile="");
				
				void loadItemsFromFiles(String directory);
				
				/** check whether the pipeline is not empty. Can be called before saving, submitting, printing the current pipeline.\n
				If no items have been created yet, a message box is displayed 
				@return true if pipelines are empty, false otherwise */
				bool checkForEmptyPipelines();
				
				/** exports the current Pipeline to file(s).
				@param no_immediate_archiving if true, the pipeline is saved as several files even if tar.gz archive was chosen. All created files will later be archived _after_ all calculation on the cluster for this pipeline are ready. */
				String exportPipeline(bool no_immediate_archiving);
				
				void readDescriptorExplanations();

				void setProgressValue(int);
			
				/** @name Private Attributes */

				DataItemView* view_;
				DataItemView* model_list_;
				DataItemView* fs_list_;
				DataItemView* val_list_;

				DataItemScene view_scene_;
				DataItemScene model_list_scene_;
				DataItemScene fs_list_scene_;
				DataItemScene val_list_scene_;
				
				std::map<String,String> descriptor_explanations_;
				bool read_descriptor_explanations_;
				
				/** List of all dock-widget of the mainWindow. It is used for switching to/from fullscreen mode by hiding all dockwidgets */
				list<QDockWidget*> dockwidgets_;
				list<bool> dockwidget_enabled_;
				
				/** is fullscreen currently enabled? */
				bool fullscreen_;
				
				
				/**registry including all available models */	
				BALL::QSAR::Registry* reg_;
				//Path* path_;

				QProgressBar* progress_bar_;
				FileBrowser* file_browser_;
				QDockWidget* documentation_;
		
				ModelConfigurationDialog* modelConfigurationDialog_;

				/** @name Menues
				*/
				QMenu* fileMenu_;
				QMenu* editMenu_;
				QMenu* helpMenu_;
				QMenu* windowMenu_;
			
				/** @name Toolbars
				*/
				QToolBar *fileToolBar_;
			
				/** @name Actions
				*/
				QAction* exitAct_;
				QAction* aboutAct_;
				QAction* clearAct_;
				QAction* delAct_;
				QAction* modelAct_;
				QAction* executeAct_;
				QAction* restoreAct_;
				QAction* exportAct_;
				QAction* fullscreen_action_;
				
				/** The directory of the executable of this program.\n
				It is used to find subfolders for icons and documentation and has to be set from main.C */
				String executable_directory_;
				
				String data_directory_;
				
				friend class ModelItem;
		};
	}
}	

 #endif