Salome HOME
:Merge branch 'master' of https://codev-tuleap.cea.fr/plugins/git/spns/SolverLab
[tools/solverlab.git] / CoreFlows / gui / src / COREFLOWSGUI.py
1 # -*- coding: latin-1 -*-
2 #  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
3 #
4 #  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
5 #  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 #
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.
11 #
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.
16 #
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
20 #
21 #  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 #
23 # Author : A. Bruneton
24 #
25 import sys, os
26 from CFDesktop import CFDesktop
27
28 desktop = None
29
30 # Get SALOME PyQt interface
31 import SalomePyQt
32 import libSALOME_Swig
33
34 ########################################################
35 # Global variables
36 ########################################################
37
38 sgPyQt = SalomePyQt.SalomePyQt()
39 sg = libSALOME_Swig.SALOMEGUI_Swig()
40 sgDesktop = sgPyQt.getDesktop()
41
42 moduleDesktop   = {}
43
44 ########################################################
45 # Internal methods
46 ########################################################
47
48 def getStudyId():
49     """This method returns the active study ID"""
50     return sgPyQt.getStudyId()
51
52 def getStudy():
53     """This method returns the active study"""
54
55     studyId = _getStudyId()
56     study = getStudyManager().GetStudyByID( studyId )
57     return study
58
59 def getDesktop():
60     """This method returns the current TRUST_PLOT2D desktop"""
61
62     global desktop
63     return desktop
64
65 def setDesktop( studyID ):
66     """This method sets and returns TRUST_PLOT2D desktop"""
67
68     global moduleDesktop, desktop
69
70     if not moduleDesktop.has_key( studyID ):
71       moduleDesktop[studyID] = CFDesktop( sgPyQt )
72       moduleDesktop[studyID].initialize()
73     desktop = moduleDesktop[studyID]
74     return desktop
75
76 ################################################
77 # Callback functions
78 ################################################
79
80 def initialize():
81     """This method is called when module is initialized. It performs initialization actions"""
82     setDesktop( getStudyId() )
83     pass
84
85 def activeStudyChanged( studyID ):
86     """This method is called when active study is changed"""
87
88     setDesktop( getStudyId() )
89     pass
90
91 def windows():
92     """This method is called when module is initialized. It returns a map of popup windows to be used by the module"""
93     wm = {}
94     return wm
95
96 def views():
97     """This method is called when module is initialized. It returns a list of 2D/3D views to be used by the module"""
98     return []
99
100 def activate():
101     """This method mimicks SALOME's module activation """
102     global desktop
103     fv = desktop.showCentralWidget()
104     return True
105
106 def deactivate():
107     """This method is called when module is deactivated"""
108     global moduleDesktop, widgetDialogBox
109     moduleDesktop[getStudyId()].hideCentralWidget()