]> SALOME platform Git repositories - modules/eficas.git/commitdiff
Salome HOME
1ere mise en reference v1_1_0
authorsalome <>
Wed, 19 Oct 2005 14:29:14 +0000 (14:29 +0000)
committersalome <>
Wed, 19 Oct 2005 14:29:14 +0000 (14:29 +0000)
src/EFICASGUI/meshdialog.ui [new file with mode: 0644]
src/EFICASGUI/meshdialogImp.py [new file with mode: 0644]

diff --git a/src/EFICASGUI/meshdialog.ui b/src/EFICASGUI/meshdialog.ui
new file mode 100644 (file)
index 0000000..956c187
--- /dev/null
@@ -0,0 +1,228 @@
+<!DOCTYPE UI><UI version="3.2" stdsetdef="1">
+<class>MeshDialog</class>
+<widget class="QDialog">
+    <property name="name">
+        <cstring>MeshDialog</cstring>
+    </property>
+    <property name="geometry">
+        <rect>
+            <x>0</x>
+            <y>0</y>
+            <width>458</width>
+            <height>316</height>
+        </rect>
+    </property>
+    <property name="caption">
+        <string>SALOME - Application Conditions aux limites</string>
+    </property>
+    <property name="sizeGripEnabled">
+        <bool>true</bool>
+    </property>
+    <vbox>
+        <property name="name">
+            <cstring>unnamed</cstring>
+        </property>
+        <widget class="QGroupBox">
+            <property name="name">
+                <cstring>groupBox2</cstring>
+            </property>
+            <property name="title">
+                <string>Salome-Mesh</string>
+            </property>
+            <grid>
+                <property name="name">
+                    <cstring>unnamed</cstring>
+                </property>
+                <widget class="QRadioButton" row="0" column="0">
+                    <property name="name">
+                        <cstring>rbNewMesh</cstring>
+                    </property>
+                    <property name="text">
+                        <string>Créer Maillage</string>
+                    </property>
+                    <property name="checked">
+                        <bool>true</bool>
+                    </property>
+                </widget>
+                <widget class="QListBox" row="1" column="1">
+                    <item>
+                        <property name="text">
+                            <string>New Item</string>
+                        </property>
+                    </item>
+                    <property name="name">
+                        <cstring>lbMeshes</cstring>
+                    </property>
+                    <property name="enabled">
+                        <bool>false</bool>
+                    </property>
+                    <property name="maximumSize">
+                        <size>
+                            <width>150</width>
+                            <height>32767</height>
+                        </size>
+                    </property>
+                    <property name="focusPolicy">
+                        <enum>WheelFocus</enum>
+                    </property>
+                    <property name="columnMode">
+                        <enum>FixedNumber</enum>
+                    </property>
+                    <property name="rowMode">
+                        <enum>Variable</enum>
+                    </property>
+                </widget>
+                <widget class="QRadioButton" row="0" column="1">
+                    <property name="name">
+                        <cstring>rbUpdateMesh</cstring>
+                    </property>
+                    <property name="text">
+                        <string>Mise à jours Maillage</string>
+                    </property>
+                </widget>
+            </grid>
+        </widget>
+        <widget class="QLayoutWidget">
+            <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>&amp;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>143</width>
+                            <height>20</height>
+                        </size>
+                    </property>
+                </spacer>
+                <widget class="QPushButton">
+                    <property name="name">
+                        <cstring>buttonOk</cstring>
+                    </property>
+                    <property name="enabled">
+                        <bool>true</bool>
+                    </property>
+                    <property name="text">
+                        <string>&amp;OK</string>
+                    </property>
+                    <property name="accel">
+                        <string></string>
+                    </property>
+                    <property name="toggleButton">
+                        <bool>false</bool>
+                    </property>
+                    <property name="on">
+                        <bool>false</bool>
+                    </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>&amp;Cancel</string>
+                    </property>
+                    <property name="accel">
+                        <string></string>
+                    </property>
+                    <property name="autoDefault">
+                        <bool>true</bool>
+                    </property>
+                </widget>
+            </hbox>
+        </widget>
+    </vbox>
+</widget>
+<connections>
+    <connection>
+        <sender>buttonOk</sender>
+        <signal>clicked()</signal>
+        <receiver>MeshDialog</receiver>
+        <slot>accept()</slot>
+    </connection>
+    <connection>
+        <sender>buttonCancel</sender>
+        <signal>clicked()</signal>
+        <receiver>MeshDialog</receiver>
+        <slot>reject()</slot>
+    </connection>
+    <connection>
+        <sender>rbNewMesh</sender>
+        <signal>clicked()</signal>
+        <receiver>rbUpdateMesh</receiver>
+        <slot>toggle()</slot>
+    </connection>
+    <connection>
+        <sender>rbUpdateMesh</sender>
+        <signal>clicked()</signal>
+        <receiver>rbNewMesh</receiver>
+        <slot>toggle()</slot>
+    </connection>
+    <connection>
+        <sender>rbNewMesh</sender>
+        <signal>toggled(bool)</signal>
+        <receiver>lbMeshes</receiver>
+        <slot>clearSelection()</slot>
+    </connection>
+    <connection>
+        <sender>rbNewMesh</sender>
+        <signal>toggled(bool)</signal>
+        <receiver>lbMeshes</receiver>
+        <slot>setDisabled(bool)</slot>
+    </connection>
+    <connection>
+        <sender>rbNewMesh</sender>
+        <signal>toggled(bool)</signal>
+        <receiver>buttonOk</receiver>
+        <slot>setEnabled(bool)</slot>
+    </connection>
+    <connection>
+        <sender>lbMeshes</sender>
+        <signal>highlighted(int)</signal>
+        <receiver>MeshDialog</receiver>
+        <slot>enableOK()</slot>
+    </connection>
+</connections>
+<slots>
+    <slot>enableOK()</slot>
+</slots>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>
diff --git a/src/EFICASGUI/meshdialogImp.py b/src/EFICASGUI/meshdialogImp.py
new file mode 100644 (file)
index 0000000..f10bc46
--- /dev/null
@@ -0,0 +1,131 @@
+# -*- coding: iso-8859-1 -*-
+from qt import *
+from meshdialog  import MeshDialog
+from EficasStudy import study, SMesh
+
+
+
+#CS_pbruno c'est à partir de ces données que la boite de dialogue est crée ( paramètres obligatoires )
+mainShapeEntry = ''
+groupeMaEntries = []
+groupeNoEntries = []
+
+
+
+# CS_pbruno message à placer dans un module approprié( EficasMsg.py àcréer )
+warning = 'Attention!'
+msg1 = "erreur création maillage dans Salome"
+msg2 = "erreur mise à jours maillage dans Salome"
+
+msg3 = "géométrie principale indéterminée"
+msg4 = "liste des sous-géométries indéterminée"
+
+
+class MeshDialogImpl( MeshDialog ):
+    def __init__(self, parent = None,name = None,modal = 0,fl = 0):
+        MeshDialog.__init__(self,parent,name,modal,fl)
+        self.meshEntries = {}        
+        if not mainShapeEntry:
+            QMessageBox.warning( self, warning,  msg3 )
+        else:
+            self.__fillLbMeshes( mainShapeEntry )            
+        if not ( groupeMaEntries or groupeNoEntries ):
+            QMessageBox.warning( self, warning,  msg4 )
+        self.show()        
+        
+
+    def enableOK( self):
+        self.buttonOk.setEnabled( 1 )
+
+
+    def accept( self ):
+        global mainShapeEntry, groupeMaEntries, groupeNoEntries
+
+        if self.rbNewMesh.isChecked(): # l'utilisateur choisi de crée un nouveau maillage
+            self.__createSalomeMesh( mainShapeEntry, groupeMaEntries, groupeNoEntries )
+        else:   # l'utilisateur choisi un maillage existant
+            self.__updateSalomeMesh( groupeMaEntries, groupeNoEntries )
+        self.close()
+
+        # réinit obligatoire des variables globales pour prochaine utilisation
+        mainShapeEntry = ''
+        groupeMaEntries = []
+        groupeNoEntries = []
+
+
+        
+        
+
+    def __fillLbMeshes( self, mainShapeEntryIn ):
+        """
+        Rempli la liste des maillages possibles à modifier ( ceux référencant
+        la géométrie principale indiquée en paramètre d'entrée )
+        """
+        self.lbMeshes.clear()
+        meshEntries = study.getAllMeshReferencingMainShape( mainShapeEntryIn )
+
+        if meshEntries: # il existe au moins un maillage dans l'arbre d'étude Salome référençant la géométrie principale
+            for aMeshEntry in meshEntries:
+                aMeshName = study.getNameAttribute( aMeshEntry )
+                self.lbMeshes.insertItem( aMeshName )
+                self.meshEntries[ aMeshName ] = aMeshEntry                
+        else:           # pas de maillages, il faudra obligatoirment en crée une nouvelle
+            self.rbUpdateMesh.setEnabled(0)
+            self.lbMeshes.setEnabled(0)
+
+
+    def __meshUniqueName( self, nameIn ):
+        """
+        Contrôle si objet du composant 'Mesh' possède déjà le nom fourni en paramètre
+        retourne le même nom si ce n'est pas le cas, le même nom avec un suffixe sinon
+        """        
+        uniqueName  = nameIn
+        suffix      = 0
+        strSuffix   = ''
+                        
+        while study.hasName( SMesh, uniqueName + strSuffix  ):
+            suffix += 1
+            strSuffix = str( suffix )
+            
+        uniqueName = uniqueName + strSuffix
+        
+        return uniqueName
+        
+           
+
+    def __createSalomeMesh( self, mainShapeEntryIn, groupeMaEntriesIn, groupeNoEntriesIn ):
+        """
+        Fonction de création d'un nouveau maillage dans Salome
+        """
+        ok = False
+        try:
+            mainShapeName = study.getNameAttribute( mainShapeEntryIn )
+            newMeshName   = str( mainShapeName ) +  '_Mesh'            
+            newMeshName   = self.__meshUniqueName( newMeshName )            
+            study.createMesh( newMeshName, mainShapeEntryIn,  groupeMaEntriesIn, groupeNoEntriesIn )
+            study.refresh()
+            ok = True
+        except:
+            QMessageBox.warning( self, warning,  msg1 )
+        return ok
+        
+
+    def __updateSalomeMesh( self, groupeMaEntriesIn, groupeNoEntriesIn  ):
+        """
+        Fonction de mise à jours d'un maillage existant( séléctionné par l'utilisateur ds la listBox ) dans Salome
+        """
+        ok = False
+        try:                            
+            item = self.lbMeshes.selectedItem()            
+            selectedMeshName = str( item.text() )
+            meshEntry = self.meshEntries[ selectedMeshName ]
+            study.updateMesh( meshEntry, groupeMaEntriesIn, groupeNoEntriesIn )
+            study.refresh()
+            ok = True
+        except:
+            QMessageBox.warning( self, warning,  msg2 )
+        return ok
+      
+
+
+