]> SALOME platform Git repositories - modules/adao.git/blob - src/daSalome/daGUI/daGuiImpl/DATASSIMGUI_impl.py
Salome HOME
Edit popup
[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 import datassimGuiHelper
39 from daGuiImpl.datassimGuiManager import DatassimGuiUiComponentBuilder
40 class GUIcontext:
41     uiComponentBuilder = None
42     def __init__(self):
43         self.uiComponentBuilder = DatassimGuiUiComponentBuilder()
44
45
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()
52         pass
53     __current_context__ = __study2context__[studyID]
54     return __current_context__
55
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.
60
61 ################################################
62 # Implementation of SALOME GUI interface
63 ################################################
64
65 # called when module is initialized
66 # perform initialization actions
67 def initialize():
68     pass
69
70 # called when module is initialized
71 # return map of popup windows to be used by the module
72 def windows():
73     wm = {}
74     wm[SalomePyQt.WT_ObjectBrowser] = Qt.LeftDockWidgetArea
75     wm[SalomePyQt.WT_PyConsole]     = Qt.BottomDockWidgetArea
76     return wm
77
78 # called when module is initialized
79 # return list of 2d/3d views to be used ny the module
80 def views():
81     return []
82
83 def createPreferences():
84     """
85     Called when module is initialized. Export module's preferences.
86     """
87     pass
88
89 # called when module is activated
90 # returns True if activating is successfull and False otherwise
91 def activate():
92     ctx = _setContext( sgPyQt.getStudyId() )
93     return True
94
95 # called when module is deactivated
96 def deactivate():
97     pass
98
99 # called when active study is changed
100 # active study ID is passed as parameter
101 def activeStudyChanged( studyID ):
102     ctx = _setContext( sgPyQt.getStudyId() )
103     pass
104
105
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)
112   if selcount == 1:
113     selectedItem = datassimGuiHelper.getSelectedItem(activeStudyId)
114     popup = ctx.uiComponentBuilder.createPopupMenuOnItem(popup, activeStudyId, selectedItem)
115
116 def OnGUIEvent(actionId) :
117     """
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.
120     """
121     pass
122     actionImpl.processAction(actionId)
123
124     
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 ):
128     pass
129
130 # called when active view is changed
131 # view ID is passed as parameter
132 def activeViewChanged( viewID ):
133     pass
134
135 # called when active view is cloned
136 # cloned view ID is passed as parameter
137 def viewCloned( viewID ):
138     pass
139
140 # called when active view is viewClosed
141 # view ID is passed as parameter
142 def viewClosed( viewID ):
143     pass
144