1 // Copyright (C) 2007-2023 CEA, EDF, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // NETGENPlugin GUI: GUI for plugged-in mesher NETGENPlugin
24 // File : NETGENPluginGUI_HypothesisCreator.cxx
25 // Author : Michael Zorin
26 // Module : NETGENPlugin
28 #include "NETGENPluginGUI_HypothesisCreator.h"
30 #include <SMESHGUI_Utils.h>
31 #include <SMESHGUI_HypothesesUtils.h>
32 #include <SMESHGUI_SpinBox.h>
33 #include <GeomSelectionTools.h>
35 #include CORBA_SERVER_HEADER(NETGENPlugin_Algorithm)
37 #include <LightApp_SelectionMgr.h>
38 #include <SALOME_ListIO.hxx>
39 #include <SUIT_FileDlg.h>
40 #include <SUIT_ResourceMgr.h>
41 #include <SUIT_Session.h>
42 #include <SalomeApp_IntSpinBox.h>
43 #include <SalomeApp_Tools.h>
53 #include <QTableWidget>
54 #include <QHeaderView>
55 #include <QPushButton>
91 template<class SPINBOX, typename VALUETYPE>
92 void setTextOrVar( SPINBOX* spin, VALUETYPE value, const QString& variable )
96 if ( variable.isEmpty() )
97 spin->setValue( value );
99 spin->setText( variable );
103 NETGENPluginGUI_HypothesisCreator::NETGENPluginGUI_HypothesisCreator( const QString& theHypType )
104 : SMESHGUI_GenericHypothesisCreator( theHypType )
106 myGeomSelectionTools = NULL;
107 myLocalSizeMap.clear();
108 myIs2D = ( theHypType.startsWith("NETGEN_Parameters_2D") ||
109 theHypType == "NETGEN_RemesherParameters_2D");
110 myIsONLY = ( theHypType == "NETGEN_Parameters_2D_ONLY" ||
111 theHypType == "NETGEN_Parameters_3D" ||
112 theHypType == "NETGEN_RemesherParameters_2D");
115 NETGENPluginGUI_HypothesisCreator::~NETGENPluginGUI_HypothesisCreator()
119 bool NETGENPluginGUI_HypothesisCreator::checkParams(QString& /*msg*/) const
121 NetgenHypothesisData data_old, data_new;
122 readParamsFromHypo( data_old );
123 readParamsFromWidgets( data_new );
124 bool res = storeParamsToHypo( data_new );
126 if ( !res ) // -- issue 0021364: Dump of netgen parameters has duplicate lines
127 storeParamsToHypo( data_old );
132 QFrame* NETGENPluginGUI_HypothesisCreator::buildFrame()
134 const bool isRemesher = ( hypType() == "NETGEN_RemesherParameters_2D" );
136 QFrame* fr = new QFrame( 0 );
137 fr->setObjectName( "myframe" );
138 QVBoxLayout* lay = new QVBoxLayout( fr );
140 lay->setSpacing( 0 );
142 QTabWidget* tab = new QTabWidget( fr );
143 tab->setTabShape( QTabWidget::Rounded );
144 tab->setTabPosition( QTabWidget::North );
145 lay->addWidget( tab );
151 QWidget* GroupC1 = new QWidget();
152 tab->insertTab( STD_TAB, GroupC1, tr( "SMESH_ARGUMENTS" ) );
154 QGridLayout* aGroupLayout = new QGridLayout( GroupC1 );
155 aGroupLayout->setMargin( 6 );
156 aGroupLayout->setSpacing( 11 );
162 aGroupLayout->addWidget( new QLabel( tr( "SMESH_NAME" ), GroupC1 ), row0, 0 );
163 myName = new QLineEdit( GroupC1 );
164 myName->setMinimumWidth(160);
165 aGroupLayout->addWidget( myName, row0, 1 );
172 QGroupBox* aSizeBox = new QGroupBox( tr("NETGEN_MESH_SIZE"), GroupC1 );
173 aGroupLayout->addWidget( aSizeBox, row0, 0, 1, 2 );
176 QGridLayout* aSizeLayout = new QGridLayout( aSizeBox );
177 aSizeLayout->setSpacing( 6 );
178 aSizeLayout->setMargin( 11 );
181 aSizeLayout->addWidget( new QLabel( tr( "NETGEN_MAX_SIZE" ), aSizeBox ), row, 0 );
182 myMaxSize = new SMESHGUI_SpinBox( aSizeBox );
183 myMaxSize->RangeStepAndValidator( 1e-07, 1e+06, 10., "length_precision" );
184 aSizeLayout->addWidget( myMaxSize, row, 1 );
187 aSizeLayout->addWidget( new QLabel( tr( "NETGEN_MIN_SIZE" ), aSizeBox ), row, 0 );
188 myMinSize = new SMESHGUI_SpinBox( aSizeBox );
189 myMinSize->RangeStepAndValidator( 0.0, 1e+06, 10., "length_precision" );
190 aSizeLayout->addWidget( myMinSize, row, 1 );
193 aSizeLayout->addWidget( new QLabel( tr( "NETGEN_FINENESS" ), aSizeBox ), row, 0 );
194 myFineness = new QComboBox( aSizeBox );
196 types << tr( "NETGEN_VERYCOARSE" ) << tr( "NETGEN_COARSE" ) << tr( "NETGEN_MODERATE" ) <<
197 tr( "NETGEN_FINE" ) << tr( "NETGEN_VERYFINE" ) << tr( "NETGEN_CUSTOM" );
198 myFineness->addItems( types );
199 aSizeLayout->addWidget( myFineness, row, 1 );
200 connect( myFineness, SIGNAL( activated( int ) ), this, SLOT( onFinenessChanged() ) );
203 aSizeLayout->addWidget( new QLabel( tr( "NETGEN_GROWTH_RATE" ), aSizeBox ), row, 0 );
204 myGrowthRate = new SMESHGUI_SpinBox( aSizeBox );
205 myGrowthRate->RangeStepAndValidator( .0001, 10., .1, "parametric_precision" );
206 aSizeLayout->addWidget( myGrowthRate, row, 1 );
210 myNbSegPerRadius = 0;
213 const double VALUE_MAX = 1.0e+6;
215 aSizeLayout->addWidget( new QLabel( tr( "NETGEN_SEG_PER_EDGE" ), aSizeBox ), row, 0 );
216 myNbSegPerEdge = new SMESHGUI_SpinBox( aSizeBox );
217 myNbSegPerEdge->RangeStepAndValidator( .2, VALUE_MAX, .1, "parametric_precision" );
218 aSizeLayout->addWidget( myNbSegPerEdge, row, 1 );
221 aSizeLayout->addWidget( new QLabel( tr( "NETGEN_SEG_PER_RADIUS" ), aSizeBox ), row, 0 );
222 myNbSegPerRadius = new SMESHGUI_SpinBox( aSizeBox );
223 myNbSegPerRadius->RangeStepAndValidator( .2, VALUE_MAX, .1, "parametric_precision" );
224 aSizeLayout->addWidget( myNbSegPerRadius, row, 1 );
228 myChordalErrorEnabled = 0;
230 if (( myIs2D && !isRemesher ) || !myIsONLY )
232 myChordalErrorEnabled = new QCheckBox( tr( "NETGEN_CHORDAL_ERROR" ), aSizeBox );
233 aSizeLayout->addWidget( myChordalErrorEnabled, row, 0 );
234 myChordalError = new SMESHGUI_SpinBox( aSizeBox );
235 myChordalError->RangeStepAndValidator( COORD_MIN, COORD_MAX, .1, "length_precision" );
236 aSizeLayout->addWidget( myChordalError, row, 1 );
237 connect( myChordalErrorEnabled, SIGNAL( stateChanged(int)), SLOT( onChordalErrorEnabled()));
241 mySurfaceCurvature = 0;
242 if (( myIs2D && !isRemesher ) || !myIsONLY )
244 mySurfaceCurvature = new QCheckBox( tr( "NETGEN_SURFACE_CURVATURE" ), aSizeBox );
245 aSizeLayout->addWidget( mySurfaceCurvature, row, 0, 1, 2 );
246 connect( mySurfaceCurvature, SIGNAL( stateChanged( int ) ), this, SLOT( onSurfaceCurvatureChanged() ) );
249 } // end Mesh Size box
251 myAllowQuadrangles = 0;
252 if ( myIs2D || !myIsONLY ) // disable only for NETGEN 3D
254 myAllowQuadrangles = new QCheckBox( tr( "NETGEN_ALLOW_QUADRANGLES" ), GroupC1 );
255 aGroupLayout->addWidget( myAllowQuadrangles, row0, 0, 1, 2 );
262 mySecondOrder = new QCheckBox( tr( "NETGEN_SECOND_ORDER" ), GroupC1 );
263 aGroupLayout->addWidget( mySecondOrder, row0, 0, 1, 2 );
268 // if ( !isRemesher ) ???
270 myOptimize = new QCheckBox( tr( "NETGEN_OPTIMIZE" ), GroupC1 );
271 aGroupLayout->addWidget( myOptimize, row0, 0, 1, 2 );
275 myKeepExistingEdges = myMakeGroupsOfSurfaces = 0;
278 myKeepExistingEdges = new QCheckBox( tr( "NETGEN_KEEP_EXISTING_EDGES" ), GroupC1 );
279 aGroupLayout->addWidget( myKeepExistingEdges, row0, 0, 1, 2 );
282 myMakeGroupsOfSurfaces = new QCheckBox( tr( "NETGEN_MAKE_SURFACE_GROUPS" ), GroupC1 );
283 aGroupLayout->addWidget( myMakeGroupsOfSurfaces, row0, 0, 1, 2 );
287 aGroupLayout->setRowStretch( row0, 1 );
293 QWidget* stlGroup = new QWidget();
294 QVBoxLayout* stlLay = new QVBoxLayout( stlGroup );
295 stlLay->setMargin( 5 );
296 stlLay->setSpacing( 10 );
300 QGroupBox* chaGroup = new QGroupBox( tr("NETGEN_STL_CHARTS"), stlGroup );
301 stlLay->addWidget( chaGroup );
303 QGridLayout* chaLayout = new QGridLayout( chaGroup );
304 chaLayout->setMargin( 6 );
305 chaLayout->setSpacing( 6 );
308 chaLayout->addWidget( new QLabel( tr( "NETGEN_RIDGE_ANGLE" ), chaGroup ), row, 0 );
309 myRidgeAngle = new SMESHGUI_SpinBox( chaGroup );
310 myRidgeAngle->RangeStepAndValidator( 0, 90, 10, "angle_precision" );
311 chaLayout->addWidget( myRidgeAngle, row, 1 );
314 chaLayout->addWidget( new QLabel( tr( "NETGEN_EDGE_CORNER_ANGLE" ), chaGroup ), row, 0 );
315 myEdgeCornerAngle = new SMESHGUI_SpinBox( chaGroup );
316 myEdgeCornerAngle->RangeStepAndValidator( 0., 180., 20., "angle_precision" );
317 chaLayout->addWidget( myEdgeCornerAngle, row, 1 );
320 chaLayout->addWidget( new QLabel( tr( "NETGEN_CHART_ANGLE" ), chaGroup ), row, 0 );
321 myChartAngle = new SMESHGUI_SpinBox( chaGroup );
322 myChartAngle->RangeStepAndValidator( 0., 180., 20., "angle_precision" );
323 chaLayout->addWidget( myChartAngle, row, 1 );
326 chaLayout->addWidget( new QLabel( tr( "NETGEN_OUTER_CHART_ANGLE" ), chaGroup ), row, 0 );
327 myOuterChartAngle = new SMESHGUI_SpinBox( chaGroup );
328 myOuterChartAngle->RangeStepAndValidator( 0., 180., 20., "angle_precision" );
329 chaLayout->addWidget( myOuterChartAngle, row, 1 );
334 QGroupBox* sizeGroup = new QGroupBox( tr("NETGEN_STL_SIZE"), stlGroup );
335 stlLay->addWidget( sizeGroup );
337 QGridLayout* sizeLayout = new QGridLayout( sizeGroup );
338 sizeLayout->setMargin( 6 );
339 sizeLayout->setSpacing( 6 );
342 myRestHChartDistEnable = new QCheckBox( tr("NETGEN_RESTH_CHART_DIST"), sizeGroup );
343 sizeLayout->addWidget( myRestHChartDistEnable, row, 0 );
344 myRestHChartDistFactor = new SMESHGUI_SpinBox( sizeGroup );
345 myRestHChartDistFactor->RangeStepAndValidator( 0.2, 5., 0.1, "length_precision" );
346 sizeLayout->addWidget( myRestHChartDistFactor, row, 1 );
349 myRestHLineLengthEnable = new QCheckBox( tr("NETGEN_RESTH_LINE_LENGTH"), sizeGroup );
350 sizeLayout->addWidget( myRestHLineLengthEnable, row, 0 );
351 myRestHLineLengthFactor = new SMESHGUI_SpinBox( sizeGroup );
352 myRestHLineLengthFactor->RangeStepAndValidator( 0.2, 5., 0.1, "length_precision" );
353 sizeLayout->addWidget( myRestHLineLengthFactor, row, 1 );
356 myRestHCloseEdgeEnable = new QCheckBox( tr("NETGEN_RESTH_CLOSE_EDGE"), sizeGroup );
357 sizeLayout->addWidget( myRestHCloseEdgeEnable, row, 0 );
358 myRestHCloseEdgeFactor = new SMESHGUI_SpinBox( sizeGroup );
359 myRestHCloseEdgeFactor->RangeStepAndValidator( 0.2, 8., 0.1, "length_precision" );
360 sizeLayout->addWidget( myRestHCloseEdgeFactor, row, 1 );
363 myRestHSurfCurvEnable = new QCheckBox( tr("NETGEN_RESTH_SURF_CURV"), sizeGroup );
364 sizeLayout->addWidget( myRestHSurfCurvEnable, row, 0 );
365 myRestHSurfCurvFactor = new SMESHGUI_SpinBox( sizeGroup );
366 myRestHSurfCurvFactor->RangeStepAndValidator( 0.2, 5., 0.1, "length_precision" );
367 sizeLayout->addWidget( myRestHSurfCurvFactor, row, 1 );
370 myRestHEdgeAngleEnable = new QCheckBox( tr("NETGEN_RESTH_EDGE_ANGLE"), sizeGroup );
371 sizeLayout->addWidget( myRestHEdgeAngleEnable, row, 0 );
372 myRestHEdgeAngleFactor = new SMESHGUI_SpinBox( sizeGroup );
373 myRestHEdgeAngleFactor->RangeStepAndValidator( 0.2, 5., 0.1, "length_precision" );
374 sizeLayout->addWidget( myRestHEdgeAngleFactor, row, 1 );
377 myRestHSurfMeshCurvEnable = new QCheckBox( tr("NETGEN_RESTH_SURF_MESH_CURV"), sizeGroup );
378 sizeLayout->addWidget( myRestHSurfMeshCurvEnable, row, 0 );
379 myRestHSurfMeshCurvFactor = new SMESHGUI_SpinBox( sizeGroup );
380 myRestHSurfMeshCurvFactor->RangeStepAndValidator( 0.2, 5., 0.1, "length_precision" );
381 sizeLayout->addWidget( myRestHSurfMeshCurvFactor, row, 1 );
386 tab->insertTab( STL_TAB, stlGroup, tr( "NETGEN_STL" ));
387 connect( myRestHChartDistEnable , SIGNAL( toggled(bool) ), this, SLOT( onSTLEnable() ));
388 connect( myRestHLineLengthEnable , SIGNAL( toggled(bool) ), this, SLOT( onSTLEnable() ));
389 connect( myRestHCloseEdgeEnable , SIGNAL( toggled(bool) ), this, SLOT( onSTLEnable() ));
390 connect( myRestHSurfCurvEnable , SIGNAL( toggled(bool) ), this, SLOT( onSTLEnable() ));
391 connect( myRestHEdgeAngleEnable , SIGNAL( toggled(bool) ), this, SLOT( onSTLEnable() ));
392 connect( myRestHSurfMeshCurvEnable, SIGNAL( toggled(bool) ), this, SLOT( onSTLEnable() ));
404 myLocalSizeTable = 0;
407 QWidget* localSizeGroup = new QWidget();
408 QGridLayout* localSizeLayout = new QGridLayout(localSizeGroup);
410 myLocalSizeTable = new QTableWidget(0, LSZ_NB_COLUMNS, localSizeGroup);
411 localSizeLayout->addWidget(myLocalSizeTable, 1, 0, 8, 2);
412 QStringList localSizeHeaders;
413 localSizeHeaders << tr( "LSZ_ENTRY_COLUMN" )<< tr( "LSZ_NAME_COLUMN" ) << tr( "LSZ_LOCALSIZE_COLUMN" );
414 myLocalSizeTable->setHorizontalHeaderLabels(localSizeHeaders);
415 myLocalSizeTable->horizontalHeader()->hideSection(LSZ_ENTRY_COLUMN);
416 myLocalSizeTable->horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive);
418 myLocalSizeTable->resizeColumnToContents(LSZ_NAME_COLUMN);
419 myLocalSizeTable->resizeColumnToContents(LSZ_LOCALSIZE_COLUMN);
420 myLocalSizeTable->setAlternatingRowColors(true);
421 myLocalSizeTable->verticalHeader()->hide();
423 QPushButton* addVertexButton = new QPushButton(tr("NETGEN_LSZ_VERTEX"), localSizeGroup);
424 localSizeLayout->addWidget(addVertexButton, LSZ_VERTEX_BTN, 2, 1, 1);
425 QPushButton* addEdgeButton = new QPushButton(tr("NETGEN_LSZ_EDGE"), localSizeGroup);
426 localSizeLayout->addWidget(addEdgeButton, LSZ_EDGE_BTN, 2, 1, 1);
427 QPushButton* addFaceButton = new QPushButton(tr("NETGEN_LSZ_FACE"), localSizeGroup);
428 localSizeLayout->addWidget(addFaceButton, LSZ_FACE_BTN, 2, 1, 1);
429 QPushButton* addSolidButton = new QPushButton(tr("NETGEN_LSZ_SOLID"), localSizeGroup);
430 localSizeLayout->addWidget(addSolidButton, LSZ_SOLID_BTN, 2, 1, 1);
432 QFrame *line2 = new QFrame(localSizeGroup);
433 line2->setFrameShape(QFrame::HLine);
434 line2->setFrameShadow(QFrame::Sunken);
435 localSizeLayout->addWidget(line2, LSZ_SEPARATOR2, 2, 1, 1);
437 QPushButton* removeButton = new QPushButton(tr("NETGEN_LSZ_REMOVE"), localSizeGroup);
438 localSizeLayout->addWidget(removeButton, LSZ_REMOVE_BTN, 2, 1, 1);
440 QPushButton* fileBtn = new QPushButton(tr("NETGEN_LSZ_FILE"), localSizeGroup);
441 myMeshSizeFile = new QLineEdit(localSizeGroup);
442 myMeshSizeFile->setReadOnly( true );
443 localSizeLayout->addWidget( fileBtn, LSZ_FILE_LE, 0, 1, 1);
444 localSizeLayout->addWidget( myMeshSizeFile, LSZ_FILE_LE, 1, 1, 2);
446 connect( addVertexButton, SIGNAL(clicked()), this, SLOT(onAddLocalSizeOnVertex()));
447 connect( addEdgeButton, SIGNAL(clicked()), this, SLOT(onAddLocalSizeOnEdge()));
448 connect( addFaceButton, SIGNAL(clicked()), this, SLOT(onAddLocalSizeOnFace()));
449 connect( addSolidButton, SIGNAL(clicked()), this, SLOT(onAddLocalSizeOnSolid()));
450 connect( removeButton, SIGNAL(clicked()), this, SLOT(onRemoveLocalSizeOnShape()));
451 connect( myLocalSizeTable, SIGNAL(cellChanged(int, int)), this, SLOT(onSetLocalSize(int, int)));
452 connect( fileBtn, SIGNAL(clicked()), this, SLOT(onSetSizeFile()));
454 tab->insertTab(LSZ_TAB, localSizeGroup, tr("NETGEN_LOCAL_SIZE"));
461 QWidget* advGroup = new QWidget();
462 tab->insertTab( ADV_TAB, advGroup, tr( "SMESH_ADVANCED" ));
463 QVBoxLayout* advLay = new QVBoxLayout( advGroup );
464 advLay->setSpacing( 6 );
465 advLay->setMargin( 5 );
470 QGroupBox* optBox = new QGroupBox( tr("NETGEN_OPTIMIZER"), advGroup );
471 advLay->addWidget( optBox );
473 QGridLayout* optLayout = new QGridLayout( optBox );
474 optLayout->setMargin( 6 );
475 optLayout->setSpacing( 6 );
478 myElemSizeWeight = 0;
479 myNbSurfOptSteps = 0;
480 if ( myIs2D || !myIsONLY ) // 2D options
482 optLayout->addWidget( new QLabel( tr( "NETGEN_ELEM_SIZE_WEIGHT" ), optBox ), row, 0 );
483 myElemSizeWeight = new SMESHGUI_SpinBox( optBox );
484 myElemSizeWeight->RangeStepAndValidator( 0., 1., 0.1, "parametric_precision" );
485 optLayout->addWidget( myElemSizeWeight, row, 1 );
488 optLayout->addWidget( new QLabel( tr( "NETGEN_NB_SURF_OPT_STEPS" ), optBox ), row, 0 );
489 myNbSurfOptSteps = new SalomeApp_IntSpinBox( optBox );
490 myNbSurfOptSteps->setMinimum( 0 );
491 myNbSurfOptSteps->setMaximum( 99 );
492 optLayout->addWidget( myNbSurfOptSteps, row, 1 );
499 optLayout->addWidget( new QLabel( tr( "NETGEN_NB_VOL_OPT_STEPS" ), optBox ), row, 0 );
500 myNbVolOptSteps = new SalomeApp_IntSpinBox( optBox );
501 myNbVolOptSteps->setMinimum( 0 );
502 myNbVolOptSteps->setMaximum( 99 );
503 optLayout->addWidget( myNbVolOptSteps, row, 1 );
508 QGroupBox* insGroup = new QGroupBox( tr("NETGEN_INSIDER"), advGroup );
509 advLay->addWidget( insGroup );
511 QGridLayout* insLayout = new QGridLayout( insGroup );
512 insLayout->setMargin( 6 );
513 insLayout->setSpacing( 6 );
516 myWorstElemMeasure = 0;
520 insLayout->addWidget( new QLabel( tr( "NETGEN_WORST_ELEM_MEASURE" ), insGroup ), row, 0 );
521 myWorstElemMeasure = new SalomeApp_IntSpinBox( insGroup );
522 myWorstElemMeasure->setMinimum( 1 );
523 myWorstElemMeasure->setMaximum( 10 );
524 insLayout->addWidget( myWorstElemMeasure, row, 1, 1, 2 );
527 myUseDelauney = new QCheckBox( tr( "NETGEN_USE_DELAUNEY" ), insGroup );
528 insLayout->addWidget( myUseDelauney, row, 0, 1, 2 );
532 myCheckOverlapping = 0;
533 if ( myIs2D || !myIsONLY ) // 2D options
535 myCheckOverlapping = new QCheckBox( tr( "NETGEN_CHECK_OVERLAPPING" ), insGroup );
536 insLayout->addWidget( myCheckOverlapping, row, 0, 1, 2 );
540 myCheckChartBoundary = 0;
543 myCheckChartBoundary = new QCheckBox( tr( "NETGEN_CHECK_CHART_BOUNDARY" ), insGroup );
544 insLayout->addWidget( myCheckChartBoundary, row, 0, 1, 2 );
549 if ( !myIsONLY && !isRemesher )
551 myFuseEdges = new QCheckBox( tr( "NETGEN_FUSE_EDGES" ), insGroup );
552 insLayout->addWidget( myFuseEdges, row, 0, 1, 2 );
555 insLayout->setRowStretch( row, 1 );
561 void NETGENPluginGUI_HypothesisCreator::retrieveParams() const
563 NetgenHypothesisData data;
564 readParamsFromHypo( data );
567 myName->setText( data.myName );
569 setTextOrVar( myMaxSize, data.myMaxSize, data.myMaxSizeVar );
570 setTextOrVar( myMinSize, data.myMinSize, data.myMinSizeVar );
572 mySecondOrder->setChecked( data.mySecondOrder );
574 myOptimize->setChecked( data.myOptimize );
575 myFineness->setCurrentIndex( data.myFineness );
576 setTextOrVar( myGrowthRate, data.myGrowthRate, data.myGrowthRateVar );
577 setTextOrVar( myNbSegPerEdge, data.myNbSegPerEdge, data.myNbSegPerEdgeVar );
578 setTextOrVar( myNbSegPerRadius, data.myNbSegPerRadius, data.myNbSegPerRadiusVar );
580 if ( myChordalError )
582 myChordalErrorEnabled->setChecked( data.myChordalErrorEnabled && data.myChordalError > 0 );
583 setTextOrVar( myChordalError, data.myChordalError, data.myChordalErrorVar );
584 myChordalError->setEnabled( myChordalErrorEnabled->isChecked() );
586 if (myAllowQuadrangles)
587 myAllowQuadrangles->setChecked( data.myAllowQuadrangles );
588 if (mySurfaceCurvature)
589 mySurfaceCurvature->setChecked( data.mySurfaceCurvature );
591 if ( myKeepExistingEdges )
593 myKeepExistingEdges->setChecked( data.myKeepExistingEdges );
594 myMakeGroupsOfSurfaces->setChecked( data.myMakeGroupsOfSurfaces );
597 setTextOrVar( myElemSizeWeight, data.myElemSizeWeight, data.myElemSizeWeightVar );
598 setTextOrVar( myNbSurfOptSteps, data.myNbSurfOptSteps, data.myNbSurfOptStepsVar );
599 setTextOrVar( myNbVolOptSteps, data.myNbVolOptSteps, data.myNbVolOptStepsVar );
602 myFuseEdges->setChecked( data.myFuseEdges );
603 setTextOrVar( myWorstElemMeasure, data.myWorstElemMeasure, data.myWorstElemMeasureVar );
605 myUseDelauney->setChecked( data.myUseDelauney );
606 if ( myCheckOverlapping )
607 myCheckOverlapping->setChecked( data.myCheckOverlapping );
608 if ( myCheckChartBoundary )
609 myCheckChartBoundary->setChecked( data.myCheckChartBoundary );
613 setTextOrVar( myRidgeAngle, data.myRidgeAngle, data.myRidgeAngleVar );
614 setTextOrVar( myEdgeCornerAngle, data.myEdgeCornerAngle, data.myEdgeCornerAngleVar );
615 setTextOrVar( myChartAngle, data.myChartAngle, data.myChartAngleVar );
616 setTextOrVar( myOuterChartAngle, data.myOuterChartAngle, data.myOuterChartAngleVar );
617 setTextOrVar( myRestHChartDistFactor, data.myRestHChartDistFactor,
618 data.myRestHChartDistFactorVar );
619 setTextOrVar( myRestHLineLengthFactor, data.myRestHLineLengthFactor,
620 data.myRestHLineLengthFactorVar );
621 setTextOrVar( myRestHCloseEdgeFactor, data.myRestHCloseEdgeFactor,
622 data.myRestHCloseEdgeFactorVar );
623 setTextOrVar( myRestHSurfCurvFactor, data.myRestHSurfCurvFactor,
624 data.myRestHSurfCurvFactorVar );
625 setTextOrVar( myRestHEdgeAngleFactor, data.myRestHEdgeAngleFactor,
626 data.myRestHEdgeAngleFactorVar );
627 setTextOrVar( myRestHSurfMeshCurvFactor, data.myRestHSurfMeshCurvFactor,
628 data.myRestHSurfMeshCurvFactorVar );
630 myRestHChartDistEnable->setChecked( data.myRestHChartDistEnable );
631 myRestHLineLengthEnable->setChecked( data.myRestHLineLengthEnable );
632 myRestHCloseEdgeEnable->setChecked( data.myRestHCloseEdgeEnable );
633 myRestHSurfCurvEnable->setChecked( data.myRestHSurfCurvEnable );
634 myRestHEdgeAngleEnable->setChecked( data.myRestHEdgeAngleEnable );
635 myRestHSurfMeshCurvEnable->setChecked( data.myRestHSurfMeshCurvEnable );
639 ((NETGENPluginGUI_HypothesisCreator*) this )-> onSurfaceCurvatureChanged();
641 if ( myLocalSizeTable )
643 NETGENPluginGUI_HypothesisCreator* that = (NETGENPluginGUI_HypothesisCreator*)this;
644 QMapIterator<QString, QString> i(myLocalSizeMap);
645 GeomSelectionTools* geomSelectionTools = that->getGeomSelectionTools();
646 while (i.hasNext()) {
648 const QString entry = i.key();
649 std::string shapeName = geomSelectionTools->getNameFromEntry(entry.toStdString());
650 const QString localSize = i.value();
651 int row = myLocalSizeTable->rowCount();
652 myLocalSizeTable->setRowCount(row+1);
653 myLocalSizeTable->setItem(row, LSZ_ENTRY_COLUMN, new QTableWidgetItem(entry));
654 myLocalSizeTable->item(row, LSZ_ENTRY_COLUMN)->setFlags(0);
655 myLocalSizeTable->setItem(row, LSZ_NAME_COLUMN, new QTableWidgetItem(QString::fromStdString(shapeName)));
656 myLocalSizeTable->item(row, LSZ_NAME_COLUMN)->setFlags(0);
657 myLocalSizeTable->setItem(row, LSZ_LOCALSIZE_COLUMN, new QTableWidgetItem(localSize));
658 myLocalSizeTable->item(row, LSZ_LOCALSIZE_COLUMN)->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEditable|Qt::ItemIsEnabled);
660 myLocalSizeTable->resizeColumnToContents(LSZ_NAME_COLUMN);
661 myLocalSizeTable->resizeColumnToContents(LSZ_LOCALSIZE_COLUMN);
663 myMeshSizeFile->setText( data.myMeshSizeFile );
667 QString NETGENPluginGUI_HypothesisCreator::storeParams() const
669 NetgenHypothesisData data;
670 readParamsFromWidgets( data );
671 storeParamsToHypo( data );
676 bool NETGENPluginGUI_HypothesisCreator::readParamsFromHypo( NetgenHypothesisData& h_data ) const
678 NETGENPlugin::NETGENPlugin_Hypothesis_var h =
679 NETGENPlugin::NETGENPlugin_Hypothesis::_narrow( initParamsHypothesis() );
681 h_data.myName = isCreation() ? hypName() : "";
683 h_data.myMaxSize = h->GetMaxSize();
684 h_data.myMaxSizeVar = getVariableName("SetMaxSize");
685 h_data.myMinSize = h->GetMinSize();
686 h_data.myMinSizeVar = getVariableName("SetMinSize");
687 h_data.mySecondOrder = h->GetSecondOrder();
688 h_data.myOptimize = h->GetOptimize();
690 h_data.myFineness = (int) h->GetFineness();
691 h_data.myGrowthRate = h->GetGrowthRate();
692 h_data.myGrowthRateVar = getVariableName("SetGrowthRate");
693 h_data.myNbSegPerEdge = h->GetNbSegPerEdge();
694 h_data.myNbSegPerEdgeVar = getVariableName("SetNbSegPerEdge");
695 h_data.myNbSegPerRadius = h->GetNbSegPerRadius();
696 h_data.myNbSegPerRadiusVar = getVariableName("SetNbSegPerRadius");
697 h_data.myChordalError = h->GetChordalError();
698 h_data.myChordalErrorVar = getVariableName("SetChordalError");
699 h_data.myChordalErrorEnabled = h->GetChordalErrorEnabled();
700 h_data.mySurfaceCurvature = h->GetUseSurfaceCurvature();
702 h_data.myElemSizeWeight = h->GetElemSizeWeight ();
703 h_data.myElemSizeWeightVar = getVariableName("SetElemSizeWeight");
704 h_data.myNbSurfOptSteps = h->GetNbSurfOptSteps ();
705 h_data.myNbSurfOptStepsVar = getVariableName("SetNbSurfOptSteps");
706 h_data.myNbVolOptSteps = h->GetNbVolOptSteps ();
707 h_data.myNbVolOptStepsVar = getVariableName("SetNbVolOptSteps");
708 h_data.myFuseEdges = h->GetFuseEdges();
709 h_data.myWorstElemMeasure = h->GetWorstElemMeasure ();
710 h_data.myWorstElemMeasureVar = getVariableName("SetWorstElemMeasure");
711 h_data.myUseDelauney = h->GetUseDelauney ();
712 h_data.myCheckOverlapping = h->GetCheckOverlapping ();
713 h_data.myCheckChartBoundary = h->GetCheckChartBoundary();
715 h_data.myMeshSizeFile = h->GetMeshSizeFile();
719 // NETGENPlugin::NETGENPlugin_Hypothesis_var h =
720 // NETGENPlugin::NETGENPlugin_Hypothesis::_narrow( initParamsHypothesis() );
723 h_data.myAllowQuadrangles = h->GetQuadAllowed();
727 NETGENPlugin::NETGENPlugin_RemesherHypothesis_2D_var rh =
728 NETGENPlugin::NETGENPlugin_RemesherHypothesis_2D::_narrow( h );
729 if ( !rh->_is_nil() )
731 h_data.myRidgeAngle = rh->GetRidgeAngle();
732 h_data.myRidgeAngleVar = getVariableName("SetRidgeAngle");
733 h_data.myEdgeCornerAngle = rh->GetEdgeCornerAngle ();
734 h_data.myEdgeCornerAngleVar = getVariableName("SetEdgeCornerAngle");
735 h_data.myChartAngle = rh->GetChartAngle ();
736 h_data.myChartAngleVar = getVariableName("SetChartAngle");
737 h_data.myOuterChartAngle = rh->GetOuterChartAngle ();
738 h_data.myOuterChartAngleVar = getVariableName("SetOuterChartAngle");
739 h_data.myRestHChartDistFactor = rh->GetRestHChartDistFactor ();
740 h_data.myRestHChartDistFactorVar = getVariableName("SetRestHChartDistFactor");
741 h_data.myRestHLineLengthFactor = rh->GetRestHLineLengthFactor ();
742 h_data.myRestHLineLengthFactorVar = getVariableName("SetRestHLineLengthFactor");
743 h_data.myRestHCloseEdgeFactor = rh->GetRestHCloseEdgeFactor ();
744 h_data.myRestHCloseEdgeFactorVar = getVariableName("SetRestHCloseEdgeFactor");
745 h_data.myRestHSurfCurvFactor = rh->GetRestHSurfCurvFactor ();
746 h_data.myRestHSurfCurvFactorVar = getVariableName("SetRestHSurfCurvFactor");
747 h_data.myRestHEdgeAngleFactor = rh->GetRestHEdgeAngleFactor ();
748 h_data.myRestHEdgeAngleFactorVar = getVariableName("SetRestHEdgeAngleFactor");
749 h_data.myRestHSurfMeshCurvFactor = rh->GetRestHSurfMeshCurvFactor();
750 h_data.myRestHSurfMeshCurvFactorVar = getVariableName("SetRestHSurfMeshCurvFactor");
751 h_data.myRestHChartDistEnable = rh->GetRestHChartDistEnable ();
752 h_data.myRestHLineLengthEnable = rh->GetRestHLineLengthEnable ();
753 h_data.myRestHCloseEdgeEnable = rh->GetRestHCloseEdgeEnable ();
754 h_data.myRestHSurfCurvEnable = rh->GetRestHSurfCurvEnable ();
755 h_data.myRestHEdgeAngleEnable = rh->GetRestHEdgeAngleEnable ();
756 h_data.myRestHSurfMeshCurvEnable = rh->GetRestHSurfMeshCurvEnable();
757 h_data.myKeepExistingEdges = rh->GetKeepExistingEdges ();
758 h_data.myMakeGroupsOfSurfaces = rh->GetMakeGroupsOfSurfaces ();
762 NETGENPluginGUI_HypothesisCreator* that = (NETGENPluginGUI_HypothesisCreator*)this;
763 NETGENPlugin::string_array_var myEntries = h->GetLocalSizeEntries();
764 for ( CORBA::ULong i = 0; i < myEntries->length(); i++ )
766 QString entry = myEntries[i].in();
767 if (myLocalSizeMap.contains(entry) &&
768 myLocalSizeMap[entry] == "__TO_DELETE__")
770 double val = h->GetLocalSizeOnEntry( myEntries[i] );
771 std::ostringstream tmp;
773 that->myLocalSizeMap[entry] = tmp.str().c_str();
779 bool NETGENPluginGUI_HypothesisCreator::storeParamsToHypo( const NetgenHypothesisData& h_data ) const
781 NETGENPlugin::NETGENPlugin_Hypothesis_var h =
782 NETGENPlugin::NETGENPlugin_Hypothesis::_narrow( hypothesis() );
788 SMESH::SetName( SMESH::FindSObject( h ), h_data.myName.toLatin1().data() );
789 h->SetVarParameter( h_data.myMaxSizeVar.toLatin1().constData(), "SetMaxSize");
790 h->SetMaxSize ( h_data.myMaxSize );
791 h->SetVarParameter( h_data.myMinSizeVar.toLatin1().constData(), "SetMinSize");
792 h->SetMinSize ( h_data.myMinSize );
794 h->SetSecondOrder ( h_data.mySecondOrder );
796 h->SetOptimize ( h_data.myOptimize );
797 h->SetFineness ( h_data.myFineness );
799 if ( h_data.myFineness == UserDefined )
801 h->SetVarParameter ( h_data.myGrowthRateVar.toLatin1().constData(), "SetGrowthRate");
802 h->SetGrowthRate ( h_data.myGrowthRate );
803 if ( myNbSegPerEdge )
805 h->SetVarParameter ( h_data.myNbSegPerEdgeVar.toLatin1().constData(), "SetNbSegPerEdge");
806 h->SetNbSegPerEdge ( h_data.myNbSegPerEdge );
808 if ( myNbSegPerRadius )
810 h->SetVarParameter ( h_data.myNbSegPerRadiusVar.toLatin1().constData(), "SetNbSegPerRadius");
811 h->SetNbSegPerRadius( h_data.myNbSegPerRadius );
814 if ( myChordalError )
816 h->SetVarParameter ( h_data.myChordalErrorVar.toLatin1().constData(), "SetChordalError");
817 h->SetChordalError ( h_data.myChordalError );
818 h->SetChordalErrorEnabled( h_data.myChordalErrorEnabled );
820 if ( mySurfaceCurvature )
821 h->SetUseSurfaceCurvature( h_data.mySurfaceCurvature );
822 h->SetMeshSizeFile ( h_data.myMeshSizeFile.toUtf8().constData() );
824 h->SetVarParameter ( h_data.myElemSizeWeightVar.toLatin1().constData(), "SetElemSizeWeight");
825 h->SetElemSizeWeight( h_data.myElemSizeWeight );
826 if ( myNbSurfOptSteps )
828 h->SetVarParameter ( h_data.myNbSurfOptStepsVar.toLatin1().constData(), "SetNbSurfOptSteps");
829 h->SetNbSurfOptSteps((CORBA::Short) h_data.myNbSurfOptSteps );
831 if ( myNbVolOptSteps )
833 h->SetVarParameter ( h_data.myNbVolOptStepsVar.toLatin1().constData(), "SetNbVolOptSteps");
834 h->SetNbVolOptSteps((CORBA::Short) h_data.myNbVolOptSteps );
837 h->SetFuseEdges( h_data.myFuseEdges );
838 h->SetVarParameter ( h_data.myWorstElemMeasureVar.toLatin1().constData(), "SetWorstElemMeasure");
839 h->SetWorstElemMeasure((CORBA::Short) h_data.myWorstElemMeasure );
841 h->SetUseDelauney( h_data.myUseDelauney );
842 h->SetCheckOverlapping( h_data.myCheckOverlapping );
843 h->SetCheckChartBoundary( h_data.myCheckChartBoundary );
847 // NETGENPlugin::NETGENPlugin_Hypothesis_2D_var h_2d =
848 // NETGENPlugin::NETGENPlugin_Hypothesis_2D::_narrow( h );
849 // if ( !h_2d->_is_nil() )
850 // h_2d->SetQuadAllowed( h_data.myAllowQuadrangles );
851 if ( myAllowQuadrangles )
852 h->SetQuadAllowed( h_data.myAllowQuadrangles );
856 NETGENPlugin::NETGENPlugin_RemesherHypothesis_2D_var rh =
857 NETGENPlugin::NETGENPlugin_RemesherHypothesis_2D::_narrow( h );
858 if ( !rh->_is_nil() )
860 rh->SetVarParameter ( h_data.myRidgeAngleVar.toLatin1().constData(), "SetRidgeAngle");
861 rh->SetRidgeAngle ( h_data.myRidgeAngle );
862 rh->SetVarParameter ( h_data.myEdgeCornerAngleVar.toLatin1().constData(), "SetEdgeCornerAngle");
863 rh->SetEdgeCornerAngle( h_data.myEdgeCornerAngle );
864 rh->SetVarParameter ( h_data.myChartAngleVar.toLatin1().constData(), "SetChartAngle");
865 rh->SetChartAngle ( h_data.myChartAngle );
866 rh->SetVarParameter ( h_data.myOuterChartAngleVar.toLatin1().constData(), "SetOuterChartAngle");
867 rh->SetOuterChartAngle( h_data.myOuterChartAngle );
869 rh->SetVarParameter ( h_data.myRestHChartDistFactorVar.toLatin1().constData(), "SetRestHChartDistFactor");
870 rh->SetRestHChartDistFactor ( h_data.myRestHChartDistFactor );
871 rh->SetVarParameter ( h_data.myRestHLineLengthFactorVar.toLatin1().constData(), "SetRestHLineLengthFactor");
872 rh->SetRestHLineLengthFactor ( h_data.myRestHLineLengthFactor );
873 rh->SetVarParameter ( h_data.myRestHCloseEdgeFactorVar.toLatin1().constData(), "SetRestHCloseEdgeFactor");
874 rh->SetRestHCloseEdgeFactor ( h_data.myRestHCloseEdgeFactor );
875 rh->SetVarParameter ( h_data.myRestHSurfCurvFactorVar.toLatin1().constData(), "SetRestHSurfCurvFactor");
876 rh->SetRestHSurfCurvFactor ( h_data.myRestHSurfCurvFactor );
877 rh->SetVarParameter ( h_data.myRestHEdgeAngleFactorVar.toLatin1().constData(), "SetRestHEdgeAngleFactor");
878 rh->SetRestHEdgeAngleFactor ( h_data.myRestHEdgeAngleFactor );
879 rh->SetVarParameter ( h_data.myRestHSurfMeshCurvFactorVar.toLatin1().constData(), "SetRestHSurfMeshCurvFactor");
880 rh->SetRestHSurfMeshCurvFactor( h_data.myRestHSurfMeshCurvFactor );
882 rh->SetRestHChartDistEnable ( h_data.myRestHChartDistEnable );
883 rh->SetRestHLineLengthEnable ( h_data.myRestHLineLengthEnable );
884 rh->SetRestHCloseEdgeEnable ( h_data.myRestHCloseEdgeEnable );
885 rh->SetRestHSurfCurvEnable ( h_data.myRestHSurfCurvEnable );
886 rh->SetRestHEdgeAngleEnable ( h_data.myRestHEdgeAngleEnable );
887 rh->SetRestHSurfMeshCurvEnable( h_data.myRestHSurfMeshCurvEnable );
889 rh->SetKeepExistingEdges ( h_data.myKeepExistingEdges );
890 rh->SetMakeGroupsOfSurfaces ( h_data.myMakeGroupsOfSurfaces );
891 //rh->SetFixedEdgeGroup ( -1 );
894 for ( QMapIterator<QString,QString> i(myLocalSizeMap); i.hasNext(); )
897 const QString& entry = i.key();
898 const QString& localSize = i.value();
899 if (localSize == "__TO_DELETE__")
901 h->UnsetLocalSizeOnEntry(entry.toLatin1().constData());
905 h->SetLocalSizeOnEntry(entry.toLatin1().constData(), localSize.toDouble());
909 catch(const SALOME::SALOME_Exception& ex)
911 SalomeApp_Tools::QtCatchCorbaException(ex);
917 bool NETGENPluginGUI_HypothesisCreator::readParamsFromWidgets( NetgenHypothesisData& h_data ) const
919 h_data.myName = myName ? myName->text() : "";
920 h_data.myMaxSize = myMaxSize->value();
921 h_data.myMaxSizeVar = myMaxSize->text();
922 h_data.myMinSize = myMinSize->value();
923 h_data.myMinSizeVar = myMinSize->text();
925 h_data.mySecondOrder = mySecondOrder->isChecked();
927 h_data.myOptimize = myOptimize->isChecked();
928 h_data.myFineness = myFineness->currentIndex();
929 h_data.myGrowthRate = myGrowthRate->value();
930 if ( myNbSegPerEdge )
931 h_data.myNbSegPerEdge = myNbSegPerEdge->value();
932 if ( myNbSegPerRadius )
933 h_data.myNbSegPerRadius = myNbSegPerRadius->value();
935 h_data.myGrowthRateVar = myGrowthRate->text();
936 if ( myNbSegPerEdge )
937 h_data.myNbSegPerEdgeVar = myNbSegPerEdge->text();
938 if ( myNbSegPerRadius )
939 h_data.myNbSegPerRadiusVar = myNbSegPerRadius->text();
940 if ( myChordalError )
942 h_data.myChordalErrorVar = myChordalError->text();
943 h_data.myChordalError = myChordalError->value();
944 h_data.myChordalErrorEnabled = myChordalError->isEnabled();
946 if ( myAllowQuadrangles )
947 h_data.myAllowQuadrangles = myAllowQuadrangles->isChecked();
949 if ( mySurfaceCurvature )
950 h_data.mySurfaceCurvature = mySurfaceCurvature->isChecked();
953 h_data.myFuseEdges = myFuseEdges->isChecked();
955 if ( myElemSizeWeight )
957 h_data.myElemSizeWeight = myElemSizeWeight->value();
958 h_data.myElemSizeWeightVar = myElemSizeWeight->text();
960 if ( myNbSurfOptSteps )
962 h_data.myNbSurfOptSteps = myNbSurfOptSteps->value();
963 h_data.myNbSurfOptStepsVar = myNbSurfOptSteps->text();
965 if ( myNbVolOptSteps )
967 h_data.myNbVolOptSteps = myNbVolOptSteps->value();
968 h_data.myNbVolOptStepsVar = myNbVolOptSteps->text();
970 if ( myWorstElemMeasure )
972 h_data.myWorstElemMeasure = myWorstElemMeasure->value();
973 h_data.myWorstElemMeasureVar = myWorstElemMeasure->text();
976 h_data.myUseDelauney = myUseDelauney->isChecked();
978 if ( myCheckOverlapping )
979 h_data.myCheckOverlapping = myCheckOverlapping->isChecked();
981 if ( myCheckChartBoundary )
982 h_data.myCheckChartBoundary = myCheckChartBoundary->isChecked();
986 h_data.myRidgeAngle = myRidgeAngle ->value();
987 h_data.myRidgeAngleVar = myRidgeAngle ->text();
988 h_data.myEdgeCornerAngle = myEdgeCornerAngle ->value();
989 h_data.myEdgeCornerAngleVar = myEdgeCornerAngle ->text();
990 h_data.myChartAngle = myChartAngle ->value();
991 h_data.myChartAngleVar = myChartAngle ->text();
992 h_data.myOuterChartAngle = myOuterChartAngle ->value();
993 h_data.myOuterChartAngleVar = myOuterChartAngle ->text();
994 h_data.myRestHChartDistFactor = myRestHChartDistFactor ->value();
995 h_data.myRestHChartDistFactorVar = myRestHChartDistFactor ->text();
996 h_data.myRestHLineLengthFactor = myRestHLineLengthFactor ->value();
997 h_data.myRestHLineLengthFactorVar = myRestHLineLengthFactor ->text();
998 h_data.myRestHCloseEdgeFactor = myRestHCloseEdgeFactor ->value();
999 h_data.myRestHCloseEdgeFactorVar = myRestHCloseEdgeFactor ->text();
1000 h_data.myRestHSurfCurvFactor = myRestHSurfCurvFactor ->value();
1001 h_data.myRestHSurfCurvFactorVar = myRestHSurfCurvFactor ->text();
1002 h_data.myRestHEdgeAngleFactor = myRestHEdgeAngleFactor ->value();
1003 h_data.myRestHEdgeAngleFactorVar = myRestHEdgeAngleFactor ->text();
1004 h_data.myRestHSurfMeshCurvFactor = myRestHSurfMeshCurvFactor->value();
1005 h_data.myRestHSurfMeshCurvFactorVar = myRestHSurfMeshCurvFactor->text();
1006 h_data.myRestHChartDistEnable = myRestHChartDistEnable ->isChecked();
1007 h_data.myRestHLineLengthEnable = myRestHLineLengthEnable ->isChecked();
1008 h_data.myRestHCloseEdgeEnable = myRestHCloseEdgeEnable ->isChecked();
1009 h_data.myRestHSurfCurvEnable = myRestHSurfCurvEnable ->isChecked();
1010 h_data.myRestHEdgeAngleEnable = myRestHEdgeAngleEnable ->isChecked();
1011 h_data.myRestHSurfMeshCurvEnable = myRestHSurfMeshCurvEnable->isChecked();
1012 h_data.myKeepExistingEdges = myKeepExistingEdges ->isChecked();
1013 h_data.myMakeGroupsOfSurfaces = myMakeGroupsOfSurfaces ->isChecked();
1016 if ( myLocalSizeTable )
1018 NETGENPluginGUI_HypothesisCreator* that = (NETGENPluginGUI_HypothesisCreator*)this;
1019 int nbRows = myLocalSizeTable->rowCount();
1020 for(int row=0 ; row < nbRows ; row++)
1022 QString entry = myLocalSizeTable->item(row, LSZ_ENTRY_COLUMN)->text();
1023 QString localSize = myLocalSizeTable->item(row, LSZ_LOCALSIZE_COLUMN)->text().trimmed();
1024 that->myLocalSizeMap[entry] = localSize;
1026 h_data.myMeshSizeFile = myMeshSizeFile->text();
1031 void NETGENPluginGUI_HypothesisCreator::onChordalErrorEnabled()
1033 myChordalError->setEnabled( myChordalErrorEnabled->isChecked() );
1036 void NETGENPluginGUI_HypothesisCreator::onSurfaceCurvatureChanged()
1038 bool isSurfaceCurvature = (mySurfaceCurvature ? mySurfaceCurvature->isChecked() : true);
1039 bool isCustom = (myFineness->currentIndex() == UserDefined);
1040 //myFineness->setEnabled(isSurfaceCurvature);
1041 myGrowthRate->setEnabled(isCustom);
1042 if ( myNbSegPerEdge )
1043 myNbSegPerEdge->setEnabled(isCustom && isSurfaceCurvature);
1044 if ( myNbSegPerRadius )
1045 myNbSegPerRadius->setEnabled(isCustom && isSurfaceCurvature);
1046 // if ( myChordalError )
1048 // myChordalError->setEnabled( isSurfaceCurvature );
1049 // myChordalErrorEnabled->setEnabled( isSurfaceCurvature );
1053 void NETGENPluginGUI_HypothesisCreator::onFinenessChanged()
1055 bool isCustom = (myFineness->currentIndex() == UserDefined);
1057 myGrowthRate->setEnabled(isCustom);
1058 if ( myNbSegPerEdge )
1059 myNbSegPerEdge->setEnabled(isCustom);
1060 if ( myNbSegPerRadius )
1061 myNbSegPerRadius->setEnabled(isCustom);
1065 double aGrowthRate, aNbSegPerEdge, aNbSegPerRadius;
1067 switch ( myFineness->currentIndex() )
1071 aNbSegPerEdge = 0.3;
1072 aNbSegPerRadius = 1;
1076 aNbSegPerEdge = 0.5;
1077 aNbSegPerRadius = 1.5;
1082 aNbSegPerRadius = 3;
1087 aNbSegPerRadius = 5;
1093 aNbSegPerRadius = 2;
1097 myGrowthRate->setValue( aGrowthRate );
1098 if ( myNbSegPerEdge )
1099 myNbSegPerEdge->setValue( aNbSegPerEdge );
1100 if ( myNbSegPerRadius )
1101 myNbSegPerRadius->setValue( aNbSegPerRadius );
1105 void NETGENPluginGUI_HypothesisCreator::onAddLocalSizeOnVertex()
1107 addLocalSizeOnShape(TopAbs_VERTEX);
1110 void NETGENPluginGUI_HypothesisCreator::onAddLocalSizeOnEdge()
1112 addLocalSizeOnShape(TopAbs_EDGE);
1115 void NETGENPluginGUI_HypothesisCreator::onAddLocalSizeOnFace()
1117 addLocalSizeOnShape(TopAbs_FACE);
1120 void NETGENPluginGUI_HypothesisCreator::onAddLocalSizeOnSolid()
1122 addLocalSizeOnShape(TopAbs_SOLID);
1125 void NETGENPluginGUI_HypothesisCreator::addLocalSizeOnShape(TopAbs_ShapeEnum typeShapeAsked)
1127 NETGENPlugin::NETGENPlugin_Hypothesis_var h = NETGENPlugin::NETGENPlugin_Hypothesis::_narrow(initParamsHypothesis());
1128 GeomSelectionTools* geomSelectionTools = getGeomSelectionTools();
1129 LightApp_SelectionMgr* mySel = geomSelectionTools->selectionMgr();
1130 SALOME_ListIO ListSelectedObjects;
1131 mySel->selectedObjects(ListSelectedObjects, NULL, false );
1132 SALOME_ListIteratorOfListIO Object_It(ListSelectedObjects);
1133 for ( ; Object_It.More() ; Object_It.Next())
1135 Handle(SALOME_InteractiveObject) anObject = Object_It.Value();
1136 std::string entry = geomSelectionTools->getEntryOfObject(anObject);
1137 std::string shapeName = anObject->getName();
1138 TopAbs_ShapeEnum shapeType = geomSelectionTools->entryToShapeType(entry);
1139 if (shapeType == TopAbs_SHAPE)
1141 // E.A. if shapeType == TopAbs_SHAPE, it is NOT a TopoDS_Shape !!!
1145 if(shapeType != typeShapeAsked)
1150 myLocalSizeTable->setFocus();
1151 QString shapeEntry = QString::fromStdString(entry);
1152 if (myLocalSizeMap.contains(shapeEntry) &&
1153 myLocalSizeMap[shapeEntry] != "__TO_DELETE__")
1156 double phySize = h->GetMaxSize();
1157 std::ostringstream oss;
1160 localSize = QString::fromStdString(oss.str());
1162 int row = myLocalSizeTable->rowCount() ;
1163 myLocalSizeTable->setRowCount(row+1);
1164 myLocalSizeTable->setItem(row, LSZ_ENTRY_COLUMN, new QTableWidgetItem(shapeEntry));
1165 myLocalSizeTable->item(row, LSZ_ENTRY_COLUMN )->setFlags(0);
1166 myLocalSizeTable->setItem(row, LSZ_NAME_COLUMN, new QTableWidgetItem(QString::fromStdString(shapeName)));
1167 myLocalSizeTable->item(row, LSZ_NAME_COLUMN )->setFlags(0);
1168 myLocalSizeTable->setItem(row, LSZ_LOCALSIZE_COLUMN, new QTableWidgetItem(localSize));
1169 myLocalSizeTable->item(row, LSZ_LOCALSIZE_COLUMN )->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEditable|Qt::ItemIsEnabled);
1170 myLocalSizeTable->resizeColumnToContents(LSZ_NAME_COLUMN);
1171 myLocalSizeTable->resizeColumnToContents(LSZ_LOCALSIZE_COLUMN);
1172 myLocalSizeTable->clearSelection();
1173 myLocalSizeTable->scrollToItem( myLocalSizeTable->item( row, LSZ_LOCALSIZE_COLUMN ) );
1178 void NETGENPluginGUI_HypothesisCreator::onRemoveLocalSizeOnShape()
1180 QList<int> selectedRows;
1181 QList<QTableWidgetItem*> selected = myLocalSizeTable->selectedItems();
1182 QTableWidgetItem* item;
1184 foreach(item, selected) {
1186 if (!selectedRows.contains(row))
1187 selectedRows.append( row );
1189 qSort( selectedRows );
1190 QListIterator<int> it( selectedRows );
1192 while (it.hasPrevious())
1194 row = it.previous();
1195 QString entry = myLocalSizeTable->item(row,LSZ_ENTRY_COLUMN)->text();
1196 if (myLocalSizeMap.contains(entry))
1198 myLocalSizeMap[entry] = "__TO_DELETE__";
1200 myLocalSizeTable->removeRow(row );
1202 myLocalSizeTable->resizeColumnToContents(LSZ_NAME_COLUMN);
1203 myLocalSizeTable->resizeColumnToContents(LSZ_LOCALSIZE_COLUMN);
1206 void NETGENPluginGUI_HypothesisCreator::onSetLocalSize(int row,int col)
1208 if (col == LSZ_LOCALSIZE_COLUMN) {
1209 QString entry = myLocalSizeTable->item(row, LSZ_ENTRY_COLUMN)->text();
1210 QString localSize = myLocalSizeTable->item(row, LSZ_LOCALSIZE_COLUMN)->text().trimmed();
1211 myLocalSizeMap[entry] = localSize;
1212 myLocalSizeTable->resizeColumnToContents(LSZ_LOCALSIZE_COLUMN);
1216 void NETGENPluginGUI_HypothesisCreator::onSetSizeFile()
1218 QString dir = SUIT_FileDlg::getFileName( dlg(), QString(),
1219 QStringList() << tr( "ALL_FILES_FILTER" ) + " (*)");
1220 myMeshSizeFile->setText( dir );
1223 void NETGENPluginGUI_HypothesisCreator::onSTLEnable()
1225 myRestHChartDistFactor ->setEnabled( myRestHChartDistEnable ->isChecked() );
1226 myRestHLineLengthFactor ->setEnabled( myRestHLineLengthEnable ->isChecked() );
1227 myRestHCloseEdgeFactor ->setEnabled( myRestHCloseEdgeEnable ->isChecked() );
1228 myRestHSurfCurvFactor ->setEnabled( myRestHSurfCurvEnable ->isChecked() );
1229 myRestHEdgeAngleFactor ->setEnabled( myRestHEdgeAngleEnable ->isChecked() );
1230 myRestHSurfMeshCurvFactor->setEnabled( myRestHSurfMeshCurvEnable->isChecked() );
1233 GeomSelectionTools* NETGENPluginGUI_HypothesisCreator::getGeomSelectionTools()
1235 if (myGeomSelectionTools == NULL) {
1236 delete myGeomSelectionTools;
1237 myGeomSelectionTools = new GeomSelectionTools();
1239 return myGeomSelectionTools;
1242 QString NETGENPluginGUI_HypothesisCreator::caption() const
1244 return tr( myIs2D ? "NETGEN_2D_TITLE" : "NETGEN_3D_TITLE");
1247 QPixmap NETGENPluginGUI_HypothesisCreator::icon() const
1249 QString hypIconName = tr( myIs2D ?
1250 "ICON_DLG_NETGEN_PARAMETERS_2D" :
1251 "ICON_DLG_NETGEN_PARAMETERS");
1252 return SUIT_Session::session()->resourceMgr()->loadPixmap( "NETGENPlugin", hypIconName );
1255 QString NETGENPluginGUI_HypothesisCreator::type() const
1257 return tr( myIs2D ? "NETGEN_2D_HYPOTHESIS" : "NETGEN_3D_HYPOTHESIS");
1260 QString NETGENPluginGUI_HypothesisCreator::helpPage() const
1262 return "netgen_2d_3d_hypo_page.html";