1 // BLSURFPlugin GUI: GUI for plugged-in mesher BLSURFPlugin
3 // Copyright (C) 2003 CEA
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License.
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Lesser General Public License for more details.
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // See http://www.salome-platform.org or email : webmaster.salome@opencascade.org
23 // File : BLSURFPluginGUI_HypothesisCreator.cxx
24 // Authors : Francis KLOSS (OCC) & Patrick LAUG (INRIA) & Lioka RAZAFINDRAZAKA (CEA)
25 // Module : BLSURFPlugin
28 #include "BLSURFPluginGUI_HypothesisCreator.h"
30 #include <SMESHGUI_Utils.h>
31 #include <SMESHGUI_HypothesesUtils.h>
33 #include CORBA_SERVER_HEADER(BLSURFPlugin_Algorithm)
35 #include <SUIT_Session.h>
37 #include <SalomeApp_Tools.h>
39 #include <QtxDblSpinBox.h>
40 #include <QtxComboBox.h>
43 #include <qgroupbox.h>
46 #include <qlineedit.h>
47 #include <qcheckbox.h>
62 BLSURFPluginGUI_HypothesisCreator::BLSURFPluginGUI_HypothesisCreator( const QString& theHypType )
63 : SMESHGUI_GenericHypothesisCreator( theHypType ),
68 BLSURFPluginGUI_HypothesisCreator::~BLSURFPluginGUI_HypothesisCreator()
72 bool BLSURFPluginGUI_HypothesisCreator::checkParams() const
74 BlsurfHypothesisData data_old, data_new;
75 readParamsFromHypo( data_old );
76 readParamsFromWidgets( data_new );
77 bool res = storeParamsToHypo( data_new );
81 QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame()
83 QFrame* fr = new QFrame( 0, "myframe" );
84 QVBoxLayout* lay = new QVBoxLayout( fr, 5, 0 );
86 QGroupBox* GroupC1 = new QGroupBox( 2, Qt::Horizontal, fr, "GroupC1" );
87 lay->addWidget( GroupC1 );
89 GroupC1->setTitle( tr( "SMESH_ARGUMENTS" ) );
90 GroupC1->layout()->setSpacing( 6 );
91 GroupC1->layout()->setMargin( 11 );
95 new QLabel( tr( "SMESH_NAME" ), GroupC1 );
96 myName = new QLineEdit( GroupC1 );
99 new QLabel( tr( "BLSURF_PHY_MESH" ), GroupC1 );
100 myPhysicalMesh = new QtxComboBox( GroupC1 );
101 QStringList physicalTypes;
102 physicalTypes.append( QObject::tr( "BLSURF_DEFAULT_USER" ) );
103 physicalTypes.append( QObject::tr( "BLSURF_CUSTOM_USER" ) );
104 myPhysicalMesh->insertStringList( physicalTypes );
106 new QLabel( tr( "BLSURF_HPHYDEF" ), GroupC1 );
107 myPhySize = new QtxDblSpinBox( GroupC1 );
108 myPhySize->setMinValue( 1e-02 );
109 myPhySize->setMaxValue( 1e+02 );
110 myPhySize->setLineStep( 1 );
112 new QLabel( tr( "BLSURF_GEOM_MESH" ), GroupC1 );
113 myGeometricMesh = new QtxComboBox( GroupC1 );
115 types.append( QObject::tr( "BLSURF_DEFAULT_GEOM" ) );
116 types.append( QObject::tr( "BLSURF_CUSTOM_GEOM" ) );
117 myGeometricMesh->insertStringList( types );
119 // new QLabel( tr( "BLSURF_GROWTH_RATE" ), GroupC1 );
120 // myGrowthRate = new QtxDblSpinBox( GroupC1 );
121 // myGrowthRate->setMinValue( 0.1 );
122 // myGrowthRate->setMaxValue( 10 );
123 // myGrowthRate->setLineStep( 0.1 );
125 new QLabel( tr( "BLSURF_ANGLE_MESH_S" ), GroupC1 );
126 myAngleMeshS = new QtxDblSpinBox( GroupC1 );
127 myAngleMeshS->setMinValue( 0 );
128 myAngleMeshS->setMaxValue( 16 );
129 myAngleMeshS->setLineStep( 0.5 );
131 new QLabel( tr( "BLSURF_GRADATION" ), GroupC1 );
132 myGradation = new QtxDblSpinBox( GroupC1 );
133 myGradation->setMinValue( 1.1 );
134 myGradation->setMaxValue( 1.5 );
135 myGradation->setLineStep( 0.1 );
137 // new QLabel( tr( "BLSURF_SEG_PER_RADIUS" ), GroupC1 );
138 // myNbSegPerRadius = new QtxDblSpinBox( GroupC1 );
139 // myNbSegPerRadius->setMinValue( 0.2 );
140 // myNbSegPerRadius->setMaxValue( 5.0 );
142 myAllowQuadrangles = new QCheckBox( tr( "BLSURF_ALLOW_QUADRANGLES" ), GroupC1 );
143 GroupC1->addSpace(0);
146 myDecimesh = new QCheckBox( tr( "BLSURF_DECIMESH" ), GroupC1 );
147 GroupC1->addSpace(0);
149 connect( myGeometricMesh, SIGNAL( activated( int ) ), this, SLOT( onGeometricMeshChanged() ) );
150 connect( myPhysicalMesh, SIGNAL( activated( int ) ), this, SLOT( onPhysicalMeshChanged() ) );
155 void BLSURFPluginGUI_HypothesisCreator::retrieveParams() const
157 BlsurfHypothesisData data;
158 readParamsFromHypo( data );
161 myName->setText( data.myName );
162 myPhysicalMesh->setCurrentItem( data.myPhysicalMesh );
163 myPhySize->setValue( data.myPhySize );
164 myGeometricMesh->setCurrentItem( data.myGeometricMesh );
165 myAngleMeshS->setValue( data.myAngleMeshS);
166 myGradation->setValue( data.myGradation);
167 myAllowQuadrangles->setChecked( data.myAllowQuadrangles );
168 myDecimesh->setChecked( data.myDecimesh );
172 bool isPhysicalCustom = (myPhysicalMesh->currentItem() == PhysicalUserDefined);
173 myPhySize->setEnabled(isPhysicalCustom);
175 bool isCustom = (myGeometricMesh->currentItem() == UserDefined);
176 myAngleMeshS->setEnabled(isCustom);
177 myGradation->setEnabled(isCustom);
180 QString BLSURFPluginGUI_HypothesisCreator::storeParams() const
182 BlsurfHypothesisData data;
183 readParamsFromWidgets( data );
184 storeParamsToHypo( data );
187 guiHyp += tr("BLSURF_PHY_MESH") + " = " + QString::number( data.myPhysicalMesh ) + "; ";
188 guiHyp += tr("BLSURF_HPHYDEF") + " = " + QString::number( data.myPhySize ) + "; ";
189 guiHyp += tr("BLSURF_GEOM_MESH") + " = " + QString::number( data.myGeometricMesh ) + "; ";
190 guiHyp += tr("BLSURF_ANGLE_MESH_S") + " = " + QString::number( data.myAngleMeshS ) + "; ";
191 guiHyp += tr("BLSURF_GRADATION") + " = " + QString::number( data.myGradation ) + "; ";
192 guiHyp += tr("BLSURF_ALLOW_QUADRANGLES") + " = " + QString(data.myAllowQuadrangles ? "yes" : "no") + "; ";
193 guiHyp += tr("BLSURF_DECIMESH") + " = " + QString(data.myDecimesh ? "yes" : "no") + "; ";
195 cout << "guiHyp : " << guiHyp << endl;
200 bool BLSURFPluginGUI_HypothesisCreator::readParamsFromHypo( BlsurfHypothesisData& h_data ) const
202 BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
203 BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( initParamsHypothesis() );
205 HypothesisData* data = SMESH::GetHypothesisData( hypType() );
206 h_data.myName = isCreation() && data ? data->Label : "";
208 h_data.myPhysicalMesh = (int) h->GetPhysicalMesh();
209 h_data.myPhySize = h->GetPhySize();
210 h_data.myGeometricMesh = (int) h->GetGeometricMesh();
211 h_data.myAngleMeshS = h->GetAngleMeshS();
212 h_data.myGradation = h->GetGradation();
213 h_data.myAllowQuadrangles = h->GetQuadAllowed();
214 h_data.myDecimesh = h->GetDecimesh();
219 bool BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo( const BlsurfHypothesisData& h_data ) const
221 BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
222 BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( hypothesis() );
228 SMESH::SetName( SMESH::FindSObject( h ), h_data.myName.latin1() );
230 h->SetPhysicalMesh( (int) h_data.myPhysicalMesh );
231 h->SetPhySize( h_data.myPhySize );
232 h->SetGeometricMesh( (int) h_data.myGeometricMesh );
233 h->SetGradation( h_data.myGradation );
234 h->SetQuadAllowed( h_data.myAllowQuadrangles );
235 h->SetDecimesh( h_data.myDecimesh );
237 if( (int) h_data.myPhysicalMesh == PhysicalUserDefined )
238 h->SetPhySize( h_data.myPhySize );
240 if( (int) h_data.myGeometricMesh == UserDefined )
241 h->SetAngleMeshS( h_data.myAngleMeshS );
243 catch(const SALOME::SALOME_Exception& ex)
245 SalomeApp_Tools::QtCatchCorbaException(ex);
251 bool BLSURFPluginGUI_HypothesisCreator::readParamsFromWidgets( BlsurfHypothesisData& h_data ) const
253 h_data.myName = myName ? myName->text() : "";
254 h_data.myPhysicalMesh = myPhysicalMesh->currentItem();
255 h_data.myPhySize = myPhySize->value();
256 h_data.myGeometricMesh = myGeometricMesh->currentItem();
257 h_data.myAngleMeshS = myAngleMeshS->value();
258 h_data.myGradation = myGradation->value();
259 h_data.myAllowQuadrangles = myAllowQuadrangles->isChecked();
260 h_data.myDecimesh = myDecimesh->isChecked();
265 void BLSURFPluginGUI_HypothesisCreator::onPhysicalMeshChanged() {
266 bool isCustom = (myPhysicalMesh->currentItem() == PhysicalUserDefined);
267 myPhySize->setEnabled(isCustom);
271 switch( myPhysicalMesh->currentItem() ) {
277 myPhySize->setValue( aPhySize );
281 void BLSURFPluginGUI_HypothesisCreator::onGeometricMeshChanged() {
282 bool isCustom = (myGeometricMesh->currentItem() == UserDefined);
283 myAngleMeshS->setEnabled(isCustom);
284 myGradation->setEnabled(isCustom);
287 double aAngleMeshS, aGradation;
288 switch( myGeometricMesh->currentItem() ) {
295 myAngleMeshS->setValue( aAngleMeshS );
296 myGradation->setValue( aGradation );
300 QString BLSURFPluginGUI_HypothesisCreator::caption() const
302 return tr( QString( "BLSURF_%1_TITLE" ).arg(myIs2D?QString("2D"):QString("3D")) );
305 QPixmap BLSURFPluginGUI_HypothesisCreator::icon() const
307 QString hypIconName = tr( QString("ICON_DLG_BLSURF_PARAMETERS%1").arg(myIs2D?QString(""):QString("")) );
308 return SUIT_Session::session()->resourceMgr()->loadPixmap( "BLSURFPlugin", hypIconName );
311 QString BLSURFPluginGUI_HypothesisCreator::type() const
313 return tr( QString( "BLSURF_%1_HYPOTHESIS" ).arg(myIs2D?QString("2D"):QString("3D")) );