1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2010-2015 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, or (at your option) any later version.
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
37 from salome.smesh import smeshBuilder
38 smesh = smeshBuilder.New(salome.myStudy)
41 "Aspect Ratio 3D" : SMESH.FT_AspectRatio3D,
42 "Volume" : SMESH.FT_Volume3D,
43 "Element Diameter 3D" : SMESH.FT_MaxElementLength3D,
44 "Length 2D" : SMESH.FT_Length2D,
45 "MultiConnection 2D" : SMESH.FT_MultiConnection2D,
46 "Area" : SMESH.FT_Area,
47 "Taper" : SMESH.FT_Taper,
48 "Aspect Ratio" : SMESH.FT_AspectRatio,
49 "Minimum Angle" : SMESH.FT_MinimumAngle,
50 "Warping" : SMESH.FT_Warping,
51 "Skew" : SMESH.FT_Skew,
52 "Element Diameter 2D" : SMESH.FT_MaxElementLength2D,
53 "Length" : SMESH.FT_Length,
54 "MultiConnection" : SMESH.FT_MultiConnection,
60 "Element Diameter 3D",
78 class MinmaxDialog(QDialog):
80 QDialog.__init__(self, None, Qt.Tool)
81 # Set up the user interface from Designer.
88 # Connect up the selectionChanged() event of the object browser.
89 self.connect(sg.getObjectBrowser(), SIGNAL("selectionChanged()"), self.select)
92 self.ui.control.setFocus()
98 self.disconnect(sg.getObjectBrowser(), SIGNAL("selectionChanged()"), self.select)
102 def clearLineEdit(self):
103 self.ui.mesh.setText("Select a Mesh")
104 self.ui.mesh.setStyleSheet("QLineEdit { color: grey }")
105 self.ui.minvalue.setText("")
106 self.ui.maxvalue.setText("")
109 self.disconnect(sg.getObjectBrowser(), SIGNAL("selectionChanged()"), self.select)
110 self.ui.control.clear()
111 self.ui.minvalue.setText("")
112 self.ui.maxvalue.setText("")
113 objId = salome.sg.getSelected(0)
115 mm = study.FindObjectID(objId).GetObject()
118 mesh = mm.GetMEDMesh()
120 #print "No mesh selected"
125 self.ui.mesh.setStyleSheet("")
126 self.ui.mesh.setText(mesh.getName())
127 #print "Mesh selected: ", mesh.getName()
129 e = self.mm.NbEdges()
130 f = self.mm.NbFaces()
131 v = self.mm.NbVolumes()
134 #print "NbVolumes: ",v
137 controls += controls_1d
140 controls += controls_2d
143 controls += controls_3d
145 self.ui.control.addItems(controls)
146 self.compute_minmax()
147 self.connect(sg.getObjectBrowser(), SIGNAL("selectionChanged()"), self.select)
150 def helpMessage(self):
151 QMessageBox.about(None, "About Min/Max value of control",
153 Displays the min/max value of a control
154 ---------------------------------
156 This plugin displays the min and max value of a control
159 - The mesh to analyse
160 - The control to compute
164 def compute_minmax(self):
166 control = self.ui.control.currentText()
167 #print "Compute control: ",control
168 fun = smesh.GetFunctor(controls_dict[str(control)])
169 fun.SetMesh(self.mm.GetMesh())
170 hist = fun.GetHistogram(1)
173 #print "Max value for %s: %f"%(control, maxVal)
174 #print "Min value for %s: %f"%(control, minVal)
175 self.ui.maxvalue.setText("%f"%(maxVal))
176 self.ui.minvalue.setText("%f"%(minVal))
178 print "Pas de maillage"
183 window = MinmaxDialog()