1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 // File : BLSURFPluginGUI_StdWidget.cxx
22 // Authors : Gilles DAVID (OCC)
26 #include "BLSURFPluginGUI_Dlg.h"
28 #include "SMESHGUI_SpinBox.h"
35 //////////////////////////////////////////
36 // BLSURFPluginGUI_StdWidget
37 //////////////////////////////////////////
39 BLSURFPluginGUI_StdWidget::BLSURFPluginGUI_StdWidget( QWidget* parent, Qt::WindowFlags f )
40 : QWidget( parent, f )
43 myPhySize->RangeStepAndValidator(0, COORD_MAX, 10.0, "length_precision");
44 myMinSize->RangeStepAndValidator(0, COORD_MAX, 10.0, "length_precision");
45 myMaxSize->RangeStepAndValidator(0, COORD_MAX, 10.0, "length_precision");
46 myGradation->RangeStepAndValidator(1.0, COORD_MAX, 0.1, "length_precision");
47 myVolumeGradation->RangeStepAndValidator(1.0, COORD_MAX, 0.1, "length_precision");
48 myAngleMesh->RangeStepAndValidator(0, 90, 0.5, "angular_precision");
49 myChordalError->RangeStepAndValidator(0, COORD_MAX, 0.1, "length_precision");
50 myAnisotropicRatio->RangeStepAndValidator(0, COORD_MAX, 0.1, "length_precision");
51 myTinyEdgeLength->RangeStepAndValidator(0, COORD_MAX, 0.1, "length_precision");
52 myTinyEdgeOptimisLength->RangeStepAndValidator(0, COORD_MAX, 0.1, "length_precision");
53 myCorrectSurfaceIntersectionMaxCost->RangeStepAndValidator(0, COORD_MAX, 1);
54 myBadElementAspectRatio->RangeStepAndValidator(0, COORD_MAX, 1000, "length_precision");
55 myMinSize->setText("");
56 myMaxSize->setText("");
57 myAngleMesh->setText("");
58 myChordalError->setText("");
59 myAnisotropicRatio->setText("");
60 myTinyEdgeLength->setText("");
61 myTinyEdgeOptimisLength->setText("");
62 myCorrectSurfaceIntersectionMaxCost->setText("");
63 myBadElementAspectRatio->setText("");
64 myButtonGroupElementType->setId(myRadioButtonTriangles, Triangles);
65 myButtonGroupElementType->setId(myRadioButtonQuadrangleDominant, QuadrangleDominant);
66 myButtonGroupElementType->setId(myRadioButtonQuadrangles, Quadrangles);
69 BLSURFPluginGUI_StdWidget::~BLSURFPluginGUI_StdWidget()
73 void BLSURFPluginGUI_StdWidget::onPhysicalMeshChanged() {
74 bool isPhysicalGlobalSize = (myPhysicalMesh->currentIndex() == PhysicalGlobalSize);
75 bool isPhysicalLocalSize = (myPhysicalMesh->currentIndex() == PhysicalLocalSize);
76 bool isCustom = (isPhysicalGlobalSize || isPhysicalLocalSize) ;
78 myPhySize->setEnabled(isCustom);
79 myPhySizeRel->setEnabled(isCustom);
82 void BLSURFPluginGUI_StdWidget::onGeometricMeshChanged() {
83 bool isCustom = (myGeometricMesh->currentIndex() != DefaultGeom);
85 myAngleMesh->setEnabled( isCustom );
86 myChordalError->setEnabled( isCustom );
90 void BLSURFPluginGUI_StdWidget::resizeWidgets() {
91 // Set minimum width of spin boxes
93 QFontMetrics metrics1( myPhySize->font() );
94 QFontMetrics metrics2( myMinSize->font() );
95 QFontMetrics metrics3( myMaxSize->font() );
96 int width1 = metrics1.width(myPhySize->GetString());
97 int width2 = metrics2.width(myMinSize->GetString());
98 int width3 = metrics3.width(myMaxSize->GetString());
99 int max_width = max(width1,width2);
100 max_width = max(max_width, width3);
101 myPhySize->setMinimumWidth( max_width+50 );
102 myMinSize->setMinimumWidth( max_width+50 );
103 myMaxSize->setMinimumWidth( max_width+50 );
104 // Geometrical parameters
105 metrics1 = QFontMetrics(myAngleMesh->font());
106 metrics2 = QFontMetrics(myChordalError->font());
107 width1 = metrics1.width(myAngleMesh->GetString());
108 width2 = metrics2.width(myChordalError->GetString());
109 max_width = max(width1,width2);
110 myAngleMesh->setMinimumWidth( max_width+50 );
111 myChordalError->setMinimumWidth( max_width+50 );
113 metrics1 = QFontMetrics(myAnisotropicRatio->font());
114 metrics2 = QFontMetrics(myTinyEdgeLength->font());
115 metrics3 = QFontMetrics(myBadElementAspectRatio->font());
116 width1 = metrics1.width(myAnisotropicRatio->GetString());
117 width2 = metrics2.width(myTinyEdgeLength->GetString());
118 width3 = metrics3.width(myBadElementAspectRatio->GetString());
119 max_width = max(width1,width2);
120 max_width = max(max_width, width3);
121 myAnisotropicRatio->setMinimumWidth( max_width+50 );
122 myTinyEdgeLength->setMinimumWidth( max_width+50 );
123 myBadElementAspectRatio->setMinimumWidth( max_width+50 );
126 void BLSURFPluginGUI_StdWidget::onEditingFinished() {
127 SMESHGUI_SpinBox* spinBox = (SMESHGUI_SpinBox*)sender();
128 bool isEmpty = spinBox->editor()->text().isEmpty();
130 spinBox->SetValue(-1);
131 spinBox->setText("");