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()
125 name = smeshBuilder.GetName( mm )
126 self.ui.mesh.setStyleSheet("")
127 self.ui.mesh.setText( name )
129 e = self.mm.NbEdges()
130 f = self.mm.NbFaces()
131 v = self.mm.NbVolumes()
134 controls += controls_1d
137 controls += controls_2d
140 controls += controls_3d
142 self.ui.control.addItems(controls)
143 self.compute_minmax()
144 self.connect(sg.getObjectBrowser(), SIGNAL("selectionChanged()"), self.select)
147 def helpMessage(self):
148 QMessageBox.about(None, "About Min/Max value of control",
150 Displays the min/max value of a control
151 ---------------------------------
153 This plugin displays the min and max value of a control
156 - The mesh to analyse
157 - The control to compute
161 def compute_minmax(self):
162 control = self.ui.control.currentText()
163 if self.mm and control:
164 fun = smesh.GetFunctor(controls_dict[str(control)])
166 hist = fun.GetHistogram(1,False)
169 self.ui.maxvalue.setText("%f"%(maxVal))
170 self.ui.minvalue.setText("%f"%(minVal))
176 window = MinmaxDialog()