]> SALOME platform Git repositories - tools/eficas.git/commitdiff
Salome HOME
complexe
authorpascale.noyret <pascale.noyret@edf.fr>
Wed, 7 Jan 2015 15:44:20 +0000 (16:44 +0100)
committerpascale.noyret <pascale.noyret@edf.fr>
Wed, 7 Jan 2015 15:44:20 +0000 (16:44 +0100)
InterfaceQT4/monWidgetSimpComplexe.py [new file with mode: 0644]
UiQT4/desWidgetComplexe.ui [deleted file]
UiQT4/desWidgetSimpComplexe.ui [new file with mode: 0644]

diff --git a/InterfaceQT4/monWidgetSimpComplexe.py b/InterfaceQT4/monWidgetSimpComplexe.py
new file mode 100644 (file)
index 0000000..5e219dc
--- /dev/null
@@ -0,0 +1,162 @@
+# -*- coding: utf-8 -*-
+# Copyright (C) 2007-2013   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
+#
+# Modules Python
+import string,types,os
+
+# Modules Eficas
+from PyQt4.QtGui import *
+from PyQt4.QtCore import *
+from Extensions.i18n import tr
+
+from feuille                import Feuille
+from desWidgetSimpComplexe  import Ui_WidgetSimpComplexe 
+from politiquesValidation   import PolitiqueUnique
+from qtSaisie               import SaisieValeur
+
+
+class MonWidgetSimpComplexe (Ui_WidgetSimpComplexe,Feuille):
+
+  def __init__(self,node,monSimpDef,nom,objSimp,parentQt):
+        Feuille.__init__(self,node,monSimpDef,nom,objSimp,parentQt)
+        self.parentQt.commandesLayout.insertWidget(-1,self)
+        self.setFocusPolicy(Qt.StrongFocus)
+        self.connect(self.LEImag,SIGNAL("returnPressed()"),self.LEImagRPressed)
+        self.connect(self.LEReel,SIGNAL("returnPressed()"),self.LEReelRPressed)
+        self.connect(self.RBRI,SIGNAL("clicked()"), self.ValeurPressed )
+        self.connect(self.RBMP,SIGNAL("clicked()"), self.ValeurPressed )
+        self.connect(self.LEComp,SIGNAL("returnPressed()"),self.LECompRPressed)
+
+
+  def setValeurs(self):
+       self.politique=PolitiqueUnique(self.node,self.editor)
+       valeur=self.node.item.get_valeur()
+       if valeur == None or valeur == '' : return
+       if type(valeur) not in (types.ListType,types.TupleType) :
+           self.LEComp.setText(str(valeur))
+       else :
+           typ_cplx,x1,x2=valeur
+           self.LEReel.setText(str(x1))
+           self.LEImag.setText(str(x2))
+           if typ_cplx == "RI" :
+              self.RBRI.setChecked(1)
+           else :
+              self.RBMP.setChecked(1)
+
+  def LECompRPressed(self) :
+        self.LEReel.clear()
+        self.LEImag.clear()
+        commentaire=tr("expression valide")
+        valeur = str(self.LEComp.text())
+        d={}
+        try :
+          v=eval(valeur,d)
+        except :
+          commentaire=tr("expression invalide")
+          self.editor.affiche_infos(commentaire,Qt.red)
+          return
+        try :
+          i=v.imag
+          self.editor.affiche_infos(commentaire)
+          self.ValeurPressed()
+        except :
+          commentaire=tr("l expression n est pas de la forme a+bj")
+          self.editor.affiche_infos(commentaire,Qt.red)
+
+  def LEReelRPressed(self):
+        self.LEComp.clear()
+        commentaire=tr("expression valide")
+        valeur = str(self.LEReel.text())
+        try :
+          a=string.atof(valeur)
+          self.editor.affiche_infos(commentaire)
+        except :
+          commentaire=tr("expression invalide")
+          self.editor.affiche_infos(commentaire,Qt.red)
+        if self.LEImag.text()!="" : self.ValeurPressed()
+
+  def LEImagRPressed(self):
+        self.LEComp.clear()
+        commentaire=tr("expression valide")
+        valeur = str(self.LEImag.text())
+        try :
+          a=string.atof(valeur)
+          self.editor.affiche_infos(commentaire)
+        except :
+          commentaire=tr("expression invalide")
+          self.editor.affiche_infos(commentaire,Qt.red)
+        if self.LEReel.text()!="" : self.ValeurPressed()
+
+  def finCommentaire(self):
+      commentaire="valeur de type complexe"
+      return commentaire
+
+  def getValeurComp(self):
+        commentaire=tr("expression valide")
+        valeur = str(self.LEComp.text())
+        d={}
+        try :
+          v=eval(valeur,d)
+        except :
+          commentaire=tr("expression invalide")
+          self.editor.affiche_infos(commentaire,Qt.red)
+          return None
+        try :
+          i=v.imag
+        except :
+          commentaire=tr("expression n est pas de la forme a+bj")
+          self.editor.affiche_infos(commentaire,Qt.red)
+          return None
+        return v
+
+
+  def ValeurPressed(self):
+      if self.LEComp.text()== ""  and (self.LEReel.text()=="" or self.LEImag.text()=="") :
+         return
+      if self.LEComp.text()== "" : valeur = self.getValeurRI()
+      else :
+          if self.LEReel.text() != "" or self.LEImag.text() != "" :
+              commentaire=tr("entrer une seule valeur SVP")
+              self.editor.affiche_infos(commentaire,Qt.red)
+              return
+          valeur=  self.getValeurComp()
+      self.politique.RecordValeur(valeur)
+      self.parentQt.donneFocus()
+
+  def getValeurRI(self):
+      """
+      Retourne le complexe saisi par l'utilisateur
+      """
+      l=[]
+      if  (self.RBMP.isChecked() == 1 ) :
+         l.append("MP")
+      elif (self.RBRI.isChecked() == 1) :
+         l.append("RI")
+      else :
+         commentaire=tr("saisir le type de complexe")
+         self.editor.affiche_infos(commentaire,Qt.red)
+         return None
+      try :
+         l.append(string.atof(str(self.LEReel.text())))
+         l.append(string.atof(str(self.LEImag.text())))
+      except :
+         return None
+      return `tuple(l)`
+
+      
diff --git a/UiQT4/desWidgetComplexe.ui b/UiQT4/desWidgetComplexe.ui
deleted file mode 100644 (file)
index d941682..0000000
+++ /dev/null
@@ -1,177 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>WidgetSimpBool</class>
- <widget class="QWidget" name="WidgetSimpBool">
-  <property name="geometry">
-   <rect>
-    <x>0</x>
-    <y>0</y>
-    <width>1053</width>
-    <height>38</height>
-   </rect>
-  </property>
-  <property name="sizePolicy">
-   <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
-    <horstretch>0</horstretch>
-    <verstretch>0</verstretch>
-   </sizepolicy>
-  </property>
-  <property name="minimumSize">
-   <size>
-    <width>940</width>
-    <height>0</height>
-   </size>
-  </property>
-  <property name="maximumSize">
-   <size>
-    <width>1493</width>
-    <height>85</height>
-   </size>
-  </property>
-  <property name="windowTitle">
-   <string>Form</string>
-  </property>
-  <layout class="QHBoxLayout" name="horizontalLayout_4">
-   <property name="spacing">
-    <number>1</number>
-   </property>
-   <property name="margin">
-    <number>0</number>
-   </property>
-   <item>
-    <layout class="QHBoxLayout" name="horizontalLayout">
-     <item>
-      <widget class="QToolButton" name="RBValide">
-       <property name="minimumSize">
-        <size>
-         <width>21</width>
-         <height>31</height>
-        </size>
-       </property>
-       <property name="styleSheet">
-        <string notr="true">border : 0px</string>
-       </property>
-       <property name="text">
-        <string>...</string>
-       </property>
-       <property name="icon">
-        <iconset>
-         <normaloff>../../../../../../home/A96028/Install_EficasV1/ArbreEficas/Editeur/icons/ast-green-ball.png</normaloff>../../../../../../home/A96028/Install_EficasV1/ArbreEficas/Editeur/icons/ast-green-ball.png</iconset>
-       </property>
-       <property name="iconSize">
-        <size>
-         <width>32</width>
-         <height>32</height>
-        </size>
-       </property>
-      </widget>
-     </item>
-     <item>
-      <widget class="QToolButton" name="RBPoubelle">
-       <property name="minimumSize">
-        <size>
-         <width>21</width>
-         <height>31</height>
-        </size>
-       </property>
-       <property name="maximumSize">
-        <size>
-         <width>21</width>
-         <height>31</height>
-        </size>
-       </property>
-       <property name="styleSheet">
-        <string notr="true">border : 0px</string>
-       </property>
-       <property name="text">
-        <string>...</string>
-       </property>
-       <property name="icon">
-        <iconset>
-         <normaloff>../../../../../../home/A96028/Install_EficasV1/ArbreEficas/Editeur/icons/deleteRond.png</normaloff>../../../../../../home/A96028/Install_EficasV1/ArbreEficas/Editeur/icons/deleteRond.png</iconset>
-       </property>
-       <property name="iconSize">
-        <size>
-         <width>32</width>
-         <height>32</height>
-        </size>
-       </property>
-      </widget>
-     </item>
-     <item>
-      <widget class="QLabel" name="label">
-       <property name="minimumSize">
-        <size>
-         <width>178</width>
-         <height>24</height>
-        </size>
-       </property>
-       <property name="frameShape">
-        <enum>QFrame::NoFrame</enum>
-       </property>
-       <property name="text">
-        <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; color:#0055ff;&quot;&gt;Label&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
-       </property>
-      </widget>
-     </item>
-    </layout>
-   </item>
-   <item>
-    <spacer name="horizontalSpacer">
-     <property name="orientation">
-      <enum>Qt::Horizontal</enum>
-     </property>
-     <property name="sizeHint" stdset="0">
-      <size>
-       <width>19</width>
-       <height>20</height>
-      </size>
-     </property>
-    </spacer>
-   </item>
-   <item>
-    <layout class="QHBoxLayout" name="horizontalLayout_2">
-     <item>
-      <widget class="QRadioButton" name="RBRI">
-       <property name="text">
-        <string>Réel/Imaginaire</string>
-       </property>
-      </widget>
-     </item>
-     <item>
-      <widget class="QRadioButton" name="RBMP">
-       <property name="text">
-        <string>Module/Phase</string>
-       </property>
-      </widget>
-     </item>
-    </layout>
-   </item>
-   <item>
-    <spacer name="horizontalSpacer_2">
-     <property name="orientation">
-      <enum>Qt::Horizontal</enum>
-     </property>
-     <property name="sizeHint" stdset="0">
-      <size>
-       <width>19</width>
-       <height>20</height>
-      </size>
-     </property>
-    </spacer>
-   </item>
-   <item>
-    <layout class="QHBoxLayout" name="horizontalLayout_3">
-     <item>
-      <widget class="QLineEdit" name="LEReelModule"/>
-     </item>
-     <item>
-      <widget class="QLineEdit" name="LEImagPhase"/>
-     </item>
-    </layout>
-   </item>
-  </layout>
- </widget>
- <resources/>
- <connections/>
-</ui>
diff --git a/UiQT4/desWidgetSimpComplexe.ui b/UiQT4/desWidgetSimpComplexe.ui
new file mode 100644 (file)
index 0000000..6ea0cdb
--- /dev/null
@@ -0,0 +1,314 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>WidgetSimpComplexe</class>
+ <widget class="QWidget" name="WidgetSimpComplexe">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>1010</width>
+    <height>85</height>
+   </rect>
+  </property>
+  <property name="sizePolicy">
+   <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+    <horstretch>0</horstretch>
+    <verstretch>0</verstretch>
+   </sizepolicy>
+  </property>
+  <property name="minimumSize">
+   <size>
+    <width>940</width>
+    <height>0</height>
+   </size>
+  </property>
+  <property name="maximumSize">
+   <size>
+    <width>1493</width>
+    <height>85</height>
+   </size>
+  </property>
+  <property name="windowTitle">
+   <string>Form</string>
+  </property>
+  <layout class="QGridLayout" name="gridLayout">
+   <property name="leftMargin">
+    <number>0</number>
+   </property>
+   <property name="topMargin">
+    <number>2</number>
+   </property>
+   <property name="rightMargin">
+    <number>0</number>
+   </property>
+   <property name="bottomMargin">
+    <number>2</number>
+   </property>
+   <property name="spacing">
+    <number>0</number>
+   </property>
+   <item row="0" column="0" rowspan="2">
+    <layout class="QHBoxLayout" name="horizontalLayout_4">
+     <property name="spacing">
+      <number>0</number>
+     </property>
+     <property name="sizeConstraint">
+      <enum>QLayout::SetFixedSize</enum>
+     </property>
+     <item>
+      <layout class="QHBoxLayout" name="horizontalLayout">
+       <property name="spacing">
+        <number>0</number>
+       </property>
+       <item>
+        <spacer name="horizontalSpacer_3">
+         <property name="orientation">
+          <enum>Qt::Horizontal</enum>
+         </property>
+         <property name="sizeType">
+          <enum>QSizePolicy::Fixed</enum>
+         </property>
+         <property name="sizeHint" stdset="0">
+          <size>
+           <width>21</width>
+           <height>20</height>
+          </size>
+         </property>
+        </spacer>
+       </item>
+       <item>
+        <widget class="MonBoutonValide" name="RBValide">
+         <property name="minimumSize">
+          <size>
+           <width>21</width>
+           <height>31</height>
+          </size>
+         </property>
+         <property name="maximumSize">
+          <size>
+           <width>21</width>
+           <height>35</height>
+          </size>
+         </property>
+         <property name="styleSheet">
+          <string notr="true">border : 0px</string>
+         </property>
+         <property name="text">
+          <string>...</string>
+         </property>
+         <property name="icon">
+          <iconset>
+           <normaloff>../../../../../../home/A96028/Install_EficasV1/ArbreEficas/Editeur/icons/ast-green-ball.png</normaloff>../../../../../../home/A96028/Install_EficasV1/ArbreEficas/Editeur/icons/ast-green-ball.png</iconset>
+         </property>
+         <property name="iconSize">
+          <size>
+           <width>32</width>
+           <height>32</height>
+          </size>
+         </property>
+        </widget>
+       </item>
+      </layout>
+     </item>
+     <item>
+      <widget class="QLabel" name="label">
+       <property name="sizePolicy">
+        <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
+         <horstretch>0</horstretch>
+         <verstretch>0</verstretch>
+        </sizepolicy>
+       </property>
+       <property name="minimumSize">
+        <size>
+         <width>220</width>
+         <height>24</height>
+        </size>
+       </property>
+       <property name="maximumSize">
+        <size>
+         <width>178</width>
+         <height>16777215</height>
+        </size>
+       </property>
+       <property name="frameShape">
+        <enum>QFrame::NoFrame</enum>
+       </property>
+       <property name="text">
+        <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; color:#0055ff;&quot;&gt;Label&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+       </property>
+      </widget>
+     </item>
+    </layout>
+   </item>
+   <item row="0" column="1">
+    <layout class="QHBoxLayout" name="horizontalLayout_5">
+     <property name="spacing">
+      <number>0</number>
+     </property>
+     <item>
+      <widget class="QLabel" name="label_2">
+       <property name="sizePolicy">
+        <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+         <horstretch>0</horstretch>
+         <verstretch>0</verstretch>
+        </sizepolicy>
+       </property>
+       <property name="text">
+        <string>Complexe : a+bj</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <spacer name="horizontalSpacer_2">
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="sizeHint" stdset="0">
+        <size>
+         <width>19</width>
+         <height>20</height>
+        </size>
+       </property>
+      </spacer>
+     </item>
+    </layout>
+   </item>
+   <item row="0" column="2">
+    <widget class="QLabel" name="label_3">
+     <property name="sizePolicy">
+      <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+       <horstretch>0</horstretch>
+       <verstretch>0</verstretch>
+      </sizepolicy>
+     </property>
+     <property name="maximumSize">
+      <size>
+       <width>50</width>
+       <height>24</height>
+      </size>
+     </property>
+     <property name="text">
+      <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;OU &lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+     </property>
+    </widget>
+   </item>
+   <item row="0" column="3">
+    <layout class="QHBoxLayout" name="horizontalLayout_2">
+     <property name="leftMargin">
+      <number>4</number>
+     </property>
+     <property name="rightMargin">
+      <number>0</number>
+     </property>
+     <item>
+      <widget class="QRadioButton" name="RBRI">
+       <property name="text">
+        <string>Réel/Imaginaire</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QRadioButton" name="RBMP">
+       <property name="text">
+        <string>Module/Phase</string>
+       </property>
+      </widget>
+     </item>
+    </layout>
+   </item>
+   <item row="0" column="4">
+    <widget class="QToolButton" name="RBPoubelle">
+     <property name="minimumSize">
+      <size>
+       <width>21</width>
+       <height>31</height>
+      </size>
+     </property>
+     <property name="maximumSize">
+      <size>
+       <width>21</width>
+       <height>31</height>
+      </size>
+     </property>
+     <property name="styleSheet">
+      <string notr="true">border : 0px</string>
+     </property>
+     <property name="text">
+      <string>...</string>
+     </property>
+     <property name="icon">
+      <iconset>
+       <normaloff>../../../../../../home/A96028/Install_EficasV1/ArbreEficas/Editeur/icons/deleteRond.png</normaloff>../../../../../../home/A96028/Install_EficasV1/ArbreEficas/Editeur/icons/deleteRond.png</iconset>
+     </property>
+     <property name="iconSize">
+      <size>
+       <width>32</width>
+       <height>32</height>
+      </size>
+     </property>
+    </widget>
+   </item>
+   <item row="1" column="2" rowspan="2">
+    <spacer name="verticalSpacer_3">
+     <property name="orientation">
+      <enum>Qt::Vertical</enum>
+     </property>
+     <property name="sizeHint" stdset="0">
+      <size>
+       <width>20</width>
+       <height>47</height>
+      </size>
+     </property>
+    </spacer>
+   </item>
+   <item row="1" column="3" rowspan="2">
+    <layout class="QHBoxLayout" name="horizontalLayout_3">
+     <item>
+      <widget class="QLineEdit" name="LEReel"/>
+     </item>
+     <item>
+      <widget class="QLineEdit" name="LEImag"/>
+     </item>
+    </layout>
+   </item>
+   <item row="1" column="4" rowspan="2">
+    <spacer name="verticalSpacer_2">
+     <property name="orientation">
+      <enum>Qt::Vertical</enum>
+     </property>
+     <property name="sizeHint" stdset="0">
+      <size>
+       <width>18</width>
+       <height>47</height>
+      </size>
+     </property>
+    </spacer>
+   </item>
+   <item row="2" column="0">
+    <spacer name="verticalSpacer">
+     <property name="orientation">
+      <enum>Qt::Vertical</enum>
+     </property>
+     <property name="sizeHint" stdset="0">
+      <size>
+       <width>20</width>
+       <height>39</height>
+      </size>
+     </property>
+    </spacer>
+   </item>
+   <item row="2" column="1">
+    <widget class="QLineEdit" name="LEComp"/>
+   </item>
+  </layout>
+ </widget>
+ <customwidgets>
+  <customwidget>
+   <class>MonBoutonValide</class>
+   <extends>QToolButton</extends>
+   <header>monBoutonValide.h</header>
+  </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections/>
+</ui>