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>
34 #include <SMESH_TypeFilter.hxx>
35 #include <SMESH_NumberFilter.hxx>
37 #include "StdMeshersGUI_FixedPointsParamWdg.h"
38 #include "StdMeshersGUI_LayerDistributionParamWdg.h"
39 #include "StdMeshersGUI_ObjectReferenceParamWdg.h"
40 #include "StdMeshersGUI_QuadrangleParamWdg.h"
41 #include "StdMeshersGUI_SubShapeSelectorWdg.h"
42 #include "StdMeshersGUI_RadioButtonsGrpWdg.h"
44 #include <SALOMEDSClient_Study.hxx>
46 #include <GEOM_wrap.hxx>
48 // SALOME GUI includes
49 #include <SUIT_ResourceMgr.h>
50 #include <SUIT_MessageBox.h>
53 #include <SALOMEconfig.h>
54 #include CORBA_SERVER_HEADER(SMESH_BasicHypothesis)
55 #include CORBA_SERVER_HEADER(SMESH_Mesh)
56 #include CORBA_SERVER_HEADER(SMESH_Group)
59 #include <QHBoxLayout>
63 #include <QButtonGroup>
65 const double VALUE_MAX = 1.0e+15, // COORD_MAX
66 VALUE_MAX_2 = VALUE_MAX * VALUE_MAX,
67 VALUE_MAX_3 = VALUE_MAX_2 * VALUE_MAX,
68 VALUE_SMALL = 1.0e-15,
69 VALUE_SMALL_2 = VALUE_SMALL * VALUE_SMALL,
70 VALUE_SMALL_3 = VALUE_SMALL_2 * VALUE_SMALL;
72 //================================================================================
75 * \param type - hypothesis type
77 //================================================================================
79 StdMeshersGUI_StdHypothesisCreator::StdMeshersGUI_StdHypothesisCreator( const QString& type )
80 : SMESHGUI_GenericHypothesisCreator( type )
84 //================================================================================
88 //================================================================================
90 StdMeshersGUI_StdHypothesisCreator::~StdMeshersGUI_StdHypothesisCreator()
94 //================================================================================
96 * \brief Return widget for i-th hypothesis parameter (got from myParamWidgets)
97 * \param i - index of hypothesis parameter
98 * \retval QWidget* - found widget
100 //================================================================================
102 QWidget* StdMeshersGUI_StdHypothesisCreator::getWidgetForParam( int i ) const
105 if ( isCreation() ) ++i; // skip widget of 'name' parameter
107 if ( i < myCustomWidgets.count() ) {
108 QList<QWidget*>::const_iterator anIt = myCustomWidgets.begin();
109 QList<QWidget*>::const_iterator aLast = myCustomWidgets.end();
110 for ( int j = 0 ; !w && anIt != aLast; ++anIt, ++j )
115 // list has no at() const, so we iterate
116 QList<QWidget*>::const_iterator anIt = widgets().begin();
117 QList<QWidget*>::const_iterator aLast = widgets().end();
118 for( int j = 0; !w && anIt!=aLast; anIt++, ++j ) {
126 //================================================================================
128 * \brief Allow modifing myCustomWidgets in const methods
129 * \retval ListOfWidgets* - non-const pointer to myCustomWidgets
131 //================================================================================
133 StdMeshersGUI_StdHypothesisCreator::ListOfWidgets*
134 StdMeshersGUI_StdHypothesisCreator::customWidgets() const
136 return const_cast< ListOfWidgets* >( & myCustomWidgets );
139 //================================================================================
141 * \brief Builds dlg layout
142 * \retval QFrame* - the built widget
144 //================================================================================
146 QFrame* StdMeshersGUI_StdHypothesisCreator::buildFrame()
148 return buildStdFrame();
151 //================================================================================
153 * \brief Initialise parameter values in controls
155 //================================================================================
157 void StdMeshersGUI_StdHypothesisCreator::retrieveParams() const
159 // buildStdFrame() sets values itself calling stdParams()
161 if ( hypType().startsWith("ProjectionSource" ))
163 // we use this method to connect depending custom widgets
164 StdMeshersGUI_ObjectReferenceParamWdg* widgetToActivate = 0;
165 ListOfWidgets::const_iterator anIt = myCustomWidgets.begin();
166 for ( ; anIt != myCustomWidgets.end(); anIt++)
168 if ( *anIt && (*anIt)->inherits("StdMeshersGUI_ObjectReferenceParamWdg"))
170 StdMeshersGUI_ObjectReferenceParamWdg * w1 =
171 ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
172 ListOfWidgets::const_iterator anIt2 = anIt;
173 for ( ++anIt2; anIt2 != myCustomWidgets.end(); anIt2++)
174 if ( *anIt2 && (*anIt2)->inherits("StdMeshersGUI_ObjectReferenceParamWdg"))
176 StdMeshersGUI_ObjectReferenceParamWdg * w2 =
177 ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt2 );
178 w1->AvoidSimultaneousSelection( w2 );
180 if ( !widgetToActivate )
181 widgetToActivate = w1;
184 if ( widgetToActivate )
185 widgetToActivate->activateSelection();
189 dlg()->setMinimumSize( dlg()->minimumSizeHint().width(), dlg()->minimumSizeHint().height() );
194 //================================================================================
196 * \brief Widget: slider with left and right labels
198 //================================================================================
200 class TDoubleSliderWith2Labels: public QWidget
203 TDoubleSliderWith2Labels( const QString& leftLabel, const QString& rightLabel,
204 const double initValue, const double bottom,
205 const double top , const double precision,
206 QWidget * parent=0 , const char * name=0 )
207 :QWidget(parent), _bottom(bottom), _precision(precision)
211 QHBoxLayout* aHBoxL = new QHBoxLayout(this);
213 if ( !leftLabel.isEmpty() ) {
214 QLabel* aLeftLabel = new QLabel( this );
215 aLeftLabel->setText( leftLabel );
216 aHBoxL->addWidget( aLeftLabel );
219 _slider = new QSlider( Qt::Horizontal, this );
220 _slider->setRange( 0, toInt( top ));
221 _slider->setValue( toInt( initValue ));
222 aHBoxL->addWidget( _slider );
224 if ( !rightLabel.isEmpty() ) {
225 QLabel* aRightLabel = new QLabel( this );
226 aRightLabel->setText( rightLabel );
227 aHBoxL->addWidget( aRightLabel );
232 double value() const { return _bottom + _slider->value() * _precision; }
233 QSlider * getSlider() const { return _slider; }
234 int toInt( double val ) const { return (int) ceil(( val - _bottom ) / _precision ); }
236 double _bottom, _precision;
240 //================================================================================
242 * \brief Retrieve GEOM_Object held by widget
244 //================================================================================
246 inline GEOM::GEOM_Object_var geomFromWdg(const QWidget* wdg)
248 const StdMeshersGUI_ObjectReferenceParamWdg * objRefWdg =
249 dynamic_cast<const StdMeshersGUI_ObjectReferenceParamWdg*>( wdg );
251 return objRefWdg->GetObject< GEOM::GEOM_Object >();
253 return GEOM::GEOM_Object::_nil();
255 //================================================================================
257 * \brief Retrieve SMESH_Mesh held by widget
259 //================================================================================
261 inline SMESH::SMESH_Mesh_var meshFromWdg(const QWidget* wdg)
263 const StdMeshersGUI_ObjectReferenceParamWdg * objRefWdg =
264 dynamic_cast<const StdMeshersGUI_ObjectReferenceParamWdg*>( wdg );
266 return objRefWdg->GetObject< SMESH::SMESH_Mesh >();
268 return SMESH::SMESH_Mesh::_nil();
270 //================================================================================
272 * \brief Retrieve SMESH_Mesh held by widget
274 //================================================================================
276 inline SMESH::ListOfGroups_var groupsFromWdg(const QWidget* wdg)
278 SMESH::ListOfGroups_var groups = new SMESH::ListOfGroups;
279 const StdMeshersGUI_ObjectReferenceParamWdg * objRefWdg =
280 dynamic_cast<const StdMeshersGUI_ObjectReferenceParamWdg*>( wdg );
283 groups->length( objRefWdg->NbObjects() );
284 for ( unsigned i = 0; i < groups->length(); ++i )
285 groups[i] = objRefWdg->GetObject< SMESH::SMESH_GroupBase >(i);
289 //================================================================================
291 * \brief creates a filter for selection of shapes of given dimension
292 * \param dim - dimension
293 * \param subShapeType - required type of sub-shapes, number of which must be \a nbSubShapes
294 * \param nbSubShapes - number of sub-shapes of given type
295 * \param closed - required closeness flag of a shape
296 * \retval SUIT_SelectionFilter* - created filter
298 //================================================================================
300 SUIT_SelectionFilter* filterForShapeOfDim(const int dim,
301 TopAbs_ShapeEnum subShapeType = TopAbs_SHAPE,
302 const int nbSubShapes = 0,
305 TColStd_MapOfInteger shapeTypes;
307 case 0: shapeTypes.Add( TopAbs_VERTEX ); break;
309 if ( subShapeType == TopAbs_SHAPE ) subShapeType = TopAbs_EDGE;
310 shapeTypes.Add( TopAbs_EDGE );
311 shapeTypes.Add( TopAbs_COMPOUND ); // for a group
314 if ( subShapeType == TopAbs_SHAPE ) subShapeType = TopAbs_FACE;
315 shapeTypes.Add( TopAbs_FACE );
316 shapeTypes.Add( TopAbs_COMPOUND ); // for a group
319 shapeTypes.Add( TopAbs_SHELL );
320 shapeTypes.Add( TopAbs_SOLID );
321 shapeTypes.Add( TopAbs_COMPSOLID );
322 shapeTypes.Add( TopAbs_COMPOUND );
325 return new SMESH_NumberFilter("GEOM", subShapeType, nbSubShapes,
326 shapeTypes, GEOM::GEOM_Object::_nil(), closed);
329 //================================================================================
331 * \brief Create a widget for object selection
332 * \param object - initial object
333 * \param filter - selection filter
334 * \retval QWidget* - created widget
336 //================================================================================
338 QWidget* newObjRefParamWdg( SUIT_SelectionFilter* filter,
339 CORBA::Object_var object)
341 StdMeshersGUI_ObjectReferenceParamWdg* w =
342 new StdMeshersGUI_ObjectReferenceParamWdg( filter, 0);
343 w->SetObject( object.in() );
346 QWidget* newObjRefParamWdg( SUIT_SelectionFilter* filter,
347 SMESH::string_array_var& objEntries)
349 StdMeshersGUI_ObjectReferenceParamWdg* w =
350 new StdMeshersGUI_ObjectReferenceParamWdg( filter, 0, /*multiSel=*/true);
351 //RNV: Firstly, activate selection, then set objects
352 w->activateSelection();
353 w->SetObjects( objEntries );
357 //================================================================================
359 * \brief calls deactivateSelection() for StdMeshersGUI_ObjectReferenceParamWdg
360 * \param widgetList - list of widgets
362 //================================================================================
364 void deactivateObjRefParamWdg( QList<QWidget*>* widgetList )
366 StdMeshersGUI_ObjectReferenceParamWdg* w = 0;
367 QList<QWidget*>::iterator anIt = widgetList->begin();
368 QList<QWidget*>::iterator aLast = widgetList->end();
369 for ( ; anIt != aLast; anIt++ ) {
370 if ( (*anIt) && (*anIt)->inherits( "StdMeshersGUI_ObjectReferenceParamWdg" ))
372 w = (StdMeshersGUI_ObjectReferenceParamWdg* )( *anIt );
373 w->deactivateSelection();
379 //================================================================================
381 * \brief Check parameter values before accept()
382 * \retval bool - true if OK
384 //================================================================================
386 bool StdMeshersGUI_StdHypothesisCreator::checkParams( QString& msg ) const
388 if( !SMESHGUI_GenericHypothesisCreator::checkParams( msg ) )
391 // check if object reference parameter is set, as it has no default value
393 if ( hypType().startsWith("ProjectionSource" ))
395 StdMeshersGUI_ObjectReferenceParamWdg* w =
396 widget< StdMeshersGUI_ObjectReferenceParamWdg >( 0 );
397 ok = ( w->IsObjectSelected() );
398 if ( !ok ) w->SetObject( CORBA::Object::_nil() );
399 int nbAssocVert = ( hypType() == "ProjectionSource1D" ? 1 : 2 );
400 int nbNonEmptyAssoc = 0;
401 for ( int i = 0; ok && i < nbAssocVert*2; i += 2)
404 StdMeshersGUI_ObjectReferenceParamWdg* w1 =
405 widget< StdMeshersGUI_ObjectReferenceParamWdg >( i+2 );
406 StdMeshersGUI_ObjectReferenceParamWdg* w2 =
407 widget< StdMeshersGUI_ObjectReferenceParamWdg >( i+3 );
408 srcV = w1->GetValue();
409 tgtV = w2->GetValue();
410 ok = (( srcV.isEmpty() && tgtV.isEmpty() ) ||
411 ( !srcV.isEmpty() && !tgtV.isEmpty() /*&& srcV != tgtV*/ ));
413 w1->SetObject( CORBA::Object::_nil() );
414 w2->SetObject( CORBA::Object::_nil() );
416 nbNonEmptyAssoc += !srcV.isEmpty();
418 if ( ok && nbNonEmptyAssoc == 1 && nbAssocVert == 2 )
420 // only one pair of VERTEXes is given for a FACE,
421 // then the FACE must have only one VERTEX
422 GEOM::GEOM_Object_var face = w->GetObject< GEOM::GEOM_Object >();
424 GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen();
425 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
426 GEOM::GEOM_IShapesOperations_wrap shapeOp;
427 if ( !geomGen->_is_nil() && aStudy )
428 shapeOp = geomGen->GetIShapesOperations( aStudy->StudyId() );
429 if ( !shapeOp->_is_nil() )
431 GEOM::ListOfLong_var vertices =
432 shapeOp->GetAllSubShapesIDs (face, GEOM::VERTEX, /*isSorted=*/false);
433 ok = ( vertices->length() == 1 );
436 // Uninstall filters of StdMeshersGUI_ObjectReferenceParamWdg
438 deactivateObjRefParamWdg( customWidgets() );
440 else if ( hypType().startsWith("ImportSource" ))
442 StdMeshersGUI_ObjectReferenceParamWdg* w =
443 widget< StdMeshersGUI_ObjectReferenceParamWdg >( 0 );
444 ok = ( w->IsObjectSelected() );
446 else if ( hypType() == "LayerDistribution" || hypType() == "LayerDistribution2D" )
448 StdMeshersGUI_LayerDistributionParamWdg* w =
449 widget< StdMeshersGUI_LayerDistributionParamWdg >( 0 );
450 ok = ( w && w->IsOk() );
456 //================================================================================
458 * \brief Store params from GUI controls to a hypothesis
459 * \retval QString - text representation of parameters
461 //================================================================================
463 QString StdMeshersGUI_StdHypothesisCreator::storeParams() const
465 ListOfStdParams params;
466 bool res = getStdParamFromDlg( params );
469 SMESH::SetName( SMESH::FindSObject( hypothesis() ), params[0].myValue.toString().toLatin1().data() );
470 params.erase( params.begin() );
473 QString valueStr = stdParamValues( params );
474 //QStringList aVariablesList = getVariablesFromDlg();
476 if( res && !params.isEmpty() )
478 if( hypType()=="LocalLength" )
480 StdMeshers::StdMeshers_LocalLength_var h =
481 StdMeshers::StdMeshers_LocalLength::_narrow( hypothesis() );
483 h->SetVarParameter( params[0].text(), "SetLength" );
484 h->SetLength( params[0].myValue.toDouble() );
485 h->SetVarParameter( params[1].text(), "SetPrecision" );
486 h->SetPrecision( params[1].myValue.toDouble() );
488 else if( hypType()=="MaxLength" )
490 StdMeshers::StdMeshers_MaxLength_var h =
491 StdMeshers::StdMeshers_MaxLength::_narrow( hypothesis() );
493 h->SetVarParameter( params[0].text(), "SetLength" );
494 h->SetLength( params[0].myValue.toDouble() );
495 h->SetUsePreestimatedLength( widget< QCheckBox >( 1 )->isChecked() );
496 if ( !h->HavePreestimatedLength() && !h->_is_equivalent( initParamsHypothesis() )) {
497 StdMeshers::StdMeshers_MaxLength_var hInit =
498 StdMeshers::StdMeshers_MaxLength::_narrow( initParamsHypothesis() );
499 h->SetPreestimatedLength( hInit->GetPreestimatedLength() );
502 else if( hypType()=="SegmentLengthAroundVertex" )
504 StdMeshers::StdMeshers_SegmentLengthAroundVertex_var h =
505 StdMeshers::StdMeshers_SegmentLengthAroundVertex::_narrow( hypothesis() );
507 h->SetVarParameter( params[0].text(), "SetLength" );
508 h->SetLength( params[0].myValue.toDouble() );
510 else if( hypType()=="Arithmetic1D" )
512 StdMeshers::StdMeshers_Arithmetic1D_var h =
513 StdMeshers::StdMeshers_Arithmetic1D::_narrow( hypothesis() );
515 StdMeshersGUI_SubShapeSelectorWdg* w =
516 widget< StdMeshersGUI_SubShapeSelectorWdg >( 2 );
518 h->SetVarParameter( params[0].text(), "SetStartLength" );
519 h->SetStartLength( params[0].myValue.toDouble() );
520 h->SetVarParameter( params[1].text(), "SetEndLength" );
521 h->SetEndLength( params[1].myValue.toDouble() );
523 h->SetReversedEdges( w->GetListOfIDs() );
524 h->SetObjectEntry( w->GetMainShapeEntry() );
527 else if( hypType()=="GeometricProgression" )
529 StdMeshers::StdMeshers_Geometric1D_var h =
530 StdMeshers::StdMeshers_Geometric1D::_narrow( hypothesis() );
532 StdMeshersGUI_SubShapeSelectorWdg* w =
533 widget< StdMeshersGUI_SubShapeSelectorWdg >( 2 );
535 h->SetVarParameter( params[0].text(), "SetStartLength" );
536 h->SetStartLength( params[0].myValue.toDouble() );
537 h->SetVarParameter( params[1].text(), "SetCommonRatio" );
538 h->SetCommonRatio( params[1].myValue.toDouble() );
540 h->SetReversedEdges( w->GetListOfIDs() );
541 h->SetObjectEntry( w->GetMainShapeEntry() );
544 else if( hypType()=="FixedPoints1D" )
546 StdMeshers::StdMeshers_FixedPoints1D_var h =
547 StdMeshers::StdMeshers_FixedPoints1D::_narrow( hypothesis() );
549 StdMeshersGUI_FixedPointsParamWdg* w1 =
550 widget< StdMeshersGUI_FixedPointsParamWdg >( 0 );
552 StdMeshersGUI_SubShapeSelectorWdg* w2 =
553 widget< StdMeshersGUI_SubShapeSelectorWdg >( 1 );
556 h->SetPoints( w1->GetListOfPoints() );
557 h->SetNbSegments( w1->GetListOfSegments() );
560 h->SetReversedEdges( w2->GetListOfIDs() );
561 h->SetObjectEntry( w2->GetMainShapeEntry() );
564 else if( hypType()=="MaxElementArea" )
566 StdMeshers::StdMeshers_MaxElementArea_var h =
567 StdMeshers::StdMeshers_MaxElementArea::_narrow( hypothesis() );
568 h->SetVarParameter( params[0].text(), "SetMaxElementArea" );
569 h->SetMaxElementArea( params[0].myValue.toDouble() );
571 else if( hypType()=="MaxElementVolume" )
573 StdMeshers::StdMeshers_MaxElementVolume_var h =
574 StdMeshers::StdMeshers_MaxElementVolume::_narrow( hypothesis() );
576 h->SetVarParameter( params[0].text(), "SetMaxElementVolume" );
577 h->SetMaxElementVolume( params[0].myValue.toDouble() );
579 else if( hypType()=="StartEndLength" )
581 StdMeshers::StdMeshers_StartEndLength_var h =
582 StdMeshers::StdMeshers_StartEndLength::_narrow( hypothesis() );
584 StdMeshersGUI_SubShapeSelectorWdg* w =
585 widget< StdMeshersGUI_SubShapeSelectorWdg >( 2 );
587 h->SetVarParameter( params[0].text(), "SetStartLength" );
588 h->SetStartLength( params[0].myValue.toDouble() );
589 h->SetVarParameter( params[1].text(), "SetEndLength" );
590 h->SetEndLength( params[1].myValue.toDouble() );
592 h->SetReversedEdges( w->GetListOfIDs() );
593 h->SetObjectEntry( w->GetMainShapeEntry() );
596 else if( hypType()=="Deflection1D" )
598 StdMeshers::StdMeshers_Deflection1D_var h =
599 StdMeshers::StdMeshers_Deflection1D::_narrow( hypothesis() );
600 h->SetVarParameter( params[0].text(), "SetDeflection" );
601 h->SetDeflection( params[0].myValue.toDouble() );
603 else if( hypType()=="Adaptive1D" )
605 StdMeshers::StdMeshers_Adaptive1D_var h =
606 StdMeshers::StdMeshers_Adaptive1D::_narrow( hypothesis() );
607 h->SetVarParameter( params[0].text(), "SetMinSize" );
608 h->SetMinSize( params[0].myValue.toDouble() );
609 h->SetVarParameter( params[0].text(), "SetMaxSize" );
610 h->SetMaxSize( params[1].myValue.toDouble() );
611 h->SetVarParameter( params[0].text(), "SetDeflection" );
612 h->SetDeflection( params[2].myValue.toDouble() );
614 else if( hypType()=="AutomaticLength" )
616 StdMeshers::StdMeshers_AutomaticLength_var h =
617 StdMeshers::StdMeshers_AutomaticLength::_narrow( hypothesis() );
619 h->SetVarParameter( params[0].text(), "SetFineness" );
620 h->SetFineness( params[0].myValue.toDouble() );
622 else if( hypType()=="NumberOfLayers" )
624 StdMeshers::StdMeshers_NumberOfLayers_var h =
625 StdMeshers::StdMeshers_NumberOfLayers::_narrow( hypothesis() );
627 h->SetVarParameter( params[0].text(), "SetNumberOfLayers" );
628 h->SetNumberOfLayers( params[0].myValue.toInt() );
630 else if( hypType()=="LayerDistribution" )
632 StdMeshers::StdMeshers_LayerDistribution_var h =
633 StdMeshers::StdMeshers_LayerDistribution::_narrow( hypothesis() );
634 StdMeshersGUI_LayerDistributionParamWdg* w =
635 widget< StdMeshersGUI_LayerDistributionParamWdg >( 0 );
637 h->SetLayerDistribution( w->GetHypothesis() );
639 else if( hypType()=="NumberOfLayers2D" )
641 StdMeshers::StdMeshers_NumberOfLayers2D_var h =
642 StdMeshers::StdMeshers_NumberOfLayers2D::_narrow( hypothesis() );
644 h->SetVarParameter( params[0].text(), "SetNumberOfLayers" );
645 h->SetNumberOfLayers( params[0].myValue.toInt() );
647 else if( hypType()=="LayerDistribution2D" )
649 StdMeshers::StdMeshers_LayerDistribution2D_var h =
650 StdMeshers::StdMeshers_LayerDistribution2D::_narrow( hypothesis() );
651 StdMeshersGUI_LayerDistributionParamWdg* w =
652 widget< StdMeshersGUI_LayerDistributionParamWdg >( 0 );
654 h->SetLayerDistribution( w->GetHypothesis() );
656 else if( hypType()=="ProjectionSource1D" )
658 StdMeshers::StdMeshers_ProjectionSource1D_var h =
659 StdMeshers::StdMeshers_ProjectionSource1D::_narrow( hypothesis() );
661 h->SetSourceEdge ( geomFromWdg ( getWidgetForParam( 0 )));
662 h->SetSourceMesh ( meshFromWdg ( getWidgetForParam( 1 )));
663 h->SetVertexAssociation( geomFromWdg ( getWidgetForParam( 2 )),
664 geomFromWdg ( getWidgetForParam( 3 )));
666 else if( hypType()=="ProjectionSource2D" )
668 StdMeshers::StdMeshers_ProjectionSource2D_var h =
669 StdMeshers::StdMeshers_ProjectionSource2D::_narrow( hypothesis() );
671 h->SetSourceFace ( geomFromWdg ( getWidgetForParam( 0 )));
672 h->SetSourceMesh ( meshFromWdg ( getWidgetForParam( 1 )));
673 h->SetVertexAssociation( geomFromWdg ( getWidgetForParam( 2 )), // src1
674 geomFromWdg ( getWidgetForParam( 4 )), // src2
675 geomFromWdg ( getWidgetForParam( 3 )), // tgt1
676 geomFromWdg ( getWidgetForParam( 5 ))); // tgt2
678 else if( hypType()=="ProjectionSource3D" )
680 StdMeshers::StdMeshers_ProjectionSource3D_var h =
681 StdMeshers::StdMeshers_ProjectionSource3D::_narrow( hypothesis() );
683 h->SetSource3DShape ( geomFromWdg ( getWidgetForParam( 0 )));
684 h->SetSourceMesh ( meshFromWdg ( getWidgetForParam( 1 )));
685 h->SetVertexAssociation( geomFromWdg ( getWidgetForParam( 2 )), // src1
686 geomFromWdg ( getWidgetForParam( 4 )), // src2
687 geomFromWdg ( getWidgetForParam( 3 )), // tgt1
688 geomFromWdg ( getWidgetForParam( 5 ))); // tgt2
690 else if( hypType()=="ImportSource1D" )
692 StdMeshers::StdMeshers_ImportSource1D_var h =
693 StdMeshers::StdMeshers_ImportSource1D::_narrow( hypothesis() );
695 SMESH::ListOfGroups_var groups = groupsFromWdg( getWidgetForParam( 0 ));
696 h->SetSourceEdges( groups.in() );
697 QCheckBox* toCopyMesh = widget< QCheckBox >( 1 );
698 QCheckBox* toCopyGroups = widget< QCheckBox >( 2 );
699 h->SetCopySourceMesh( toCopyMesh->isChecked(), toCopyGroups->isChecked());
701 else if( hypType()=="ImportSource2D" )
703 StdMeshers::StdMeshers_ImportSource2D_var h =
704 StdMeshers::StdMeshers_ImportSource2D::_narrow( hypothesis() );
706 SMESH::ListOfGroups_var groups = groupsFromWdg( getWidgetForParam( 0 ));
707 h->SetSourceFaces( groups.in() );
708 QCheckBox* toCopyMesh = widget< QCheckBox >( 1 );
709 QCheckBox* toCopyGroups = widget< QCheckBox >( 2 );
710 h->SetCopySourceMesh( toCopyMesh->isChecked(), toCopyGroups->isChecked());
712 else if( hypType()=="ViscousLayers" )
714 StdMeshers::StdMeshers_ViscousLayers_var h =
715 StdMeshers::StdMeshers_ViscousLayers::_narrow( hypothesis() );
717 h->SetVarParameter ( params[0].text(), "SetTotalThickness" );
718 h->SetTotalThickness( params[0].myValue.toDouble() );
719 h->SetVarParameter ( params[1].text(), "SetNumberLayers" );
720 h->SetNumberLayers ( params[1].myValue.toInt() );
721 h->SetVarParameter ( params[2].text(), "SetStretchFactor" );
722 h->SetStretchFactor ( params[2].myValue.toDouble() );
723 h->SetMethod (( StdMeshers::VLExtrusionMethod ) params[3].myValue.toInt() );
725 if ( StdMeshersGUI_SubShapeSelectorWdg* idsWg =
726 widget< StdMeshersGUI_SubShapeSelectorWdg >( 5 ))
728 h->SetFaces( idsWg->GetListOfIDs(), params[4].myValue.toInt() );
731 else if( hypType()=="ViscousLayers2D" )
733 StdMeshers::StdMeshers_ViscousLayers2D_var h =
734 StdMeshers::StdMeshers_ViscousLayers2D::_narrow( hypothesis() );
736 h->SetVarParameter ( params[0].text(), "SetTotalThickness" );
737 h->SetTotalThickness( params[0].myValue.toDouble() );
738 h->SetVarParameter ( params[1].text(), "SetNumberLayers" );
739 h->SetNumberLayers ( params[1].myValue.toInt() );
740 h->SetVarParameter ( params[2].text(), "SetStretchFactor" );
741 h->SetStretchFactor ( params[2].myValue.toDouble() );
743 if ( StdMeshersGUI_SubShapeSelectorWdg* idsWg =
744 widget< StdMeshersGUI_SubShapeSelectorWdg >( 4 ))
746 h->SetEdges( idsWg->GetListOfIDs(), params[3].myValue.toInt() );
749 // else if( hypType()=="QuadrangleParams" )
751 // StdMeshers::StdMeshers_QuadrangleParams_var h =
752 // StdMeshers::StdMeshers_QuadrangleParams::_narrow( hypothesis() );
753 // StdMeshersGUI_SubShapeSelectorWdg* w1 =
754 // widget< StdMeshersGUI_SubShapeSelectorWdg >( 0 );
755 // StdMeshersGUI_QuadrangleParamWdg* w2 =
756 // widget< StdMeshersGUI_QuadrangleParamWdg >( 1 );
758 // if (w1->GetListSize() > 0) {
759 // h->SetTriaVertex(w1->GetListOfIDs()[0]); // getlist must be called once
760 // const char * entry = w1->GetMainShapeEntry();
761 // h->SetObjectEntry(entry);
763 // h->SetQuadType(StdMeshers::QuadType(w2->GetType()));
770 //================================================================================
772 * \brief Return parameter values as SMESHGUI_GenericHypothesisCreator::StdParam
773 * \param p - list of parameters
774 * \retval bool - success flag
776 * Is called from SMESHGUI_GenericHypothesisCreator::buildStdFrame().
777 * Parameters will be shown using "standard" controls:
778 * Int by QtxIntSpinBox
779 * Double by SMESHGUI_SpinBox
780 * String by QLineEdit
781 * getCustomWidget() allows to redefine control for a parameter
783 //================================================================================
785 bool StdMeshersGUI_StdHypothesisCreator::stdParams( ListOfStdParams& p ) const
788 SMESHGUI_GenericHypothesisCreator::StdParam item;
791 customWidgets()->clear();
794 HypothesisData* data = SMESH::GetHypothesisData( hypType() );
795 item.myName = tr( "SMESH_NAME" );
796 item.myValue = data ? hypName() : QString();
798 customWidgets()->append(0);
801 SMESH::SMESH_Hypothesis_var hyp = initParamsHypothesis();
802 //SMESH::ListOfParameters_var aParameters = hyp->GetLastParameters();
804 if( hypType()=="LocalLength" )
806 StdMeshers::StdMeshers_LocalLength_var h =
807 StdMeshers::StdMeshers_LocalLength::_narrow( hyp );
809 item.myName = tr("SMESH_LOCAL_LENGTH_PARAM");
810 if(!initVariableName( hyp, item, "SetLength"))
811 item.myValue = h->GetLength();
814 item.myName = tr("SMESH_LOCAL_LENGTH_PRECISION");
815 if(!initVariableName( hyp, item, "SetPrecision"))
816 item.myValue = h->GetPrecision();
819 else if( hypType()=="MaxLength" )
821 StdMeshers::StdMeshers_MaxLength_var h =
822 StdMeshers::StdMeshers_MaxLength::_narrow( hyp );
823 // try to set a right preestimated length to edited hypothesis
824 bool noPreestimatedAtEdition = false;
825 if ( !isCreation() ) {
826 StdMeshers::StdMeshers_MaxLength_var initHyp =
827 StdMeshers::StdMeshers_MaxLength::_narrow( initParamsHypothesis(true) );
828 noPreestimatedAtEdition =
829 ( initHyp->_is_nil() || !initHyp->HavePreestimatedLength() );
830 if ( !noPreestimatedAtEdition )
831 h->SetPreestimatedLength( initHyp->GetPreestimatedLength() );
834 item.myName = tr("SMESH_LOCAL_LENGTH_PARAM");
835 if(!initVariableName( hyp, item, "SetLength"))
836 item.myValue = h->GetLength();
838 customWidgets()->append(0);
840 item.myName = tr("SMESH_USE_PREESTIMATED_LENGTH");
842 QCheckBox* aQCheckBox = new QCheckBox(dlg());
843 if ( !noPreestimatedAtEdition && h->HavePreestimatedLength() ) {
844 aQCheckBox->setChecked( h->GetUsePreestimatedLength() );
845 connect( aQCheckBox, SIGNAL( stateChanged(int) ), this, SLOT( onValueChanged() ) );
848 aQCheckBox->setChecked( false );
849 aQCheckBox->setEnabled( false );
851 customWidgets()->append( aQCheckBox );
853 else if( hypType()=="SegmentLengthAroundVertex" )
855 StdMeshers::StdMeshers_SegmentLengthAroundVertex_var h =
856 StdMeshers::StdMeshers_SegmentLengthAroundVertex::_narrow( hyp );
858 item.myName = tr("SMESH_LOCAL_LENGTH_PARAM");
859 if(!initVariableName( hyp, item, "SetLength"))
860 item.myValue = h->GetLength();
864 else if( hypType()=="Arithmetic1D" )
866 StdMeshers::StdMeshers_Arithmetic1D_var h =
867 StdMeshers::StdMeshers_Arithmetic1D::_narrow( hyp );
869 item.myName = tr( "SMESH_START_LENGTH_PARAM" );
870 if(!initVariableName( hyp, item, "SetStartLength" ))
871 item.myValue = h->GetLength( true );
874 customWidgets()->append (0);
876 item.myName = tr( "SMESH_END_LENGTH_PARAM" );
877 if(!initVariableName( hyp, item, "SetEndLength" ))
878 item.myValue = h->GetLength( false );
881 customWidgets()->append (0);
883 item.myName = tr( "SMESH_REVERSED_EDGES" );
886 StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget =
887 new StdMeshersGUI_SubShapeSelectorWdg();
888 QString aGeomEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
889 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
890 if ( aGeomEntry == "" )
891 aGeomEntry = h->GetObjectEntry();
893 aDirectionWidget->SetGeomShapeEntry( aGeomEntry );
894 aDirectionWidget->SetMainShapeEntry( aMainEntry );
895 aDirectionWidget->SetListOfIDs( h->GetReversedEdges() );
896 aDirectionWidget->showPreview( true );
897 customWidgets()->append ( aDirectionWidget );
900 else if( hypType()=="GeometricProgression" )
902 StdMeshers::StdMeshers_Geometric1D_var h =
903 StdMeshers::StdMeshers_Geometric1D::_narrow( hyp );
905 item.myName = tr( "SMESH_START_LENGTH_PARAM" );
906 if(!initVariableName( hyp, item, "SetStartLength" ))
907 item.myValue = h->GetStartLength();
910 customWidgets()->append (0);
912 item.myName = tr( "SMESH_COMMON_RATIO" );
913 if(!initVariableName( hyp, item, "SetCommonRatio" ))
914 item.myValue = h->GetCommonRatio();
917 customWidgets()->append (0);
919 item.myName = tr( "SMESH_REVERSED_EDGES" );
922 StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget =
923 new StdMeshersGUI_SubShapeSelectorWdg();
924 QString aGeomEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
925 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
926 if ( aGeomEntry == "" )
927 aGeomEntry = h->GetObjectEntry();
929 aDirectionWidget->SetGeomShapeEntry( aGeomEntry );
930 aDirectionWidget->SetMainShapeEntry( aMainEntry );
931 aDirectionWidget->SetListOfIDs( h->GetReversedEdges() );
932 aDirectionWidget->showPreview( true );
933 customWidgets()->append ( aDirectionWidget );
936 else if( hypType()=="FixedPoints1D" )
938 StdMeshers::StdMeshers_FixedPoints1D_var h =
939 StdMeshers::StdMeshers_FixedPoints1D::_narrow( hyp );
941 item.myName = tr( "SMESH_FIXED_POINTS" );
944 StdMeshersGUI_FixedPointsParamWdg* aFixedPointsWidget =
945 new StdMeshersGUI_FixedPointsParamWdg();
947 if ( !isCreation() ) {
948 aFixedPointsWidget->SetListOfPoints( h->GetPoints() );
949 aFixedPointsWidget->SetListOfSegments( h->GetNbSegments() );
951 customWidgets()->append( aFixedPointsWidget );
953 item.myName = tr( "SMESH_REVERSED_EDGES" );
956 StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget =
957 new StdMeshersGUI_SubShapeSelectorWdg();
958 QString anEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
959 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
961 anEntry = h->GetObjectEntry();
962 aDirectionWidget->SetGeomShapeEntry( anEntry );
963 aDirectionWidget->SetMainShapeEntry( aMainEntry );
964 aDirectionWidget->SetListOfIDs( h->GetReversedEdges() );
965 aDirectionWidget->showPreview( true );
966 customWidgets()->append ( aDirectionWidget );
970 else if( hypType()=="MaxElementArea" )
972 StdMeshers::StdMeshers_MaxElementArea_var h =
973 StdMeshers::StdMeshers_MaxElementArea::_narrow( hyp );
975 item.myName = tr( "SMESH_MAX_ELEMENT_AREA_PARAM" );
976 if(!initVariableName( hyp, item, "SetMaxElementArea" ))
977 item.myValue = h->GetMaxElementArea();
981 else if( hypType()=="MaxElementVolume" )
983 StdMeshers::StdMeshers_MaxElementVolume_var h =
984 StdMeshers::StdMeshers_MaxElementVolume::_narrow( hyp );
986 item.myName = tr( "SMESH_MAX_ELEMENT_VOLUME_PARAM" );
987 if(!initVariableName( hyp, item, "SetMaxElementVolume" ))
988 item.myValue = h->GetMaxElementVolume();
991 else if( hypType()=="StartEndLength" )
993 StdMeshers::StdMeshers_StartEndLength_var h =
994 StdMeshers::StdMeshers_StartEndLength::_narrow( hyp );
996 item.myName = tr( "SMESH_START_LENGTH_PARAM" );
998 if(!initVariableName( hyp, item, "SetStartLength" ))
999 item.myValue = h->GetLength( true );
1001 customWidgets()->append(0);
1003 item.myName = tr( "SMESH_END_LENGTH_PARAM" );
1004 if(!initVariableName( hyp, item, "SetEndLength" ))
1005 item.myValue = h->GetLength( false );
1007 customWidgets()->append(0);
1009 item.myName = tr( "SMESH_REVERSED_EDGES" );
1012 StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget =
1013 new StdMeshersGUI_SubShapeSelectorWdg();
1014 QString anEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
1015 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
1016 if ( anEntry == "" )
1017 anEntry = h->GetObjectEntry();
1018 aDirectionWidget->SetGeomShapeEntry( anEntry );
1019 aDirectionWidget->SetMainShapeEntry( aMainEntry );
1020 aDirectionWidget->SetListOfIDs( h->GetReversedEdges() );
1021 aDirectionWidget->showPreview( true );
1022 customWidgets()->append ( aDirectionWidget );
1024 else if( hypType()=="Deflection1D" )
1026 StdMeshers::StdMeshers_Deflection1D_var h =
1027 StdMeshers::StdMeshers_Deflection1D::_narrow( hyp );
1029 item.myName = tr( "SMESH_DEFLECTION1D_PARAM" );
1030 if(!initVariableName( hyp, item, "SetDeflection" ))
1031 item.myValue = h->GetDeflection();
1034 else if( hypType()=="Adaptive1D" )
1036 StdMeshers::StdMeshers_Adaptive1D_var h =
1037 StdMeshers::StdMeshers_Adaptive1D::_narrow( hyp );
1039 item.myName = tr( "SMESH_MIN_SIZE" );
1040 if(!initVariableName( hyp, item, "SetMinSize" ))
1041 item.myValue = h->GetMinSize();
1044 item.myName = tr( "SMESH_MAX_SIZE" );
1045 if(!initVariableName( hyp, item, "SetMaxSize" ))
1046 item.myValue = h->GetMaxSize();
1049 item.myName = tr( "SMESH_DEFLECTION1D_PARAM" );
1050 if(!initVariableName( hyp, item, "SetDeflection" ))
1051 item.myValue = h->GetDeflection();
1054 else if( hypType()=="AutomaticLength" )
1056 StdMeshers::StdMeshers_AutomaticLength_var h =
1057 StdMeshers::StdMeshers_AutomaticLength::_narrow( hyp );
1059 item.myName = tr( "SMESH_FINENESS_PARAM" );
1060 //item.myValue = h->GetFineness();
1062 SMESHGUI_SpinBox* _autoLengthSpinBox = new SMESHGUI_SpinBox(dlg());
1063 _autoLengthSpinBox->RangeStepAndValidator(0, 1, 0.01, "length_precision");
1064 _autoLengthSpinBox->SetValue(h->GetFineness());
1065 customWidgets()->append( _autoLengthSpinBox);
1067 else if( hypType()=="NumberOfLayers" )
1069 StdMeshers::StdMeshers_NumberOfLayers_var h =
1070 StdMeshers::StdMeshers_NumberOfLayers::_narrow( hyp );
1072 item.myName = tr( "SMESH_NUMBER_OF_LAYERS" );
1073 if(!initVariableName( hyp, item, "SetNumberOfLayers" ))
1074 item.myValue = (int) h->GetNumberOfLayers();
1077 else if( hypType()=="LayerDistribution" )
1079 StdMeshers::StdMeshers_LayerDistribution_var h =
1080 StdMeshers::StdMeshers_LayerDistribution::_narrow( hyp );
1082 item.myName = tr( "SMESH_LAYERS_DISTRIBUTION" ); p.append( item );
1083 initVariableName( hyp, item, "SetLayerDistribution" );
1084 customWidgets()->append ( new StdMeshersGUI_LayerDistributionParamWdg
1085 ( h, h->GetLayerDistribution(), hypName(), dlg() ));
1087 else if( hypType()=="NumberOfLayers2D" )
1089 StdMeshers::StdMeshers_NumberOfLayers2D_var h =
1090 StdMeshers::StdMeshers_NumberOfLayers2D::_narrow( hyp );
1092 item.myName = tr( "SMESH_NUMBER_OF_LAYERS" );
1093 if(!initVariableName( hyp, item, "SetNumberOfLayers" ))
1094 item.myValue = (int) h->GetNumberOfLayers();
1097 else if( hypType()=="LayerDistribution2D" )
1099 StdMeshers::StdMeshers_LayerDistribution2D_var h =
1100 StdMeshers::StdMeshers_LayerDistribution2D::_narrow( hyp );
1102 item.myName = tr( "SMESH_LAYERS_DISTRIBUTION" ); p.append( item );
1103 initVariableName( hyp, item, "SetLayerDistribution" );
1104 customWidgets()->append ( new StdMeshersGUI_LayerDistributionParamWdg
1105 ( h, h->GetLayerDistribution(), hypName(), dlg() ));
1107 else if( hypType()=="ProjectionSource1D" )
1109 StdMeshers::StdMeshers_ProjectionSource1D_var h =
1110 StdMeshers::StdMeshers_ProjectionSource1D::_narrow( hyp );
1112 item.myName = tr( "SMESH_SOURCE_EDGE" ); p.append( item );
1113 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 1 ),
1114 h->GetSourceEdge()));
1115 item.myName = tr( "SMESH_SOURCE_MESH" ); p.append( item );
1116 customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( SMESH::MESH ),
1117 h->GetSourceMesh()));
1118 item.myName = tr( "SMESH_SOURCE_VERTEX" ); p.append( item );
1119 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1120 h->GetSourceVertex()));
1121 item.myName = tr( "SMESH_TARGET_VERTEX" ); p.append( item );
1122 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1123 h->GetTargetVertex()));
1125 else if( hypType()=="ProjectionSource2D" )
1127 StdMeshers::StdMeshers_ProjectionSource2D_var h =
1128 StdMeshers::StdMeshers_ProjectionSource2D::_narrow( hyp );
1130 item.myName = tr( "SMESH_SOURCE_FACE" ); p.append( item );
1131 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 2 ),
1132 h->GetSourceFace()));
1133 item.myName = tr( "SMESH_SOURCE_MESH" ); p.append( item );
1134 customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( SMESH::MESH ),
1135 h->GetSourceMesh()));
1136 item.myName = tr( "SMESH_SOURCE_VERTEX1" ); p.append( item );
1137 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1138 h->GetSourceVertex( 1 )));
1139 item.myName = tr( "SMESH_TARGET_VERTEX1" ); p.append( item );
1140 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1141 h->GetTargetVertex( 1 )));
1142 item.myName = tr( "SMESH_SOURCE_VERTEX2" ); p.append( item );
1143 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1144 h->GetSourceVertex( 2 )));
1145 item.myName = tr( "SMESH_TARGET_VERTEX2" ); p.append( item );
1146 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1147 h->GetTargetVertex( 2 )));
1149 else if( hypType()=="ProjectionSource3D" )
1151 StdMeshers::StdMeshers_ProjectionSource3D_var h =
1152 StdMeshers::StdMeshers_ProjectionSource3D::_narrow( hyp );
1154 item.myName = tr( "SMESH_SOURCE_3DSHAPE" ); p.append( item );
1155 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 3, TopAbs_FACE, 6, true ),
1156 h->GetSource3DShape()));
1157 item.myName = tr( "SMESH_SOURCE_MESH" ); p.append( item );
1158 customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( SMESH::MESH ),
1159 h->GetSourceMesh()));
1160 item.myName = tr( "SMESH_SOURCE_VERTEX1" ); p.append( item );
1161 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1162 h->GetSourceVertex( 1 )));
1163 item.myName = tr( "SMESH_TARGET_VERTEX1" ); p.append( item );
1164 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1165 h->GetTargetVertex( 1 )));
1166 item.myName = tr( "SMESH_SOURCE_VERTEX2" ); p.append( item );
1167 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1168 h->GetSourceVertex( 2 )));
1169 item.myName = tr( "SMESH_TARGET_VERTEX2" ); p.append( item );
1170 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1171 h->GetTargetVertex( 2 )));
1173 else if( hypType()=="ImportSource1D" )
1175 StdMeshers::StdMeshers_ImportSource1D_var h =
1176 StdMeshers::StdMeshers_ImportSource1D::_narrow( hyp );
1178 SMESH::string_array_var groupEntries = h->GetSourceEdges();
1179 CORBA::Boolean toCopyMesh, toCopyGroups;
1180 h->GetCopySourceMesh(toCopyMesh, toCopyGroups);
1182 item.myName = tr( "SMESH_SOURCE_EDGES" ); p.append( item );
1183 customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( SMESH::GROUP_EDGE ),
1186 item.myName = tr( "SMESH_COPY_MESH" ); p.append( item );
1187 QCheckBox* aQCheckBox = new QCheckBox(dlg());
1188 aQCheckBox->setChecked( toCopyMesh );
1189 connect( aQCheckBox, SIGNAL( stateChanged(int) ), this, SLOT( onValueChanged() ));
1190 customWidgets()->append( aQCheckBox );
1192 item.myName = tr( "SMESH_TO_COPY_GROUPS" ); p.append( item );
1193 aQCheckBox = new QCheckBox(dlg());
1194 aQCheckBox->setChecked( toCopyGroups );
1195 aQCheckBox->setEnabled( toCopyMesh );
1196 customWidgets()->append( aQCheckBox );
1198 else if( hypType()=="ImportSource2D" )
1200 StdMeshers::StdMeshers_ImportSource2D_var h =
1201 StdMeshers::StdMeshers_ImportSource2D::_narrow( hyp );
1203 SMESH::string_array_var groupEntries = h->GetSourceFaces();
1204 CORBA::Boolean toCopyMesh, toCopyGroups;
1205 h->GetCopySourceMesh(toCopyMesh, toCopyGroups);
1207 item.myName = tr( "SMESH_SOURCE_FACES" ); p.append( item );
1208 customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( SMESH::GROUP_FACE ),
1211 item.myName = tr( "SMESH_COPY_MESH" ); p.append( item );
1212 QCheckBox* aQCheckBox = new QCheckBox(dlg());
1213 aQCheckBox->setChecked( toCopyMesh );
1214 connect( aQCheckBox, SIGNAL( stateChanged(int) ), this, SLOT( onValueChanged() ));
1215 customWidgets()->append( aQCheckBox );
1217 item.myName = tr( "SMESH_COPY_GROUPS" ); p.append( item );
1218 aQCheckBox = new QCheckBox(dlg());
1219 aQCheckBox->setChecked( toCopyGroups );
1220 aQCheckBox->setEnabled( toCopyMesh );
1221 customWidgets()->append( aQCheckBox );
1223 else if( hypType()=="ViscousLayers" )
1225 StdMeshers::StdMeshers_ViscousLayers_var h =
1226 StdMeshers::StdMeshers_ViscousLayers::_narrow( hyp );
1228 item.myName = tr( "SMESH_TOTAL_THICKNESS" );
1229 if(!initVariableName( hyp, item, "SetTotalThickness" ))
1230 item.myValue = h->GetTotalThickness();
1232 customWidgets()->append (0);
1234 item.myName = tr( "SMESH_NUMBER_OF_LAYERS" );
1235 if(!initVariableName( hyp, item, "SetNumberLayers" ))
1236 item.myValue = h->GetNumberLayers();
1238 customWidgets()->append (0);
1240 item.myName = tr( "SMESH_STRETCH_FACTOR" );
1241 if(!initVariableName( hyp, item, "SetStretchFactor" ))
1242 item.myValue = h->GetStretchFactor();
1244 customWidgets()->append (0);
1246 item.myName = tr( "EXTRUSION_METHOD" );
1248 StdMeshersGUI_RadioButtonsGrpWdg* methodWdg = new StdMeshersGUI_RadioButtonsGrpWdg("");
1249 methodWdg->setButtonLabels ( QStringList()
1250 << tr("EXTMETH_SURF_OFFSET_SMOOTH")
1251 << tr("EXTMETH_FACE_OFFSET")
1252 << tr("EXTMETH_NODE_OFFSET"),
1254 << tr("ICON_EXTMETH_SURF_OFFSET_SMOOTH")
1255 << tr("ICON_EXTMETH_FACE_OFFSET")
1256 << tr("ICON_EXTMETH_NODE_OFFSET"));
1257 methodWdg->setChecked( (int) h->GetMethod() );
1258 customWidgets()->append( methodWdg );
1260 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
1261 QString aSubEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
1262 if ( !aMainEntry.isEmpty() )
1264 item.myName = tr( "TO_IGNORE_FACES_OR_NOT" );
1267 StdMeshersGUI_RadioButtonsGrpWdg* ignoreWdg = new StdMeshersGUI_RadioButtonsGrpWdg("");
1268 ignoreWdg->setButtonLabels ( QStringList()
1269 << tr("NOT_TO_IGNORE_FACES")
1270 << tr("TO_IGNORE_FACES") );
1271 ignoreWdg->setChecked( h->GetIsToIgnoreFaces() );
1272 connect(ignoreWdg->getButtonGroup(),SIGNAL(buttonClicked(int)),this,SLOT(onValueChanged()));
1273 customWidgets()->append( ignoreWdg );
1276 tr( h->GetIsToIgnoreFaces() ? "SMESH_FACES_WO_LAYERS" : "SMESH_FACES_WITH_LAYERS" );
1279 StdMeshersGUI_SubShapeSelectorWdg* idsWg =
1280 new StdMeshersGUI_SubShapeSelectorWdg(0,TopAbs_FACE);
1282 idsWg->SetMainShapeEntry( aMainEntry );
1283 idsWg->SetGeomShapeEntry( aSubEntry.isEmpty() ? aMainEntry : aSubEntry );
1284 if ( idsWg->SetListOfIDs( h->GetFaces() ))
1286 idsWg->showPreview( true );
1290 SUIT_MessageBox::warning( dlg(),tr( "SMESH_WRN_WARNING" ),tr( "BAD_FACES_WARNING" ));
1291 idsWg->setEnabled( false );
1293 customWidgets()->append ( idsWg );
1296 else if( hypType()=="ViscousLayers2D" )
1298 StdMeshers::StdMeshers_ViscousLayers2D_var h =
1299 StdMeshers::StdMeshers_ViscousLayers2D::_narrow( hyp );
1301 item.myName = tr( "SMESH_TOTAL_THICKNESS" );
1302 if(!initVariableName( hyp, item, "SetTotalThickness" ))
1303 item.myValue = h->GetTotalThickness();
1305 customWidgets()->append (0);
1307 item.myName = tr( "SMESH_NUMBER_OF_LAYERS" );
1308 if(!initVariableName( hyp, item, "SetNumberLayers" ))
1309 item.myValue = h->GetNumberLayers();
1311 customWidgets()->append (0);
1313 item.myName = tr( "SMESH_STRETCH_FACTOR" );
1314 if(!initVariableName( hyp, item, "SetStretchFactor" ))
1315 item.myValue = h->GetStretchFactor();
1317 customWidgets()->append (0);
1319 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
1320 QString aSubEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
1321 if ( !aMainEntry.isEmpty() )
1323 item.myName = tr("TO_IGNORE_EDGES_OR_NOT");
1326 StdMeshersGUI_RadioButtonsGrpWdg* ignoreWdg = new StdMeshersGUI_RadioButtonsGrpWdg("");
1327 ignoreWdg->setButtonLabels ( QStringList()
1328 << tr("NOT_TO_IGNORE_EDGES")
1329 << tr("TO_IGNORE_EDGES") );
1330 ignoreWdg->setChecked( h->GetIsToIgnoreEdges() );
1331 connect(ignoreWdg->getButtonGroup(),SIGNAL(buttonClicked(int)),this,SLOT(onValueChanged()));
1332 customWidgets()->append( ignoreWdg );
1335 tr( h->GetIsToIgnoreEdges() ? "SMESH_EDGES_WO_LAYERS" : "SMESH_EDGES_WITH_LAYERS" );
1338 StdMeshersGUI_SubShapeSelectorWdg* idsWg =
1339 new StdMeshersGUI_SubShapeSelectorWdg(0,TopAbs_EDGE);
1341 idsWg->SetMainShapeEntry( aMainEntry );
1342 idsWg->SetGeomShapeEntry( aSubEntry.isEmpty() ? aMainEntry : aSubEntry );
1343 if ( idsWg->SetListOfIDs( h->GetEdges() ))
1345 idsWg->showPreview( true );
1349 SUIT_MessageBox::warning( dlg(),tr( "SMESH_WRN_WARNING" ),tr( "BAD_EDGES_WARNING" ));
1350 idsWg->setEnabled( false );
1352 customWidgets()->append ( idsWg );
1355 // else if (hypType() == "QuadrangleParams")
1357 // StdMeshers::StdMeshers_QuadrangleParams_var h =
1358 // StdMeshers::StdMeshers_QuadrangleParams::_narrow(hyp);
1360 // item.myName = tr("SMESH_BASE_VERTEX");
1363 // StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget =
1364 // new StdMeshersGUI_SubShapeSelectorWdg(0, TopAbs_VERTEX);
1365 // aDirectionWidget->SetMaxSize(1);
1366 // QString anEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
1367 // QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
1368 // if (anEntry == "")
1369 // anEntry = h->GetObjectEntry();
1370 // aDirectionWidget->SetGeomShapeEntry(anEntry);
1371 // aDirectionWidget->SetMainShapeEntry(aMainEntry);
1372 // if (!isCreation()) {
1373 // SMESH::long_array_var aVec = new SMESH::long_array;
1374 // int vertID = h->GetTriaVertex();
1375 // if (vertID > 0) {
1377 // aVec[0] = vertID;
1378 // aDirectionWidget->SetListOfIDs(aVec);
1381 // aDirectionWidget->showPreview(true);
1383 // item.myName = tr("SMESH_QUAD_TYPE");
1386 // StdMeshersGUI_QuadrangleParamWdg* aTypeWidget =
1387 // new StdMeshersGUI_QuadrangleParamWdg();
1388 // if (!isCreation()) {
1389 // aTypeWidget->SetType(int(h->GetQuadType()));
1392 // customWidgets()->append(aDirectionWidget);
1393 // customWidgets()->append(aTypeWidget);
1400 //================================================================================
1402 * \brief tune "standard" control
1403 * \param w - control widget
1404 * \param int - parameter index
1406 //================================================================================
1408 void StdMeshersGUI_StdHypothesisCreator::attuneStdWidget (QWidget* w, const int) const
1410 SMESHGUI_SpinBox* sb = w->inherits( "SMESHGUI_SpinBox" ) ? ( SMESHGUI_SpinBox* )w : 0;
1413 if( hypType()=="LocalLength" )
1415 if (sb->objectName() == tr("SMESH_LOCAL_LENGTH_PARAM"))
1416 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1417 else if (sb->objectName() == tr("SMESH_LOCAL_LENGTH_PRECISION"))
1418 sb->RangeStepAndValidator( 0.0, 1.0, 0.05, "len_tol_precision" );
1420 else if( hypType()=="Arithmetic1D" )
1422 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "parametric_precision" );
1424 else if( hypType()=="GeometricProgression" )
1426 if (sb->objectName() == tr("SMESH_START_LENGTH_PARAM"))
1427 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1428 else if (sb->objectName() == tr("SMESH_COMMON_RATIO"))
1429 sb->RangeStepAndValidator( -VALUE_MAX, VALUE_MAX, 0.5, "len_tol_precision" );
1431 else if( hypType()=="MaxLength" )
1433 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1434 sb->setEnabled( !widget< QCheckBox >( 1 )->isChecked() );
1436 else if( hypType()=="MaxElementArea" )
1438 sb->RangeStepAndValidator( VALUE_SMALL_2, VALUE_MAX_2, 1.0, "area_precision" );
1440 else if( hypType()=="MaxElementVolume" )
1442 sb->RangeStepAndValidator( VALUE_SMALL_3, VALUE_MAX_3, 1.0, "vol_precision" );
1444 else if( hypType()=="StartEndLength" )
1446 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1448 else if( hypType()=="Deflection1D" )
1450 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "parametric_precision" );
1452 else if( hypType()=="Adaptive1D" )
1454 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1456 else if( hypType().startsWith( "ViscousLayers" ))
1458 if (sb->objectName() == tr("SMESH_STRETCH_FACTOR"))
1459 sb->RangeStepAndValidator( 1.0, VALUE_MAX, 0.1, "parametric_precision" );
1461 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1463 else // default validator for possible ancestors
1465 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1470 //================================================================================
1472 * \brief Return dlg title
1473 * \retval QString - title string
1475 //================================================================================
1477 QString StdMeshersGUI_StdHypothesisCreator::caption() const
1479 return tr( QString( "SMESH_%1_TITLE" ).arg( hypTypeName( hypType() ) ).toLatin1().data() );
1482 //================================================================================
1484 * \brief return pixmap for dlg icon
1487 //================================================================================
1489 QPixmap StdMeshersGUI_StdHypothesisCreator::icon() const
1491 QString hypIconName = tr( QString( "ICON_DLG_%1" ).arg( hypTypeName( hypType() ) ).toLatin1().data() );
1492 return SMESHGUI::resourceMgr()->loadPixmap( "SMESH", hypIconName );
1495 //================================================================================
1497 * \brief Return hypothesis type name to show in dlg
1500 //================================================================================
1502 QString StdMeshersGUI_StdHypothesisCreator::type() const
1504 return tr( QString( "SMESH_%1_HYPOTHESIS" ).arg( hypTypeName( hypType() ) ).toLatin1().data() );
1507 //================================================================================
1509 * \brief String to insert in "SMESH_%1_HYPOTHESIS" to get hypothesis type name
1510 * from message resouce file
1511 * \param t - hypothesis type
1512 * \retval QString - result string
1514 //================================================================================
1516 QString StdMeshersGUI_StdHypothesisCreator::hypTypeName( const QString& t ) const
1518 static QMap<QString,QString> types;
1519 if( types.isEmpty() )
1521 types.insert( "LocalLength", "LOCAL_LENGTH" );
1522 types.insert( "NumberOfSegments", "NB_SEGMENTS" );
1523 types.insert( "MaxElementArea", "MAX_ELEMENT_AREA" );
1524 types.insert( "MaxElementVolume", "MAX_ELEMENT_VOLUME" );
1525 types.insert( "StartEndLength", "START_END_LENGTH" );
1526 types.insert( "Deflection1D", "DEFLECTION1D" );
1527 types.insert( "Adaptive1D", "ADAPTIVE1D" );
1528 types.insert( "Arithmetic1D", "ARITHMETIC_1D" );
1529 types.insert( "GeometricProgression", "GEOMETRIC_1D" );
1530 types.insert( "FixedPoints1D", "FIXED_POINTS_1D" );
1531 types.insert( "AutomaticLength", "AUTOMATIC_LENGTH" );
1532 types.insert( "ProjectionSource1D", "PROJECTION_SOURCE_1D" );
1533 types.insert( "ProjectionSource2D", "PROJECTION_SOURCE_2D" );
1534 types.insert( "ProjectionSource3D", "PROJECTION_SOURCE_3D" );
1535 types.insert( "ImportSource1D", "IMPORT_SOURCE_1D" );
1536 types.insert( "ImportSource2D", "IMPORT_SOURCE_2D" );
1537 types.insert( "NumberOfLayers", "NUMBER_OF_LAYERS" );
1538 types.insert( "LayerDistribution", "LAYER_DISTRIBUTION" );
1539 types.insert( "NumberOfLayers2D", "NUMBER_OF_LAYERS_2D" );
1540 types.insert( "LayerDistribution2D", "LAYER_DISTRIBUTION" );
1541 types.insert( "SegmentLengthAroundVertex", "SEGMENT_LENGTH_AROUND_VERTEX" );
1542 types.insert( "MaxLength", "MAX_LENGTH" );
1543 types.insert( "ViscousLayers", "VISCOUS_LAYERS" );
1544 types.insert( "ViscousLayers2D", "VISCOUS_LAYERS" );
1545 types.insert( "QuadrangleParams", "QUADRANGLE_PARAMS" );
1546 types.insert( "CartesianParameters3D", "CARTESIAN_PARAMS" );
1550 if( types.contains( t ) )
1557 //=======================================================================
1558 //function : getCustomWidget
1559 //purpose : is called from buildStdFrame()
1560 //=======================================================================
1562 QWidget* StdMeshersGUI_StdHypothesisCreator::getCustomWidget( const StdParam & param,
1564 const int index) const
1567 if ( index < customWidgets()->count() ) {
1568 w = customWidgets()->at( index );
1570 w->setParent( parent );
1571 w->move( QPoint( 0, 0 ) );
1577 //================================================================================
1579 * \brief Set param value taken from a custom widget
1580 * \param param - SMESHGUI_GenericHypothesisCreator::StdParam structure
1581 * \param widget - widget presenting param
1582 * \retval bool - success flag
1584 * this method is called from getStdParamFromDlg()
1586 //================================================================================
1588 bool StdMeshersGUI_StdHypothesisCreator::getParamFromCustomWidget( StdParam & param,
1589 QWidget* widget) const
1591 if ( hypType()=="AutomaticLength" ) {
1592 SMESHGUI_SpinBox* w = dynamic_cast<SMESHGUI_SpinBox*>( widget );
1594 param.myValue = w->GetValue();
1598 if ( hypType() == "MaxLength" ) {
1602 if ( widget->inherits( "StdMeshersGUI_ObjectReferenceParamWdg" ))
1604 // show only 1st reference value
1605 if ( true /*widget == getWidgetForParam( 0 )*/) {
1606 const StdMeshersGUI_ObjectReferenceParamWdg * w =
1607 static_cast<const StdMeshersGUI_ObjectReferenceParamWdg*>( widget );
1608 param.myValue = w->GetValue();
1612 if ( widget->inherits( "StdMeshersGUI_LayerDistributionParamWdg" ))
1614 const StdMeshersGUI_LayerDistributionParamWdg * w =
1615 static_cast<const StdMeshersGUI_LayerDistributionParamWdg*>( widget );
1616 param.myValue = w->GetValue();
1619 if ( widget->inherits( "StdMeshersGUI_SubShapeSelectorWdg" ))
1621 const StdMeshersGUI_SubShapeSelectorWdg * w =
1622 static_cast<const StdMeshersGUI_SubShapeSelectorWdg*>( widget );
1623 param.myValue = w->GetValue();
1626 // if ( widget->inherits( "StdMeshersGUI_QuadrangleParamWdg" ))
1628 // param.myValue = "QuadType";
1631 if ( widget->inherits( "StdMeshersGUI_FixedPointsParamWdg" ))
1633 const StdMeshersGUI_FixedPointsParamWdg * w =
1634 static_cast<const StdMeshersGUI_FixedPointsParamWdg*>( widget );
1635 param.myValue = w->GetValue();
1638 if ( widget->inherits( "QCheckBox" ))
1640 //const QCheckBox * w = static_cast<const QCheckBox*>( widget );
1641 //param.myValue = w->isChecked();
1644 if ( widget->inherits( "StdMeshersGUI_RadioButtonsGrpWdg" ))
1646 const StdMeshersGUI_RadioButtonsGrpWdg * w =
1647 static_cast<const StdMeshersGUI_RadioButtonsGrpWdg*>( widget );
1648 param.myValue = w->checkedId();
1654 //================================================================================
1656 * \brief called when operation cancelled
1658 //================================================================================
1660 void StdMeshersGUI_StdHypothesisCreator::onReject()
1662 if ( hypType().startsWith("ProjectionSource" ) ||
1663 hypType().startsWith("ImportSource" ))
1665 // Uninstall filters of StdMeshersGUI_ObjectReferenceParamWdg
1666 deactivateObjRefParamWdg( customWidgets() );
1670 //================================================================================
1672 * \brief Update widgets dependent on paramWidget
1674 //================================================================================
1676 void StdMeshersGUI_StdHypothesisCreator::valueChanged( QWidget* paramWidget)
1678 if ( hypType() == "MaxLength" && paramWidget == getWidgetForParam(1) )
1680 getWidgetForParam(0)->setEnabled( !widget< QCheckBox >( 1 )->isChecked() );
1681 if ( !getWidgetForParam(0)->isEnabled() ) {
1682 StdMeshers::StdMeshers_MaxLength_var h =
1683 StdMeshers::StdMeshers_MaxLength::_narrow( initParamsHypothesis() );
1684 widget< QtxDoubleSpinBox >( 0 )->setValue( h->GetPreestimatedLength() );
1687 else if ( hypType().startsWith("ImportSource") && paramWidget == getWidgetForParam(1) )
1689 QCheckBox* toCopyMesh = (QCheckBox*) paramWidget;
1690 QCheckBox* toCopyGroups = widget< QCheckBox >( 2 );
1691 if ( !toCopyMesh->isChecked() )
1693 toCopyGroups->setChecked( false );
1694 toCopyGroups->setEnabled( false );
1698 toCopyGroups->setEnabled( true );
1701 else if ( hypType().startsWith( "ViscousLayers" ) && paramWidget->inherits("QButtonGroup"))
1703 if ( QLabel* label = getLabel(4) )
1705 bool toIgnore = widget< StdMeshersGUI_RadioButtonsGrpWdg >( 3 )->checkedId();
1706 if ( hypType() == "ViscousLayers2D" )
1707 label->setText( tr( toIgnore ? "SMESH_EDGES_WO_LAYERS" : "SMESH_EDGES_WITH_LAYERS" ));
1709 label->setText( tr( toIgnore ? "SMESH_FACES_WO_LAYERS" : "SMESH_FACES_WITH_LAYERS" ));
1714 //================================================================================
1718 //================================================================================
1720 bool StdMeshersGUI_StdHypothesisCreator::initVariableName(SMESH::SMESH_Hypothesis_var theHyp,
1721 StdParam & theParams,
1722 const char* theMethod) const
1724 QString aVaribaleName = getVariableName( theMethod );
1725 theParams.isVariable = !aVaribaleName.isEmpty();
1726 if (theParams.isVariable)
1727 theParams.myValue = aVaribaleName;
1729 return theParams.isVariable;