From: Pascale Noyret Date: Mon, 12 Oct 2009 08:34:01 +0000 (+0000) Subject: *** empty log message *** X-Git-Tag: V5_1_3_beta1~10 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=33c67215476afe0e9de42e4e8a5d2040651900b4;p=modules%2Feficas.git *** empty log message *** --- diff --git a/src/EFICASGUI/EFICASGUI.py b/src/EFICASGUI/EFICASGUI.py index cddc9859..23b5c126 100644 --- a/src/EFICASGUI/EFICASGUI.py +++ b/src/EFICASGUI/EFICASGUI.py @@ -26,27 +26,13 @@ import salome sg=salome.sg sgPyQt=SalomePyQt.SalomePyQt() - -import studyManager +from pal.studyedit import StudyEditor +monEditor=StudyEditor() print "EFicasGUI :: :::::::::::::::::::::::::::::::::::::::::::::::::::::" -# ----------------------------------------------------------------------------- -#Cette méthode est obsolète en V3 -#En V2, si on n'implémente pas cette méthode, le composant fonctionne -#correctement. Un message "Attribute Error" apparait dans la trace. -#def setWorkSpace(workSpace): -# global WORKSPACE -# WORKSPACE=workSpace - # le desktop -# desktop=sgPyQt.getDesktop() - - # recuperation du workspace -# ws=sgPyQt.getMainFrame() -# #print ws - # ----------------------------------------------------------------------------- def OnGUIEvent(commandID) : @@ -68,11 +54,6 @@ def setSettings(): desktop=sgPyQt.getDesktop() global currentStudyId currentStudyId = sgPyQt.getStudyId() - #print "setSettings: currentStudyId = " + str(currentStudyId) - # _CS_gbo_ Voir si on peut utiliser directement sgPyQt.getStudyId() - # dans salomedsgui? - - studyManager.palStudy.setCurrentStudyID( currentStudyId ) #CS_pbruno def activate(): """ @@ -91,11 +72,8 @@ def activeStudyChanged(ID): # le desktop desktop=sgPyQt.getDesktop() global currentStudyId - # ne marche pas car sg est supposé résider dans une etude - # studyId=sg.getActiveStudyId() currentStudyId=ID - studyManager.palStudy.setCurrentStudyID( currentStudyId ) #CS_pbruno def definePopup(theContext, theObject, theParent): @@ -103,18 +81,25 @@ def definePopup(theContext, theObject, theParent): theObject = "100" theParent = "ObjectBrowser" a=salome.sg.getAllSelected() - #print a selectedEntry = a[0] - aType, aValue = studyManager.palStudy.getTypeAndValue( selectedEntry ) - - if aType == studyManager.FICHIER_EFICAS_ASTER : + mySO = monEditor.study.FindObjectID(selectedEntry); + aType = monEditor.getFileType(mySO) + if aType == "FICHIER_EFICAS_ASTER" : theObject="73" return (theContext, theObject, theParent) def customPopup(popup, theContext, theObject, theParent): + print "EFICASGUI --- customPopup TODO" + print "EFICASGUI --- customPopup" + print "EFICASGUI --- customPopup" + print "EFICASGUI --- customPopup" + print "EFICASGUI --- customPopup" + print "EFICASGUI --- customPopup" + print "EFICASGUI --- customPopup" + print "EFICASGUI --- customPopup" print "EFICASGUI --- customPopup" # popup.removeItem(99003) @@ -159,14 +144,16 @@ def runEficasFichier(version=None): if len(a) == 1: selectedEntry = a[0] - aType, aValue = studyManager.palStudy.getTypeAndValue( selectedEntry ) - if aType == studyManager.FICHIER_EFICAS_ASTER: + mySO = monEditor.study.FindObjectID(selectedEntry); + aType = monEditor.getFileType(mySO) + aValue = monEditor.getFileName(mySO) + if aType == "FICHIER_EFICAS_ASTER": fileName = aValue code = "ASTER" - elif aType == studyManager.FICHIER_EFICAS_OM: + elif aType == "FICHIER_EFICAS_SEP": fileName = aValue code = "SEP" - elif aType == studyManager.FICHIER_EFICAS_OPENTURNS: + elif aType == "FICHIER_EFICAS_OPENTURNS": fileName = aValue code = "OPENTURNS" else: diff --git a/src/EFICASGUI/Makefile.in b/src/EFICASGUI/Makefile.in index e86289f1..cf43bb34 100644 --- a/src/EFICASGUI/Makefile.in +++ b/src/EFICASGUI/Makefile.in @@ -32,6 +32,7 @@ LIB_SERVER_IDL = PO_FILES = EFICAS_msg_en.po EFICAS_icons.po EXPORT_PYSCRIPTS = \ +colors.py\ cabri.py\ SelectMeshDiag_ui.py\ SelectMainShapeDiag_ui.py\ @@ -40,7 +41,8 @@ eficasSalome.py \ # _CS_gbo_151104 Ajout pour compatibilité ascendante entre versions de Eficas -EXPORT_PYSCRIPTS+=eficas_etude.py +# PN On l enleve +#EXPORT_PYSCRIPTS+=eficas_etude.py # On utilise le pyuic trouvé par le configure plutôt que celui se trouvant dans l'environnement PYUIC = pyuic diff --git a/src/EFICASGUI/colors.py b/src/EFICASGUI/colors.py new file mode 100644 index 00000000..8ff63917 --- /dev/null +++ b/src/EFICASGUI/colors.py @@ -0,0 +1,17 @@ +# Liste de couleurs pour visualisation +RED = 255,0,0 +GREEN = 0,255,0 +BLUE = 0,0,255 + +SANDY = 255,0,128 +ORANGE = 255,128,0 +PURPLE = 128,0,255 + +DARK_RED = 128,0,0 +DARK_GREEN = 0,128,0 +DARK_BLUE = 0,0,128 + +YELLOW = 255,255,0 +PINK = 255,0,255 +CYAN = 0,255,255 + diff --git a/src/EFICASGUI/eficasSalome.py b/src/EFICASGUI/eficasSalome.py index 63aacc64..b4f19c5b 100644 --- a/src/EFICASGUI/eficasSalome.py +++ b/src/EFICASGUI/eficasSalome.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -from Logger import ExtLogger +from pal.logger import ExtLogger logger=ExtLogger( "EFICAS_SRC.EFICASGUI.eficasSalome.py" ) # ----------------------------------------------------------------------------- @@ -24,7 +24,7 @@ def exit(ier): import eficasConfig -# __GBO__ lignes de path ajoutees pour acceder aux packages python du +# lignes de path ajoutees pour acceder aux packages python du # logiciel Eficas. Le package Aster est ajoute explicitement pour # acceder au module prefs.py. A sys.path[:0]=[eficasConfig.eficasPath, @@ -48,12 +48,12 @@ import Editeur from InterfaceQT4 import qtEficas import salome - -import studyManager import visuDriver import SalomePyQt +from pal.studyedit import StudyEditor +monEditor=StudyEditor() # message utilisateur msgWarning = "Attention" @@ -73,87 +73,25 @@ msgWarningGroupNoSelection = "Attention, GROUP_NO devrait prendre un point ou u +# couleur pour visualisation des geometries -# couleur pour visualisation des geometrie CS_CBO -COLORS = ( studyManager.RED, - studyManager.GREEN, - studyManager.BLUE, - studyManager.SANDY, - studyManager.ORANGE, - studyManager.PURPLE, - studyManager.DARK_RED, - studyManager.DARK_GREEN, - studyManager.DARK_BLUE, - studyManager.YELLOW, - studyManager.PINK, - studyManager.CYAN ) +import colors +COLORS = ( colors.RED, + colors.GREEN, + colors.BLUE, + colors.SANDY, + colors.ORANGE, + colors.PURPLE, + colors.DARK_RED, + colors.DARK_GREEN, + colors.DARK_BLUE, + colors.YELLOW, + colors.PINK, + colors.CYAN ) LEN_COLORS = len( COLORS ) - - -#class SelectMainShapeDiagImpl( SelectMainShapeDiag ): -# def __init__( self, mainShapeEntries, parent = None,name = None,modal = 1,fl = 0 ): -# SelectMainShapeDiag.__init__( self,parent,name,modal,fl ) -# -# self.mainShapes = {} # ( entry, value ) -# for entry in mainShapeEntries: -# name = studyManager.palStudy.getName( entry ) -# self.mainShapes[entry] = name -# -# self.lbMainShapes.clear() -# for entry,name in self.mainShapes.items(): -# self.lbMainShapes.insertItem( name ) -# self.lbMainShapes.setCurrentItem( 0 ) -# -# -# def getUserSelection( self ): -# mainShapeEntry = None -# -# item = self.lbMainShapes.selectedItem() -# mainShapeName = str( item.text() ) -# -# for entry, name in self.mainShapes.items(): -# if mainShapeName == name: -# mainShapeEntry = entry -# break -# -# return mainShapeEntry -# -# -#class SelectMeshDiagImpl( SelectMeshDiag ): -# def __init__( self, meshGroupEntries, parent = None,name = None,modal = 1,fl = 0 ): -# SelectMeshDiag.__init__( self,parent,name,modal,fl ) -# -# self.meshes = {} # ( entry, value ) -# -# for meshGroupEntry in meshGroupEntries: -# meshEntry = studyManager.palStudy.getMesh(meshGroupEntry) -# meshName = studyManager.palStudy.getName(meshEntry) -# self.meshes[meshEntry] = meshName -# -# self.lbMeshes.clear() -# for entry,name in self.meshes .items(): -# self.lbMeshes.insertItem( name ) -# self.lbMeshes.setCurrentItem( 0 ) -# -# def getUserSelection( self ): -# selMeshEntry, keep = None, False -# -# item = self.lbMeshes.selectedItem() -# meshName = str( item.text() ) -# for entry, name in self.meshes.items(): -# if meshName == name: -# selMeshEntry = entry -# break -# -# keep = self.cbAgain.isChecked() -# -# return selMeshEntry, keep -# -# -# class MyEficas( qtEficas.Appli ): """ Classe de lancement du logiciel EFICAS dans SALOME. @@ -161,7 +99,7 @@ class MyEficas( qtEficas.Appli ): a)la creation de groupes de mailles dans le composant SMESH de SALOME b)la visualisation d'elements geometrique dans le coposant GEOM de SALOME par selection dans EFICAS """ - def __init__( self, parent, code = "ASTER", fichier = None, module = studyManager.SEficas, version=None): + def __init__( self, parent, code = "ASTER", fichier = None, module = "Eficas", version=None): """ Constructeur. @type parent: @@ -182,7 +120,6 @@ class MyEficas( qtEficas.Appli ): if fichier: eficasArg += [ fichier ] if version: - print version eficasArg += [ "-c", version ] else : print "noversion" @@ -218,60 +155,6 @@ class MyEficas( qtEficas.Appli ): appli = None event.accept() - def __studySync( self ): - """ - IMPORTANT( a appeler prealablement a chaque appel du gestionnaire d'etude ) : specifique au lancement de Eficas dans Salome, - permet au gestionnaire d'etude ( studyManager.palStudy ) de pointer sur la bonne etude. - - Un retour a False indique qu'il n'y a aucune etude active, dans ce cas ne faire aucune operation avec le gestionnaire d'etude( - gros plantage sinon ) - """ - activeStudyId = salome.sg.getActiveStudyId() - - if activeStudyId == 0: # pas d'etude active - return False - - if activeStudyId != salome.myStudyId: - studyManager.palStudy.setCurrentStudyID( activeStudyId ) - - return True - - - def __createOCCView( self ): - """ - Creation vue Occ - """ - #salome.salome_init() - import iparameters - - # On determine le nombre de GUI states deja presents dans l'arbre d'etude - GUIStateID = 1 - - ipar = iparameters.IParameters(salome.myStudy.GetCommonParameters("Interface Applicative", GUIStateID)) - properties = ipar.getProperties() - - while properties != []: - GUIStateID += 1 - ipar = iparameters.IParameters(salome.myStudy.GetCommonParameters("Interface Applicative", GUIStateID)) - properties = ipar.getProperties() - - print "GUIStateID: ", GUIStateID - - #Set up visual properties: - ipar.setProperty("AP_ACTIVE_VIEW", "OCCViewer_0_0") - ipar.setProperty("AP_WORKSTACK_INFO", "(splitter orientation=0 sizes=1045 (views active='OCCViewer_0_0' 'OCCViewer_0_0'))") - ipar.setProperty("AP_SAVEPOINT_NAME", "GUI state: %i"%(GUIStateID)) - - #Set up lists: - # fill list AP_VIEWERS_LIST - ipar.append("AP_VIEWERS_LIST", "OCCViewer_1") - # fill list OCCViewer_1 - ipar.append("OCCViewer_1", "OCC scene:1 - viewer:1") - ipar.append("OCCViewer_1", "1.000000000000e+00*0.000000000000e+00*0.000000000000e+00*5.773502588272e-01*-5.773502588272e-01*5.773502588272e-01*0.000000000000e+00*0.000000000000e+00*0.000000000000e+00*0.000000000000e+00*2.886751294136e+02*-2.886751294136e+02*2.886751294136e+02") - - if salome.sg.hasDesktop(): - salome.sg.updateObjBrowser(1) - iparameters.getSession().restoreVisualState(GUIStateID) def __selectWorkingMesh( self, meshGroupEntries ): @@ -299,9 +182,10 @@ class MyEficas( qtEficas.Appli ): # liste des main shape possibles for groups in ( groupeMaNamesIn, groupeNoNamesIn ): for subShapeName in groups: - entries = studyManager.palStudy.getEntriesFromName( studyManager.SGeom, subShapeName ) + entries = getEntriesFromName(self, "GEOM", subShapeName ) + for entry in entries: - mainShapeEntry = studyManager.palStudy.getMainShapeEntry( entry ) + mainShapeEntry = self.getMainShapeEntry( entry ) if mainShapeEntry != entry: if mainShapes.has_key(subShapeName): mainShapes[ subShapeName ].append( mainShapeEntry ) @@ -353,27 +237,33 @@ class MyEficas( qtEficas.Appli ): """ name, msgError = '','' - selectedMainShapeEntry = studyManager.palStudy.getMainShapeEntry( selectedEntry ) - + selectedMainShapeEntry = self.getMainShapeEntry( selectedEntry ) if selectedMainShapeEntry and selectedMainShapeEntry != selectedEntry: #ok test1) - tGeo = studyManager.palStudy.getRealShapeType( selectedEntry ) - if kwType == "GROUP_NO" and tGeo != studyManager.VERTEX: + #PNPNPNPN a Revoir + tgeo=self.getShapeType( selectedEntry ) + if kwType == "GROUP_NO" and tGeo != "VERTEX": msgError = msgWarningGroupNoSelection - elif kwType == "GROUP_MA" and tGeo == studyManager.VERTEX: + elif kwType == "GROUP_MA" and tGeo == "VERTEX": name, msgError = '', msgErrorGroupMaSelection return name, msgError if not self.mainShapeEntries.has_key( editor ): self.mainShapeEntries[ editor ] = selectedMainShapeEntry - name = studyManager.palStudy.getName( selectedMainShapeEntry ) + mySO=monEditor.study.FindObjectID(selectedMainShapeEntry ) + if mySO: + name = mySO.GetName() msgError = msgMainShapeSelection + name if selectedMainShapeEntry == self.mainShapeEntries[ editor ]: - name = studyManager.palStudy.getName( selectedEntry ) + mySO=monEditor.study.FindObjectID(selectedMainShapeEntry ) + if mySO: + name = mySO.GetName() self.subShapes[ selectedEntry ] = name else: if not self.mainShapeNames.has_key( editor ): - self.mainShapeNames[ editor ] = studyManager.palStudy.getName( self.mainShapeEntries[ editor ] ) + mySO=monEditor.study.FindObjectID(self.mainShapeEntries[ editor ]) + if mySO: + self.mainShapeNames[ editor ] = mySO.GetName() msgError = msgSubShapeBadMainShape + self.mainShapeNames[ editor ] else: name, msgError = '', msgErrorNeedSubShape @@ -390,52 +280,89 @@ class MyEficas( qtEficas.Appli ): """ name, msgError = '','' - selectedMeshEntry = studyManager.palStudy.getMesh( selectedEntry ) + mySO=monEditor.study.FindObjectID(selectedEntry ) + from pal.smeshstudytools import SMeshStudyTools + monSMeshStudyTools=SMeshStudyTools(monEditor) + selectedMeshEntry = monSMeshStudyTools.getMeshFromGroup(mySO) + if selectedMeshEntry: # ok test 1) - tGroup = studyManager.palStudy.getGroupType( selectedEntry ) - if kwType == "GROUP_NO" and tGroup != studyManager.NodeGroups: + tGroup = "" + mySO = self._myStudy.FindObjectID(selectedEntry) + if mySO: + groupObject = mySO.GetObject() + if not groupObject: + mycomponent = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH") + SCom = monEditor.study.FindComponent( "SMESH" ) + monEditor.builder.LoadWith( SCom , myComponent ) + groupObject = mySO.GetObject() + if not groupObject : + logger.debug("selectedMeshEntry: An error occurs") + + + import SMESH + aGroup = groupObject._narrow( SMESH.SMESH_GroupBase ) + if aGroup: tGroup = aGroup.GetType() + + #PNPNPNPN bizarre + if kwType == "GROUP_NO" and tGroup != SMESH.NODE: msgError = msgWarningGroupNoSelection - elif kwType == "GROUP_MA" and tGroup == studyManager.NodeGroups: + elif kwType == "GROUP_MA" and tGroup == SMESH.NODE: name, msgError = '', msgErrorGroupMaSelection return name, msgError - selectedMainShapeEntry = studyManager.palStudy.getShapeFromMesh( selectedMeshEntry ) + mySO = self._myStudy.FindObjectID(selectedMeshEntry) + if mySO: + object = mySO.GetObject() + if not object: + mycomponent = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH") + SCom = monEditor.study.FindComponent( "SMESH" ) + monEditor.builder.LoadWith( SCom , myComponent ) + object = mySO.GetObject() + if not object : + logger.debug("selectedMainShapeEntry: An error occurs") + + mesh = object._narrow( SMESH.SMESH_Mesh ) + if mesh: #Ok, c'est bien un objet maillage + shape = mesh.GetShapeToMesh() + if shape: + ior = salome.orb.object_to_string( shape ) + if ior: + sObject = currentStudy.FindObjectIOR( ior ) + selectedMainShapeEntry = sObject.GetID() + else: + selectedMainShapeEntry=0 + logger.debug( 'SalomeStudy.getShapeFromMesh( meshEntry = %s ) ' %meshEntry ) + if selectedMainShapeEntry: #test 2) if not self.mainShapeEntries.has_key( editor ): self.mainShapeEntries[ editor ] = selectedMainShapeEntry - name = studyManager.palStudy.getName( selectedMainShapeEntry ) + mySO=monEditor.study.FindObjectID(selectedMainShapeEntry ) + if mySO: + name = mySO.GetName() msgError = msgMainShapeSelection + name if selectedMainShapeEntry == self.mainShapeEntries[ editor ]: - name = studyManager.palStudy.getName( selectedEntry ) #ok test 2) + mySO=monEditor.study.FindObjectID(selectedEntry ) + if mySO: + name = mySO.GetName() else: if not self.mainShapeNames.has_key( editor ): - self.mainShapeNames[ editor ] = studyManager.palStudy.getName( - self.mainShapeEntries[ editor ] ) + mySO=monEditor.study.FindObjectID(self.mainShapeEntries[ editor ]) + if mySO: + self.mainShapeNames[ editor ] = mySO.GetName() msgError = msgMeshGroupBadMainShape + self.mainShapeNames[ editor ] else: # on authorise quand meme les groupes de maillage ne faisant # pas reference a une geometrie principale (dixit CS_CBO ) - name = studyManager.palStudy.getName( selectedEntry ) + mySO=monEditor.study.FindObjectID(selectedEntry ) + if mySO: + name = mySO.GetName() return name, msgError - - def __updateSubShapes( self, editor, groupeNames ): - """ - mise a jours de la liste self.subShapes a partir de la liste des noms de groupe fourni en entre - """ - for name in groupeNames: - entries = studyManager.palStudy.getEntriesFromName( studyManager.SGeom, name ) - for entry in entries: - if not self.subShapes.has_key( entry ): - ok, msgError = self.__selectShape( editor, entry ) # filtre - if ok: - self.subShapes[ entry ] = name - def __getAllGroupeMa(self, item ): """ Recupere tous les GROUPE_MA dans le JDC courant @@ -520,6 +447,56 @@ class MyEficas( qtEficas.Appli ): return groupNo + # ___________________________ Methodes de l ex Pal __________________________________ + def getEntriesFromName(self, componentName, subShapeName ): + entries = [] + try : + listSO = self._myStudy.FindObjectByName( objectName, componentName ) + for SObjet in listSO : + entry = SObjet.GetID() + entries.append( entry ) + except : + logger.debug("getEntriesFromName: An error occurs") + entries = None + return entries + + def getMainShapeEntry(self,entry): + result=None + try: + mainShapeEntry = entry.split(':')[:4] + + if len(mainShapeEntry) == 4: + strMainShapeEntry = '%s:%s:%s:%s'%tuple(mainShapeEntry) + if self.isMainShape(strMainShapeEntry): + result = strMainShapeEntry + except: + logger.debug( 'Erreur pour SalomeStudy.getMainShapeEntry( entry = %s ) ' %entry ) + result = None + return result + + def isMainShape(self,entry): + result = False + try: + anObject=None + mySO=monEditor.study.FindObjectID(entry ) + if mySO: + anObject = mySO.GetObject() + if not anObject : + strContainer, strComponentName = "FactoryServer", "GEOM" + myComponent = salome.lcc.FindOrLoadComponent( strContainer, strComponentName ) + SCom = monEditor.study.FindComponent( strComponentName ) + monEditor.builder.LoadWith( SCom , myComponent ) + anObject = mySO.GetObject() + + shape = anObject._narrow( GEOM.GEOM_Object ) + if shape.IsMainShape(): + result = True + except: + logger.debug( 'Errreur pour SalomeStudy.isMainShape( entry = %s ) ' %entry ) + result = False + return result + + #----------------------- LISTE DES NOUVEAUX CAS D'UTILISATIONS ----------- def selectGroupFromSalome( self, kwType = None, editor=None): """ @@ -531,22 +508,22 @@ class MyEficas( qtEficas.Appli ): names, msg = [], '' try: self.editor=editor - atLeastOneStudy = self.__studySync() + atLeastOneStudy = monEditor.study if not atLeastOneStudy: return names, msg # recupere toutes les selections de l'utilsateur dans l'arbre Salome entries = salome.sg.getAllSelected() nbEntries = len( entries ) - if nbEntries >= 1: - for entry in entries: - if studyManager.palStudy.isMeshGroup( entry ): #selection d'un groupe de maille - name, msg = self.__selectMeshGroup( editor, entry, kwType ) - elif studyManager.palStudy.isShape( entry ): #selection d'une sous-geometrie - name, msg = self.__selectShape( editor, entry, kwType ) - else: - name, msg = '', msgUnAuthorizedSelecion - if name: - names.append( name ) + #if nbEntries >= 1: + # for entry in entries: + # if studyManager.palStudy.isMeshGroup( entry ): #selection d'un groupe de maille + # name, msg = self.__selectMeshGroup( editor, entry, kwType ) + # elif studyManager.palStudy.isShape( entry ): #selection d'une sous-geometrie + # name, msg = self.__selectShape( editor, entry, kwType ) + # else: + # name, msg = '', msgUnAuthorizedSelecion + # if name: + # names.append( name ) if names and len( names ) < nbEntries: msg = msgIncompleteSelection @@ -562,107 +539,54 @@ class MyEficas( qtEficas.Appli ): ok, msgError = False, msgErrorAddJdcInSalome #try: if 1: - atLeastOneStudy = self.__studySync() + atLeastOneStudy = monEditor.study if not atLeastOneStudy: return ok, msgError - fileType = { 'ASTER' : studyManager.FICHIER_EFICAS_ASTER, - 'SEP' : studyManager.FICHIER_EFICAS_OM , - 'OPENTURNS': studyManager.FICHIER_EFICAS_OPENTURNS, - 'OPENTURNS_STUDY': studyManager.FICHIER_EFICAS_OPENTURNS, - 'OPENTURNS_WRAPPER': studyManager.FICHIER_EFICAS_OPENTURNS} + fileType = { 'ASTER' : "FICHIER_EFICAS_ASTER", + 'SEP' : "FICHIER_EFICAS_SEP", + 'OPENTURNS': "FICHIER_EFICAS_OPENTURNS", + 'OPENTURNS_STUDY': "FICHIER_EFICAS_OPENTURNS", + 'OPENTURNS_WRAPPER': "FICHIER_EFICAS_OPENTURNS", + } folderName = { 'ASTER' : 'AsterFiles', 'SEP' : 'OMFiles' , 'OPENTURNS_STUDY': 'OpenturnsFiles', 'OPENTURNS_WRAPPER': 'OpenturnsFiles'} - folderType = { 'ASTER': studyManager.ASTER_FILE_FOLDER, - 'SEP': studyManager.OM_FILE_FOLDER, - 'OPENTURNS_STUDY': studyManager.OPENTURNS_FILE_FOLDER, - 'OPENTURNS_WRAPPER': studyManager.OPENTURNS_FILE_FOLDER } + folderType = { 'ASTER': "ASTER_FILE_FOLDER", + 'SEP': "SEP_FILE_FOLDER", + 'OPENTURNS_STUDY':"OPENTURNS_FILE_FOLDER", + 'OPENTURNS_WRAPPER': "OPENTURNS_FILE_FOLDER"} - moduleEntry = studyManager.palStudy.addComponent(self.module) + moduleEntry = monEditor.findOrCreateComponent(self.module) itemName = re.split("/",jdcPath)[-1] - fatherEntry = studyManager.palStudy.addItem( + fatherEntry = monEditor.findOrCreateItem( moduleEntry, - itemName = folderName[self.code], - itemIcon = "ICON_COMM_FOLDER", - itemType = folderType[self.code], - bDoublonCheck = True ) + name = folderName[self.code], + #icon = "ICON_COMM_FOLDER", + fileType = folderType[self.code]) - commEntry = studyManager.palStudy.addItem( fatherEntry , - itemName = itemName, - itemType = fileType[ self.code ], - itemValue = jdcPath, - itemComment = str( jdcPath ), - itemIcon = "ICON_COMM_FILE", - bDoublonCheck = True ) - studyManager.palStudy.refresh() + commEntry = monEditor.findOrCreateItem( fatherEntry , + name = itemName, + fileType = fileType[ self.code ], + fileName = jdcPath, + #icon = "ICON_COMM_FILE", + comment = str( jdcPath )) + + salome.sg.updateObjBrowser() + print 'addJdcInSalome commEntry->', commEntry if commEntry: ok, msgError = True, '' #except: - logger.debug(50*'=') + # logger.debug(50*'=' Erreur au AddJDC) return ok, msgError - def createOrUpdateMesh( self, editor ): - """ - Ouverture d'une boite de dialogue : Creation de groupes de mailles dans un maillage existant ou un nouveau maillage. - Note: Appele par EFICAS à la sauvegarde du JDC. - """ - try: - atLeastOneStudy = self.__studySync() - if not atLeastOneStudy: - return - - groupeMaNames = self.__getAllGroupeMa( editor.tree.item ) - groupeNoNames = self.__getAllGroupeNo( editor.tree.item ) - - # on elimine les doublons de la liste - groupeMaNames = dict.fromkeys(groupeMaNames).keys() - groupeNoNames = dict.fromkeys(groupeNoNames).keys() - - #print 'CS_pbruno createOrUpdateMesh groupeNoNames', groupeNoNames - - # mise à jours de la liste des sous-geometrie ( self.subShapes ) - if not self.mainShapeEntries.has_key( editor ): - # l'utilisateur n'a selectionne aucune sous-geometrie et donc pas de geometrie principale - groupeMaNames, groupeNoNames = self.__selectMainShape( groupeMaNames, groupeNoNames, editor ) - - if groupeMaNames or groupeNoNames: - print 'CS_pbruno createOrUpdateMesh groupeMaNames', groupeMaNames - print 'CS_pbruno createOrUpdateMesh groupeNoNames', groupeNoNames - self.__updateSubShapes( editor, groupeMaNames + groupeNoNames ) - - # recuperation des identifiants( entries ) associes aux noms des groupes - groupeMaEntries = [] - groupeNoEntries = [] - - for entry, name in self.subShapes.items(): - if name in groupeMaNames: - groupeMaEntries.append( entry ) - if name in groupeNoNames: - groupeNoEntries.append( entry ) - - if groupeMaEntries or groupeNoEntries: - diag = meshGui.MeshUpdateDialogImpl( - self.mainShapeEntries[editor], - groupeMaEntries, - groupeNoEntries, - studyManager.palStudy, - self.parent ) - diag.show() - - self.subShapes.clear() - self.mainShapeNames.clear() - self.mainShapeEntries.clear() - except: - logger.debug(50*'=') - def displayMeshGroups(self, meshGroupName): """ @@ -677,7 +601,7 @@ class MyEficas( qtEficas.Appli ): selMeshGroupEntry = None # liste des groupes de maille de nom meshGroupName - listSO = studyManager.palStudy._myStudy.FindObjectByName(meshGroupName, "SMESH") + listSO = monEditor.study.FindObjectByName(meshGroupName, "SMESH") print "liste des groupes de maille de nom %s: "%(meshGroupName), listSO if len(listSO)>0: @@ -710,8 +634,8 @@ class MyEficas( qtEficas.Appli ): if selMeshGroupEntry: #CS_pbruno: marche QUE si le module SMESH est active myComponent = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH") - SCom = studyManager.palStudy._myStudy.FindComponent("SMESH") - studyManager.palStudy._myBuilder.LoadWith( SCom , myComponent ) + SCom = monEditor.study.FindComponent("SMESH") + monEditor.builder.LoadWith( SCom , myComponent ) sg.CreateAndDisplayActor(selMeshGroupEntry) salome.sg.Display(selMeshGroupEntry) salome.sg.FitAll() @@ -736,11 +660,10 @@ class MyEficas( qtEficas.Appli ): if v: currentViewType = v.GetType() - atLeastOneStudy = self.__studySync() + atLeastOneStudy = monEditor.study if not atLeastOneStudy: return ok, msgError - #salome.sg.EraseAll() print 'displayShapestrGeomShape shapeName -> ', shapeName if currentViewType == VISU.TVIEW3D: # maillage @@ -748,9 +671,9 @@ class MyEficas( qtEficas.Appli ): ok, msgError = self.displayMeshGroups(shapeName) else: #geometrie print 'Vue courante = OCC : affichage element geometrique' - #self.__createOCCView() current_color = COLORS[ self.icolor % LEN_COLORS ] - ok = studyManager.palStudy.displayShapeByName( shapeName, current_color ) + ##### PNPNPNPN dans visuPal + #ok = studyManager.palStudy.displayShapeByName( shapeName, current_color ) salome.sg.FitAll() self.icolor = self.icolor + 1 if not ok: @@ -797,7 +720,7 @@ class MyEficas( qtEficas.Appli ): def envoievisu(self,liste_commandes): import traceback try: - atLeastOneStudy = self.__studySync() + atLeastOneStudy = monEditor.study if not atLeastOneStudy: return logger.debug(10*'#'+":envoievisu: creating a visuDriver instance") @@ -816,7 +739,7 @@ class MyEficas( qtEficas.Appli ): #------------------------------------------------------------------------------------------------------- # Point d'entree lancement EFICAS # -def runEficas( code="ASTER", fichier=None, module = studyManager.SEficas, version=None ): +def runEficas( code="ASTER", fichier=None, module = "Eficas", version=None ): logger.debug(10*'#'+":runEficas: START") global appli logger.debug(10*'#'+":runEficas: code="+str(code)) @@ -841,10 +764,10 @@ def runHomard( code="HOMARD", fichier=None ): """ -def runAster(parent = SalomePyQt.SalomePyQt().getDesktop(), palStudyManager = studyManager.palStudy, code="ASTER", fichier=None ) : +def runAster(parent = SalomePyQt.SalomePyQt().getDesktop(), code="ASTER", fichier=None ) : global appli if not appli: #une seul instance possible! - appli = MyEficas( parent, palStudyManager, code = code, fichier = fichier ) + appli = MyEficas( parent, code = code, fichier = fichier ) """ appli = None diff --git a/src/STUDY/EficasStudy.py b/src/STUDY/EficasStudy.py index eedfcbee..8183cc2f 100644 --- a/src/STUDY/EficasStudy.py +++ b/src/STUDY/EficasStudy.py @@ -12,7 +12,7 @@ try : except : pass -from Logger import Logger +from pal.logger import Logger logger=Logger( "EficasStudy" )