--- /dev/null
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>SelectMeshDiag</class>
+<widget class="QDialog">
+ <property name="name">
+ <cstring>SelectMeshDiag</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>392</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>SALOME - Mesh Selection</string>
+ </property>
+ <property name="sizeGripEnabled">
+ <bool>true</bool>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel" row="0" column="0">
+ <property name="name">
+ <cstring>textLabel2</cstring>
+ </property>
+ <property name="text">
+ <string>Select the mesh you want to work on</string>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget" row="3" column="0">
+ <property name="name">
+ <cstring>Layout1</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>buttonHelp</cstring>
+ </property>
+ <property name="text">
+ <string>&Help</string>
+ </property>
+ <property name="accel">
+ <string>F1</string>
+ </property>
+ <property name="autoDefault">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>Horizontal Spacing2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>buttonOk</cstring>
+ </property>
+ <property name="text">
+ <string>&OK</string>
+ </property>
+ <property name="accel">
+ <string></string>
+ </property>
+ <property name="autoDefault">
+ <bool>true</bool>
+ </property>
+ <property name="default">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>buttonCancel</cstring>
+ </property>
+ <property name="text">
+ <string>&Cancel</string>
+ </property>
+ <property name="accel">
+ <string></string>
+ </property>
+ <property name="autoDefault">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QCheckBox" row="2" column="0">
+ <property name="name">
+ <cstring>cbAgain</cstring>
+ </property>
+ <property name="text">
+ <string>Don't ask again</string>
+ </property>
+ </widget>
+ <widget class="QListBox" row="1" column="0">
+ <item>
+ <property name="text">
+ <string>New Item</string>
+ </property>
+ </item>
+ <property name="name">
+ <cstring>lbMeshes</cstring>
+ </property>
+ </widget>
+ </grid>
+</widget>
+<connections>
+ <connection>
+ <sender>buttonOk</sender>
+ <signal>clicked()</signal>
+ <receiver>SelectMeshDiag</receiver>
+ <slot>accept()</slot>
+ </connection>
+ <connection>
+ <sender>buttonCancel</sender>
+ <signal>clicked()</signal>
+ <receiver>SelectMeshDiag</receiver>
+ <slot>reject()</slot>
+ </connection>
+</connections>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>
import SalomePyQt
from SelectMainShapeDiag_ui import SelectMainShapeDiag
+from SelectMeshDiag_ui import SelectMeshDiag
msgUnAuthorizedSelecion = "Sélection SALOME non authorisé. Autorisé : sous-géométrie, groupe de maille"
msgErrorAddJdcInSalome = "Erreur dans l'export du fichier de commande dans l'arbre d'étude Salome"
msgErrorDisplayShape = "Erreur dans l'affichage de la forme géométrique sélectionnée"
+msgErrorDisplayMeshGroup = "Erreur dans l'affichage du groupe de maillage sélectionné"
msgErrorNeedSubShape = "Sélection d'un élément sous géométrique seulement"
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( Tkinter.Toplevel, eficas.EFICAS, QXEmbed ):
self.subShapes = {} #dictionnaire des sous-géométrie de la géométrie principale ( clé = entry, valeur = name )
#----------------------------------------------------------------------
+ # visualisation groupes de mailles
+ self.workingMesh = {} #dictionnaire clé = identifiant JDC / valeur = entry Mesh
+ #----------------------------------------------------------------------
self.icolor = 0 # compteur pour mémoriser la couleur courante
studyManager.palStudy.setCurrentStudyID( activeStudyId )
return True
-
+
+ def __selectWorkingMesh( self, meshGroupEntries ):
+ """
+ Sélection intéractive du maillage sur lequel on travail
+ """
+ selMeshEntry, keep = None, False
+ diag = SelectMeshDiagImpl( meshGroupEntries, self.parent )
+
+ if diag.exec_loop() == qt.QDialog.Accepted:
+ selMeshEntry, keep = diag.getUserSelection()
+ return selMeshEntry, keep
def __selectMainShape( self, groupeMaNamesIn, groupeNoNamesIn ):
"""
logger.debug(50*'=')
+ def displayMeshGroups(self, meshGroupName):
+ """
+ visualisation group de maille de nom meshGroupName dans salome
+ """
+ ok, msgError = False, ''
+ try:
+ sg = salome.ImportComponentGUI('SMESH')
+ currentjdcID = self.bureau.nb.getcurselection()
+ meshGroupEntries = []
+ selMeshEntry = None
+ selMeshGroupEntry = None
+
+ # liste des groupes de maille de nom meshGroupName
+ listSO = studyManager.palStudy._myStudy.FindObjectByName(meshGroupName, "SMESH")
+ for SObjet in listSO:
+ groupEntry = SObjet.GetID()
+ meshGroupEntries += [groupEntry]
+
+ # choix d'un maillage
+ if not self.workingMesh.has_key(currentjdcID): # aucun maillage de défini par défaut encore
+ #selMeshEntry = "0:1:3:5" #CS_pbruno todo : choix maillage + test si c un maillage
+ selMeshEntry, keep = self.__selectWorkingMesh(meshGroupEntries)
+ if keep:
+ self.workingMesh[currentjdcID] = selMeshEntry
+ else: # déja un de défini par défaut
+ selMeshEntry = self.workingMesh[currentjdcID]
+
+ # le groupe de maille est il ds ce maillage?
+ lselMeshEntry = len(selMeshEntry)
+ for groupEntry in meshGroupEntries:
+ if selMeshEntry == groupEntry[0:lselMeshEntry]:
+ selMeshGroupEntry = groupEntry
+ break
+
+ # si oui, on l'affiche ds la vue VTK
+ if selMeshGroupEntry:
+ #CS_pbruno: marche QUE si le module SMESH est activé
+ myComponent = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
+ SCom = studyManager.palStudy._myStudy.FindComponent("SMESH")
+ studyManager.palStudy._myBuilder.LoadWith( SCom , myComponent )
+ sg.CreateAndDisplayActor(selMeshGroupEntry)
+ salome.sg.DisplayOnly(selMeshGroupEntry)
+ salome.sg.FitAll()
+ ok = True
+ except:
+ msgError = msgErrorDisplayMeshGroup
+ logger.debug(50*'=')
+ return ok, msgError
+
+
def displayShape( self, shapeName ):
"""
visualisation géométrie de nom shapeName dans salome
"""
ok, msgError = False, ''
try:
+ import VISU
+ import visu_gui
+ currentViewType = None
+ m = visu_gui.myVisu.GetViewManager()
+ v = m.GetCurrentView()
+ if v:
+ currentViewType = v.GetType()
+
atLeastOneStudy = self.__studySync()
if not atLeastOneStudy:
- return ok, msgError
-
+ return ok, msgError
#salome.sg.EraseAll()
- print 'displayShapestrGeomShape shapeName -> ', shapeName
- current_color = COLORS[ self.icolor % LEN_COLORS ]
- ok = studyManager.palStudy.displayShapeByName( shapeName, current_color )
- self.icolor = self.icolor + 1
+ print 'displayShapestrGeomShape shapeName -> ', shapeName
- if not ok:
- msgError = msgErrorDisplayShape
- except:
- logger.debug(50*'=')
+ if currentViewType == VISU.TVIEW3D: # maillage
+ print 'Vue courante = VTK : affichage groupe de maille'
+ ok, msgError = self.displayMeshGroups(shapeName)
+ else: #geometrie
+ print 'Vue courante = OCC : affichage element geometrique'
+ current_color = COLORS[ self.icolor % LEN_COLORS ]
+ ok = studyManager.palStudy.displayShapeByName( shapeName, current_color )
+ salome.sg.FitAll()
+ self.icolor = self.icolor + 1
+ if not ok:
+ msgError = msgErrorDisplayShape
+ except:
+ logger.debug(50*'=')
return ok, msgError