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>
69 BLSURFPluginGUI_HypothesisCreator::BLSURFPluginGUI_HypothesisCreator( const QString& theHypType )
70 : SMESHGUI_GenericHypothesisCreator( theHypType ),
75 BLSURFPluginGUI_HypothesisCreator::~BLSURFPluginGUI_HypothesisCreator()
79 bool BLSURFPluginGUI_HypothesisCreator::checkParams() const
81 BlsurfHypothesisData data_old, data_new;
82 readParamsFromHypo( data_old );
83 readParamsFromWidgets( data_new );
84 bool res = storeParamsToHypo( data_new );
88 QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame()
90 QFrame* fr = new QFrame( 0, "myframe" );
91 QVBoxLayout* lay = new QVBoxLayout( fr, 5, 0 );
93 QGroupBox* GroupC1 = new QGroupBox( 2, Qt::Horizontal, fr, "GroupC1" );
94 lay->addWidget( GroupC1 );
96 GroupC1->setTitle( tr( "SMESH_ARGUMENTS" ) );
97 GroupC1->layout()->setSpacing( 6 );
98 GroupC1->layout()->setMargin( 11 );
102 new QLabel( tr( "SMESH_NAME" ), GroupC1 );
103 myName = new QLineEdit( GroupC1 );
106 new QLabel( tr( "BLSURF_TOPOLOGY" ), GroupC1 );
107 myTopology = new QtxComboBox( GroupC1 );
108 QStringList topologyTypes;
109 topologyTypes.append( QObject::tr( "BLSURF_TOPOLOGY_CAD" ) );
110 topologyTypes.append( QObject::tr( "BLSURF_TOPOLOGY_PROCESS" ) );
111 topologyTypes.append( QObject::tr( "BLSURF_TOPOLOGY_PROCESS2" ) );
112 myTopology->insertStringList( topologyTypes );
114 new QLabel( tr( "BLSURF_PHY_MESH" ), GroupC1 );
115 myPhysicalMesh = new QtxComboBox( GroupC1 );
116 QStringList physicalTypes;
117 physicalTypes.append( QObject::tr( "BLSURF_DEFAULT_USER" ) );
118 physicalTypes.append( QObject::tr( "BLSURF_CUSTOM_USER" ) );
119 myPhysicalMesh->insertStringList( physicalTypes );
121 new QLabel( tr( "BLSURF_HPHYDEF" ), GroupC1 );
122 myPhySize = new QtxDblSpinBox( GroupC1 );
123 myPhySize->setMinValue( 1e-02 );
124 myPhySize->setMaxValue( 1e+02 );
125 myPhySize->setLineStep( 1 );
127 new QLabel( tr( "BLSURF_GEOM_MESH" ), GroupC1 );
128 myGeometricMesh = new QtxComboBox( GroupC1 );
130 types.append( QObject::tr( "BLSURF_DEFAULT_GEOM" ) );
131 types.append( QObject::tr( "BLSURF_CUSTOM_GEOM" ) );
132 myGeometricMesh->insertStringList( types );
134 // new QLabel( tr( "BLSURF_GROWTH_RATE" ), GroupC1 );
135 // myGrowthRate = new QtxDblSpinBox( GroupC1 );
136 // myGrowthRate->setMinValue( 0.1 );
137 // myGrowthRate->setMaxValue( 10 );
138 // myGrowthRate->setLineStep( 0.1 );
140 new QLabel( tr( "BLSURF_ANGLE_MESH_S" ), GroupC1 );
141 myAngleMeshS = new QtxDblSpinBox( GroupC1 );
142 myAngleMeshS->setMinValue( 0 );
143 myAngleMeshS->setMaxValue( 16 );
144 myAngleMeshS->setLineStep( 0.5 );
146 new QLabel( tr( "BLSURF_GRADATION" ), GroupC1 );
147 myGradation = new QtxDblSpinBox( GroupC1 );
148 myGradation->setMinValue( 1.1 );
149 myGradation->setMaxValue( 2.5 );
150 myGradation->setLineStep( 0.1 );
152 // new QLabel( tr( "BLSURF_SEG_PER_RADIUS" ), GroupC1 );
153 // myNbSegPerRadius = new QtxDblSpinBox( GroupC1 );
154 // myNbSegPerRadius->setMinValue( 0.2 );
155 // myNbSegPerRadius->setMaxValue( 5.0 );
157 myAllowQuadrangles = new QCheckBox( tr( "BLSURF_ALLOW_QUADRANGLES" ), GroupC1 );
158 GroupC1->addSpace(0);
161 myDecimesh = new QCheckBox( tr( "BLSURF_DECIMESH" ), GroupC1 );
162 GroupC1->addSpace(0);
164 connect( myGeometricMesh, SIGNAL( activated( int ) ), this, SLOT( onGeometricMeshChanged() ) );
165 connect( myPhysicalMesh, SIGNAL( activated( int ) ), this, SLOT( onPhysicalMeshChanged() ) );
170 void BLSURFPluginGUI_HypothesisCreator::retrieveParams() const
172 BlsurfHypothesisData data;
173 readParamsFromHypo( data );
176 myName->setText( data.myName );
177 myTopology->setCurrentItem( data.myTopology );
178 myPhysicalMesh->setCurrentItem( data.myPhysicalMesh );
179 myPhySize->setValue( data.myPhySize );
180 myGeometricMesh->setCurrentItem( data.myGeometricMesh );
181 myAngleMeshS->setValue( data.myAngleMeshS);
182 myGradation->setValue( data.myGradation);
183 myAllowQuadrangles->setChecked( data.myAllowQuadrangles );
184 myDecimesh->setChecked( data.myDecimesh );
188 bool isPhysicalCustom = (myPhysicalMesh->currentItem() == PhysicalUserDefined);
189 myPhySize->setEnabled(isPhysicalCustom);
191 bool isCustom = (myGeometricMesh->currentItem() == UserDefined);
192 myAngleMeshS->setEnabled(isCustom);
193 myGradation->setEnabled(isCustom);
196 QString BLSURFPluginGUI_HypothesisCreator::storeParams() const
198 BlsurfHypothesisData data;
199 readParamsFromWidgets( data );
200 storeParamsToHypo( data );
203 guiHyp += tr("BLSURF_TOPOLOGY") + " = " + QString::number( data.myTopology ) + "; ";
204 guiHyp += tr("BLSURF_PHY_MESH") + " = " + QString::number( data.myPhysicalMesh ) + "; ";
205 guiHyp += tr("BLSURF_HPHYDEF") + " = " + QString::number( data.myPhySize ) + "; ";
206 guiHyp += tr("BLSURF_GEOM_MESH") + " = " + QString::number( data.myGeometricMesh ) + "; ";
207 guiHyp += tr("BLSURF_ANGLE_MESH_S") + " = " + QString::number( data.myAngleMeshS ) + "; ";
208 guiHyp += tr("BLSURF_GRADATION") + " = " + QString::number( data.myGradation ) + "; ";
209 guiHyp += tr("BLSURF_ALLOW_QUADRANGLES") + " = " + QString(data.myAllowQuadrangles ? "yes" : "no") + "; ";
210 guiHyp += tr("BLSURF_DECIMESH") + " = " + QString(data.myDecimesh ? "yes" : "no") + "; ";
212 cout << "guiHyp : " << guiHyp << endl;
217 bool BLSURFPluginGUI_HypothesisCreator::readParamsFromHypo( BlsurfHypothesisData& h_data ) const
219 BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
220 BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( initParamsHypothesis() );
222 HypothesisData* data = SMESH::GetHypothesisData( hypType() );
223 h_data.myName = isCreation() && data ? data->Label : "";
225 h_data.myTopology = (int) h->GetTopology();
226 h_data.myPhysicalMesh = (int) h->GetPhysicalMesh();
227 h_data.myPhySize = h->GetPhySize();
228 h_data.myGeometricMesh = (int) h->GetGeometricMesh();
229 h_data.myAngleMeshS = h->GetAngleMeshS();
230 h_data.myGradation = h->GetGradation();
231 h_data.myAllowQuadrangles = h->GetQuadAllowed();
232 h_data.myDecimesh = h->GetDecimesh();
237 bool BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo( const BlsurfHypothesisData& h_data ) const
239 BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
240 BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( hypothesis() );
246 SMESH::SetName( SMESH::FindSObject( h ), h_data.myName.latin1() );
248 h->SetTopology( (int) h_data.myTopology );
249 h->SetPhysicalMesh( (int) h_data.myPhysicalMesh );
250 h->SetPhySize( h_data.myPhySize );
251 h->SetGeometricMesh( (int) h_data.myGeometricMesh );
252 h->SetGradation( h_data.myGradation );
253 h->SetQuadAllowed( h_data.myAllowQuadrangles );
254 h->SetDecimesh( h_data.myDecimesh );
256 if( (int) h_data.myPhysicalMesh == PhysicalUserDefined )
257 h->SetPhySize( h_data.myPhySize );
259 if( (int) h_data.myGeometricMesh == UserDefined )
260 h->SetAngleMeshS( h_data.myAngleMeshS );
262 catch(const SALOME::SALOME_Exception& ex)
264 SalomeApp_Tools::QtCatchCorbaException(ex);
270 bool BLSURFPluginGUI_HypothesisCreator::readParamsFromWidgets( BlsurfHypothesisData& h_data ) const
272 h_data.myName = myName ? myName->text() : "";
273 h_data.myTopology = myTopology->currentItem();
274 h_data.myPhysicalMesh = myPhysicalMesh->currentItem();
275 h_data.myPhySize = myPhySize->value();
276 h_data.myGeometricMesh = myGeometricMesh->currentItem();
277 h_data.myAngleMeshS = myAngleMeshS->value();
278 h_data.myGradation = myGradation->value();
279 h_data.myAllowQuadrangles = myAllowQuadrangles->isChecked();
280 h_data.myDecimesh = myDecimesh->isChecked();
285 void BLSURFPluginGUI_HypothesisCreator::onPhysicalMeshChanged() {
286 bool isCustom = (myPhysicalMesh->currentItem() == PhysicalUserDefined);
287 myPhySize->setEnabled(isCustom);
291 switch( myPhysicalMesh->currentItem() ) {
297 myPhySize->setValue( aPhySize );
301 void BLSURFPluginGUI_HypothesisCreator::onGeometricMeshChanged() {
302 bool isCustom = (myGeometricMesh->currentItem() == UserDefined);
303 myAngleMeshS->setEnabled(isCustom);
304 myGradation->setEnabled(isCustom);
307 double aAngleMeshS, aGradation;
308 switch( myGeometricMesh->currentItem() ) {
315 myAngleMeshS->setValue( aAngleMeshS );
316 myGradation->setValue( aGradation );
320 QString BLSURFPluginGUI_HypothesisCreator::caption() const
322 return tr( QString( "BLSURF_%1_TITLE" ).arg(myIs2D?QString("2D"):QString("3D")) );
325 QPixmap BLSURFPluginGUI_HypothesisCreator::icon() const
327 QString hypIconName = tr( QString("ICON_DLG_BLSURF_PARAMETERS%1").arg(myIs2D?QString(""):QString("")) );
328 return SUIT_Session::session()->resourceMgr()->loadPixmap( "BLSURFPlugin", hypIconName );
331 QString BLSURFPluginGUI_HypothesisCreator::type() const
333 return tr( QString( "BLSURF_%1_HYPOTHESIS" ).arg(myIs2D?QString("2D"):QString("3D")) );