1 | import sys |
---|
2 | |
---|
3 | from PyQt4 import QtCore |
---|
4 | from PyQt4 import QtGui |
---|
5 | |
---|
6 | # General SAS imports |
---|
7 | import LocalConfig |
---|
8 | from GuiUtils import * |
---|
9 | |
---|
10 | # Perspectives |
---|
11 | from Perspectives.Invariant.InvariantPerspective import InvariantWindow |
---|
12 | from DataExplorer import DataExplorerWindow |
---|
13 | from WelcomePanel import WelcomePanel |
---|
14 | |
---|
15 | class GuiManager(object): |
---|
16 | """ |
---|
17 | Main SasView window functionality |
---|
18 | """ |
---|
19 | def __init__(self, mainWindow=None, reactor=None, parent=None): |
---|
20 | """ |
---|
21 | |
---|
22 | """ |
---|
23 | self._workspace = mainWindow |
---|
24 | self._parent = parent |
---|
25 | |
---|
26 | # Reactor passed from above |
---|
27 | self.setReactor(reactor) |
---|
28 | |
---|
29 | # Add signal callbacks |
---|
30 | self.addCallbacks() |
---|
31 | |
---|
32 | # Create the data manager |
---|
33 | #self._data_manager = DataManager() |
---|
34 | |
---|
35 | # Create action triggers |
---|
36 | self.addTriggers() |
---|
37 | |
---|
38 | # Populate menus with dynamic data |
---|
39 | # |
---|
40 | # Analysis/Perspectives - potentially |
---|
41 | # Window/current windows |
---|
42 | # |
---|
43 | |
---|
44 | # Widgets |
---|
45 | # |
---|
46 | # Add FileDialog widget as docked |
---|
47 | self.filesWidget = DataExplorerWindow(parent, self) |
---|
48 | #flags = (QtCore.Qt.Window | QtCore.Qt.WindowTitleHint | QtCore.Qt.CustomizeWindowHint) |
---|
49 | |
---|
50 | self.dockedFilesWidget = QtGui.QDockWidget("File explorer", self._workspace) |
---|
51 | self.dockedFilesWidget.setWidget(self.filesWidget) |
---|
52 | self._workspace.addDockWidget(QtCore.Qt.DockWidgetArea(1), self.dockedFilesWidget) |
---|
53 | # Disable the close button (?) |
---|
54 | # Show the Welcome panel |
---|
55 | self.welcomePanel = WelcomePanel() |
---|
56 | self._workspace.workspace.addWindow(self.welcomePanel) |
---|
57 | |
---|
58 | #========================================================== |
---|
59 | # TEMP PROTOTYPE |
---|
60 | # Add InvariantWindow to the workspace. |
---|
61 | self.invariantWidget = InvariantWindow(self) |
---|
62 | self._workspace.workspace.addWindow(self.invariantWidget) |
---|
63 | |
---|
64 | # Default perspective |
---|
65 | self._current_perspective = self.invariantWidget |
---|
66 | |
---|
67 | def fileRead(self, data): |
---|
68 | """ |
---|
69 | """ |
---|
70 | print("FILE %s "%data) |
---|
71 | pass |
---|
72 | |
---|
73 | def updatePerspective(self, data): |
---|
74 | """ |
---|
75 | """ |
---|
76 | assert isinstance(data, list) |
---|
77 | if self._current_perspective is not None: |
---|
78 | self._current_perspective.setData(data.values()) |
---|
79 | else: |
---|
80 | msg = "No perspective is currently active." |
---|
81 | logging.info(msg) |
---|
82 | |
---|
83 | |
---|
84 | def communicator(self): |
---|
85 | """ |
---|
86 | """ |
---|
87 | return self.communicate |
---|
88 | |
---|
89 | def reactor(self): |
---|
90 | """ |
---|
91 | """ |
---|
92 | return self._reactor |
---|
93 | |
---|
94 | def setReactor(self, reactor): |
---|
95 | """ |
---|
96 | """ |
---|
97 | self._reactor = reactor |
---|
98 | |
---|
99 | def perspective(self): |
---|
100 | """ |
---|
101 | """ |
---|
102 | return self._current_perspective |
---|
103 | |
---|
104 | def updateStatusBar(self, text): |
---|
105 | """ |
---|
106 | """ |
---|
107 | self._workspace.statusbar.showMessage(text) |
---|
108 | |
---|
109 | #def createGuiData(self, item, p_file): |
---|
110 | # """ |
---|
111 | # """ |
---|
112 | # return self._data_manager.create_gui_data(item, p_file) |
---|
113 | |
---|
114 | def addData(self, data_list): |
---|
115 | """ |
---|
116 | receive a dictionary of data from loader |
---|
117 | store them its data manager if possible |
---|
118 | send to data the current active perspective if the data panel |
---|
119 | is not active. |
---|
120 | :param data_list: dictionary of data's ID and value Data |
---|
121 | """ |
---|
122 | #Store data into manager |
---|
123 | #self._data_manager.add_data(data_list) |
---|
124 | |
---|
125 | # set data in the data panel |
---|
126 | #if self._data_panel is not None: |
---|
127 | # data_state = self._data_manager.get_data_state(data_list.keys()) |
---|
128 | # self._data_panel.load_data_list(data_state) |
---|
129 | |
---|
130 | #if the data panel is shown wait for the user to press a button |
---|
131 | #to send data to the current perspective. if the panel is not |
---|
132 | #show automatically send the data to the current perspective |
---|
133 | #style = self.__gui_style & GUIFRAME.MANAGER_ON |
---|
134 | #if style == GUIFRAME.MANAGER_ON: |
---|
135 | # #wait for button press from the data panel to set_data |
---|
136 | # if self._data_panel is not None: |
---|
137 | # self._data_panel.frame.Show(True) |
---|
138 | #else: |
---|
139 | #automatically send that to the current perspective |
---|
140 | #self.setData(data_id=data_list.keys()) |
---|
141 | pass |
---|
142 | |
---|
143 | def setData(self, data): |
---|
144 | """ |
---|
145 | Sends data to current perspective |
---|
146 | """ |
---|
147 | if self._current_perspective is not None: |
---|
148 | self._current_perspective.setData(data.values()) |
---|
149 | else: |
---|
150 | msg = "Guiframe does not have a current perspective" |
---|
151 | logging.info(msg) |
---|
152 | |
---|
153 | def addCallbacks(self): |
---|
154 | """ |
---|
155 | """ |
---|
156 | self.communicate = Communicate() |
---|
157 | self.communicate.fileDataReceivedSignal.connect(self.fileRead) |
---|
158 | self.communicate.statusBarUpdateSignal.connect(self.updateStatusBar) |
---|
159 | self.communicate.updatePerspectiveWithDataSignal.connect(self.updatePerspective) |
---|
160 | |
---|
161 | def addTriggers(self): |
---|
162 | """ |
---|
163 | Trigger definitions for all menu/toolbar actions. |
---|
164 | """ |
---|
165 | # File |
---|
166 | self._workspace.actionLoadData.triggered.connect(self.actionLoadData) |
---|
167 | self._workspace.actionLoad_Data_Folder.triggered.connect(self.actionLoad_Data_Folder) |
---|
168 | self._workspace.actionOpen_Project.triggered.connect(self.actionOpen_Project) |
---|
169 | self._workspace.actionOpen_Analysis.triggered.connect(self.actionOpen_Analysis) |
---|
170 | self._workspace.actionSave.triggered.connect(self.actionSave) |
---|
171 | self._workspace.actionSave_Analysis.triggered.connect(self.actionSave_Analysis) |
---|
172 | self._workspace.actionQuit.triggered.connect(self.actionQuit) |
---|
173 | # Edit |
---|
174 | self._workspace.actionUndo.triggered.connect(self.actionUndo) |
---|
175 | self._workspace.actionRedo.triggered.connect(self.actionRedo) |
---|
176 | self._workspace.actionCopy.triggered.connect(self.actionCopy) |
---|
177 | self._workspace.actionPaste.triggered.connect(self.actionPaste) |
---|
178 | self._workspace.actionReport.triggered.connect(self.actionReport) |
---|
179 | self._workspace.actionReset.triggered.connect(self.actionReset) |
---|
180 | self._workspace.actionExcel.triggered.connect(self.actionExcel) |
---|
181 | self._workspace.actionLatex.triggered.connect(self.actionLatex) |
---|
182 | |
---|
183 | # View |
---|
184 | self._workspace.actionShow_Grid_Window.triggered.connect(self.actionShow_Grid_Window) |
---|
185 | self._workspace.actionHide_Toolbar.triggered.connect(self.actionHide_Toolbar) |
---|
186 | self._workspace.actionStartup_Settings.triggered.connect(self.actionStartup_Settings) |
---|
187 | self._workspace.actionCategry_Manager.triggered.connect(self.actionCategry_Manager) |
---|
188 | # Tools |
---|
189 | self._workspace.actionData_Operation.triggered.connect(self.actionData_Operation) |
---|
190 | self._workspace.actionSLD_Calculator.triggered.connect(self.actionSLD_Calculator) |
---|
191 | self._workspace.actionDensity_Volume_Calculator.triggered.connect(self.actionDensity_Volume_Calculator) |
---|
192 | self._workspace.actionSlit_Size_Calculator.triggered.connect(self.actionSlit_Size_Calculator) |
---|
193 | self._workspace.actionSAS_Resolution_Estimator.triggered.connect(self.actionSAS_Resolution_Estimator) |
---|
194 | self._workspace.actionGeneric_Scattering_Calculator.triggered.connect(self.actionGeneric_Scattering_Calculator) |
---|
195 | self._workspace.actionPython_Shell_Editor.triggered.connect(self.actionPython_Shell_Editor) |
---|
196 | self._workspace.actionImage_Viewer.triggered.connect(self.actionImage_Viewer) |
---|
197 | # Fitting |
---|
198 | self._workspace.actionNew_Fit_Page.triggered.connect(self.actionNew_Fit_Page) |
---|
199 | self._workspace.actionConstrained_Fit.triggered.connect(self.actionConstrained_Fit) |
---|
200 | self._workspace.actionCombine_Batch_Fit.triggered.connect(self.actionCombine_Batch_Fit) |
---|
201 | self._workspace.actionFit_Options.triggered.connect(self.actionFit_Options) |
---|
202 | self._workspace.actionFit_Results.triggered.connect(self.actionFit_Results) |
---|
203 | self._workspace.actionChain_Fitting.triggered.connect(self.actionChain_Fitting) |
---|
204 | self._workspace.actionEdit_Custom_Model.triggered.connect(self.actionEdit_Custom_Model) |
---|
205 | # Window |
---|
206 | self._workspace.actionCascade.triggered.connect(self.actionCascade) |
---|
207 | self._workspace.actionTile_Horizontally.triggered.connect(self.actionTile_Horizontally) |
---|
208 | self._workspace.actionTile_Vertically.triggered.connect(self.actionTile_Vertically) |
---|
209 | self._workspace.actionArrange_Icons.triggered.connect(self.actionArrange_Icons) |
---|
210 | self._workspace.actionNext.triggered.connect(self.actionNext) |
---|
211 | self._workspace.actionPrevious.triggered.connect(self.actionPrevious) |
---|
212 | # Analysis |
---|
213 | self._workspace.actionFitting.triggered.connect(self.actionFitting) |
---|
214 | self._workspace.actionInversion.triggered.connect(self.actionInversion) |
---|
215 | self._workspace.actionInvariant.triggered.connect(self.actionInvariant) |
---|
216 | # Help |
---|
217 | self._workspace.actionDocumentation.triggered.connect(self.actionDocumentation) |
---|
218 | self._workspace.actionTutorial.triggered.connect(self.actionTutorial) |
---|
219 | self._workspace.actionAcknowledge.triggered.connect(self.actionAcknowledge) |
---|
220 | self._workspace.actionAbout.triggered.connect(self.actionAbout) |
---|
221 | self._workspace.actionCheck_for_update.triggered.connect(self.actionCheck_for_update) |
---|
222 | |
---|
223 | #============ FILE ================= |
---|
224 | def actionLoadData(self): |
---|
225 | """ |
---|
226 | Load file from Data Explorer |
---|
227 | """ |
---|
228 | self.filesWidget.loadFile() |
---|
229 | |
---|
230 | def actionLoad_Data_Folder(self): |
---|
231 | """ |
---|
232 | """ |
---|
233 | self.filesWidget.loadFolder() |
---|
234 | |
---|
235 | def actionOpen_Project(self): |
---|
236 | """ |
---|
237 | """ |
---|
238 | print("actionOpen_Project TRIGGERED") |
---|
239 | pass |
---|
240 | |
---|
241 | def actionOpen_Analysis(self): |
---|
242 | """ |
---|
243 | """ |
---|
244 | print("actionOpen_Analysis TRIGGERED") |
---|
245 | pass |
---|
246 | |
---|
247 | def actionSave(self): |
---|
248 | """ |
---|
249 | """ |
---|
250 | print("actionSave TRIGGERED") |
---|
251 | pass |
---|
252 | |
---|
253 | def actionSave_Analysis(self): |
---|
254 | """ |
---|
255 | """ |
---|
256 | print("actionSave_Analysis TRIGGERED") |
---|
257 | pass |
---|
258 | |
---|
259 | def actionQuit(self): |
---|
260 | """ |
---|
261 | """ |
---|
262 | print("actionQuit TRIGGERED") |
---|
263 | pass |
---|
264 | |
---|
265 | #============ EDIT ================= |
---|
266 | def actionUndo(self): |
---|
267 | """ |
---|
268 | """ |
---|
269 | print("actionUndo TRIGGERED") |
---|
270 | pass |
---|
271 | |
---|
272 | def actionRedo(self): |
---|
273 | """ |
---|
274 | """ |
---|
275 | print("actionRedo TRIGGERED") |
---|
276 | pass |
---|
277 | |
---|
278 | def actionCopy(self): |
---|
279 | """ |
---|
280 | """ |
---|
281 | print("actionCopy TRIGGERED") |
---|
282 | pass |
---|
283 | |
---|
284 | def actionPaste(self): |
---|
285 | """ |
---|
286 | """ |
---|
287 | print("actionPaste TRIGGERED") |
---|
288 | pass |
---|
289 | |
---|
290 | def actionReport(self): |
---|
291 | """ |
---|
292 | """ |
---|
293 | print("actionReport TRIGGERED") |
---|
294 | pass |
---|
295 | |
---|
296 | def actionReset(self): |
---|
297 | """ |
---|
298 | """ |
---|
299 | print("actionReset TRIGGERED") |
---|
300 | pass |
---|
301 | |
---|
302 | def actionExcel(self): |
---|
303 | """ |
---|
304 | """ |
---|
305 | print("actionExcel TRIGGERED") |
---|
306 | pass |
---|
307 | |
---|
308 | def actionLatex(self): |
---|
309 | """ |
---|
310 | """ |
---|
311 | print("actionLatex TRIGGERED") |
---|
312 | pass |
---|
313 | |
---|
314 | #============ VIEW ================= |
---|
315 | def actionShow_Grid_Window(self): |
---|
316 | """ |
---|
317 | """ |
---|
318 | print("actionShow_Grid_Window TRIGGERED") |
---|
319 | pass |
---|
320 | |
---|
321 | def actionHide_Toolbar(self): |
---|
322 | """ |
---|
323 | """ |
---|
324 | print("actionHide_Toolbar TRIGGERED") |
---|
325 | pass |
---|
326 | |
---|
327 | def actionStartup_Settings(self): |
---|
328 | """ |
---|
329 | """ |
---|
330 | print("actionStartup_Settings TRIGGERED") |
---|
331 | pass |
---|
332 | |
---|
333 | def actionCategry_Manager(self): |
---|
334 | """ |
---|
335 | """ |
---|
336 | print("actionCategry_Manager TRIGGERED") |
---|
337 | pass |
---|
338 | |
---|
339 | #============ TOOLS ================= |
---|
340 | def actionData_Operation(self): |
---|
341 | """ |
---|
342 | """ |
---|
343 | print("actionData_Operation TRIGGERED") |
---|
344 | pass |
---|
345 | |
---|
346 | def actionSLD_Calculator(self): |
---|
347 | """ |
---|
348 | """ |
---|
349 | print("actionSLD_Calculator TRIGGERED") |
---|
350 | pass |
---|
351 | |
---|
352 | def actionDensity_Volume_Calculator(self): |
---|
353 | """ |
---|
354 | """ |
---|
355 | print("actionDensity_Volume_Calculator TRIGGERED") |
---|
356 | pass |
---|
357 | |
---|
358 | def actionSlit_Size_Calculator(self): |
---|
359 | """ |
---|
360 | """ |
---|
361 | print("actionSlit_Size_Calculator TRIGGERED") |
---|
362 | pass |
---|
363 | |
---|
364 | def actionSAS_Resolution_Estimator(self): |
---|
365 | """ |
---|
366 | """ |
---|
367 | print("actionSAS_Resolution_Estimator TRIGGERED") |
---|
368 | pass |
---|
369 | |
---|
370 | def actionGeneric_Scattering_Calculator(self): |
---|
371 | """ |
---|
372 | """ |
---|
373 | print("actionGeneric_Scattering_Calculator TRIGGERED") |
---|
374 | pass |
---|
375 | |
---|
376 | def actionPython_Shell_Editor(self): |
---|
377 | """ |
---|
378 | """ |
---|
379 | print("actionPython_Shell_Editor TRIGGERED") |
---|
380 | pass |
---|
381 | |
---|
382 | def actionImage_Viewer(self): |
---|
383 | """ |
---|
384 | """ |
---|
385 | print("actionImage_Viewer TRIGGERED") |
---|
386 | pass |
---|
387 | |
---|
388 | #============ FITTING ================= |
---|
389 | def actionNew_Fit_Page(self): |
---|
390 | """ |
---|
391 | """ |
---|
392 | print("actionNew_Fit_Page TRIGGERED") |
---|
393 | pass |
---|
394 | |
---|
395 | def actionConstrained_Fit(self): |
---|
396 | """ |
---|
397 | """ |
---|
398 | print("actionConstrained_Fit TRIGGERED") |
---|
399 | pass |
---|
400 | |
---|
401 | def actionCombine_Batch_Fit(self): |
---|
402 | """ |
---|
403 | """ |
---|
404 | print("actionCombine_Batch_Fit TRIGGERED") |
---|
405 | pass |
---|
406 | |
---|
407 | def actionFit_Options(self): |
---|
408 | """ |
---|
409 | """ |
---|
410 | print("actionFit_Options TRIGGERED") |
---|
411 | pass |
---|
412 | |
---|
413 | def actionFit_Results(self): |
---|
414 | """ |
---|
415 | """ |
---|
416 | print("actionFit_Results TRIGGERED") |
---|
417 | pass |
---|
418 | |
---|
419 | def actionChain_Fitting(self): |
---|
420 | """ |
---|
421 | """ |
---|
422 | print("actionChain_Fitting TRIGGERED") |
---|
423 | pass |
---|
424 | |
---|
425 | def actionEdit_Custom_Model(self): |
---|
426 | """ |
---|
427 | """ |
---|
428 | print("actionEdit_Custom_Model TRIGGERED") |
---|
429 | pass |
---|
430 | |
---|
431 | #============ ANALYSIS ================= |
---|
432 | def actionFitting(self): |
---|
433 | """ |
---|
434 | """ |
---|
435 | print("actionFitting TRIGGERED") |
---|
436 | pass |
---|
437 | |
---|
438 | def actionInversion(self): |
---|
439 | """ |
---|
440 | """ |
---|
441 | print("actionInversion TRIGGERED") |
---|
442 | pass |
---|
443 | |
---|
444 | def actionInvariant(self): |
---|
445 | """ |
---|
446 | """ |
---|
447 | print("actionInvariant TRIGGERED") |
---|
448 | pass |
---|
449 | |
---|
450 | #============ WINDOW ================= |
---|
451 | def actionCascade(self): |
---|
452 | """ |
---|
453 | """ |
---|
454 | print("actionCascade TRIGGERED") |
---|
455 | pass |
---|
456 | |
---|
457 | def actionTile_Horizontally(self): |
---|
458 | """ |
---|
459 | """ |
---|
460 | print("actionTile_Horizontally TRIGGERED") |
---|
461 | pass |
---|
462 | |
---|
463 | def actionTile_Vertically(self): |
---|
464 | """ |
---|
465 | """ |
---|
466 | print("actionTile_Vertically TRIGGERED") |
---|
467 | pass |
---|
468 | |
---|
469 | def actionArrange_Icons(self): |
---|
470 | """ |
---|
471 | """ |
---|
472 | print("actionArrange_Icons TRIGGERED") |
---|
473 | pass |
---|
474 | |
---|
475 | def actionNext(self): |
---|
476 | """ |
---|
477 | """ |
---|
478 | print("actionNext TRIGGERED") |
---|
479 | pass |
---|
480 | |
---|
481 | def actionPrevious(self): |
---|
482 | """ |
---|
483 | """ |
---|
484 | print("actionPrevious TRIGGERED") |
---|
485 | pass |
---|
486 | |
---|
487 | #============ HELP ================= |
---|
488 | def actionDocumentation(self): |
---|
489 | """ |
---|
490 | """ |
---|
491 | print("actionDocumentation TRIGGERED") |
---|
492 | pass |
---|
493 | |
---|
494 | def actionTutorial(self): |
---|
495 | """ |
---|
496 | """ |
---|
497 | print("actionTutorial TRIGGERED") |
---|
498 | pass |
---|
499 | |
---|
500 | def actionAcknowledge(self): |
---|
501 | """ |
---|
502 | """ |
---|
503 | print("actionAcknowledge TRIGGERED") |
---|
504 | pass |
---|
505 | |
---|
506 | def actionAbout(self): |
---|
507 | """ |
---|
508 | """ |
---|
509 | print("actionAbout TRIGGERED") |
---|
510 | pass |
---|
511 | |
---|
512 | def actionCheck_for_update(self): |
---|
513 | """ |
---|
514 | """ |
---|
515 | print("actionCheck_for_update TRIGGERED") |
---|
516 | pass |
---|
517 | |
---|