source: sasview/sansguiframe/src/sans/guiframe/panel_base.py @ ebf422a

ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalccostrafo411magnetic_scattrelease-4.1.1release-4.1.2release-4.2.2release_4.0.1ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249ticket885unittest-saveload
Last change on this file since ebf422a was d03a356, checked in by Gervaise Alina <gervyh@…>, 13 years ago

working on data processor

  • Property mode set to 100644
File size: 13.7 KB
RevLine 
[b5ca223]1
2
3################################################################################
4#This software was developed by the University of Tennessee as part of the
5#Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
6#project funded by the US National Science Foundation.
7#
8#See the license text in license.txt
9#
10#copyright 2008, University of Tennessee
11################################################################################
12
[03314e7]13
[a45037aa]14from sans.guiframe.events import PanelOnFocusEvent
[c958e30]15from sans.guiframe.events import EVT_NEW_BATCH
[a45037aa]16import wx
[b5ca223]17
18class PanelBase:
19    """
20    Defines the API for a panels to work with
21    the ViewerFrame toolbar and menu bar
22    """
23    ## Internal nickname for the window, used by the AUI manager
[691643c]24    #window_name = "default"
[b5ca223]25    ## Name to appear on the window title bar
[691643c]26    #window_caption = "Welcome panel"
[b5ca223]27    ## Flag to tell the AUI manager to put this panel in the center pane
[75fbd17]28    group_id = None
[df22224]29    uid = None
[b5ca223]30   
[a45037aa]31    def __init__(self, parent=None):
[b5ca223]32        """
33        Initialize some flag that Viewerframe used
34        """
[52725d6]35        #panel manager
36        self._manager = None
[03314e7]37        self.parent = parent
[7bf9a8c]38        if self.parent is not None and hasattr(self.parent, '_manager'):
39            self._manager = self.parent._manager
[b5ca223]40        self._print_flag = False
41        self._undo_flag = False
42        self._redo_flag = False
[07c8630]43        self._copy_flag = False
44        self._paste_flag = False
[b5ca223]45        self._preview_flag = False
46        self._bookmark_flag = False
47        self._zoom_in_flag = False
48        self._zoom_out_flag = False
49        self._zoom_flag = False
50        self._save_flag = False
51        self._drag_flag = False
52        self._reset_flag = False
[03314e7]53        self._has_changed = False
[c958e30]54        self.batch_on = False
[d03a356]55        if self.parent is not None and hasattr(self.parent, "batch_on"):
56            self.batch_on = self.parent.batch_on
57       
[c70eb7c]58        self.group_id = None
[c958e30]59        self.Bind(EVT_NEW_BATCH, self.on_batch_selection)
[a45037aa]60        self.Bind(wx.EVT_LEFT_DOWN, self.on_set_focus)
61        self.Bind(wx.EVT_TEXT_ENTER, self.on_set_focus)
62        self.Bind(wx.EVT_MIDDLE_DOWN, self.on_set_focus)
63        self.Bind(wx.EVT_RIGHT_DOWN, self.on_set_focus)
[03314e7]64       
[c958e30]65    def on_batch_selection(self, event):
66        """
67        :param event: contains parameter enable . when enable is set to True
68        the application is in Batch mode
69        else the application is default mode(single mode)
70        """
71        self.batch_on = event.enable
[6f28e70]72    def save_project(self, doc=None):
73        """
74        return an xml node containing state of the panel
75         that guiframe can write to file
76        """
77        return None
78   
[03314e7]79    def has_changed(self):
80        """
81        """
82        return self._has_changed
83           
[f036c692]84    def _set_print_flag(self, flag=True):
[b5ca223]85        """
86        The derivative class sets the print flag value to indicate that it can
87        be printed
88        """
[03314e7]89        if flag == self._print_flag:
90            self._has_changed = False
91            return
92        self._has_changed = True
[b5ca223]93        self._print_flag = flag
[03314e7]94        if self._manager is not None and self._manager.parent is not None:
[0a2fdca]95            self._manager.parent.cpanel_on_focus = self
[03314e7]96            self._manager.parent.enable_print()
97     
[b5ca223]98    def get_print_flag(self):
99        """
100        Get the print flag to update appropriately the tool bar
101        """
102        return self._print_flag
103   
[f036c692]104    def _set_undo_flag(self, flag=True):
[b5ca223]105        """
106        The derivative class sets the undo flag value to indicate that the
107        current action done can be canceled
108        """
[03314e7]109        if flag == self._undo_flag:
110            self._has_changed = False
111            return
112        self._has_changed = True
[b5ca223]113        self._undo_flag = flag
[03314e7]114        if self._manager is not None and self._manager.parent is not None:
[0a2fdca]115            self._manager.parent.cpanel_on_focus = self
[03314e7]116            self._manager.parent.enable_undo()
117     
[b5ca223]118    def get_undo_flag(self):
119        """
120        Get the undo flag to update appropriately the tool bar
121        """
122        return self._undo_flag
123   
[f036c692]124    def _set_redo_flag(self, flag=True):
[b5ca223]125        """
126        The derivative class sets the redo flag value to indicate that the
127        action done can be recovered
128        """
[03314e7]129        if flag == self._redo_flag:
130            self._has_changed = False
131            return
132        self._has_changed = True
[b5ca223]133        self._redo_flag = flag
[03314e7]134        if self._manager is not None and self._manager.parent is not None:
[0a2fdca]135            self._manager.parent.cpanel_on_focus = self
[03314e7]136            self._manager.parent.enable_redo()
137     
[b5ca223]138    def get_redo_flag(self):
139        """
140        Get the redo flag to update appropriately the tool bar
141        """
142        return self._redo_flag
[07c8630]143
144    def _set_copy_flag(self, flag=True):
145        """
146        The derivative class sets the copy flag value to indicate that the
147        action done can be recovered
148        """
149        if flag == self._copy_flag:
150            self._has_changed = False
151            return
152        self._has_changed = True
153        self._copy_flag = flag
154        if self._manager is not None and self._manager.parent is not None:
155            self._manager.parent.cpanel_on_focus = self
156            self._manager.parent.enable_copy()
157     
158    def get_copy_flag(self):
159        """
160        Get the copy flag to update appropriately the tool bar
161        """
162        return self._copy_flag
[b5ca223]163   
[07c8630]164    def _set_paste_flag(self, flag=True):
165        """
166        The derivative class sets the paste flag value to indicate that the
167        action done can be recovered
168        """
169        if flag == self._paste_flag:
170            self._has_changed = False
171            return
172        self._has_changed = True
173        self._paste_flag = flag
174        if self._manager is not None and self._manager.parent is not None:
175            self._manager.parent.cpanel_on_focus = self
176            self._manager.parent.enable_paste()
177     
178    def get_paste_flag(self):
179        """
180        Get the copy flag to update appropriately the tool bar
181        """
182        return self._copy_flag
183       
[f036c692]184    def _set_zoomed_in_flag(self, flag=True):
[b5ca223]185        """
186        The derivative class sets the zoom in flag value to indicate that it
187        can be zoomed in
188        """
[03314e7]189        if self._zoom_in_flag == flag:
190            self._has_changed = False
191            return
192        self._has_changed = True
[b5ca223]193        self._zoom_in_flag = flag
[03314e7]194        if self._manager is not None and self._manager.parent is not None:
[0a2fdca]195            self._manager.parent.cpanel_on_focus = self
[03314e7]196            self._manager.parent.enable_zoom_in()
197       
[b5ca223]198    def get_zoom_in_flag(self):
199        """
200        Get the zoom in flag to update appropriately the tool bar
201        """
202        return self._zoom_in_flag
203   
[f036c692]204    def _set_zoomed_out_flag(self, flag=True):
[b5ca223]205        """
206        The derivative class sets the zoom out flag value to indicate that it
207        can be zoomed out
208        """
[03314e7]209        if self._zoom_out_flag == flag:
210            self._has_changed = False
211            return
212        self._has_changed = True
[b5ca223]213        self._zoom_out_flag = flag
[03314e7]214        if self._manager is not None and self._manager.parent is not None:
[ecc85443]215            self._manager.parent.panel_on_focus = self
[03314e7]216            self._manager.parent.enable_zoom_out()
[b5ca223]217       
218    def get_zoom_out_flag(self):
219        """
220        Get the zoom out flag to update appropriately the tool bar
221        """
222        return self._zoom_out_flag
223   
[f036c692]224    def _set_zoom_flag(self, flag=True):
[b5ca223]225        """
226        The derivative class sets the zoom flag value to indicate that it
227        can be zoomed
228        """
[03314e7]229        if flag == self._zoom_flag:
230            self._has_changed = False
231            return
232        self._has_changed = True
[b5ca223]233        self._zoom_flag = flag
[03314e7]234        if self._manager is not None and self._manager.parent is not None:
[0a2fdca]235            self._manager.parent.cpanel_on_focus = self
[03314e7]236            self._manager.parent.enable_zoom()
237     
[b5ca223]238    def get_zoom_flag(self):
239        """
240        Get the zoom flag to update appropriately the tool bar
241        """
242        return self._zoom_flag
243   
[f036c692]244    def _set_bookmark_flag(self, flag=True):
[b5ca223]245        """
246        The derivative class sets the bookmark flag value to indicate that it
247        can be bookmarked
248        """
[03314e7]249        if flag == self._bookmark_flag:
250            self._has_changed = False
251            return
252        self._has_changed = True
[b5ca223]253        self._bookmark_flag = flag
[03314e7]254        if self._manager is not None and self._manager.parent is not None:
[0a2fdca]255            self._manager.parent.cpanel_on_focus = self
[03314e7]256            self._manager.parent.enable_bookmark()
[a45037aa]257       
[b5ca223]258    def get_bookmark_flag(self):
259        """
260        Get the bookmark flag to update appropriately the tool bar
261        """
262        return self._bookmark_flag
263   
[f036c692]264    def _set_preview_flag(self, flag=True):
[b5ca223]265        """
266        The derivative class sets the preview flag value to indicate that it
267        can be previewed
268        """
[03314e7]269        if flag == self._preview_flag:
270            self._has_changed = False
271            return
272        self._has_changed = True
[b5ca223]273        self._preview_flag = flag
[03314e7]274        if self._manager is not None and self._manager.parent is not None:
[0a2fdca]275            self._manager.parent.cpanel_on_focus = self
[03314e7]276            self._manager.parent.enable_preview()
277       
[b5ca223]278    def get_preview_flag(self):
279        """
280        Get the preview flag to update appropriately the tool bar
281        """
282        return self._preview_flag
283   
[f036c692]284    def _set_save_flag(self, flag=True):
[b5ca223]285        """
286        The derivative class sets the drag flag value to indicate that it
287        can be saved
288        """
[03314e7]289        if flag == self._save_flag:
290            self._has_changed = False
291            return
292        self._has_changed = True
[b5ca223]293        self._save_flag = flag
[03314e7]294        if self._manager is not None and self._manager.parent is not None:
[0a2fdca]295            self._manager.parent.cpanel_on_focus = self
[03314e7]296            self._manager.parent.enable_save()
[a45037aa]297
[b5ca223]298    def get_save_flag(self):
299        """
300        Get the save flag to update appropriately the tool bar
301        """
302        return self._save_flag
303   
[f036c692]304    def _set_drag_flag(self, flag=True):
[b5ca223]305        """
306        The derivative class sets the drag flag value to indicate that
307        dragging motion is possible
308        """
[03314e7]309        if self._drag_flag == flag:
310            self._has_changed = False
311            return
312        self._has_changed = True
[b5ca223]313        self._drag_flag = flag
[03314e7]314        if self._manager is not None and self._manager.parent is not None:
[0a2fdca]315            self._manager.parent.cpanel_on_focus = self
[03314e7]316            self._manager.parent.enable_drag()
[a45037aa]317       
[b5ca223]318    def get_drag_flag(self):
319        """
320        Get the drag flag to update appropriately the tool bar
321        """
322        return self._drag_flag
323   
[f036c692]324    def _set_reset_flag(self, flag=True):
[b5ca223]325        """
326        The derivative class sets the reset flag value to indicate that it
327        can be reset
328        """
[03314e7]329        if self._reset_flag == flag:
330            self._has_changed = False
331            return
332        self._has_changed = True
[b5ca223]333        self._reset_flag = flag
[03314e7]334        if self._manager is not None and self._manager.parent is not None:
[0a2fdca]335            self._manager.parent.cpanel_on_focus = self
[03314e7]336            self._manager.parent.enable_reset()
[a45037aa]337     
[b5ca223]338    def get_reset_flag(self):
339        """
340        Get the reset flag to update appropriately the tool bar
341        """
342        return self._reset_flag
343
344    def on_reset(self, event):
345        """
346        The derivative class state is restored
347        """
348    def on_drag(self, event):
349        """
350        The derivative class allows dragging motion if implemented
351        """
352    def on_preview(self, event):
353        """
354        Display a printable version of the class derivative
355        """
356    def on_save(self, event):
357        """
358        The state of the derivative class is restored
359        """
360    def on_redo(self, event):
361        """
362        The previous action is restored if possible
363        """
364    def on_undo(self, event):
365        """
366        The current action is canceled
367        """
[07c8630]368    def on_copy(self, event):
369        """
370        The copy action if possible
371        """
372    def on_paste(self, event):
373        """
374        The paste action if possible
375        """
[b5ca223]376    def on_bookmark(self, event):
377        """
378        The derivative class is on bookmark mode if implemented
379        """
380    def on_zoom_in(self, event):
381        """
382        The derivative class is on zoom in mode if implemented
383        """
384    def on_zoom_out(self, event):
385        """
386        The derivative class is on zoom out mode if implemented
387        """
388    def on_zoom(self, event):
389        """
390        The derivative class is on zoom mode (using pane)
391        if zoom mode is implemented
392        """
[a45037aa]393    def on_set_focus(self, event=None):
[b5ca223]394        """
395        The  derivative class is on focus if implemented
396        """
[a45037aa]397        if self.parent is not None:
398            wx.PostEvent(self.parent, PanelOnFocusEvent(panel=self))
[f69b5830]399           
400    def on_kill_focus(self, event=None):
401        """
402        The  derivative class is on unfocus if implemented
403        """
404        pass
405               
[52725d6]406    def get_data(self):
407        """
408        return list of current data
409        """
410        return
411   
412    def get_state(self):
413        """
414         return the current state
415        """
416        return
417
418    def set_manager(self, manager):
419        """
420        """
421        self._manager = manager
422       
423    def get_manager(self):
424        """
425        """
426        return self._manager
Note: See TracBrowser for help on using the repository browser.