self.dictMCVal={}
self.text_comm = ""
self.text_da = ""
+ self.text_da_status = False
def gener(self,obj,format='brut',config=None):
print "DatassimGenerator gener"
print "Dictionnaire"
print self.dictMCVal
-
- self.generate_da()
+
+ try :
+ self.text_da_status = False
+ self.generate_da()
+ self.text_da_status = True
+ except:
+ print "Case seems not be correct"
+ pass
return self.text_comm
def writeDefault(self, fn):
- print "writeDefault"
- filename = fn[:fn.rfind(".")] + '.py'
- f = open( str(filename), 'wb')
- f.write( self.text_da )
- f.close()
+ if self.text_da_status:
+ print "write datassim python command file"
+ filename = fn[:fn.rfind(".")] + '.py'
+ f = open( str(filename), 'wb')
+ f.write( self.text_da )
+ f.close()
def generMCSIMP(self,obj) :
"""
#
from eficasWrapper import *
+from PyQt4 import QtGui,QtCore
import sys
# Configuration de l'installation
# ================================================
#
class DatassimEficasWrapper(EficasWrapper):
+
+ __myCallbackId = {}
+ __close_editor = None
+
def __init__(self, parent, code="DATASSIM"):
EficasWrapper.__init__(self, parent, code)
+ # Association de l'objet editor avec le callbackId
+ def setCallbackId(self, callbackId):
+ index = self.viewmanager.myQtab.currentIndex()
+ self.__myCallbackId[self.viewmanager.dict_editors[index]] = callbackId
+
+ def getCallbackId(self):
+ if self.__close_editor is None:
+ index = self.viewmanager.myQtab.currentIndex()
+ return self.__myCallbackId[self.viewmanager.dict_editors[index]]
+ else:
+ return self.__myCallbackId[self.__close_editor]
+
def fileSave(self):
"""
@overload
"""
qtEficas.Appli.fileSave(self)
- self.notifyObserver(EficasEvent.EVENT_TYPES.SAVE)
+ index = self.viewmanager.myQtab.currentIndex()
+ if index > -1 :
+ self.notifyObserver(EficasEvent.EVENT_TYPES.SAVE)
def fileSaveAs(self):
"""
qtEficas.Appli.fileSaveAs(self)
self.notifyObserver(EficasEvent.EVENT_TYPES.SAVE)
- def getCurrentFileName(self):
- index = self.viewmanager.myQtab.currentIndex()
- print index
- rtn = ""
- if index > 0 :
- rtn = self.viewmanager.myQtab.tabText(index)
- return rtn
+ def getCaseName(self):
+ if self.__close_editor is None:
+ index = self.viewmanager.myQtab.currentIndex()
+ CaseName = self.viewmanager.myQtab.tabText(index)
+ return CaseName
+ else:
+ CaseName = self.__close_editor.fichier.split('/')[-1]
+ return CaseName
+
+ def fileOpen(self):
+ """
+ @overload
+ """
+ QtGui.QMessageBox.warning( self, "Alerte", "You cannot Open a Case into Eficas window when you are using Datassim SALOME module")
+
+ def fileClose(self):
+ """
+ @overload
+ """
+ index = self.viewmanager.myQtab.currentIndex()
+ self.__close_editor = self.viewmanager.dict_editors[index]
+ res = self.viewmanager.handleClose(self)
+ if res != 2: # l utilsateur a annule
+ if self.__close_editor.fichier is None:
+ # We have to destroy the case
+ self.notifyObserver(EficasEvent.EVENT_TYPES.DESTROY)
+ self.__myCallbackId.pop(self.__close_editor)
+ else:
+ # Il faudrait en faire plus -> Voir Edit dans SALOME !
+ self.notifyObserver(EficasEvent.EVENT_TYPES.SAVE)
+ self.__myCallbackId.pop(self.__close_editor)
+ self.__close_editor = None
+ return res
+
+ def fileCloseAll(self):
+ """
+ @overload
+ """
+ while len(self.viewmanager.dict_editors) > 0:
+ self.viewmanager.myQtab.setCurrentIndex(0)
+ res = self.fileClose()
+ if res==2 : return res # l utilsateur a annule
class EficasEvent:
EVENT_TYPES=Enumerate([
'CLOSE',
- 'SAVE'
+ 'SAVE',
+ 'DESTROY',
+ 'NEW'
])
def __init__(self,eventType,callbackId=None):
self.__observer = observer
def notifyObserver(self, eventType):
+ if eventType != EficasEvent.EVENT_TYPES.NEW:
eficasEvent = EficasEvent(eventType, self.getCallbackId())
- self.__observer.processEficasEvent(self, eficasEvent)
+ else:
+ eficasEvent = EficasEvent(eventType)
+ self.__observer.processEficasEvent(self, eficasEvent)
def setCallbackId(self, callbackId):
"""
del InterfaceQT4.readercata.reader
event.accept()
+ def fileNew(self):
+ """
+ @overload
+ """
+ logger.debug("This is my fileNew")
+ qtEficas.Appli.fileNew(self)
+ # Notify the observers of the event - after to be able to handled with editor
+ # If needed
+ self.notifyObserver(EficasEvent.EVENT_TYPES.NEW)
def fileSave(self):
"""
datassimModuleHelper.py \
datassimStudyEditor.py \
studyedit.py \
+ datassimCase.py \
enumerate.py
--- /dev/null
+# -*- coding: iso-8859-1 -*-
+# Copyright (C) 2010 EDF R&D
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+class DatassimCase:
+
+ __name = "new_case"
+
+ def __init__(self):
+ pass
+
+ def get_name(self):
+ return self.__name
+
+ def set_name(self, name):
+ self.__name = name
sgPyQt = SalomePyQt.SalomePyQt()
from daGuiImpl.enumerate import Enumerate
+from daGuiImpl.datassimCase import DatassimCase
from daEficasWrapper.datassimEficasWrapper import DatassimEficasWrapper
from daEficasWrapper.eficasWrapper import EficasObserver
from daEficasWrapper.eficasWrapper import EficasEvent
import datassimGuiHelper
import datassimStudyEditor
+__cases__ = {}
+
#
# ==============================================================================
# Classes to manage the building of UI components
print msg
def newDatassimCase(self):
- print "newDatassimCase"
- salomeStudyId = datassimGuiHelper.getActiveStudyId()
- salomeStudyItem = datassimStudyEditor.addInStudy(salomeStudyId, "newDatassimCase")
- datassimGuiHelper.refreshObjectBrowser()
- callbackId = [salomeStudyId, salomeStudyItem]
- self.__dlgEficasWrapper.setCallbackId(callbackId)
self.__dlgEficasWrapper.displayNew()
# ==========================================================================
#
__processOptions={
EficasEvent.EVENT_TYPES.CLOSE : "_processEficasCloseEvent",
- EficasEvent.EVENT_TYPES.SAVE : "_processEficasSaveEvent"
+ EficasEvent.EVENT_TYPES.SAVE : "_processEficasSaveEvent",
+ EficasEvent.EVENT_TYPES.NEW : "_processEficasNewEvent",
+ EficasEvent.EVENT_TYPES.DESTROY : "_processEficasDestroyEvent"
}
def processEficasEvent(self, eficasWrapper, eficasEvent):
"""
print "Remove datassim case in study if empty..."
pass
+ def _processEficasNewEvent(self, eficasWrapper, eficasEvent):
+ global __cases__
+ new_case = DatassimCase()
+ salomeStudyId = datassimGuiHelper.getActiveStudyId()
+ salomeStudyItem = datassimStudyEditor.addInStudy(salomeStudyId, new_case)
+ case_key = (salomeStudyId, salomeStudyItem)
+ __cases__[case_key] = new_case
+ datassimGuiHelper.refreshObjectBrowser()
+ callbackId = [salomeStudyId, salomeStudyItem]
+ self.__dlgEficasWrapper.setCallbackId(callbackId)
+
def _processEficasSaveEvent(self, eficasWrapper, eficasEvent):
callbackId = eficasEvent.callbackId
if callbackId is None:
if ( targetSalomeStudyId is None ) or ( targetSalomeStudyItem is None ):
raise DevelException("the parameters targetSalomeStudyId and targetSalomeStudyItem should not be None")
- file_name = eficasWrapper.getCurrentFileName()
- datassimStudyEditor.updateItem(targetSalomeStudyId, targetSalomeStudyItem, file_name)
- #studyCase = omaStudyEditor.getOmaCaseFromItem(targetSalomeStudyId, targetSalomeStudyItem)
- #studyCase = eficasWrapper.getData(studyCase)
- #logger.debug("jdc="+str(studyCase.userdata.getJdc()))
+ # Get Editor All infos we need !
+ file_name = eficasWrapper.getCaseName()
+ if file_name != "" :
+ case_key = (targetSalomeStudyId, targetSalomeStudyItem)
+ case =__cases__[case_key]
+ case.set_name(file_name)
+ datassimStudyEditor.updateItem(targetSalomeStudyId, targetSalomeStudyItem, case)
+ datassimGuiHelper.refreshObjectBrowser()
+
+ def _processEficasDestroyEvent(self, eficasWrapper, eficasEvent):
+ callbackId = eficasEvent.callbackId
+ if callbackId is None:
+ raise DevelException("the callback data should not be None. Can't guess what are the study and case")
+ [targetSalomeStudyId,targetSalomeStudyItem] = callbackId
+ if ( targetSalomeStudyId is None ) or ( targetSalomeStudyItem is None ):
+ raise DevelException("the parameters targetSalomeStudyId and targetSalomeStudyItem should not be None")
+
+ case_key = (targetSalomeStudyId, targetSalomeStudyItem)
+ __cases__.pop(case_key)
+ datassimStudyEditor.removeItem(targetSalomeStudyId, targetSalomeStudyItem)
+ datassimGuiHelper.refreshObjectBrowser()
def _processEficasUnknownEvent(self, eficasWrapper, eficasEvent):
print "Unknown Eficas Event"
from enumerate import Enumerate
import studyedit
import datassimModuleHelper
+from daGuiImpl.datassimCase import DatassimCase
#
# ==============================================================================
engineName = datassimModuleHelper.componentName(),
componentName = datassimModuleHelper.componentUserName())
- itemName = datassimCase
+ itemName = datassimCase.get_name()
itemValue = ""
itemType = DATASSIM_ITEM_TYPES.DATASSIM_CASE
studyEditor = studyedit.getStudyEditor(salomeStudyId)
- itemName = datassimCase
+ itemName = datassimCase.get_name()
itemValue = ""
studyEditor.setItem(salomeStudyItem,
"""
Remove the item from the specified study.
"""
- if not isValidDatassimCaseItem(salomeStudyId, item):
- return False
studyEditor = studyedit.getStudyEditor(salomeStudyId)
return studyEditor.removeItem(item,True)
return False
return True
-
-
-def getDatassimCaseFromItem(salomeStudyId, item):
- """
- Get the datassim case from the selected item.
- Note that the study must be specify to retrieve the attributes value from
- the item reference. The attribute values are stored in the study object.
- """
- if not isValidDatassimCaseItem(salomeStudyId, item):
- return None
-
- itemName = item.GetName()
- itemValue = item.GetComment()
- return itemName
-