]> SALOME platform Git repositories - modules/adao.git/blob - src/daSalome/daGUI/daEficasWrapper/datassimEficasWrapper.py
Salome HOME
- On gére bien le GUI EFICAS
[modules/adao.git] / src / daSalome / daGUI / daEficasWrapper / datassimEficasWrapper.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 from eficasWrapper import *
22 from PyQt4 import QtGui,QtCore
23 import sys
24
25 # Configuration de l'installation
26 my_path = os.path.dirname(os.path.abspath(__file__))
27 DATASSIM_INSTALL_DIR = my_path + "/../daEficas"
28 sys.path[:0]=[DATASSIM_INSTALL_DIR]
29
30 #
31 # ================================================
32 # Specialization of the EficasWrapper for DATASSIM
33 # ================================================
34 #
35 class DatassimEficasWrapper(EficasWrapper):
36
37     __myCallbackId = {}
38     __close_editor = None
39
40     def __init__(self, parent, code="DATASSIM"):
41         EficasWrapper.__init__(self, parent, code)
42
43     # Association de l'objet editor avec le callbackId
44     def setCallbackId(self, callbackId):
45       index = self.viewmanager.myQtab.currentIndex()
46       self.__myCallbackId[self.viewmanager.dict_editors[index]] = callbackId
47
48     def getCallbackId(self):
49       if self.__close_editor is None:
50         index = self.viewmanager.myQtab.currentIndex()
51         return self.__myCallbackId[self.viewmanager.dict_editors[index]]
52       else:
53         return self.__myCallbackId[self.__close_editor]
54
55     def fileSave(self):
56         """
57         @overload
58         """
59         qtEficas.Appli.fileSave(self)
60         index = self.viewmanager.myQtab.currentIndex()
61         if index > -1 :
62           self.notifyObserver(EficasEvent.EVENT_TYPES.SAVE)
63
64     def fileSaveAs(self):
65         """
66         @overload
67         """
68         qtEficas.Appli.fileSaveAs(self)
69         self.notifyObserver(EficasEvent.EVENT_TYPES.SAVE)
70
71     def getCaseName(self):
72       if self.__close_editor is None:
73         index = self.viewmanager.myQtab.currentIndex()
74         CaseName = self.viewmanager.myQtab.tabText(index)
75         return CaseName
76       else:
77         CaseName = self.__close_editor.fichier.split('/')[-1]
78         return CaseName
79
80     def fileOpen(self):
81         """
82         @overload
83         """
84         QtGui.QMessageBox.warning( self, "Alerte", "You cannot Open a Case into Eficas window when you are using Datassim SALOME module")
85
86     def fileClose(self):
87         """
88         @overload
89         """
90         index = self.viewmanager.myQtab.currentIndex()
91         self.__close_editor = self.viewmanager.dict_editors[index]
92         res = self.viewmanager.handleClose(self)
93         if res != 2: # l utilsateur a annule
94           if self.__close_editor.fichier is None:
95             # We have to destroy the case
96             self.notifyObserver(EficasEvent.EVENT_TYPES.DESTROY)
97             self.__myCallbackId.pop(self.__close_editor)
98           else:
99             # Il faudrait en faire plus -> Voir Edit dans SALOME !
100             self.notifyObserver(EficasEvent.EVENT_TYPES.SAVE)
101             self.__myCallbackId.pop(self.__close_editor)
102         self.__close_editor = None
103         return res
104
105     def fileCloseAll(self):
106       """
107       @overload
108       """
109       while len(self.viewmanager.dict_editors) > 0:
110         self.viewmanager.myQtab.setCurrentIndex(0)
111         res = self.fileClose()
112         if res==2 : return res   # l utilsateur a annule