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
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)
51 #include CORBA_SERVER_HEADER(SMESH_Group)
54 #include <QHBoxLayout>
59 const double VALUE_MAX = 1.0e+15, // COORD_MAX
60 VALUE_MAX_2 = VALUE_MAX * VALUE_MAX,
61 VALUE_MAX_3 = VALUE_MAX_2 * VALUE_MAX,
62 VALUE_SMALL = 1.0e-15,
63 VALUE_SMALL_2 = VALUE_SMALL * VALUE_SMALL,
64 VALUE_SMALL_3 = VALUE_SMALL_2 * VALUE_SMALL;
66 //================================================================================
69 * \param type - hypothesis type
71 //================================================================================
73 StdMeshersGUI_StdHypothesisCreator::StdMeshersGUI_StdHypothesisCreator( const QString& type )
74 : SMESHGUI_GenericHypothesisCreator( type )
78 //================================================================================
82 //================================================================================
84 StdMeshersGUI_StdHypothesisCreator::~StdMeshersGUI_StdHypothesisCreator()
88 //================================================================================
90 * \brief Return widget for i-th hypothesis parameter (got from myParamWidgets)
91 * \param i - index of hypothesis parameter
92 * \retval QWidget* - found widget
94 //================================================================================
96 QWidget* StdMeshersGUI_StdHypothesisCreator::getWidgetForParam( int i ) const
99 if ( isCreation() ) ++i; // skip widget of 'name' parameter
101 if ( i < myCustomWidgets.count() ) {
102 QList<QWidget*>::const_iterator anIt = myCustomWidgets.begin();
103 QList<QWidget*>::const_iterator aLast = myCustomWidgets.end();
104 for ( int j = 0 ; !w && anIt != aLast; ++anIt, ++j )
109 // list has no at() const, so we iterate
110 QList<QWidget*>::const_iterator anIt = widgets().begin();
111 QList<QWidget*>::const_iterator aLast = widgets().end();
112 for( int j = 0; !w && anIt!=aLast; anIt++, ++j ) {
120 //================================================================================
122 * \brief Allow modifing myCustomWidgets in const methods
123 * \retval ListOfWidgets* - non-const pointer to myCustomWidgets
125 //================================================================================
127 StdMeshersGUI_StdHypothesisCreator::ListOfWidgets*
128 StdMeshersGUI_StdHypothesisCreator::customWidgets() const
130 return const_cast< ListOfWidgets* >( & myCustomWidgets );
133 //================================================================================
135 * \brief Builds dlg layout
136 * \retval QFrame* - the built widget
138 //================================================================================
140 QFrame* StdMeshersGUI_StdHypothesisCreator::buildFrame()
142 return buildStdFrame();
145 //================================================================================
147 * \brief Initialise parameter values in controls
149 //================================================================================
151 void StdMeshersGUI_StdHypothesisCreator::retrieveParams() const
153 // buildStdFrame() sets values itself calling stdParams()
155 if ( hypType().startsWith("ProjectionSource" ))
157 // we use this method to connect depending custom widgets
158 StdMeshersGUI_ObjectReferenceParamWdg* widgetToActivate = 0;
159 ListOfWidgets::const_iterator anIt = myCustomWidgets.begin();
160 for ( ; anIt != myCustomWidgets.end(); anIt++)
162 if ( *anIt && (*anIt)->inherits("StdMeshersGUI_ObjectReferenceParamWdg"))
164 StdMeshersGUI_ObjectReferenceParamWdg * w1 =
165 ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
166 ListOfWidgets::const_iterator anIt2 = anIt;
167 for ( ++anIt2; anIt2 != myCustomWidgets.end(); anIt2++)
168 if ( *anIt2 && (*anIt2)->inherits("StdMeshersGUI_ObjectReferenceParamWdg"))
170 StdMeshersGUI_ObjectReferenceParamWdg * w2 =
171 ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt2 );
172 w1->AvoidSimultaneousSelection( w2 );
174 if ( !widgetToActivate )
175 widgetToActivate = w1;
178 if ( widgetToActivate )
179 widgetToActivate->activateSelection();
183 dlg()->setMinimumSize( dlg()->minimumSizeHint().width(), dlg()->minimumSizeHint().height() );
188 //================================================================================
190 * \brief Widget: slider with left and right labels
192 //================================================================================
194 class TDoubleSliderWith2Labels: public QWidget
197 TDoubleSliderWith2Labels( const QString& leftLabel, const QString& rightLabel,
198 const double initValue, const double bottom,
199 const double top , const double precision,
200 QWidget * parent=0 , const char * name=0 )
201 :QWidget(parent), _bottom(bottom), _precision(precision)
205 QHBoxLayout* aHBoxL = new QHBoxLayout(this);
207 if ( !leftLabel.isEmpty() ) {
208 QLabel* aLeftLabel = new QLabel( this );
209 aLeftLabel->setText( leftLabel );
210 aHBoxL->addWidget( aLeftLabel );
213 _slider = new QSlider( Qt::Horizontal, this );
214 _slider->setRange( 0, toInt( top ));
215 _slider->setValue( toInt( initValue ));
216 aHBoxL->addWidget( _slider );
218 if ( !rightLabel.isEmpty() ) {
219 QLabel* aRightLabel = new QLabel( this );
220 aRightLabel->setText( rightLabel );
221 aHBoxL->addWidget( aRightLabel );
226 double value() const { return _bottom + _slider->value() * _precision; }
227 QSlider * getSlider() const { return _slider; }
228 int toInt( double val ) const { return (int) ceil(( val - _bottom ) / _precision ); }
230 double _bottom, _precision;
234 //================================================================================
236 * \brief Retrieve GEOM_Object held by widget
238 //================================================================================
240 inline GEOM::GEOM_Object_var geomFromWdg(const QWidget* wdg)
242 const StdMeshersGUI_ObjectReferenceParamWdg * objRefWdg =
243 dynamic_cast<const StdMeshersGUI_ObjectReferenceParamWdg*>( wdg );
245 return objRefWdg->GetObject< GEOM::GEOM_Object >();
247 return GEOM::GEOM_Object::_nil();
249 //================================================================================
251 * \brief Retrieve SMESH_Mesh held by widget
253 //================================================================================
255 inline SMESH::SMESH_Mesh_var meshFromWdg(const QWidget* wdg)
257 const StdMeshersGUI_ObjectReferenceParamWdg * objRefWdg =
258 dynamic_cast<const StdMeshersGUI_ObjectReferenceParamWdg*>( wdg );
260 return objRefWdg->GetObject< SMESH::SMESH_Mesh >();
262 return SMESH::SMESH_Mesh::_nil();
264 //================================================================================
266 * \brief Retrieve SMESH_Mesh held by widget
268 //================================================================================
270 inline SMESH::ListOfGroups_var groupsFromWdg(const QWidget* wdg)
272 SMESH::ListOfGroups_var groups = new SMESH::ListOfGroups;
273 const StdMeshersGUI_ObjectReferenceParamWdg * objRefWdg =
274 dynamic_cast<const StdMeshersGUI_ObjectReferenceParamWdg*>( wdg );
277 groups->length( objRefWdg->NbObjects() );
278 for ( unsigned i = 0; i < groups->length(); ++i )
279 groups[i] = objRefWdg->GetObject< SMESH::SMESH_GroupBase >(i);
283 //================================================================================
285 * \brief creates a filter for selection of shapes of given dimension
286 * \param dim - dimension
287 * \param subShapeType - required type of subshapes, number of which must be \a nbSubShapes
288 * \param nbSubShapes - number of subshapes of given type
289 * \param closed - required closeness flag of a shape
290 * \retval SUIT_SelectionFilter* - created filter
292 //================================================================================
294 SUIT_SelectionFilter* filterForShapeOfDim(const int dim,
295 TopAbs_ShapeEnum subShapeType = TopAbs_SHAPE,
296 const int nbSubShapes = 0,
299 TColStd_MapOfInteger shapeTypes;
301 case 0: shapeTypes.Add( TopAbs_VERTEX ); break;
303 if ( subShapeType == TopAbs_SHAPE ) subShapeType = TopAbs_EDGE;
304 shapeTypes.Add( TopAbs_EDGE );
305 shapeTypes.Add( TopAbs_COMPOUND ); // for a group
308 if ( subShapeType == TopAbs_SHAPE ) subShapeType = TopAbs_FACE;
309 shapeTypes.Add( TopAbs_FACE );
310 shapeTypes.Add( TopAbs_COMPOUND ); // for a group
313 shapeTypes.Add( TopAbs_SHELL );
314 shapeTypes.Add( TopAbs_SOLID );
315 shapeTypes.Add( TopAbs_COMPSOLID );
316 shapeTypes.Add( TopAbs_COMPOUND );
319 return new SMESH_NumberFilter("GEOM", subShapeType, nbSubShapes,
320 shapeTypes, GEOM::GEOM_Object::_nil(), closed);
323 //================================================================================
325 * \brief Create a widget for object selection
326 * \param object - initial object
327 * \param filter - selection filter
328 * \retval QWidget* - created widget
330 //================================================================================
332 QWidget* newObjRefParamWdg( SUIT_SelectionFilter* filter,
333 CORBA::Object_var object)
335 StdMeshersGUI_ObjectReferenceParamWdg* w =
336 new StdMeshersGUI_ObjectReferenceParamWdg( filter, 0);
337 w->SetObject( object.in() );
340 QWidget* newObjRefParamWdg( SUIT_SelectionFilter* filter,
341 SMESH::string_array_var& objEntries)
343 StdMeshersGUI_ObjectReferenceParamWdg* w =
344 new StdMeshersGUI_ObjectReferenceParamWdg( filter, 0, /*multiSel=*/true);
345 w->SetObjects( objEntries );
346 w->activateSelection();
350 //================================================================================
352 * \brief calls deactivateSelection() for StdMeshersGUI_ObjectReferenceParamWdg
353 * \param widgetList - list of widgets
355 //================================================================================
357 void deactivateObjRefParamWdg( QList<QWidget*>* widgetList )
359 StdMeshersGUI_ObjectReferenceParamWdg* w = 0;
360 QList<QWidget*>::iterator anIt = widgetList->begin();
361 QList<QWidget*>::iterator aLast = widgetList->end();
362 for ( ; anIt != aLast; anIt++ ) {
363 if ( (*anIt) && (*anIt)->inherits( "StdMeshersGUI_ObjectReferenceParamWdg" ))
365 w = (StdMeshersGUI_ObjectReferenceParamWdg* )( *anIt );
366 w->deactivateSelection();
372 //================================================================================
374 * \brief Check parameter values before accept()
375 * \retval bool - true if OK
377 //================================================================================
379 bool StdMeshersGUI_StdHypothesisCreator::checkParams( QString& msg ) const
381 if( !SMESHGUI_GenericHypothesisCreator::checkParams( msg ) )
384 // check if object reference parameter is set, as it has no default value
386 if ( hypType().startsWith("ProjectionSource" ))
388 StdMeshersGUI_ObjectReferenceParamWdg* w =
389 widget< StdMeshersGUI_ObjectReferenceParamWdg >( 0 );
390 ok = ( w->IsObjectSelected() );
391 if ( !ok ) w->SetObject( CORBA::Object::_nil() );
392 int nbAssocVert = ( hypType() == "ProjectionSource1D" ? 1 : 2 );
393 for ( int i = 0; ok && i < nbAssocVert; i += 2)
396 StdMeshersGUI_ObjectReferenceParamWdg* w1 =
397 widget< StdMeshersGUI_ObjectReferenceParamWdg >( i+2 );
398 StdMeshersGUI_ObjectReferenceParamWdg* w2 =
399 widget< StdMeshersGUI_ObjectReferenceParamWdg >( i+3 );
400 srcV = w1->GetValue();
401 tgtV = w2->GetValue();
402 ok = (( srcV.isEmpty() && tgtV.isEmpty() ) ||
403 ( !srcV.isEmpty() && !tgtV.isEmpty() && srcV != tgtV ));
405 w1->SetObject( CORBA::Object::_nil() );
406 w2->SetObject( CORBA::Object::_nil() );
410 // Uninstall filters of StdMeshersGUI_ObjectReferenceParamWdg
412 deactivateObjRefParamWdg( customWidgets() );
414 else if ( hypType().startsWith("ImportSource" ))
416 StdMeshersGUI_ObjectReferenceParamWdg* w =
417 widget< StdMeshersGUI_ObjectReferenceParamWdg >( 0 );
418 ok = ( w->IsObjectSelected() );
420 else if ( hypType() == "LayerDistribution" || hypType() == "LayerDistribution2D" )
422 StdMeshersGUI_LayerDistributionParamWdg* w =
423 widget< StdMeshersGUI_LayerDistributionParamWdg >( 0 );
424 ok = ( w && w->IsOk() );
426 else if ( hypType() == "QuadrangleParams" )
428 //StdMeshersGUI_SubShapeSelectorWdg* w =
429 // widget< StdMeshersGUI_SubShapeSelectorWdg >( 0 );
430 //ok = ( w->GetListSize() > 0 );
431 //StdMeshersGUI_QuadrangleParamWdg* w =
432 // widget< StdMeshersGUI_QuadrangleParamWdg >( 1 );
437 //================================================================================
439 * \brief Store params from GUI controls to a hypothesis
440 * \retval QString - text representation of parameters
442 //================================================================================
444 QString StdMeshersGUI_StdHypothesisCreator::storeParams() const
446 ListOfStdParams params;
447 bool res = getStdParamFromDlg( params );
450 SMESH::SetName( SMESH::FindSObject( hypothesis() ), params[0].myValue.toString().toLatin1().data() );
451 params.erase( params.begin() );
454 QString valueStr = stdParamValues( params );
455 QStringList aVariablesList = getVariablesFromDlg();
457 if( res && !params.isEmpty() )
459 if( hypType()=="LocalLength" )
461 StdMeshers::StdMeshers_LocalLength_var h =
462 StdMeshers::StdMeshers_LocalLength::_narrow( hypothesis() );
464 h->SetLength( params[0].myValue.toDouble() );
465 h->SetParameters(aVariablesList.join(":").toLatin1().constData());
466 h->SetPrecision( params[1].myValue.toDouble() );
467 h->SetParameters(aVariablesList.join(":").toLatin1().constData());
469 else if( hypType()=="MaxLength" )
471 StdMeshers::StdMeshers_MaxLength_var h =
472 StdMeshers::StdMeshers_MaxLength::_narrow( hypothesis() );
474 h->SetLength( params[0].myValue.toDouble() );
475 h->SetParameters(aVariablesList.join(":").toLatin1().constData());
476 h->SetUsePreestimatedLength( widget< QCheckBox >( 1 )->isChecked() );
477 if ( !h->HavePreestimatedLength() && !h->_is_equivalent( initParamsHypothesis() )) {
478 StdMeshers::StdMeshers_MaxLength_var hInit =
479 StdMeshers::StdMeshers_MaxLength::_narrow( initParamsHypothesis() );
480 h->SetPreestimatedLength( hInit->GetPreestimatedLength() );
483 else if( hypType()=="SegmentLengthAroundVertex" )
485 StdMeshers::StdMeshers_SegmentLengthAroundVertex_var h =
486 StdMeshers::StdMeshers_SegmentLengthAroundVertex::_narrow( hypothesis() );
488 h->SetLength( params[0].myValue.toDouble() );
489 h->SetParameters(aVariablesList.join(":").toLatin1().constData());
491 else if( hypType()=="Arithmetic1D" )
493 StdMeshers::StdMeshers_Arithmetic1D_var h =
494 StdMeshers::StdMeshers_Arithmetic1D::_narrow( hypothesis() );
496 StdMeshersGUI_SubShapeSelectorWdg* w =
497 widget< StdMeshersGUI_SubShapeSelectorWdg >( 2 );
499 h->SetStartLength( params[0].myValue.toDouble() );
500 h->SetParameters(aVariablesList.join(":").toLatin1().constData());
501 h->SetEndLength( params[1].myValue.toDouble() );
502 h->SetParameters(aVariablesList.join(":").toLatin1().constData());
504 h->SetReversedEdges( w->GetListOfIDs() );
505 h->SetObjectEntry( w->GetMainShapeEntry() );
508 else if( hypType()=="FixedPoints1D" )
510 StdMeshers::StdMeshers_FixedPoints1D_var h =
511 StdMeshers::StdMeshers_FixedPoints1D::_narrow( hypothesis() );
513 StdMeshersGUI_FixedPointsParamWdg* w1 =
514 widget< StdMeshersGUI_FixedPointsParamWdg >( 0 );
516 StdMeshersGUI_SubShapeSelectorWdg* w2 =
517 widget< StdMeshersGUI_SubShapeSelectorWdg >( 1 );
520 h->SetParameters(aVariablesList.join(":").toLatin1().constData());
521 h->SetPoints( w1->GetListOfPoints() );
522 h->SetNbSegments( w1->GetListOfSegments() );
525 h->SetReversedEdges( w2->GetListOfIDs() );
526 h->SetObjectEntry( w2->GetMainShapeEntry() );
529 else if( hypType()=="MaxElementArea" )
531 StdMeshers::StdMeshers_MaxElementArea_var h =
532 StdMeshers::StdMeshers_MaxElementArea::_narrow( hypothesis() );
533 h->SetParameters(aVariablesList.join(":").toLatin1().constData());
534 h->SetMaxElementArea( params[0].myValue.toDouble() );
536 else if( hypType()=="MaxElementVolume" )
538 StdMeshers::StdMeshers_MaxElementVolume_var h =
539 StdMeshers::StdMeshers_MaxElementVolume::_narrow( hypothesis() );
541 h->SetMaxElementVolume( params[0].myValue.toDouble() );
542 h->SetParameters(aVariablesList.join(":").toLatin1().constData());
544 else if( hypType()=="StartEndLength" )
546 StdMeshers::StdMeshers_StartEndLength_var h =
547 StdMeshers::StdMeshers_StartEndLength::_narrow( hypothesis() );
549 StdMeshersGUI_SubShapeSelectorWdg* w =
550 widget< StdMeshersGUI_SubShapeSelectorWdg >( 2 );
552 h->SetStartLength( params[0].myValue.toDouble() );
553 h->SetParameters(aVariablesList.join(":").toLatin1().constData());
554 h->SetEndLength( params[1].myValue.toDouble() );
555 h->SetParameters(aVariablesList.join(":").toLatin1().constData());
557 h->SetReversedEdges( w->GetListOfIDs() );
558 h->SetObjectEntry( w->GetMainShapeEntry() );
561 else if( hypType()=="Deflection1D" )
563 StdMeshers::StdMeshers_Deflection1D_var h =
564 StdMeshers::StdMeshers_Deflection1D::_narrow( hypothesis() );
565 h->SetParameters(aVariablesList.join(":").toLatin1().constData());
566 h->SetDeflection( params[0].myValue.toDouble() );
568 else if( hypType()=="AutomaticLength" )
570 StdMeshers::StdMeshers_AutomaticLength_var h =
571 StdMeshers::StdMeshers_AutomaticLength::_narrow( hypothesis() );
573 h->SetFineness( params[0].myValue.toDouble() );
575 else if( hypType()=="NumberOfLayers" )
577 StdMeshers::StdMeshers_NumberOfLayers_var h =
578 StdMeshers::StdMeshers_NumberOfLayers::_narrow( hypothesis() );
580 h->SetNumberOfLayers( params[0].myValue.toInt() );
581 h->SetParameters(aVariablesList.join(":").toLatin1().constData());
583 else if( hypType()=="LayerDistribution" )
585 StdMeshers::StdMeshers_LayerDistribution_var h =
586 StdMeshers::StdMeshers_LayerDistribution::_narrow( hypothesis() );
587 StdMeshersGUI_LayerDistributionParamWdg* w =
588 widget< StdMeshersGUI_LayerDistributionParamWdg >( 0 );
590 h->SetLayerDistribution( w->GetHypothesis() );
591 h->SetParameters(w->GetHypothesis()->GetParameters());
592 w->GetHypothesis()->ClearParameters();
594 else if( hypType()=="NumberOfLayers2D" )
596 StdMeshers::StdMeshers_NumberOfLayers2D_var h =
597 StdMeshers::StdMeshers_NumberOfLayers2D::_narrow( hypothesis() );
599 h->SetNumberOfLayers( params[0].myValue.toInt() );
600 h->SetParameters(aVariablesList.join(":").toLatin1().constData());
602 else if( hypType()=="LayerDistribution2D" )
604 StdMeshers::StdMeshers_LayerDistribution2D_var h =
605 StdMeshers::StdMeshers_LayerDistribution2D::_narrow( hypothesis() );
606 StdMeshersGUI_LayerDistributionParamWdg* w =
607 widget< StdMeshersGUI_LayerDistributionParamWdg >( 0 );
609 h->SetLayerDistribution( w->GetHypothesis() );
610 h->SetParameters(w->GetHypothesis()->GetParameters());
611 w->GetHypothesis()->ClearParameters();
613 else if( hypType()=="ProjectionSource1D" )
615 StdMeshers::StdMeshers_ProjectionSource1D_var h =
616 StdMeshers::StdMeshers_ProjectionSource1D::_narrow( hypothesis() );
618 h->SetSourceEdge ( geomFromWdg ( getWidgetForParam( 0 )));
619 h->SetSourceMesh ( meshFromWdg ( getWidgetForParam( 1 )));
620 h->SetVertexAssociation( geomFromWdg ( getWidgetForParam( 2 )),
621 geomFromWdg ( getWidgetForParam( 3 )));
623 else if( hypType()=="ProjectionSource2D" )
625 StdMeshers::StdMeshers_ProjectionSource2D_var h =
626 StdMeshers::StdMeshers_ProjectionSource2D::_narrow( hypothesis() );
628 h->SetSourceFace ( geomFromWdg ( getWidgetForParam( 0 )));
629 h->SetSourceMesh ( meshFromWdg ( getWidgetForParam( 1 )));
630 h->SetVertexAssociation( geomFromWdg ( getWidgetForParam( 2 )), // src1
631 geomFromWdg ( getWidgetForParam( 4 )), // src2
632 geomFromWdg ( getWidgetForParam( 3 )), // tgt1
633 geomFromWdg ( getWidgetForParam( 5 ))); // tgt2
635 else if( hypType()=="ProjectionSource3D" )
637 StdMeshers::StdMeshers_ProjectionSource3D_var h =
638 StdMeshers::StdMeshers_ProjectionSource3D::_narrow( hypothesis() );
640 h->SetSource3DShape ( geomFromWdg ( getWidgetForParam( 0 )));
641 h->SetSourceMesh ( meshFromWdg ( getWidgetForParam( 1 )));
642 h->SetVertexAssociation( geomFromWdg ( getWidgetForParam( 2 )), // src1
643 geomFromWdg ( getWidgetForParam( 4 )), // src2
644 geomFromWdg ( getWidgetForParam( 3 )), // tgt1
645 geomFromWdg ( getWidgetForParam( 5 ))); // tgt2
647 else if( hypType()=="ImportSource1D" )
649 StdMeshers::StdMeshers_ImportSource1D_var h =
650 StdMeshers::StdMeshers_ImportSource1D::_narrow( hypothesis() );
652 SMESH::ListOfGroups_var groups = groupsFromWdg( getWidgetForParam( 0 ));
653 h->SetSourceEdges( groups.in() );
654 QCheckBox* toCopyMesh = widget< QCheckBox >( 1 );
655 QCheckBox* toCopyGroups = widget< QCheckBox >( 2 );
656 h->SetCopySourceMesh( toCopyMesh->isChecked(), toCopyGroups->isChecked());
658 else if( hypType()=="ImportSource2D" )
660 StdMeshers::StdMeshers_ImportSource2D_var h =
661 StdMeshers::StdMeshers_ImportSource2D::_narrow( hypothesis() );
663 SMESH::ListOfGroups_var groups = groupsFromWdg( getWidgetForParam( 0 ));
664 h->SetSourceFaces( groups.in() );
665 QCheckBox* toCopyMesh = widget< QCheckBox >( 1 );
666 QCheckBox* toCopyGroups = widget< QCheckBox >( 2 );
667 h->SetCopySourceMesh( toCopyMesh->isChecked(), toCopyGroups->isChecked());
669 else if( hypType()=="QuadrangleParams" )
671 StdMeshers::StdMeshers_QuadrangleParams_var h =
672 StdMeshers::StdMeshers_QuadrangleParams::_narrow( hypothesis() );
673 StdMeshersGUI_SubShapeSelectorWdg* w1 =
674 widget< StdMeshersGUI_SubShapeSelectorWdg >( 0 );
675 StdMeshersGUI_QuadrangleParamWdg* w2 =
676 widget< StdMeshersGUI_QuadrangleParamWdg >( 1 );
678 if (w1->GetListSize() > 0) {
679 h->SetTriaVertex(w1->GetListOfIDs()[0]); // getlist must be called once
680 const char * entry = w1->GetMainShapeEntry();
681 h->SetObjectEntry(entry);
683 h->SetQuadType(StdMeshers::QuadType(w2->GetType()));
690 //================================================================================
692 * \brief Return parameter values as SMESHGUI_GenericHypothesisCreator::StdParam
693 * \param p - list of parameters
694 * \retval bool - success flag
696 * Is called from SMESHGUI_GenericHypothesisCreator::buildStdFrame().
697 * Parameters will be shown using "standard" controls:
698 * Int by QtxIntSpinBox
699 * Double by SMESHGUI_SpinBox
700 * String by QLineEdit
701 * getCustomWidget() allows to redefine control for a parameter
703 //================================================================================
705 bool StdMeshersGUI_StdHypothesisCreator::stdParams( ListOfStdParams& p ) const
708 SMESHGUI_GenericHypothesisCreator::StdParam item;
711 customWidgets()->clear();
714 HypothesisData* data = SMESH::GetHypothesisData( hypType() );
715 item.myName = tr( "SMESH_NAME" );
716 item.myValue = data ? hypName() : QString();
718 customWidgets()->append(0);
721 SMESH::SMESH_Hypothesis_var hyp = initParamsHypothesis();
722 SMESH::ListOfParameters_var aParameters = hyp->GetLastParameters();
724 if( hypType()=="LocalLength" )
726 StdMeshers::StdMeshers_LocalLength_var h =
727 StdMeshers::StdMeshers_LocalLength::_narrow( hyp );
729 item.myName = tr("SMESH_LOCAL_LENGTH_PARAM");
730 if(!initVariableName(aParameters,item,0))
731 item.myValue = h->GetLength();
734 item.myName = tr("SMESH_LOCAL_LENGTH_PRECISION");
735 if(!initVariableName(aParameters,item,1))
736 item.myValue = h->GetPrecision();
740 else if( hypType()=="MaxLength" )
742 StdMeshers::StdMeshers_MaxLength_var h =
743 StdMeshers::StdMeshers_MaxLength::_narrow( hyp );
744 // try to set a right preestimated length to edited hypothesis
745 bool noPreestimatedAtEdition = false;
746 if ( !isCreation() ) {
747 StdMeshers::StdMeshers_MaxLength_var initHyp =
748 StdMeshers::StdMeshers_MaxLength::_narrow( initParamsHypothesis(true) );
749 noPreestimatedAtEdition =
750 ( initHyp->_is_nil() || !initHyp->HavePreestimatedLength() );
751 if ( !noPreestimatedAtEdition )
752 h->SetPreestimatedLength( initHyp->GetPreestimatedLength() );
755 item.myName = tr("SMESH_LOCAL_LENGTH_PARAM");
756 if(!initVariableName(aParameters,item,0))
757 item.myValue = h->GetLength();
759 customWidgets()->append(0);
761 item.myName = tr("SMESH_USE_PREESTIMATED_LENGTH");
763 QCheckBox* aQCheckBox = new QCheckBox(dlg());
764 if ( !noPreestimatedAtEdition && h->HavePreestimatedLength() ) {
765 aQCheckBox->setChecked( h->GetUsePreestimatedLength() );
766 connect( aQCheckBox, SIGNAL( stateChanged(int) ), this, SLOT( onValueChanged() ) );
769 aQCheckBox->setChecked( false );
770 aQCheckBox->setEnabled( false );
772 customWidgets()->append( aQCheckBox );
774 else if( hypType()=="SegmentLengthAroundVertex" )
776 StdMeshers::StdMeshers_SegmentLengthAroundVertex_var h =
777 StdMeshers::StdMeshers_SegmentLengthAroundVertex::_narrow( hyp );
779 item.myName = tr("SMESH_LOCAL_LENGTH_PARAM");
780 if(!initVariableName(aParameters,item,0))
781 item.myValue = h->GetLength();
785 else if( hypType()=="Arithmetic1D" )
787 StdMeshers::StdMeshers_Arithmetic1D_var h =
788 StdMeshers::StdMeshers_Arithmetic1D::_narrow( hyp );
790 item.myName = tr( "SMESH_START_LENGTH_PARAM" );
791 if(!initVariableName(aParameters,item,0))
792 item.myValue = h->GetLength( true );
795 customWidgets()->append (0);
797 item.myName = tr( "SMESH_END_LENGTH_PARAM" );
798 if(!initVariableName(aParameters,item,1))
799 item.myValue = h->GetLength( false );
802 customWidgets()->append (0);
804 item.myName = tr( "SMESH_REVERSED_EDGES" );
807 StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget =
808 new StdMeshersGUI_SubShapeSelectorWdg();
809 QString aGeomEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
810 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
811 if ( aGeomEntry == "" )
812 aGeomEntry = h->GetObjectEntry();
814 aDirectionWidget->SetGeomShapeEntry( aGeomEntry );
815 aDirectionWidget->SetMainShapeEntry( aMainEntry );
816 aDirectionWidget->SetListOfIDs( h->GetReversedEdges() );
817 aDirectionWidget->showPreview( true );
818 customWidgets()->append ( aDirectionWidget );
822 else if( hypType()=="FixedPoints1D" )
824 StdMeshers::StdMeshers_FixedPoints1D_var h =
825 StdMeshers::StdMeshers_FixedPoints1D::_narrow( hyp );
827 item.myName = tr( "SMESH_FIXED_POINTS" );
830 StdMeshersGUI_FixedPointsParamWdg* aFixedPointsWidget =
831 new StdMeshersGUI_FixedPointsParamWdg();
833 if ( !isCreation() ) {
834 aFixedPointsWidget->SetListOfPoints( h->GetPoints() );
835 aFixedPointsWidget->SetListOfSegments( h->GetNbSegments() );
837 customWidgets()->append( aFixedPointsWidget );
839 item.myName = tr( "SMESH_REVERSED_EDGES" );
842 StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget =
843 new StdMeshersGUI_SubShapeSelectorWdg();
844 QString anEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
845 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
847 anEntry = h->GetObjectEntry();
848 aDirectionWidget->SetGeomShapeEntry( anEntry );
849 aDirectionWidget->SetMainShapeEntry( aMainEntry );
850 aDirectionWidget->SetListOfIDs( h->GetReversedEdges() );
851 aDirectionWidget->showPreview( true );
852 customWidgets()->append ( aDirectionWidget );
856 else if( hypType()=="MaxElementArea" )
858 StdMeshers::StdMeshers_MaxElementArea_var h =
859 StdMeshers::StdMeshers_MaxElementArea::_narrow( hyp );
861 item.myName = tr( "SMESH_MAX_ELEMENT_AREA_PARAM" );
862 if(!initVariableName(aParameters,item,0))
863 item.myValue = h->GetMaxElementArea();
867 else if( hypType()=="MaxElementVolume" )
869 StdMeshers::StdMeshers_MaxElementVolume_var h =
870 StdMeshers::StdMeshers_MaxElementVolume::_narrow( hyp );
872 item.myName = tr( "SMESH_MAX_ELEMENT_VOLUME_PARAM" );
873 if(!initVariableName(aParameters,item,0))
874 item.myValue = h->GetMaxElementVolume();
877 else if( hypType()=="StartEndLength" )
879 StdMeshers::StdMeshers_StartEndLength_var h =
880 StdMeshers::StdMeshers_StartEndLength::_narrow( hyp );
882 item.myName = tr( "SMESH_START_LENGTH_PARAM" );
884 if(!initVariableName(aParameters,item,0))
885 item.myValue = h->GetLength( true );
887 customWidgets()->append(0);
889 item.myName = tr( "SMESH_END_LENGTH_PARAM" );
890 if(!initVariableName(aParameters,item,1))
891 item.myValue = h->GetLength( false );
893 customWidgets()->append(0);
895 item.myName = tr( "SMESH_REVERSED_EDGES" );
898 StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget =
899 new StdMeshersGUI_SubShapeSelectorWdg();
900 QString anEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
901 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
903 anEntry = h->GetObjectEntry();
904 aDirectionWidget->SetGeomShapeEntry( anEntry );
905 aDirectionWidget->SetMainShapeEntry( aMainEntry );
906 aDirectionWidget->SetListOfIDs( h->GetReversedEdges() );
907 aDirectionWidget->showPreview( true );
908 customWidgets()->append ( aDirectionWidget );
910 else if( hypType()=="Deflection1D" )
912 StdMeshers::StdMeshers_Deflection1D_var h =
913 StdMeshers::StdMeshers_Deflection1D::_narrow( hyp );
915 item.myName = tr( "SMESH_DEFLECTION1D_PARAM" );
916 if(!initVariableName(aParameters,item,0))
917 item.myValue = h->GetDeflection();
920 else if( hypType()=="AutomaticLength" )
922 StdMeshers::StdMeshers_AutomaticLength_var h =
923 StdMeshers::StdMeshers_AutomaticLength::_narrow( hyp );
925 item.myName = tr( "SMESH_FINENESS_PARAM" );
926 //item.myValue = h->GetFineness();
928 SMESHGUI_SpinBox* _autoLengthSpinBox = new SMESHGUI_SpinBox(dlg());
929 _autoLengthSpinBox->RangeStepAndValidator(0, 1, 0.01, "length_precision");
930 _autoLengthSpinBox->SetValue(h->GetFineness());
931 customWidgets()->append( _autoLengthSpinBox);
933 else if( hypType()=="NumberOfLayers" )
935 StdMeshers::StdMeshers_NumberOfLayers_var h =
936 StdMeshers::StdMeshers_NumberOfLayers::_narrow( hyp );
938 item.myName = tr( "SMESH_NUMBER_OF_LAYERS" );
939 if(!initVariableName(aParameters,item,0))
940 item.myValue = (int) h->GetNumberOfLayers();
943 else if( hypType()=="LayerDistribution" ) {
944 StdMeshers::StdMeshers_LayerDistribution_var h =
945 StdMeshers::StdMeshers_LayerDistribution::_narrow( hyp );
947 item.myName = tr( "SMESH_LAYERS_DISTRIBUTION" ); p.append( item );
949 //Set into not published hypo last variables
950 QStringList aLastVarsList;
951 for(int i = 0;i<aParameters->length();i++)
952 aLastVarsList.append(QString(aParameters[i].in()));
954 if(!aLastVarsList.isEmpty())
955 h->GetLayerDistribution()->SetLastParameters(aLastVarsList.join(":").toLatin1().constData());
957 customWidgets()->append
958 ( new StdMeshersGUI_LayerDistributionParamWdg( h->GetLayerDistribution(), hypName(), dlg()));
960 else if( hypType()=="NumberOfLayers2D" ) {
961 StdMeshers::StdMeshers_NumberOfLayers2D_var h =
962 StdMeshers::StdMeshers_NumberOfLayers2D::_narrow( hyp );
964 item.myName = tr( "SMESH_NUMBER_OF_LAYERS" );
965 if(!initVariableName(aParameters,item,0))
966 item.myValue = (int) h->GetNumberOfLayers();
969 else if( hypType()=="LayerDistribution2D" ) {
970 StdMeshers::StdMeshers_LayerDistribution2D_var h =
971 StdMeshers::StdMeshers_LayerDistribution2D::_narrow( hyp );
973 item.myName = tr( "SMESH_LAYERS_DISTRIBUTION" ); p.append( item );
975 //Set into not published hypo last variables
976 QStringList aLastVarsList;
977 for(int i = 0;i<aParameters->length();i++)
978 aLastVarsList.append(QString(aParameters[i].in()));
980 if(!aLastVarsList.isEmpty())
981 h->GetLayerDistribution()->SetLastParameters(aLastVarsList.join(":").toLatin1().constData());
983 customWidgets()->append
984 ( new StdMeshersGUI_LayerDistributionParamWdg( h->GetLayerDistribution(), hypName(), dlg()));
986 else if( hypType()=="ProjectionSource1D" )
988 StdMeshers::StdMeshers_ProjectionSource1D_var h =
989 StdMeshers::StdMeshers_ProjectionSource1D::_narrow( hyp );
991 item.myName = tr( "SMESH_SOURCE_EDGE" ); p.append( item );
992 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 1 ),
993 h->GetSourceEdge()));
994 item.myName = tr( "SMESH_SOURCE_MESH" ); p.append( item );
995 customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( MESH ),
996 h->GetSourceMesh()));
997 item.myName = tr( "SMESH_SOURCE_VERTEX" ); p.append( item );
998 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
999 h->GetSourceVertex()));
1000 item.myName = tr( "SMESH_TARGET_VERTEX" ); p.append( item );
1001 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1002 h->GetTargetVertex()));
1004 else if( hypType()=="ProjectionSource2D" )
1006 StdMeshers::StdMeshers_ProjectionSource2D_var h =
1007 StdMeshers::StdMeshers_ProjectionSource2D::_narrow( hyp );
1009 item.myName = tr( "SMESH_SOURCE_FACE" ); p.append( item );
1010 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 2 ),
1011 h->GetSourceFace()));
1012 item.myName = tr( "SMESH_SOURCE_MESH" ); p.append( item );
1013 customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( MESH ),
1014 h->GetSourceMesh()));
1015 item.myName = tr( "SMESH_SOURCE_VERTEX1" ); p.append( item );
1016 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1017 h->GetSourceVertex( 1 )));
1018 item.myName = tr( "SMESH_TARGET_VERTEX1" ); p.append( item );
1019 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1020 h->GetTargetVertex( 1 )));
1021 item.myName = tr( "SMESH_SOURCE_VERTEX2" ); p.append( item );
1022 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1023 h->GetSourceVertex( 2 )));
1024 item.myName = tr( "SMESH_TARGET_VERTEX2" ); p.append( item );
1025 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1026 h->GetTargetVertex( 2 )));
1028 else if( hypType()=="ProjectionSource3D" )
1030 StdMeshers::StdMeshers_ProjectionSource3D_var h =
1031 StdMeshers::StdMeshers_ProjectionSource3D::_narrow( hyp );
1033 item.myName = tr( "SMESH_SOURCE_3DSHAPE" ); p.append( item );
1034 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 3, TopAbs_FACE, 6, true ),
1035 h->GetSource3DShape()));
1036 item.myName = tr( "SMESH_SOURCE_MESH" ); p.append( item );
1037 customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( MESH ),
1038 h->GetSourceMesh()));
1039 item.myName = tr( "SMESH_SOURCE_VERTEX1" ); p.append( item );
1040 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1041 h->GetSourceVertex( 1 )));
1042 item.myName = tr( "SMESH_TARGET_VERTEX1" ); p.append( item );
1043 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1044 h->GetTargetVertex( 1 )));
1045 item.myName = tr( "SMESH_SOURCE_VERTEX2" ); p.append( item );
1046 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1047 h->GetSourceVertex( 2 )));
1048 item.myName = tr( "SMESH_TARGET_VERTEX2" ); p.append( item );
1049 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1050 h->GetTargetVertex( 2 )));
1052 else if( hypType()=="ImportSource1D" )
1054 StdMeshers::StdMeshers_ImportSource1D_var h =
1055 StdMeshers::StdMeshers_ImportSource1D::_narrow( hyp );
1057 SMESH::string_array_var groupEntries = h->GetSourceEdges();
1058 CORBA::Boolean toCopyMesh, toCopyGroups;
1059 h->GetCopySourceMesh(toCopyMesh, toCopyGroups);
1061 item.myName = tr( "SMESH_SOURCE_EDGES" ); p.append( item );
1062 customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( GROUP_EDGE ),
1065 item.myName = tr( "SMESH_COPY_MESH" ); p.append( item );
1066 QCheckBox* aQCheckBox = new QCheckBox(dlg());
1067 aQCheckBox->setChecked( toCopyMesh );
1068 connect( aQCheckBox, SIGNAL( stateChanged(int) ), this, SLOT( onValueChanged() ));
1069 customWidgets()->append( aQCheckBox );
1071 item.myName = tr( "SMESH_TO_COPY_GROUPS" ); p.append( item );
1072 aQCheckBox = new QCheckBox(dlg());
1073 aQCheckBox->setChecked( toCopyGroups );
1074 aQCheckBox->setEnabled( toCopyMesh );
1075 customWidgets()->append( aQCheckBox );
1077 else if( hypType()=="ImportSource2D" )
1079 StdMeshers::StdMeshers_ImportSource2D_var h =
1080 StdMeshers::StdMeshers_ImportSource2D::_narrow( hyp );
1082 SMESH::string_array_var groupEntries = h->GetSourceFaces();
1083 CORBA::Boolean toCopyMesh, toCopyGroups;
1084 h->GetCopySourceMesh(toCopyMesh, toCopyGroups);
1086 item.myName = tr( "SMESH_SOURCE_FACES" ); p.append( item );
1087 customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( GROUP_FACE ),
1090 item.myName = tr( "SMESH_COPY_MESH" ); p.append( item );
1091 QCheckBox* aQCheckBox = new QCheckBox(dlg());
1092 aQCheckBox->setChecked( toCopyMesh );
1093 connect( aQCheckBox, SIGNAL( stateChanged(int) ), this, SLOT( onValueChanged() ));
1094 customWidgets()->append( aQCheckBox );
1096 item.myName = tr( "SMESH_COPY_GROUPS" ); p.append( item );
1097 aQCheckBox = new QCheckBox(dlg());
1098 aQCheckBox->setChecked( toCopyGroups );
1099 aQCheckBox->setEnabled( toCopyMesh );
1100 customWidgets()->append( aQCheckBox );
1102 else if (hypType() == "QuadrangleParams")
1104 StdMeshers::StdMeshers_QuadrangleParams_var h =
1105 StdMeshers::StdMeshers_QuadrangleParams::_narrow(hyp);
1107 item.myName = tr("SMESH_BASE_VERTEX");
1110 StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget =
1111 new StdMeshersGUI_SubShapeSelectorWdg();
1112 aDirectionWidget->SetMaxSize(1);
1113 aDirectionWidget->SetSubShType(TopAbs_VERTEX);
1114 QString anEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
1115 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
1117 anEntry = h->GetObjectEntry();
1118 aDirectionWidget->SetGeomShapeEntry(anEntry);
1119 aDirectionWidget->SetMainShapeEntry(aMainEntry);
1120 if (!isCreation()) {
1121 SMESH::long_array_var aVec = new SMESH::long_array;
1122 int vertID = h->GetTriaVertex();
1126 aDirectionWidget->SetListOfIDs(aVec);
1129 aDirectionWidget->showPreview(true);
1131 item.myName = tr("SMESH_QUAD_TYPE");
1134 StdMeshersGUI_QuadrangleParamWdg* aTypeWidget =
1135 new StdMeshersGUI_QuadrangleParamWdg();
1136 if (!isCreation()) {
1137 aTypeWidget->SetType(int(h->GetQuadType()));
1140 customWidgets()->append(aDirectionWidget);
1141 customWidgets()->append(aTypeWidget);
1148 //================================================================================
1150 * \brief tune "standard" control
1151 * \param w - control widget
1152 * \param int - parameter index
1154 //================================================================================
1156 void StdMeshersGUI_StdHypothesisCreator::attuneStdWidget (QWidget* w, const int) const
1158 SMESHGUI_SpinBox* sb = w->inherits( "SMESHGUI_SpinBox" ) ? ( SMESHGUI_SpinBox* )w : 0;
1159 if( hypType()=="LocalLength" && sb )
1161 if (sb->objectName() == tr("SMESH_LOCAL_LENGTH_PARAM"))
1162 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1163 else if (sb->objectName() == tr("SMESH_LOCAL_LENGTH_PRECISION"))
1164 sb->RangeStepAndValidator( 0.0, 1.0, 0.05, "len_tol_precision" );
1166 else if( hypType()=="Arithmetic1D" && sb )
1168 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "parametric_precision" );
1170 else if( hypType()=="MaxLength" && sb )
1172 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1173 sb->setEnabled( !widget< QCheckBox >( 1 )->isChecked() );
1175 else if( hypType()=="MaxElementArea" && sb )
1177 sb->RangeStepAndValidator( VALUE_SMALL_2, VALUE_MAX_2, 1.0, "area_precision" );
1179 else if( hypType()=="MaxElementVolume" && sb )
1181 sb->RangeStepAndValidator( VALUE_SMALL_3, VALUE_MAX_3, 1.0, "vol_precision" );
1183 else if( hypType()=="StartEndLength" && sb )
1185 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1187 else if( hypType()=="Deflection1D" && sb )
1189 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "parametric_precision" );
1191 else if ( sb ) // default validator for possible ancestors
1193 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1197 //================================================================================
1199 * \brief Return dlg title
1200 * \retval QString - title string
1202 //================================================================================
1204 QString StdMeshersGUI_StdHypothesisCreator::caption() const
1206 return tr( QString( "SMESH_%1_TITLE" ).arg( hypTypeName( hypType() ) ).toLatin1().data() );
1209 //================================================================================
1211 * \brief return pixmap for dlg icon
1214 //================================================================================
1216 QPixmap StdMeshersGUI_StdHypothesisCreator::icon() const
1218 QString hypIconName = tr( QString( "ICON_DLG_%1" ).arg( hypTypeName( hypType() ) ).toLatin1().data() );
1219 return SMESHGUI::resourceMgr()->loadPixmap( "SMESH", hypIconName );
1222 //================================================================================
1224 * \brief Return hypothesis type name to show in dlg
1227 //================================================================================
1229 QString StdMeshersGUI_StdHypothesisCreator::type() const
1231 return tr( QString( "SMESH_%1_HYPOTHESIS" ).arg( hypTypeName( hypType() ) ).toLatin1().data() );
1234 //================================================================================
1236 * \brief String to insert in "SMESH_%1_HYPOTHESIS" to get hypothesis type name
1237 * from message resouce file
1238 * \param t - hypothesis type
1239 * \retval QString - result string
1241 //================================================================================
1243 QString StdMeshersGUI_StdHypothesisCreator::hypTypeName( const QString& t ) const
1245 static QMap<QString,QString> types;
1246 if( types.isEmpty() )
1248 types.insert( "LocalLength", "LOCAL_LENGTH" );
1249 types.insert( "NumberOfSegments", "NB_SEGMENTS" );
1250 types.insert( "MaxElementArea", "MAX_ELEMENT_AREA" );
1251 types.insert( "MaxElementVolume", "MAX_ELEMENT_VOLUME" );
1252 types.insert( "StartEndLength", "START_END_LENGTH" );
1253 types.insert( "Deflection1D", "DEFLECTION1D" );
1254 types.insert( "Arithmetic1D", "ARITHMETIC_1D" );
1255 types.insert( "FixedPoints1D", "FIXED_POINTS_1D" );
1256 types.insert( "AutomaticLength", "AUTOMATIC_LENGTH" );
1257 types.insert( "ProjectionSource1D", "PROJECTION_SOURCE_1D" );
1258 types.insert( "ProjectionSource2D", "PROJECTION_SOURCE_2D" );
1259 types.insert( "ProjectionSource3D", "PROJECTION_SOURCE_3D" );
1260 types.insert( "ImportSource1D", "IMPORT_SOURCE_1D" );
1261 types.insert( "ImportSource2D", "IMPORT_SOURCE_2D" );
1262 types.insert( "NumberOfLayers", "NUMBER_OF_LAYERS" );
1263 types.insert( "LayerDistribution", "LAYER_DISTRIBUTION" );
1264 types.insert( "NumberOfLayers2D", "NUMBER_OF_LAYERS_2D" );
1265 types.insert( "LayerDistribution2D", "LAYER_DISTRIBUTION" );
1266 types.insert( "SegmentLengthAroundVertex", "SEGMENT_LENGTH_AROUND_VERTEX" );
1267 types.insert( "MaxLength", "MAX_LENGTH" );
1268 types.insert( "QuadrangleParams", "QUADRANGLE_PARAMS" );
1272 if( types.contains( t ) )
1279 //=======================================================================
1280 //function : getCustomWidget
1281 //purpose : is called from buildStdFrame()
1282 //=======================================================================
1284 QWidget* StdMeshersGUI_StdHypothesisCreator::getCustomWidget( const StdParam & param,
1286 const int index) const
1289 if ( index < customWidgets()->count() ) {
1290 w = customWidgets()->at( index );
1292 w->setParent( parent );
1293 w->move( QPoint( 0, 0 ) );
1299 //================================================================================
1301 * \brief Set param value taken from a custom widget
1302 * \param param - SMESHGUI_GenericHypothesisCreator::StdParam structure
1303 * \param widget - widget presenting param
1304 * \retval bool - success flag
1306 * this method is called from getStdParamFromDlg()
1308 //================================================================================
1310 bool StdMeshersGUI_StdHypothesisCreator::getParamFromCustomWidget( StdParam & param,
1311 QWidget* widget) const
1313 if ( hypType()=="AutomaticLength" ) {
1314 SMESHGUI_SpinBox* w = dynamic_cast<SMESHGUI_SpinBox*>( widget );
1316 param.myValue = w->GetValue();
1320 if ( hypType() == "MaxLength" ) {
1324 if ( widget->inherits( "StdMeshersGUI_ObjectReferenceParamWdg" ))
1326 // show only 1st reference value
1327 if ( true /*widget == getWidgetForParam( 0 )*/) {
1328 const StdMeshersGUI_ObjectReferenceParamWdg * w =
1329 static_cast<const StdMeshersGUI_ObjectReferenceParamWdg*>( widget );
1330 param.myValue = w->GetValue();
1334 if ( widget->inherits( "StdMeshersGUI_LayerDistributionParamWdg" ))
1336 const StdMeshersGUI_LayerDistributionParamWdg * w =
1337 static_cast<const StdMeshersGUI_LayerDistributionParamWdg*>( widget );
1338 param.myValue = w->GetValue();
1341 if ( widget->inherits( "StdMeshersGUI_SubShapeSelectorWdg" ))
1343 const StdMeshersGUI_SubShapeSelectorWdg * w =
1344 static_cast<const StdMeshersGUI_SubShapeSelectorWdg*>( widget );
1345 param.myValue = w->GetValue();
1348 if ( widget->inherits( "StdMeshersGUI_QuadrangleParamWdg" ))
1350 //const StdMeshersGUI_QuadrangleParamWdg * w =
1351 // static_cast<const StdMeshersGUI_QuadrangleParamWdg*>( widget );
1352 param.myValue = "QuadType";
1355 if ( widget->inherits( "StdMeshersGUI_FixedPointsParamWdg" ))
1357 const StdMeshersGUI_FixedPointsParamWdg * w =
1358 static_cast<const StdMeshersGUI_FixedPointsParamWdg*>( widget );
1359 param.myValue = w->GetValue();
1362 if ( widget->inherits( "QCheckBox" ))
1364 //const QCheckBox * w = static_cast<const QCheckBox*>( widget );
1365 //param.myValue = w->isChecked();
1371 //================================================================================
1373 * \brief called when operation cancelled
1375 //================================================================================
1377 void StdMeshersGUI_StdHypothesisCreator::onReject()
1379 if ( hypType().startsWith("ProjectionSource" ) ||
1380 hypType().startsWith("ImportSource" ))
1382 // Uninstall filters of StdMeshersGUI_ObjectReferenceParamWdg
1383 deactivateObjRefParamWdg( customWidgets() );
1387 //================================================================================
1389 * \brief Update widgets dependent on paramWidget
1391 //================================================================================
1393 void StdMeshersGUI_StdHypothesisCreator::valueChanged( QWidget* paramWidget)
1395 if ( hypType() == "MaxLength" && paramWidget == getWidgetForParam(1) )
1397 getWidgetForParam(0)->setEnabled( !widget< QCheckBox >( 1 )->isChecked() );
1398 if ( !getWidgetForParam(0)->isEnabled() ) {
1399 StdMeshers::StdMeshers_MaxLength_var h =
1400 StdMeshers::StdMeshers_MaxLength::_narrow( initParamsHypothesis() );
1401 widget< QtxDoubleSpinBox >( 0 )->setValue( h->GetPreestimatedLength() );
1404 else if ( hypType().startsWith("ImportSource") && paramWidget == getWidgetForParam(1) )
1406 QCheckBox* toCopyMesh = (QCheckBox*) paramWidget;
1407 QCheckBox* toCopyGroups = widget< QCheckBox >( 2 );
1408 if ( !toCopyMesh->isChecked() )
1410 toCopyGroups->setChecked( false );
1411 toCopyGroups->setEnabled( false );
1415 toCopyGroups->setEnabled( true );
1420 //================================================================================
1424 //================================================================================
1426 bool StdMeshersGUI_StdHypothesisCreator::initVariableName(SMESH::ListOfParameters_var theParameters,
1427 StdParam &theParams,
1430 QString aVaribaleName = (theParameters->length() > order) ? QString(theParameters[order].in()) : QString("");
1431 theParams.isVariable = !aVaribaleName.isEmpty();
1432 if(theParams.isVariable)
1433 theParams.myValue = aVaribaleName;
1435 return theParams.isVariable;