1 // Copyright (C) 2007-2011 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.
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>
33 #include <SMESH_TypeFilter.hxx>
34 #include <SMESH_NumberFilter.hxx>
36 #include "StdMeshersGUI_FixedPointsParamWdg.h"
37 #include "StdMeshersGUI_LayerDistributionParamWdg.h"
38 #include "StdMeshersGUI_ObjectReferenceParamWdg.h"
39 #include "StdMeshersGUI_QuadrangleParamWdg.h"
40 #include "StdMeshersGUI_SubShapeSelectorWdg.h"
42 #include <SALOMEDSClient_Study.hxx>
44 // SALOME GUI includes
45 #include <SUIT_ResourceMgr.h>
48 #include <SALOMEconfig.h>
49 #include CORBA_SERVER_HEADER(SMESH_BasicHypothesis)
50 #include CORBA_SERVER_HEADER(SMESH_Mesh)
53 #include <QHBoxLayout>
58 const double VALUE_MAX = 1.0e+15, // COORD_MAX
59 VALUE_MAX_2 = VALUE_MAX * VALUE_MAX,
60 VALUE_MAX_3 = VALUE_MAX_2 * VALUE_MAX,
61 VALUE_SMALL = 1.0e-15,
62 VALUE_SMALL_2 = VALUE_SMALL * VALUE_SMALL,
63 VALUE_SMALL_3 = VALUE_SMALL_2 * VALUE_SMALL;
65 //================================================================================
68 * \param type - hypothesis type
70 //================================================================================
72 StdMeshersGUI_StdHypothesisCreator::StdMeshersGUI_StdHypothesisCreator( const QString& type )
73 : SMESHGUI_GenericHypothesisCreator( type )
77 //================================================================================
81 //================================================================================
83 StdMeshersGUI_StdHypothesisCreator::~StdMeshersGUI_StdHypothesisCreator()
87 //================================================================================
89 * \brief Return widget for i-th hypothesis parameter (got from myParamWidgets)
90 * \param i - index of hypothesis parameter
91 * \retval QWidget* - found widget
93 //================================================================================
95 QWidget* StdMeshersGUI_StdHypothesisCreator::getWidgetForParam( int i ) const
98 if ( isCreation() ) ++i; // skip widget of 'name' parameter
100 if ( i < myCustomWidgets.count() ) {
101 QList<QWidget*>::const_iterator anIt = myCustomWidgets.begin();
102 QList<QWidget*>::const_iterator aLast = myCustomWidgets.end();
103 for ( int j = 0 ; !w && anIt != aLast; ++anIt, ++j )
108 // list has no at() const, so we iterate
109 QList<QWidget*>::const_iterator anIt = widgets().begin();
110 QList<QWidget*>::const_iterator aLast = widgets().end();
111 for( int j = 0; !w && anIt!=aLast; anIt++, ++j ) {
119 //================================================================================
121 * \brief Allow modifing myCustomWidgets in const methods
122 * \retval ListOfWidgets* - non-const pointer to myCustomWidgets
124 //================================================================================
126 StdMeshersGUI_StdHypothesisCreator::ListOfWidgets*
127 StdMeshersGUI_StdHypothesisCreator::customWidgets() const
129 return const_cast< ListOfWidgets* >( & myCustomWidgets );
132 //================================================================================
134 * \brief Builds dlg layout
135 * \retval QFrame* - the built widget
137 //================================================================================
139 QFrame* StdMeshersGUI_StdHypothesisCreator::buildFrame()
141 return buildStdFrame();
144 //================================================================================
146 * \brief Initialise parameter values in controls
148 //================================================================================
150 void StdMeshersGUI_StdHypothesisCreator::retrieveParams() const
152 // buildStdFrame() sets values itself calling stdParams()
154 if ( hypType().startsWith("ProjectionSource" ))
156 // we use this method to connect depending custom widgets
157 StdMeshersGUI_ObjectReferenceParamWdg* widgetToActivate = 0;
158 ListOfWidgets::const_iterator anIt = myCustomWidgets.begin();
159 for ( ; anIt != myCustomWidgets.end(); anIt++)
161 if ( *anIt && (*anIt)->inherits("StdMeshersGUI_ObjectReferenceParamWdg"))
163 StdMeshersGUI_ObjectReferenceParamWdg * w1 =
164 ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
165 ListOfWidgets::const_iterator anIt2 = anIt;
166 for ( ++anIt2; anIt2 != myCustomWidgets.end(); anIt2++)
167 if ( *anIt2 && (*anIt2)->inherits("StdMeshersGUI_ObjectReferenceParamWdg"))
169 StdMeshersGUI_ObjectReferenceParamWdg * w2 =
170 ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt2 );
171 w1->AvoidSimultaneousSelection( w2 );
173 if ( !widgetToActivate )
174 widgetToActivate = w1;
177 if ( widgetToActivate )
178 widgetToActivate->activateSelection();
182 dlg()->setMinimumSize( dlg()->minimumSizeHint().width(), dlg()->minimumSizeHint().height() );
187 //================================================================================
189 * \brief Widget: slider with left and right labels
191 //================================================================================
193 class TDoubleSliderWith2Labels: public QWidget
196 TDoubleSliderWith2Labels( const QString& leftLabel, const QString& rightLabel,
197 const double initValue, const double bottom,
198 const double top , const double precision,
199 QWidget * parent=0 , const char * name=0 )
200 :QWidget(parent), _bottom(bottom), _precision(precision)
204 QHBoxLayout* aHBoxL = new QHBoxLayout(this);
206 if ( !leftLabel.isEmpty() ) {
207 QLabel* aLeftLabel = new QLabel( this );
208 aLeftLabel->setText( leftLabel );
209 aHBoxL->addWidget( aLeftLabel );
212 _slider = new QSlider( Qt::Horizontal, this );
213 _slider->setRange( 0, toInt( top ));
214 _slider->setValue( toInt( initValue ));
215 aHBoxL->addWidget( _slider );
217 if ( !rightLabel.isEmpty() ) {
218 QLabel* aRightLabel = new QLabel( this );
219 aRightLabel->setText( rightLabel );
220 aHBoxL->addWidget( aRightLabel );
225 double value() const { return _bottom + _slider->value() * _precision; }
226 QSlider * getSlider() const { return _slider; }
227 int toInt( double val ) const { return (int) ceil(( val - _bottom ) / _precision ); }
229 double _bottom, _precision;
233 //================================================================================
235 * \brief Retrieve GEOM_Object held by widget
237 //================================================================================
239 inline GEOM::GEOM_Object_var geomFromWdg(const QWidget* wdg)
241 const StdMeshersGUI_ObjectReferenceParamWdg * objRefWdg =
242 dynamic_cast<const StdMeshersGUI_ObjectReferenceParamWdg*>( wdg );
244 return objRefWdg->GetObject< GEOM::GEOM_Object >();
246 return GEOM::GEOM_Object::_nil();
248 //================================================================================
250 * \brief Retrieve SMESH_Mesh held by widget
252 //================================================================================
254 inline SMESH::SMESH_Mesh_var meshFromWdg(const QWidget* wdg)
256 const StdMeshersGUI_ObjectReferenceParamWdg * objRefWdg =
257 dynamic_cast<const StdMeshersGUI_ObjectReferenceParamWdg*>( wdg );
259 return objRefWdg->GetObject< SMESH::SMESH_Mesh >();
261 return SMESH::SMESH_Mesh::_nil();
263 //================================================================================
265 * \brief creates a filter for selection of shapes of given dimension
266 * \param dim - dimension
267 * \param subShapeType - required type of subshapes, number of which must be \a nbSubShapes
268 * \param nbSubShapes - number of subshapes of given type
269 * \param closed - required closeness flag of a shape
270 * \retval SUIT_SelectionFilter* - created filter
272 //================================================================================
274 SUIT_SelectionFilter* filterForShapeOfDim(const int dim,
275 TopAbs_ShapeEnum subShapeType = TopAbs_SHAPE,
276 const int nbSubShapes = 0,
279 TColStd_MapOfInteger shapeTypes;
281 case 0: shapeTypes.Add( TopAbs_VERTEX ); break;
283 if ( subShapeType == TopAbs_SHAPE ) subShapeType = TopAbs_EDGE;
284 shapeTypes.Add( TopAbs_EDGE );
285 shapeTypes.Add( TopAbs_COMPOUND ); // for a group
288 if ( subShapeType == TopAbs_SHAPE ) subShapeType = TopAbs_FACE;
289 shapeTypes.Add( TopAbs_FACE );
290 shapeTypes.Add( TopAbs_COMPOUND ); // for a group
293 shapeTypes.Add( TopAbs_SHELL );
294 shapeTypes.Add( TopAbs_SOLID );
295 shapeTypes.Add( TopAbs_COMPSOLID );
296 shapeTypes.Add( TopAbs_COMPOUND );
299 return new SMESH_NumberFilter("GEOM", subShapeType, nbSubShapes,
300 shapeTypes, GEOM::GEOM_Object::_nil(), closed);
303 //================================================================================
305 * \brief Create a widget for object selection
306 * \param object - initial object
307 * \param filter - selection filter
308 * \retval QWidget* - created widget
310 //================================================================================
312 QWidget* newObjRefParamWdg( SUIT_SelectionFilter* filter,
313 CORBA::Object_var object)
315 StdMeshersGUI_ObjectReferenceParamWdg* w =
316 new StdMeshersGUI_ObjectReferenceParamWdg( filter, 0);
317 w->SetObject( object.in() );
321 //================================================================================
323 * \brief calls deactivateSelection() for StdMeshersGUI_ObjectReferenceParamWdg
324 * \param widgetList - list of widgets
326 //================================================================================
328 void deactivateObjRefParamWdg( QList<QWidget*>* widgetList )
330 StdMeshersGUI_ObjectReferenceParamWdg* w = 0;
331 QList<QWidget*>::iterator anIt = widgetList->begin();
332 QList<QWidget*>::iterator aLast = widgetList->end();
333 for ( ; anIt != aLast; anIt++ ) {
334 if ( (*anIt) && (*anIt)->inherits( "StdMeshersGUI_ObjectReferenceParamWdg" ))
336 w = (StdMeshersGUI_ObjectReferenceParamWdg* )( *anIt );
337 w->deactivateSelection();
343 //================================================================================
345 * \brief Check parameter values before accept()
346 * \retval bool - true if OK
348 //================================================================================
350 bool StdMeshersGUI_StdHypothesisCreator::checkParams( QString& msg ) const
352 if( !SMESHGUI_GenericHypothesisCreator::checkParams( msg ) )
355 // check if object reference parameter is set, as it has no default value
357 if ( hypType().startsWith("ProjectionSource" ))
359 StdMeshersGUI_ObjectReferenceParamWdg* w =
360 widget< StdMeshersGUI_ObjectReferenceParamWdg >( 0 );
361 ok = ( w->IsObjectSelected() );
362 if ( !ok ) w->SetObject( CORBA::Object::_nil() );
363 int nbAssocVert = ( hypType() == "ProjectionSource1D" ? 1 : 2 );
364 for ( int i = 0; ok && i < nbAssocVert; i += 2)
367 StdMeshersGUI_ObjectReferenceParamWdg* w1 =
368 widget< StdMeshersGUI_ObjectReferenceParamWdg >( i+2 );
369 StdMeshersGUI_ObjectReferenceParamWdg* w2 =
370 widget< StdMeshersGUI_ObjectReferenceParamWdg >( i+3 );
371 srcV = w1->GetValue();
372 tgtV = w2->GetValue();
373 ok = (( srcV.isEmpty() && tgtV.isEmpty() ) ||
374 ( !srcV.isEmpty() && !tgtV.isEmpty() && srcV != tgtV ));
376 w1->SetObject( CORBA::Object::_nil() );
377 w2->SetObject( CORBA::Object::_nil() );
381 // Uninstall filters of StdMeshersGUI_ObjectReferenceParamWdg
383 deactivateObjRefParamWdg( customWidgets() );
385 else if ( hypType() == "LayerDistribution" || hypType() == "LayerDistribution2D" )
387 StdMeshersGUI_LayerDistributionParamWdg* w =
388 widget< StdMeshersGUI_LayerDistributionParamWdg >( 0 );
389 ok = ( w && w->IsOk() );
391 else if ( hypType() == "QuadrangleParams" )
393 //StdMeshersGUI_SubShapeSelectorWdg* w =
394 // widget< StdMeshersGUI_SubShapeSelectorWdg >( 0 );
395 //ok = ( w->GetListSize() > 0 );
396 //StdMeshersGUI_QuadrangleParamWdg* w =
397 // widget< StdMeshersGUI_QuadrangleParamWdg >( 1 );
402 //================================================================================
404 * \brief Store params from GUI controls to a hypothesis
405 * \retval QString - text representation of parameters
407 //================================================================================
409 QString StdMeshersGUI_StdHypothesisCreator::storeParams() const
411 ListOfStdParams params;
412 bool res = getStdParamFromDlg( params );
415 SMESH::SetName( SMESH::FindSObject( hypothesis() ), params[0].myValue.toString().toLatin1().data() );
416 params.erase( params.begin() );
419 QString valueStr = stdParamValues( params );
420 QStringList aVariablesList = getVariablesFromDlg();
422 if( res && !params.isEmpty() )
424 if( hypType()=="LocalLength" )
426 StdMeshers::StdMeshers_LocalLength_var h =
427 StdMeshers::StdMeshers_LocalLength::_narrow( hypothesis() );
429 h->SetLength( params[0].myValue.toDouble() );
430 h->SetParameters(aVariablesList.join(":").toLatin1().constData());
431 h->SetPrecision( params[1].myValue.toDouble() );
432 h->SetParameters(aVariablesList.join(":").toLatin1().constData());
434 else if( hypType()=="MaxLength" )
436 StdMeshers::StdMeshers_MaxLength_var h =
437 StdMeshers::StdMeshers_MaxLength::_narrow( hypothesis() );
439 h->SetLength( params[0].myValue.toDouble() );
440 h->SetParameters(aVariablesList.join(":").toLatin1().constData());
441 h->SetUsePreestimatedLength( widget< QCheckBox >( 1 )->isChecked() );
442 if ( !h->HavePreestimatedLength() && !h->_is_equivalent( initParamsHypothesis() )) {
443 StdMeshers::StdMeshers_MaxLength_var hInit =
444 StdMeshers::StdMeshers_MaxLength::_narrow( initParamsHypothesis() );
445 h->SetPreestimatedLength( hInit->GetPreestimatedLength() );
448 else if( hypType()=="SegmentLengthAroundVertex" )
450 StdMeshers::StdMeshers_SegmentLengthAroundVertex_var h =
451 StdMeshers::StdMeshers_SegmentLengthAroundVertex::_narrow( hypothesis() );
453 h->SetLength( params[0].myValue.toDouble() );
454 h->SetParameters(aVariablesList.join(":").toLatin1().constData());
456 else if( hypType()=="Arithmetic1D" )
458 StdMeshers::StdMeshers_Arithmetic1D_var h =
459 StdMeshers::StdMeshers_Arithmetic1D::_narrow( hypothesis() );
461 StdMeshersGUI_SubShapeSelectorWdg* w =
462 widget< StdMeshersGUI_SubShapeSelectorWdg >( 2 );
464 h->SetStartLength( params[0].myValue.toDouble() );
465 h->SetParameters(aVariablesList.join(":").toLatin1().constData());
466 h->SetEndLength( params[1].myValue.toDouble() );
467 h->SetParameters(aVariablesList.join(":").toLatin1().constData());
469 h->SetReversedEdges( w->GetListOfIDs() );
470 h->SetObjectEntry( w->GetMainShapeEntry() );
473 else if( hypType()=="FixedPoints1D" )
475 StdMeshers::StdMeshers_FixedPoints1D_var h =
476 StdMeshers::StdMeshers_FixedPoints1D::_narrow( hypothesis() );
478 StdMeshersGUI_FixedPointsParamWdg* w1 =
479 widget< StdMeshersGUI_FixedPointsParamWdg >( 0 );
481 StdMeshersGUI_SubShapeSelectorWdg* w2 =
482 widget< StdMeshersGUI_SubShapeSelectorWdg >( 1 );
485 h->SetParameters(aVariablesList.join(":").toLatin1().constData());
486 h->SetPoints( w1->GetListOfPoints() );
487 h->SetNbSegments( w1->GetListOfSegments() );
490 h->SetReversedEdges( w2->GetListOfIDs() );
491 h->SetObjectEntry( w2->GetMainShapeEntry() );
494 else if( hypType()=="MaxElementArea" )
496 StdMeshers::StdMeshers_MaxElementArea_var h =
497 StdMeshers::StdMeshers_MaxElementArea::_narrow( hypothesis() );
498 h->SetParameters(aVariablesList.join(":").toLatin1().constData());
499 h->SetMaxElementArea( params[0].myValue.toDouble() );
501 else if( hypType()=="MaxElementVolume" )
503 StdMeshers::StdMeshers_MaxElementVolume_var h =
504 StdMeshers::StdMeshers_MaxElementVolume::_narrow( hypothesis() );
506 h->SetMaxElementVolume( params[0].myValue.toDouble() );
507 h->SetParameters(aVariablesList.join(":").toLatin1().constData());
509 else if( hypType()=="StartEndLength" )
511 StdMeshers::StdMeshers_StartEndLength_var h =
512 StdMeshers::StdMeshers_StartEndLength::_narrow( hypothesis() );
514 StdMeshersGUI_SubShapeSelectorWdg* w =
515 widget< StdMeshersGUI_SubShapeSelectorWdg >( 2 );
517 h->SetStartLength( params[0].myValue.toDouble() );
518 h->SetParameters(aVariablesList.join(":").toLatin1().constData());
519 h->SetEndLength( params[1].myValue.toDouble() );
520 h->SetParameters(aVariablesList.join(":").toLatin1().constData());
522 h->SetReversedEdges( w->GetListOfIDs() );
523 h->SetObjectEntry( w->GetMainShapeEntry() );
526 else if( hypType()=="Deflection1D" )
528 StdMeshers::StdMeshers_Deflection1D_var h =
529 StdMeshers::StdMeshers_Deflection1D::_narrow( hypothesis() );
530 h->SetParameters(aVariablesList.join(":").toLatin1().constData());
531 h->SetDeflection( params[0].myValue.toDouble() );
533 else if( hypType()=="AutomaticLength" )
535 StdMeshers::StdMeshers_AutomaticLength_var h =
536 StdMeshers::StdMeshers_AutomaticLength::_narrow( hypothesis() );
538 h->SetFineness( params[0].myValue.toDouble() );
540 else if( hypType()=="NumberOfLayers" )
542 StdMeshers::StdMeshers_NumberOfLayers_var h =
543 StdMeshers::StdMeshers_NumberOfLayers::_narrow( hypothesis() );
545 h->SetNumberOfLayers( params[0].myValue.toInt() );
546 h->SetParameters(aVariablesList.join(":").toLatin1().constData());
548 else if( hypType()=="LayerDistribution" )
550 StdMeshers::StdMeshers_LayerDistribution_var h =
551 StdMeshers::StdMeshers_LayerDistribution::_narrow( hypothesis() );
552 StdMeshersGUI_LayerDistributionParamWdg* w =
553 widget< StdMeshersGUI_LayerDistributionParamWdg >( 0 );
555 h->SetLayerDistribution( w->GetHypothesis() );
556 h->SetParameters(w->GetHypothesis()->GetParameters());
557 w->GetHypothesis()->ClearParameters();
559 else if( hypType()=="NumberOfLayers2D" )
561 StdMeshers::StdMeshers_NumberOfLayers2D_var h =
562 StdMeshers::StdMeshers_NumberOfLayers2D::_narrow( hypothesis() );
564 h->SetNumberOfLayers( params[0].myValue.toInt() );
565 h->SetParameters(aVariablesList.join(":").toLatin1().constData());
567 else if( hypType()=="LayerDistribution2D" )
569 StdMeshers::StdMeshers_LayerDistribution2D_var h =
570 StdMeshers::StdMeshers_LayerDistribution2D::_narrow( hypothesis() );
571 StdMeshersGUI_LayerDistributionParamWdg* w =
572 widget< StdMeshersGUI_LayerDistributionParamWdg >( 0 );
574 h->SetLayerDistribution( w->GetHypothesis() );
575 h->SetParameters(w->GetHypothesis()->GetParameters());
576 w->GetHypothesis()->ClearParameters();
578 else if( hypType()=="ProjectionSource1D" )
580 StdMeshers::StdMeshers_ProjectionSource1D_var h =
581 StdMeshers::StdMeshers_ProjectionSource1D::_narrow( hypothesis() );
583 h->SetSourceEdge ( geomFromWdg ( getWidgetForParam( 0 )));
584 h->SetSourceMesh ( meshFromWdg ( getWidgetForParam( 1 )));
585 h->SetVertexAssociation( geomFromWdg ( getWidgetForParam( 2 )),
586 geomFromWdg ( getWidgetForParam( 3 )));
588 else if( hypType()=="ProjectionSource2D" )
590 StdMeshers::StdMeshers_ProjectionSource2D_var h =
591 StdMeshers::StdMeshers_ProjectionSource2D::_narrow( hypothesis() );
593 h->SetSourceFace ( geomFromWdg ( getWidgetForParam( 0 )));
594 h->SetSourceMesh ( meshFromWdg ( getWidgetForParam( 1 )));
595 h->SetVertexAssociation( geomFromWdg ( getWidgetForParam( 2 )), // src1
596 geomFromWdg ( getWidgetForParam( 4 )), // src2
597 geomFromWdg ( getWidgetForParam( 3 )), // tgt1
598 geomFromWdg ( getWidgetForParam( 5 ))); // tgt2
600 else if( hypType()=="ProjectionSource3D" )
602 StdMeshers::StdMeshers_ProjectionSource3D_var h =
603 StdMeshers::StdMeshers_ProjectionSource3D::_narrow( hypothesis() );
605 h->SetSource3DShape ( geomFromWdg ( getWidgetForParam( 0 )));
606 h->SetSourceMesh ( meshFromWdg ( getWidgetForParam( 1 )));
607 h->SetVertexAssociation( geomFromWdg ( getWidgetForParam( 2 )), // src1
608 geomFromWdg ( getWidgetForParam( 4 )), // src2
609 geomFromWdg ( getWidgetForParam( 3 )), // tgt1
610 geomFromWdg ( getWidgetForParam( 5 ))); // tgt2
612 else if( hypType()=="QuadrangleParams" )
614 StdMeshers::StdMeshers_QuadrangleParams_var h =
615 StdMeshers::StdMeshers_QuadrangleParams::_narrow( hypothesis() );
616 StdMeshersGUI_SubShapeSelectorWdg* w1 =
617 widget< StdMeshersGUI_SubShapeSelectorWdg >( 0 );
618 StdMeshersGUI_QuadrangleParamWdg* w2 =
619 widget< StdMeshersGUI_QuadrangleParamWdg >( 1 );
621 if (w1->GetListSize() > 0) {
622 h->SetTriaVertex(w1->GetListOfIDs()[0]); // getlist must be called once
623 const char * entry = w1->GetMainShapeEntry();
624 h->SetObjectEntry(entry);
626 h->SetQuadType(StdMeshers::QuadType(w2->GetType()));
633 //================================================================================
635 * \brief Return parameter values as SMESHGUI_GenericHypothesisCreator::StdParam
636 * \param p - list of parameters
637 * \retval bool - success flag
639 * Is called from SMESHGUI_GenericHypothesisCreator::buildStdFrame().
640 * Parameters will be shown using "standard" controls:
641 * Int by QtxIntSpinBox
642 * Double by SMESHGUI_SpinBox
643 * String by QLineEdit
644 * getCustomWidget() allows to redefine control for a parameter
646 //================================================================================
648 bool StdMeshersGUI_StdHypothesisCreator::stdParams( ListOfStdParams& p ) const
651 SMESHGUI_GenericHypothesisCreator::StdParam item;
654 customWidgets()->clear();
657 HypothesisData* data = SMESH::GetHypothesisData( hypType() );
658 item.myName = tr( "SMESH_NAME" );
659 item.myValue = data ? hypName() : QString();
661 customWidgets()->append(0);
664 SMESH::SMESH_Hypothesis_var hyp = initParamsHypothesis();
665 SMESH::ListOfParameters_var aParameters = hyp->GetLastParameters();
667 if( hypType()=="LocalLength" )
669 StdMeshers::StdMeshers_LocalLength_var h =
670 StdMeshers::StdMeshers_LocalLength::_narrow( hyp );
672 item.myName = tr("SMESH_LOCAL_LENGTH_PARAM");
673 if(!initVariableName(aParameters,item,0))
674 item.myValue = h->GetLength();
677 item.myName = tr("SMESH_LOCAL_LENGTH_PRECISION");
678 if(!initVariableName(aParameters,item,1))
679 item.myValue = h->GetPrecision();
683 else if( hypType()=="MaxLength" )
685 StdMeshers::StdMeshers_MaxLength_var h =
686 StdMeshers::StdMeshers_MaxLength::_narrow( hyp );
687 // try to set a right preestimated length to edited hypothesis
688 bool noPreestimatedAtEdition = false;
689 if ( !isCreation() ) {
690 StdMeshers::StdMeshers_MaxLength_var initHyp =
691 StdMeshers::StdMeshers_MaxLength::_narrow( initParamsHypothesis(true) );
692 noPreestimatedAtEdition =
693 ( initHyp->_is_nil() || !initHyp->HavePreestimatedLength() );
694 if ( !noPreestimatedAtEdition )
695 h->SetPreestimatedLength( initHyp->GetPreestimatedLength() );
698 item.myName = tr("SMESH_LOCAL_LENGTH_PARAM");
699 if(!initVariableName(aParameters,item,0))
700 item.myValue = h->GetLength();
702 customWidgets()->append(0);
704 item.myName = tr("SMESH_USE_PREESTIMATED_LENGTH");
706 QCheckBox* aQCheckBox = new QCheckBox(dlg());
707 if ( !noPreestimatedAtEdition && h->HavePreestimatedLength() ) {
708 aQCheckBox->setChecked( h->GetUsePreestimatedLength() );
709 connect( aQCheckBox, SIGNAL( stateChanged(int) ), this, SLOT( onValueChanged() ) );
712 aQCheckBox->setChecked( false );
713 aQCheckBox->setEnabled( false );
715 customWidgets()->append( aQCheckBox );
717 else if( hypType()=="SegmentLengthAroundVertex" )
719 StdMeshers::StdMeshers_SegmentLengthAroundVertex_var h =
720 StdMeshers::StdMeshers_SegmentLengthAroundVertex::_narrow( hyp );
722 item.myName = tr("SMESH_LOCAL_LENGTH_PARAM");
723 if(!initVariableName(aParameters,item,0))
724 item.myValue = h->GetLength();
728 else if( hypType()=="Arithmetic1D" )
730 StdMeshers::StdMeshers_Arithmetic1D_var h =
731 StdMeshers::StdMeshers_Arithmetic1D::_narrow( hyp );
733 item.myName = tr( "SMESH_START_LENGTH_PARAM" );
734 if(!initVariableName(aParameters,item,0))
735 item.myValue = h->GetLength( true );
738 customWidgets()->append (0);
740 item.myName = tr( "SMESH_END_LENGTH_PARAM" );
741 if(!initVariableName(aParameters,item,1))
742 item.myValue = h->GetLength( false );
745 customWidgets()->append (0);
747 item.myName = tr( "SMESH_REVERSED_EDGES" );
750 StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget =
751 new StdMeshersGUI_SubShapeSelectorWdg();
752 QString aGeomEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
753 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
754 if ( aGeomEntry == "" )
755 aGeomEntry = h->GetObjectEntry();
757 aDirectionWidget->SetGeomShapeEntry( aGeomEntry );
758 aDirectionWidget->SetMainShapeEntry( aMainEntry );
759 aDirectionWidget->SetListOfIDs( h->GetReversedEdges() );
760 aDirectionWidget->showPreview( true );
761 customWidgets()->append ( aDirectionWidget );
765 else if( hypType()=="FixedPoints1D" )
767 StdMeshers::StdMeshers_FixedPoints1D_var h =
768 StdMeshers::StdMeshers_FixedPoints1D::_narrow( hyp );
770 item.myName = tr( "SMESH_FIXED_POINTS" );
773 StdMeshersGUI_FixedPointsParamWdg* aFixedPointsWidget =
774 new StdMeshersGUI_FixedPointsParamWdg();
776 if ( !isCreation() ) {
777 aFixedPointsWidget->SetListOfPoints( h->GetPoints() );
778 aFixedPointsWidget->SetListOfSegments( h->GetNbSegments() );
780 customWidgets()->append( aFixedPointsWidget );
782 item.myName = tr( "SMESH_REVERSED_EDGES" );
785 StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget =
786 new StdMeshersGUI_SubShapeSelectorWdg();
787 QString anEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
788 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
790 anEntry = h->GetObjectEntry();
791 aDirectionWidget->SetGeomShapeEntry( anEntry );
792 aDirectionWidget->SetMainShapeEntry( aMainEntry );
793 aDirectionWidget->SetListOfIDs( h->GetReversedEdges() );
794 aDirectionWidget->showPreview( true );
795 customWidgets()->append ( aDirectionWidget );
799 else if( hypType()=="MaxElementArea" )
801 StdMeshers::StdMeshers_MaxElementArea_var h =
802 StdMeshers::StdMeshers_MaxElementArea::_narrow( hyp );
804 item.myName = tr( "SMESH_MAX_ELEMENT_AREA_PARAM" );
805 if(!initVariableName(aParameters,item,0))
806 item.myValue = h->GetMaxElementArea();
810 else if( hypType()=="MaxElementVolume" )
812 StdMeshers::StdMeshers_MaxElementVolume_var h =
813 StdMeshers::StdMeshers_MaxElementVolume::_narrow( hyp );
815 item.myName = tr( "SMESH_MAX_ELEMENT_VOLUME_PARAM" );
816 if(!initVariableName(aParameters,item,0))
817 item.myValue = h->GetMaxElementVolume();
820 else if( hypType()=="StartEndLength" )
822 StdMeshers::StdMeshers_StartEndLength_var h =
823 StdMeshers::StdMeshers_StartEndLength::_narrow( hyp );
825 item.myName = tr( "SMESH_START_LENGTH_PARAM" );
827 if(!initVariableName(aParameters,item,0))
828 item.myValue = h->GetLength( true );
830 customWidgets()->append(0);
832 item.myName = tr( "SMESH_END_LENGTH_PARAM" );
833 if(!initVariableName(aParameters,item,1))
834 item.myValue = h->GetLength( false );
836 customWidgets()->append(0);
838 item.myName = tr( "SMESH_REVERSED_EDGES" );
841 StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget =
842 new StdMeshersGUI_SubShapeSelectorWdg();
843 QString anEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
844 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
846 anEntry = h->GetObjectEntry();
847 aDirectionWidget->SetGeomShapeEntry( anEntry );
848 aDirectionWidget->SetMainShapeEntry( aMainEntry );
849 aDirectionWidget->SetListOfIDs( h->GetReversedEdges() );
850 aDirectionWidget->showPreview( true );
851 customWidgets()->append ( aDirectionWidget );
853 else if( hypType()=="Deflection1D" )
855 StdMeshers::StdMeshers_Deflection1D_var h =
856 StdMeshers::StdMeshers_Deflection1D::_narrow( hyp );
858 item.myName = tr( "SMESH_DEFLECTION1D_PARAM" );
859 if(!initVariableName(aParameters,item,0))
860 item.myValue = h->GetDeflection();
863 else if( hypType()=="AutomaticLength" )
865 StdMeshers::StdMeshers_AutomaticLength_var h =
866 StdMeshers::StdMeshers_AutomaticLength::_narrow( hyp );
868 item.myName = tr( "SMESH_FINENESS_PARAM" );
869 //item.myValue = h->GetFineness();
871 SMESHGUI_SpinBox* _autoLengthSpinBox = new SMESHGUI_SpinBox(dlg());
872 _autoLengthSpinBox->RangeStepAndValidator(0, 1, 0.01, "length_precision");
873 _autoLengthSpinBox->SetValue(h->GetFineness());
874 customWidgets()->append( _autoLengthSpinBox);
876 else if( hypType()=="NumberOfLayers" )
878 StdMeshers::StdMeshers_NumberOfLayers_var h =
879 StdMeshers::StdMeshers_NumberOfLayers::_narrow( hyp );
881 item.myName = tr( "SMESH_NUMBER_OF_LAYERS" );
882 if(!initVariableName(aParameters,item,0))
883 item.myValue = (int) h->GetNumberOfLayers();
886 else if( hypType()=="LayerDistribution" ) {
887 StdMeshers::StdMeshers_LayerDistribution_var h =
888 StdMeshers::StdMeshers_LayerDistribution::_narrow( hyp );
890 item.myName = tr( "SMESH_LAYERS_DISTRIBUTION" ); p.append( item );
892 //Set into not published hypo last variables
893 QStringList aLastVarsList;
894 for(int i = 0;i<aParameters->length();i++)
895 aLastVarsList.append(QString(aParameters[i].in()));
897 if(!aLastVarsList.isEmpty())
898 h->GetLayerDistribution()->SetLastParameters(aLastVarsList.join(":").toLatin1().constData());
900 customWidgets()->append
901 ( new StdMeshersGUI_LayerDistributionParamWdg( h->GetLayerDistribution(), hypName(), dlg()));
903 else if( hypType()=="NumberOfLayers2D" ) {
904 StdMeshers::StdMeshers_NumberOfLayers2D_var h =
905 StdMeshers::StdMeshers_NumberOfLayers2D::_narrow( hyp );
907 item.myName = tr( "SMESH_NUMBER_OF_LAYERS" );
908 if(!initVariableName(aParameters,item,0))
909 item.myValue = (int) h->GetNumberOfLayers();
912 else if( hypType()=="LayerDistribution2D" ) {
913 StdMeshers::StdMeshers_LayerDistribution2D_var h =
914 StdMeshers::StdMeshers_LayerDistribution2D::_narrow( hyp );
916 item.myName = tr( "SMESH_LAYERS_DISTRIBUTION" ); p.append( item );
918 //Set into not published hypo last variables
919 QStringList aLastVarsList;
920 for(int i = 0;i<aParameters->length();i++)
921 aLastVarsList.append(QString(aParameters[i].in()));
923 if(!aLastVarsList.isEmpty())
924 h->GetLayerDistribution()->SetLastParameters(aLastVarsList.join(":").toLatin1().constData());
926 customWidgets()->append
927 ( new StdMeshersGUI_LayerDistributionParamWdg( h->GetLayerDistribution(), hypName(), dlg()));
929 else if( hypType()=="ProjectionSource1D" )
931 StdMeshers::StdMeshers_ProjectionSource1D_var h =
932 StdMeshers::StdMeshers_ProjectionSource1D::_narrow( hyp );
934 item.myName = tr( "SMESH_SOURCE_EDGE" ); p.append( item );
935 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 1 ),
936 h->GetSourceEdge()));
937 item.myName = tr( "SMESH_SOURCE_MESH" ); p.append( item );
938 customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( MESH ),
939 h->GetSourceMesh()));
940 item.myName = tr( "SMESH_SOURCE_VERTEX" ); p.append( item );
941 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
942 h->GetSourceVertex()));
943 item.myName = tr( "SMESH_TARGET_VERTEX" ); p.append( item );
944 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
945 h->GetTargetVertex()));
947 else if( hypType()=="ProjectionSource2D" )
949 StdMeshers::StdMeshers_ProjectionSource2D_var h =
950 StdMeshers::StdMeshers_ProjectionSource2D::_narrow( hyp );
952 item.myName = tr( "SMESH_SOURCE_FACE" ); p.append( item );
953 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 2 ),
954 h->GetSourceFace()));
955 item.myName = tr( "SMESH_SOURCE_MESH" ); p.append( item );
956 customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( MESH ),
957 h->GetSourceMesh()));
958 item.myName = tr( "SMESH_SOURCE_VERTEX1" ); p.append( item );
959 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
960 h->GetSourceVertex( 1 )));
961 item.myName = tr( "SMESH_TARGET_VERTEX1" ); p.append( item );
962 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
963 h->GetTargetVertex( 1 )));
964 item.myName = tr( "SMESH_SOURCE_VERTEX2" ); p.append( item );
965 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
966 h->GetSourceVertex( 2 )));
967 item.myName = tr( "SMESH_TARGET_VERTEX2" ); p.append( item );
968 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
969 h->GetTargetVertex( 2 )));
971 else if( hypType()=="ProjectionSource3D" )
973 StdMeshers::StdMeshers_ProjectionSource3D_var h =
974 StdMeshers::StdMeshers_ProjectionSource3D::_narrow( hyp );
976 item.myName = tr( "SMESH_SOURCE_3DSHAPE" ); p.append( item );
977 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 3, TopAbs_FACE, 6, true ),
978 h->GetSource3DShape()));
979 item.myName = tr( "SMESH_SOURCE_MESH" ); p.append( item );
980 customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( MESH ),
981 h->GetSourceMesh()));
982 item.myName = tr( "SMESH_SOURCE_VERTEX1" ); p.append( item );
983 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
984 h->GetSourceVertex( 1 )));
985 item.myName = tr( "SMESH_TARGET_VERTEX1" ); p.append( item );
986 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
987 h->GetTargetVertex( 1 )));
988 item.myName = tr( "SMESH_SOURCE_VERTEX2" ); p.append( item );
989 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
990 h->GetSourceVertex( 2 )));
991 item.myName = tr( "SMESH_TARGET_VERTEX2" ); p.append( item );
992 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
993 h->GetTargetVertex( 2 )));
995 else if (hypType() == "QuadrangleParams")
997 StdMeshers::StdMeshers_QuadrangleParams_var h =
998 StdMeshers::StdMeshers_QuadrangleParams::_narrow(hyp);
1000 item.myName = tr("SMESH_BASE_VERTEX");
1003 StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget =
1004 new StdMeshersGUI_SubShapeSelectorWdg();
1005 aDirectionWidget->SetMaxSize(1);
1006 aDirectionWidget->SetSubShType(TopAbs_VERTEX);
1007 QString anEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
1008 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
1010 anEntry = h->GetObjectEntry();
1011 aDirectionWidget->SetGeomShapeEntry(anEntry);
1012 aDirectionWidget->SetMainShapeEntry(aMainEntry);
1013 if (!isCreation()) {
1014 SMESH::long_array_var aVec = new SMESH::long_array;
1015 int vertID = h->GetTriaVertex();
1019 aDirectionWidget->SetListOfIDs(aVec);
1022 aDirectionWidget->showPreview(true);
1024 item.myName = tr("SMESH_QUAD_TYPE");
1027 StdMeshersGUI_QuadrangleParamWdg* aTypeWidget =
1028 new StdMeshersGUI_QuadrangleParamWdg();
1029 if (!isCreation()) {
1030 aTypeWidget->SetType(int(h->GetQuadType()));
1033 customWidgets()->append(aDirectionWidget);
1034 customWidgets()->append(aTypeWidget);
1041 //================================================================================
1043 * \brief tune "standard" control
1044 * \param w - control widget
1045 * \param int - parameter index
1047 //================================================================================
1049 void StdMeshersGUI_StdHypothesisCreator::attuneStdWidget (QWidget* w, const int) const
1051 SMESHGUI_SpinBox* sb = w->inherits( "SMESHGUI_SpinBox" ) ? ( SMESHGUI_SpinBox* )w : 0;
1052 if( hypType()=="LocalLength" && sb )
1054 if (sb->objectName() == tr("SMESH_LOCAL_LENGTH_PARAM"))
1055 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1056 else if (sb->objectName() == tr("SMESH_LOCAL_LENGTH_PRECISION"))
1057 sb->RangeStepAndValidator( 0.0, 1.0, 0.05, "len_tol_precision" );
1059 else if( hypType()=="Arithmetic1D" && sb )
1061 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "parametric_precision" );
1063 else if( hypType()=="MaxLength" && sb )
1065 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1066 sb->setEnabled( !widget< QCheckBox >( 1 )->isChecked() );
1068 else if( hypType()=="MaxElementArea" && sb )
1070 sb->RangeStepAndValidator( VALUE_SMALL_2, VALUE_MAX_2, 1.0, "area_precision" );
1072 else if( hypType()=="MaxElementVolume" && sb )
1074 sb->RangeStepAndValidator( VALUE_SMALL_3, VALUE_MAX_3, 1.0, "vol_precision" );
1076 else if( hypType()=="StartEndLength" && sb )
1078 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1080 else if( hypType()=="Deflection1D" && sb )
1082 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "parametric_precision" );
1084 else if ( sb ) // default validator for possible ancestors
1086 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1090 //================================================================================
1092 * \brief Return dlg title
1093 * \retval QString - title string
1095 //================================================================================
1097 QString StdMeshersGUI_StdHypothesisCreator::caption() const
1099 return tr( QString( "SMESH_%1_TITLE" ).arg( hypTypeName( hypType() ) ).toLatin1().data() );
1102 //================================================================================
1104 * \brief return pixmap for dlg icon
1107 //================================================================================
1109 QPixmap StdMeshersGUI_StdHypothesisCreator::icon() const
1111 QString hypIconName = tr( QString( "ICON_DLG_%1" ).arg( hypTypeName( hypType() ) ).toLatin1().data() );
1112 return SMESHGUI::resourceMgr()->loadPixmap( "SMESH", hypIconName );
1115 //================================================================================
1117 * \brief Return hypothesis type name to show in dlg
1120 //================================================================================
1122 QString StdMeshersGUI_StdHypothesisCreator::type() const
1124 return tr( QString( "SMESH_%1_HYPOTHESIS" ).arg( hypTypeName( hypType() ) ).toLatin1().data() );
1127 //================================================================================
1129 * \brief String to insert in "SMESH_%1_HYPOTHESIS" to get hypothesis type name
1130 * from message resouce file
1131 * \param t - hypothesis type
1132 * \retval QString - result string
1134 //================================================================================
1136 QString StdMeshersGUI_StdHypothesisCreator::hypTypeName( const QString& t ) const
1138 static QMap<QString,QString> types;
1139 if( types.isEmpty() )
1141 types.insert( "LocalLength", "LOCAL_LENGTH" );
1142 types.insert( "NumberOfSegments", "NB_SEGMENTS" );
1143 types.insert( "MaxElementArea", "MAX_ELEMENT_AREA" );
1144 types.insert( "MaxElementVolume", "MAX_ELEMENT_VOLUME" );
1145 types.insert( "StartEndLength", "START_END_LENGTH" );
1146 types.insert( "Deflection1D", "DEFLECTION1D" );
1147 types.insert( "Arithmetic1D", "ARITHMETIC_1D" );
1148 types.insert( "FixedPoints1D", "FIXED_POINTS_1D" );
1149 types.insert( "AutomaticLength", "AUTOMATIC_LENGTH" );
1150 types.insert( "ProjectionSource1D", "PROJECTION_SOURCE_1D" );
1151 types.insert( "ProjectionSource2D", "PROJECTION_SOURCE_2D" );
1152 types.insert( "ProjectionSource3D", "PROJECTION_SOURCE_3D" );
1153 types.insert( "NumberOfLayers", "NUMBER_OF_LAYERS" );
1154 types.insert( "LayerDistribution", "LAYER_DISTRIBUTION" );
1155 types.insert( "NumberOfLayers2D", "NUMBER_OF_LAYERS_2D" );
1156 types.insert( "LayerDistribution2D", "LAYER_DISTRIBUTION" );
1157 types.insert( "SegmentLengthAroundVertex", "SEGMENT_LENGTH_AROUND_VERTEX" );
1158 types.insert( "MaxLength", "MAX_LENGTH" );
1159 types.insert( "QuadrangleParams", "QUADRANGLE_PARAMS" );
1163 if( types.contains( t ) )
1170 //=======================================================================
1171 //function : getCustomWidget
1172 //purpose : is called from buildStdFrame()
1173 //=======================================================================
1175 QWidget* StdMeshersGUI_StdHypothesisCreator::getCustomWidget( const StdParam & param,
1177 const int index) const
1180 if ( index < customWidgets()->count() ) {
1181 w = customWidgets()->at( index );
1183 w->setParent( parent );
1184 w->move( QPoint( 0, 0 ) );
1190 //================================================================================
1192 * \brief Set param value taken from a custom widget
1193 * \param param - SMESHGUI_GenericHypothesisCreator::StdParam structure
1194 * \param widget - widget presenting param
1195 * \retval bool - success flag
1197 * this method is called from getStdParamFromDlg()
1199 //================================================================================
1201 bool StdMeshersGUI_StdHypothesisCreator::getParamFromCustomWidget( StdParam & param,
1202 QWidget* widget) const
1204 if ( hypType()=="AutomaticLength" ) {
1205 SMESHGUI_SpinBox* w = dynamic_cast<SMESHGUI_SpinBox*>( widget );
1207 param.myValue = w->GetValue();
1211 if ( hypType() == "MaxLength" ) {
1215 if ( widget->inherits( "StdMeshersGUI_ObjectReferenceParamWdg" ))
1217 // show only 1st reference value
1218 if ( true /*widget == getWidgetForParam( 0 )*/) {
1219 const StdMeshersGUI_ObjectReferenceParamWdg * w =
1220 static_cast<const StdMeshersGUI_ObjectReferenceParamWdg*>( widget );
1221 param.myValue = w->GetValue();
1225 if ( widget->inherits( "StdMeshersGUI_LayerDistributionParamWdg" ))
1227 const StdMeshersGUI_LayerDistributionParamWdg * w =
1228 static_cast<const StdMeshersGUI_LayerDistributionParamWdg*>( widget );
1229 param.myValue = w->GetValue();
1232 if ( widget->inherits( "StdMeshersGUI_SubShapeSelectorWdg" ))
1234 const StdMeshersGUI_SubShapeSelectorWdg * w =
1235 static_cast<const StdMeshersGUI_SubShapeSelectorWdg*>( widget );
1236 param.myValue = w->GetValue();
1239 if ( widget->inherits( "StdMeshersGUI_QuadrangleParamWdg" ))
1241 //const StdMeshersGUI_QuadrangleParamWdg * w =
1242 // static_cast<const StdMeshersGUI_QuadrangleParamWdg*>( widget );
1243 param.myValue = "QuadType";
1246 if ( widget->inherits( "StdMeshersGUI_FixedPointsParamWdg" ))
1248 const StdMeshersGUI_FixedPointsParamWdg * w =
1249 static_cast<const StdMeshersGUI_FixedPointsParamWdg*>( widget );
1250 param.myValue = w->GetValue();
1256 //================================================================================
1258 * \brief called when operation cancelled
1260 //================================================================================
1262 void StdMeshersGUI_StdHypothesisCreator::onReject()
1264 if ( hypType().startsWith("ProjectionSource" ))
1266 // Uninstall filters of StdMeshersGUI_ObjectReferenceParamWdg
1267 deactivateObjRefParamWdg( customWidgets() );
1271 //================================================================================
1275 //================================================================================
1277 void StdMeshersGUI_StdHypothesisCreator::valueChanged( QWidget* paramWidget)
1279 if ( hypType() == "MaxLength" && paramWidget == getWidgetForParam(1) ) {
1280 getWidgetForParam(0)->setEnabled( !widget< QCheckBox >( 1 )->isChecked() );
1281 if ( !getWidgetForParam(0)->isEnabled() ) {
1282 StdMeshers::StdMeshers_MaxLength_var h =
1283 StdMeshers::StdMeshers_MaxLength::_narrow( initParamsHypothesis() );
1284 widget< QtxDoubleSpinBox >( 0 )->setValue( h->GetPreestimatedLength() );
1289 //================================================================================
1293 //================================================================================
1295 bool StdMeshersGUI_StdHypothesisCreator::initVariableName(SMESH::ListOfParameters_var theParameters,
1296 StdParam &theParams,
1299 QString aVaribaleName = (theParameters->length() > order) ? QString(theParameters[order].in()) : QString("");
1300 theParams.isVariable = !aVaribaleName.isEmpty();
1301 if(theParams.isVariable)
1302 theParams.myValue = aVaribaleName;
1304 return theParams.isVariable;