1 # -*- coding: utf-8 -*-
3 # Copyright (C) 2008-2024 EDF R&D
5 # This file is part of SALOME ADAO module
7 # This library is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU Lesser General Public
9 # License as published by the Free Software Foundation; either
10 # version 2.1 of the License.
12 # This library is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # Lesser General Public License for more details.
17 # You should have received a copy of the GNU Lesser General Public
18 # License along with this library; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 __author__="aribes/gboulant"
26 from PyQt5.QtGui import *
27 from PyQt5.QtCore import *
28 from PyQt5.QtWidgets import QApplication
31 sgPyQt = SalomePyQt.SalomePyQt()
33 ################################################
35 # Used to store actions, menus, toolbars, etc...
36 ################################################
37 # A gui context instance is created for each study. The dictionnary __study2context__
38 # keeps the mapping in memory. This context contains graphical objects that have
39 # to be created for each study. It contains at least the ui component builder that
40 # creates the menu and toolbar items (must be created for every study)
42 from daGuiImpl import adaoGuiHelper
43 from daGuiImpl.adaoGuiManager import AdaoCaseManager
46 adaoCaseManager = None
48 self.adaoCaseManager = AdaoCaseManager()
50 #~ __study2context__ = {}
51 #~ __current_context__ = None
52 __current_context__ = GUIcontext()
53 #~ def _setContext( studyID ):
54 #~ global __study2context__, __current_context__
55 #~ QApplication.processEvents()
56 #~ if studyID not in __study2context__:
57 #~ __study2context__[studyID] = GUIcontext()
59 #~ __current_context__ = __study2context__[studyID]
60 #~ return __current_context__
62 # This object does not need to be embedded in a GUI context object. A single
63 # instance for all studies is a priori sufficient.
65 ################################################
66 # Implementation of SALOME GUI interface
67 ################################################
69 # called when module is initialized
70 # perform initialization actions
74 # called when module is initialized
75 # return map of popup windows to be used by the module
78 wm[SalomePyQt.WT_ObjectBrowser] = Qt.LeftDockWidgetArea
79 wm[SalomePyQt.WT_PyConsole] = Qt.BottomDockWidgetArea
82 # called when module is initialized
83 # return list of 2d/3d views to be used ny the module
87 def createPreferences():
89 Called when module is initialized. Export module's preferences.
93 # called when module is activated
94 # returns True if activating is successfull and False otherwise
96 #~ ctx = _setContext( sgPyQt.getStudyId() )
97 global __current_context__ ; ctx = __current_context__
98 QApplication.processEvents()
99 ctx.adaoCaseManager.activate()
102 # called when module is deactivated
104 #~ ctx = _setContext( sgPyQt.getStudyId() )
105 global __current_context__ ; ctx = __current_context__
106 QApplication.processEvents()
107 ctx.adaoCaseManager.deactivate()
109 # called when active study is changed
110 # active study ID is passed as parameter
111 def activeStudyChanged(): # studyID ):
112 #~ ctx = _setContext( sgPyQt.getStudyId() )
113 QApplication.processEvents()
115 # called when popup menu is invoked
116 # popup menu and menu context are passed as parameters
117 def createPopupMenu( popup, context ):
118 #~ activeStudyId = sgPyQt.getStudyId()
119 #~ ctx = _setContext(sgPyQt.getStudyId())
120 global __current_context__ ; ctx = __current_context__
121 QApplication.processEvents()
122 selcount, selected = adaoGuiHelper.getAllSelected()# activeStudyId)
124 selectedItem = adaoGuiHelper.getSelectedItem()# activeStudyId)
125 popup = ctx.adaoCaseManager.salome_manager.createPopupMenuOnItem(popup, selectedItem) # activeStudyId, selectedItem)
127 def OnGUIEvent(actionId) :
129 Called when an event is raised from a graphic item (click on menu item or
130 toolbar button). The actionId value is the ID associated to the item.
132 #~ ctx = _setContext( sgPyQt.getStudyId() )
133 global __current_context__ ; ctx = __current_context__
134 QApplication.processEvents()
135 ctx.adaoCaseManager.processGUIEvent(actionId)
137 # called when module's preferences are changed
138 # preference's resources section and setting name are passed as parameters
139 def preferenceChanged( section, setting ):
142 # called when active view is changed
143 # view ID is passed as parameter
144 def activeViewChanged( viewID ):
147 # called when active view is cloned
148 # cloned view ID is passed as parameter
149 def viewCloned( viewID ):
152 # called when active view is viewClosed
153 # view ID is passed as parameter
154 def viewClosed( viewID ):