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, studyId, salomeGui
27 studyId = context.studyId
30 from minmax_ui import Ui_Dialog
34 from salome.smesh import smeshBuilder
35 smesh = smeshBuilder.New(salome.myStudy)
38 "Aspect Ratio 3D" : SMESH.FT_AspectRatio3D,
39 "Volume" : SMESH.FT_Volume3D,
40 "Element Diameter 3D" : SMESH.FT_MaxElementLength3D,
41 "Length 2D" : SMESH.FT_Length2D,
42 "MultiConnection 2D" : SMESH.FT_MultiConnection2D,
43 "Area" : SMESH.FT_Area,
44 "Taper" : SMESH.FT_Taper,
45 "Aspect Ratio" : SMESH.FT_AspectRatio,
46 "Minimum Angle" : SMESH.FT_MinimumAngle,
47 "Warping" : SMESH.FT_Warping,
48 "Skew" : SMESH.FT_Skew,
49 "Element Diameter 2D" : SMESH.FT_MaxElementLength2D,
50 "Length" : SMESH.FT_Length,
51 "MultiConnection" : SMESH.FT_MultiConnection,
57 "Element Diameter 3D",
75 class MinmaxDialog(QDialog):
77 QDialog.__init__(self, None, Qt.Tool)
78 # Set up the user interface from Designer.
85 # Connect up the selectionChanged() event of the object browser.
86 sg.getObjectBrowser().selectionChanged.connect(self.select)
89 self.ui.control.setFocus()
95 sg.getObjectBrowser().selectionChanged.disconnect(self.select)
99 def clearLineEdit(self):
100 self.ui.mesh.setText("Select a Mesh")
101 self.ui.mesh.setStyleSheet("QLineEdit { color: grey }")
102 self.ui.minvalue.setText("")
103 self.ui.maxvalue.setText("")
106 sg.getObjectBrowser().selectionChanged.disconnect(self.select)
107 self.ui.minvalue.setText("")
108 self.ui.maxvalue.setText("")
109 objId = salome.sg.getSelected(0)
111 mm = study.FindObjectID(objId).GetObject()
121 name = smeshBuilder.GetName( mm )
122 self.ui.mesh.setStyleSheet("")
123 self.ui.mesh.setText( name )
125 e = self.mm.NbEdges()
126 f = self.mm.NbFaces()
127 v = self.mm.NbVolumes()
130 controls += controls_1d
133 controls += controls_2d
136 controls += controls_3d
138 if self.ui.control.count() != len( controls ):
139 self.ui.control.clear()
140 self.ui.control.addItems(controls)
141 self.compute_minmax()
142 sg.getObjectBrowser().selectionChanged.connect(self.select)
145 def helpMessage(self):
146 QMessageBox.about(None, "About Min/Max value of control",
148 Displays the min/max value of a control
149 ---------------------------------
151 This plugin displays the min and max value of a control
154 - The mesh to analyse
155 - The control to compute
159 def compute_minmax(self):
160 control = self.ui.control.currentText()
161 if self.mm and control:
162 fun = smesh.GetFunctor(controls_dict[str(control)])
164 hist = fun.GetHistogram(1,False)
167 self.ui.maxvalue.setText("%f"%(maxVal))
168 self.ui.minvalue.setText("%f"%(minVal))
174 window = MinmaxDialog()