1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2010-2012 CEA/DEN, EDF R&D, OPEN CASCADE
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 # Author : Guillaume Boulant (EDF)
23 # get context study, studyId, salomeGui
25 studyId = context.studyId
28 from PyQt4.QtGui import QDialog
29 from PyQt4.QtGui import QMessageBox
30 from PyQt4.QtCore import Qt
31 from PyQt4.QtCore import SIGNAL
33 from minmax_dialog import Ui_Dialog
39 "Aspect Ratio 3D" : smesh.FT_AspectRatio3D,
40 "Volume" : smesh.FT_Volume3D,
41 "Element Diameter 3D" : smesh.FT_MaxElementLength3D,
42 "Length 2D" : smesh.FT_Length2D,
43 "MultiConnection 2D" : smesh.FT_MultiConnection2D,
44 "Area" : smesh.FT_Area,
45 "Taper" : smesh.FT_Taper,
46 "Aspect Ratio" : smesh.FT_AspectRatio,
47 "Minimum Angle" : smesh.FT_MinimumAngle,
48 "Warping" : smesh.FT_Warping,
49 "Skew" : smesh.FT_Skew,
50 "Element Diameter 2D" : smesh.FT_MaxElementLength2D,
51 "Length" : smesh.FT_Length,
52 "MultiConnection" : smesh.FT_MultiConnection,
58 "Element Diameter 3D",
76 class MinmaxDialog(QDialog):
78 QDialog.__init__(self, None, Qt.Tool)
79 # Set up the user interface from Designer.
86 # Connect up the selectionChanged() event of the object browser.
87 self.connect(sg.getObjectBrowser(), SIGNAL("selectionChanged()"), self.select)
90 self.ui.control.setFocus()
96 self.disconnect(sg.getObjectBrowser(), SIGNAL("selectionChanged()"), self.select)
100 def clearLineEdit(self):
101 self.ui.mesh.setText("Select a Mesh")
102 self.ui.mesh.setStyleSheet("QLineEdit { color: grey }")
103 self.ui.minvalue.setText("")
104 self.ui.maxvalue.setText("")
107 self.disconnect(sg.getObjectBrowser(), SIGNAL("selectionChanged()"), self.select)
108 self.ui.control.clear()
109 self.ui.minvalue.setText("")
110 self.ui.maxvalue.setText("")
111 objId = salome.sg.getSelected(0)
113 mm = study.FindObjectID(objId).GetObject()
116 mesh = mm.GetMEDMesh()
118 #print "No mesh selected"
123 self.ui.mesh.setStyleSheet("")
124 self.ui.mesh.setText(mesh.getName())
125 #print "Mesh selected: ", mesh.getName()
127 e = self.mm.NbEdges()
128 f = self.mm.NbFaces()
129 v = self.mm.NbVolumes()
132 #print "NbVolumes: ",v
135 controls += controls_1d
138 controls += controls_2d
141 controls += controls_3d
143 self.ui.control.addItems(controls)
144 self.compute_minmax()
145 self.connect(sg.getObjectBrowser(), SIGNAL("selectionChanged()"), self.select)
148 def helpMessage(self):
149 QMessageBox.about(None, "About Min/Max value of control",
151 Displays the min/max value of a control
152 ---------------------------------
154 This plugin displays the min and max value of a control
157 - The mesh to analyse
158 - The control to compute
162 def compute_minmax(self):
164 control = self.ui.control.currentText()
165 #print "Compute control: ",control
166 fun = smesh.GetFunctor(controls_dict[str(control)])
167 fun.SetMesh(self.mm.GetMesh())
168 hist = fun.GetHistogram(1)
171 #print "Max value for %s: %f"%(control, maxVal)
172 #print "Min value for %s: %f"%(control, minVal)
173 self.ui.maxvalue.setText("%f"%(maxVal))
174 self.ui.minvalue.setText("%f"%(minVal))
176 print "Pas de maillage"
181 window = MinmaxDialog()