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
20 // File : BLSURFPluginGUI_HypothesisCreator.cxx
21 // Authors : Francis KLOSS (OCC) & Patrick LAUG (INRIA) & Lioka RAZAFINDRAZAKA (CEA)
22 // & Aurelien ALLEAUME (DISTENE)
25 #include "BLSURFPluginGUI_HypothesisCreator.h"
27 #include <SMESHGUI_Utils.h>
28 #include <SMESHGUI_HypothesesUtils.h>
30 #include <SUIT_Session.h>
31 #include <SUIT_MessageBox.h>
32 #include <SUIT_ResourceMgr.h>
33 #include <SalomeApp_Tools.h>
34 #include <QtxDoubleSpinBox.h>
40 #include <QVBoxLayout>
41 #include <QGridLayout>
46 #include <QPushButton>
48 #include <QTableWidget>
49 #include <QHeaderView>
50 #include <QApplication>
52 #define WITH_SIZE_BOUNDARIES
81 BLSURFPluginGUI_HypothesisCreator::BLSURFPluginGUI_HypothesisCreator( const QString& theHypType )
82 : SMESHGUI_GenericHypothesisCreator( theHypType )
86 BLSURFPluginGUI_HypothesisCreator::~BLSURFPluginGUI_HypothesisCreator()
91 inline bool isDouble( const QString& theText, const bool emptyOK=false ) {
92 QString str = theText.trimmed();
102 bool BLSURFPluginGUI_HypothesisCreator::checkParams() const
105 if ( !isDouble( myPhySize->text(), false )) {
106 if ( myPhySize->text().isEmpty() )
107 myPhySize->setText(tr("OBLIGATORY_VALUE"));
108 myPhySize->selectAll();
111 if ( !isDouble( myPhyMin->text(), true )) {
112 myPhyMin->selectAll();
115 if ( !isDouble( myPhyMax->text(), true )) {
116 myPhyMax->selectAll();
119 if ( !isDouble( myGeoMin->text(), true )) {
120 myGeoMin->selectAll();
123 if ( !isDouble( myGeoMin->text(), true )) {
124 myGeoMin->selectAll();
129 myOptionTable->setFocus();
130 QApplication::instance()->processEvents();
132 BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
133 BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( initParamsHypothesis() );
135 int row = 0, nbRows = myOptionTable->rowCount();
136 for ( ; row < nbRows; ++row )
138 QString name = myOptionTable->item( row, OPTION_NAME_COLUMN )->text();
139 QString value = myOptionTable->item( row, OPTION_VALUE_COLUMN )->text().trimmed();
140 if ( !value.isEmpty() ) {
142 h->SetOptionValue( name.toLatin1().constData(), value.toLatin1().constData() );
144 catch ( const SALOME::SALOME_Exception& ex )
146 SUIT_MessageBox::critical( dlg(),
148 ex.details.text.in() );
153 h->SetOptionValues( myOptions ); // restore values
159 QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame()
161 QFrame* fr = new QFrame( 0 );
162 QVBoxLayout* lay = new QVBoxLayout( fr );
164 lay->setSpacing( 0 );
167 QTabWidget* tab = new QTabWidget( fr );
168 tab->setTabShape( QTabWidget::Rounded );
169 tab->setTabPosition( QTabWidget::North );
170 lay->addWidget( tab );
173 myStdGroup = new QWidget();
174 QGridLayout* aStdLayout = new QGridLayout( myStdGroup );
175 aStdLayout->setSpacing( 6 );
176 aStdLayout->setMargin( 11 );
181 aStdLayout->addWidget( new QLabel( tr( "SMESH_NAME" ), myStdGroup ), row, 0, 1, 1 );
182 myName = new QLineEdit( myStdGroup );
183 aStdLayout->addWidget( myName, row++, 1, 1, 1 );
186 aStdLayout->addWidget( new QLabel( tr( "BLSURF_PHY_MESH" ), myStdGroup ), row, 0, 1, 1 );
187 myPhysicalMesh = new QComboBox( myStdGroup );
188 aStdLayout->addWidget( myPhysicalMesh, row++, 1, 1, 1 );
189 QStringList physicalTypes;
190 physicalTypes << tr( "BLSURF_DEFAULT_USER" ) << tr( "BLSURF_CUSTOM_USER" );
191 myPhysicalMesh->addItems( physicalTypes );
193 aStdLayout->addWidget( new QLabel( tr( "BLSURF_HPHYDEF" ), myStdGroup), row, 0, 1, 1 );
194 myPhySize = new QLineEdit( myStdGroup );
195 aStdLayout->addWidget( myPhySize, row++, 1, 1, 1 );
197 #ifdef WITH_SIZE_BOUNDARIES
198 aStdLayout->addWidget( new QLabel( tr( "BLSURF_HPHYMIN" ), myStdGroup ), row, 0, 1, 1 );
199 myPhyMin = new QLineEdit( myStdGroup );
200 aStdLayout->addWidget( myPhyMin, row++, 1, 1, 1 );
202 aStdLayout->addWidget( new QLabel( tr( "BLSURF_HPHYMAX" ), myStdGroup ), row, 0, 1, 1 );
203 myPhyMax = new QLineEdit( myStdGroup );
204 aStdLayout->addWidget( myPhyMax, row++, 1, 1, 1 );
207 aStdLayout->addWidget( new QLabel( tr( "BLSURF_GEOM_MESH" ), myStdGroup ), row, 0, 1, 1 );
208 myGeometricMesh = new QComboBox( myStdGroup );
209 aStdLayout->addWidget( myGeometricMesh, row++, 1, 1, 1 );
211 types << tr( "BLSURF_DEFAULT_GEOM" ) << tr( "BLSURF_CUSTOM_GEOM" );
212 myGeometricMesh->addItems( types );
214 aStdLayout->addWidget( new QLabel( tr( "BLSURF_ANGLE_MESH_S" ), myStdGroup ), row, 0, 1, 1 );
215 myAngleMeshS = new QtxDoubleSpinBox( myStdGroup );
216 aStdLayout->addWidget( myAngleMeshS, row++, 1, 1, 1 );
217 myAngleMeshS->setMinimum( 0 );
218 myAngleMeshS->setMaximum( 16 );
219 myAngleMeshS->setSingleStep( 0.5 );
221 aStdLayout->addWidget( new QLabel( tr( "BLSURF_ANGLE_MESH_C" ), myStdGroup ), row, 0, 1, 1 );
222 myAngleMeshC = new QtxDoubleSpinBox( myStdGroup );
223 aStdLayout->addWidget( myAngleMeshC, row++, 1, 1, 1 );
224 myAngleMeshC->setMinimum( 0 );
225 myAngleMeshC->setMaximum( 16 );
226 myAngleMeshC->setSingleStep( 0.5 );
228 aStdLayout->addWidget( new QLabel( tr( "BLSURF_GRADATION" ), myStdGroup ), row, 0, 1, 1 );
229 myGradation = new QtxDoubleSpinBox( myStdGroup );
230 aStdLayout->addWidget( myGradation, row++, 1, 1, 1 );
231 myGradation->setMinimum( 1.1 );
232 myGradation->setMaximum( 2.5 );
233 myGradation->setSingleStep( 0.1 );
235 #ifdef WITH_SIZE_BOUNDARIES
236 aStdLayout->addWidget( new QLabel( tr( "BLSURF_HGEOMIN" ), myStdGroup ), row, 0, 1, 1 );
237 myGeoMin = new QLineEdit( myStdGroup );
238 aStdLayout->addWidget( myGeoMin, row++, 1, 1, 1 );
240 aStdLayout->addWidget( new QLabel( tr( "BLSURF_HGEOMAX" ), myStdGroup ), row, 0, 1, 1 );
241 myGeoMax = new QLineEdit( myStdGroup );
242 aStdLayout->addWidget( myGeoMax, row++, 1, 1, 1 );
245 myAllowQuadrangles = new QCheckBox( tr( "BLSURF_ALLOW_QUADRANGLES" ), myStdGroup );
246 aStdLayout->addWidget( myAllowQuadrangles, row++, 0, 1, 2 );
248 myDecimesh = new QCheckBox( tr( "BLSURF_DECIMESH" ), myStdGroup );
249 aStdLayout->addWidget( myDecimesh, row++, 0, 1, 2 );
251 // advanced parameters
252 myAdvGroup = new QWidget();
253 QGridLayout* anAdvLayout = new QGridLayout( myAdvGroup );
254 anAdvLayout->setSpacing( 6 );
255 anAdvLayout->setMargin( 11 );
257 anAdvLayout->addWidget( new QLabel( tr( "BLSURF_TOPOLOGY" ), myAdvGroup ), 0, 0, 1, 1 );
258 myTopology = new QComboBox( myAdvGroup );
259 anAdvLayout->addWidget( myTopology, 0, 1, 1, 1 );
260 QStringList topologyTypes;
261 topologyTypes << tr( "BLSURF_TOPOLOGY_CAD" ) << tr( "BLSURF_TOPOLOGY_PROCESS" ) << tr( "BLSURF_TOPOLOGY_PROCESS2" );
262 myTopology->addItems( topologyTypes );
264 anAdvLayout->addWidget( new QLabel( tr( "BLSURF_VERBOSITY" ), myAdvGroup ), 1, 0, 1, 1 );
265 myVerbosity = new QSpinBox( myAdvGroup );
266 anAdvLayout->addWidget( myVerbosity, 1, 1, 1, 1 );
267 myVerbosity->setMinimum( 0 );
268 myVerbosity->setMaximum( 100 );
269 myVerbosity->setSingleStep( 5 );
271 myOptionTable = new QTableWidget( 0, NB_COLUMNS, myAdvGroup );
272 anAdvLayout->addWidget( myOptionTable, 2, 0, 3, 2 );
274 headers << tr( "OPTION_ID_COLUMN" ) << tr( "OPTION_NAME_COLUMN" ) << tr( "OPTION_VALUE_COLUMN" );
275 myOptionTable->setHorizontalHeaderLabels( headers );
276 myOptionTable->horizontalHeader()->hideSection( OPTION_ID_COLUMN );
277 //myOptionTable->setColumnReadOnly( OPTION_NAME_COLUMN, TRUE );//////
278 //myOptionTable->setColumnReadOnly( OPTION_VALUE_COLUMN, FALSE );/////
279 myOptionTable->verticalHeader()->hide();
280 //myOptionTable->setSelectionBehavior( QAbstractItemView::SelectRows );
282 QPushButton* addBtn = new QPushButton( tr( "ADD_OPTION"), myAdvGroup );
283 anAdvLayout->addWidget( addBtn, 2, 2, 1, 1 );
284 addBtn->setMenu( new QMenu() );
286 QPushButton* rmBtn = new QPushButton( tr( "REMOVE_OPTION"), myAdvGroup );
287 anAdvLayout->addWidget( rmBtn, 3, 2, 1, 1 );
289 anAdvLayout->setRowStretch( 4, 5 );
290 anAdvLayout->setColumnStretch( 1, 5 );
293 tab->insertTab( STD_TAB, myStdGroup, tr( "SMESH_ARGUMENTS" ) );
294 tab->insertTab( ADV_TAB, myAdvGroup, tr( "GHS3D_ADV_ARGS" ) );
295 tab->setCurrentIndex( STD_TAB );
298 connect( myGeometricMesh, SIGNAL( activated( int ) ), this, SLOT( onGeometricMeshChanged() ) );
299 connect( myPhysicalMesh, SIGNAL( activated( int ) ), this, SLOT( onPhysicalMeshChanged() ) );
300 connect( addBtn->menu(), SIGNAL( aboutToShow() ), this, SLOT( onAddOption() ) );
301 connect( addBtn->menu(), SIGNAL( triggered( QAction* ) ), this, SLOT( onOptionChosenInPopup( QAction* ) ) );
302 connect( rmBtn, SIGNAL( clicked()), this, SLOT( onDeleteOption() ) );
307 void BLSURFPluginGUI_HypothesisCreator::retrieveParams() const
309 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
311 BlsurfHypothesisData data;
312 that->readParamsFromHypo( data );
315 myName->setText( data.myName );
316 QFontMetrics metrics( myName->font() );
317 myName->setMinimumWidth( metrics.width( data.myName )+5 );
319 myTopology->setCurrentIndex( data.myTopology );
320 myPhysicalMesh->setCurrentIndex( data.myPhysicalMesh );
321 myPhySize->setText( data.myPhySize );
322 #ifdef WITH_SIZE_BOUNDARIES
323 myPhyMin->setText( data.myPhyMin );
324 myPhyMax->setText( data.myPhyMax );
325 myGeoMin->setText( data.myGeoMin );
326 myGeoMax->setText( data.myGeoMax );
328 myGeometricMesh->setCurrentIndex( data.myGeometricMesh );
329 myAngleMeshS->setValue( data.myAngleMeshS );
330 myAngleMeshC->setValue( data.myAngleMeshC );
331 myGradation->setValue( data.myGradation );
332 myAllowQuadrangles->setChecked( data.myAllowQuadrangles );
333 myDecimesh->setChecked( data.myDecimesh );
334 myVerbosity->setValue( data.myVerbosity );
336 if ( myOptions.operator->() ) {
337 printf("retrieveParams():myOptions->length()=%d\n",myOptions->length());
338 for ( int i = 0, nb = myOptions->length(); i < nb; ++i ) {
339 QString option = that->myOptions[i].in();
340 QStringList name_value = option.split( ":", QString::KeepEmptyParts );
341 if ( name_value.count() > 1 ) {
342 QString idStr = QString("%1").arg( i );
343 int row = myOptionTable->rowCount();
344 myOptionTable->setRowCount( row+1 );
345 myOptionTable->setItem( row, OPTION_ID_COLUMN, new QTableWidgetItem( idStr ) );
346 myOptionTable->item( row, OPTION_ID_COLUMN )->setFlags( 0 );
347 myOptionTable->setItem( row, OPTION_NAME_COLUMN, new QTableWidgetItem( name_value[0] ) );
348 myOptionTable->item( row, OPTION_NAME_COLUMN )->setFlags( 0 );
349 myOptionTable->setItem( row, OPTION_VALUE_COLUMN, new QTableWidgetItem( name_value[1] ) );
350 myOptionTable->item( row, OPTION_VALUE_COLUMN )->setFlags( Qt::ItemIsSelectable |
356 myOptionTable->resizeColumnToContents( OPTION_NAME_COLUMN );
359 that->onPhysicalMeshChanged();
360 that->onGeometricMeshChanged();
363 QString BLSURFPluginGUI_HypothesisCreator::storeParams() const
365 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
367 BlsurfHypothesisData data;
368 QString guiHyp = that->readParamsFromWidgets( data );
369 that->storeParamsToHypo( data );
374 bool BLSURFPluginGUI_HypothesisCreator::readParamsFromHypo( BlsurfHypothesisData& h_data ) const
376 BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
377 BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( initParamsHypothesis() );
379 HypothesisData* data = SMESH::GetHypothesisData( hypType() );
380 h_data.myName = isCreation() && data ? hypName() : "";
382 h_data.myTopology = (int) h->GetTopology();
383 h_data.myPhysicalMesh = (int) h->GetPhysicalMesh();
384 h_data.myPhySize = QString::number( h->GetPhySize() );
385 h_data.myGeometricMesh = (int) h->GetGeometricMesh();
386 h_data.myAngleMeshS = h->GetAngleMeshS();
387 h_data.myAngleMeshC = h->GetAngleMeshC();
388 h_data.myGradation = h->GetGradation();
389 h_data.myAllowQuadrangles = h->GetQuadAllowed();
390 h_data.myDecimesh = h->GetDecimesh();
391 h_data.myVerbosity = h->GetVerbosity();
393 #ifdef WITH_SIZE_BOUNDARIES
394 double PhyMin = h->GetPhyMin();
395 double PhyMax = h->GetPhyMax();
396 double GeoMin = h->GetGeoMin();
397 double GeoMax = h->GetGeoMax();
399 h_data.myPhyMin = PhyMin > 0 ? QString::number( h->GetPhyMin() ) : QString("");
400 h_data.myPhyMax = PhyMax > 0 ? QString::number( h->GetPhyMax() ) : QString("");
401 h_data.myGeoMin = GeoMin > 0 ? QString::number( h->GetGeoMin() ) : QString("");
402 h_data.myGeoMax = GeoMax > 0 ? QString::number( h->GetGeoMax() ) : QString("");
405 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
406 that->myOptions = h->GetOptionValues();
411 bool BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo( const BlsurfHypothesisData& h_data ) const
413 BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
414 BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( hypothesis() );
420 SMESH::SetName( SMESH::FindSObject( h ), h_data.myName.toLatin1().constData() );
422 if ( h->GetTopology() != h_data.myTopology ) // avoid duplication of DumpPython commands
423 h->SetTopology( (int) h_data.myTopology );
424 if ( h->GetPhysicalMesh() != h_data.myPhysicalMesh )
425 h->SetPhysicalMesh( (int) h_data.myPhysicalMesh );
426 if ( h->GetGeometricMesh() != (int) h_data.myGeometricMesh )
427 h->SetGeometricMesh( (int) h_data.myGeometricMesh );
428 if ( h->GetGradation() != h_data.myGradation )
429 h->SetGradation( h_data.myGradation );
430 if ( h->GetQuadAllowed() != h_data.myAllowQuadrangles )
431 h->SetQuadAllowed( h_data.myAllowQuadrangles );
432 if ( h->GetDecimesh() != h_data.myDecimesh )
433 h->SetDecimesh( h_data.myDecimesh );
434 if ( h->GetVerbosity() != h_data.myVerbosity )
435 h->SetVerbosity( h_data.myVerbosity );
437 if( (int) h_data.myPhysicalMesh == PhysicalUserDefined ) {
438 if ( h->GetPhySize() != h_data.myPhySize.toDouble() )
439 h->SetPhySize( h_data.myPhySize.toDouble() );
441 if( (int) h_data.myGeometricMesh == UserDefined ) {
442 if ( h->GetAngleMeshS() != h_data.myAngleMeshS )
443 h->SetAngleMeshS( h_data.myAngleMeshS );
444 if ( h->GetAngleMeshC() != h_data.myAngleMeshC )
445 h->SetAngleMeshC( h_data.myAngleMeshC );
447 #ifdef WITH_SIZE_BOUNDARIES
448 if ( !isDouble( h_data.myPhyMin ))
450 else if ( h->GetPhyMin() != h_data.myPhyMin.toDouble() )
451 h->SetPhyMin( h_data.myPhyMin.toDouble() );
452 if ( !isDouble( h_data.myPhyMax ))
454 else if ( h->GetPhyMax() != h_data.myPhyMax.toDouble() )
455 h->SetPhyMax( h_data.myPhyMax.toDouble() );
456 if ( !isDouble( h_data.myGeoMin ))
458 else if ( h->GetGeoMin() != h_data.myGeoMin.toDouble() )
459 h->SetGeoMin( h_data.myGeoMin.toDouble() );
460 if ( !isDouble( h_data.myGeoMax ))
462 else if ( h->GetGeoMax() != h_data.myGeoMax.toDouble() )
463 h->SetGeoMax( h_data.myGeoMax.toDouble() );
466 printf("storeParamsToHypo():myOptions->length()=%d\n",myOptions->length());
467 h->SetOptionValues( myOptions ); // is set in checkParams()
469 catch(const SALOME::SALOME_Exception& ex)
471 SalomeApp_Tools::QtCatchCorbaException(ex);
477 QString BLSURFPluginGUI_HypothesisCreator::readParamsFromWidgets( BlsurfHypothesisData& h_data ) const
479 h_data.myName = myName ? myName->text() : "";
480 h_data.myTopology = myTopology->currentIndex();
481 h_data.myPhysicalMesh = myPhysicalMesh->currentIndex();
482 h_data.myPhySize = myPhySize->text();
483 #ifdef WITH_SIZE_BOUNDARIES
484 h_data.myPhyMin = myPhyMin->text();
485 h_data.myPhyMax = myPhyMax->text();
486 h_data.myGeoMin = myGeoMin->text();
487 h_data.myGeoMax = myGeoMax->text();
489 h_data.myGeometricMesh = myGeometricMesh->currentIndex();
490 h_data.myAngleMeshS = myAngleMeshS->value();
491 h_data.myAngleMeshC = myAngleMeshC->value();
492 h_data.myGradation = myGradation->value();
493 h_data.myAllowQuadrangles = myAllowQuadrangles->isChecked();
494 h_data.myDecimesh = myDecimesh->isChecked();
495 h_data.myVerbosity = myVerbosity->value();
498 guiHyp += tr("BLSURF_TOPOLOGY") + " = " + QString::number( h_data.myTopology ) + "; ";
499 guiHyp += tr("BLSURF_PHY_MESH") + " = " + QString::number( h_data.myPhysicalMesh ) + "; ";
500 guiHyp += tr("BLSURF_HPHYDEF") + " = " + h_data.myPhySize + "; ";
501 guiHyp += tr("BLSURF_GEOM_MESH") + " = " + QString::number( h_data.myGeometricMesh ) + "; ";
502 guiHyp += tr("BLSURF_ANGLE_MESH_S") + " = " + QString::number( h_data.myAngleMeshS ) + "; ";
503 guiHyp += tr("BLSURF_GRADATION") + " = " + QString::number( h_data.myGradation ) + "; ";
504 guiHyp += tr("BLSURF_ALLOW_QUADRANGLES") + " = " + QString(h_data.myAllowQuadrangles ? "yes" : "no") + "; ";
505 guiHyp += tr("BLSURF_DECIMESH") + " = " + QString(h_data.myDecimesh ? "yes" : "no") + "; ";
506 #ifdef WITH_SIZE_BOUNDARIES
507 if ( isDouble( h_data.myPhyMin )) guiHyp += "hphymin = " + h_data.myPhyMin + "; ";
508 if ( isDouble( h_data.myPhyMax )) guiHyp += "hphymax = " + h_data.myPhyMax + "; ";
509 if ( isDouble( h_data.myGeoMin )) guiHyp += "hgeomin = " + h_data.myGeoMin + "; ";
510 if ( isDouble( h_data.myGeoMax )) guiHyp += "hgeomax = " + h_data.myGeoMax + "; ";
513 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
514 int row = 0, nbRows = myOptionTable->rowCount();
515 for ( ; row < nbRows; ++row )
517 int id = myOptionTable->item( row, OPTION_ID_COLUMN )->text().toInt();
518 if ( id >= 0 && id < myOptions->length() )
520 QString name = myOptionTable->item( row, OPTION_NAME_COLUMN )->text();
521 QString value = myOptionTable->item( row, OPTION_VALUE_COLUMN )->text().trimmed();
522 if ( value.isNull() )
524 that->myOptions[ id ] = ( name + ":" + value).toLatin1().constData();
526 guiHyp += name + " = " + value + "; ";
530 cout << "guiHyp : " << guiHyp.toLatin1().data() << endl;
535 void BLSURFPluginGUI_HypothesisCreator::onPhysicalMeshChanged() {
536 bool isCustom = (myPhysicalMesh->currentIndex() == PhysicalUserDefined);
537 myPhySize->setEnabled(isCustom);
538 myPhyMax->setEnabled(isCustom);
539 myPhyMin->setEnabled(isCustom);
542 QString aPhySize = "";
543 switch( myPhysicalMesh->currentIndex() ) {
549 myPhySize->setText( aPhySize );
550 if ( !isDouble( myPhyMin->text(), true ))
551 myPhyMin->setText("");
552 if ( !isDouble( myPhyMax->text(), true ))
553 myPhyMax->setText("");
554 if ( myGeometricMesh->currentIndex() == DefaultGeom ) {
555 myGeometricMesh->setCurrentIndex( UserDefined );
556 onGeometricMeshChanged();
561 void BLSURFPluginGUI_HypothesisCreator::onGeometricMeshChanged() {
562 bool isCustom = (myGeometricMesh->currentIndex() == UserDefined);
563 myAngleMeshS->setEnabled(isCustom);
564 myAngleMeshC->setEnabled(isCustom);
565 myGradation->setEnabled(isCustom);
566 myGeoMax->setEnabled(isCustom);
567 myGeoMin->setEnabled(isCustom);
570 double aAngleMeshS, aGradation;
571 switch( myGeometricMesh->currentIndex() ) {
578 myAngleMeshS->setValue( aAngleMeshS );
579 myAngleMeshC->setValue( aAngleMeshS );
580 myGradation->setValue( aGradation );
581 if ( !isDouble( myGeoMin->text(), true ))
582 myGeoMin->setText("");
583 if ( !isDouble( myGeoMax->text(), true ))
584 myGeoMax->setText("");
585 // hphy_flag = 0 and hgeo_flag = 0 is not allowed (spec)
586 if ( myPhysicalMesh->currentIndex() == DefaultSize ) {
587 myPhysicalMesh->setCurrentIndex( PhysicalUserDefined );
588 onPhysicalMeshChanged();
593 void BLSURFPluginGUI_HypothesisCreator::onAddOption()
595 QMenu* menu = (QMenu*)sender();
596 // fill popup with option names
598 if ( myOptions.operator->() ) {
599 for ( int i = 0, nb = myOptions->length(); i < nb; ++i ) {
600 QString name_value = myOptions[i].in();
601 QString name = name_value.split( ":", QString::KeepEmptyParts )[0];
602 menu->addAction( name );
607 void BLSURFPluginGUI_HypothesisCreator::onOptionChosenInPopup( QAction* a )
609 myOptionTable->setFocus();
610 QMenu* menu = (QMenu*)( a->parent() );
612 int idx = menu->actions().indexOf( a );
613 QString idStr = QString("%1").arg( idx );
614 QString option = myOptions[idx].in();
615 QString optionName = option.split( ":", QString::KeepEmptyParts )[0];
617 // look for a row with optionName
618 int row = 0, nbRows = myOptionTable->rowCount();
619 for ( ; row < nbRows; ++row )
620 if ( myOptionTable->item( row, OPTION_ID_COLUMN )->text() == idStr )
622 // add a row if not found
623 if ( row == nbRows ) {
624 myOptionTable->setRowCount( row+1 );
625 myOptionTable->setItem( row, OPTION_ID_COLUMN, new QTableWidgetItem( idStr ) );
626 myOptionTable->item( row, OPTION_ID_COLUMN )->setFlags( 0 );
627 myOptionTable->setItem( row, OPTION_NAME_COLUMN, new QTableWidgetItem( optionName ) );
628 myOptionTable->item( row, OPTION_NAME_COLUMN )->setFlags( 0 );
629 myOptionTable->setItem( row, OPTION_VALUE_COLUMN, new QTableWidgetItem( "" ) );
630 myOptionTable->item( row, OPTION_VALUE_COLUMN )->setFlags( Qt::ItemIsSelectable |
633 myOptionTable->resizeColumnToContents( OPTION_NAME_COLUMN );
635 myOptionTable->clearSelection();
636 myOptionTable->scrollToItem( myOptionTable->item( row, OPTION_VALUE_COLUMN ) );
637 //myOptionTable->item( row, OPTION_VALUE_COLUMN )->setSelected( true );
638 myOptionTable->setCurrentCell( row, OPTION_VALUE_COLUMN );
639 //myOptionTable->openPersistentEditor( myOptionTable->item( row, OPTION_VALUE_COLUMN ) );
642 void BLSURFPluginGUI_HypothesisCreator::onDeleteOption()
644 // clear option values and remember selected row
645 QList<int> selectedRows;
646 QList<QTableWidgetItem*> selected = myOptionTable->selectedItems();
647 QTableWidgetItem* item;
648 foreach( item, selected ) {
649 int row = item->row();
650 if ( !selectedRows.contains( row ) ) {
651 selectedRows.append( row );
652 int id = myOptionTable->item( row, OPTION_ID_COLUMN )->text().toInt();
653 if ( id >= 0 && id < myOptions->length() )
654 myOptions[ id ] = myOptionTable->item( row, OPTION_NAME_COLUMN )->text().toLatin1().constData();
657 qSort( selectedRows );
658 QListIterator<int> it( selectedRows );
660 while ( it.hasPrevious() )
661 myOptionTable->removeRow( it.previous() );
665 QString BLSURFPluginGUI_HypothesisCreator::caption() const
667 return tr( "BLSURF_TITLE" );
670 QPixmap BLSURFPluginGUI_HypothesisCreator::icon() const
672 return SUIT_Session::session()->resourceMgr()->loadPixmap( "BLSURFPlugin", tr( "ICON_DLG_BLSURF_PARAMETERS") );
675 QString BLSURFPluginGUI_HypothesisCreator::type() const
677 return tr( "BLSURF_HYPOTHESIS" );
680 QString BLSURFPluginGUI_HypothesisCreator::helpPage() const
682 return "blsurf_hypo_page.html";