1 // Copyright (C) 2007-2019 CEA/DEN, EDF R&D, 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
22 // File : StdMeshersGUI_StdHypothesisCreator.cxx
23 // Author : Alexander SOLOVYOV, Open CASCADE S.A.S.
26 #include "StdMeshersGUI_StdHypothesisCreator.h"
29 #include <SMESHGUI_SpinBox.h>
30 #include <SMESHGUI_HypothesesUtils.h>
31 #include <SMESHGUI_Utils.h>
32 #include <SMESHGUI_GEOMGenUtils.h>
33 #include <SMESH_TypeFilter.hxx>
34 #include <SMESH_NumberFilter.hxx>
36 #include "StdMeshersGUI_FixedPointsParamWdg.h"
37 #include "StdMeshersGUI_LayerDistributionParamWdg.h"
38 #include "StdMeshersGUI_ObjectReferenceParamWdg.h"
39 #include "StdMeshersGUI_PropagationHelperWdg.h"
40 #include "StdMeshersGUI_QuadrangleParamWdg.h"
41 #include "StdMeshersGUI_RadioButtonsGrpWdg.h"
42 #include "StdMeshersGUI_NameCheckableGrpWdg.h"
43 #include "StdMeshersGUI_SubShapeSelectorWdg.h"
45 #include <SALOMEDSClient_Study.hxx>
47 #include <GEOM_wrap.hxx>
49 // SALOME GUI includes
50 #include <SUIT_MessageBox.h>
51 #include <SUIT_ResourceMgr.h>
52 #include <SalomeApp_IntSpinBox.h>
55 #include <SALOMEconfig.h>
56 #include CORBA_SERVER_HEADER(SMESH_BasicHypothesis)
57 #include CORBA_SERVER_HEADER(SMESH_Mesh)
58 #include CORBA_SERVER_HEADER(SMESH_Group)
61 #include <QHBoxLayout>
65 #include <QButtonGroup>
67 const double VALUE_MAX = 1.0e+15, // COORD_MAX
68 VALUE_MAX_2 = VALUE_MAX * VALUE_MAX,
69 VALUE_MAX_3 = VALUE_MAX_2 * VALUE_MAX,
70 VALUE_SMALL = 1.0e-15,
71 VALUE_SMALL_2 = VALUE_SMALL * VALUE_SMALL,
72 VALUE_SMALL_3 = VALUE_SMALL_2 * VALUE_SMALL;
74 //================================================================================
77 * \param type - hypothesis type
79 //================================================================================
81 StdMeshersGUI_StdHypothesisCreator::StdMeshersGUI_StdHypothesisCreator( const QString& type )
82 : SMESHGUI_GenericHypothesisCreator( type ), myHelperWidget( 0 )
86 //================================================================================
90 //================================================================================
92 StdMeshersGUI_StdHypothesisCreator::~StdMeshersGUI_StdHypothesisCreator()
96 //================================================================================
98 * \brief Return widget for i-th hypothesis parameter (got from myParamWidgets)
99 * \param i - index of hypothesis parameter
100 * \retval QWidget* - found widget
102 //================================================================================
104 QWidget* StdMeshersGUI_StdHypothesisCreator::getWidgetForParam( int i ) const
107 if ( isCreation() ) ++i; // skip widget of 'name' parameter
109 if ( i < myCustomWidgets.count() ) {
110 QList<QWidget*>::const_iterator anIt = myCustomWidgets.begin();
111 QList<QWidget*>::const_iterator aLast = myCustomWidgets.end();
112 for ( int j = 0 ; !w && anIt != aLast; ++anIt, ++j )
117 // list has no at() const, so we iterate
118 QList<QWidget*>::const_iterator anIt = widgets().begin();
119 QList<QWidget*>::const_iterator aLast = widgets().end();
120 for( int j = 0; !w && anIt!=aLast; anIt++, ++j ) {
128 //================================================================================
130 * \brief Allow modifying myCustomWidgets in const methods
131 * \retval ListOfWidgets* - non-const pointer to myCustomWidgets
133 //================================================================================
135 StdMeshersGUI_StdHypothesisCreator::ListOfWidgets*
136 StdMeshersGUI_StdHypothesisCreator::customWidgets() const
138 return const_cast< ListOfWidgets* >( & myCustomWidgets );
141 //================================================================================
143 * \brief Builds dlg layout
144 * \retval QFrame* - the built widget
146 //================================================================================
148 QFrame* StdMeshersGUI_StdHypothesisCreator::buildFrame()
150 return buildStdFrame();
153 //================================================================================
155 * \brief Initialise parameter values in controls
157 //================================================================================
159 void StdMeshersGUI_StdHypothesisCreator::retrieveParams() const
161 // buildStdFrame() sets values itself calling stdParams()
163 if ( hypType().startsWith("ProjectionSource" ))
165 // we use this method to connect depending custom widgets
166 StdMeshersGUI_ObjectReferenceParamWdg* widgetToActivate = 0;
167 ListOfWidgets::const_iterator anIt = myCustomWidgets.begin();
168 for ( ; anIt != myCustomWidgets.end(); anIt++)
170 if ( *anIt && (*anIt)->inherits("StdMeshersGUI_ObjectReferenceParamWdg"))
172 StdMeshersGUI_ObjectReferenceParamWdg * w1 =
173 ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
174 ListOfWidgets::const_iterator anIt2 = anIt;
175 for ( ++anIt2; anIt2 != myCustomWidgets.end(); anIt2++)
176 if ( *anIt2 && (*anIt2)->inherits("StdMeshersGUI_ObjectReferenceParamWdg"))
178 StdMeshersGUI_ObjectReferenceParamWdg * w2 =
179 ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt2 );
180 w1->AvoidSimultaneousSelection( w2 );
182 if ( !widgetToActivate )
183 widgetToActivate = w1;
186 if ( widgetToActivate )
187 widgetToActivate->activateSelection();
191 dlg()->setMinimumSize( dlg()->minimumSizeHint().width(), dlg()->minimumSizeHint().height() );
196 //================================================================================
198 * \brief Widget: slider with left and right labels
200 //================================================================================
202 class TDoubleSliderWith2Labels: public QWidget
205 TDoubleSliderWith2Labels( const QString& leftLabel, const QString& rightLabel,
206 const double initValue, const double bottom,
207 const double top , const double precision,
208 QWidget * parent=0 , const char * name=0 )
209 :QWidget(parent), _bottom(bottom), _precision(precision)
213 QHBoxLayout* aHBoxL = new QHBoxLayout(this);
215 if ( !leftLabel.isEmpty() ) {
216 QLabel* aLeftLabel = new QLabel( this );
217 aLeftLabel->setText( leftLabel );
218 aHBoxL->addWidget( aLeftLabel );
221 _slider = new QSlider( Qt::Horizontal, this );
222 _slider->setRange( 0, toInt( top ));
223 _slider->setValue( toInt( initValue ));
224 aHBoxL->addWidget( _slider );
226 if ( !rightLabel.isEmpty() ) {
227 QLabel* aRightLabel = new QLabel( this );
228 aRightLabel->setText( rightLabel );
229 aHBoxL->addWidget( aRightLabel );
234 double value() const { return _bottom + _slider->value() * _precision; }
235 QSlider * getSlider() const { return _slider; }
236 int toInt( double val ) const { return (int) ceil(( val - _bottom ) / _precision ); }
238 double _bottom, _precision;
242 //================================================================================
244 * \brief Retrieve GEOM_Object held by widget
246 //================================================================================
248 inline GEOM::GEOM_Object_var geomFromWdg(const QWidget* wdg)
250 const StdMeshersGUI_ObjectReferenceParamWdg * objRefWdg =
251 dynamic_cast<const StdMeshersGUI_ObjectReferenceParamWdg*>( wdg );
253 return objRefWdg->GetObject< GEOM::GEOM_Object >();
255 return GEOM::GEOM_Object::_nil();
257 //================================================================================
259 * \brief Retrieve SMESH_Mesh held by widget
261 //================================================================================
263 inline SMESH::SMESH_Mesh_var meshFromWdg(const QWidget* wdg)
265 const StdMeshersGUI_ObjectReferenceParamWdg * objRefWdg =
266 dynamic_cast<const StdMeshersGUI_ObjectReferenceParamWdg*>( wdg );
268 return objRefWdg->GetObject< SMESH::SMESH_Mesh >();
270 return SMESH::SMESH_Mesh::_nil();
272 //================================================================================
274 * \brief Retrieve SMESH_Mesh held by widget
276 //================================================================================
278 inline SMESH::ListOfGroups_var groupsFromWdg(const QWidget* wdg)
280 SMESH::ListOfGroups_var groups = new SMESH::ListOfGroups;
281 const StdMeshersGUI_ObjectReferenceParamWdg * objRefWdg =
282 dynamic_cast<const StdMeshersGUI_ObjectReferenceParamWdg*>( wdg );
285 groups->length( objRefWdg->NbObjects() );
286 for ( unsigned i = 0; i < groups->length(); ++i )
287 groups[i] = objRefWdg->GetObject< SMESH::SMESH_GroupBase >(i);
291 //================================================================================
293 * \brief creates a filter for selection of shapes of given dimension
294 * \param dim - dimension
295 * \param subShapeType - required type of sub-shapes, number of which must be \a nbSubShapes
296 * \param nbSubShapes - number of sub-shapes of given type
297 * \param closed - required closeness flag of a shape
298 * \retval SUIT_SelectionFilter* - created filter
300 //================================================================================
302 SUIT_SelectionFilter* filterForShapeOfDim(const int dim,
303 TopAbs_ShapeEnum subShapeType = TopAbs_SHAPE,
304 const int nbSubShapes = 0,
307 TColStd_MapOfInteger shapeTypes;
309 case 0: shapeTypes.Add( TopAbs_VERTEX ); break;
311 if ( subShapeType == TopAbs_SHAPE ) subShapeType = TopAbs_EDGE;
312 shapeTypes.Add( TopAbs_EDGE );
313 shapeTypes.Add( TopAbs_COMPOUND ); // for a group
316 if ( subShapeType == TopAbs_SHAPE ) subShapeType = TopAbs_FACE;
317 shapeTypes.Add( TopAbs_FACE );
318 shapeTypes.Add( TopAbs_COMPOUND ); // for a group
321 shapeTypes.Add( TopAbs_SHELL );
322 shapeTypes.Add( TopAbs_SOLID );
323 shapeTypes.Add( TopAbs_COMPSOLID );
324 shapeTypes.Add( TopAbs_COMPOUND );
327 return new SMESH_NumberFilter("GEOM", subShapeType, nbSubShapes,
328 shapeTypes, GEOM::GEOM_Object::_nil(), closed);
331 //================================================================================
333 * \brief Create a widget for object selection
334 * \param object - initial object
335 * \param filter - selection filter
336 * \retval QWidget* - created widget
338 //================================================================================
340 QWidget* newObjRefParamWdg( SUIT_SelectionFilter* filter,
341 CORBA::Object_var object)
343 StdMeshersGUI_ObjectReferenceParamWdg* w =
344 new StdMeshersGUI_ObjectReferenceParamWdg( filter, 0);
345 w->SetObject( object.in() );
348 QWidget* newObjRefParamWdg( SUIT_SelectionFilter* filter,
349 SMESH::string_array_var& objEntries)
351 StdMeshersGUI_ObjectReferenceParamWdg* w =
352 new StdMeshersGUI_ObjectReferenceParamWdg( filter, 0, /*multiSel=*/true);
353 //RNV: Firstly, activate selection, then set objects
354 w->activateSelection();
355 w->SetObjects( objEntries );
359 //================================================================================
361 * \brief calls deactivateSelection() for StdMeshersGUI_ObjectReferenceParamWdg
362 * \param widgetList - list of widgets
364 //================================================================================
366 void deactivateObjRefParamWdg( QList<QWidget*>* widgetList )
368 StdMeshersGUI_ObjectReferenceParamWdg* w = 0;
369 QList<QWidget*>::iterator anIt = widgetList->begin();
370 QList<QWidget*>::iterator aLast = widgetList->end();
371 for ( ; anIt != aLast; anIt++ ) {
372 if ( (*anIt) && (*anIt)->inherits( "StdMeshersGUI_ObjectReferenceParamWdg" ))
374 w = (StdMeshersGUI_ObjectReferenceParamWdg* )( *anIt );
375 w->deactivateSelection();
381 //================================================================================
383 * \brief Check parameter values before accept()
384 * \retval bool - true if OK
386 //================================================================================
388 bool StdMeshersGUI_StdHypothesisCreator::checkParams( QString& msg ) const
390 if( !SMESHGUI_GenericHypothesisCreator::checkParams( msg ) )
393 // check if object reference parameter is set, as it has no default value
395 if ( hypType().startsWith("ProjectionSource" ))
397 StdMeshersGUI_ObjectReferenceParamWdg* w =
398 widget< StdMeshersGUI_ObjectReferenceParamWdg >( 0 );
399 ok = ( w->IsObjectSelected() );
400 if ( !ok ) w->SetObject( CORBA::Object::_nil() );
401 int nbAssocVert = ( hypType() == "ProjectionSource1D" ? 1 : 2 );
402 int nbNonEmptyAssoc = 0;
403 for ( int i = 0; ok && i < nbAssocVert*2; i += 2)
406 StdMeshersGUI_ObjectReferenceParamWdg* w1 =
407 widget< StdMeshersGUI_ObjectReferenceParamWdg >( i+2 );
408 StdMeshersGUI_ObjectReferenceParamWdg* w2 =
409 widget< StdMeshersGUI_ObjectReferenceParamWdg >( i+3 );
410 srcV = w1->GetValue();
411 tgtV = w2->GetValue();
412 ok = (( srcV.isEmpty() && tgtV.isEmpty() ) ||
413 ( !srcV.isEmpty() && !tgtV.isEmpty() /*&& srcV != tgtV*/ ));
415 w1->SetObject( CORBA::Object::_nil() );
416 w2->SetObject( CORBA::Object::_nil() );
418 nbNonEmptyAssoc += !srcV.isEmpty();
420 if ( ok && nbNonEmptyAssoc == 1 && nbAssocVert == 2 )
422 // only one pair of VERTEXes is given for a FACE,
423 // then the FACE must have only one VERTEX
424 GEOM::GEOM_Object_var face = w->GetObject< GEOM::GEOM_Object >();
426 GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen();
427 _PTR(Study) aStudy = SMESH::getStudy();
428 GEOM::GEOM_IShapesOperations_wrap shapeOp;
429 if ( !geomGen->_is_nil() && aStudy )
430 shapeOp = geomGen->GetIShapesOperations();
431 if ( !shapeOp->_is_nil() )
433 GEOM::ListOfLong_var vertices =
434 shapeOp->GetAllSubShapesIDs (face, GEOM::VERTEX, /*isSorted=*/false);
435 ok = ( vertices->length() == 1 );
438 // Uninstall filters of StdMeshersGUI_ObjectReferenceParamWdg
440 deactivateObjRefParamWdg( customWidgets() );
442 else if ( hypType().startsWith("ImportSource" ))
444 StdMeshersGUI_ObjectReferenceParamWdg* w =
445 widget< StdMeshersGUI_ObjectReferenceParamWdg >( 0 );
446 ok = ( w->IsObjectSelected() );
448 else if ( hypType() == "LayerDistribution" || hypType() == "LayerDistribution2D" )
450 StdMeshersGUI_LayerDistributionParamWdg* w =
451 widget< StdMeshersGUI_LayerDistributionParamWdg >( 0 );
452 ok = ( w && w->IsOk() );
458 //================================================================================
460 * \brief Store params from GUI controls to a hypothesis
461 * \retval QString - text representation of parameters
463 //================================================================================
465 QString StdMeshersGUI_StdHypothesisCreator::storeParams() const
467 ListOfStdParams params;
468 bool res = getStdParamFromDlg( params );
471 SMESH::SetName( SMESH::FindSObject( hypothesis() ), params[0].myValue.toString().toUtf8().data() );
472 params.erase( params.begin() );
475 QString valueStr = stdParamValues( params );
476 //QStringList aVariablesList = getVariablesFromDlg();
478 if( res && !params.isEmpty() )
480 if( hypType()=="LocalLength" )
482 StdMeshers::StdMeshers_LocalLength_var h =
483 StdMeshers::StdMeshers_LocalLength::_narrow( hypothesis() );
485 h->SetVarParameter( params[0].text(), "SetLength" );
486 h->SetLength( params[0].myValue.toDouble() );
487 h->SetVarParameter( params[1].text(), "SetPrecision" );
488 h->SetPrecision( params[1].myValue.toDouble() );
490 else if( hypType()=="MaxLength" )
492 StdMeshers::StdMeshers_MaxLength_var h =
493 StdMeshers::StdMeshers_MaxLength::_narrow( hypothesis() );
495 h->SetVarParameter( params[0].text(), "SetLength" );
496 h->SetLength( params[0].myValue.toDouble() );
497 h->SetUsePreestimatedLength( widget< QCheckBox >( 1 )->isChecked() );
498 if ( !h->HavePreestimatedLength() && !h->_is_equivalent( initParamsHypothesis() )) {
499 StdMeshers::StdMeshers_MaxLength_var hInit =
500 StdMeshers::StdMeshers_MaxLength::_narrow( initParamsHypothesis() );
501 h->SetPreestimatedLength( hInit->GetPreestimatedLength() );
504 else if( hypType()=="SegmentLengthAroundVertex" )
506 StdMeshers::StdMeshers_SegmentLengthAroundVertex_var h =
507 StdMeshers::StdMeshers_SegmentLengthAroundVertex::_narrow( hypothesis() );
509 h->SetVarParameter( params[0].text(), "SetLength" );
510 h->SetLength( params[0].myValue.toDouble() );
512 else if( hypType()=="Arithmetic1D" )
514 StdMeshers::StdMeshers_Arithmetic1D_var h =
515 StdMeshers::StdMeshers_Arithmetic1D::_narrow( hypothesis() );
517 StdMeshersGUI_SubShapeSelectorWdg* w =
518 widget< StdMeshersGUI_SubShapeSelectorWdg >( 2 );
520 h->SetVarParameter( params[0].text(), "SetStartLength" );
521 h->SetStartLength( params[0].myValue.toDouble() );
522 h->SetVarParameter( params[1].text(), "SetEndLength" );
523 h->SetEndLength( params[1].myValue.toDouble() );
525 h->SetReversedEdges( w->GetListOfIDs() );
526 h->SetObjectEntry( w->GetMainShapeEntry() );
529 else if( hypType()=="GeometricProgression" )
531 StdMeshers::StdMeshers_Geometric1D_var h =
532 StdMeshers::StdMeshers_Geometric1D::_narrow( hypothesis() );
534 StdMeshersGUI_SubShapeSelectorWdg* w =
535 widget< StdMeshersGUI_SubShapeSelectorWdg >( 2 );
537 h->SetVarParameter( params[0].text(), "SetStartLength" );
538 h->SetStartLength( params[0].myValue.toDouble() );
539 h->SetVarParameter( params[1].text(), "SetCommonRatio" );
540 h->SetCommonRatio( params[1].myValue.toDouble() );
542 h->SetReversedEdges( w->GetListOfIDs() );
543 h->SetObjectEntry( w->GetMainShapeEntry() );
546 else if( hypType()=="FixedPoints1D" )
548 StdMeshers::StdMeshers_FixedPoints1D_var h =
549 StdMeshers::StdMeshers_FixedPoints1D::_narrow( hypothesis() );
551 StdMeshersGUI_FixedPointsParamWdg* w1 =
552 widget< StdMeshersGUI_FixedPointsParamWdg >( 0 );
554 StdMeshersGUI_SubShapeSelectorWdg* w2 =
555 widget< StdMeshersGUI_SubShapeSelectorWdg >( 1 );
558 h->SetPoints( w1->GetListOfPoints() );
559 h->SetNbSegments( w1->GetListOfSegments() );
562 h->SetReversedEdges( w2->GetListOfIDs() );
563 h->SetObjectEntry( w2->GetMainShapeEntry() );
566 else if( hypType()=="MaxElementArea" )
568 StdMeshers::StdMeshers_MaxElementArea_var h =
569 StdMeshers::StdMeshers_MaxElementArea::_narrow( hypothesis() );
570 h->SetVarParameter( params[0].text(), "SetMaxElementArea" );
571 h->SetMaxElementArea( params[0].myValue.toDouble() );
573 else if( hypType()=="MaxElementVolume" )
575 StdMeshers::StdMeshers_MaxElementVolume_var h =
576 StdMeshers::StdMeshers_MaxElementVolume::_narrow( hypothesis() );
578 h->SetVarParameter( params[0].text(), "SetMaxElementVolume" );
579 h->SetMaxElementVolume( params[0].myValue.toDouble() );
581 else if( hypType()=="StartEndLength" )
583 StdMeshers::StdMeshers_StartEndLength_var h =
584 StdMeshers::StdMeshers_StartEndLength::_narrow( hypothesis() );
586 StdMeshersGUI_SubShapeSelectorWdg* w =
587 widget< StdMeshersGUI_SubShapeSelectorWdg >( 2 );
589 h->SetVarParameter( params[0].text(), "SetStartLength" );
590 h->SetStartLength( params[0].myValue.toDouble() );
591 h->SetVarParameter( params[1].text(), "SetEndLength" );
592 h->SetEndLength( params[1].myValue.toDouble() );
594 h->SetReversedEdges( w->GetListOfIDs() );
595 h->SetObjectEntry( w->GetMainShapeEntry() );
598 else if( hypType()=="Deflection1D" )
600 StdMeshers::StdMeshers_Deflection1D_var h =
601 StdMeshers::StdMeshers_Deflection1D::_narrow( hypothesis() );
602 h->SetVarParameter( params[0].text(), "SetDeflection" );
603 h->SetDeflection( params[0].myValue.toDouble() );
605 else if( hypType()=="Adaptive1D" )
607 StdMeshers::StdMeshers_Adaptive1D_var h =
608 StdMeshers::StdMeshers_Adaptive1D::_narrow( hypothesis() );
609 h->SetVarParameter( params[0].text(), "SetMinSize" );
610 h->SetMinSize( params[0].myValue.toDouble() );
611 h->SetVarParameter( params[0].text(), "SetMaxSize" );
612 h->SetMaxSize( params[1].myValue.toDouble() );
613 h->SetVarParameter( params[0].text(), "SetDeflection" );
614 h->SetDeflection( params[2].myValue.toDouble() );
616 else if( hypType()=="AutomaticLength" )
618 StdMeshers::StdMeshers_AutomaticLength_var h =
619 StdMeshers::StdMeshers_AutomaticLength::_narrow( hypothesis() );
621 h->SetVarParameter( params[0].text(), "SetFineness" );
622 h->SetFineness( params[0].myValue.toDouble() );
624 else if( hypType()=="NumberOfLayers" )
626 StdMeshers::StdMeshers_NumberOfLayers_var h =
627 StdMeshers::StdMeshers_NumberOfLayers::_narrow( hypothesis() );
629 h->SetVarParameter( params[0].text(), "SetNumberOfLayers" );
630 h->SetNumberOfLayers( params[0].myValue.toInt() );
632 else if( hypType()=="LayerDistribution" )
634 StdMeshers::StdMeshers_LayerDistribution_var h =
635 StdMeshers::StdMeshers_LayerDistribution::_narrow( hypothesis() );
636 StdMeshersGUI_LayerDistributionParamWdg* w =
637 widget< StdMeshersGUI_LayerDistributionParamWdg >( 0 );
639 h->SetLayerDistribution( w->GetHypothesis() );
641 else if( hypType()=="NumberOfLayers2D" )
643 StdMeshers::StdMeshers_NumberOfLayers2D_var h =
644 StdMeshers::StdMeshers_NumberOfLayers2D::_narrow( hypothesis() );
646 h->SetVarParameter( params[0].text(), "SetNumberOfLayers" );
647 h->SetNumberOfLayers( params[0].myValue.toInt() );
649 else if( hypType()=="LayerDistribution2D" )
651 StdMeshers::StdMeshers_LayerDistribution2D_var h =
652 StdMeshers::StdMeshers_LayerDistribution2D::_narrow( hypothesis() );
653 StdMeshersGUI_LayerDistributionParamWdg* w =
654 widget< StdMeshersGUI_LayerDistributionParamWdg >( 0 );
656 h->SetLayerDistribution( w->GetHypothesis() );
658 else if( hypType()=="ProjectionSource1D" )
660 StdMeshers::StdMeshers_ProjectionSource1D_var h =
661 StdMeshers::StdMeshers_ProjectionSource1D::_narrow( hypothesis() );
663 h->SetSourceEdge ( geomFromWdg ( getWidgetForParam( 0 )));
664 h->SetSourceMesh ( meshFromWdg ( getWidgetForParam( 1 )));
665 h->SetVertexAssociation( geomFromWdg ( getWidgetForParam( 2 )),
666 geomFromWdg ( getWidgetForParam( 3 )));
668 else if( hypType()=="ProjectionSource2D" )
670 StdMeshers::StdMeshers_ProjectionSource2D_var h =
671 StdMeshers::StdMeshers_ProjectionSource2D::_narrow( hypothesis() );
673 h->SetSourceFace ( geomFromWdg ( getWidgetForParam( 0 )));
674 h->SetSourceMesh ( meshFromWdg ( getWidgetForParam( 1 )));
675 h->SetVertexAssociation( geomFromWdg ( getWidgetForParam( 2 )), // src1
676 geomFromWdg ( getWidgetForParam( 4 )), // src2
677 geomFromWdg ( getWidgetForParam( 3 )), // tgt1
678 geomFromWdg ( getWidgetForParam( 5 ))); // tgt2
680 else if( hypType()=="ProjectionSource3D" )
682 StdMeshers::StdMeshers_ProjectionSource3D_var h =
683 StdMeshers::StdMeshers_ProjectionSource3D::_narrow( hypothesis() );
685 h->SetSource3DShape ( geomFromWdg ( getWidgetForParam( 0 )));
686 h->SetSourceMesh ( meshFromWdg ( getWidgetForParam( 1 )));
687 h->SetVertexAssociation( geomFromWdg ( getWidgetForParam( 2 )), // src1
688 geomFromWdg ( getWidgetForParam( 4 )), // src2
689 geomFromWdg ( getWidgetForParam( 3 )), // tgt1
690 geomFromWdg ( getWidgetForParam( 5 ))); // tgt2
692 else if( hypType()=="ImportSource1D" )
694 StdMeshers::StdMeshers_ImportSource1D_var h =
695 StdMeshers::StdMeshers_ImportSource1D::_narrow( hypothesis() );
697 SMESH::ListOfGroups_var groups = groupsFromWdg( getWidgetForParam( 0 ));
698 h->SetSourceEdges( groups.in() );
699 QCheckBox* toCopyMesh = widget< QCheckBox >( 1 );
700 QCheckBox* toCopyGroups = widget< QCheckBox >( 2 );
701 h->SetCopySourceMesh( toCopyMesh->isChecked(), toCopyGroups->isChecked());
703 else if( hypType()=="ImportSource2D" )
705 StdMeshers::StdMeshers_ImportSource2D_var h =
706 StdMeshers::StdMeshers_ImportSource2D::_narrow( hypothesis() );
708 SMESH::ListOfGroups_var groups = groupsFromWdg( getWidgetForParam( 0 ));
709 h->SetSourceFaces( groups.in() );
710 QCheckBox* toCopyMesh = widget< QCheckBox >( 1 );
711 QCheckBox* toCopyGroups = widget< QCheckBox >( 2 );
712 h->SetCopySourceMesh( toCopyMesh->isChecked(), toCopyGroups->isChecked());
714 else if( hypType()=="ViscousLayers" )
716 StdMeshers::StdMeshers_ViscousLayers_var h =
717 StdMeshers::StdMeshers_ViscousLayers::_narrow( hypothesis() );
719 h->SetVarParameter ( params[0].text(), "SetTotalThickness" );
720 h->SetTotalThickness( params[0].myValue.toDouble() );
721 h->SetVarParameter ( params[1].text(), "SetNumberLayers" );
722 h->SetNumberLayers ( params[1].myValue.toInt() );
723 h->SetVarParameter ( params[2].text(), "SetStretchFactor" );
724 h->SetStretchFactor ( params[2].myValue.toDouble() );
725 h->SetMethod (( StdMeshers::VLExtrusionMethod ) params[3].myValue.toInt() );
727 if ( StdMeshersGUI_SubShapeSelectorWdg* idsWg =
728 widget< StdMeshersGUI_SubShapeSelectorWdg >( 5 ))
730 h->SetFaces( idsWg->GetListOfIDs(), params[4].myValue.toInt() );
733 if ( StdMeshersGUI_NameCheckableGrpWdg* nameWg =
734 widget< StdMeshersGUI_NameCheckableGrpWdg >( 6 ))
736 h->SetGroupName( nameWg->getName().toUtf8().data() );
739 else if( hypType()=="ViscousLayers2D" )
741 StdMeshers::StdMeshers_ViscousLayers2D_var h =
742 StdMeshers::StdMeshers_ViscousLayers2D::_narrow( hypothesis() );
744 h->SetVarParameter ( params[0].text(), "SetTotalThickness" );
745 h->SetTotalThickness( params[0].myValue.toDouble() );
746 h->SetVarParameter ( params[1].text(), "SetNumberLayers" );
747 h->SetNumberLayers ( params[1].myValue.toInt() );
748 h->SetVarParameter ( params[2].text(), "SetStretchFactor" );
749 h->SetStretchFactor ( params[2].myValue.toDouble() );
751 if ( StdMeshersGUI_SubShapeSelectorWdg* idsWg =
752 widget< StdMeshersGUI_SubShapeSelectorWdg >( 4 ))
754 h->SetEdges( idsWg->GetListOfIDs(), params[3].myValue.toInt() );
757 if ( StdMeshersGUI_NameCheckableGrpWdg* nameWg =
758 widget< StdMeshersGUI_NameCheckableGrpWdg >( 5 ))
760 h->SetGroupName( nameWg->getName().toUtf8().data() );
763 // else if( hypType()=="QuadrangleParams" )
765 // StdMeshers::StdMeshers_QuadrangleParams_var h =
766 // StdMeshers::StdMeshers_QuadrangleParams::_narrow( hypothesis() );
767 // StdMeshersGUI_SubShapeSelectorWdg* w1 =
768 // widget< StdMeshersGUI_SubShapeSelectorWdg >( 0 );
769 // StdMeshersGUI_QuadrangleParamWdg* w2 =
770 // widget< StdMeshersGUI_QuadrangleParamWdg >( 1 );
772 // if (w1->GetListSize() > 0) {
773 // h->SetTriaVertex(w1->GetListOfIDs()[0]); // getlist must be called once
774 // const char * entry = w1->GetMainShapeEntry();
775 // h->SetObjectEntry(entry);
777 // h->SetQuadType(StdMeshers::QuadType(w2->GetType()));
784 //================================================================================
786 * \brief Return parameter values as SMESHGUI_GenericHypothesisCreator::StdParam
787 * \param p - list of parameters
788 * \retval bool - success flag
790 * Is called from SMESHGUI_GenericHypothesisCreator::buildStdFrame().
791 * Parameters will be shown using "standard" controls:
792 * Int by QtxIntSpinBox
793 * Double by SMESHGUI_SpinBox
794 * String by QLineEdit
795 * getCustomWidget() allows to redefine control for a parameter
797 //================================================================================
799 bool StdMeshersGUI_StdHypothesisCreator::stdParams( ListOfStdParams& p ) const
802 SMESHGUI_GenericHypothesisCreator::StdParam item;
805 customWidgets()->clear();
808 HypothesisData* data = SMESH::GetHypothesisData( hypType() );
809 item.myName = tr( "SMESH_NAME" );
810 item.myValue = data ? hypName() : QString();
812 customWidgets()->append(0);
815 SMESH::SMESH_Hypothesis_var hyp = initParamsHypothesis();
816 //SMESH::ListOfParameters_var aParameters = hyp->GetLastParameters();
818 if( hypType()=="LocalLength" )
820 StdMeshers::StdMeshers_LocalLength_var h =
821 StdMeshers::StdMeshers_LocalLength::_narrow( hyp );
823 item.myName = tr("SMESH_LOCAL_LENGTH_PARAM");
824 if(!initVariableName( hyp, item, "SetLength"))
825 item.myValue = h->GetLength();
828 item.myName = tr("SMESH_LOCAL_LENGTH_PRECISION");
829 if(!initVariableName( hyp, item, "SetPrecision"))
830 item.myValue = h->GetPrecision();
833 else if( hypType()=="MaxLength" )
835 StdMeshers::StdMeshers_MaxLength_var h =
836 StdMeshers::StdMeshers_MaxLength::_narrow( hyp );
837 // try to set a right preestimated length to edited hypothesis
838 bool noPreestimatedAtEdition = false;
839 if ( !isCreation() ) {
840 StdMeshers::StdMeshers_MaxLength_var initHyp =
841 StdMeshers::StdMeshers_MaxLength::_narrow( initParamsHypothesis(true) );
842 noPreestimatedAtEdition =
843 ( initHyp->_is_nil() || !initHyp->HavePreestimatedLength() );
844 if ( !noPreestimatedAtEdition )
845 h->SetPreestimatedLength( initHyp->GetPreestimatedLength() );
848 item.myName = tr("SMESH_LOCAL_LENGTH_PARAM");
849 if(!initVariableName( hyp, item, "SetLength"))
850 item.myValue = h->GetLength();
852 customWidgets()->append(0);
854 item.myName = tr("SMESH_USE_PREESTIMATED_LENGTH");
856 QCheckBox* aQCheckBox = new QCheckBox(dlg());
857 if ( h->HavePreestimatedLength() ) {
858 aQCheckBox->setChecked( h->GetUsePreestimatedLength() );
859 connect( aQCheckBox, SIGNAL( stateChanged(int) ), this, SLOT( onValueChanged() ) );
862 aQCheckBox->setChecked( false );
863 aQCheckBox->setEnabled( false );
865 customWidgets()->append( aQCheckBox );
867 else if( hypType()=="SegmentLengthAroundVertex" )
869 StdMeshers::StdMeshers_SegmentLengthAroundVertex_var h =
870 StdMeshers::StdMeshers_SegmentLengthAroundVertex::_narrow( hyp );
872 item.myName = tr("SMESH_LOCAL_LENGTH_PARAM");
873 if(!initVariableName( hyp, item, "SetLength"))
874 item.myValue = h->GetLength();
878 else if( hypType()=="Arithmetic1D" )
880 StdMeshers::StdMeshers_Arithmetic1D_var h =
881 StdMeshers::StdMeshers_Arithmetic1D::_narrow( hyp );
883 item.myName = tr( "SMESH_START_LENGTH_PARAM" );
884 if(!initVariableName( hyp, item, "SetStartLength" ))
885 item.myValue = h->GetLength( true );
888 customWidgets()->append (0);
890 item.myName = tr( "SMESH_END_LENGTH_PARAM" );
891 if(!initVariableName( hyp, item, "SetEndLength" ))
892 item.myValue = h->GetLength( false );
895 customWidgets()->append (0);
897 item.myName = tr( "SMESH_REVERSED_EDGES" );
900 customWidgets()->append ( makeReverseEdgesWdg( h->GetReversedEdges(), h->GetObjectEntry() ));
903 else if( hypType()=="GeometricProgression" )
905 StdMeshers::StdMeshers_Geometric1D_var h =
906 StdMeshers::StdMeshers_Geometric1D::_narrow( hyp );
908 item.myName = tr( "SMESH_START_LENGTH_PARAM" );
909 if(!initVariableName( hyp, item, "SetStartLength" ))
910 item.myValue = h->GetStartLength();
913 customWidgets()->append (0);
915 item.myName = tr( "SMESH_COMMON_RATIO" );
916 if(!initVariableName( hyp, item, "SetCommonRatio" ))
917 item.myValue = h->GetCommonRatio();
920 customWidgets()->append (0);
922 item.myName = tr( "SMESH_REVERSED_EDGES" );
925 customWidgets()->append ( makeReverseEdgesWdg( h->GetReversedEdges(), h->GetObjectEntry() ));
928 else if( hypType()=="FixedPoints1D" )
930 StdMeshers::StdMeshers_FixedPoints1D_var h =
931 StdMeshers::StdMeshers_FixedPoints1D::_narrow( hyp );
933 item.myName = tr( "SMESH_FIXED_POINTS" );
936 StdMeshersGUI_FixedPointsParamWdg* aFixedPointsWidget =
937 new StdMeshersGUI_FixedPointsParamWdg();
939 if ( !isCreation() ) {
940 aFixedPointsWidget->SetListOfPoints( h->GetPoints() );
941 aFixedPointsWidget->SetListOfSegments( h->GetNbSegments() );
943 customWidgets()->append( aFixedPointsWidget );
945 item.myName = tr( "SMESH_REVERSED_EDGES" );
948 customWidgets()->append ( makeReverseEdgesWdg( h->GetReversedEdges(), h->GetObjectEntry() ));
952 else if( hypType()=="MaxElementArea" )
954 StdMeshers::StdMeshers_MaxElementArea_var h =
955 StdMeshers::StdMeshers_MaxElementArea::_narrow( hyp );
957 item.myName = tr( "SMESH_MAX_ELEMENT_AREA_PARAM" );
958 if(!initVariableName( hyp, item, "SetMaxElementArea" ))
959 item.myValue = h->GetMaxElementArea();
963 else if( hypType()=="MaxElementVolume" )
965 StdMeshers::StdMeshers_MaxElementVolume_var h =
966 StdMeshers::StdMeshers_MaxElementVolume::_narrow( hyp );
968 item.myName = tr( "SMESH_MAX_ELEMENT_VOLUME_PARAM" );
969 if(!initVariableName( hyp, item, "SetMaxElementVolume" ))
970 item.myValue = h->GetMaxElementVolume();
973 else if( hypType()=="StartEndLength" )
975 StdMeshers::StdMeshers_StartEndLength_var h =
976 StdMeshers::StdMeshers_StartEndLength::_narrow( hyp );
978 item.myName = tr( "SMESH_START_LENGTH_PARAM" );
980 if(!initVariableName( hyp, item, "SetStartLength" ))
981 item.myValue = h->GetLength( true );
983 customWidgets()->append(0);
985 item.myName = tr( "SMESH_END_LENGTH_PARAM" );
986 if(!initVariableName( hyp, item, "SetEndLength" ))
987 item.myValue = h->GetLength( false );
989 customWidgets()->append(0);
991 item.myName = tr( "SMESH_REVERSED_EDGES" );
994 customWidgets()->append ( makeReverseEdgesWdg( h->GetReversedEdges(), h->GetObjectEntry() ));
996 else if( hypType()=="Deflection1D" )
998 StdMeshers::StdMeshers_Deflection1D_var h =
999 StdMeshers::StdMeshers_Deflection1D::_narrow( hyp );
1001 item.myName = tr( "SMESH_DEFLECTION1D_PARAM" );
1002 if(!initVariableName( hyp, item, "SetDeflection" ))
1003 item.myValue = h->GetDeflection();
1006 else if( hypType()=="Adaptive1D" )
1008 StdMeshers::StdMeshers_Adaptive1D_var h =
1009 StdMeshers::StdMeshers_Adaptive1D::_narrow( hyp );
1011 item.myName = tr( "SMESH_MIN_SIZE" );
1012 if(!initVariableName( hyp, item, "SetMinSize" ))
1013 item.myValue = h->GetMinSize();
1016 item.myName = tr( "SMESH_MAX_SIZE" );
1017 if(!initVariableName( hyp, item, "SetMaxSize" ))
1018 item.myValue = h->GetMaxSize();
1021 item.myName = tr( "SMESH_DEFLECTION1D_PARAM" );
1022 if(!initVariableName( hyp, item, "SetDeflection" ))
1023 item.myValue = h->GetDeflection();
1026 else if( hypType()=="AutomaticLength" )
1028 StdMeshers::StdMeshers_AutomaticLength_var h =
1029 StdMeshers::StdMeshers_AutomaticLength::_narrow( hyp );
1031 item.myName = tr( "SMESH_FINENESS_PARAM" );
1032 //item.myValue = h->GetFineness();
1034 SMESHGUI_SpinBox* _autoLengthSpinBox = new SMESHGUI_SpinBox(dlg());
1035 _autoLengthSpinBox->RangeStepAndValidator(0, 1, 0.01, "length_precision");
1036 _autoLengthSpinBox->SetValue(h->GetFineness());
1037 customWidgets()->append( _autoLengthSpinBox);
1039 else if( hypType()=="NumberOfLayers" )
1041 StdMeshers::StdMeshers_NumberOfLayers_var h =
1042 StdMeshers::StdMeshers_NumberOfLayers::_narrow( hyp );
1044 item.myName = tr( "SMESH_NUMBER_OF_LAYERS" );
1045 if(!initVariableName( hyp, item, "SetNumberOfLayers" ))
1046 item.myValue = (int) h->GetNumberOfLayers();
1049 else if( hypType()=="LayerDistribution" )
1051 StdMeshers::StdMeshers_LayerDistribution_var h =
1052 StdMeshers::StdMeshers_LayerDistribution::_narrow( hyp );
1054 item.myName = tr( "SMESH_LAYERS_DISTRIBUTION" ); p.append( item );
1055 initVariableName( hyp, item, "SetLayerDistribution" );
1056 customWidgets()->append ( new StdMeshersGUI_LayerDistributionParamWdg
1057 ( h, h->GetLayerDistribution(), hypName(), dlg() ));
1059 else if( hypType()=="NumberOfLayers2D" )
1061 StdMeshers::StdMeshers_NumberOfLayers2D_var h =
1062 StdMeshers::StdMeshers_NumberOfLayers2D::_narrow( hyp );
1064 item.myName = tr( "SMESH_NUMBER_OF_LAYERS" );
1065 if(!initVariableName( hyp, item, "SetNumberOfLayers" ))
1066 item.myValue = (int) h->GetNumberOfLayers();
1069 else if( hypType()=="LayerDistribution2D" )
1071 StdMeshers::StdMeshers_LayerDistribution2D_var h =
1072 StdMeshers::StdMeshers_LayerDistribution2D::_narrow( hyp );
1074 item.myName = tr( "SMESH_LAYERS_DISTRIBUTION" ); p.append( item );
1075 initVariableName( hyp, item, "SetLayerDistribution" );
1076 customWidgets()->append ( new StdMeshersGUI_LayerDistributionParamWdg
1077 ( h, h->GetLayerDistribution(), hypName(), dlg() ));
1079 else if( hypType()=="ProjectionSource1D" )
1081 StdMeshers::StdMeshers_ProjectionSource1D_var h =
1082 StdMeshers::StdMeshers_ProjectionSource1D::_narrow( hyp );
1084 item.myName = tr( "SMESH_SOURCE_EDGE" ); p.append( item );
1085 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 1 ),
1086 h->GetSourceEdge()));
1087 item.myName = tr( "SMESH_SOURCE_MESH" ); p.append( item );
1088 customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( SMESH::MESH ),
1089 h->GetSourceMesh()));
1090 item.myName = tr( "SMESH_SOURCE_VERTEX" ); p.append( item );
1091 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1092 h->GetSourceVertex()));
1093 item.myName = tr( "SMESH_TARGET_VERTEX" ); p.append( item );
1094 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1095 h->GetTargetVertex()));
1097 else if( hypType()=="ProjectionSource2D" )
1099 StdMeshers::StdMeshers_ProjectionSource2D_var h =
1100 StdMeshers::StdMeshers_ProjectionSource2D::_narrow( hyp );
1102 item.myName = tr( "SMESH_SOURCE_FACE" ); p.append( item );
1103 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 2 ),
1104 h->GetSourceFace()));
1105 item.myName = tr( "SMESH_SOURCE_MESH" ); p.append( item );
1106 customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( SMESH::MESH ),
1107 h->GetSourceMesh()));
1108 item.myName = tr( "SMESH_SOURCE_VERTEX1" ); p.append( item );
1109 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1110 h->GetSourceVertex( 1 )));
1111 item.myName = tr( "SMESH_TARGET_VERTEX1" ); p.append( item );
1112 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1113 h->GetTargetVertex( 1 )));
1114 item.myName = tr( "SMESH_SOURCE_VERTEX2" ); p.append( item );
1115 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1116 h->GetSourceVertex( 2 )));
1117 item.myName = tr( "SMESH_TARGET_VERTEX2" ); p.append( item );
1118 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1119 h->GetTargetVertex( 2 )));
1121 else if( hypType()=="ProjectionSource3D" )
1123 StdMeshers::StdMeshers_ProjectionSource3D_var h =
1124 StdMeshers::StdMeshers_ProjectionSource3D::_narrow( hyp );
1126 item.myName = tr( "SMESH_SOURCE_3DSHAPE" ); p.append( item );
1127 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 3, TopAbs_FACE, 6, true ),
1128 h->GetSource3DShape()));
1129 item.myName = tr( "SMESH_SOURCE_MESH" ); p.append( item );
1130 customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( SMESH::MESH ),
1131 h->GetSourceMesh()));
1132 item.myName = tr( "SMESH_SOURCE_VERTEX1" ); p.append( item );
1133 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1134 h->GetSourceVertex( 1 )));
1135 item.myName = tr( "SMESH_TARGET_VERTEX1" ); p.append( item );
1136 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1137 h->GetTargetVertex( 1 )));
1138 item.myName = tr( "SMESH_SOURCE_VERTEX2" ); p.append( item );
1139 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1140 h->GetSourceVertex( 2 )));
1141 item.myName = tr( "SMESH_TARGET_VERTEX2" ); p.append( item );
1142 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1143 h->GetTargetVertex( 2 )));
1145 else if( hypType()=="ImportSource1D" )
1147 StdMeshers::StdMeshers_ImportSource1D_var h =
1148 StdMeshers::StdMeshers_ImportSource1D::_narrow( hyp );
1150 SMESH::string_array_var groupEntries = h->GetSourceEdges();
1151 CORBA::Boolean toCopyMesh, toCopyGroups;
1152 h->GetCopySourceMesh(toCopyMesh, toCopyGroups);
1154 item.myName = tr( "SMESH_SOURCE_EDGES" ); p.append( item );
1155 customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( SMESH::GROUP_EDGE ),
1158 item.myName = tr( "SMESH_COPY_MESH" ); p.append( item );
1159 QCheckBox* aQCheckBox = new QCheckBox(dlg());
1160 aQCheckBox->setChecked( toCopyMesh );
1161 connect( aQCheckBox, SIGNAL( stateChanged(int) ), this, SLOT( onValueChanged() ));
1162 customWidgets()->append( aQCheckBox );
1164 item.myName = tr( "SMESH_TO_COPY_GROUPS" ); p.append( item );
1165 aQCheckBox = new QCheckBox(dlg());
1166 aQCheckBox->setChecked( toCopyGroups );
1167 aQCheckBox->setEnabled( toCopyMesh );
1168 customWidgets()->append( aQCheckBox );
1170 else if( hypType()=="ImportSource2D" )
1172 StdMeshers::StdMeshers_ImportSource2D_var h =
1173 StdMeshers::StdMeshers_ImportSource2D::_narrow( hyp );
1175 SMESH::string_array_var groupEntries = h->GetSourceFaces();
1176 CORBA::Boolean toCopyMesh, toCopyGroups;
1177 h->GetCopySourceMesh(toCopyMesh, toCopyGroups);
1179 item.myName = tr( "SMESH_SOURCE_FACES" ); p.append( item );
1180 customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( SMESH::GROUP_FACE ),
1183 item.myName = tr( "SMESH_COPY_MESH" ); p.append( item );
1184 QCheckBox* aQCheckBox = new QCheckBox(dlg());
1185 aQCheckBox->setChecked( toCopyMesh );
1186 connect( aQCheckBox, SIGNAL( stateChanged(int) ), this, SLOT( onValueChanged() ));
1187 customWidgets()->append( aQCheckBox );
1189 item.myName = tr( "SMESH_COPY_GROUPS" ); p.append( item );
1190 aQCheckBox = new QCheckBox(dlg());
1191 aQCheckBox->setChecked( toCopyGroups );
1192 aQCheckBox->setEnabled( toCopyMesh );
1193 customWidgets()->append( aQCheckBox );
1195 else if( hypType()=="ViscousLayers" )
1197 StdMeshers::StdMeshers_ViscousLayers_var h =
1198 StdMeshers::StdMeshers_ViscousLayers::_narrow( hyp );
1200 item.myName = tr( "SMESH_TOTAL_THICKNESS" );
1201 if(!initVariableName( hyp, item, "SetTotalThickness" ))
1202 item.myValue = h->GetTotalThickness();
1204 customWidgets()->append (0);
1206 item.myName = tr( "SMESH_NUMBER_OF_LAYERS" );
1207 if(!initVariableName( hyp, item, "SetNumberLayers" ))
1208 item.myValue = h->GetNumberLayers();
1210 customWidgets()->append (0);
1212 item.myName = tr( "SMESH_STRETCH_FACTOR" );
1213 if(!initVariableName( hyp, item, "SetStretchFactor" ))
1214 item.myValue = h->GetStretchFactor();
1216 customWidgets()->append (0);
1218 item.myName = tr( "EXTRUSION_METHOD" );
1220 StdMeshersGUI_RadioButtonsGrpWdg* methodWdg = new StdMeshersGUI_RadioButtonsGrpWdg("");
1221 methodWdg->setButtonLabels ( QStringList()
1222 << tr("EXTMETH_SURF_OFFSET_SMOOTH")
1223 << tr("EXTMETH_FACE_OFFSET")
1224 << tr("EXTMETH_NODE_OFFSET"),
1226 << tr("ICON_EXTMETH_SURF_OFFSET_SMOOTH")
1227 << tr("ICON_EXTMETH_FACE_OFFSET")
1228 << tr("ICON_EXTMETH_NODE_OFFSET"));
1229 methodWdg->setChecked( (int) h->GetMethod() );
1230 customWidgets()->append( methodWdg );
1232 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
1233 QString aSubEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
1234 if ( !aMainEntry.isEmpty() )
1236 item.myName = tr( "TO_IGNORE_FACES_OR_NOT" );
1239 StdMeshersGUI_RadioButtonsGrpWdg* ignoreWdg = new StdMeshersGUI_RadioButtonsGrpWdg("");
1240 ignoreWdg->setButtonLabels ( QStringList()
1241 << tr("NOT_TO_IGNORE_FACES")
1242 << tr("TO_IGNORE_FACES") );
1243 ignoreWdg->setChecked( h->GetIsToIgnoreFaces() );
1244 connect(ignoreWdg->getButtonGroup(),SIGNAL(buttonClicked(int)),this,SLOT(onValueChanged()));
1245 customWidgets()->append( ignoreWdg );
1248 tr( h->GetIsToIgnoreFaces() ? "SMESH_FACES_WO_LAYERS" : "SMESH_FACES_WITH_LAYERS" );
1251 StdMeshersGUI_SubShapeSelectorWdg* idsWg =
1252 new StdMeshersGUI_SubShapeSelectorWdg(0,TopAbs_FACE);
1254 idsWg->SetGeomShapeEntry( aSubEntry, aMainEntry );
1255 if ( idsWg->SetListOfIDs( h->GetFaces() ))
1257 idsWg->ShowPreview( true );
1261 SUIT_MessageBox::warning( dlg(),tr( "SMESH_WRN_WARNING" ),tr( "BAD_FACES_WARNING" ));
1262 idsWg->setEnabled( false );
1264 customWidgets()->append ( idsWg );
1269 StdMeshersGUI_NameCheckableGrpWdg* nameWdg =
1270 new StdMeshersGUI_NameCheckableGrpWdg( tr( "CREATE_GROUPS_FROM_LAYERS" ),
1271 tr( "GROUP_NAME" ));
1272 nameWdg->setName( h->GetGroupName() );
1273 if ( nameWdg->getName().isEmpty() )
1275 nameWdg->setDefaultName( type() );
1276 nameWdg->setChecked( false );
1278 customWidgets()->append ( nameWdg );
1280 else if( hypType()=="ViscousLayers2D" )
1282 StdMeshers::StdMeshers_ViscousLayers2D_var h =
1283 StdMeshers::StdMeshers_ViscousLayers2D::_narrow( hyp );
1285 item.myName = tr( "SMESH_TOTAL_THICKNESS" );
1286 if(!initVariableName( hyp, item, "SetTotalThickness" ))
1287 item.myValue = h->GetTotalThickness();
1289 customWidgets()->append (0);
1291 item.myName = tr( "SMESH_NUMBER_OF_LAYERS" );
1292 if(!initVariableName( hyp, item, "SetNumberLayers" ))
1293 item.myValue = h->GetNumberLayers();
1295 customWidgets()->append (0);
1297 item.myName = tr( "SMESH_STRETCH_FACTOR" );
1298 if(!initVariableName( hyp, item, "SetStretchFactor" ))
1299 item.myValue = h->GetStretchFactor();
1301 customWidgets()->append (0);
1303 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
1304 QString aSubEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
1305 if ( !aMainEntry.isEmpty() )
1307 item.myName = tr("TO_IGNORE_EDGES_OR_NOT");
1310 StdMeshersGUI_RadioButtonsGrpWdg* ignoreWdg = new StdMeshersGUI_RadioButtonsGrpWdg("");
1311 ignoreWdg->setButtonLabels ( QStringList()
1312 << tr("NOT_TO_IGNORE_EDGES")
1313 << tr("TO_IGNORE_EDGES") );
1314 ignoreWdg->setChecked( h->GetIsToIgnoreEdges() );
1315 connect(ignoreWdg->getButtonGroup(),SIGNAL(buttonClicked(int)),this,SLOT(onValueChanged()));
1316 customWidgets()->append( ignoreWdg );
1319 tr( h->GetIsToIgnoreEdges() ? "SMESH_EDGES_WO_LAYERS" : "SMESH_EDGES_WITH_LAYERS" );
1322 StdMeshersGUI_SubShapeSelectorWdg* idsWg =
1323 new StdMeshersGUI_SubShapeSelectorWdg(0,TopAbs_EDGE);
1325 idsWg->SetGeomShapeEntry( aSubEntry, aMainEntry );
1326 if ( idsWg->SetListOfIDs( h->GetEdges() ))
1328 idsWg->ShowPreview( true );
1332 SUIT_MessageBox::warning( dlg(),tr( "SMESH_WRN_WARNING" ),tr( "BAD_EDGES_WARNING" ));
1333 idsWg->setEnabled( false );
1335 customWidgets()->append ( idsWg );
1340 StdMeshersGUI_NameCheckableGrpWdg* nameWdg =
1341 new StdMeshersGUI_NameCheckableGrpWdg( tr( "CREATE_GROUPS_FROM_LAYERS" ),
1342 tr( "GROUP_NAME" ));
1343 nameWdg->setName( h->GetGroupName() );
1344 if ( nameWdg->getName().isEmpty() )
1346 nameWdg->setDefaultName( type() );
1347 nameWdg->setChecked( false );
1349 customWidgets()->append ( nameWdg );
1356 //================================================================================
1358 * \brief tune "standard" control
1359 * \param w - control widget
1360 * \param int - parameter index
1362 //================================================================================
1364 void StdMeshersGUI_StdHypothesisCreator::attuneStdWidget (QWidget* w, const int) const
1366 SMESHGUI_SpinBox* sb = w->inherits( "SMESHGUI_SpinBox" ) ? ( SMESHGUI_SpinBox* )w : 0;
1369 if( hypType()=="LocalLength" )
1371 if (sb->objectName() == tr("SMESH_LOCAL_LENGTH_PARAM"))
1372 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1373 else if (sb->objectName() == tr("SMESH_LOCAL_LENGTH_PRECISION"))
1374 sb->RangeStepAndValidator( 0.0, 1.0, 0.05, "len_tol_precision" );
1376 else if( hypType()=="Arithmetic1D" )
1378 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "parametric_precision" );
1380 else if( hypType()=="GeometricProgression" )
1382 if (sb->objectName() == tr("SMESH_START_LENGTH_PARAM"))
1383 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1384 else if (sb->objectName() == tr("SMESH_COMMON_RATIO"))
1385 sb->RangeStepAndValidator( -VALUE_MAX, VALUE_MAX, 0.5, "len_tol_precision" );
1387 else if( hypType()=="MaxLength" )
1389 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1390 sb->setEnabled( !widget< QCheckBox >( 1 )->isChecked() );
1391 sb->setMinimumWidth( 150 );
1393 else if( hypType()=="MaxElementArea" )
1395 sb->RangeStepAndValidator( VALUE_SMALL_2, VALUE_MAX_2, 1.0, "area_precision" );
1397 else if( hypType()=="MaxElementVolume" )
1399 sb->RangeStepAndValidator( VALUE_SMALL_3, VALUE_MAX_3, 1.0, "vol_precision" );
1401 else if( hypType()=="StartEndLength" )
1403 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1405 else if( hypType()=="Deflection1D" )
1407 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "parametric_precision" );
1409 else if( hypType()=="Adaptive1D" )
1411 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1413 else if( hypType().startsWith( "ViscousLayers" ))
1415 if (sb->objectName() == tr("SMESH_STRETCH_FACTOR"))
1416 sb->RangeStepAndValidator( 1.0, VALUE_MAX, 0.1, "parametric_precision" );
1418 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1420 else // default validator for possible ancestors
1422 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1425 else if ( SalomeApp_IntSpinBox* sb = qobject_cast< SalomeApp_IntSpinBox* >( w ))
1427 if ( hypType().startsWith( "NumberOfLayers" ) ||
1428 hypType().startsWith( "ViscousLayers" ))
1430 sb->setMinimum( 1 );
1435 //================================================================================
1437 * \brief Return dlg title
1438 * \retval QString - title string
1440 //================================================================================
1442 QString StdMeshersGUI_StdHypothesisCreator::caption() const
1444 return tr( QString( "SMESH_%1_TITLE" ).arg( hypTypeName( hypType() ) ).toLatin1().data() );
1447 //================================================================================
1449 * \brief return pixmap for dlg icon
1452 //================================================================================
1454 QPixmap StdMeshersGUI_StdHypothesisCreator::icon() const
1456 QString hypIconName = tr( QString( "ICON_DLG_%1" ).arg( hypTypeName( hypType() ) ).toLatin1().data() );
1457 return SMESHGUI::resourceMgr()->loadPixmap( "SMESH", hypIconName );
1460 //================================================================================
1462 * \brief Return hypothesis type name to show in dlg
1465 //================================================================================
1467 QString StdMeshersGUI_StdHypothesisCreator::type() const
1469 return tr( QString( "SMESH_%1_HYPOTHESIS" ).arg( hypTypeName( hypType() ) ).toLatin1().data() );
1472 //================================================================================
1474 * \brief String to insert in "SMESH_%1_HYPOTHESIS" to get hypothesis type name
1475 * from message resource file
1476 * \param t - hypothesis type
1477 * \retval QString - result string
1479 //================================================================================
1481 QString StdMeshersGUI_StdHypothesisCreator::hypTypeName( const QString& t ) const
1483 static QMap<QString,QString> types;
1484 if( types.isEmpty() )
1486 types.insert( "LocalLength", "LOCAL_LENGTH" );
1487 types.insert( "NumberOfSegments", "NB_SEGMENTS" );
1488 types.insert( "MaxElementArea", "MAX_ELEMENT_AREA" );
1489 types.insert( "MaxElementVolume", "MAX_ELEMENT_VOLUME" );
1490 types.insert( "StartEndLength", "START_END_LENGTH" );
1491 types.insert( "Deflection1D", "DEFLECTION1D" );
1492 types.insert( "Adaptive1D", "ADAPTIVE1D" );
1493 types.insert( "Arithmetic1D", "ARITHMETIC_1D" );
1494 types.insert( "GeometricProgression", "GEOMETRIC_1D" );
1495 types.insert( "FixedPoints1D", "FIXED_POINTS_1D" );
1496 types.insert( "AutomaticLength", "AUTOMATIC_LENGTH" );
1497 types.insert( "ProjectionSource1D", "PROJECTION_SOURCE_1D" );
1498 types.insert( "ProjectionSource2D", "PROJECTION_SOURCE_2D" );
1499 types.insert( "ProjectionSource3D", "PROJECTION_SOURCE_3D" );
1500 types.insert( "ImportSource1D", "IMPORT_SOURCE_1D" );
1501 types.insert( "ImportSource2D", "IMPORT_SOURCE_2D" );
1502 types.insert( "NumberOfLayers", "NUMBER_OF_LAYERS" );
1503 types.insert( "LayerDistribution", "LAYER_DISTRIBUTION" );
1504 types.insert( "NumberOfLayers2D", "NUMBER_OF_LAYERS_2D" );
1505 types.insert( "LayerDistribution2D", "LAYER_DISTRIBUTION" );
1506 types.insert( "SegmentLengthAroundVertex", "SEGMENT_LENGTH_AROUND_VERTEX" );
1507 types.insert( "MaxLength", "MAX_LENGTH" );
1508 types.insert( "ViscousLayers", "VISCOUS_LAYERS" );
1509 types.insert( "ViscousLayers2D", "VISCOUS_LAYERS" );
1510 types.insert( "QuadrangleParams", "QUADRANGLE_PARAMS" );
1511 types.insert( "CartesianParameters3D", "CARTESIAN_PARAMS" );
1515 if( types.contains( t ) )
1522 //=======================================================================
1523 //function : getCustomWidget
1524 //purpose : is called from buildStdFrame()
1525 //=======================================================================
1527 QWidget* StdMeshersGUI_StdHypothesisCreator::getCustomWidget( const StdParam & param,
1529 const int index) const
1532 if ( index < customWidgets()->count() ) {
1533 w = customWidgets()->at( index );
1535 w->setParent( parent );
1536 w->move( QPoint( 0, 0 ) );
1542 //================================================================================
1544 * \brief Set param value taken from a custom widget
1545 * \param param - SMESHGUI_GenericHypothesisCreator::StdParam structure
1546 * \param widget - widget presenting param
1547 * \retval bool - success flag
1549 * this method is called from getStdParamFromDlg()
1551 //================================================================================
1553 bool StdMeshersGUI_StdHypothesisCreator::getParamFromCustomWidget( StdParam & param,
1554 QWidget* widget) const
1556 if ( hypType()=="AutomaticLength" ) {
1557 SMESHGUI_SpinBox* w = dynamic_cast<SMESHGUI_SpinBox*>( widget );
1559 param.myValue = w->GetValue();
1563 if ( hypType() == "MaxLength" ) {
1567 if ( widget->inherits( "StdMeshersGUI_ObjectReferenceParamWdg" ))
1569 // show only 1st reference value
1570 if ( true /*widget == getWidgetForParam( 0 )*/) {
1571 const StdMeshersGUI_ObjectReferenceParamWdg * w =
1572 static_cast<const StdMeshersGUI_ObjectReferenceParamWdg*>( widget );
1573 param.myValue = w->GetValue();
1577 if ( widget->inherits( "StdMeshersGUI_LayerDistributionParamWdg" ))
1579 const StdMeshersGUI_LayerDistributionParamWdg * w =
1580 static_cast<const StdMeshersGUI_LayerDistributionParamWdg*>( widget );
1581 param.myValue = w->GetValue();
1584 if ( widget->inherits( "StdMeshersGUI_SubShapeSelectorWdg" ))
1586 const StdMeshersGUI_SubShapeSelectorWdg * w =
1587 static_cast<const StdMeshersGUI_SubShapeSelectorWdg*>( widget );
1588 param.myValue = w->GetValue();
1591 // if ( widget->inherits( "StdMeshersGUI_QuadrangleParamWdg" ))
1593 // param.myValue = "QuadType";
1596 if ( widget->inherits( "StdMeshersGUI_FixedPointsParamWdg" ))
1598 const StdMeshersGUI_FixedPointsParamWdg * w =
1599 static_cast<const StdMeshersGUI_FixedPointsParamWdg*>( widget );
1600 param.myValue = w->GetValue();
1603 if ( widget->inherits( "QCheckBox" ))
1605 //const QCheckBox * w = static_cast<const QCheckBox*>( widget );
1606 //param.myValue = w->isChecked();
1609 if ( widget->inherits( "StdMeshersGUI_RadioButtonsGrpWdg" ))
1611 const StdMeshersGUI_RadioButtonsGrpWdg * w =
1612 static_cast<const StdMeshersGUI_RadioButtonsGrpWdg*>( widget );
1613 param.myValue = w->checkedId();
1616 if ( widget->inherits( "StdMeshersGUI_NameCheckableGrpWdg" ))
1623 //================================================================================
1625 * \brief called when operation cancelled
1627 //================================================================================
1629 void StdMeshersGUI_StdHypothesisCreator::onReject()
1631 if ( hypType().startsWith("ProjectionSource" ) ||
1632 hypType().startsWith("ImportSource" ))
1634 // Uninstall filters of StdMeshersGUI_ObjectReferenceParamWdg
1635 deactivateObjRefParamWdg( customWidgets() );
1639 //================================================================================
1641 * \brief Update widgets dependent on paramWidget
1643 //================================================================================
1645 void StdMeshersGUI_StdHypothesisCreator::valueChanged( QWidget* paramWidget)
1647 if ( hypType() == "MaxLength" && paramWidget == getWidgetForParam(1) )
1649 getWidgetForParam(0)->setEnabled( !widget< QCheckBox >( 1 )->isChecked() );
1650 if ( !getWidgetForParam(0)->isEnabled() ) {
1651 StdMeshers::StdMeshers_MaxLength_var h =
1652 StdMeshers::StdMeshers_MaxLength::_narrow( initParamsHypothesis() );
1653 widget< QtxDoubleSpinBox >( 0 )->setValue( h->GetPreestimatedLength() );
1656 else if ( hypType().startsWith("ImportSource") && paramWidget == getWidgetForParam(1) )
1658 QCheckBox* toCopyMesh = (QCheckBox*) paramWidget;
1659 QCheckBox* toCopyGroups = widget< QCheckBox >( 2 );
1660 if ( !toCopyMesh->isChecked() )
1662 toCopyGroups->setChecked( false );
1663 toCopyGroups->setEnabled( false );
1667 toCopyGroups->setEnabled( true );
1670 else if ( hypType().startsWith( "ViscousLayers" ) && paramWidget->inherits("QButtonGroup"))
1672 int widgetNumber = hypType() == "ViscousLayers2D" ? 3 : 4;
1673 if ( QLabel* label = getLabel( widgetNumber + 1 ) )
1675 bool toIgnore = widget< StdMeshersGUI_RadioButtonsGrpWdg >( widgetNumber )->checkedId();
1676 if ( hypType() == "ViscousLayers2D" )
1677 label->setText( tr( toIgnore ? "SMESH_EDGES_WO_LAYERS" : "SMESH_EDGES_WITH_LAYERS" ));
1679 label->setText( tr( toIgnore ? "SMESH_FACES_WO_LAYERS" : "SMESH_FACES_WITH_LAYERS" ));
1684 //================================================================================
1688 //================================================================================
1690 bool StdMeshersGUI_StdHypothesisCreator::initVariableName(SMESH::SMESH_Hypothesis_var theHyp,
1691 StdParam & theParams,
1692 const char* theMethod) const
1694 QString aVaribaleName = getVariableName( theMethod );
1695 theParams.isVariable = !aVaribaleName.isEmpty();
1696 if (theParams.isVariable)
1697 theParams.myValue = aVaribaleName;
1699 return theParams.isVariable;
1702 //================================================================================
1704 * \brief Creates two widgets used to define reversed edges for some 1D hypotheses
1705 * \param [in] edgeIDs - ids of reversed edges to set to the widgets
1706 * \param [in] shapeEntry - entry of a sub-shape of a sub-mesh if any
1707 * \return QWidget* - new StdMeshersGUI_SubShapeSelectorWdg;
1708 * new StdMeshersGUI_PropagationHelperWdg is stored in \a myHelperWidget field.
1710 //================================================================================
1713 StdMeshersGUI_StdHypothesisCreator::makeReverseEdgesWdg( SMESH::long_array_var edgeIDs,
1714 CORBA::String_var shapeEntry) const
1716 QString aGeomEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
1717 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
1718 if ( aGeomEntry.isEmpty() && shapeEntry.in() )
1719 aGeomEntry = shapeEntry.in();
1721 StdMeshersGUI_SubShapeSelectorWdg* wdg = new StdMeshersGUI_SubShapeSelectorWdg();
1722 wdg->SetGeomShapeEntry( aGeomEntry, aMainEntry );
1723 wdg->SetListOfIDs( edgeIDs );
1724 wdg->ShowPreview( true );
1726 if ( !aGeomEntry.isEmpty() || !aMainEntry.isEmpty() )
1727 const_cast<StdMeshersGUI_StdHypothesisCreator*>( this )->
1728 myHelperWidget = new StdMeshersGUI_PropagationHelperWdg( wdg );