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.1, COORD_MAX, 0.1, "length_precision");
47 myAngleMesh->RangeStepAndValidator(0, 90, 0.5, "angular_precision");
48 myChordalError->RangeStepAndValidator(0, COORD_MAX, 0.1, "length_precision");
49 myAnisotropicRatio->RangeStepAndValidator(0, COORD_MAX, 0.1, "length_precision");
50 myTinyEdgeLength->RangeStepAndValidator(COORD_MIN, COORD_MAX, 0.1, "length_precision");
51 myBadElementAspectRatio->RangeStepAndValidator(0, COORD_MAX, 1000, "length_precision");
52 myMinSize->setText("");
53 myMaxSize->setText("");
54 myAngleMesh->setText("");
55 myChordalError->setText("");
56 myAnisotropicRatio->setText("");
57 myTinyEdgeLength->setText("");
58 myBadElementAspectRatio->setText("");
61 BLSURFPluginGUI_StdWidget::~BLSURFPluginGUI_StdWidget()
65 void BLSURFPluginGUI_StdWidget::onPhysicalMeshChanged() {
66 bool isPhysicalGlobalSize = (myPhysicalMesh->currentIndex() == PhysicalGlobalSize);
67 bool isPhysicalLocalSize = (myPhysicalMesh->currentIndex() == PhysicalLocalSize);
68 bool isCustom = (isPhysicalGlobalSize || isPhysicalLocalSize) ;
69 bool geomIsCustom = (myGeometricMesh->currentIndex() != DefaultGeom);
70 bool isQuadAllowed = (myAllowQuadrangles->isChecked() );
72 myGradation->setEnabled( !isQuadAllowed && ( !isPhysicalGlobalSize || geomIsCustom ));
73 myPhySize->setEnabled(isCustom);
74 myPhySizeRel->setEnabled(isCustom);
77 if ( myGeometricMesh->currentIndex() == DefaultGeom ) {
78 myGeometricMesh->setCurrentIndex( GeometricalGlobalSize );
79 onGeometricMeshChanged();
84 void BLSURFPluginGUI_StdWidget::onGeometricMeshChanged() {
85 bool isCustom = (myGeometricMesh->currentIndex() != DefaultGeom);
86 bool isPhysicalLocalSize = (myPhysicalMesh->currentIndex() == PhysicalLocalSize);
87 bool isQuadAllowed = (myAllowQuadrangles->isChecked() );
89 GeomParamsGroupBox->setEnabled(isCustom);
90 myGradation->setEnabled( !isQuadAllowed && ( isCustom || isPhysicalLocalSize ));
93 // hphy_flag = 0 and hgeo_flag = 0 is not allowed (spec)
94 if ( myPhysicalMesh->currentIndex() == DefaultSize ) {
95 myPhysicalMesh->setCurrentIndex( PhysicalGlobalSize );
96 onPhysicalMeshChanged();
101 void BLSURFPluginGUI_StdWidget::resizeWidgets() {
102 // Set minimum width of spin boxes
104 QFontMetrics metrics1( myPhySize->font() );
105 QFontMetrics metrics2( myMinSize->font() );
106 QFontMetrics metrics3( myMaxSize->font() );
107 int width1 = metrics1.width(myPhySize->GetString());
108 int width2 = metrics2.width(myMinSize->GetString());
109 int width3 = metrics3.width(myMaxSize->GetString());
110 int max_width = max(width1,width2);
111 max_width = max(max_width, width3);
112 myPhySize->setMinimumWidth( max_width+50 );
113 myMinSize->setMinimumWidth( max_width+50 );
114 myMaxSize->setMinimumWidth( max_width+50 );
115 // Geometrical parameters
116 metrics1 = QFontMetrics(myAngleMesh->font());
117 metrics2 = QFontMetrics(myChordalError->font());
118 width1 = metrics1.width(myAngleMesh->GetString());
119 width2 = metrics2.width(myChordalError->GetString());
120 max_width = max(width1,width2);
121 myAngleMesh->setMinimumWidth( max_width+50 );
122 myChordalError->setMinimumWidth( max_width+50 );
124 metrics1 = QFontMetrics(myAnisotropicRatio->font());
125 metrics2 = QFontMetrics(myTinyEdgeLength->font());
126 metrics3 = QFontMetrics(myBadElementAspectRatio->font());
127 width1 = metrics1.width(myAnisotropicRatio->GetString());
128 width2 = metrics2.width(myTinyEdgeLength->GetString());
129 width3 = metrics3.width(myBadElementAspectRatio->GetString());
130 max_width = max(width1,width2);
131 max_width = max(max_width, width3);
132 myAnisotropicRatio->setMinimumWidth( max_width+50 );
133 myTinyEdgeLength->setMinimumWidth( max_width+50 );
134 myBadElementAspectRatio->setMinimumWidth( max_width+50 );
137 void BLSURFPluginGUI_StdWidget::onEditingFinished() {
138 SMESHGUI_SpinBox* spinBox = (SMESHGUI_SpinBox*)sender();
139 bool isEmpty = spinBox->editor()->text().isEmpty();
141 spinBox->SetValue(-1);
142 spinBox->setText("");