1 // Copyright (C) 2007-2010 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
23 // File : StdMeshersGUI_StdHypothesisCreator.cxx
24 // Author : Alexander SOLOVYOV, Open CASCADE S.A.S.
27 #include "StdMeshersGUI_StdHypothesisCreator.h"
30 #include <SMESHGUI_SpinBox.h>
31 #include <SMESHGUI_HypothesesUtils.h>
32 #include <SMESHGUI_Utils.h>
33 #include <SMESH_TypeFilter.hxx>
34 #include <SMESH_NumberFilter.hxx>
35 #include "StdMeshersGUI_ObjectReferenceParamWdg.h"
36 #include "StdMeshersGUI_LayerDistributionParamWdg.h"
37 #include "StdMeshersGUI_SubShapeSelectorWdg.h"
38 #include "StdMeshersGUI_FixedPointsParamWdg.h"
39 #include <SALOMEDSClient_Study.hxx>
41 // SALOME GUI includes
42 #include <SUIT_ResourceMgr.h>
45 #include <SALOMEconfig.h>
46 #include CORBA_SERVER_HEADER(SMESH_BasicHypothesis)
47 #include CORBA_SERVER_HEADER(SMESH_Mesh)
50 #include <QHBoxLayout>
55 const double VALUE_MAX = 1.0e+15, // COORD_MAX
56 VALUE_MAX_2 = VALUE_MAX * VALUE_MAX,
57 VALUE_MAX_3 = VALUE_MAX_2 * VALUE_MAX,
58 VALUE_SMALL = 1.0e-15,
59 VALUE_SMALL_2 = VALUE_SMALL * VALUE_SMALL,
60 VALUE_SMALL_3 = VALUE_SMALL_2 * VALUE_SMALL;
62 //================================================================================
65 * \param type - hypothesis type
67 //================================================================================
69 StdMeshersGUI_StdHypothesisCreator::StdMeshersGUI_StdHypothesisCreator( const QString& type )
70 : SMESHGUI_GenericHypothesisCreator( type )
74 //================================================================================
78 //================================================================================
80 StdMeshersGUI_StdHypothesisCreator::~StdMeshersGUI_StdHypothesisCreator()
84 //================================================================================
86 * \brief Return widget for i-th hypothesis parameter (got from myParamWidgets)
87 * \param i - index of hypothesis parameter
88 * \retval QWidget* - found widget
90 //================================================================================
92 QWidget* StdMeshersGUI_StdHypothesisCreator::getWidgetForParam( int i ) const
95 if ( isCreation() ) ++i; // skip widget of 'name' parameter
97 if ( i < myCustomWidgets.count() ) {
98 QList<QWidget*>::const_iterator anIt = myCustomWidgets.begin();
99 QList<QWidget*>::const_iterator aLast = myCustomWidgets.end();
100 for ( int j = 0 ; !w && anIt != aLast; ++anIt, ++j )
105 // list has no at() const, so we iterate
106 QList<QWidget*>::const_iterator anIt = widgets().begin();
107 QList<QWidget*>::const_iterator aLast = widgets().end();
108 for( int j = 0; !w && anIt!=aLast; anIt++, ++j ) {
116 //================================================================================
118 * \brief Allow modifing myCustomWidgets in const methods
119 * \retval ListOfWidgets* - non-const pointer to myCustomWidgets
121 //================================================================================
123 StdMeshersGUI_StdHypothesisCreator::ListOfWidgets*
124 StdMeshersGUI_StdHypothesisCreator::customWidgets() const
126 return const_cast< ListOfWidgets* >( & myCustomWidgets );
129 //================================================================================
131 * \brief Builds dlg layout
132 * \retval QFrame* - the built widget
134 //================================================================================
136 QFrame* StdMeshersGUI_StdHypothesisCreator::buildFrame()
138 return buildStdFrame();
141 //================================================================================
143 * \brief Initialise parameter values in controls
145 //================================================================================
147 void StdMeshersGUI_StdHypothesisCreator::retrieveParams() const
149 // buildStdFrame() sets values itself calling stdParams()
151 if ( hypType().startsWith("ProjectionSource" ))
153 // we use this method to connect depending custom widgets
154 StdMeshersGUI_ObjectReferenceParamWdg* widgetToActivate = 0;
155 ListOfWidgets::const_iterator anIt = myCustomWidgets.begin();
156 for ( ; anIt != myCustomWidgets.end(); anIt++)
158 if ( *anIt && (*anIt)->inherits("StdMeshersGUI_ObjectReferenceParamWdg"))
160 StdMeshersGUI_ObjectReferenceParamWdg * w1 =
161 ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
162 ListOfWidgets::const_iterator anIt2 = anIt;
163 for ( ++anIt2; anIt2 != myCustomWidgets.end(); anIt2++)
164 if ( *anIt2 && (*anIt2)->inherits("StdMeshersGUI_ObjectReferenceParamWdg"))
166 StdMeshersGUI_ObjectReferenceParamWdg * w2 =
167 ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt2 );
168 w1->AvoidSimultaneousSelection( w2 );
170 if ( !widgetToActivate )
171 widgetToActivate = w1;
174 if ( widgetToActivate )
175 widgetToActivate->activateSelection();
179 dlg()->setMinimumSize( dlg()->minimumSizeHint().width(), dlg()->minimumSizeHint().height() );
184 //================================================================================
186 * \brief Widget: slider with left and right labels
188 //================================================================================
190 class TDoubleSliderWith2Labels: public QWidget
193 TDoubleSliderWith2Labels( const QString& leftLabel, const QString& rightLabel,
194 const double initValue, const double bottom,
195 const double top , const double precision,
196 QWidget * parent=0 , const char * name=0 )
197 :QWidget(parent), _bottom(bottom), _precision(precision)
201 QHBoxLayout* aHBoxL = new QHBoxLayout(this);
203 if ( !leftLabel.isEmpty() ) {
204 QLabel* aLeftLabel = new QLabel( this );
205 aLeftLabel->setText( leftLabel );
206 aHBoxL->addWidget( aLeftLabel );
209 _slider = new QSlider( Qt::Horizontal, this );
210 _slider->setRange( 0, toInt( top ));
211 _slider->setValue( toInt( initValue ));
212 aHBoxL->addWidget( _slider );
214 if ( !rightLabel.isEmpty() ) {
215 QLabel* aRightLabel = new QLabel( this );
216 aRightLabel->setText( rightLabel );
217 aHBoxL->addWidget( aRightLabel );
222 double value() const { return _bottom + _slider->value() * _precision; }
223 QSlider * getSlider() const { return _slider; }
224 int toInt( double val ) const { return (int) ceil(( val - _bottom ) / _precision ); }
226 double _bottom, _precision;
230 //================================================================================
232 * \brief Retrieve GEOM_Object held by widget
234 //================================================================================
236 inline GEOM::GEOM_Object_var geomFromWdg(const QWidget* wdg)
238 const StdMeshersGUI_ObjectReferenceParamWdg * objRefWdg =
239 dynamic_cast<const StdMeshersGUI_ObjectReferenceParamWdg*>( wdg );
241 return objRefWdg->GetObject< GEOM::GEOM_Object >();
243 return GEOM::GEOM_Object::_nil();
245 //================================================================================
247 * \brief Retrieve SMESH_Mesh held by widget
249 //================================================================================
251 inline SMESH::SMESH_Mesh_var meshFromWdg(const QWidget* wdg)
253 const StdMeshersGUI_ObjectReferenceParamWdg * objRefWdg =
254 dynamic_cast<const StdMeshersGUI_ObjectReferenceParamWdg*>( wdg );
256 return objRefWdg->GetObject< SMESH::SMESH_Mesh >();
258 return SMESH::SMESH_Mesh::_nil();
260 //================================================================================
262 * \brief creates a filter for selection of shapes of given dimension
263 * \param dim - dimension
264 * \param subShapeType - required type of subshapes, number of which must be \a nbSubShapes
265 * \param nbSubShapes - number of subshapes of given type
266 * \param closed - required closeness flag of a shape
267 * \retval SUIT_SelectionFilter* - created filter
269 //================================================================================
271 SUIT_SelectionFilter* filterForShapeOfDim(const int dim,
272 TopAbs_ShapeEnum subShapeType = TopAbs_SHAPE,
273 const int nbSubShapes = 0,
276 TColStd_MapOfInteger shapeTypes;
278 case 0: shapeTypes.Add( TopAbs_VERTEX ); break;
280 if ( subShapeType == TopAbs_SHAPE ) subShapeType = TopAbs_EDGE;
281 shapeTypes.Add( TopAbs_EDGE );
282 shapeTypes.Add( TopAbs_COMPOUND ); // for a group
285 if ( subShapeType == TopAbs_SHAPE ) subShapeType = TopAbs_FACE;
286 shapeTypes.Add( TopAbs_FACE );
287 shapeTypes.Add( TopAbs_COMPOUND ); // for a group
290 shapeTypes.Add( TopAbs_SHELL );
291 shapeTypes.Add( TopAbs_SOLID );
292 shapeTypes.Add( TopAbs_COMPSOLID );
293 shapeTypes.Add( TopAbs_COMPOUND );
296 return new SMESH_NumberFilter("GEOM", subShapeType, nbSubShapes,
297 shapeTypes, GEOM::GEOM_Object::_nil(), closed);
300 //================================================================================
302 * \brief Create a widget for object selection
303 * \param object - initial object
304 * \param filter - selection filter
305 * \retval QWidget* - created widget
307 //================================================================================
309 QWidget* newObjRefParamWdg( SUIT_SelectionFilter* filter,
310 CORBA::Object_var object)
312 StdMeshersGUI_ObjectReferenceParamWdg* w =
313 new StdMeshersGUI_ObjectReferenceParamWdg( filter, 0);
314 w->SetObject( object.in() );
318 //================================================================================
320 * \brief calls deactivateSelection() for StdMeshersGUI_ObjectReferenceParamWdg
321 * \param widgetList - list of widgets
323 //================================================================================
325 void deactivateObjRefParamWdg( QList<QWidget*>* widgetList )
327 StdMeshersGUI_ObjectReferenceParamWdg* w = 0;
328 QList<QWidget*>::iterator anIt = widgetList->begin();
329 QList<QWidget*>::iterator aLast = widgetList->end();
330 for ( ; anIt != aLast; anIt++ ) {
331 if ( (*anIt) && (*anIt)->inherits( "StdMeshersGUI_ObjectReferenceParamWdg" ))
333 w = (StdMeshersGUI_ObjectReferenceParamWdg* )( *anIt );
334 w->deactivateSelection();
340 //================================================================================
342 * \brief Check parameter values before accept()
343 * \retval bool - true if OK
345 //================================================================================
347 bool StdMeshersGUI_StdHypothesisCreator::checkParams( QString& msg ) const
349 if( !SMESHGUI_GenericHypothesisCreator::checkParams( msg ) )
352 // check if object reference parameter is set, as it has no default value
354 if ( hypType().startsWith("ProjectionSource" ))
356 StdMeshersGUI_ObjectReferenceParamWdg* w =
357 widget< StdMeshersGUI_ObjectReferenceParamWdg >( 0 );
358 ok = ( w->IsObjectSelected() );
359 if ( !ok ) w->SetObject( CORBA::Object::_nil() );
360 int nbAssocVert = ( hypType() == "ProjectionSource1D" ? 1 : 2 );
361 for ( int i = 0; ok && i < nbAssocVert; i += 2)
364 StdMeshersGUI_ObjectReferenceParamWdg* w1 =
365 widget< StdMeshersGUI_ObjectReferenceParamWdg >( i+2 );
366 StdMeshersGUI_ObjectReferenceParamWdg* w2 =
367 widget< StdMeshersGUI_ObjectReferenceParamWdg >( i+3 );
368 srcV = w1->GetValue();
369 tgtV = w2->GetValue();
370 ok = (( srcV.isEmpty() && tgtV.isEmpty() ) ||
371 ( !srcV.isEmpty() && !tgtV.isEmpty() && srcV != tgtV ));
373 w1->SetObject( CORBA::Object::_nil() );
374 w2->SetObject( CORBA::Object::_nil() );
378 // Uninstall filters of StdMeshersGUI_ObjectReferenceParamWdg
380 deactivateObjRefParamWdg( customWidgets() );
382 else if ( hypType() == "LayerDistribution" || hypType() == "LayerDistribution2D" )
384 StdMeshersGUI_LayerDistributionParamWdg* w =
385 widget< StdMeshersGUI_LayerDistributionParamWdg >( 0 );
386 ok = ( w && w->IsOk() );
388 else if ( hypType() == "QuadrangleParams" )
390 StdMeshersGUI_SubShapeSelectorWdg* w =
391 widget< StdMeshersGUI_SubShapeSelectorWdg >( 0 );
392 ok = ( w->GetListSize() > 0 );
397 //================================================================================
399 * \brief Store params from GUI controls to a hypothesis
400 * \retval QString - text representation of parameters
402 //================================================================================
404 QString StdMeshersGUI_StdHypothesisCreator::storeParams() const
406 ListOfStdParams params;
407 bool res = getStdParamFromDlg( params );
410 SMESH::SetName( SMESH::FindSObject( hypothesis() ), params[0].myValue.toString().toLatin1().data() );
411 params.erase( params.begin() );
414 QString valueStr = stdParamValues( params );
415 QStringList aVariablesList = getVariablesFromDlg();
417 if( res && !params.isEmpty() )
419 if( hypType()=="LocalLength" )
421 StdMeshers::StdMeshers_LocalLength_var h =
422 StdMeshers::StdMeshers_LocalLength::_narrow( hypothesis() );
424 h->SetLength( params[0].myValue.toDouble() );
425 h->SetParameters(aVariablesList.join(":").toLatin1().constData());
426 h->SetPrecision( params[1].myValue.toDouble() );
427 h->SetParameters(aVariablesList.join(":").toLatin1().constData());
429 else if( hypType()=="MaxLength" )
431 StdMeshers::StdMeshers_MaxLength_var h =
432 StdMeshers::StdMeshers_MaxLength::_narrow( hypothesis() );
434 h->SetLength( params[0].myValue.toDouble() );
435 h->SetParameters(aVariablesList.join(":").toLatin1().constData());
436 h->SetUsePreestimatedLength( widget< QCheckBox >( 1 )->isChecked() );
437 if ( !h->HavePreestimatedLength() && !h->_is_equivalent( initParamsHypothesis() )) {
438 StdMeshers::StdMeshers_MaxLength_var hInit =
439 StdMeshers::StdMeshers_MaxLength::_narrow( initParamsHypothesis() );
440 h->SetPreestimatedLength( hInit->GetPreestimatedLength() );
443 else if( hypType()=="SegmentLengthAroundVertex" )
445 StdMeshers::StdMeshers_SegmentLengthAroundVertex_var h =
446 StdMeshers::StdMeshers_SegmentLengthAroundVertex::_narrow( hypothesis() );
448 h->SetLength( params[0].myValue.toDouble() );
449 h->SetParameters(aVariablesList.join(":").toLatin1().constData());
451 else if( hypType()=="Arithmetic1D" )
453 StdMeshers::StdMeshers_Arithmetic1D_var h =
454 StdMeshers::StdMeshers_Arithmetic1D::_narrow( hypothesis() );
456 StdMeshersGUI_SubShapeSelectorWdg* w =
457 widget< StdMeshersGUI_SubShapeSelectorWdg >( 2 );
459 h->SetStartLength( params[0].myValue.toDouble() );
460 h->SetParameters(aVariablesList.join(":").toLatin1().constData());
461 h->SetEndLength( params[1].myValue.toDouble() );
462 h->SetParameters(aVariablesList.join(":").toLatin1().constData());
464 h->SetReversedEdges( w->GetListOfIDs() );
465 h->SetObjectEntry( w->GetMainShapeEntry() );
468 else if( hypType()=="FixedPoints1D" )
470 StdMeshers::StdMeshers_FixedPoints1D_var h =
471 StdMeshers::StdMeshers_FixedPoints1D::_narrow( hypothesis() );
473 StdMeshersGUI_FixedPointsParamWdg* w1 =
474 widget< StdMeshersGUI_FixedPointsParamWdg >( 0 );
476 StdMeshersGUI_SubShapeSelectorWdg* w2 =
477 widget< StdMeshersGUI_SubShapeSelectorWdg >( 1 );
480 h->SetParameters(aVariablesList.join(":").toLatin1().constData());
481 h->SetPoints( w1->GetListOfPoints() );
482 h->SetNbSegments( w1->GetListOfSegments() );
485 h->SetReversedEdges( w2->GetListOfIDs() );
486 h->SetObjectEntry( w2->GetMainShapeEntry() );
489 else if( hypType()=="MaxElementArea" )
491 StdMeshers::StdMeshers_MaxElementArea_var h =
492 StdMeshers::StdMeshers_MaxElementArea::_narrow( hypothesis() );
493 h->SetParameters(aVariablesList.join(":").toLatin1().constData());
494 h->SetMaxElementArea( params[0].myValue.toDouble() );
496 else if( hypType()=="MaxElementVolume" )
498 StdMeshers::StdMeshers_MaxElementVolume_var h =
499 StdMeshers::StdMeshers_MaxElementVolume::_narrow( hypothesis() );
501 h->SetMaxElementVolume( params[0].myValue.toDouble() );
502 h->SetParameters(aVariablesList.join(":").toLatin1().constData());
504 else if( hypType()=="StartEndLength" )
506 StdMeshers::StdMeshers_StartEndLength_var h =
507 StdMeshers::StdMeshers_StartEndLength::_narrow( hypothesis() );
509 StdMeshersGUI_SubShapeSelectorWdg* w =
510 widget< StdMeshersGUI_SubShapeSelectorWdg >( 2 );
512 h->SetStartLength( params[0].myValue.toDouble() );
513 h->SetParameters(aVariablesList.join(":").toLatin1().constData());
514 h->SetEndLength( params[1].myValue.toDouble() );
515 h->SetParameters(aVariablesList.join(":").toLatin1().constData());
517 h->SetReversedEdges( w->GetListOfIDs() );
518 h->SetObjectEntry( w->GetMainShapeEntry() );
521 else if( hypType()=="Deflection1D" )
523 StdMeshers::StdMeshers_Deflection1D_var h =
524 StdMeshers::StdMeshers_Deflection1D::_narrow( hypothesis() );
525 h->SetParameters(aVariablesList.join(":").toLatin1().constData());
526 h->SetDeflection( params[0].myValue.toDouble() );
528 else if( hypType()=="AutomaticLength" )
530 StdMeshers::StdMeshers_AutomaticLength_var h =
531 StdMeshers::StdMeshers_AutomaticLength::_narrow( hypothesis() );
533 h->SetFineness( params[0].myValue.toDouble() );
535 else if( hypType()=="NumberOfLayers" )
537 StdMeshers::StdMeshers_NumberOfLayers_var h =
538 StdMeshers::StdMeshers_NumberOfLayers::_narrow( hypothesis() );
540 h->SetNumberOfLayers( params[0].myValue.toInt() );
541 h->SetParameters(aVariablesList.join(":").toLatin1().constData());
543 else if( hypType()=="LayerDistribution" )
545 StdMeshers::StdMeshers_LayerDistribution_var h =
546 StdMeshers::StdMeshers_LayerDistribution::_narrow( hypothesis() );
547 StdMeshersGUI_LayerDistributionParamWdg* w =
548 widget< StdMeshersGUI_LayerDistributionParamWdg >( 0 );
550 h->SetLayerDistribution( w->GetHypothesis() );
551 h->SetParameters(w->GetHypothesis()->GetParameters());
552 w->GetHypothesis()->ClearParameters();
554 else if( hypType()=="NumberOfLayers2D" )
556 StdMeshers::StdMeshers_NumberOfLayers2D_var h =
557 StdMeshers::StdMeshers_NumberOfLayers2D::_narrow( hypothesis() );
559 h->SetNumberOfLayers( params[0].myValue.toInt() );
560 h->SetParameters(aVariablesList.join(":").toLatin1().constData());
562 else if( hypType()=="LayerDistribution2D" )
564 StdMeshers::StdMeshers_LayerDistribution2D_var h =
565 StdMeshers::StdMeshers_LayerDistribution2D::_narrow( hypothesis() );
566 StdMeshersGUI_LayerDistributionParamWdg* w =
567 widget< StdMeshersGUI_LayerDistributionParamWdg >( 0 );
569 h->SetLayerDistribution( w->GetHypothesis() );
570 h->SetParameters(w->GetHypothesis()->GetParameters());
571 w->GetHypothesis()->ClearParameters();
573 else if( hypType()=="ProjectionSource1D" )
575 StdMeshers::StdMeshers_ProjectionSource1D_var h =
576 StdMeshers::StdMeshers_ProjectionSource1D::_narrow( hypothesis() );
578 h->SetSourceEdge ( geomFromWdg ( getWidgetForParam( 0 )));
579 h->SetSourceMesh ( meshFromWdg ( getWidgetForParam( 1 )));
580 h->SetVertexAssociation( geomFromWdg ( getWidgetForParam( 2 )),
581 geomFromWdg ( getWidgetForParam( 3 )));
583 else if( hypType()=="ProjectionSource2D" )
585 StdMeshers::StdMeshers_ProjectionSource2D_var h =
586 StdMeshers::StdMeshers_ProjectionSource2D::_narrow( hypothesis() );
588 h->SetSourceFace ( geomFromWdg ( getWidgetForParam( 0 )));
589 h->SetSourceMesh ( meshFromWdg ( getWidgetForParam( 1 )));
590 h->SetVertexAssociation( geomFromWdg ( getWidgetForParam( 2 )), // src1
591 geomFromWdg ( getWidgetForParam( 4 )), // src2
592 geomFromWdg ( getWidgetForParam( 3 )), // tgt1
593 geomFromWdg ( getWidgetForParam( 5 ))); // tgt2
595 else if( hypType()=="ProjectionSource3D" )
597 StdMeshers::StdMeshers_ProjectionSource3D_var h =
598 StdMeshers::StdMeshers_ProjectionSource3D::_narrow( hypothesis() );
600 h->SetSource3DShape ( geomFromWdg ( getWidgetForParam( 0 )));
601 h->SetSourceMesh ( meshFromWdg ( getWidgetForParam( 1 )));
602 h->SetVertexAssociation( geomFromWdg ( getWidgetForParam( 2 )), // src1
603 geomFromWdg ( getWidgetForParam( 4 )), // src2
604 geomFromWdg ( getWidgetForParam( 3 )), // tgt1
605 geomFromWdg ( getWidgetForParam( 5 ))); // tgt2
607 else if( hypType()=="QuadrangleParams" )
609 StdMeshers::StdMeshers_QuadrangleParams_var h =
610 StdMeshers::StdMeshers_QuadrangleParams::_narrow( hypothesis() );
611 StdMeshersGUI_SubShapeSelectorWdg* w =
612 widget< StdMeshersGUI_SubShapeSelectorWdg >( 0 );
614 if( w->GetListSize() > 0 ) {
615 h->SetTriaVertex( w->GetListOfIDs()[0] ); // getlist must be called once
616 const char * entry = w->GetMainShapeEntry();
617 h->SetObjectEntry( entry );
625 //================================================================================
627 * \brief Return parameter values as SMESHGUI_GenericHypothesisCreator::StdParam
628 * \param p - list of parameters
629 * \retval bool - success flag
631 * Is called from SMESHGUI_GenericHypothesisCreator::buildStdFrame().
632 * Parameters will be shown using "standard" controls:
633 * Int by QtxIntSpinBox
634 * Double by SMESHGUI_SpinBox
635 * String by QLineEdit
636 * getCustomWidget() allows to redefine control for a parameter
638 //================================================================================
640 bool StdMeshersGUI_StdHypothesisCreator::stdParams( ListOfStdParams& p ) const
643 SMESHGUI_GenericHypothesisCreator::StdParam item;
646 customWidgets()->clear();
649 HypothesisData* data = SMESH::GetHypothesisData( hypType() );
650 item.myName = tr( "SMESH_NAME" );
651 item.myValue = data ? hypName() : QString();
653 customWidgets()->append(0);
656 SMESH::SMESH_Hypothesis_var hyp = initParamsHypothesis();
657 SMESH::ListOfParameters_var aParameters = hyp->GetLastParameters();
659 if( hypType()=="LocalLength" )
661 StdMeshers::StdMeshers_LocalLength_var h =
662 StdMeshers::StdMeshers_LocalLength::_narrow( hyp );
664 item.myName = tr("SMESH_LOCAL_LENGTH_PARAM");
665 if(!initVariableName(aParameters,item,0))
666 item.myValue = h->GetLength();
669 item.myName = tr("SMESH_LOCAL_LENGTH_PRECISION");
670 if(!initVariableName(aParameters,item,1))
671 item.myValue = h->GetPrecision();
675 else if( hypType()=="MaxLength" )
677 StdMeshers::StdMeshers_MaxLength_var h =
678 StdMeshers::StdMeshers_MaxLength::_narrow( hyp );
679 // try to set a right preestimated length to edited hypothesis
680 bool noPreestimatedAtEdition = false;
681 if ( !isCreation() ) {
682 StdMeshers::StdMeshers_MaxLength_var initHyp =
683 StdMeshers::StdMeshers_MaxLength::_narrow( initParamsHypothesis(true) );
684 noPreestimatedAtEdition =
685 ( initHyp->_is_nil() || !initHyp->HavePreestimatedLength() );
686 if ( !noPreestimatedAtEdition )
687 h->SetPreestimatedLength( initHyp->GetPreestimatedLength() );
690 item.myName = tr("SMESH_LOCAL_LENGTH_PARAM");
691 if(!initVariableName(aParameters,item,0))
692 item.myValue = h->GetLength();
694 customWidgets()->append(0);
696 item.myName = tr("SMESH_USE_PREESTIMATED_LENGTH");
698 QCheckBox* aQCheckBox = new QCheckBox(dlg());
699 if ( !noPreestimatedAtEdition && h->HavePreestimatedLength() ) {
700 aQCheckBox->setChecked( h->GetUsePreestimatedLength() );
701 connect( aQCheckBox, SIGNAL( stateChanged(int) ), this, SLOT( onValueChanged() ) );
704 aQCheckBox->setChecked( false );
705 aQCheckBox->setEnabled( false );
707 customWidgets()->append( aQCheckBox );
709 else if( hypType()=="SegmentLengthAroundVertex" )
711 StdMeshers::StdMeshers_SegmentLengthAroundVertex_var h =
712 StdMeshers::StdMeshers_SegmentLengthAroundVertex::_narrow( hyp );
714 item.myName = tr("SMESH_LOCAL_LENGTH_PARAM");
715 if(!initVariableName(aParameters,item,0))
716 item.myValue = h->GetLength();
720 else if( hypType()=="Arithmetic1D" )
722 StdMeshers::StdMeshers_Arithmetic1D_var h =
723 StdMeshers::StdMeshers_Arithmetic1D::_narrow( hyp );
725 item.myName = tr( "SMESH_START_LENGTH_PARAM" );
726 if(!initVariableName(aParameters,item,0))
727 item.myValue = h->GetLength( true );
730 customWidgets()->append (0);
732 item.myName = tr( "SMESH_END_LENGTH_PARAM" );
733 if(!initVariableName(aParameters,item,1))
734 item.myValue = h->GetLength( false );
737 customWidgets()->append (0);
739 item.myName = tr( "SMESH_REVERSED_EDGES" );
742 StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget =
743 new StdMeshersGUI_SubShapeSelectorWdg();
744 QString aGeomEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
745 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
746 if ( aGeomEntry == "" )
747 aGeomEntry = h->GetObjectEntry();
749 aDirectionWidget->SetGeomShapeEntry( aGeomEntry );
750 aDirectionWidget->SetMainShapeEntry( aMainEntry );
751 aDirectionWidget->SetListOfIDs( h->GetReversedEdges() );
752 aDirectionWidget->showPreview( true );
753 customWidgets()->append ( aDirectionWidget );
757 else if( hypType()=="FixedPoints1D" )
759 StdMeshers::StdMeshers_FixedPoints1D_var h =
760 StdMeshers::StdMeshers_FixedPoints1D::_narrow( hyp );
762 item.myName = tr( "SMESH_FIXED_POINTS" );
765 StdMeshersGUI_FixedPointsParamWdg* aFixedPointsWidget =
766 new StdMeshersGUI_FixedPointsParamWdg();
768 if ( !isCreation() ) {
769 aFixedPointsWidget->SetListOfPoints( h->GetPoints() );
770 aFixedPointsWidget->SetListOfSegments( h->GetNbSegments() );
772 customWidgets()->append( aFixedPointsWidget );
774 item.myName = tr( "SMESH_REVERSED_EDGES" );
777 StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget =
778 new StdMeshersGUI_SubShapeSelectorWdg();
779 QString anEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
780 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
782 anEntry = h->GetObjectEntry();
783 aDirectionWidget->SetGeomShapeEntry( anEntry );
784 aDirectionWidget->SetMainShapeEntry( aMainEntry );
785 aDirectionWidget->SetListOfIDs( h->GetReversedEdges() );
786 aDirectionWidget->showPreview( true );
787 customWidgets()->append ( aDirectionWidget );
791 else if( hypType()=="MaxElementArea" )
793 StdMeshers::StdMeshers_MaxElementArea_var h =
794 StdMeshers::StdMeshers_MaxElementArea::_narrow( hyp );
796 item.myName = tr( "SMESH_MAX_ELEMENT_AREA_PARAM" );
797 if(!initVariableName(aParameters,item,0))
798 item.myValue = h->GetMaxElementArea();
802 else if( hypType()=="MaxElementVolume" )
804 StdMeshers::StdMeshers_MaxElementVolume_var h =
805 StdMeshers::StdMeshers_MaxElementVolume::_narrow( hyp );
807 item.myName = tr( "SMESH_MAX_ELEMENT_VOLUME_PARAM" );
808 if(!initVariableName(aParameters,item,0))
809 item.myValue = h->GetMaxElementVolume();
812 else if( hypType()=="StartEndLength" )
814 StdMeshers::StdMeshers_StartEndLength_var h =
815 StdMeshers::StdMeshers_StartEndLength::_narrow( hyp );
817 item.myName = tr( "SMESH_START_LENGTH_PARAM" );
819 if(!initVariableName(aParameters,item,0))
820 item.myValue = h->GetLength( true );
822 customWidgets()->append(0);
824 item.myName = tr( "SMESH_END_LENGTH_PARAM" );
825 if(!initVariableName(aParameters,item,1))
826 item.myValue = h->GetLength( false );
828 customWidgets()->append(0);
830 item.myName = tr( "SMESH_REVERSED_EDGES" );
833 StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget =
834 new StdMeshersGUI_SubShapeSelectorWdg();
835 QString anEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
836 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
838 anEntry = h->GetObjectEntry();
839 aDirectionWidget->SetGeomShapeEntry( anEntry );
840 aDirectionWidget->SetMainShapeEntry( aMainEntry );
841 aDirectionWidget->SetListOfIDs( h->GetReversedEdges() );
842 aDirectionWidget->showPreview( true );
843 customWidgets()->append ( aDirectionWidget );
845 else if( hypType()=="Deflection1D" )
847 StdMeshers::StdMeshers_Deflection1D_var h =
848 StdMeshers::StdMeshers_Deflection1D::_narrow( hyp );
850 item.myName = tr( "SMESH_DEFLECTION1D_PARAM" );
851 if(!initVariableName(aParameters,item,0))
852 item.myValue = h->GetDeflection();
855 else if( hypType()=="AutomaticLength" )
857 StdMeshers::StdMeshers_AutomaticLength_var h =
858 StdMeshers::StdMeshers_AutomaticLength::_narrow( hyp );
860 item.myName = tr( "SMESH_FINENESS_PARAM" );
861 //item.myValue = h->GetFineness();
863 SMESHGUI_SpinBox* _autoLengthSpinBox = new SMESHGUI_SpinBox(dlg());
864 _autoLengthSpinBox->RangeStepAndValidator(0, 1, 0.01, "length_precision");
865 _autoLengthSpinBox->SetValue(h->GetFineness());
866 customWidgets()->append( _autoLengthSpinBox);
868 else if( hypType()=="NumberOfLayers" )
870 StdMeshers::StdMeshers_NumberOfLayers_var h =
871 StdMeshers::StdMeshers_NumberOfLayers::_narrow( hyp );
873 item.myName = tr( "SMESH_NUMBER_OF_LAYERS" );
874 if(!initVariableName(aParameters,item,0))
875 item.myValue = (int) h->GetNumberOfLayers();
878 else if( hypType()=="LayerDistribution" ) {
879 StdMeshers::StdMeshers_LayerDistribution_var h =
880 StdMeshers::StdMeshers_LayerDistribution::_narrow( hyp );
882 item.myName = tr( "SMESH_LAYERS_DISTRIBUTION" ); p.append( item );
884 //Set into not published hypo last variables
885 QStringList aLastVarsList;
886 for(int i = 0;i<aParameters->length();i++)
887 aLastVarsList.append(QString(aParameters[i].in()));
889 if(!aLastVarsList.isEmpty())
890 h->GetLayerDistribution()->SetLastParameters(aLastVarsList.join(":").toLatin1().constData());
892 customWidgets()->append
893 ( new StdMeshersGUI_LayerDistributionParamWdg( h->GetLayerDistribution(), hypName(), dlg()));
895 else if( hypType()=="NumberOfLayers2D" ) {
896 StdMeshers::StdMeshers_NumberOfLayers2D_var h =
897 StdMeshers::StdMeshers_NumberOfLayers2D::_narrow( hyp );
899 item.myName = tr( "SMESH_NUMBER_OF_LAYERS" );
900 if(!initVariableName(aParameters,item,0))
901 item.myValue = (int) h->GetNumberOfLayers();
904 else if( hypType()=="LayerDistribution2D" ) {
905 StdMeshers::StdMeshers_LayerDistribution2D_var h =
906 StdMeshers::StdMeshers_LayerDistribution2D::_narrow( hyp );
908 item.myName = tr( "SMESH_LAYERS_DISTRIBUTION" ); p.append( item );
910 //Set into not published hypo last variables
911 QStringList aLastVarsList;
912 for(int i = 0;i<aParameters->length();i++)
913 aLastVarsList.append(QString(aParameters[i].in()));
915 if(!aLastVarsList.isEmpty())
916 h->GetLayerDistribution()->SetLastParameters(aLastVarsList.join(":").toLatin1().constData());
918 customWidgets()->append
919 ( new StdMeshersGUI_LayerDistributionParamWdg( h->GetLayerDistribution(), hypName(), dlg()));
921 else if( hypType()=="ProjectionSource1D" )
923 StdMeshers::StdMeshers_ProjectionSource1D_var h =
924 StdMeshers::StdMeshers_ProjectionSource1D::_narrow( hyp );
926 item.myName = tr( "SMESH_SOURCE_EDGE" ); p.append( item );
927 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 1 ),
928 h->GetSourceEdge()));
929 item.myName = tr( "SMESH_SOURCE_MESH" ); p.append( item );
930 customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( MESH ),
931 h->GetSourceMesh()));
932 item.myName = tr( "SMESH_SOURCE_VERTEX" ); p.append( item );
933 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
934 h->GetSourceVertex()));
935 item.myName = tr( "SMESH_TARGET_VERTEX" ); p.append( item );
936 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
937 h->GetTargetVertex()));
939 else if( hypType()=="ProjectionSource2D" )
941 StdMeshers::StdMeshers_ProjectionSource2D_var h =
942 StdMeshers::StdMeshers_ProjectionSource2D::_narrow( hyp );
944 item.myName = tr( "SMESH_SOURCE_FACE" ); p.append( item );
945 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 2 ),
946 h->GetSourceFace()));
947 item.myName = tr( "SMESH_SOURCE_MESH" ); p.append( item );
948 customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( MESH ),
949 h->GetSourceMesh()));
950 item.myName = tr( "SMESH_SOURCE_VERTEX1" ); p.append( item );
951 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
952 h->GetSourceVertex( 1 )));
953 item.myName = tr( "SMESH_TARGET_VERTEX1" ); p.append( item );
954 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
955 h->GetTargetVertex( 1 )));
956 item.myName = tr( "SMESH_SOURCE_VERTEX2" ); p.append( item );
957 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
958 h->GetSourceVertex( 2 )));
959 item.myName = tr( "SMESH_TARGET_VERTEX2" ); p.append( item );
960 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
961 h->GetTargetVertex( 2 )));
963 else if( hypType()=="ProjectionSource3D" )
965 StdMeshers::StdMeshers_ProjectionSource3D_var h =
966 StdMeshers::StdMeshers_ProjectionSource3D::_narrow( hyp );
968 item.myName = tr( "SMESH_SOURCE_3DSHAPE" ); p.append( item );
969 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 3, TopAbs_FACE, 6, true ),
970 h->GetSource3DShape()));
971 item.myName = tr( "SMESH_SOURCE_MESH" ); p.append( item );
972 customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( MESH ),
973 h->GetSourceMesh()));
974 item.myName = tr( "SMESH_SOURCE_VERTEX1" ); p.append( item );
975 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
976 h->GetSourceVertex( 1 )));
977 item.myName = tr( "SMESH_TARGET_VERTEX1" ); p.append( item );
978 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
979 h->GetTargetVertex( 1 )));
980 item.myName = tr( "SMESH_SOURCE_VERTEX2" ); p.append( item );
981 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
982 h->GetSourceVertex( 2 )));
983 item.myName = tr( "SMESH_TARGET_VERTEX2" ); p.append( item );
984 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
985 h->GetTargetVertex( 2 )));
987 else if( hypType()=="QuadrangleParams" )
989 StdMeshers::StdMeshers_QuadrangleParams_var h =
990 StdMeshers::StdMeshers_QuadrangleParams::_narrow( hyp );
992 item.myName = tr( "SMESH_BASE_VERTEX" );
995 StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget =
996 new StdMeshersGUI_SubShapeSelectorWdg();
997 aDirectionWidget->SetMaxSize(1);
998 aDirectionWidget->SetSubShType(TopAbs_VERTEX);
999 QString anEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
1000 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
1001 if ( anEntry == "" )
1002 anEntry = h->GetObjectEntry();
1003 aDirectionWidget->SetGeomShapeEntry( anEntry );
1004 aDirectionWidget->SetMainShapeEntry( aMainEntry );
1005 if ( !isCreation() ) {
1006 SMESH::long_array_var aVec = new SMESH::long_array;
1007 int vertID = h->GetTriaVertex();
1011 aDirectionWidget->SetListOfIDs( aVec );
1014 aDirectionWidget->showPreview( true );
1015 customWidgets()->append ( aDirectionWidget );
1022 //================================================================================
1024 * \brief tune "standard" control
1025 * \param w - control widget
1026 * \param int - parameter index
1028 //================================================================================
1030 void StdMeshersGUI_StdHypothesisCreator::attuneStdWidget (QWidget* w, const int) const
1032 SMESHGUI_SpinBox* sb = w->inherits( "SMESHGUI_SpinBox" ) ? ( SMESHGUI_SpinBox* )w : 0;
1033 if( hypType()=="LocalLength" && sb )
1035 if (sb->objectName() == tr("SMESH_LOCAL_LENGTH_PARAM"))
1036 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1037 else if (sb->objectName() == tr("SMESH_LOCAL_LENGTH_PRECISION"))
1038 sb->RangeStepAndValidator( 0.0, 1.0, 0.05, "len_tol_precision" );
1040 else if( hypType()=="Arithmetic1D" && sb )
1042 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "parametric_precision" );
1044 else if( hypType()=="MaxLength" && sb )
1046 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1047 sb->setEnabled( !widget< QCheckBox >( 1 )->isChecked() );
1049 else if( hypType()=="MaxElementArea" && sb )
1051 sb->RangeStepAndValidator( VALUE_SMALL_2, VALUE_MAX_2, 1.0, "area_precision" );
1053 else if( hypType()=="MaxElementVolume" && sb )
1055 sb->RangeStepAndValidator( VALUE_SMALL_3, VALUE_MAX_3, 1.0, "vol_precision" );
1057 else if( hypType()=="StartEndLength" && sb )
1059 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1061 else if( hypType()=="Deflection1D" && sb )
1063 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "parametric_precision" );
1065 else if ( sb ) // default validator for possible ancestors
1067 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1071 //================================================================================
1073 * \brief Return dlg title
1074 * \retval QString - title string
1076 //================================================================================
1078 QString StdMeshersGUI_StdHypothesisCreator::caption() const
1080 return tr( QString( "SMESH_%1_TITLE" ).arg( hypTypeName( hypType() ) ).toLatin1().data() );
1083 //================================================================================
1085 * \brief return pixmap for dlg icon
1088 //================================================================================
1090 QPixmap StdMeshersGUI_StdHypothesisCreator::icon() const
1092 QString hypIconName = tr( QString( "ICON_DLG_%1" ).arg( hypTypeName( hypType() ) ).toLatin1().data() );
1093 return SMESHGUI::resourceMgr()->loadPixmap( "SMESH", hypIconName );
1096 //================================================================================
1098 * \brief Return hypothesis type name to show in dlg
1101 //================================================================================
1103 QString StdMeshersGUI_StdHypothesisCreator::type() const
1105 return tr( QString( "SMESH_%1_HYPOTHESIS" ).arg( hypTypeName( hypType() ) ).toLatin1().data() );
1108 //================================================================================
1110 * \brief String to insert in "SMESH_%1_HYPOTHESIS" to get hypothesis type name
1111 * from message resouce file
1112 * \param t - hypothesis type
1113 * \retval QString - result string
1115 //================================================================================
1117 QString StdMeshersGUI_StdHypothesisCreator::hypTypeName( const QString& t ) const
1119 static QMap<QString,QString> types;
1120 if( types.isEmpty() )
1122 types.insert( "LocalLength", "LOCAL_LENGTH" );
1123 types.insert( "NumberOfSegments", "NB_SEGMENTS" );
1124 types.insert( "MaxElementArea", "MAX_ELEMENT_AREA" );
1125 types.insert( "MaxElementVolume", "MAX_ELEMENT_VOLUME" );
1126 types.insert( "StartEndLength", "START_END_LENGTH" );
1127 types.insert( "Deflection1D", "DEFLECTION1D" );
1128 types.insert( "Arithmetic1D", "ARITHMETIC_1D" );
1129 types.insert( "FixedPoints1D", "FIXED_POINTS_1D" );
1130 types.insert( "AutomaticLength", "AUTOMATIC_LENGTH" );
1131 types.insert( "ProjectionSource1D", "PROJECTION_SOURCE_1D" );
1132 types.insert( "ProjectionSource2D", "PROJECTION_SOURCE_2D" );
1133 types.insert( "ProjectionSource3D", "PROJECTION_SOURCE_3D" );
1134 types.insert( "NumberOfLayers", "NUMBER_OF_LAYERS" );
1135 types.insert( "LayerDistribution", "LAYER_DISTRIBUTION" );
1136 types.insert( "NumberOfLayers2D", "NUMBER_OF_LAYERS_2D" );
1137 types.insert( "LayerDistribution2D", "LAYER_DISTRIBUTION" );
1138 types.insert( "SegmentLengthAroundVertex", "SEGMENT_LENGTH_AROUND_VERTEX" );
1139 types.insert( "MaxLength", "MAX_LENGTH" );
1140 types.insert( "QuadrangleParams", "QUADRANGLE_PARAMS" );
1144 if( types.contains( t ) )
1151 //=======================================================================
1152 //function : getCustomWidget
1153 //purpose : is called from buildStdFrame()
1154 //=======================================================================
1156 QWidget* StdMeshersGUI_StdHypothesisCreator::getCustomWidget( const StdParam & param,
1158 const int index) const
1161 if ( index < customWidgets()->count() ) {
1162 w = customWidgets()->at( index );
1164 w->setParent( parent );
1165 w->move( QPoint( 0, 0 ) );
1171 //================================================================================
1173 * \brief Set param value taken from a custom widget
1174 * \param param - SMESHGUI_GenericHypothesisCreator::StdParam structure
1175 * \param widget - widget presenting param
1176 * \retval bool - success flag
1178 * this method is called from getStdParamFromDlg()
1180 //================================================================================
1182 bool StdMeshersGUI_StdHypothesisCreator::getParamFromCustomWidget( StdParam & param,
1183 QWidget* widget) const
1185 if ( hypType()=="AutomaticLength" ) {
1186 SMESHGUI_SpinBox* w = dynamic_cast<SMESHGUI_SpinBox*>( widget );
1188 param.myValue = w->GetValue();
1192 if ( hypType() == "MaxLength" ) {
1196 if ( widget->inherits( "StdMeshersGUI_ObjectReferenceParamWdg" ))
1198 // show only 1st reference value
1199 if ( true /*widget == getWidgetForParam( 0 )*/) {
1200 const StdMeshersGUI_ObjectReferenceParamWdg * w =
1201 static_cast<const StdMeshersGUI_ObjectReferenceParamWdg*>( widget );
1202 param.myValue = w->GetValue();
1206 if ( widget->inherits( "StdMeshersGUI_LayerDistributionParamWdg" ))
1208 const StdMeshersGUI_LayerDistributionParamWdg * w =
1209 static_cast<const StdMeshersGUI_LayerDistributionParamWdg*>( widget );
1210 param.myValue = w->GetValue();
1213 if ( widget->inherits( "StdMeshersGUI_SubShapeSelectorWdg" ))
1215 const StdMeshersGUI_SubShapeSelectorWdg * w =
1216 static_cast<const StdMeshersGUI_SubShapeSelectorWdg*>( widget );
1217 param.myValue = w->GetValue();
1220 if ( widget->inherits( "StdMeshersGUI_FixedPointsParamWdg" ))
1222 const StdMeshersGUI_FixedPointsParamWdg * w =
1223 static_cast<const StdMeshersGUI_FixedPointsParamWdg*>( widget );
1224 param.myValue = w->GetValue();
1230 //================================================================================
1232 * \brief called when operation cancelled
1234 //================================================================================
1236 void StdMeshersGUI_StdHypothesisCreator::onReject()
1238 if ( hypType().startsWith("ProjectionSource" ))
1240 // Uninstall filters of StdMeshersGUI_ObjectReferenceParamWdg
1241 deactivateObjRefParamWdg( customWidgets() );
1245 //================================================================================
1249 //================================================================================
1251 void StdMeshersGUI_StdHypothesisCreator::valueChanged( QWidget* paramWidget)
1253 if ( hypType() == "MaxLength" && paramWidget == getWidgetForParam(1) ) {
1254 getWidgetForParam(0)->setEnabled( !widget< QCheckBox >( 1 )->isChecked() );
1255 if ( !getWidgetForParam(0)->isEnabled() ) {
1256 StdMeshers::StdMeshers_MaxLength_var h =
1257 StdMeshers::StdMeshers_MaxLength::_narrow( initParamsHypothesis() );
1258 widget< QtxDoubleSpinBox >( 0 )->setValue( h->GetPreestimatedLength() );
1263 //================================================================================
1267 //================================================================================
1269 bool StdMeshersGUI_StdHypothesisCreator::initVariableName(SMESH::ListOfParameters_var theParameters,
1270 StdParam &theParams,
1273 QString aVaribaleName = (theParameters->length() > order) ? QString(theParameters[order].in()) : QString("");
1274 theParams.isVariable = !aVaribaleName.isEmpty();
1275 if(theParams.isVariable)
1276 theParams.myValue = aVaribaleName;
1278 return theParams.isVariable;