1 // Copyright (C) 2007-2015 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_SubShapeSelectorWdg.h"
44 #include <SALOMEDSClient_Study.hxx>
46 #include <GEOM_wrap.hxx>
48 // SALOME GUI includes
49 #include <SUIT_MessageBox.h>
50 #include <SUIT_ResourceMgr.h>
51 #include <SalomeApp_IntSpinBox.h>
54 #include <SALOMEconfig.h>
55 #include CORBA_SERVER_HEADER(SMESH_BasicHypothesis)
56 #include CORBA_SERVER_HEADER(SMESH_Mesh)
57 #include CORBA_SERVER_HEADER(SMESH_Group)
60 #include <QHBoxLayout>
64 #include <QButtonGroup>
66 const double VALUE_MAX = 1.0e+15, // COORD_MAX
67 VALUE_MAX_2 = VALUE_MAX * VALUE_MAX,
68 VALUE_MAX_3 = VALUE_MAX_2 * VALUE_MAX,
69 VALUE_SMALL = 1.0e-15,
70 VALUE_SMALL_2 = VALUE_SMALL * VALUE_SMALL,
71 VALUE_SMALL_3 = VALUE_SMALL_2 * VALUE_SMALL;
73 //================================================================================
76 * \param type - hypothesis type
78 //================================================================================
80 StdMeshersGUI_StdHypothesisCreator::StdMeshersGUI_StdHypothesisCreator( const QString& type )
81 : SMESHGUI_GenericHypothesisCreator( type ), myHelperWidget( 0 )
85 //================================================================================
89 //================================================================================
91 StdMeshersGUI_StdHypothesisCreator::~StdMeshersGUI_StdHypothesisCreator()
95 //================================================================================
97 * \brief Return widget for i-th hypothesis parameter (got from myParamWidgets)
98 * \param i - index of hypothesis parameter
99 * \retval QWidget* - found widget
101 //================================================================================
103 QWidget* StdMeshersGUI_StdHypothesisCreator::getWidgetForParam( int i ) const
106 if ( isCreation() ) ++i; // skip widget of 'name' parameter
108 if ( i < myCustomWidgets.count() ) {
109 QList<QWidget*>::const_iterator anIt = myCustomWidgets.begin();
110 QList<QWidget*>::const_iterator aLast = myCustomWidgets.end();
111 for ( int j = 0 ; !w && anIt != aLast; ++anIt, ++j )
116 // list has no at() const, so we iterate
117 QList<QWidget*>::const_iterator anIt = widgets().begin();
118 QList<QWidget*>::const_iterator aLast = widgets().end();
119 for( int j = 0; !w && anIt!=aLast; anIt++, ++j ) {
127 //================================================================================
129 * \brief Allow modifing myCustomWidgets in const methods
130 * \retval ListOfWidgets* - non-const pointer to myCustomWidgets
132 //================================================================================
134 StdMeshersGUI_StdHypothesisCreator::ListOfWidgets*
135 StdMeshersGUI_StdHypothesisCreator::customWidgets() const
137 return const_cast< ListOfWidgets* >( & myCustomWidgets );
140 //================================================================================
142 * \brief Builds dlg layout
143 * \retval QFrame* - the built widget
145 //================================================================================
147 QFrame* StdMeshersGUI_StdHypothesisCreator::buildFrame()
149 return buildStdFrame();
152 //================================================================================
154 * \brief Initialise parameter values in controls
156 //================================================================================
158 void StdMeshersGUI_StdHypothesisCreator::retrieveParams() const
160 // buildStdFrame() sets values itself calling stdParams()
162 if ( hypType().startsWith("ProjectionSource" ))
164 // we use this method to connect depending custom widgets
165 StdMeshersGUI_ObjectReferenceParamWdg* widgetToActivate = 0;
166 ListOfWidgets::const_iterator anIt = myCustomWidgets.begin();
167 for ( ; anIt != myCustomWidgets.end(); anIt++)
169 if ( *anIt && (*anIt)->inherits("StdMeshersGUI_ObjectReferenceParamWdg"))
171 StdMeshersGUI_ObjectReferenceParamWdg * w1 =
172 ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
173 ListOfWidgets::const_iterator anIt2 = anIt;
174 for ( ++anIt2; anIt2 != myCustomWidgets.end(); anIt2++)
175 if ( *anIt2 && (*anIt2)->inherits("StdMeshersGUI_ObjectReferenceParamWdg"))
177 StdMeshersGUI_ObjectReferenceParamWdg * w2 =
178 ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt2 );
179 w1->AvoidSimultaneousSelection( w2 );
181 if ( !widgetToActivate )
182 widgetToActivate = w1;
185 if ( widgetToActivate )
186 widgetToActivate->activateSelection();
190 dlg()->setMinimumSize( dlg()->minimumSizeHint().width(), dlg()->minimumSizeHint().height() );
195 //================================================================================
197 * \brief Widget: slider with left and right labels
199 //================================================================================
201 class TDoubleSliderWith2Labels: public QWidget
204 TDoubleSliderWith2Labels( const QString& leftLabel, const QString& rightLabel,
205 const double initValue, const double bottom,
206 const double top , const double precision,
207 QWidget * parent=0 , const char * name=0 )
208 :QWidget(parent), _bottom(bottom), _precision(precision)
212 QHBoxLayout* aHBoxL = new QHBoxLayout(this);
214 if ( !leftLabel.isEmpty() ) {
215 QLabel* aLeftLabel = new QLabel( this );
216 aLeftLabel->setText( leftLabel );
217 aHBoxL->addWidget( aLeftLabel );
220 _slider = new QSlider( Qt::Horizontal, this );
221 _slider->setRange( 0, toInt( top ));
222 _slider->setValue( toInt( initValue ));
223 aHBoxL->addWidget( _slider );
225 if ( !rightLabel.isEmpty() ) {
226 QLabel* aRightLabel = new QLabel( this );
227 aRightLabel->setText( rightLabel );
228 aHBoxL->addWidget( aRightLabel );
233 double value() const { return _bottom + _slider->value() * _precision; }
234 QSlider * getSlider() const { return _slider; }
235 int toInt( double val ) const { return (int) ceil(( val - _bottom ) / _precision ); }
237 double _bottom, _precision;
241 //================================================================================
243 * \brief Retrieve GEOM_Object held by widget
245 //================================================================================
247 inline GEOM::GEOM_Object_var geomFromWdg(const QWidget* wdg)
249 const StdMeshersGUI_ObjectReferenceParamWdg * objRefWdg =
250 dynamic_cast<const StdMeshersGUI_ObjectReferenceParamWdg*>( wdg );
252 return objRefWdg->GetObject< GEOM::GEOM_Object >();
254 return GEOM::GEOM_Object::_nil();
256 //================================================================================
258 * \brief Retrieve SMESH_Mesh held by widget
260 //================================================================================
262 inline SMESH::SMESH_Mesh_var meshFromWdg(const QWidget* wdg)
264 const StdMeshersGUI_ObjectReferenceParamWdg * objRefWdg =
265 dynamic_cast<const StdMeshersGUI_ObjectReferenceParamWdg*>( wdg );
267 return objRefWdg->GetObject< SMESH::SMESH_Mesh >();
269 return SMESH::SMESH_Mesh::_nil();
271 //================================================================================
273 * \brief Retrieve SMESH_Mesh held by widget
275 //================================================================================
277 inline SMESH::ListOfGroups_var groupsFromWdg(const QWidget* wdg)
279 SMESH::ListOfGroups_var groups = new SMESH::ListOfGroups;
280 const StdMeshersGUI_ObjectReferenceParamWdg * objRefWdg =
281 dynamic_cast<const StdMeshersGUI_ObjectReferenceParamWdg*>( wdg );
284 groups->length( objRefWdg->NbObjects() );
285 for ( unsigned i = 0; i < groups->length(); ++i )
286 groups[i] = objRefWdg->GetObject< SMESH::SMESH_GroupBase >(i);
290 //================================================================================
292 * \brief creates a filter for selection of shapes of given dimension
293 * \param dim - dimension
294 * \param subShapeType - required type of sub-shapes, number of which must be \a nbSubShapes
295 * \param nbSubShapes - number of sub-shapes of given type
296 * \param closed - required closeness flag of a shape
297 * \retval SUIT_SelectionFilter* - created filter
299 //================================================================================
301 SUIT_SelectionFilter* filterForShapeOfDim(const int dim,
302 TopAbs_ShapeEnum subShapeType = TopAbs_SHAPE,
303 const int nbSubShapes = 0,
306 TColStd_MapOfInteger shapeTypes;
308 case 0: shapeTypes.Add( TopAbs_VERTEX ); break;
310 if ( subShapeType == TopAbs_SHAPE ) subShapeType = TopAbs_EDGE;
311 shapeTypes.Add( TopAbs_EDGE );
312 shapeTypes.Add( TopAbs_COMPOUND ); // for a group
315 if ( subShapeType == TopAbs_SHAPE ) subShapeType = TopAbs_FACE;
316 shapeTypes.Add( TopAbs_FACE );
317 shapeTypes.Add( TopAbs_COMPOUND ); // for a group
320 shapeTypes.Add( TopAbs_SHELL );
321 shapeTypes.Add( TopAbs_SOLID );
322 shapeTypes.Add( TopAbs_COMPSOLID );
323 shapeTypes.Add( TopAbs_COMPOUND );
326 return new SMESH_NumberFilter("GEOM", subShapeType, nbSubShapes,
327 shapeTypes, GEOM::GEOM_Object::_nil(), closed);
330 //================================================================================
332 * \brief Create a widget for object selection
333 * \param object - initial object
334 * \param filter - selection filter
335 * \retval QWidget* - created widget
337 //================================================================================
339 QWidget* newObjRefParamWdg( SUIT_SelectionFilter* filter,
340 CORBA::Object_var object)
342 StdMeshersGUI_ObjectReferenceParamWdg* w =
343 new StdMeshersGUI_ObjectReferenceParamWdg( filter, 0);
344 w->SetObject( object.in() );
347 QWidget* newObjRefParamWdg( SUIT_SelectionFilter* filter,
348 SMESH::string_array_var& objEntries)
350 StdMeshersGUI_ObjectReferenceParamWdg* w =
351 new StdMeshersGUI_ObjectReferenceParamWdg( filter, 0, /*multiSel=*/true);
352 //RNV: Firstly, activate selection, then set objects
353 w->activateSelection();
354 w->SetObjects( objEntries );
358 //================================================================================
360 * \brief calls deactivateSelection() for StdMeshersGUI_ObjectReferenceParamWdg
361 * \param widgetList - list of widgets
363 //================================================================================
365 void deactivateObjRefParamWdg( QList<QWidget*>* widgetList )
367 StdMeshersGUI_ObjectReferenceParamWdg* w = 0;
368 QList<QWidget*>::iterator anIt = widgetList->begin();
369 QList<QWidget*>::iterator aLast = widgetList->end();
370 for ( ; anIt != aLast; anIt++ ) {
371 if ( (*anIt) && (*anIt)->inherits( "StdMeshersGUI_ObjectReferenceParamWdg" ))
373 w = (StdMeshersGUI_ObjectReferenceParamWdg* )( *anIt );
374 w->deactivateSelection();
380 //================================================================================
382 * \brief Check parameter values before accept()
383 * \retval bool - true if OK
385 //================================================================================
387 bool StdMeshersGUI_StdHypothesisCreator::checkParams( QString& msg ) const
389 if( !SMESHGUI_GenericHypothesisCreator::checkParams( msg ) )
392 // check if object reference parameter is set, as it has no default value
394 if ( hypType().startsWith("ProjectionSource" ))
396 StdMeshersGUI_ObjectReferenceParamWdg* w =
397 widget< StdMeshersGUI_ObjectReferenceParamWdg >( 0 );
398 ok = ( w->IsObjectSelected() );
399 if ( !ok ) w->SetObject( CORBA::Object::_nil() );
400 int nbAssocVert = ( hypType() == "ProjectionSource1D" ? 1 : 2 );
401 int nbNonEmptyAssoc = 0;
402 for ( int i = 0; ok && i < nbAssocVert*2; i += 2)
405 StdMeshersGUI_ObjectReferenceParamWdg* w1 =
406 widget< StdMeshersGUI_ObjectReferenceParamWdg >( i+2 );
407 StdMeshersGUI_ObjectReferenceParamWdg* w2 =
408 widget< StdMeshersGUI_ObjectReferenceParamWdg >( i+3 );
409 srcV = w1->GetValue();
410 tgtV = w2->GetValue();
411 ok = (( srcV.isEmpty() && tgtV.isEmpty() ) ||
412 ( !srcV.isEmpty() && !tgtV.isEmpty() /*&& srcV != tgtV*/ ));
414 w1->SetObject( CORBA::Object::_nil() );
415 w2->SetObject( CORBA::Object::_nil() );
417 nbNonEmptyAssoc += !srcV.isEmpty();
419 if ( ok && nbNonEmptyAssoc == 1 && nbAssocVert == 2 )
421 // only one pair of VERTEXes is given for a FACE,
422 // then the FACE must have only one VERTEX
423 GEOM::GEOM_Object_var face = w->GetObject< GEOM::GEOM_Object >();
425 GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen();
426 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
427 GEOM::GEOM_IShapesOperations_wrap shapeOp;
428 if ( !geomGen->_is_nil() && aStudy )
429 shapeOp = geomGen->GetIShapesOperations( aStudy->StudyId() );
430 if ( !shapeOp->_is_nil() )
432 GEOM::ListOfLong_var vertices =
433 shapeOp->GetAllSubShapesIDs (face, GEOM::VERTEX, /*isSorted=*/false);
434 ok = ( vertices->length() == 1 );
437 // Uninstall filters of StdMeshersGUI_ObjectReferenceParamWdg
439 deactivateObjRefParamWdg( customWidgets() );
441 else if ( hypType().startsWith("ImportSource" ))
443 StdMeshersGUI_ObjectReferenceParamWdg* w =
444 widget< StdMeshersGUI_ObjectReferenceParamWdg >( 0 );
445 ok = ( w->IsObjectSelected() );
447 else if ( hypType() == "LayerDistribution" || hypType() == "LayerDistribution2D" )
449 StdMeshersGUI_LayerDistributionParamWdg* w =
450 widget< StdMeshersGUI_LayerDistributionParamWdg >( 0 );
451 ok = ( w && w->IsOk() );
457 //================================================================================
459 * \brief Store params from GUI controls to a hypothesis
460 * \retval QString - text representation of parameters
462 //================================================================================
464 QString StdMeshersGUI_StdHypothesisCreator::storeParams() const
466 ListOfStdParams params;
467 bool res = getStdParamFromDlg( params );
470 SMESH::SetName( SMESH::FindSObject( hypothesis() ), params[0].myValue.toString().toLatin1().data() );
471 params.erase( params.begin() );
474 QString valueStr = stdParamValues( params );
475 //QStringList aVariablesList = getVariablesFromDlg();
477 if( res && !params.isEmpty() )
479 if( hypType()=="LocalLength" )
481 StdMeshers::StdMeshers_LocalLength_var h =
482 StdMeshers::StdMeshers_LocalLength::_narrow( hypothesis() );
484 h->SetVarParameter( params[0].text(), "SetLength" );
485 h->SetLength( params[0].myValue.toDouble() );
486 h->SetVarParameter( params[1].text(), "SetPrecision" );
487 h->SetPrecision( params[1].myValue.toDouble() );
489 else if( hypType()=="MaxLength" )
491 StdMeshers::StdMeshers_MaxLength_var h =
492 StdMeshers::StdMeshers_MaxLength::_narrow( hypothesis() );
494 h->SetVarParameter( params[0].text(), "SetLength" );
495 h->SetLength( params[0].myValue.toDouble() );
496 h->SetUsePreestimatedLength( widget< QCheckBox >( 1 )->isChecked() );
497 if ( !h->HavePreestimatedLength() && !h->_is_equivalent( initParamsHypothesis() )) {
498 StdMeshers::StdMeshers_MaxLength_var hInit =
499 StdMeshers::StdMeshers_MaxLength::_narrow( initParamsHypothesis() );
500 h->SetPreestimatedLength( hInit->GetPreestimatedLength() );
503 else if( hypType()=="SegmentLengthAroundVertex" )
505 StdMeshers::StdMeshers_SegmentLengthAroundVertex_var h =
506 StdMeshers::StdMeshers_SegmentLengthAroundVertex::_narrow( hypothesis() );
508 h->SetVarParameter( params[0].text(), "SetLength" );
509 h->SetLength( params[0].myValue.toDouble() );
511 else if( hypType()=="Arithmetic1D" )
513 StdMeshers::StdMeshers_Arithmetic1D_var h =
514 StdMeshers::StdMeshers_Arithmetic1D::_narrow( hypothesis() );
516 StdMeshersGUI_SubShapeSelectorWdg* w =
517 widget< StdMeshersGUI_SubShapeSelectorWdg >( 2 );
519 h->SetVarParameter( params[0].text(), "SetStartLength" );
520 h->SetStartLength( params[0].myValue.toDouble() );
521 h->SetVarParameter( params[1].text(), "SetEndLength" );
522 h->SetEndLength( params[1].myValue.toDouble() );
524 h->SetReversedEdges( w->GetListOfIDs() );
525 h->SetObjectEntry( w->GetMainShapeEntry() );
528 else if( hypType()=="GeometricProgression" )
530 StdMeshers::StdMeshers_Geometric1D_var h =
531 StdMeshers::StdMeshers_Geometric1D::_narrow( hypothesis() );
533 StdMeshersGUI_SubShapeSelectorWdg* w =
534 widget< StdMeshersGUI_SubShapeSelectorWdg >( 2 );
536 h->SetVarParameter( params[0].text(), "SetStartLength" );
537 h->SetStartLength( params[0].myValue.toDouble() );
538 h->SetVarParameter( params[1].text(), "SetCommonRatio" );
539 h->SetCommonRatio( params[1].myValue.toDouble() );
541 h->SetReversedEdges( w->GetListOfIDs() );
542 h->SetObjectEntry( w->GetMainShapeEntry() );
545 else if( hypType()=="FixedPoints1D" )
547 StdMeshers::StdMeshers_FixedPoints1D_var h =
548 StdMeshers::StdMeshers_FixedPoints1D::_narrow( hypothesis() );
550 StdMeshersGUI_FixedPointsParamWdg* w1 =
551 widget< StdMeshersGUI_FixedPointsParamWdg >( 0 );
553 StdMeshersGUI_SubShapeSelectorWdg* w2 =
554 widget< StdMeshersGUI_SubShapeSelectorWdg >( 1 );
557 h->SetPoints( w1->GetListOfPoints() );
558 h->SetNbSegments( w1->GetListOfSegments() );
561 h->SetReversedEdges( w2->GetListOfIDs() );
562 h->SetObjectEntry( w2->GetMainShapeEntry() );
565 else if( hypType()=="MaxElementArea" )
567 StdMeshers::StdMeshers_MaxElementArea_var h =
568 StdMeshers::StdMeshers_MaxElementArea::_narrow( hypothesis() );
569 h->SetVarParameter( params[0].text(), "SetMaxElementArea" );
570 h->SetMaxElementArea( params[0].myValue.toDouble() );
572 else if( hypType()=="MaxElementVolume" )
574 StdMeshers::StdMeshers_MaxElementVolume_var h =
575 StdMeshers::StdMeshers_MaxElementVolume::_narrow( hypothesis() );
577 h->SetVarParameter( params[0].text(), "SetMaxElementVolume" );
578 h->SetMaxElementVolume( params[0].myValue.toDouble() );
580 else if( hypType()=="StartEndLength" )
582 StdMeshers::StdMeshers_StartEndLength_var h =
583 StdMeshers::StdMeshers_StartEndLength::_narrow( hypothesis() );
585 StdMeshersGUI_SubShapeSelectorWdg* w =
586 widget< StdMeshersGUI_SubShapeSelectorWdg >( 2 );
588 h->SetVarParameter( params[0].text(), "SetStartLength" );
589 h->SetStartLength( params[0].myValue.toDouble() );
590 h->SetVarParameter( params[1].text(), "SetEndLength" );
591 h->SetEndLength( params[1].myValue.toDouble() );
593 h->SetReversedEdges( w->GetListOfIDs() );
594 h->SetObjectEntry( w->GetMainShapeEntry() );
597 else if( hypType()=="Deflection1D" )
599 StdMeshers::StdMeshers_Deflection1D_var h =
600 StdMeshers::StdMeshers_Deflection1D::_narrow( hypothesis() );
601 h->SetVarParameter( params[0].text(), "SetDeflection" );
602 h->SetDeflection( params[0].myValue.toDouble() );
604 else if( hypType()=="Adaptive1D" )
606 StdMeshers::StdMeshers_Adaptive1D_var h =
607 StdMeshers::StdMeshers_Adaptive1D::_narrow( hypothesis() );
608 h->SetVarParameter( params[0].text(), "SetMinSize" );
609 h->SetMinSize( params[0].myValue.toDouble() );
610 h->SetVarParameter( params[0].text(), "SetMaxSize" );
611 h->SetMaxSize( params[1].myValue.toDouble() );
612 h->SetVarParameter( params[0].text(), "SetDeflection" );
613 h->SetDeflection( params[2].myValue.toDouble() );
615 else if( hypType()=="AutomaticLength" )
617 StdMeshers::StdMeshers_AutomaticLength_var h =
618 StdMeshers::StdMeshers_AutomaticLength::_narrow( hypothesis() );
620 h->SetVarParameter( params[0].text(), "SetFineness" );
621 h->SetFineness( params[0].myValue.toDouble() );
623 else if( hypType()=="NumberOfLayers" )
625 StdMeshers::StdMeshers_NumberOfLayers_var h =
626 StdMeshers::StdMeshers_NumberOfLayers::_narrow( hypothesis() );
628 h->SetVarParameter( params[0].text(), "SetNumberOfLayers" );
629 h->SetNumberOfLayers( params[0].myValue.toInt() );
631 else if( hypType()=="LayerDistribution" )
633 StdMeshers::StdMeshers_LayerDistribution_var h =
634 StdMeshers::StdMeshers_LayerDistribution::_narrow( hypothesis() );
635 StdMeshersGUI_LayerDistributionParamWdg* w =
636 widget< StdMeshersGUI_LayerDistributionParamWdg >( 0 );
638 h->SetLayerDistribution( w->GetHypothesis() );
640 else if( hypType()=="NumberOfLayers2D" )
642 StdMeshers::StdMeshers_NumberOfLayers2D_var h =
643 StdMeshers::StdMeshers_NumberOfLayers2D::_narrow( hypothesis() );
645 h->SetVarParameter( params[0].text(), "SetNumberOfLayers" );
646 h->SetNumberOfLayers( params[0].myValue.toInt() );
648 else if( hypType()=="LayerDistribution2D" )
650 StdMeshers::StdMeshers_LayerDistribution2D_var h =
651 StdMeshers::StdMeshers_LayerDistribution2D::_narrow( hypothesis() );
652 StdMeshersGUI_LayerDistributionParamWdg* w =
653 widget< StdMeshersGUI_LayerDistributionParamWdg >( 0 );
655 h->SetLayerDistribution( w->GetHypothesis() );
657 else if( hypType()=="ProjectionSource1D" )
659 StdMeshers::StdMeshers_ProjectionSource1D_var h =
660 StdMeshers::StdMeshers_ProjectionSource1D::_narrow( hypothesis() );
662 h->SetSourceEdge ( geomFromWdg ( getWidgetForParam( 0 )));
663 h->SetSourceMesh ( meshFromWdg ( getWidgetForParam( 1 )));
664 h->SetVertexAssociation( geomFromWdg ( getWidgetForParam( 2 )),
665 geomFromWdg ( getWidgetForParam( 3 )));
667 else if( hypType()=="ProjectionSource2D" )
669 StdMeshers::StdMeshers_ProjectionSource2D_var h =
670 StdMeshers::StdMeshers_ProjectionSource2D::_narrow( hypothesis() );
672 h->SetSourceFace ( geomFromWdg ( getWidgetForParam( 0 )));
673 h->SetSourceMesh ( meshFromWdg ( getWidgetForParam( 1 )));
674 h->SetVertexAssociation( geomFromWdg ( getWidgetForParam( 2 )), // src1
675 geomFromWdg ( getWidgetForParam( 4 )), // src2
676 geomFromWdg ( getWidgetForParam( 3 )), // tgt1
677 geomFromWdg ( getWidgetForParam( 5 ))); // tgt2
679 else if( hypType()=="ProjectionSource3D" )
681 StdMeshers::StdMeshers_ProjectionSource3D_var h =
682 StdMeshers::StdMeshers_ProjectionSource3D::_narrow( hypothesis() );
684 h->SetSource3DShape ( geomFromWdg ( getWidgetForParam( 0 )));
685 h->SetSourceMesh ( meshFromWdg ( getWidgetForParam( 1 )));
686 h->SetVertexAssociation( geomFromWdg ( getWidgetForParam( 2 )), // src1
687 geomFromWdg ( getWidgetForParam( 4 )), // src2
688 geomFromWdg ( getWidgetForParam( 3 )), // tgt1
689 geomFromWdg ( getWidgetForParam( 5 ))); // tgt2
691 else if( hypType()=="ImportSource1D" )
693 StdMeshers::StdMeshers_ImportSource1D_var h =
694 StdMeshers::StdMeshers_ImportSource1D::_narrow( hypothesis() );
696 SMESH::ListOfGroups_var groups = groupsFromWdg( getWidgetForParam( 0 ));
697 h->SetSourceEdges( groups.in() );
698 QCheckBox* toCopyMesh = widget< QCheckBox >( 1 );
699 QCheckBox* toCopyGroups = widget< QCheckBox >( 2 );
700 h->SetCopySourceMesh( toCopyMesh->isChecked(), toCopyGroups->isChecked());
702 else if( hypType()=="ImportSource2D" )
704 StdMeshers::StdMeshers_ImportSource2D_var h =
705 StdMeshers::StdMeshers_ImportSource2D::_narrow( hypothesis() );
707 SMESH::ListOfGroups_var groups = groupsFromWdg( getWidgetForParam( 0 ));
708 h->SetSourceFaces( groups.in() );
709 QCheckBox* toCopyMesh = widget< QCheckBox >( 1 );
710 QCheckBox* toCopyGroups = widget< QCheckBox >( 2 );
711 h->SetCopySourceMesh( toCopyMesh->isChecked(), toCopyGroups->isChecked());
713 else if( hypType()=="ViscousLayers" )
715 StdMeshers::StdMeshers_ViscousLayers_var h =
716 StdMeshers::StdMeshers_ViscousLayers::_narrow( hypothesis() );
718 h->SetVarParameter ( params[0].text(), "SetTotalThickness" );
719 h->SetTotalThickness( params[0].myValue.toDouble() );
720 h->SetVarParameter ( params[1].text(), "SetNumberLayers" );
721 h->SetNumberLayers ( params[1].myValue.toInt() );
722 h->SetVarParameter ( params[2].text(), "SetStretchFactor" );
723 h->SetStretchFactor ( params[2].myValue.toDouble() );
724 h->SetMethod (( StdMeshers::VLExtrusionMethod ) params[3].myValue.toInt() );
726 if ( StdMeshersGUI_SubShapeSelectorWdg* idsWg =
727 widget< StdMeshersGUI_SubShapeSelectorWdg >( 5 ))
729 h->SetFaces( idsWg->GetListOfIDs(), params[4].myValue.toInt() );
732 else if( hypType()=="ViscousLayers2D" )
734 StdMeshers::StdMeshers_ViscousLayers2D_var h =
735 StdMeshers::StdMeshers_ViscousLayers2D::_narrow( hypothesis() );
737 h->SetVarParameter ( params[0].text(), "SetTotalThickness" );
738 h->SetTotalThickness( params[0].myValue.toDouble() );
739 h->SetVarParameter ( params[1].text(), "SetNumberLayers" );
740 h->SetNumberLayers ( params[1].myValue.toInt() );
741 h->SetVarParameter ( params[2].text(), "SetStretchFactor" );
742 h->SetStretchFactor ( params[2].myValue.toDouble() );
744 if ( StdMeshersGUI_SubShapeSelectorWdg* idsWg =
745 widget< StdMeshersGUI_SubShapeSelectorWdg >( 4 ))
747 h->SetEdges( idsWg->GetListOfIDs(), params[3].myValue.toInt() );
750 // else if( hypType()=="QuadrangleParams" )
752 // StdMeshers::StdMeshers_QuadrangleParams_var h =
753 // StdMeshers::StdMeshers_QuadrangleParams::_narrow( hypothesis() );
754 // StdMeshersGUI_SubShapeSelectorWdg* w1 =
755 // widget< StdMeshersGUI_SubShapeSelectorWdg >( 0 );
756 // StdMeshersGUI_QuadrangleParamWdg* w2 =
757 // widget< StdMeshersGUI_QuadrangleParamWdg >( 1 );
759 // if (w1->GetListSize() > 0) {
760 // h->SetTriaVertex(w1->GetListOfIDs()[0]); // getlist must be called once
761 // const char * entry = w1->GetMainShapeEntry();
762 // h->SetObjectEntry(entry);
764 // h->SetQuadType(StdMeshers::QuadType(w2->GetType()));
771 //================================================================================
773 * \brief Return parameter values as SMESHGUI_GenericHypothesisCreator::StdParam
774 * \param p - list of parameters
775 * \retval bool - success flag
777 * Is called from SMESHGUI_GenericHypothesisCreator::buildStdFrame().
778 * Parameters will be shown using "standard" controls:
779 * Int by QtxIntSpinBox
780 * Double by SMESHGUI_SpinBox
781 * String by QLineEdit
782 * getCustomWidget() allows to redefine control for a parameter
784 //================================================================================
786 bool StdMeshersGUI_StdHypothesisCreator::stdParams( ListOfStdParams& p ) const
789 SMESHGUI_GenericHypothesisCreator::StdParam item;
792 customWidgets()->clear();
795 HypothesisData* data = SMESH::GetHypothesisData( hypType() );
796 item.myName = tr( "SMESH_NAME" );
797 item.myValue = data ? hypName() : QString();
799 customWidgets()->append(0);
802 SMESH::SMESH_Hypothesis_var hyp = initParamsHypothesis();
803 //SMESH::ListOfParameters_var aParameters = hyp->GetLastParameters();
805 if( hypType()=="LocalLength" )
807 StdMeshers::StdMeshers_LocalLength_var h =
808 StdMeshers::StdMeshers_LocalLength::_narrow( hyp );
810 item.myName = tr("SMESH_LOCAL_LENGTH_PARAM");
811 if(!initVariableName( hyp, item, "SetLength"))
812 item.myValue = h->GetLength();
815 item.myName = tr("SMESH_LOCAL_LENGTH_PRECISION");
816 if(!initVariableName( hyp, item, "SetPrecision"))
817 item.myValue = h->GetPrecision();
820 else if( hypType()=="MaxLength" )
822 StdMeshers::StdMeshers_MaxLength_var h =
823 StdMeshers::StdMeshers_MaxLength::_narrow( hyp );
824 // try to set a right preestimated length to edited hypothesis
825 bool noPreestimatedAtEdition = false;
826 if ( !isCreation() ) {
827 StdMeshers::StdMeshers_MaxLength_var initHyp =
828 StdMeshers::StdMeshers_MaxLength::_narrow( initParamsHypothesis(true) );
829 noPreestimatedAtEdition =
830 ( initHyp->_is_nil() || !initHyp->HavePreestimatedLength() );
831 if ( !noPreestimatedAtEdition )
832 h->SetPreestimatedLength( initHyp->GetPreestimatedLength() );
835 item.myName = tr("SMESH_LOCAL_LENGTH_PARAM");
836 if(!initVariableName( hyp, item, "SetLength"))
837 item.myValue = h->GetLength();
839 customWidgets()->append(0);
841 item.myName = tr("SMESH_USE_PREESTIMATED_LENGTH");
843 QCheckBox* aQCheckBox = new QCheckBox(dlg());
844 if ( !noPreestimatedAtEdition && h->HavePreestimatedLength() ) {
845 aQCheckBox->setChecked( h->GetUsePreestimatedLength() );
846 connect( aQCheckBox, SIGNAL( stateChanged(int) ), this, SLOT( onValueChanged() ) );
849 aQCheckBox->setChecked( false );
850 aQCheckBox->setEnabled( false );
852 customWidgets()->append( aQCheckBox );
854 else if( hypType()=="SegmentLengthAroundVertex" )
856 StdMeshers::StdMeshers_SegmentLengthAroundVertex_var h =
857 StdMeshers::StdMeshers_SegmentLengthAroundVertex::_narrow( hyp );
859 item.myName = tr("SMESH_LOCAL_LENGTH_PARAM");
860 if(!initVariableName( hyp, item, "SetLength"))
861 item.myValue = h->GetLength();
865 else if( hypType()=="Arithmetic1D" )
867 StdMeshers::StdMeshers_Arithmetic1D_var h =
868 StdMeshers::StdMeshers_Arithmetic1D::_narrow( hyp );
870 item.myName = tr( "SMESH_START_LENGTH_PARAM" );
871 if(!initVariableName( hyp, item, "SetStartLength" ))
872 item.myValue = h->GetLength( true );
875 customWidgets()->append (0);
877 item.myName = tr( "SMESH_END_LENGTH_PARAM" );
878 if(!initVariableName( hyp, item, "SetEndLength" ))
879 item.myValue = h->GetLength( false );
882 customWidgets()->append (0);
884 item.myName = tr( "SMESH_REVERSED_EDGES" );
887 customWidgets()->append ( makeReverseEdgesWdg( h->GetReversedEdges(), h->GetObjectEntry() ));
890 else if( hypType()=="GeometricProgression" )
892 StdMeshers::StdMeshers_Geometric1D_var h =
893 StdMeshers::StdMeshers_Geometric1D::_narrow( hyp );
895 item.myName = tr( "SMESH_START_LENGTH_PARAM" );
896 if(!initVariableName( hyp, item, "SetStartLength" ))
897 item.myValue = h->GetStartLength();
900 customWidgets()->append (0);
902 item.myName = tr( "SMESH_COMMON_RATIO" );
903 if(!initVariableName( hyp, item, "SetCommonRatio" ))
904 item.myValue = h->GetCommonRatio();
907 customWidgets()->append (0);
909 item.myName = tr( "SMESH_REVERSED_EDGES" );
912 customWidgets()->append ( makeReverseEdgesWdg( h->GetReversedEdges(), h->GetObjectEntry() ));
915 else if( hypType()=="FixedPoints1D" )
917 StdMeshers::StdMeshers_FixedPoints1D_var h =
918 StdMeshers::StdMeshers_FixedPoints1D::_narrow( hyp );
920 item.myName = tr( "SMESH_FIXED_POINTS" );
923 StdMeshersGUI_FixedPointsParamWdg* aFixedPointsWidget =
924 new StdMeshersGUI_FixedPointsParamWdg();
926 if ( !isCreation() ) {
927 aFixedPointsWidget->SetListOfPoints( h->GetPoints() );
928 aFixedPointsWidget->SetListOfSegments( h->GetNbSegments() );
930 customWidgets()->append( aFixedPointsWidget );
932 item.myName = tr( "SMESH_REVERSED_EDGES" );
935 customWidgets()->append ( makeReverseEdgesWdg( h->GetReversedEdges(), h->GetObjectEntry() ));
939 else if( hypType()=="MaxElementArea" )
941 StdMeshers::StdMeshers_MaxElementArea_var h =
942 StdMeshers::StdMeshers_MaxElementArea::_narrow( hyp );
944 item.myName = tr( "SMESH_MAX_ELEMENT_AREA_PARAM" );
945 if(!initVariableName( hyp, item, "SetMaxElementArea" ))
946 item.myValue = h->GetMaxElementArea();
950 else if( hypType()=="MaxElementVolume" )
952 StdMeshers::StdMeshers_MaxElementVolume_var h =
953 StdMeshers::StdMeshers_MaxElementVolume::_narrow( hyp );
955 item.myName = tr( "SMESH_MAX_ELEMENT_VOLUME_PARAM" );
956 if(!initVariableName( hyp, item, "SetMaxElementVolume" ))
957 item.myValue = h->GetMaxElementVolume();
960 else if( hypType()=="StartEndLength" )
962 StdMeshers::StdMeshers_StartEndLength_var h =
963 StdMeshers::StdMeshers_StartEndLength::_narrow( hyp );
965 item.myName = tr( "SMESH_START_LENGTH_PARAM" );
967 if(!initVariableName( hyp, item, "SetStartLength" ))
968 item.myValue = h->GetLength( true );
970 customWidgets()->append(0);
972 item.myName = tr( "SMESH_END_LENGTH_PARAM" );
973 if(!initVariableName( hyp, item, "SetEndLength" ))
974 item.myValue = h->GetLength( false );
976 customWidgets()->append(0);
978 item.myName = tr( "SMESH_REVERSED_EDGES" );
981 customWidgets()->append ( makeReverseEdgesWdg( h->GetReversedEdges(), h->GetObjectEntry() ));
983 else if( hypType()=="Deflection1D" )
985 StdMeshers::StdMeshers_Deflection1D_var h =
986 StdMeshers::StdMeshers_Deflection1D::_narrow( hyp );
988 item.myName = tr( "SMESH_DEFLECTION1D_PARAM" );
989 if(!initVariableName( hyp, item, "SetDeflection" ))
990 item.myValue = h->GetDeflection();
993 else if( hypType()=="Adaptive1D" )
995 StdMeshers::StdMeshers_Adaptive1D_var h =
996 StdMeshers::StdMeshers_Adaptive1D::_narrow( hyp );
998 item.myName = tr( "SMESH_MIN_SIZE" );
999 if(!initVariableName( hyp, item, "SetMinSize" ))
1000 item.myValue = h->GetMinSize();
1003 item.myName = tr( "SMESH_MAX_SIZE" );
1004 if(!initVariableName( hyp, item, "SetMaxSize" ))
1005 item.myValue = h->GetMaxSize();
1008 item.myName = tr( "SMESH_DEFLECTION1D_PARAM" );
1009 if(!initVariableName( hyp, item, "SetDeflection" ))
1010 item.myValue = h->GetDeflection();
1013 else if( hypType()=="AutomaticLength" )
1015 StdMeshers::StdMeshers_AutomaticLength_var h =
1016 StdMeshers::StdMeshers_AutomaticLength::_narrow( hyp );
1018 item.myName = tr( "SMESH_FINENESS_PARAM" );
1019 //item.myValue = h->GetFineness();
1021 SMESHGUI_SpinBox* _autoLengthSpinBox = new SMESHGUI_SpinBox(dlg());
1022 _autoLengthSpinBox->RangeStepAndValidator(0, 1, 0.01, "length_precision");
1023 _autoLengthSpinBox->SetValue(h->GetFineness());
1024 customWidgets()->append( _autoLengthSpinBox);
1026 else if( hypType()=="NumberOfLayers" )
1028 StdMeshers::StdMeshers_NumberOfLayers_var h =
1029 StdMeshers::StdMeshers_NumberOfLayers::_narrow( hyp );
1031 item.myName = tr( "SMESH_NUMBER_OF_LAYERS" );
1032 if(!initVariableName( hyp, item, "SetNumberOfLayers" ))
1033 item.myValue = (int) h->GetNumberOfLayers();
1036 else if( hypType()=="LayerDistribution" )
1038 StdMeshers::StdMeshers_LayerDistribution_var h =
1039 StdMeshers::StdMeshers_LayerDistribution::_narrow( hyp );
1041 item.myName = tr( "SMESH_LAYERS_DISTRIBUTION" ); p.append( item );
1042 initVariableName( hyp, item, "SetLayerDistribution" );
1043 customWidgets()->append ( new StdMeshersGUI_LayerDistributionParamWdg
1044 ( h, h->GetLayerDistribution(), hypName(), dlg() ));
1046 else if( hypType()=="NumberOfLayers2D" )
1048 StdMeshers::StdMeshers_NumberOfLayers2D_var h =
1049 StdMeshers::StdMeshers_NumberOfLayers2D::_narrow( hyp );
1051 item.myName = tr( "SMESH_NUMBER_OF_LAYERS" );
1052 if(!initVariableName( hyp, item, "SetNumberOfLayers" ))
1053 item.myValue = (int) h->GetNumberOfLayers();
1056 else if( hypType()=="LayerDistribution2D" )
1058 StdMeshers::StdMeshers_LayerDistribution2D_var h =
1059 StdMeshers::StdMeshers_LayerDistribution2D::_narrow( hyp );
1061 item.myName = tr( "SMESH_LAYERS_DISTRIBUTION" ); p.append( item );
1062 initVariableName( hyp, item, "SetLayerDistribution" );
1063 customWidgets()->append ( new StdMeshersGUI_LayerDistributionParamWdg
1064 ( h, h->GetLayerDistribution(), hypName(), dlg() ));
1066 else if( hypType()=="ProjectionSource1D" )
1068 StdMeshers::StdMeshers_ProjectionSource1D_var h =
1069 StdMeshers::StdMeshers_ProjectionSource1D::_narrow( hyp );
1071 item.myName = tr( "SMESH_SOURCE_EDGE" ); p.append( item );
1072 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 1 ),
1073 h->GetSourceEdge()));
1074 item.myName = tr( "SMESH_SOURCE_MESH" ); p.append( item );
1075 customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( SMESH::MESH ),
1076 h->GetSourceMesh()));
1077 item.myName = tr( "SMESH_SOURCE_VERTEX" ); p.append( item );
1078 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1079 h->GetSourceVertex()));
1080 item.myName = tr( "SMESH_TARGET_VERTEX" ); p.append( item );
1081 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1082 h->GetTargetVertex()));
1084 else if( hypType()=="ProjectionSource2D" )
1086 StdMeshers::StdMeshers_ProjectionSource2D_var h =
1087 StdMeshers::StdMeshers_ProjectionSource2D::_narrow( hyp );
1089 item.myName = tr( "SMESH_SOURCE_FACE" ); p.append( item );
1090 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 2 ),
1091 h->GetSourceFace()));
1092 item.myName = tr( "SMESH_SOURCE_MESH" ); p.append( item );
1093 customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( SMESH::MESH ),
1094 h->GetSourceMesh()));
1095 item.myName = tr( "SMESH_SOURCE_VERTEX1" ); p.append( item );
1096 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1097 h->GetSourceVertex( 1 )));
1098 item.myName = tr( "SMESH_TARGET_VERTEX1" ); p.append( item );
1099 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1100 h->GetTargetVertex( 1 )));
1101 item.myName = tr( "SMESH_SOURCE_VERTEX2" ); p.append( item );
1102 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1103 h->GetSourceVertex( 2 )));
1104 item.myName = tr( "SMESH_TARGET_VERTEX2" ); p.append( item );
1105 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1106 h->GetTargetVertex( 2 )));
1108 else if( hypType()=="ProjectionSource3D" )
1110 StdMeshers::StdMeshers_ProjectionSource3D_var h =
1111 StdMeshers::StdMeshers_ProjectionSource3D::_narrow( hyp );
1113 item.myName = tr( "SMESH_SOURCE_3DSHAPE" ); p.append( item );
1114 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 3, TopAbs_FACE, 6, true ),
1115 h->GetSource3DShape()));
1116 item.myName = tr( "SMESH_SOURCE_MESH" ); p.append( item );
1117 customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( SMESH::MESH ),
1118 h->GetSourceMesh()));
1119 item.myName = tr( "SMESH_SOURCE_VERTEX1" ); p.append( item );
1120 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1121 h->GetSourceVertex( 1 )));
1122 item.myName = tr( "SMESH_TARGET_VERTEX1" ); p.append( item );
1123 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1124 h->GetTargetVertex( 1 )));
1125 item.myName = tr( "SMESH_SOURCE_VERTEX2" ); p.append( item );
1126 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1127 h->GetSourceVertex( 2 )));
1128 item.myName = tr( "SMESH_TARGET_VERTEX2" ); p.append( item );
1129 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1130 h->GetTargetVertex( 2 )));
1132 else if( hypType()=="ImportSource1D" )
1134 StdMeshers::StdMeshers_ImportSource1D_var h =
1135 StdMeshers::StdMeshers_ImportSource1D::_narrow( hyp );
1137 SMESH::string_array_var groupEntries = h->GetSourceEdges();
1138 CORBA::Boolean toCopyMesh, toCopyGroups;
1139 h->GetCopySourceMesh(toCopyMesh, toCopyGroups);
1141 item.myName = tr( "SMESH_SOURCE_EDGES" ); p.append( item );
1142 customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( SMESH::GROUP_EDGE ),
1145 item.myName = tr( "SMESH_COPY_MESH" ); p.append( item );
1146 QCheckBox* aQCheckBox = new QCheckBox(dlg());
1147 aQCheckBox->setChecked( toCopyMesh );
1148 connect( aQCheckBox, SIGNAL( stateChanged(int) ), this, SLOT( onValueChanged() ));
1149 customWidgets()->append( aQCheckBox );
1151 item.myName = tr( "SMESH_TO_COPY_GROUPS" ); p.append( item );
1152 aQCheckBox = new QCheckBox(dlg());
1153 aQCheckBox->setChecked( toCopyGroups );
1154 aQCheckBox->setEnabled( toCopyMesh );
1155 customWidgets()->append( aQCheckBox );
1157 else if( hypType()=="ImportSource2D" )
1159 StdMeshers::StdMeshers_ImportSource2D_var h =
1160 StdMeshers::StdMeshers_ImportSource2D::_narrow( hyp );
1162 SMESH::string_array_var groupEntries = h->GetSourceFaces();
1163 CORBA::Boolean toCopyMesh, toCopyGroups;
1164 h->GetCopySourceMesh(toCopyMesh, toCopyGroups);
1166 item.myName = tr( "SMESH_SOURCE_FACES" ); p.append( item );
1167 customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( SMESH::GROUP_FACE ),
1170 item.myName = tr( "SMESH_COPY_MESH" ); p.append( item );
1171 QCheckBox* aQCheckBox = new QCheckBox(dlg());
1172 aQCheckBox->setChecked( toCopyMesh );
1173 connect( aQCheckBox, SIGNAL( stateChanged(int) ), this, SLOT( onValueChanged() ));
1174 customWidgets()->append( aQCheckBox );
1176 item.myName = tr( "SMESH_COPY_GROUPS" ); p.append( item );
1177 aQCheckBox = new QCheckBox(dlg());
1178 aQCheckBox->setChecked( toCopyGroups );
1179 aQCheckBox->setEnabled( toCopyMesh );
1180 customWidgets()->append( aQCheckBox );
1182 else if( hypType()=="ViscousLayers" )
1184 StdMeshers::StdMeshers_ViscousLayers_var h =
1185 StdMeshers::StdMeshers_ViscousLayers::_narrow( hyp );
1187 item.myName = tr( "SMESH_TOTAL_THICKNESS" );
1188 if(!initVariableName( hyp, item, "SetTotalThickness" ))
1189 item.myValue = h->GetTotalThickness();
1191 customWidgets()->append (0);
1193 item.myName = tr( "SMESH_NUMBER_OF_LAYERS" );
1194 if(!initVariableName( hyp, item, "SetNumberLayers" ))
1195 item.myValue = h->GetNumberLayers();
1197 customWidgets()->append (0);
1199 item.myName = tr( "SMESH_STRETCH_FACTOR" );
1200 if(!initVariableName( hyp, item, "SetStretchFactor" ))
1201 item.myValue = h->GetStretchFactor();
1203 customWidgets()->append (0);
1205 item.myName = tr( "EXTRUSION_METHOD" );
1207 StdMeshersGUI_RadioButtonsGrpWdg* methodWdg = new StdMeshersGUI_RadioButtonsGrpWdg("");
1208 methodWdg->setButtonLabels ( QStringList()
1209 << tr("EXTMETH_SURF_OFFSET_SMOOTH")
1210 << tr("EXTMETH_FACE_OFFSET")
1211 << tr("EXTMETH_NODE_OFFSET"),
1213 << tr("ICON_EXTMETH_SURF_OFFSET_SMOOTH")
1214 << tr("ICON_EXTMETH_FACE_OFFSET")
1215 << tr("ICON_EXTMETH_NODE_OFFSET"));
1216 methodWdg->setChecked( (int) h->GetMethod() );
1217 customWidgets()->append( methodWdg );
1219 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
1220 QString aSubEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
1221 if ( !aMainEntry.isEmpty() )
1223 item.myName = tr( "TO_IGNORE_FACES_OR_NOT" );
1226 StdMeshersGUI_RadioButtonsGrpWdg* ignoreWdg = new StdMeshersGUI_RadioButtonsGrpWdg("");
1227 ignoreWdg->setButtonLabels ( QStringList()
1228 << tr("NOT_TO_IGNORE_FACES")
1229 << tr("TO_IGNORE_FACES") );
1230 ignoreWdg->setChecked( h->GetIsToIgnoreFaces() );
1231 connect(ignoreWdg->getButtonGroup(),SIGNAL(buttonClicked(int)),this,SLOT(onValueChanged()));
1232 customWidgets()->append( ignoreWdg );
1235 tr( h->GetIsToIgnoreFaces() ? "SMESH_FACES_WO_LAYERS" : "SMESH_FACES_WITH_LAYERS" );
1238 StdMeshersGUI_SubShapeSelectorWdg* idsWg =
1239 new StdMeshersGUI_SubShapeSelectorWdg(0,TopAbs_FACE);
1241 idsWg->SetGeomShapeEntry( aSubEntry, aMainEntry );
1242 if ( idsWg->SetListOfIDs( h->GetFaces() ))
1244 idsWg->ShowPreview( true );
1248 SUIT_MessageBox::warning( dlg(),tr( "SMESH_WRN_WARNING" ),tr( "BAD_FACES_WARNING" ));
1249 idsWg->setEnabled( false );
1251 customWidgets()->append ( idsWg );
1254 else if( hypType()=="ViscousLayers2D" )
1256 StdMeshers::StdMeshers_ViscousLayers2D_var h =
1257 StdMeshers::StdMeshers_ViscousLayers2D::_narrow( hyp );
1259 item.myName = tr( "SMESH_TOTAL_THICKNESS" );
1260 if(!initVariableName( hyp, item, "SetTotalThickness" ))
1261 item.myValue = h->GetTotalThickness();
1263 customWidgets()->append (0);
1265 item.myName = tr( "SMESH_NUMBER_OF_LAYERS" );
1266 if(!initVariableName( hyp, item, "SetNumberLayers" ))
1267 item.myValue = h->GetNumberLayers();
1269 customWidgets()->append (0);
1271 item.myName = tr( "SMESH_STRETCH_FACTOR" );
1272 if(!initVariableName( hyp, item, "SetStretchFactor" ))
1273 item.myValue = h->GetStretchFactor();
1275 customWidgets()->append (0);
1277 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
1278 QString aSubEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
1279 if ( !aMainEntry.isEmpty() )
1281 item.myName = tr("TO_IGNORE_EDGES_OR_NOT");
1284 StdMeshersGUI_RadioButtonsGrpWdg* ignoreWdg = new StdMeshersGUI_RadioButtonsGrpWdg("");
1285 ignoreWdg->setButtonLabels ( QStringList()
1286 << tr("NOT_TO_IGNORE_EDGES")
1287 << tr("TO_IGNORE_EDGES") );
1288 ignoreWdg->setChecked( h->GetIsToIgnoreEdges() );
1289 connect(ignoreWdg->getButtonGroup(),SIGNAL(buttonClicked(int)),this,SLOT(onValueChanged()));
1290 customWidgets()->append( ignoreWdg );
1293 tr( h->GetIsToIgnoreEdges() ? "SMESH_EDGES_WO_LAYERS" : "SMESH_EDGES_WITH_LAYERS" );
1296 StdMeshersGUI_SubShapeSelectorWdg* idsWg =
1297 new StdMeshersGUI_SubShapeSelectorWdg(0,TopAbs_EDGE);
1299 idsWg->SetGeomShapeEntry( aSubEntry, aMainEntry );
1300 if ( idsWg->SetListOfIDs( h->GetEdges() ))
1302 idsWg->ShowPreview( true );
1306 SUIT_MessageBox::warning( dlg(),tr( "SMESH_WRN_WARNING" ),tr( "BAD_EDGES_WARNING" ));
1307 idsWg->setEnabled( false );
1309 customWidgets()->append ( idsWg );
1317 //================================================================================
1319 * \brief tune "standard" control
1320 * \param w - control widget
1321 * \param int - parameter index
1323 //================================================================================
1325 void StdMeshersGUI_StdHypothesisCreator::attuneStdWidget (QWidget* w, const int) const
1327 SMESHGUI_SpinBox* sb = w->inherits( "SMESHGUI_SpinBox" ) ? ( SMESHGUI_SpinBox* )w : 0;
1330 if( hypType()=="LocalLength" )
1332 if (sb->objectName() == tr("SMESH_LOCAL_LENGTH_PARAM"))
1333 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1334 else if (sb->objectName() == tr("SMESH_LOCAL_LENGTH_PRECISION"))
1335 sb->RangeStepAndValidator( 0.0, 1.0, 0.05, "len_tol_precision" );
1337 else if( hypType()=="Arithmetic1D" )
1339 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "parametric_precision" );
1341 else if( hypType()=="GeometricProgression" )
1343 if (sb->objectName() == tr("SMESH_START_LENGTH_PARAM"))
1344 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1345 else if (sb->objectName() == tr("SMESH_COMMON_RATIO"))
1346 sb->RangeStepAndValidator( -VALUE_MAX, VALUE_MAX, 0.5, "len_tol_precision" );
1348 else if( hypType()=="MaxLength" )
1350 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1351 sb->setEnabled( !widget< QCheckBox >( 1 )->isChecked() );
1352 sb->setMinimumWidth( 150 );
1354 else if( hypType()=="MaxElementArea" )
1356 sb->RangeStepAndValidator( VALUE_SMALL_2, VALUE_MAX_2, 1.0, "area_precision" );
1358 else if( hypType()=="MaxElementVolume" )
1360 sb->RangeStepAndValidator( VALUE_SMALL_3, VALUE_MAX_3, 1.0, "vol_precision" );
1362 else if( hypType()=="StartEndLength" )
1364 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1366 else if( hypType()=="Deflection1D" )
1368 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "parametric_precision" );
1370 else if( hypType()=="Adaptive1D" )
1372 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1374 else if( hypType().startsWith( "ViscousLayers" ))
1376 if (sb->objectName() == tr("SMESH_STRETCH_FACTOR"))
1377 sb->RangeStepAndValidator( 1.0, VALUE_MAX, 0.1, "parametric_precision" );
1379 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1381 else // default validator for possible ancestors
1383 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1386 else if ( SalomeApp_IntSpinBox* sb = qobject_cast< SalomeApp_IntSpinBox* >( w ))
1388 if ( hypType().startsWith( "NumberOfLayers" ) ||
1389 hypType().startsWith( "ViscousLayers" ))
1391 sb->setMinimum( 1 );
1396 //================================================================================
1398 * \brief Return dlg title
1399 * \retval QString - title string
1401 //================================================================================
1403 QString StdMeshersGUI_StdHypothesisCreator::caption() const
1405 return tr( QString( "SMESH_%1_TITLE" ).arg( hypTypeName( hypType() ) ).toLatin1().data() );
1408 //================================================================================
1410 * \brief return pixmap for dlg icon
1413 //================================================================================
1415 QPixmap StdMeshersGUI_StdHypothesisCreator::icon() const
1417 QString hypIconName = tr( QString( "ICON_DLG_%1" ).arg( hypTypeName( hypType() ) ).toLatin1().data() );
1418 return SMESHGUI::resourceMgr()->loadPixmap( "SMESH", hypIconName );
1421 //================================================================================
1423 * \brief Return hypothesis type name to show in dlg
1426 //================================================================================
1428 QString StdMeshersGUI_StdHypothesisCreator::type() const
1430 return tr( QString( "SMESH_%1_HYPOTHESIS" ).arg( hypTypeName( hypType() ) ).toLatin1().data() );
1433 //================================================================================
1435 * \brief String to insert in "SMESH_%1_HYPOTHESIS" to get hypothesis type name
1436 * from message resouce file
1437 * \param t - hypothesis type
1438 * \retval QString - result string
1440 //================================================================================
1442 QString StdMeshersGUI_StdHypothesisCreator::hypTypeName( const QString& t ) const
1444 static QMap<QString,QString> types;
1445 if( types.isEmpty() )
1447 types.insert( "LocalLength", "LOCAL_LENGTH" );
1448 types.insert( "NumberOfSegments", "NB_SEGMENTS" );
1449 types.insert( "MaxElementArea", "MAX_ELEMENT_AREA" );
1450 types.insert( "MaxElementVolume", "MAX_ELEMENT_VOLUME" );
1451 types.insert( "StartEndLength", "START_END_LENGTH" );
1452 types.insert( "Deflection1D", "DEFLECTION1D" );
1453 types.insert( "Adaptive1D", "ADAPTIVE1D" );
1454 types.insert( "Arithmetic1D", "ARITHMETIC_1D" );
1455 types.insert( "GeometricProgression", "GEOMETRIC_1D" );
1456 types.insert( "FixedPoints1D", "FIXED_POINTS_1D" );
1457 types.insert( "AutomaticLength", "AUTOMATIC_LENGTH" );
1458 types.insert( "ProjectionSource1D", "PROJECTION_SOURCE_1D" );
1459 types.insert( "ProjectionSource2D", "PROJECTION_SOURCE_2D" );
1460 types.insert( "ProjectionSource3D", "PROJECTION_SOURCE_3D" );
1461 types.insert( "ImportSource1D", "IMPORT_SOURCE_1D" );
1462 types.insert( "ImportSource2D", "IMPORT_SOURCE_2D" );
1463 types.insert( "NumberOfLayers", "NUMBER_OF_LAYERS" );
1464 types.insert( "LayerDistribution", "LAYER_DISTRIBUTION" );
1465 types.insert( "NumberOfLayers2D", "NUMBER_OF_LAYERS_2D" );
1466 types.insert( "LayerDistribution2D", "LAYER_DISTRIBUTION" );
1467 types.insert( "SegmentLengthAroundVertex", "SEGMENT_LENGTH_AROUND_VERTEX" );
1468 types.insert( "MaxLength", "MAX_LENGTH" );
1469 types.insert( "ViscousLayers", "VISCOUS_LAYERS" );
1470 types.insert( "ViscousLayers2D", "VISCOUS_LAYERS" );
1471 types.insert( "QuadrangleParams", "QUADRANGLE_PARAMS" );
1472 types.insert( "CartesianParameters3D", "CARTESIAN_PARAMS" );
1476 if( types.contains( t ) )
1483 //=======================================================================
1484 //function : getCustomWidget
1485 //purpose : is called from buildStdFrame()
1486 //=======================================================================
1488 QWidget* StdMeshersGUI_StdHypothesisCreator::getCustomWidget( const StdParam & param,
1490 const int index) const
1493 if ( index < customWidgets()->count() ) {
1494 w = customWidgets()->at( index );
1496 w->setParent( parent );
1497 w->move( QPoint( 0, 0 ) );
1503 //================================================================================
1505 * \brief Set param value taken from a custom widget
1506 * \param param - SMESHGUI_GenericHypothesisCreator::StdParam structure
1507 * \param widget - widget presenting param
1508 * \retval bool - success flag
1510 * this method is called from getStdParamFromDlg()
1512 //================================================================================
1514 bool StdMeshersGUI_StdHypothesisCreator::getParamFromCustomWidget( StdParam & param,
1515 QWidget* widget) const
1517 if ( hypType()=="AutomaticLength" ) {
1518 SMESHGUI_SpinBox* w = dynamic_cast<SMESHGUI_SpinBox*>( widget );
1520 param.myValue = w->GetValue();
1524 if ( hypType() == "MaxLength" ) {
1528 if ( widget->inherits( "StdMeshersGUI_ObjectReferenceParamWdg" ))
1530 // show only 1st reference value
1531 if ( true /*widget == getWidgetForParam( 0 )*/) {
1532 const StdMeshersGUI_ObjectReferenceParamWdg * w =
1533 static_cast<const StdMeshersGUI_ObjectReferenceParamWdg*>( widget );
1534 param.myValue = w->GetValue();
1538 if ( widget->inherits( "StdMeshersGUI_LayerDistributionParamWdg" ))
1540 const StdMeshersGUI_LayerDistributionParamWdg * w =
1541 static_cast<const StdMeshersGUI_LayerDistributionParamWdg*>( widget );
1542 param.myValue = w->GetValue();
1545 if ( widget->inherits( "StdMeshersGUI_SubShapeSelectorWdg" ))
1547 const StdMeshersGUI_SubShapeSelectorWdg * w =
1548 static_cast<const StdMeshersGUI_SubShapeSelectorWdg*>( widget );
1549 param.myValue = w->GetValue();
1552 // if ( widget->inherits( "StdMeshersGUI_QuadrangleParamWdg" ))
1554 // param.myValue = "QuadType";
1557 if ( widget->inherits( "StdMeshersGUI_FixedPointsParamWdg" ))
1559 const StdMeshersGUI_FixedPointsParamWdg * w =
1560 static_cast<const StdMeshersGUI_FixedPointsParamWdg*>( widget );
1561 param.myValue = w->GetValue();
1564 if ( widget->inherits( "QCheckBox" ))
1566 //const QCheckBox * w = static_cast<const QCheckBox*>( widget );
1567 //param.myValue = w->isChecked();
1570 if ( widget->inherits( "StdMeshersGUI_RadioButtonsGrpWdg" ))
1572 const StdMeshersGUI_RadioButtonsGrpWdg * w =
1573 static_cast<const StdMeshersGUI_RadioButtonsGrpWdg*>( widget );
1574 param.myValue = w->checkedId();
1580 //================================================================================
1582 * \brief called when operation cancelled
1584 //================================================================================
1586 void StdMeshersGUI_StdHypothesisCreator::onReject()
1588 if ( hypType().startsWith("ProjectionSource" ) ||
1589 hypType().startsWith("ImportSource" ))
1591 // Uninstall filters of StdMeshersGUI_ObjectReferenceParamWdg
1592 deactivateObjRefParamWdg( customWidgets() );
1596 //================================================================================
1598 * \brief Update widgets dependent on paramWidget
1600 //================================================================================
1602 void StdMeshersGUI_StdHypothesisCreator::valueChanged( QWidget* paramWidget)
1604 if ( hypType() == "MaxLength" && paramWidget == getWidgetForParam(1) )
1606 getWidgetForParam(0)->setEnabled( !widget< QCheckBox >( 1 )->isChecked() );
1607 if ( !getWidgetForParam(0)->isEnabled() ) {
1608 StdMeshers::StdMeshers_MaxLength_var h =
1609 StdMeshers::StdMeshers_MaxLength::_narrow( initParamsHypothesis() );
1610 widget< QtxDoubleSpinBox >( 0 )->setValue( h->GetPreestimatedLength() );
1613 else if ( hypType().startsWith("ImportSource") && paramWidget == getWidgetForParam(1) )
1615 QCheckBox* toCopyMesh = (QCheckBox*) paramWidget;
1616 QCheckBox* toCopyGroups = widget< QCheckBox >( 2 );
1617 if ( !toCopyMesh->isChecked() )
1619 toCopyGroups->setChecked( false );
1620 toCopyGroups->setEnabled( false );
1624 toCopyGroups->setEnabled( true );
1627 else if ( hypType().startsWith( "ViscousLayers" ) && paramWidget->inherits("QButtonGroup"))
1629 int widgetNumber = hypType() == "ViscousLayers2D" ? 3 : 4;
1630 if ( QLabel* label = getLabel( widgetNumber + 1 ) )
1632 bool toIgnore = widget< StdMeshersGUI_RadioButtonsGrpWdg >( widgetNumber )->checkedId();
1633 if ( hypType() == "ViscousLayers2D" )
1634 label->setText( tr( toIgnore ? "SMESH_EDGES_WO_LAYERS" : "SMESH_EDGES_WITH_LAYERS" ));
1636 label->setText( tr( toIgnore ? "SMESH_FACES_WO_LAYERS" : "SMESH_FACES_WITH_LAYERS" ));
1641 //================================================================================
1645 //================================================================================
1647 bool StdMeshersGUI_StdHypothesisCreator::initVariableName(SMESH::SMESH_Hypothesis_var theHyp,
1648 StdParam & theParams,
1649 const char* theMethod) const
1651 QString aVaribaleName = getVariableName( theMethod );
1652 theParams.isVariable = !aVaribaleName.isEmpty();
1653 if (theParams.isVariable)
1654 theParams.myValue = aVaribaleName;
1656 return theParams.isVariable;
1659 //================================================================================
1661 * \brief Creates two widgets used to define reversed edges for some 1D hypotheses
1662 * \param [in] edgeIDs - ids of reversed edges to set to the widgets
1663 * \param [in] shapeEntry - entry of a sub-shape of a sub-mesh if any
1664 * \return QWidget* - new StdMeshersGUI_SubShapeSelectorWdg;
1665 * new StdMeshersGUI_PropagationHelperWdg is stored in \a myHelperWidget field.
1667 //================================================================================
1670 StdMeshersGUI_StdHypothesisCreator::makeReverseEdgesWdg( SMESH::long_array_var edgeIDs,
1671 CORBA::String_var shapeEntry) const
1673 QString aGeomEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
1674 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
1675 if ( aGeomEntry.isEmpty() && shapeEntry.in() )
1676 aGeomEntry = shapeEntry.in();
1678 StdMeshersGUI_SubShapeSelectorWdg* wdg = new StdMeshersGUI_SubShapeSelectorWdg();
1679 wdg->SetGeomShapeEntry( aGeomEntry, aMainEntry );
1680 wdg->SetListOfIDs( edgeIDs );
1681 wdg->ShowPreview( true );
1683 if ( !aGeomEntry.isEmpty() || !aMainEntry.isEmpty() )
1684 const_cast<StdMeshersGUI_StdHypothesisCreator*>( this )->
1685 myHelperWidget = new StdMeshersGUI_PropagationHelperWdg( wdg );