1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2010-2016 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)
22 from qtsalome import *
25 # get context study, salomeGui
29 from minmax_ui import Ui_Dialog
33 from salome.smesh import smeshBuilder
34 smesh = smeshBuilder.New()
37 "Aspect Ratio 3D" : SMESH.FT_AspectRatio3D,
38 "Volume" : SMESH.FT_Volume3D,
39 "Element Diameter 3D" : SMESH.FT_MaxElementLength3D,
40 "Length 2D" : SMESH.FT_Length2D,
41 "MultiConnection 2D" : SMESH.FT_MultiConnection2D,
42 "Area" : SMESH.FT_Area,
43 "Taper" : SMESH.FT_Taper,
44 "Aspect Ratio" : SMESH.FT_AspectRatio,
45 "Minimum Angle" : SMESH.FT_MinimumAngle,
46 "Warping" : SMESH.FT_Warping,
47 "Skew" : SMESH.FT_Skew,
48 "Element Diameter 2D" : SMESH.FT_MaxElementLength2D,
49 "Length" : SMESH.FT_Length,
50 "MultiConnection" : SMESH.FT_MultiConnection,
56 "Element Diameter 3D",
74 class MinmaxDialog(QDialog):
76 QDialog.__init__(self, None, Qt.Tool)
77 # Set up the user interface from Designer.
84 # Connect up the selectionChanged() event of the object browser.
85 sg.getObjectBrowser().selectionChanged.connect(self.select)
88 self.ui.control.setFocus()
94 sg.getObjectBrowser().selectionChanged.disconnect(self.select)
98 def clearLineEdit(self):
99 self.ui.mesh.setText("Select a Mesh")
100 self.ui.mesh.setStyleSheet("QLineEdit { color: grey }")
101 self.ui.minvalue.setText("")
102 self.ui.maxvalue.setText("")
105 sg.getObjectBrowser().selectionChanged.disconnect(self.select)
106 self.ui.minvalue.setText("")
107 self.ui.maxvalue.setText("")
108 objId = salome.sg.getSelected(0)
110 mm = study.FindObjectID(objId).GetObject()
120 name = smeshBuilder.GetName( mm )
121 self.ui.mesh.setStyleSheet("")
122 self.ui.mesh.setText( name )
124 e = self.mm.NbEdges()
125 f = self.mm.NbFaces()
126 v = self.mm.NbVolumes()
129 controls += controls_1d
132 controls += controls_2d
135 controls += controls_3d
137 if self.ui.control.count() != len( controls ):
138 self.ui.control.clear()
139 self.ui.control.addItems(controls)
140 self.compute_minmax()
141 sg.getObjectBrowser().selectionChanged.connect(self.select)
144 def helpMessage(self):
145 QMessageBox.about(None, "About Min/Max value of control",
147 Displays the min/max value of a control
148 ---------------------------------
150 This plugin displays the min and max value of a control
153 - The mesh to analyse
154 - The control to compute
158 def compute_minmax(self):
159 control = self.ui.control.currentText()
160 if self.mm and control:
161 fun = smesh.GetFunctor(controls_dict[str(control)])
163 hist = fun.GetHistogram(1,False)
166 self.ui.maxvalue.setText("%f"%(maxVal))
167 self.ui.minvalue.setText("%f"%(minVal))
173 window = MinmaxDialog()