1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2010 EDF R&D
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.
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.
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
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 from eficasWrapper import *
22 from PyQt4 import QtGui,QtCore
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]
31 # ================================================
32 # Specialization of the EficasWrapper for DATASSIM
33 # ================================================
35 class DatassimEficasWrapper(EficasWrapper):
41 def __init__(self, parent, code="DATASSIM"):
42 EficasWrapper.__init__(self, parent, code)
44 # Association de l'objet editor avec le callbackId
45 def setCallbackId(self, callbackId):
46 index = self.viewmanager.myQtab.currentIndex()
47 self.__myCallbackId[self.viewmanager.dict_editors[index]] = callbackId
49 def getCallbackId(self):
50 if self.__close_editor is None:
51 index = self.viewmanager.myQtab.currentIndex()
52 return self.__myCallbackId[self.viewmanager.dict_editors[index]]
54 return self.__myCallbackId[self.__close_editor]
60 qtEficas.Appli.fileSave(self)
61 index = self.viewmanager.myQtab.currentIndex()
63 self.notifyObserver(EficasEvent.EVENT_TYPES.SAVE)
69 qtEficas.Appli.fileSaveAs(self)
70 self.notifyObserver(EficasEvent.EVENT_TYPES.SAVE)
72 def getCaseName(self):
73 if self.__close_editor is None:
74 index = self.viewmanager.myQtab.currentIndex()
75 CaseName = self.viewmanager.myQtab.tabText(index)
78 CaseName = str(self.__close_editor.fichier.split('/')[-1])
81 def getFileCaseName(self):
82 if self.__close_editor is None:
83 index = self.viewmanager.myQtab.currentIndex()
84 editor = self.viewmanager.dict_editors[index]
87 return self.__close_editor.fichier
89 def Openfile(self, filename):
90 self.viewmanager.handleOpen(fichier=filename)
92 def handleOpenRecent(self):
97 fichier = self.ficRecents[idx]
98 self.__file_open_name = fichier
99 self.notifyObserver(EficasEvent.EVENT_TYPES.OPEN)
100 self.__file_open_name = ""
106 fichier = QtGui.QFileDialog.getOpenFileName(self,
107 self.trUtf8('Ouvrir Fichier'),
108 self.CONFIGURATION.savedir,
109 self.trUtf8('JDC Files (*.comm);;''All Files (*)'))
110 if fichier.isNull(): return
111 self.__file_open_name = fichier
112 self.notifyObserver(EficasEvent.EVENT_TYPES.OPEN)
113 self.__file_open_name = ""
115 def getOpenFileName(self):
116 return str(self.__file_open_name)
122 index = self.viewmanager.myQtab.currentIndex()
123 self.__close_editor = self.viewmanager.dict_editors[index]
124 res = self.viewmanager.handleClose(self)
125 if res != 2: # l utilsateur a annule
126 if self.__close_editor.fichier is None:
127 # We have to destroy the case
128 self.notifyObserver(EficasEvent.EVENT_TYPES.DESTROY)
129 self.__myCallbackId.pop(self.__close_editor)
131 # Il faudrait en faire plus -> Voir Edit dans SALOME !
132 self.notifyObserver(EficasEvent.EVENT_TYPES.SAVE)
133 self.__myCallbackId.pop(self.__close_editor)
134 self.__close_editor = None
137 def fileCloseAll(self):
141 while len(self.viewmanager.dict_editors) > 0:
142 self.viewmanager.myQtab.setCurrentIndex(0)
143 if self.viewmanager.myQtab.currentIndex() == 0:
144 res = self.fileClose()
145 if res==2 : return res # l utilsateur a annule