1 // Copyright (C) 2007-2014 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() );
724 if ( StdMeshersGUI_SubShapeSelectorWdg* idsWg =
725 widget< StdMeshersGUI_SubShapeSelectorWdg >( 4 ))
727 h->SetFaces( idsWg->GetListOfIDs(), params[3].myValue.toInt() );
730 else if( hypType()=="ViscousLayers2D" )
732 StdMeshers::StdMeshers_ViscousLayers2D_var h =
733 StdMeshers::StdMeshers_ViscousLayers2D::_narrow( hypothesis() );
735 h->SetVarParameter( params[0].text(), "SetTotalThickness" );
736 h->SetTotalThickness( params[0].myValue.toDouble() );
737 h->SetVarParameter( params[1].text(), "SetNumberLayers" );
738 h->SetNumberLayers ( params[1].myValue.toInt() );
739 h->SetVarParameter( params[2].text(), "SetStretchFactor" );
740 h->SetStretchFactor ( params[2].myValue.toDouble() );
742 if ( StdMeshersGUI_SubShapeSelectorWdg* idsWg =
743 widget< StdMeshersGUI_SubShapeSelectorWdg >( 4 ))
745 h->SetEdges( idsWg->GetListOfIDs(), params[3].myValue.toInt() );
748 // else if( hypType()=="QuadrangleParams" )
750 // StdMeshers::StdMeshers_QuadrangleParams_var h =
751 // StdMeshers::StdMeshers_QuadrangleParams::_narrow( hypothesis() );
752 // StdMeshersGUI_SubShapeSelectorWdg* w1 =
753 // widget< StdMeshersGUI_SubShapeSelectorWdg >( 0 );
754 // StdMeshersGUI_QuadrangleParamWdg* w2 =
755 // widget< StdMeshersGUI_QuadrangleParamWdg >( 1 );
757 // if (w1->GetListSize() > 0) {
758 // h->SetTriaVertex(w1->GetListOfIDs()[0]); // getlist must be called once
759 // const char * entry = w1->GetMainShapeEntry();
760 // h->SetObjectEntry(entry);
762 // h->SetQuadType(StdMeshers::QuadType(w2->GetType()));
769 //================================================================================
771 * \brief Return parameter values as SMESHGUI_GenericHypothesisCreator::StdParam
772 * \param p - list of parameters
773 * \retval bool - success flag
775 * Is called from SMESHGUI_GenericHypothesisCreator::buildStdFrame().
776 * Parameters will be shown using "standard" controls:
777 * Int by QtxIntSpinBox
778 * Double by SMESHGUI_SpinBox
779 * String by QLineEdit
780 * getCustomWidget() allows to redefine control for a parameter
782 //================================================================================
784 bool StdMeshersGUI_StdHypothesisCreator::stdParams( ListOfStdParams& p ) const
787 SMESHGUI_GenericHypothesisCreator::StdParam item;
790 customWidgets()->clear();
793 HypothesisData* data = SMESH::GetHypothesisData( hypType() );
794 item.myName = tr( "SMESH_NAME" );
795 item.myValue = data ? hypName() : QString();
797 customWidgets()->append(0);
800 SMESH::SMESH_Hypothesis_var hyp = initParamsHypothesis();
801 //SMESH::ListOfParameters_var aParameters = hyp->GetLastParameters();
803 if( hypType()=="LocalLength" )
805 StdMeshers::StdMeshers_LocalLength_var h =
806 StdMeshers::StdMeshers_LocalLength::_narrow( hyp );
808 item.myName = tr("SMESH_LOCAL_LENGTH_PARAM");
809 if(!initVariableName( hyp, item, "SetLength"))
810 item.myValue = h->GetLength();
813 item.myName = tr("SMESH_LOCAL_LENGTH_PRECISION");
814 if(!initVariableName( hyp, item, "SetPrecision"))
815 item.myValue = h->GetPrecision();
818 else if( hypType()=="MaxLength" )
820 StdMeshers::StdMeshers_MaxLength_var h =
821 StdMeshers::StdMeshers_MaxLength::_narrow( hyp );
822 // try to set a right preestimated length to edited hypothesis
823 bool noPreestimatedAtEdition = false;
824 if ( !isCreation() ) {
825 StdMeshers::StdMeshers_MaxLength_var initHyp =
826 StdMeshers::StdMeshers_MaxLength::_narrow( initParamsHypothesis(true) );
827 noPreestimatedAtEdition =
828 ( initHyp->_is_nil() || !initHyp->HavePreestimatedLength() );
829 if ( !noPreestimatedAtEdition )
830 h->SetPreestimatedLength( initHyp->GetPreestimatedLength() );
833 item.myName = tr("SMESH_LOCAL_LENGTH_PARAM");
834 if(!initVariableName( hyp, item, "SetLength"))
835 item.myValue = h->GetLength();
837 customWidgets()->append(0);
839 item.myName = tr("SMESH_USE_PREESTIMATED_LENGTH");
841 QCheckBox* aQCheckBox = new QCheckBox(dlg());
842 if ( !noPreestimatedAtEdition && h->HavePreestimatedLength() ) {
843 aQCheckBox->setChecked( h->GetUsePreestimatedLength() );
844 connect( aQCheckBox, SIGNAL( stateChanged(int) ), this, SLOT( onValueChanged() ) );
847 aQCheckBox->setChecked( false );
848 aQCheckBox->setEnabled( false );
850 customWidgets()->append( aQCheckBox );
852 else if( hypType()=="SegmentLengthAroundVertex" )
854 StdMeshers::StdMeshers_SegmentLengthAroundVertex_var h =
855 StdMeshers::StdMeshers_SegmentLengthAroundVertex::_narrow( hyp );
857 item.myName = tr("SMESH_LOCAL_LENGTH_PARAM");
858 if(!initVariableName( hyp, item, "SetLength"))
859 item.myValue = h->GetLength();
863 else if( hypType()=="Arithmetic1D" )
865 StdMeshers::StdMeshers_Arithmetic1D_var h =
866 StdMeshers::StdMeshers_Arithmetic1D::_narrow( hyp );
868 item.myName = tr( "SMESH_START_LENGTH_PARAM" );
869 if(!initVariableName( hyp, item, "SetStartLength" ))
870 item.myValue = h->GetLength( true );
873 customWidgets()->append (0);
875 item.myName = tr( "SMESH_END_LENGTH_PARAM" );
876 if(!initVariableName( hyp, item, "SetEndLength" ))
877 item.myValue = h->GetLength( false );
880 customWidgets()->append (0);
882 item.myName = tr( "SMESH_REVERSED_EDGES" );
885 StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget =
886 new StdMeshersGUI_SubShapeSelectorWdg();
887 QString aGeomEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
888 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
889 if ( aGeomEntry == "" )
890 aGeomEntry = h->GetObjectEntry();
892 aDirectionWidget->SetGeomShapeEntry( aGeomEntry );
893 aDirectionWidget->SetMainShapeEntry( aMainEntry );
894 aDirectionWidget->SetListOfIDs( h->GetReversedEdges() );
895 aDirectionWidget->showPreview( true );
896 customWidgets()->append ( aDirectionWidget );
899 else if( hypType()=="GeometricProgression" )
901 StdMeshers::StdMeshers_Geometric1D_var h =
902 StdMeshers::StdMeshers_Geometric1D::_narrow( hyp );
904 item.myName = tr( "SMESH_START_LENGTH_PARAM" );
905 if(!initVariableName( hyp, item, "SetStartLength" ))
906 item.myValue = h->GetStartLength();
909 customWidgets()->append (0);
911 item.myName = tr( "SMESH_COMMON_RATIO" );
912 if(!initVariableName( hyp, item, "SetCommonRatio" ))
913 item.myValue = h->GetCommonRatio();
916 customWidgets()->append (0);
918 item.myName = tr( "SMESH_REVERSED_EDGES" );
921 StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget =
922 new StdMeshersGUI_SubShapeSelectorWdg();
923 QString aGeomEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
924 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
925 if ( aGeomEntry == "" )
926 aGeomEntry = h->GetObjectEntry();
928 aDirectionWidget->SetGeomShapeEntry( aGeomEntry );
929 aDirectionWidget->SetMainShapeEntry( aMainEntry );
930 aDirectionWidget->SetListOfIDs( h->GetReversedEdges() );
931 aDirectionWidget->showPreview( true );
932 customWidgets()->append ( aDirectionWidget );
935 else if( hypType()=="FixedPoints1D" )
937 StdMeshers::StdMeshers_FixedPoints1D_var h =
938 StdMeshers::StdMeshers_FixedPoints1D::_narrow( hyp );
940 item.myName = tr( "SMESH_FIXED_POINTS" );
943 StdMeshersGUI_FixedPointsParamWdg* aFixedPointsWidget =
944 new StdMeshersGUI_FixedPointsParamWdg();
946 if ( !isCreation() ) {
947 aFixedPointsWidget->SetListOfPoints( h->GetPoints() );
948 aFixedPointsWidget->SetListOfSegments( h->GetNbSegments() );
950 customWidgets()->append( aFixedPointsWidget );
952 item.myName = tr( "SMESH_REVERSED_EDGES" );
955 StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget =
956 new StdMeshersGUI_SubShapeSelectorWdg();
957 QString anEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
958 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
960 anEntry = h->GetObjectEntry();
961 aDirectionWidget->SetGeomShapeEntry( anEntry );
962 aDirectionWidget->SetMainShapeEntry( aMainEntry );
963 aDirectionWidget->SetListOfIDs( h->GetReversedEdges() );
964 aDirectionWidget->showPreview( true );
965 customWidgets()->append ( aDirectionWidget );
969 else if( hypType()=="MaxElementArea" )
971 StdMeshers::StdMeshers_MaxElementArea_var h =
972 StdMeshers::StdMeshers_MaxElementArea::_narrow( hyp );
974 item.myName = tr( "SMESH_MAX_ELEMENT_AREA_PARAM" );
975 if(!initVariableName( hyp, item, "SetMaxElementArea" ))
976 item.myValue = h->GetMaxElementArea();
980 else if( hypType()=="MaxElementVolume" )
982 StdMeshers::StdMeshers_MaxElementVolume_var h =
983 StdMeshers::StdMeshers_MaxElementVolume::_narrow( hyp );
985 item.myName = tr( "SMESH_MAX_ELEMENT_VOLUME_PARAM" );
986 if(!initVariableName( hyp, item, "SetMaxElementVolume" ))
987 item.myValue = h->GetMaxElementVolume();
990 else if( hypType()=="StartEndLength" )
992 StdMeshers::StdMeshers_StartEndLength_var h =
993 StdMeshers::StdMeshers_StartEndLength::_narrow( hyp );
995 item.myName = tr( "SMESH_START_LENGTH_PARAM" );
997 if(!initVariableName( hyp, item, "SetStartLength" ))
998 item.myValue = h->GetLength( true );
1000 customWidgets()->append(0);
1002 item.myName = tr( "SMESH_END_LENGTH_PARAM" );
1003 if(!initVariableName( hyp, item, "SetEndLength" ))
1004 item.myValue = h->GetLength( false );
1006 customWidgets()->append(0);
1008 item.myName = tr( "SMESH_REVERSED_EDGES" );
1011 StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget =
1012 new StdMeshersGUI_SubShapeSelectorWdg();
1013 QString anEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
1014 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
1015 if ( anEntry == "" )
1016 anEntry = h->GetObjectEntry();
1017 aDirectionWidget->SetGeomShapeEntry( anEntry );
1018 aDirectionWidget->SetMainShapeEntry( aMainEntry );
1019 aDirectionWidget->SetListOfIDs( h->GetReversedEdges() );
1020 aDirectionWidget->showPreview( true );
1021 customWidgets()->append ( aDirectionWidget );
1023 else if( hypType()=="Deflection1D" )
1025 StdMeshers::StdMeshers_Deflection1D_var h =
1026 StdMeshers::StdMeshers_Deflection1D::_narrow( hyp );
1028 item.myName = tr( "SMESH_DEFLECTION1D_PARAM" );
1029 if(!initVariableName( hyp, item, "SetDeflection" ))
1030 item.myValue = h->GetDeflection();
1033 else if( hypType()=="Adaptive1D" )
1035 StdMeshers::StdMeshers_Adaptive1D_var h =
1036 StdMeshers::StdMeshers_Adaptive1D::_narrow( hyp );
1038 item.myName = tr( "SMESH_MIN_SIZE" );
1039 if(!initVariableName( hyp, item, "SetMinSize" ))
1040 item.myValue = h->GetMinSize();
1043 item.myName = tr( "SMESH_MAX_SIZE" );
1044 if(!initVariableName( hyp, item, "SetMaxSize" ))
1045 item.myValue = h->GetMaxSize();
1048 item.myName = tr( "SMESH_DEFLECTION1D_PARAM" );
1049 if(!initVariableName( hyp, item, "SetDeflection" ))
1050 item.myValue = h->GetDeflection();
1053 else if( hypType()=="AutomaticLength" )
1055 StdMeshers::StdMeshers_AutomaticLength_var h =
1056 StdMeshers::StdMeshers_AutomaticLength::_narrow( hyp );
1058 item.myName = tr( "SMESH_FINENESS_PARAM" );
1059 //item.myValue = h->GetFineness();
1061 SMESHGUI_SpinBox* _autoLengthSpinBox = new SMESHGUI_SpinBox(dlg());
1062 _autoLengthSpinBox->RangeStepAndValidator(0, 1, 0.01, "length_precision");
1063 _autoLengthSpinBox->SetValue(h->GetFineness());
1064 customWidgets()->append( _autoLengthSpinBox);
1066 else if( hypType()=="NumberOfLayers" )
1068 StdMeshers::StdMeshers_NumberOfLayers_var h =
1069 StdMeshers::StdMeshers_NumberOfLayers::_narrow( hyp );
1071 item.myName = tr( "SMESH_NUMBER_OF_LAYERS" );
1072 if(!initVariableName( hyp, item, "SetNumberOfLayers" ))
1073 item.myValue = (int) h->GetNumberOfLayers();
1076 else if( hypType()=="LayerDistribution" )
1078 StdMeshers::StdMeshers_LayerDistribution_var h =
1079 StdMeshers::StdMeshers_LayerDistribution::_narrow( hyp );
1081 item.myName = tr( "SMESH_LAYERS_DISTRIBUTION" ); p.append( item );
1082 initVariableName( hyp, item, "SetLayerDistribution" );
1083 customWidgets()->append ( new StdMeshersGUI_LayerDistributionParamWdg
1084 ( h, h->GetLayerDistribution(), hypName(), dlg() ));
1086 else if( hypType()=="NumberOfLayers2D" )
1088 StdMeshers::StdMeshers_NumberOfLayers2D_var h =
1089 StdMeshers::StdMeshers_NumberOfLayers2D::_narrow( hyp );
1091 item.myName = tr( "SMESH_NUMBER_OF_LAYERS" );
1092 if(!initVariableName( hyp, item, "SetNumberOfLayers" ))
1093 item.myValue = (int) h->GetNumberOfLayers();
1096 else if( hypType()=="LayerDistribution2D" )
1098 StdMeshers::StdMeshers_LayerDistribution2D_var h =
1099 StdMeshers::StdMeshers_LayerDistribution2D::_narrow( hyp );
1101 item.myName = tr( "SMESH_LAYERS_DISTRIBUTION" ); p.append( item );
1102 initVariableName( hyp, item, "SetLayerDistribution" );
1103 customWidgets()->append ( new StdMeshersGUI_LayerDistributionParamWdg
1104 ( h, h->GetLayerDistribution(), hypName(), dlg() ));
1106 else if( hypType()=="ProjectionSource1D" )
1108 StdMeshers::StdMeshers_ProjectionSource1D_var h =
1109 StdMeshers::StdMeshers_ProjectionSource1D::_narrow( hyp );
1111 item.myName = tr( "SMESH_SOURCE_EDGE" ); p.append( item );
1112 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 1 ),
1113 h->GetSourceEdge()));
1114 item.myName = tr( "SMESH_SOURCE_MESH" ); p.append( item );
1115 customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( SMESH::MESH ),
1116 h->GetSourceMesh()));
1117 item.myName = tr( "SMESH_SOURCE_VERTEX" ); p.append( item );
1118 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1119 h->GetSourceVertex()));
1120 item.myName = tr( "SMESH_TARGET_VERTEX" ); p.append( item );
1121 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1122 h->GetTargetVertex()));
1124 else if( hypType()=="ProjectionSource2D" )
1126 StdMeshers::StdMeshers_ProjectionSource2D_var h =
1127 StdMeshers::StdMeshers_ProjectionSource2D::_narrow( hyp );
1129 item.myName = tr( "SMESH_SOURCE_FACE" ); p.append( item );
1130 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 2 ),
1131 h->GetSourceFace()));
1132 item.myName = tr( "SMESH_SOURCE_MESH" ); p.append( item );
1133 customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( SMESH::MESH ),
1134 h->GetSourceMesh()));
1135 item.myName = tr( "SMESH_SOURCE_VERTEX1" ); p.append( item );
1136 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1137 h->GetSourceVertex( 1 )));
1138 item.myName = tr( "SMESH_TARGET_VERTEX1" ); p.append( item );
1139 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1140 h->GetTargetVertex( 1 )));
1141 item.myName = tr( "SMESH_SOURCE_VERTEX2" ); p.append( item );
1142 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1143 h->GetSourceVertex( 2 )));
1144 item.myName = tr( "SMESH_TARGET_VERTEX2" ); p.append( item );
1145 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1146 h->GetTargetVertex( 2 )));
1148 else if( hypType()=="ProjectionSource3D" )
1150 StdMeshers::StdMeshers_ProjectionSource3D_var h =
1151 StdMeshers::StdMeshers_ProjectionSource3D::_narrow( hyp );
1153 item.myName = tr( "SMESH_SOURCE_3DSHAPE" ); p.append( item );
1154 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 3, TopAbs_FACE, 6, true ),
1155 h->GetSource3DShape()));
1156 item.myName = tr( "SMESH_SOURCE_MESH" ); p.append( item );
1157 customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( SMESH::MESH ),
1158 h->GetSourceMesh()));
1159 item.myName = tr( "SMESH_SOURCE_VERTEX1" ); p.append( item );
1160 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1161 h->GetSourceVertex( 1 )));
1162 item.myName = tr( "SMESH_TARGET_VERTEX1" ); p.append( item );
1163 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1164 h->GetTargetVertex( 1 )));
1165 item.myName = tr( "SMESH_SOURCE_VERTEX2" ); p.append( item );
1166 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1167 h->GetSourceVertex( 2 )));
1168 item.myName = tr( "SMESH_TARGET_VERTEX2" ); p.append( item );
1169 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1170 h->GetTargetVertex( 2 )));
1172 else if( hypType()=="ImportSource1D" )
1174 StdMeshers::StdMeshers_ImportSource1D_var h =
1175 StdMeshers::StdMeshers_ImportSource1D::_narrow( hyp );
1177 SMESH::string_array_var groupEntries = h->GetSourceEdges();
1178 CORBA::Boolean toCopyMesh, toCopyGroups;
1179 h->GetCopySourceMesh(toCopyMesh, toCopyGroups);
1181 item.myName = tr( "SMESH_SOURCE_EDGES" ); p.append( item );
1182 customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( SMESH::GROUP_EDGE ),
1185 item.myName = tr( "SMESH_COPY_MESH" ); p.append( item );
1186 QCheckBox* aQCheckBox = new QCheckBox(dlg());
1187 aQCheckBox->setChecked( toCopyMesh );
1188 connect( aQCheckBox, SIGNAL( stateChanged(int) ), this, SLOT( onValueChanged() ));
1189 customWidgets()->append( aQCheckBox );
1191 item.myName = tr( "SMESH_TO_COPY_GROUPS" ); p.append( item );
1192 aQCheckBox = new QCheckBox(dlg());
1193 aQCheckBox->setChecked( toCopyGroups );
1194 aQCheckBox->setEnabled( toCopyMesh );
1195 customWidgets()->append( aQCheckBox );
1197 else if( hypType()=="ImportSource2D" )
1199 StdMeshers::StdMeshers_ImportSource2D_var h =
1200 StdMeshers::StdMeshers_ImportSource2D::_narrow( hyp );
1202 SMESH::string_array_var groupEntries = h->GetSourceFaces();
1203 CORBA::Boolean toCopyMesh, toCopyGroups;
1204 h->GetCopySourceMesh(toCopyMesh, toCopyGroups);
1206 item.myName = tr( "SMESH_SOURCE_FACES" ); p.append( item );
1207 customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( SMESH::GROUP_FACE ),
1210 item.myName = tr( "SMESH_COPY_MESH" ); p.append( item );
1211 QCheckBox* aQCheckBox = new QCheckBox(dlg());
1212 aQCheckBox->setChecked( toCopyMesh );
1213 connect( aQCheckBox, SIGNAL( stateChanged(int) ), this, SLOT( onValueChanged() ));
1214 customWidgets()->append( aQCheckBox );
1216 item.myName = tr( "SMESH_COPY_GROUPS" ); p.append( item );
1217 aQCheckBox = new QCheckBox(dlg());
1218 aQCheckBox->setChecked( toCopyGroups );
1219 aQCheckBox->setEnabled( toCopyMesh );
1220 customWidgets()->append( aQCheckBox );
1222 else if( hypType()=="ViscousLayers" )
1224 StdMeshers::StdMeshers_ViscousLayers_var h =
1225 StdMeshers::StdMeshers_ViscousLayers::_narrow( hyp );
1227 item.myName = tr( "SMESH_TOTAL_THICKNESS" );
1228 if(!initVariableName( hyp, item, "SetTotalThickness" ))
1229 item.myValue = h->GetTotalThickness();
1231 customWidgets()->append (0);
1233 item.myName = tr( "SMESH_NUMBER_OF_LAYERS" );
1234 if(!initVariableName( hyp, item, "SetNumberLayers" ))
1235 item.myValue = h->GetNumberLayers();
1237 customWidgets()->append (0);
1239 item.myName = tr( "SMESH_STRETCH_FACTOR" );
1240 if(!initVariableName( hyp, item, "SetStretchFactor" ))
1241 item.myValue = h->GetStretchFactor();
1243 customWidgets()->append (0);
1245 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
1246 QString aSubEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
1247 if ( !aMainEntry.isEmpty() )
1249 item.myName = tr( "TO_IGNORE_FACES_OR_NOT" );
1252 StdMeshersGUI_RadioButtonsGrpWdg* ignoreWdg = new StdMeshersGUI_RadioButtonsGrpWdg("");
1253 ignoreWdg->setButtonLabels ( QStringList()
1254 << tr("NOT_TO_IGNORE_FACES")
1255 << tr("TO_IGNORE_FACES") );
1256 ignoreWdg->setChecked( h->GetIsToIgnoreFaces() );
1257 connect(ignoreWdg->getButtonGroup(),SIGNAL(buttonClicked(int)),this,SLOT(onValueChanged()));
1258 customWidgets()->append( ignoreWdg );
1261 tr( h->GetIsToIgnoreFaces() ? "SMESH_FACES_WO_LAYERS" : "SMESH_FACES_WITH_LAYERS" );
1264 StdMeshersGUI_SubShapeSelectorWdg* idsWg =
1265 new StdMeshersGUI_SubShapeSelectorWdg(0,TopAbs_FACE);
1267 idsWg->SetMainShapeEntry( aMainEntry );
1268 idsWg->SetGeomShapeEntry( aSubEntry.isEmpty() ? aMainEntry : aSubEntry );
1269 if ( idsWg->SetListOfIDs( h->GetFaces() ))
1271 idsWg->showPreview( true );
1275 SUIT_MessageBox::warning( dlg(),tr( "SMESH_WRN_WARNING" ),tr( "BAD_FACES_WARNING" ));
1276 idsWg->setEnabled( false );
1278 customWidgets()->append ( idsWg );
1281 else if( hypType()=="ViscousLayers2D" )
1283 StdMeshers::StdMeshers_ViscousLayers2D_var h =
1284 StdMeshers::StdMeshers_ViscousLayers2D::_narrow( hyp );
1286 item.myName = tr( "SMESH_TOTAL_THICKNESS" );
1287 if(!initVariableName( hyp, item, "SetTotalThickness" ))
1288 item.myValue = h->GetTotalThickness();
1290 customWidgets()->append (0);
1292 item.myName = tr( "SMESH_NUMBER_OF_LAYERS" );
1293 if(!initVariableName( hyp, item, "SetNumberLayers" ))
1294 item.myValue = h->GetNumberLayers();
1296 customWidgets()->append (0);
1298 item.myName = tr( "SMESH_STRETCH_FACTOR" );
1299 if(!initVariableName( hyp, item, "SetStretchFactor" ))
1300 item.myValue = h->GetStretchFactor();
1302 customWidgets()->append (0);
1304 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
1305 QString aSubEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
1306 if ( !aMainEntry.isEmpty() )
1308 item.myName = tr("TO_IGNORE_EDGES_OR_NOT");
1311 StdMeshersGUI_RadioButtonsGrpWdg* ignoreWdg = new StdMeshersGUI_RadioButtonsGrpWdg("");
1312 ignoreWdg->setButtonLabels ( QStringList()
1313 << tr("NOT_TO_IGNORE_EDGES")
1314 << tr("TO_IGNORE_EDGES") );
1315 ignoreWdg->setChecked( h->GetIsToIgnoreEdges() );
1316 connect(ignoreWdg->getButtonGroup(),SIGNAL(buttonClicked(int)),this,SLOT(onValueChanged()));
1317 customWidgets()->append( ignoreWdg );
1320 tr( h->GetIsToIgnoreEdges() ? "SMESH_EDGES_WO_LAYERS" : "SMESH_EDGES_WITH_LAYERS" );
1323 StdMeshersGUI_SubShapeSelectorWdg* idsWg =
1324 new StdMeshersGUI_SubShapeSelectorWdg(0,TopAbs_EDGE);
1326 idsWg->SetMainShapeEntry( aMainEntry );
1327 idsWg->SetGeomShapeEntry( aSubEntry.isEmpty() ? aMainEntry : aSubEntry );
1328 if ( idsWg->SetListOfIDs( h->GetEdges() ))
1330 idsWg->showPreview( true );
1334 SUIT_MessageBox::warning( dlg(),tr( "SMESH_WRN_WARNING" ),tr( "BAD_EDGES_WARNING" ));
1335 idsWg->setEnabled( false );
1337 customWidgets()->append ( idsWg );
1340 // else if (hypType() == "QuadrangleParams")
1342 // StdMeshers::StdMeshers_QuadrangleParams_var h =
1343 // StdMeshers::StdMeshers_QuadrangleParams::_narrow(hyp);
1345 // item.myName = tr("SMESH_BASE_VERTEX");
1348 // StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget =
1349 // new StdMeshersGUI_SubShapeSelectorWdg(0, TopAbs_VERTEX);
1350 // aDirectionWidget->SetMaxSize(1);
1351 // QString anEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
1352 // QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
1353 // if (anEntry == "")
1354 // anEntry = h->GetObjectEntry();
1355 // aDirectionWidget->SetGeomShapeEntry(anEntry);
1356 // aDirectionWidget->SetMainShapeEntry(aMainEntry);
1357 // if (!isCreation()) {
1358 // SMESH::long_array_var aVec = new SMESH::long_array;
1359 // int vertID = h->GetTriaVertex();
1360 // if (vertID > 0) {
1362 // aVec[0] = vertID;
1363 // aDirectionWidget->SetListOfIDs(aVec);
1366 // aDirectionWidget->showPreview(true);
1368 // item.myName = tr("SMESH_QUAD_TYPE");
1371 // StdMeshersGUI_QuadrangleParamWdg* aTypeWidget =
1372 // new StdMeshersGUI_QuadrangleParamWdg();
1373 // if (!isCreation()) {
1374 // aTypeWidget->SetType(int(h->GetQuadType()));
1377 // customWidgets()->append(aDirectionWidget);
1378 // customWidgets()->append(aTypeWidget);
1385 //================================================================================
1387 * \brief tune "standard" control
1388 * \param w - control widget
1389 * \param int - parameter index
1391 //================================================================================
1393 void StdMeshersGUI_StdHypothesisCreator::attuneStdWidget (QWidget* w, const int) const
1395 SMESHGUI_SpinBox* sb = w->inherits( "SMESHGUI_SpinBox" ) ? ( SMESHGUI_SpinBox* )w : 0;
1398 if( hypType()=="LocalLength" )
1400 if (sb->objectName() == tr("SMESH_LOCAL_LENGTH_PARAM"))
1401 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1402 else if (sb->objectName() == tr("SMESH_LOCAL_LENGTH_PRECISION"))
1403 sb->RangeStepAndValidator( 0.0, 1.0, 0.05, "len_tol_precision" );
1405 else if( hypType()=="Arithmetic1D" )
1407 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "parametric_precision" );
1409 else if( hypType()=="GeometricProgression" )
1411 if (sb->objectName() == tr("SMESH_START_LENGTH_PARAM"))
1412 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1413 else if (sb->objectName() == tr("SMESH_COMMON_RATIO"))
1414 sb->RangeStepAndValidator( -VALUE_MAX, VALUE_MAX, 0.5, "len_tol_precision" );
1416 else if( hypType()=="MaxLength" )
1418 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1419 sb->setEnabled( !widget< QCheckBox >( 1 )->isChecked() );
1421 else if( hypType()=="MaxElementArea" )
1423 sb->RangeStepAndValidator( VALUE_SMALL_2, VALUE_MAX_2, 1.0, "area_precision" );
1425 else if( hypType()=="MaxElementVolume" )
1427 sb->RangeStepAndValidator( VALUE_SMALL_3, VALUE_MAX_3, 1.0, "vol_precision" );
1429 else if( hypType()=="StartEndLength" )
1431 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1433 else if( hypType()=="Deflection1D" )
1435 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "parametric_precision" );
1437 else if( hypType()=="Adaptive1D" )
1439 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1441 else if( hypType().startsWith( "ViscousLayers" ))
1443 if (sb->objectName() == tr("SMESH_STRETCH_FACTOR"))
1444 sb->RangeStepAndValidator( 1.0, VALUE_MAX, 0.1, "parametric_precision" );
1446 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1448 else // default validator for possible ancestors
1450 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1455 //================================================================================
1457 * \brief Return dlg title
1458 * \retval QString - title string
1460 //================================================================================
1462 QString StdMeshersGUI_StdHypothesisCreator::caption() const
1464 return tr( QString( "SMESH_%1_TITLE" ).arg( hypTypeName( hypType() ) ).toLatin1().data() );
1467 //================================================================================
1469 * \brief return pixmap for dlg icon
1472 //================================================================================
1474 QPixmap StdMeshersGUI_StdHypothesisCreator::icon() const
1476 QString hypIconName = tr( QString( "ICON_DLG_%1" ).arg( hypTypeName( hypType() ) ).toLatin1().data() );
1477 return SMESHGUI::resourceMgr()->loadPixmap( "SMESH", hypIconName );
1480 //================================================================================
1482 * \brief Return hypothesis type name to show in dlg
1485 //================================================================================
1487 QString StdMeshersGUI_StdHypothesisCreator::type() const
1489 return tr( QString( "SMESH_%1_HYPOTHESIS" ).arg( hypTypeName( hypType() ) ).toLatin1().data() );
1492 //================================================================================
1494 * \brief String to insert in "SMESH_%1_HYPOTHESIS" to get hypothesis type name
1495 * from message resouce file
1496 * \param t - hypothesis type
1497 * \retval QString - result string
1499 //================================================================================
1501 QString StdMeshersGUI_StdHypothesisCreator::hypTypeName( const QString& t ) const
1503 static QMap<QString,QString> types;
1504 if( types.isEmpty() )
1506 types.insert( "LocalLength", "LOCAL_LENGTH" );
1507 types.insert( "NumberOfSegments", "NB_SEGMENTS" );
1508 types.insert( "MaxElementArea", "MAX_ELEMENT_AREA" );
1509 types.insert( "MaxElementVolume", "MAX_ELEMENT_VOLUME" );
1510 types.insert( "StartEndLength", "START_END_LENGTH" );
1511 types.insert( "Deflection1D", "DEFLECTION1D" );
1512 types.insert( "Adaptive1D", "ADAPTIVE1D" );
1513 types.insert( "Arithmetic1D", "ARITHMETIC_1D" );
1514 types.insert( "GeometricProgression", "GEOMETRIC_1D" );
1515 types.insert( "FixedPoints1D", "FIXED_POINTS_1D" );
1516 types.insert( "AutomaticLength", "AUTOMATIC_LENGTH" );
1517 types.insert( "ProjectionSource1D", "PROJECTION_SOURCE_1D" );
1518 types.insert( "ProjectionSource2D", "PROJECTION_SOURCE_2D" );
1519 types.insert( "ProjectionSource3D", "PROJECTION_SOURCE_3D" );
1520 types.insert( "ImportSource1D", "IMPORT_SOURCE_1D" );
1521 types.insert( "ImportSource2D", "IMPORT_SOURCE_2D" );
1522 types.insert( "NumberOfLayers", "NUMBER_OF_LAYERS" );
1523 types.insert( "LayerDistribution", "LAYER_DISTRIBUTION" );
1524 types.insert( "NumberOfLayers2D", "NUMBER_OF_LAYERS_2D" );
1525 types.insert( "LayerDistribution2D", "LAYER_DISTRIBUTION" );
1526 types.insert( "SegmentLengthAroundVertex", "SEGMENT_LENGTH_AROUND_VERTEX" );
1527 types.insert( "MaxLength", "MAX_LENGTH" );
1528 types.insert( "ViscousLayers", "VISCOUS_LAYERS" );
1529 types.insert( "ViscousLayers2D", "VISCOUS_LAYERS" );
1530 types.insert( "QuadrangleParams", "QUADRANGLE_PARAMS" );
1531 types.insert( "CartesianParameters3D", "CARTESIAN_PARAMS" );
1535 if( types.contains( t ) )
1542 //=======================================================================
1543 //function : getCustomWidget
1544 //purpose : is called from buildStdFrame()
1545 //=======================================================================
1547 QWidget* StdMeshersGUI_StdHypothesisCreator::getCustomWidget( const StdParam & param,
1549 const int index) const
1552 if ( index < customWidgets()->count() ) {
1553 w = customWidgets()->at( index );
1555 w->setParent( parent );
1556 w->move( QPoint( 0, 0 ) );
1562 //================================================================================
1564 * \brief Set param value taken from a custom widget
1565 * \param param - SMESHGUI_GenericHypothesisCreator::StdParam structure
1566 * \param widget - widget presenting param
1567 * \retval bool - success flag
1569 * this method is called from getStdParamFromDlg()
1571 //================================================================================
1573 bool StdMeshersGUI_StdHypothesisCreator::getParamFromCustomWidget( StdParam & param,
1574 QWidget* widget) const
1576 if ( hypType()=="AutomaticLength" ) {
1577 SMESHGUI_SpinBox* w = dynamic_cast<SMESHGUI_SpinBox*>( widget );
1579 param.myValue = w->GetValue();
1583 if ( hypType() == "MaxLength" ) {
1587 if ( widget->inherits( "StdMeshersGUI_ObjectReferenceParamWdg" ))
1589 // show only 1st reference value
1590 if ( true /*widget == getWidgetForParam( 0 )*/) {
1591 const StdMeshersGUI_ObjectReferenceParamWdg * w =
1592 static_cast<const StdMeshersGUI_ObjectReferenceParamWdg*>( widget );
1593 param.myValue = w->GetValue();
1597 if ( widget->inherits( "StdMeshersGUI_LayerDistributionParamWdg" ))
1599 const StdMeshersGUI_LayerDistributionParamWdg * w =
1600 static_cast<const StdMeshersGUI_LayerDistributionParamWdg*>( widget );
1601 param.myValue = w->GetValue();
1604 if ( widget->inherits( "StdMeshersGUI_SubShapeSelectorWdg" ))
1606 const StdMeshersGUI_SubShapeSelectorWdg * w =
1607 static_cast<const StdMeshersGUI_SubShapeSelectorWdg*>( widget );
1608 param.myValue = w->GetValue();
1611 // if ( widget->inherits( "StdMeshersGUI_QuadrangleParamWdg" ))
1613 // param.myValue = "QuadType";
1616 if ( widget->inherits( "StdMeshersGUI_FixedPointsParamWdg" ))
1618 const StdMeshersGUI_FixedPointsParamWdg * w =
1619 static_cast<const StdMeshersGUI_FixedPointsParamWdg*>( widget );
1620 param.myValue = w->GetValue();
1623 if ( widget->inherits( "QCheckBox" ))
1625 //const QCheckBox * w = static_cast<const QCheckBox*>( widget );
1626 //param.myValue = w->isChecked();
1629 if ( widget->inherits( "StdMeshersGUI_RadioButtonsGrpWdg" ))
1631 const StdMeshersGUI_RadioButtonsGrpWdg * w =
1632 static_cast<const StdMeshersGUI_RadioButtonsGrpWdg*>( widget );
1633 param.myValue = w->checkedId();
1639 //================================================================================
1641 * \brief called when operation cancelled
1643 //================================================================================
1645 void StdMeshersGUI_StdHypothesisCreator::onReject()
1647 if ( hypType().startsWith("ProjectionSource" ) ||
1648 hypType().startsWith("ImportSource" ))
1650 // Uninstall filters of StdMeshersGUI_ObjectReferenceParamWdg
1651 deactivateObjRefParamWdg( customWidgets() );
1655 //================================================================================
1657 * \brief Update widgets dependent on paramWidget
1659 //================================================================================
1661 void StdMeshersGUI_StdHypothesisCreator::valueChanged( QWidget* paramWidget)
1663 if ( hypType() == "MaxLength" && paramWidget == getWidgetForParam(1) )
1665 getWidgetForParam(0)->setEnabled( !widget< QCheckBox >( 1 )->isChecked() );
1666 if ( !getWidgetForParam(0)->isEnabled() ) {
1667 StdMeshers::StdMeshers_MaxLength_var h =
1668 StdMeshers::StdMeshers_MaxLength::_narrow( initParamsHypothesis() );
1669 widget< QtxDoubleSpinBox >( 0 )->setValue( h->GetPreestimatedLength() );
1672 else if ( hypType().startsWith("ImportSource") && paramWidget == getWidgetForParam(1) )
1674 QCheckBox* toCopyMesh = (QCheckBox*) paramWidget;
1675 QCheckBox* toCopyGroups = widget< QCheckBox >( 2 );
1676 if ( !toCopyMesh->isChecked() )
1678 toCopyGroups->setChecked( false );
1679 toCopyGroups->setEnabled( false );
1683 toCopyGroups->setEnabled( true );
1686 else if ( hypType().startsWith( "ViscousLayers" ) && paramWidget->inherits("QButtonGroup"))
1688 if ( QLabel* label = getLabel(4) )
1690 bool toIgnore = widget< StdMeshersGUI_RadioButtonsGrpWdg >( 3 )->checkedId();
1691 if ( hypType() == "ViscousLayers2D" )
1692 label->setText( tr( toIgnore ? "SMESH_EDGES_WO_LAYERS" : "SMESH_EDGES_WITH_LAYERS" ));
1694 label->setText( tr( toIgnore ? "SMESH_FACES_WO_LAYERS" : "SMESH_FACES_WITH_LAYERS" ));
1699 //================================================================================
1703 //================================================================================
1705 bool StdMeshersGUI_StdHypothesisCreator::initVariableName(SMESH::SMESH_Hypothesis_var theHyp,
1706 StdParam & theParams,
1707 const char* theMethod) const
1709 QString aVaribaleName = getVariableName( theMethod );
1710 theParams.isVariable = !aVaribaleName.isEmpty();
1711 if (theParams.isVariable)
1712 theParams.myValue = aVaribaleName;
1714 return theParams.isVariable;