Salome HOME
Edit popup
[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 Openfile(self, filename):
81       self.viewmanager.handleOpen(fichier=filename)
82
83     def fileOpen(self):
84         """
85         @overload
86         """
87         QtGui.QMessageBox.warning( self, "Alerte", "You cannot Open a Case into Eficas window when you are using Datassim SALOME module")
88
89     def fileClose(self):
90         """
91         @overload
92         """
93         index = self.viewmanager.myQtab.currentIndex()
94         self.__close_editor = self.viewmanager.dict_editors[index]
95         res = self.viewmanager.handleClose(self)
96         if res != 2: # l utilsateur a annule
97           if self.__close_editor.fichier is None:
98             # We have to destroy the case
99             self.notifyObserver(EficasEvent.EVENT_TYPES.DESTROY)
100             self.__myCallbackId.pop(self.__close_editor)
101           else:
102             # Il faudrait en faire plus -> Voir Edit dans SALOME !
103             self.notifyObserver(EficasEvent.EVENT_TYPES.SAVE)
104             self.__myCallbackId.pop(self.__close_editor)
105         self.__close_editor = None
106         return res
107
108     def fileCloseAll(self):
109       """
110       @overload
111       """
112       while len(self.viewmanager.dict_editors) > 0:
113         self.viewmanager.myQtab.setCurrentIndex(0)
114         res = self.fileClose()
115         if res==2 : return res   # l utilsateur a annule