1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2010 EDF R&D
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.
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.
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
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 __author__="aribes/gboulant"
23 from PyQt4.QtGui import *
24 from PyQt4.QtCore import *
27 sgPyQt = SalomePyQt.SalomePyQt()
29 ################################################
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)
38 from daGuiImpl import datassimGuiHelper
39 from daGuiImpl.datassimGuiManager import DatassimGuiUiComponentBuilder
41 uiComponentBuilder = None
43 self.uiComponentBuilder = DatassimGuiUiComponentBuilder()
46 __study2context__ = {}
47 __current_context__ = None
48 def _setContext( studyID ):
49 global __study2context__, __current_context__
50 if not __study2context__.has_key(studyID):
51 __study2context__[studyID] = GUIcontext()
53 __current_context__ = __study2context__[studyID]
54 return __current_context__
56 from daGuiImpl.datassimGuiManager import DatassimGuiActionImpl
57 actionImpl = DatassimGuiActionImpl()
58 # This object does not need to be embedded in a GUI context object. A single
59 # instance for all studies is a priori sufficient.
61 ################################################
62 # Implementation of SALOME GUI interface
63 ################################################
65 # called when module is initialized
66 # perform initialization actions
70 # called when module is initialized
71 # return map of popup windows to be used by the module
74 wm[SalomePyQt.WT_ObjectBrowser] = Qt.LeftDockWidgetArea
75 wm[SalomePyQt.WT_PyConsole] = Qt.BottomDockWidgetArea
78 # called when module is initialized
79 # return list of 2d/3d views to be used ny the module
83 def createPreferences():
85 Called when module is initialized. Export module's preferences.
89 # called when module is activated
90 # returns True if activating is successfull and False otherwise
92 ctx = _setContext( sgPyQt.getStudyId() )
95 # called when module is deactivated
99 # called when active study is changed
100 # active study ID is passed as parameter
101 def activeStudyChanged( studyID ):
102 ctx = _setContext( sgPyQt.getStudyId() )
106 # called when popup menu is invoked
107 # popup menu and menu context are passed as parameters
108 def createPopupMenu( popup, context ):
109 activeStudyId = sgPyQt.getStudyId()
110 ctx = _setContext(sgPyQt.getStudyId())
111 selcount, selected = datassimGuiHelper.getAllSelected(activeStudyId)
113 selectedItem = datassimGuiHelper.getSelectedItem(activeStudyId)
114 popup = ctx.uiComponentBuilder.createPopupMenuOnItem(popup, activeStudyId, selectedItem)
116 def OnGUIEvent(actionId) :
118 Called when an event is raised from a graphic item (click on menu item or
119 toolbar button). The actionId value is the ID associated to the item.
122 actionImpl.processAction(actionId)
125 # called when module's preferences are changed
126 # preference's resources section and setting name are passed as parameters
127 def preferenceChanged( section, setting ):
130 # called when active view is changed
131 # view ID is passed as parameter
132 def activeViewChanged( viewID ):
135 # called when active view is cloned
136 # cloned view ID is passed as parameter
137 def viewCloned( viewID ):
140 # called when active view is viewClosed
141 # view ID is passed as parameter
142 def viewClosed( viewID ):