source: sasview/src/sas/qtgui/GuiManager.py @ f721030

ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalc
Last change on this file since f721030 was f721030, checked in by Piotr Rozyczko <piotr.rozyczko@…>, 8 years ago

Initial commit of the main window prototype

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