]> SALOME platform Git repositories - modules/adao.git/blob - src/daSalome/daGUI/daGuiImpl/DATASSIMGUI_impl.py
Salome HOME
Premiere Action: newcase :-)
[modules/adao.git] / src / daSalome / daGUI / daGuiImpl / DATASSIMGUI_impl.py
1 # -*- coding: iso-8859-1 -*-
2 #  Copyright (C) 2010 EDF R&D
3 #
4 #  This library is free software; you can redistribute it and/or
5 #  modify it under the terms of the GNU Lesser General Public
6 #  License as published by the Free Software Foundation; either
7 #  version 2.1 of the License.
8 #
9 #  This library is distributed in the hope that it will be useful,
10 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
11 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 #  Lesser General Public License for more details.
13 #
14 #  You should have received a copy of the GNU Lesser General Public
15 #  License along with this library; if not, write to the Free Software
16 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
17 #
18 #  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #
20
21 __author__="aribes/gboulant"
22
23 from PyQt4.QtGui import *
24 from PyQt4.QtCore import *
25
26 import SalomePyQt
27 sgPyQt = SalomePyQt.SalomePyQt()
28
29 ################################################
30 # GUI context class
31 # Used to store actions, menus, toolbars, etc...
32 ################################################
33 # A gui context instance is created for each study. The dictionnary __study2context__
34 # keeps the mapping in memory. This context contains graphical objects that have
35 # to be created for each study. It contains at least the ui component builder that
36 # creates the menu and toolbar items (must be created for every study)
37
38 from daGuiImpl.datassimGuiManager import DatassimGuiUiComponentBuilder
39 class GUIcontext:
40     uiComponentBuilder = None
41     def __init__(self):
42         self.uiComponentBuilder = DatassimGuiUiComponentBuilder()
43
44
45 __study2context__   = {}
46 __current_context__ = None
47 def _setContext( studyID ):
48     global __study2context__, __current_context__
49     if not __study2context__.has_key(studyID):
50         __study2context__[studyID] = GUIcontext()
51         pass
52     __current_context__ = __study2context__[studyID]
53     return __current_context__
54
55 from daGuiImpl.datassimGuiManager import DatassimGuiActionImpl
56 actionImpl = DatassimGuiActionImpl()
57 # This object does not need to be embedded in a GUI context object. A single
58 # instance for all studies is a priori sufficient.
59
60 ################################################
61 # Implementation of SALOME GUI interface
62 ################################################
63
64 # called when module is initialized
65 # perform initialization actions
66 def initialize():
67     pass
68
69 # called when module is initialized
70 # return map of popup windows to be used by the module
71 def windows():
72     wm = {}
73     wm[SalomePyQt.WT_ObjectBrowser] = Qt.LeftDockWidgetArea
74     wm[SalomePyQt.WT_PyConsole]     = Qt.BottomDockWidgetArea
75     return wm
76
77 # called when module is initialized
78 # return list of 2d/3d views to be used ny the module
79 def views():
80     return []
81
82 def createPreferences():
83     """
84     Called when module is initialized. Export module's preferences.
85     """
86     pass
87
88 # called when module is activated
89 # returns True if activating is successfull and False otherwise
90 def activate():
91     ctx = _setContext( sgPyQt.getStudyId() )
92     return True
93
94 # called when module is deactivated
95 def deactivate():
96     pass
97
98 # called when active study is changed
99 # active study ID is passed as parameter
100 def activeStudyChanged( studyID ):
101     ctx = _setContext( sgPyQt.getStudyId() )
102     pass
103
104
105 # called when popup menu is invoked
106 # popup menu and menu context are passed as parameters
107 def createPopupMenu( popup, context ):
108   pass
109 #    activeStudyId = sgPyQt.getStudyId()
110 #    if omaModuleHelper.verbose() : print "OMAGUI.createPopupMenu(): context = %s" % context
111 #    ctx = _setContext( sgPyQt.getStudyId() )
112 #    selcount, selected = omaGuiHelper.getAllSelected(activeStudyId)
113 #    if selcount == 1:
114 #        selectedItem = omaGuiHelper.getSelectedItem(activeStudyId)
115 #        popup = ctx.uiComponentBuilder.createPopupMenuOnItem(popup, activeStudyId, selectedItem)
116
117 def OnGUIEvent(actionId) :
118     """
119     Called when an event is raised from a graphic item (click on menu item or
120     toolbar button). The actionId value is the ID associated to the item.
121     """
122     pass
123     actionImpl.processAction(actionId)
124
125     
126 # called when module's preferences are changed
127 # preference's resources section and setting name are passed as parameters
128 def preferenceChanged( section, setting ):
129     pass
130
131 # called when active view is changed
132 # view ID is passed as parameter
133 def activeViewChanged( viewID ):
134     pass
135
136 # called when active view is cloned
137 # cloned view ID is passed as parameter
138 def viewCloned( viewID ):
139     pass
140
141 # called when active view is viewClosed
142 # view ID is passed as parameter
143 def viewClosed( viewID ):
144     pass
145