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 ADAO_INSTALL_DIR = my_path + "/../daEficas"
28 sys.path[:0]=[ADAO_INSTALL_DIR]
31 # ============================================
32 # Specialization of the EficasWrapper for ADAO
33 # ============================================
35 class AdaoEficasWrapper(EficasWrapper):
37 def __init__(self, parent, code="ADAO"):
38 EficasWrapper.__init__(self, parent, code)
39 self.__myCallbackId = {}
40 self.__close_editor = None
41 self.__file_open_name = ""
44 EficasWrapper.init_gui(self)
45 print "self.__myCallbackId", self.__myCallbackId
46 save_CallbackId = self.__myCallbackId.copy()
47 for editor, myCallbackId in save_CallbackId.iteritems():
48 self.notifyObserver(EficasEvent.EVENT_TYPES.REOPEN, callbackId=myCallbackId)
50 # Association de l'objet editor avec le callbackId
51 def setCallbackId(self, callbackId):
52 index = self.viewmanager.myQtab.currentIndex()
53 self.__myCallbackId[self.viewmanager.dict_editors[index]] = callbackId
55 def getCallbackId(self):
56 if self.__close_editor is None:
57 index = self.viewmanager.myQtab.currentIndex()
58 return self.__myCallbackId[self.viewmanager.dict_editors[index]]
60 return self.__myCallbackId[self.__close_editor]
66 qtEficas.Appli.fileSave(self)
67 index = self.viewmanager.myQtab.currentIndex()
69 self.notifyObserver(EficasEvent.EVENT_TYPES.SAVE)
75 qtEficas.Appli.fileSaveAs(self)
76 self.notifyObserver(EficasEvent.EVENT_TYPES.SAVE)
78 def getCaseName(self):
79 if self.__close_editor is None:
80 index = self.viewmanager.myQtab.currentIndex()
81 CaseName = self.viewmanager.myQtab.tabText(index)
84 CaseName = str(self.__close_editor.fichier.split('/')[-1])
87 def getFileCaseName(self):
88 if self.__close_editor is None:
89 index = self.viewmanager.myQtab.currentIndex()
90 editor = self.viewmanager.dict_editors[index]
93 return self.__close_editor.fichier
95 def Openfile(self, filename):
96 self.viewmanager.handleOpen(fichier=filename)
98 def handleOpenRecent(self):
103 fichier = self.ficRecents[idx]
104 self.__file_open_name = fichier
105 self.notifyObserver(EficasEvent.EVENT_TYPES.OPEN)
106 self.__file_open_name = ""
112 fichier = QtGui.QFileDialog.getOpenFileName(self,
113 self.trUtf8('Ouvrir Fichier'),
114 self.CONFIGURATION.savedir,
115 self.trUtf8('JDC Files (*.comm);;''All Files (*)'))
116 if fichier.isNull(): return
117 self.__file_open_name = fichier
118 self.notifyObserver(EficasEvent.EVENT_TYPES.OPEN)
119 self.__file_open_name = ""
121 def getOpenFileName(self):
122 return str(self.__file_open_name)
124 def selectCase(self, callbackId):
126 for editor, myCallbackId in self.__myCallbackId.iteritems():
127 if myCallbackId[0] == callbackId[0]:
128 if myCallbackId[1].GetID() == callbackId[1].GetID():
130 for indexEditor in self.viewmanager.dict_editors.keys():
131 if editor is self.viewmanager.dict_editors[indexEditor]:
132 self.viewmanager.myQtab.setCurrentIndex(indexEditor)
142 index = self.viewmanager.myQtab.currentIndex()
143 self.__close_editor = self.viewmanager.dict_editors[index]
144 res = self.viewmanager.handleClose(self)
145 if res != 2: # l utilsateur a annule
146 if self.__close_editor.fichier is None:
147 # We have to destroy the case
148 self.notifyObserver(EficasEvent.EVENT_TYPES.DESTROY)
149 self.__myCallbackId.pop(self.__close_editor)
151 # Il faudrait en faire plus -> Voir Edit dans SALOME !
152 self.notifyObserver(EficasEvent.EVENT_TYPES.SAVE)
153 self.__myCallbackId.pop(self.__close_editor)
154 self.__close_editor = None
157 def fileCloseAll(self):
161 while len(self.viewmanager.dict_editors) > 0:
162 self.viewmanager.myQtab.setCurrentIndex(0)
163 if self.viewmanager.myQtab.currentIndex() == 0:
164 res = self.fileClose()
165 if res==2 : return res # l utilsateur a annule