1 // Copyright (C) 2007-2008 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.
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
19 // BLSURFPlugin GUI: GUI for plugged-in mesher BLSURFPlugin
20 // File : BLSURFPluginGUI_HypothesisCreator.cxx
21 // Authors : Francis KLOSS (OCC) & Patrick LAUG (INRIA) & Lioka RAZAFINDRAZAKA (CEA)
22 // Module : BLSURFPlugin
25 #include "BLSURFPluginGUI_HypothesisCreator.h"
27 #include <SMESHGUI_Utils.h>
28 #include <SMESHGUI_HypothesesUtils.h>
30 #include <SUIT_Session.h>
32 #include <SalomeApp_Tools.h>
34 #include <QtxDblSpinBox.h>
35 #include <QtxComboBox.h>
38 #include <qgroupbox.h>
41 #include <qlineedit.h>
42 #include <qcheckbox.h>
44 #include <qfontmetrics.h>
47 #include <qpushbutton.h>
49 #include <qpopupmenu.h>
51 #include <qapplication.h>
54 #include <SUIT_MessageBox.h>
56 #define WITH_SIZE_BOUNDARIES
86 BLSURFPluginGUI_HypothesisCreator::BLSURFPluginGUI_HypothesisCreator( const QString& theHypType )
87 : SMESHGUI_GenericHypothesisCreator( theHypType )
92 BLSURFPluginGUI_HypothesisCreator::~BLSURFPluginGUI_HypothesisCreator()
99 inline bool isDouble( const QString& theText, const bool emptyOK=false ) {
100 QString str = theText.stripWhiteSpace();
102 if ( !str.isEmpty() )
110 bool BLSURFPluginGUI_HypothesisCreator::checkParams() const
113 if ( !isDouble( myPhySize->text(), false )) {
114 if ( myPhySize->text().isEmpty() )
115 myPhySize->setText(tr("OBIGATORY_VALUE"));
116 myPhySize->selectAll();
119 if ( !isDouble( myPhyMin->text(), true )) {
120 myPhyMin->selectAll();
123 if ( !isDouble( myPhyMax->text(), true )) {
124 myPhyMax->selectAll();
127 if ( !isDouble( myGeoMin->text(), true )) {
128 myGeoMin->selectAll();
131 if ( !isDouble( myGeoMin->text(), true )) {
132 myGeoMin->selectAll();
137 myOptionTable->setFocus();
138 qApp->processEvents();
140 BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
141 BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( initParamsHypothesis() );
143 int row = 0, nbRows = myOptionTable->numRows();
144 for ( ; row < nbRows; ++row )
146 QString name = myOptionTable->text( row, OPTION_NAME_COLUMN );
147 QString value = myOptionTable->text( row, OPTION_VALUE_COLUMN ).stripWhiteSpace();
148 if ( !value.isEmpty() ) {
150 h->SetOptionValue( name.latin1(), value.latin1() );
152 catch ( const SALOME::SALOME_Exception& ex )
154 SUIT_MessageBox::error1( dlg(),
156 ex.details.text.in(),
162 h->SetOptionValues( myOptions ); // restore values
168 QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame()
170 QFrame* fr = new QFrame( 0, "myframe" );
171 QVBoxLayout* lay = new QVBoxLayout( fr, 5, 0 );
174 QTabBar* tab = new QTabBar( fr, "QTabBar");
175 tab->setShape( QTabBar::RoundedAbove );
176 tab->insertTab( new QTab( tr( "SMESH_ARGUMENTS")), STD_TAB);
177 tab->insertTab( new QTab( tr( "GHS3D_ADV_ARGS")), ADV_TAB);
178 lay->addWidget( tab );
182 myStdGroup = new QGroupBox( 2, Qt::Horizontal, fr, "myStdGroup" );
183 myStdGroup->layout()->setSpacing( 6 );
184 myStdGroup->layout()->setMargin( 11 );
185 lay->addWidget( myStdGroup );
189 new QLabel( tr( "SMESH_NAME" ), myStdGroup );
190 myName = new QLineEdit( myStdGroup );
193 new QLabel( tr( "BLSURF_PHY_MESH" ), myStdGroup );
194 myPhysicalMesh = new QtxComboBox( myStdGroup );
195 QStringList physicalTypes;
196 physicalTypes.append( QObject::tr( "BLSURF_DEFAULT_USER" ) );
197 physicalTypes.append( QObject::tr( "BLSURF_CUSTOM_USER" ) );
198 myPhysicalMesh->insertStringList( physicalTypes );
200 new QLabel( tr( "BLSURF_HPHYDEF" ), myStdGroup );
201 myPhySize = new QLineEdit( myStdGroup );
202 // myPhySize = new QtxDblSpinBox( myStdGroup );
203 // myPhySize->setMinValue( 1e-02 );
204 // myPhySize->setMaxValue( 1e+02 );
205 // myPhySize->setLineStep( 1 );
207 #ifdef WITH_SIZE_BOUNDARIES
208 new QLabel( tr( "BLSURF_HPHYMIN" ), myStdGroup );
209 myPhyMin = new QLineEdit( myStdGroup );
210 // myPhyMin = new QtxDblSpinBox( myStdGroup );
211 // myPhyMin->setMinValue( 1e-06 );
212 // myPhyMin->setMaxValue( 1e+04 );
213 // myPhyMin->setLineStep( 1 );
215 new QLabel( tr( "BLSURF_HPHYMAX" ), myStdGroup );
216 myPhyMax = new QLineEdit( myStdGroup );
217 // myPhyMax = new QtxDblSpinBox( myStdGroup );
218 // myPhyMax->setMinValue( 1e-04 );
219 // myPhyMax->setMaxValue( 1e+06 );
220 // myPhyMax->setLineStep( 1 );
223 new QLabel( tr( "BLSURF_GEOM_MESH" ), myStdGroup );
224 myGeometricMesh = new QtxComboBox( myStdGroup );
226 types.append( QObject::tr( "BLSURF_DEFAULT_GEOM" ) );
227 types.append( QObject::tr( "BLSURF_CUSTOM_GEOM" ) );
228 myGeometricMesh->insertStringList( types );
230 new QLabel( tr( "BLSURF_ANGLE_MESH_S" ), myStdGroup );
231 myAngleMeshS = new QtxDblSpinBox( myStdGroup );
232 myAngleMeshS->setMinValue( 0 );
233 myAngleMeshS->setMaxValue( 16 );
234 myAngleMeshS->setLineStep( 0.5 );
236 new QLabel( tr( "BLSURF_ANGLE_MESH_C" ), myStdGroup );
237 myAngleMeshC = new QtxDblSpinBox( myStdGroup );
238 myAngleMeshC->setMinValue( 0 );
239 myAngleMeshC->setMaxValue( 16 );
240 myAngleMeshC->setLineStep( 0.5 );
242 new QLabel( tr( "BLSURF_GRADATION" ), myStdGroup );
243 myGradation = new QtxDblSpinBox( myStdGroup );
244 myGradation->setMinValue( 1.1 );
245 myGradation->setMaxValue( 2.5 );
246 myGradation->setLineStep( 0.1 );
248 #ifdef WITH_SIZE_BOUNDARIES
249 new QLabel( tr( "BLSURF_HGEOMIN" ), myStdGroup );
250 myGeoMin = new QLineEdit( myStdGroup );
251 // myGeoMin = new QtxDblSpinBox( myStdGroup );
252 // myGeoMin->setMinValue( 1e-06 );
253 // myGeoMin->setMaxValue( 1e+04 );
254 // myGeoMin->setLineStep( 1 );
256 new QLabel( tr( "BLSURF_HGEOMAX" ), myStdGroup );
257 myGeoMax = new QLineEdit( myStdGroup );
258 // myGeoMax = new QtxDblSpinBox( myStdGroup );
259 // myGeoMax->setMinValue( 1e-04 );
260 // myGeoMax->setMaxValue( 1e+06 );
261 // myGeoMax->setLineStep( 1 );
264 myAllowQuadrangles = new QCheckBox( tr( "BLSURF_ALLOW_QUADRANGLES" ), myStdGroup );
265 myStdGroup->addSpace(0);
267 myDecimesh = new QCheckBox( tr( "BLSURF_DECIMESH" ), myStdGroup );
268 myStdGroup->addSpace(0);
272 // advanced parameters
274 myAdvGroup = new QGroupBox( 3, Qt::Horizontal, fr, "myAdvGroup" );
275 lay->addWidget( myAdvGroup );
276 QFrame* anAdvFrame = new QFrame(myAdvGroup, "anAdvFrame");
277 QGridLayout* anAdvLayout = new QGridLayout(anAdvFrame, 5, 3);
278 anAdvLayout->setSpacing(6);
279 anAdvLayout->setAutoAdd(false);
281 QLabel* aTopologyLabel = new QLabel( tr( "BLSURF_TOPOLOGY" ), anAdvFrame );
282 myTopology = new QtxComboBox( anAdvFrame );
283 QStringList topologyTypes;
284 topologyTypes.append( QObject::tr( "BLSURF_TOPOLOGY_CAD" ) );
285 topologyTypes.append( QObject::tr( "BLSURF_TOPOLOGY_PROCESS" ) );
286 topologyTypes.append( QObject::tr( "BLSURF_TOPOLOGY_PROCESS2" ) );
287 myTopology->insertStringList( topologyTypes );
289 QLabel* aVarbosityLabel = new QLabel( tr( "BLSURF_VERBOSITY" ), anAdvFrame );
290 myVerbosity = new QSpinBox( anAdvFrame );
291 myVerbosity->setMinValue( 0 );
292 myVerbosity->setMaxValue( 100 );
293 myVerbosity->setLineStep( 5 );
295 QButton* addBtn = new QPushButton(tr("ADD_OPTION"), anAdvFrame, "addBtn");
296 QButton* rmBtn = new QPushButton(tr("REMOVE_OPTION"), anAdvFrame, "rmBtn");
298 myOptionTable = new QTable( 0, NB_COLUMNS, anAdvFrame, "myOptionTable");
299 myOptionTable->hideColumn( OPTION_ID_COLUMN );
300 myOptionTable->horizontalHeader()->setLabel( OPTION_NAME_COLUMN, tr("OPTION_NAME_COLUMN"));
301 myOptionTable->horizontalHeader()->setLabel( OPTION_VALUE_COLUMN, tr("OPTION_VALUE_COLUMN"));
302 myOptionTable->setColumnReadOnly( OPTION_NAME_COLUMN, TRUE );
303 myOptionTable->setColumnReadOnly( OPTION_VALUE_COLUMN, FALSE );
304 myOptionTable->setLeftMargin( 0 );
306 anAdvLayout->addWidget(aTopologyLabel, 0, 0);
307 anAdvLayout->addWidget(myTopology, 0, 1);
309 anAdvLayout->addWidget(aVarbosityLabel, 1, 0);
310 anAdvLayout->addWidget(myVerbosity, 1, 1);
312 anAdvLayout->addMultiCellWidget( myOptionTable, 2,4, 0,1 );
313 anAdvLayout->addWidget( addBtn, 2, 2);
314 anAdvLayout->addWidget( rmBtn, 3, 2);
316 anAdvLayout->setRowStretch( 4, 1 );
317 anAdvLayout->setColStretch( 9, 1 );
319 onTabSelected( STD_TAB );
321 connect( tab, SIGNAL( selected ( int ) ), this, SLOT( onTabSelected(int) ));
322 connect( myGeometricMesh, SIGNAL( activated( int ) ), this, SLOT( onGeometricMeshChanged() ));
323 connect( myPhysicalMesh, SIGNAL( activated( int ) ), this, SLOT( onPhysicalMeshChanged() ));
324 connect( addBtn, SIGNAL( clicked()), this, SLOT( onAddOption() ));
325 connect( rmBtn, SIGNAL( clicked()), this, SLOT( onDeleteOption() ));
330 void BLSURFPluginGUI_HypothesisCreator::retrieveParams() const
332 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
334 BlsurfHypothesisData data;
335 that->readParamsFromHypo( data );
338 myName->setText( data.myName );
339 QFontMetrics metrics( myName->font() );
340 myName->setMinimumWidth( metrics.width( data.myName )+5 );
342 myTopology ->setCurrentItem( data.myTopology );
343 myPhysicalMesh ->setCurrentItem( data.myPhysicalMesh );
344 //myPhySize ->setValue ( data.myPhySize );
345 myPhySize ->setText ( data.myPhySize );
346 #ifdef WITH_SIZE_BOUNDARIES
347 myPhyMin ->setText ( data.myPhyMin );
348 myPhyMax ->setText ( data.myPhyMax );
349 myGeoMin ->setText ( data.myGeoMin );
350 myGeoMax ->setText ( data.myGeoMax );
351 // myPhyMin ->setValue ( data.myPhyMin );
352 // myPhyMax ->setValue ( data.myPhyMax );
353 // myGeoMin ->setValue ( data.myGeoMin );
354 // myGeoMax ->setValue ( data.myGeoMax );
356 myGeometricMesh ->setCurrentItem( data.myGeometricMesh );
357 myAngleMeshS ->setValue ( data.myAngleMeshS);
358 myAngleMeshC ->setValue ( data.myAngleMeshC);
359 myGradation ->setValue ( data.myGradation);
360 myAllowQuadrangles->setChecked ( data.myAllowQuadrangles );
361 myDecimesh ->setChecked ( data.myDecimesh );
362 myVerbosity ->setValue ( data.myVerbosity);
364 if ( myOptions.operator->() ) {
365 for ( int i = 0, nb = myOptions->length(); i < nb; ++i ) {
366 QString option = that->myOptions[i].in();
367 QStringList name_value = QStringList::split( ":", option );
368 if ( name_value.size() > 1 ) {
369 QString idStr = QString("%1").arg( i );
370 int row = myOptionTable->numRows();
371 myOptionTable->insertRows( row );
372 myOptionTable->setText( row, OPTION_ID_COLUMN, idStr);
373 myOptionTable->setText( row, OPTION_NAME_COLUMN, name_value[0]);
374 myOptionTable->setText( row, OPTION_VALUE_COLUMN, name_value[1] );
378 myOptionTable->adjustColumn( OPTION_NAME_COLUMN );
381 that->onPhysicalMeshChanged();
382 that->onGeometricMeshChanged();
385 QString BLSURFPluginGUI_HypothesisCreator::storeParams() const
387 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
389 BlsurfHypothesisData data;
390 QString guiHyp = that->readParamsFromWidgets( data );
391 that->storeParamsToHypo( data );
396 bool BLSURFPluginGUI_HypothesisCreator::readParamsFromHypo( BlsurfHypothesisData& h_data ) const
398 BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
399 BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( initParamsHypothesis() );
401 HypothesisData* data = SMESH::GetHypothesisData( hypType() );
402 h_data.myName = isCreation() && data ? hypName() : "";
404 h_data.myTopology = (int) h->GetTopology();
405 h_data.myPhysicalMesh = (int) h->GetPhysicalMesh();
406 h_data.myPhySize = QString::number( h->GetPhySize() );
407 // h_data.myPhySize = h->GetPhySize();
408 h_data.myGeometricMesh = (int) h->GetGeometricMesh();
409 h_data.myAngleMeshS = h->GetAngleMeshS();
410 h_data.myAngleMeshC = h->GetAngleMeshC();
411 h_data.myGradation = h->GetGradation();
412 h_data.myAllowQuadrangles = h->GetQuadAllowed();
413 h_data.myDecimesh = h->GetDecimesh();
414 h_data.myVerbosity = h->GetVerbosity();
416 #ifdef WITH_SIZE_BOUNDARIES
417 double PhyMin = h->GetPhyMin();
418 double PhyMax = h->GetPhyMax();
419 double GeoMin = h->GetGeoMin();
420 double GeoMax = h->GetGeoMax();
422 h_data.myPhyMin = PhyMin > 0 ? QString::number( h->GetPhyMin() ) : QString("");
423 h_data.myPhyMax = PhyMax > 0 ? QString::number( h->GetPhyMax() ) : QString("");
424 h_data.myGeoMin = GeoMin > 0 ? QString::number( h->GetGeoMin() ) : QString("");
425 h_data.myGeoMax = GeoMax > 0 ? QString::number( h->GetGeoMax() ) : QString("");
426 // h_data.myPhyMin = h->GetPhyMin();
427 // h_data.myPhyMax = h->GetPhyMax();
428 // h_data.myGeoMin = h->GetGeoMin();
429 // h_data.myGeoMax = h->GetGeoMax();
432 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
433 that->myOptions = h->GetOptionValues();
438 bool BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo( const BlsurfHypothesisData& h_data ) const
440 BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
441 BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( hypothesis() );
447 SMESH::SetName( SMESH::FindSObject( h ), h_data.myName.latin1() );
449 if ( h->GetTopology() != h_data.myTopology ) // avoid duplication of DumpPython commands
450 h->SetTopology( (int) h_data.myTopology );
451 if ( h->GetPhysicalMesh() != h_data.myPhysicalMesh )
452 h->SetPhysicalMesh( (int) h_data.myPhysicalMesh );
453 if ( h->GetGeometricMesh() != (int) h_data.myGeometricMesh )
454 h->SetGeometricMesh( (int) h_data.myGeometricMesh );
455 if ( h->GetGradation() != h_data.myGradation )
456 h->SetGradation( h_data.myGradation );
457 if ( h->GetQuadAllowed() != h_data.myAllowQuadrangles )
458 h->SetQuadAllowed( h_data.myAllowQuadrangles );
459 if ( h->GetDecimesh() != h_data.myDecimesh )
460 h->SetDecimesh( h_data.myDecimesh );
461 if ( h->GetVerbosity() != h_data.myVerbosity )
462 h->SetVerbosity( h_data.myVerbosity );
464 if( (int) h_data.myPhysicalMesh == PhysicalUserDefined ) {
465 if ( h->GetPhySize() != h_data.myPhySize.toDouble() )
466 h->SetPhySize( h_data.myPhySize.toDouble() );
468 if( (int) h_data.myGeometricMesh == UserDefined ) {
469 if ( h->GetAngleMeshS() != h_data.myAngleMeshS )
470 h->SetAngleMeshS( h_data.myAngleMeshS );
471 if ( h->GetAngleMeshC() != h_data.myAngleMeshC )
472 h->SetAngleMeshC( h_data.myAngleMeshC );
474 #ifdef WITH_SIZE_BOUNDARIES
475 if ( !isDouble( h_data.myPhyMin ))
477 else if ( h->GetPhyMin() != h_data.myPhyMin.toDouble() )
478 h->SetPhyMin( h_data.myPhyMin.toDouble() );
479 if ( !isDouble( h_data.myPhyMax ))
481 else if ( h->GetPhyMax() != h_data.myPhyMax.toDouble() )
482 h->SetPhyMax( h_data.myPhyMax.toDouble() );
483 if ( !isDouble( h_data.myGeoMin ))
485 else if ( h->GetGeoMin() != h_data.myGeoMin.toDouble() )
486 h->SetGeoMin( h_data.myGeoMin.toDouble() );
487 if ( !isDouble( h_data.myGeoMax ))
489 else if ( h->GetGeoMax() != h_data.myGeoMax.toDouble() )
490 h->SetGeoMax( h_data.myGeoMax.toDouble() );
491 // if ( h->GetPhyMin() != h_data.myPhyMin )
492 // h->SetPhyMin( h_data.myPhyMin );
493 // if ( h->GetPhyMax() != h_data.myPhyMax )
494 // h->SetPhyMax( h_data.myPhyMax );
495 // if ( h->GetGeoMin() != h_data.myGeoMin )
496 // h->SetGeoMin( h_data.myGeoMin );
497 // if ( h->GetGeoMax() != h_data.myGeoMax )
498 // h->SetGeoMax( h_data.myGeoMax );
501 h->SetOptionValues( myOptions ); // is set in checkParams()
503 catch(const SALOME::SALOME_Exception& ex)
505 SalomeApp_Tools::QtCatchCorbaException(ex);
511 QString BLSURFPluginGUI_HypothesisCreator::readParamsFromWidgets( BlsurfHypothesisData& h_data ) const
513 h_data.myName = myName ? myName->text() : "";
514 h_data.myTopology = myTopology->currentItem();
515 h_data.myPhysicalMesh = myPhysicalMesh->currentItem();
516 h_data.myPhySize = myPhySize->text();
517 // h_data.myPhySize = myPhySize->value();
518 #ifdef WITH_SIZE_BOUNDARIES
519 h_data.myPhyMin = myPhyMin->text();
520 h_data.myPhyMax = myPhyMax->text();
521 h_data.myGeoMin = myGeoMin->text();
522 h_data.myGeoMax = myGeoMax->text();
523 // h_data.myPhyMin = myPhyMin->value();
524 // h_data.myPhyMax = myPhyMax->value();
525 // h_data.myGeoMin = myGeoMin->value();
526 // h_data.myGeoMax = myGeoMax->value();
528 h_data.myGeometricMesh = myGeometricMesh->currentItem();
529 h_data.myAngleMeshS = myAngleMeshS->value();
530 h_data.myAngleMeshC = myAngleMeshC->value();
531 h_data.myGradation = myGradation->value();
532 h_data.myAllowQuadrangles = myAllowQuadrangles->isChecked();
533 h_data.myDecimesh = myDecimesh->isChecked();
534 h_data.myVerbosity = myVerbosity->value();
537 guiHyp += tr("BLSURF_TOPOLOGY") + " = " + QString::number( h_data.myTopology ) + "; ";
538 guiHyp += tr("BLSURF_PHY_MESH") + " = " + QString::number( h_data.myPhysicalMesh ) + "; ";
539 guiHyp += tr("BLSURF_HPHYDEF") + " = " + h_data.myPhySize + "; ";
540 guiHyp += tr("BLSURF_GEOM_MESH") + " = " + QString::number( h_data.myGeometricMesh ) + "; ";
541 guiHyp += tr("BLSURF_ANGLE_MESH_S") + " = " + QString::number( h_data.myAngleMeshS ) + "; ";
542 guiHyp += tr("BLSURF_GRADATION") + " = " + QString::number( h_data.myGradation ) + "; ";
543 guiHyp += tr("BLSURF_ALLOW_QUADRANGLES") + " = " + QString(h_data.myAllowQuadrangles ? "yes" : "no") + "; ";
544 guiHyp += tr("BLSURF_DECIMESH") + " = " + QString(h_data.myDecimesh ? "yes" : "no") + "; ";
545 #ifdef WITH_SIZE_BOUNDARIES
546 if ( isDouble( h_data.myPhyMin )) guiHyp += "hphymin = " + h_data.myPhyMin + "; ";
547 if ( isDouble( h_data.myPhyMax )) guiHyp += "hphymax = " + h_data.myPhyMax + "; ";
548 if ( isDouble( h_data.myGeoMin )) guiHyp += "hgeomin = " + h_data.myGeoMin + "; ";
549 if ( isDouble( h_data.myGeoMax )) guiHyp += "hgeomax = " + h_data.myGeoMax + "; ";
552 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
553 int row = 0, nbRows = myOptionTable->numRows();
554 for ( ; row < nbRows; ++row )
556 int id = myOptionTable->text( row, OPTION_ID_COLUMN ).toInt();
557 if ( id >= 0 && id < myOptions->length() )
559 QString name = myOptionTable->text( row, OPTION_NAME_COLUMN );
560 QString value = myOptionTable->text( row, OPTION_VALUE_COLUMN ).stripWhiteSpace();
563 that->myOptions[ id ] = ( name + ":" + value).latin1();
565 guiHyp += name + " = " + value + "; ";
569 cout << "guiHyp : " << guiHyp << endl;
574 void BLSURFPluginGUI_HypothesisCreator::onPhysicalMeshChanged() {
575 bool isCustom = (myPhysicalMesh->currentItem() == PhysicalUserDefined);
576 myPhySize->setEnabled(isCustom);
577 myPhyMax->setEnabled(isCustom);
578 myPhyMin->setEnabled(isCustom);
581 QString aPhySize = "";
583 switch( myPhysicalMesh->currentItem() ) {
590 myPhySize->setText( aPhySize );
591 // myPhySize->setValue( aPhySize );
592 if ( !isDouble( myPhyMin->text(), true ))
593 myPhyMin->setText("");
594 if ( !isDouble( myPhyMax->text(), true ))
595 myPhyMax->setText("");
596 // hphy_flag = 0 and hgeo_flag = 0 is not allowed (spec)
597 if ( myGeometricMesh->currentItem() == DefaultGeom ) {
598 myGeometricMesh->setCurrentItem( UserDefined );
599 onGeometricMeshChanged();
604 void BLSURFPluginGUI_HypothesisCreator::onGeometricMeshChanged() {
605 bool isCustom = (myGeometricMesh->currentItem() == UserDefined);
606 myAngleMeshS->setEnabled(isCustom);
607 myAngleMeshC->setEnabled(isCustom);
608 myGradation->setEnabled(isCustom);
609 myGeoMax->setEnabled(isCustom);
610 myGeoMin->setEnabled(isCustom);
613 double aAngleMeshS, aGradation;
614 switch( myGeometricMesh->currentItem() ) {
621 myAngleMeshS->setValue( aAngleMeshS );
622 myAngleMeshC->setValue( aAngleMeshS );
623 myGradation->setValue( aGradation );
624 if ( !isDouble( myGeoMin->text(), true ))
625 myGeoMin->setText("");
626 if ( !isDouble( myGeoMax->text(), true ))
627 myGeoMax->setText("");
628 // hphy_flag = 0 and hgeo_flag = 0 is not allowed (spec)
629 if ( myPhysicalMesh->currentItem() == DefaultSize ) {
630 myPhysicalMesh->setCurrentItem( PhysicalUserDefined );
631 onPhysicalMeshChanged();
636 void BLSURFPluginGUI_HypothesisCreator::onTabSelected(int tab)
638 if ( tab == STD_TAB ) {
646 qApp->processEvents();
650 void BLSURFPluginGUI_HypothesisCreator::onAddOption()
653 // fill popup with option names
654 myPopup = new QPopupMenu();
655 if ( myOptions.operator->() ) {
656 for ( int i = 0, nb = myOptions->length(); i < nb; ++i ) {
657 QString name_value = myOptions[i].in();
658 QString name = QStringList::split( ":", name_value )[0];
659 myPopup->insertItem( name, i );
662 connect( myPopup, SIGNAL( activated( int ) ), SLOT( onOptionChosenInPopup( int ) ) );
664 if ( myPopup && myPopup->text(0) )
665 myPopup->exec( QCursor::pos() );
668 void BLSURFPluginGUI_HypothesisCreator::onOptionChosenInPopup(int i)
670 myOptionTable->setFocus();
671 qApp->processEvents();
673 QString idStr = QString("%1").arg( i );
674 QString option = myOptions[i].in();
675 QString optionName = QStringList::split( ":", option )[0];
677 // look for a row with optionName
678 int row = 0, nbRows = myOptionTable->numRows();
679 for ( ; row < nbRows; ++row )
680 if ( myOptionTable->text( row, OPTION_ID_COLUMN ) == idStr )
682 // add a row if not found
684 myOptionTable->insertRows( nbRows );
686 myOptionTable->setText( row, OPTION_ID_COLUMN, idStr);
687 myOptionTable->setText( row, OPTION_NAME_COLUMN, optionName);
688 myOptionTable->editCell( row, OPTION_VALUE_COLUMN );
689 myOptionTable->adjustColumn( OPTION_NAME_COLUMN );
692 void BLSURFPluginGUI_HypothesisCreator::onDeleteOption()
694 // clear option values and remember selected row
695 std::set<int> selectedRows;
696 int row = 0, nbRows = myOptionTable->numRows();
697 for ( ; row < nbRows; ++row ) {
698 if ( myOptionTable->isRowSelected( row )) {
699 selectedRows.insert( row );
700 int id = myOptionTable->text( row, OPTION_ID_COLUMN ).toInt();
701 if ( id >= 0 && id < myOptions->length() )
702 myOptions[ id ] = myOptionTable->text( row, OPTION_NAME_COLUMN );
705 // remove selected rows
706 std::set<int>::reverse_iterator r = selectedRows.rbegin();
707 for ( ; r != selectedRows.rend(); ++r )
708 myOptionTable->removeRow ( *r );
712 QString BLSURFPluginGUI_HypothesisCreator::caption() const
714 return tr( "BLSURF_TITLE" );
717 QPixmap BLSURFPluginGUI_HypothesisCreator::icon() const
719 QString hypIconName = tr( "ICON_DLG_BLSURF_PARAMETERS");
720 return SUIT_Session::session()->resourceMgr()->loadPixmap( "BLSURFPlugin", hypIconName );
723 QString BLSURFPluginGUI_HypothesisCreator::type() const
725 return tr( "BLSURF_HYPOTHESIS" );
728 QString BLSURFPluginGUI_HypothesisCreator::helpPage() const
730 return "blsurf_hypo_page.html";