1 // Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File : StdMeshersGUI_StdHypothesisCreator.cxx
23 // Author : Alexander SOLOVYOV, Open CASCADE S.A.S.
26 #include "StdMeshersGUI_StdHypothesisCreator.h"
29 #include <SMESHGUI_SpinBox.h>
30 #include <SMESHGUI_HypothesesUtils.h>
31 #include <SMESHGUI_Utils.h>
33 #include <SMESH_TypeFilter.hxx>
34 #include <SMESH_NumberFilter.hxx>
36 #include "StdMeshersGUI_FixedPointsParamWdg.h"
37 #include "StdMeshersGUI_LayerDistributionParamWdg.h"
38 #include "StdMeshersGUI_ObjectReferenceParamWdg.h"
39 #include "StdMeshersGUI_QuadrangleParamWdg.h"
40 #include "StdMeshersGUI_SubShapeSelectorWdg.h"
42 #include <SALOMEDSClient_Study.hxx>
44 // SALOME GUI includes
45 #include <SUIT_ResourceMgr.h>
48 #include <SALOMEconfig.h>
49 #include CORBA_SERVER_HEADER(SMESH_BasicHypothesis)
50 #include CORBA_SERVER_HEADER(SMESH_Mesh)
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 //RNV: Firstly, activate selection, then set objects
346 w->activateSelection();
347 w->SetObjects( objEntries );
351 //================================================================================
353 * \brief calls deactivateSelection() for StdMeshersGUI_ObjectReferenceParamWdg
354 * \param widgetList - list of widgets
356 //================================================================================
358 void deactivateObjRefParamWdg( QList<QWidget*>* widgetList )
360 StdMeshersGUI_ObjectReferenceParamWdg* w = 0;
361 QList<QWidget*>::iterator anIt = widgetList->begin();
362 QList<QWidget*>::iterator aLast = widgetList->end();
363 for ( ; anIt != aLast; anIt++ ) {
364 if ( (*anIt) && (*anIt)->inherits( "StdMeshersGUI_ObjectReferenceParamWdg" ))
366 w = (StdMeshersGUI_ObjectReferenceParamWdg* )( *anIt );
367 w->deactivateSelection();
373 //================================================================================
375 * \brief Check parameter values before accept()
376 * \retval bool - true if OK
378 //================================================================================
380 bool StdMeshersGUI_StdHypothesisCreator::checkParams( QString& msg ) const
382 if( !SMESHGUI_GenericHypothesisCreator::checkParams( msg ) )
385 // check if object reference parameter is set, as it has no default value
387 if ( hypType().startsWith("ProjectionSource" ))
389 StdMeshersGUI_ObjectReferenceParamWdg* w =
390 widget< StdMeshersGUI_ObjectReferenceParamWdg >( 0 );
391 ok = ( w->IsObjectSelected() );
392 if ( !ok ) w->SetObject( CORBA::Object::_nil() );
393 int nbAssocVert = ( hypType() == "ProjectionSource1D" ? 1 : 2 );
394 for ( int i = 0; ok && i < nbAssocVert; i += 2)
397 StdMeshersGUI_ObjectReferenceParamWdg* w1 =
398 widget< StdMeshersGUI_ObjectReferenceParamWdg >( i+2 );
399 StdMeshersGUI_ObjectReferenceParamWdg* w2 =
400 widget< StdMeshersGUI_ObjectReferenceParamWdg >( i+3 );
401 srcV = w1->GetValue();
402 tgtV = w2->GetValue();
403 ok = (( srcV.isEmpty() && tgtV.isEmpty() ) ||
404 ( !srcV.isEmpty() && !tgtV.isEmpty() && srcV != tgtV ));
406 w1->SetObject( CORBA::Object::_nil() );
407 w2->SetObject( CORBA::Object::_nil() );
411 // Uninstall filters of StdMeshersGUI_ObjectReferenceParamWdg
413 deactivateObjRefParamWdg( customWidgets() );
415 else if ( hypType().startsWith("ImportSource" ))
417 StdMeshersGUI_ObjectReferenceParamWdg* w =
418 widget< StdMeshersGUI_ObjectReferenceParamWdg >( 0 );
419 ok = ( w->IsObjectSelected() );
421 else if ( hypType() == "LayerDistribution" || hypType() == "LayerDistribution2D" )
423 StdMeshersGUI_LayerDistributionParamWdg* w =
424 widget< StdMeshersGUI_LayerDistributionParamWdg >( 0 );
425 ok = ( w && w->IsOk() );
427 else if ( hypType() == "QuadrangleParams" )
429 //StdMeshersGUI_SubShapeSelectorWdg* w =
430 // widget< StdMeshersGUI_SubShapeSelectorWdg >( 0 );
431 //ok = ( w->GetListSize() > 0 );
432 //StdMeshersGUI_QuadrangleParamWdg* w =
433 // widget< StdMeshersGUI_QuadrangleParamWdg >( 1 );
438 //================================================================================
440 * \brief Store params from GUI controls to a hypothesis
441 * \retval QString - text representation of parameters
443 //================================================================================
445 QString StdMeshersGUI_StdHypothesisCreator::storeParams() const
447 ListOfStdParams params;
448 bool res = getStdParamFromDlg( params );
451 SMESH::SetName( SMESH::FindSObject( hypothesis() ), params[0].myValue.toString().toLatin1().data() );
452 params.erase( params.begin() );
455 QString valueStr = stdParamValues( params );
456 QStringList aVariablesList = getVariablesFromDlg();
458 if( res && !params.isEmpty() )
460 if( hypType()=="LocalLength" )
462 StdMeshers::StdMeshers_LocalLength_var h =
463 StdMeshers::StdMeshers_LocalLength::_narrow( hypothesis() );
465 h->SetLength( params[0].myValue.toDouble() );
466 h->SetParameters(aVariablesList.join(":").toLatin1().constData());
467 h->SetPrecision( params[1].myValue.toDouble() );
468 h->SetParameters(aVariablesList.join(":").toLatin1().constData());
470 else if( hypType()=="MaxLength" )
472 StdMeshers::StdMeshers_MaxLength_var h =
473 StdMeshers::StdMeshers_MaxLength::_narrow( hypothesis() );
475 h->SetLength( params[0].myValue.toDouble() );
476 h->SetParameters(aVariablesList.join(":").toLatin1().constData());
477 h->SetUsePreestimatedLength( widget< QCheckBox >( 1 )->isChecked() );
478 if ( !h->HavePreestimatedLength() && !h->_is_equivalent( initParamsHypothesis() )) {
479 StdMeshers::StdMeshers_MaxLength_var hInit =
480 StdMeshers::StdMeshers_MaxLength::_narrow( initParamsHypothesis() );
481 h->SetPreestimatedLength( hInit->GetPreestimatedLength() );
484 else if( hypType()=="SegmentLengthAroundVertex" )
486 StdMeshers::StdMeshers_SegmentLengthAroundVertex_var h =
487 StdMeshers::StdMeshers_SegmentLengthAroundVertex::_narrow( hypothesis() );
489 h->SetLength( params[0].myValue.toDouble() );
490 h->SetParameters(aVariablesList.join(":").toLatin1().constData());
492 else if( hypType()=="Arithmetic1D" )
494 StdMeshers::StdMeshers_Arithmetic1D_var h =
495 StdMeshers::StdMeshers_Arithmetic1D::_narrow( hypothesis() );
497 StdMeshersGUI_SubShapeSelectorWdg* w =
498 widget< StdMeshersGUI_SubShapeSelectorWdg >( 2 );
500 h->SetStartLength( params[0].myValue.toDouble() );
501 h->SetParameters(aVariablesList.join(":").toLatin1().constData());
502 h->SetEndLength( params[1].myValue.toDouble() );
503 h->SetParameters(aVariablesList.join(":").toLatin1().constData());
505 h->SetReversedEdges( w->GetListOfIDs() );
506 h->SetObjectEntry( w->GetMainShapeEntry() );
509 else if( hypType()=="FixedPoints1D" )
511 StdMeshers::StdMeshers_FixedPoints1D_var h =
512 StdMeshers::StdMeshers_FixedPoints1D::_narrow( hypothesis() );
514 StdMeshersGUI_FixedPointsParamWdg* w1 =
515 widget< StdMeshersGUI_FixedPointsParamWdg >( 0 );
517 StdMeshersGUI_SubShapeSelectorWdg* w2 =
518 widget< StdMeshersGUI_SubShapeSelectorWdg >( 1 );
521 h->SetParameters(aVariablesList.join(":").toLatin1().constData());
522 h->SetPoints( w1->GetListOfPoints() );
523 h->SetNbSegments( w1->GetListOfSegments() );
526 h->SetReversedEdges( w2->GetListOfIDs() );
527 h->SetObjectEntry( w2->GetMainShapeEntry() );
530 else if( hypType()=="MaxElementArea" )
532 StdMeshers::StdMeshers_MaxElementArea_var h =
533 StdMeshers::StdMeshers_MaxElementArea::_narrow( hypothesis() );
534 h->SetParameters(aVariablesList.join(":").toLatin1().constData());
535 h->SetMaxElementArea( params[0].myValue.toDouble() );
537 else if( hypType()=="MaxElementVolume" )
539 StdMeshers::StdMeshers_MaxElementVolume_var h =
540 StdMeshers::StdMeshers_MaxElementVolume::_narrow( hypothesis() );
542 h->SetMaxElementVolume( params[0].myValue.toDouble() );
543 h->SetParameters(aVariablesList.join(":").toLatin1().constData());
545 else if( hypType()=="StartEndLength" )
547 StdMeshers::StdMeshers_StartEndLength_var h =
548 StdMeshers::StdMeshers_StartEndLength::_narrow( hypothesis() );
550 StdMeshersGUI_SubShapeSelectorWdg* w =
551 widget< StdMeshersGUI_SubShapeSelectorWdg >( 2 );
553 h->SetStartLength( params[0].myValue.toDouble() );
554 h->SetParameters(aVariablesList.join(":").toLatin1().constData());
555 h->SetEndLength( params[1].myValue.toDouble() );
556 h->SetParameters(aVariablesList.join(":").toLatin1().constData());
558 h->SetReversedEdges( w->GetListOfIDs() );
559 h->SetObjectEntry( w->GetMainShapeEntry() );
562 else if( hypType()=="Deflection1D" )
564 StdMeshers::StdMeshers_Deflection1D_var h =
565 StdMeshers::StdMeshers_Deflection1D::_narrow( hypothesis() );
566 h->SetParameters(aVariablesList.join(":").toLatin1().constData());
567 h->SetDeflection( params[0].myValue.toDouble() );
569 else if( hypType()=="AutomaticLength" )
571 StdMeshers::StdMeshers_AutomaticLength_var h =
572 StdMeshers::StdMeshers_AutomaticLength::_narrow( hypothesis() );
574 h->SetFineness( params[0].myValue.toDouble() );
576 else if( hypType()=="NumberOfLayers" )
578 StdMeshers::StdMeshers_NumberOfLayers_var h =
579 StdMeshers::StdMeshers_NumberOfLayers::_narrow( hypothesis() );
581 h->SetNumberOfLayers( params[0].myValue.toInt() );
582 h->SetParameters(aVariablesList.join(":").toLatin1().constData());
584 else if( hypType()=="LayerDistribution" )
586 StdMeshers::StdMeshers_LayerDistribution_var h =
587 StdMeshers::StdMeshers_LayerDistribution::_narrow( hypothesis() );
588 StdMeshersGUI_LayerDistributionParamWdg* w =
589 widget< StdMeshersGUI_LayerDistributionParamWdg >( 0 );
591 h->SetLayerDistribution( w->GetHypothesis() );
592 h->SetParameters(w->GetHypothesis()->GetParameters());
593 w->GetHypothesis()->ClearParameters();
595 else if( hypType()=="NumberOfLayers2D" )
597 StdMeshers::StdMeshers_NumberOfLayers2D_var h =
598 StdMeshers::StdMeshers_NumberOfLayers2D::_narrow( hypothesis() );
600 h->SetNumberOfLayers( params[0].myValue.toInt() );
601 h->SetParameters(aVariablesList.join(":").toLatin1().constData());
603 else if( hypType()=="LayerDistribution2D" )
605 StdMeshers::StdMeshers_LayerDistribution2D_var h =
606 StdMeshers::StdMeshers_LayerDistribution2D::_narrow( hypothesis() );
607 StdMeshersGUI_LayerDistributionParamWdg* w =
608 widget< StdMeshersGUI_LayerDistributionParamWdg >( 0 );
610 h->SetLayerDistribution( w->GetHypothesis() );
611 h->SetParameters(w->GetHypothesis()->GetParameters());
612 w->GetHypothesis()->ClearParameters();
614 else if( hypType()=="ProjectionSource1D" )
616 StdMeshers::StdMeshers_ProjectionSource1D_var h =
617 StdMeshers::StdMeshers_ProjectionSource1D::_narrow( hypothesis() );
619 h->SetSourceEdge ( geomFromWdg ( getWidgetForParam( 0 )));
620 h->SetSourceMesh ( meshFromWdg ( getWidgetForParam( 1 )));
621 h->SetVertexAssociation( geomFromWdg ( getWidgetForParam( 2 )),
622 geomFromWdg ( getWidgetForParam( 3 )));
624 else if( hypType()=="ProjectionSource2D" )
626 StdMeshers::StdMeshers_ProjectionSource2D_var h =
627 StdMeshers::StdMeshers_ProjectionSource2D::_narrow( hypothesis() );
629 h->SetSourceFace ( geomFromWdg ( getWidgetForParam( 0 )));
630 h->SetSourceMesh ( meshFromWdg ( getWidgetForParam( 1 )));
631 h->SetVertexAssociation( geomFromWdg ( getWidgetForParam( 2 )), // src1
632 geomFromWdg ( getWidgetForParam( 4 )), // src2
633 geomFromWdg ( getWidgetForParam( 3 )), // tgt1
634 geomFromWdg ( getWidgetForParam( 5 ))); // tgt2
636 else if( hypType()=="ProjectionSource3D" )
638 StdMeshers::StdMeshers_ProjectionSource3D_var h =
639 StdMeshers::StdMeshers_ProjectionSource3D::_narrow( hypothesis() );
641 h->SetSource3DShape ( geomFromWdg ( getWidgetForParam( 0 )));
642 h->SetSourceMesh ( meshFromWdg ( getWidgetForParam( 1 )));
643 h->SetVertexAssociation( geomFromWdg ( getWidgetForParam( 2 )), // src1
644 geomFromWdg ( getWidgetForParam( 4 )), // src2
645 geomFromWdg ( getWidgetForParam( 3 )), // tgt1
646 geomFromWdg ( getWidgetForParam( 5 ))); // tgt2
648 else if( hypType()=="ImportSource1D" )
650 StdMeshers::StdMeshers_ImportSource1D_var h =
651 StdMeshers::StdMeshers_ImportSource1D::_narrow( hypothesis() );
653 SMESH::ListOfGroups_var groups = groupsFromWdg( getWidgetForParam( 0 ));
654 h->SetSourceEdges( groups.in() );
655 QCheckBox* toCopyMesh = widget< QCheckBox >( 1 );
656 QCheckBox* toCopyGroups = widget< QCheckBox >( 2 );
657 h->SetCopySourceMesh( toCopyMesh->isChecked(), toCopyGroups->isChecked());
659 else if( hypType()=="ImportSource2D" )
661 StdMeshers::StdMeshers_ImportSource2D_var h =
662 StdMeshers::StdMeshers_ImportSource2D::_narrow( hypothesis() );
664 SMESH::ListOfGroups_var groups = groupsFromWdg( getWidgetForParam( 0 ));
665 h->SetSourceFaces( groups.in() );
666 QCheckBox* toCopyMesh = widget< QCheckBox >( 1 );
667 QCheckBox* toCopyGroups = widget< QCheckBox >( 2 );
668 h->SetCopySourceMesh( toCopyMesh->isChecked(), toCopyGroups->isChecked());
670 else if( hypType()=="ViscousLayers" )
672 StdMeshers::StdMeshers_ViscousLayers_var h =
673 StdMeshers::StdMeshers_ViscousLayers::_narrow( hypothesis() );
675 h->SetTotalThickness( params[0].myValue.toDouble() );
676 /* */ h->SetParameters(aVariablesList.join(":").toLatin1().constData());
677 h->SetNumberLayers ( params[1].myValue.toInt() );
678 /* */ h->SetParameters(aVariablesList.join(":").toLatin1().constData());
679 h->SetStretchFactor ( params[2].myValue.toDouble() );
680 /* */ h->SetParameters(aVariablesList.join(":").toLatin1().constData());
682 if ( StdMeshersGUI_SubShapeSelectorWdg* idsWg =
683 widget< StdMeshersGUI_SubShapeSelectorWdg >( 3 ))
685 h->SetIgnoreFaces( idsWg->GetListOfIDs() );
686 //h->SetObjectEntry( idsWg->GetMainShapeEntry() );
689 else if( hypType()=="QuadrangleParams" )
691 StdMeshers::StdMeshers_QuadrangleParams_var h =
692 StdMeshers::StdMeshers_QuadrangleParams::_narrow( hypothesis() );
693 StdMeshersGUI_SubShapeSelectorWdg* w1 =
694 widget< StdMeshersGUI_SubShapeSelectorWdg >( 0 );
695 StdMeshersGUI_QuadrangleParamWdg* w2 =
696 widget< StdMeshersGUI_QuadrangleParamWdg >( 1 );
698 if (w1->GetListSize() > 0) {
699 h->SetTriaVertex(w1->GetListOfIDs()[0]); // getlist must be called once
700 const char * entry = w1->GetMainShapeEntry();
701 h->SetObjectEntry(entry);
703 h->SetQuadType(StdMeshers::QuadType(w2->GetType()));
710 //================================================================================
712 * \brief Return parameter values as SMESHGUI_GenericHypothesisCreator::StdParam
713 * \param p - list of parameters
714 * \retval bool - success flag
716 * Is called from SMESHGUI_GenericHypothesisCreator::buildStdFrame().
717 * Parameters will be shown using "standard" controls:
718 * Int by QtxIntSpinBox
719 * Double by SMESHGUI_SpinBox
720 * String by QLineEdit
721 * getCustomWidget() allows to redefine control for a parameter
723 //================================================================================
725 bool StdMeshersGUI_StdHypothesisCreator::stdParams( ListOfStdParams& p ) const
728 SMESHGUI_GenericHypothesisCreator::StdParam item;
731 customWidgets()->clear();
734 HypothesisData* data = SMESH::GetHypothesisData( hypType() );
735 item.myName = tr( "SMESH_NAME" );
736 item.myValue = data ? hypName() : QString();
738 customWidgets()->append(0);
741 SMESH::SMESH_Hypothesis_var hyp = initParamsHypothesis();
742 SMESH::ListOfParameters_var aParameters = hyp->GetLastParameters();
744 if( hypType()=="LocalLength" )
746 StdMeshers::StdMeshers_LocalLength_var h =
747 StdMeshers::StdMeshers_LocalLength::_narrow( hyp );
749 item.myName = tr("SMESH_LOCAL_LENGTH_PARAM");
750 if(!initVariableName(aParameters,item,0))
751 item.myValue = h->GetLength();
754 item.myName = tr("SMESH_LOCAL_LENGTH_PRECISION");
755 if(!initVariableName(aParameters,item,1))
756 item.myValue = h->GetPrecision();
760 else if( hypType()=="MaxLength" )
762 StdMeshers::StdMeshers_MaxLength_var h =
763 StdMeshers::StdMeshers_MaxLength::_narrow( hyp );
764 // try to set a right preestimated length to edited hypothesis
765 bool noPreestimatedAtEdition = false;
766 if ( !isCreation() ) {
767 StdMeshers::StdMeshers_MaxLength_var initHyp =
768 StdMeshers::StdMeshers_MaxLength::_narrow( initParamsHypothesis(true) );
769 noPreestimatedAtEdition =
770 ( initHyp->_is_nil() || !initHyp->HavePreestimatedLength() );
771 if ( !noPreestimatedAtEdition )
772 h->SetPreestimatedLength( initHyp->GetPreestimatedLength() );
775 item.myName = tr("SMESH_LOCAL_LENGTH_PARAM");
776 if(!initVariableName(aParameters,item,0))
777 item.myValue = h->GetLength();
779 customWidgets()->append(0);
781 item.myName = tr("SMESH_USE_PREESTIMATED_LENGTH");
783 QCheckBox* aQCheckBox = new QCheckBox(dlg());
784 if ( !noPreestimatedAtEdition && h->HavePreestimatedLength() ) {
785 aQCheckBox->setChecked( h->GetUsePreestimatedLength() );
786 connect( aQCheckBox, SIGNAL( stateChanged(int) ), this, SLOT( onValueChanged() ) );
789 aQCheckBox->setChecked( false );
790 aQCheckBox->setEnabled( false );
792 customWidgets()->append( aQCheckBox );
794 else if( hypType()=="SegmentLengthAroundVertex" )
796 StdMeshers::StdMeshers_SegmentLengthAroundVertex_var h =
797 StdMeshers::StdMeshers_SegmentLengthAroundVertex::_narrow( hyp );
799 item.myName = tr("SMESH_LOCAL_LENGTH_PARAM");
800 if(!initVariableName(aParameters,item,0))
801 item.myValue = h->GetLength();
805 else if( hypType()=="Arithmetic1D" )
807 StdMeshers::StdMeshers_Arithmetic1D_var h =
808 StdMeshers::StdMeshers_Arithmetic1D::_narrow( hyp );
810 item.myName = tr( "SMESH_START_LENGTH_PARAM" );
811 if(!initVariableName(aParameters,item,0))
812 item.myValue = h->GetLength( true );
815 customWidgets()->append (0);
817 item.myName = tr( "SMESH_END_LENGTH_PARAM" );
818 if(!initVariableName(aParameters,item,1))
819 item.myValue = h->GetLength( false );
822 customWidgets()->append (0);
824 item.myName = tr( "SMESH_REVERSED_EDGES" );
827 StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget =
828 new StdMeshersGUI_SubShapeSelectorWdg();
829 QString aGeomEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
830 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
831 if ( aGeomEntry == "" )
832 aGeomEntry = h->GetObjectEntry();
834 aDirectionWidget->SetGeomShapeEntry( aGeomEntry );
835 aDirectionWidget->SetMainShapeEntry( aMainEntry );
836 aDirectionWidget->SetListOfIDs( h->GetReversedEdges() );
837 aDirectionWidget->showPreview( true );
838 customWidgets()->append ( aDirectionWidget );
842 else if( hypType()=="FixedPoints1D" )
844 StdMeshers::StdMeshers_FixedPoints1D_var h =
845 StdMeshers::StdMeshers_FixedPoints1D::_narrow( hyp );
847 item.myName = tr( "SMESH_FIXED_POINTS" );
850 StdMeshersGUI_FixedPointsParamWdg* aFixedPointsWidget =
851 new StdMeshersGUI_FixedPointsParamWdg();
853 if ( !isCreation() ) {
854 aFixedPointsWidget->SetListOfPoints( h->GetPoints() );
855 aFixedPointsWidget->SetListOfSegments( h->GetNbSegments() );
857 customWidgets()->append( aFixedPointsWidget );
859 item.myName = tr( "SMESH_REVERSED_EDGES" );
862 StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget =
863 new StdMeshersGUI_SubShapeSelectorWdg();
864 QString anEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
865 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
867 anEntry = h->GetObjectEntry();
868 aDirectionWidget->SetGeomShapeEntry( anEntry );
869 aDirectionWidget->SetMainShapeEntry( aMainEntry );
870 aDirectionWidget->SetListOfIDs( h->GetReversedEdges() );
871 aDirectionWidget->showPreview( true );
872 customWidgets()->append ( aDirectionWidget );
876 else if( hypType()=="MaxElementArea" )
878 StdMeshers::StdMeshers_MaxElementArea_var h =
879 StdMeshers::StdMeshers_MaxElementArea::_narrow( hyp );
881 item.myName = tr( "SMESH_MAX_ELEMENT_AREA_PARAM" );
882 if(!initVariableName(aParameters,item,0))
883 item.myValue = h->GetMaxElementArea();
887 else if( hypType()=="MaxElementVolume" )
889 StdMeshers::StdMeshers_MaxElementVolume_var h =
890 StdMeshers::StdMeshers_MaxElementVolume::_narrow( hyp );
892 item.myName = tr( "SMESH_MAX_ELEMENT_VOLUME_PARAM" );
893 if(!initVariableName(aParameters,item,0))
894 item.myValue = h->GetMaxElementVolume();
897 else if( hypType()=="StartEndLength" )
899 StdMeshers::StdMeshers_StartEndLength_var h =
900 StdMeshers::StdMeshers_StartEndLength::_narrow( hyp );
902 item.myName = tr( "SMESH_START_LENGTH_PARAM" );
904 if(!initVariableName(aParameters,item,0))
905 item.myValue = h->GetLength( true );
907 customWidgets()->append(0);
909 item.myName = tr( "SMESH_END_LENGTH_PARAM" );
910 if(!initVariableName(aParameters,item,1))
911 item.myValue = h->GetLength( false );
913 customWidgets()->append(0);
915 item.myName = tr( "SMESH_REVERSED_EDGES" );
918 StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget =
919 new StdMeshersGUI_SubShapeSelectorWdg();
920 QString anEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
921 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
923 anEntry = h->GetObjectEntry();
924 aDirectionWidget->SetGeomShapeEntry( anEntry );
925 aDirectionWidget->SetMainShapeEntry( aMainEntry );
926 aDirectionWidget->SetListOfIDs( h->GetReversedEdges() );
927 aDirectionWidget->showPreview( true );
928 customWidgets()->append ( aDirectionWidget );
930 else if( hypType()=="Deflection1D" )
932 StdMeshers::StdMeshers_Deflection1D_var h =
933 StdMeshers::StdMeshers_Deflection1D::_narrow( hyp );
935 item.myName = tr( "SMESH_DEFLECTION1D_PARAM" );
936 if(!initVariableName(aParameters,item,0))
937 item.myValue = h->GetDeflection();
940 else if( hypType()=="AutomaticLength" )
942 StdMeshers::StdMeshers_AutomaticLength_var h =
943 StdMeshers::StdMeshers_AutomaticLength::_narrow( hyp );
945 item.myName = tr( "SMESH_FINENESS_PARAM" );
946 //item.myValue = h->GetFineness();
948 SMESHGUI_SpinBox* _autoLengthSpinBox = new SMESHGUI_SpinBox(dlg());
949 _autoLengthSpinBox->RangeStepAndValidator(0, 1, 0.01, "length_precision");
950 _autoLengthSpinBox->SetValue(h->GetFineness());
951 customWidgets()->append( _autoLengthSpinBox);
953 else if( hypType()=="NumberOfLayers" )
955 StdMeshers::StdMeshers_NumberOfLayers_var h =
956 StdMeshers::StdMeshers_NumberOfLayers::_narrow( hyp );
958 item.myName = tr( "SMESH_NUMBER_OF_LAYERS" );
959 if(!initVariableName(aParameters,item,0))
960 item.myValue = (int) h->GetNumberOfLayers();
963 else if( hypType()=="LayerDistribution" ) {
964 StdMeshers::StdMeshers_LayerDistribution_var h =
965 StdMeshers::StdMeshers_LayerDistribution::_narrow( hyp );
967 item.myName = tr( "SMESH_LAYERS_DISTRIBUTION" ); p.append( item );
969 //Set into not published hypo last variables
970 QStringList aLastVarsList;
971 for(int i = 0;i<aParameters->length();i++)
972 aLastVarsList.append(QString(aParameters[i].in()));
974 if(!aLastVarsList.isEmpty())
975 h->GetLayerDistribution()->SetLastParameters(aLastVarsList.join(":").toLatin1().constData());
977 customWidgets()->append
978 ( new StdMeshersGUI_LayerDistributionParamWdg( h->GetLayerDistribution(), hypName(), dlg()));
980 else if( hypType()=="NumberOfLayers2D" ) {
981 StdMeshers::StdMeshers_NumberOfLayers2D_var h =
982 StdMeshers::StdMeshers_NumberOfLayers2D::_narrow( hyp );
984 item.myName = tr( "SMESH_NUMBER_OF_LAYERS" );
985 if(!initVariableName(aParameters,item,0))
986 item.myValue = (int) h->GetNumberOfLayers();
989 else if( hypType()=="LayerDistribution2D" ) {
990 StdMeshers::StdMeshers_LayerDistribution2D_var h =
991 StdMeshers::StdMeshers_LayerDistribution2D::_narrow( hyp );
993 item.myName = tr( "SMESH_LAYERS_DISTRIBUTION" ); p.append( item );
995 //Set into not published hypo last variables
996 QStringList aLastVarsList;
997 for(int i = 0;i<aParameters->length();i++)
998 aLastVarsList.append(QString(aParameters[i].in()));
1000 if(!aLastVarsList.isEmpty())
1001 h->GetLayerDistribution()->SetLastParameters(aLastVarsList.join(":").toLatin1().constData());
1003 customWidgets()->append
1004 ( new StdMeshersGUI_LayerDistributionParamWdg( h->GetLayerDistribution(), hypName(), dlg()));
1006 else if( hypType()=="ProjectionSource1D" )
1008 StdMeshers::StdMeshers_ProjectionSource1D_var h =
1009 StdMeshers::StdMeshers_ProjectionSource1D::_narrow( hyp );
1011 item.myName = tr( "SMESH_SOURCE_EDGE" ); p.append( item );
1012 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 1 ),
1013 h->GetSourceEdge()));
1014 item.myName = tr( "SMESH_SOURCE_MESH" ); p.append( item );
1015 customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( MESH ),
1016 h->GetSourceMesh()));
1017 item.myName = tr( "SMESH_SOURCE_VERTEX" ); p.append( item );
1018 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1019 h->GetSourceVertex()));
1020 item.myName = tr( "SMESH_TARGET_VERTEX" ); p.append( item );
1021 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1022 h->GetTargetVertex()));
1024 else if( hypType()=="ProjectionSource2D" )
1026 StdMeshers::StdMeshers_ProjectionSource2D_var h =
1027 StdMeshers::StdMeshers_ProjectionSource2D::_narrow( hyp );
1029 item.myName = tr( "SMESH_SOURCE_FACE" ); p.append( item );
1030 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 2 ),
1031 h->GetSourceFace()));
1032 item.myName = tr( "SMESH_SOURCE_MESH" ); p.append( item );
1033 customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( MESH ),
1034 h->GetSourceMesh()));
1035 item.myName = tr( "SMESH_SOURCE_VERTEX1" ); p.append( item );
1036 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1037 h->GetSourceVertex( 1 )));
1038 item.myName = tr( "SMESH_TARGET_VERTEX1" ); p.append( item );
1039 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1040 h->GetTargetVertex( 1 )));
1041 item.myName = tr( "SMESH_SOURCE_VERTEX2" ); p.append( item );
1042 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1043 h->GetSourceVertex( 2 )));
1044 item.myName = tr( "SMESH_TARGET_VERTEX2" ); p.append( item );
1045 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1046 h->GetTargetVertex( 2 )));
1048 else if( hypType()=="ProjectionSource3D" )
1050 StdMeshers::StdMeshers_ProjectionSource3D_var h =
1051 StdMeshers::StdMeshers_ProjectionSource3D::_narrow( hyp );
1053 item.myName = tr( "SMESH_SOURCE_3DSHAPE" ); p.append( item );
1054 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 3, TopAbs_FACE, 6, true ),
1055 h->GetSource3DShape()));
1056 item.myName = tr( "SMESH_SOURCE_MESH" ); p.append( item );
1057 customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( MESH ),
1058 h->GetSourceMesh()));
1059 item.myName = tr( "SMESH_SOURCE_VERTEX1" ); p.append( item );
1060 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1061 h->GetSourceVertex( 1 )));
1062 item.myName = tr( "SMESH_TARGET_VERTEX1" ); p.append( item );
1063 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1064 h->GetTargetVertex( 1 )));
1065 item.myName = tr( "SMESH_SOURCE_VERTEX2" ); p.append( item );
1066 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1067 h->GetSourceVertex( 2 )));
1068 item.myName = tr( "SMESH_TARGET_VERTEX2" ); p.append( item );
1069 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1070 h->GetTargetVertex( 2 )));
1072 else if( hypType()=="ImportSource1D" )
1074 StdMeshers::StdMeshers_ImportSource1D_var h =
1075 StdMeshers::StdMeshers_ImportSource1D::_narrow( hyp );
1077 SMESH::string_array_var groupEntries = h->GetSourceEdges();
1078 CORBA::Boolean toCopyMesh, toCopyGroups;
1079 h->GetCopySourceMesh(toCopyMesh, toCopyGroups);
1081 item.myName = tr( "SMESH_SOURCE_EDGES" ); p.append( item );
1082 customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( GROUP_EDGE ),
1085 item.myName = tr( "SMESH_COPY_MESH" ); p.append( item );
1086 QCheckBox* aQCheckBox = new QCheckBox(dlg());
1087 aQCheckBox->setChecked( toCopyMesh );
1088 connect( aQCheckBox, SIGNAL( stateChanged(int) ), this, SLOT( onValueChanged() ));
1089 customWidgets()->append( aQCheckBox );
1091 item.myName = tr( "SMESH_TO_COPY_GROUPS" ); p.append( item );
1092 aQCheckBox = new QCheckBox(dlg());
1093 aQCheckBox->setChecked( toCopyGroups );
1094 aQCheckBox->setEnabled( toCopyMesh );
1095 customWidgets()->append( aQCheckBox );
1097 else if( hypType()=="ImportSource2D" )
1099 StdMeshers::StdMeshers_ImportSource2D_var h =
1100 StdMeshers::StdMeshers_ImportSource2D::_narrow( hyp );
1102 SMESH::string_array_var groupEntries = h->GetSourceFaces();
1103 CORBA::Boolean toCopyMesh, toCopyGroups;
1104 h->GetCopySourceMesh(toCopyMesh, toCopyGroups);
1106 item.myName = tr( "SMESH_SOURCE_FACES" ); p.append( item );
1107 customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( GROUP_FACE ),
1110 item.myName = tr( "SMESH_COPY_MESH" ); p.append( item );
1111 QCheckBox* aQCheckBox = new QCheckBox(dlg());
1112 aQCheckBox->setChecked( toCopyMesh );
1113 connect( aQCheckBox, SIGNAL( stateChanged(int) ), this, SLOT( onValueChanged() ));
1114 customWidgets()->append( aQCheckBox );
1116 item.myName = tr( "SMESH_COPY_GROUPS" ); p.append( item );
1117 aQCheckBox = new QCheckBox(dlg());
1118 aQCheckBox->setChecked( toCopyGroups );
1119 aQCheckBox->setEnabled( toCopyMesh );
1120 customWidgets()->append( aQCheckBox );
1122 else if( hypType()=="ViscousLayers" )
1124 StdMeshers::StdMeshers_ViscousLayers_var h =
1125 StdMeshers::StdMeshers_ViscousLayers::_narrow( hyp );
1127 item.myName = tr( "SMESH_TOTAL_THICKNESS" );
1128 if(!initVariableName(aParameters,item,0))
1129 item.myValue = h->GetTotalThickness();
1131 customWidgets()->append (0);
1133 item.myName = tr( "SMESH_NUMBER_OF_LAYERS" );
1134 if(!initVariableName(aParameters,item,1))
1135 item.myValue = h->GetNumberLayers();
1137 customWidgets()->append (0);
1139 item.myName = tr( "SMESH_STRETCH_FACTOR" );
1140 if(!initVariableName(aParameters,item,2))
1141 item.myValue = h->GetStretchFactor();
1143 customWidgets()->append (0);
1145 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
1146 if ( !aMainEntry.isEmpty() )
1148 item.myName = tr( "SMESH_FACES_WO_LAYERS" );
1151 StdMeshersGUI_SubShapeSelectorWdg* idsWg =
1152 new StdMeshersGUI_SubShapeSelectorWdg(0,TopAbs_FACE);
1154 idsWg->SetGeomShapeEntry( aMainEntry );
1155 idsWg->SetMainShapeEntry( aMainEntry );
1156 idsWg->SetListOfIDs( h->GetIgnoreFaces() );
1157 idsWg->showPreview( true );
1158 customWidgets()->append ( idsWg );
1161 else if (hypType() == "QuadrangleParams")
1163 StdMeshers::StdMeshers_QuadrangleParams_var h =
1164 StdMeshers::StdMeshers_QuadrangleParams::_narrow(hyp);
1166 item.myName = tr("SMESH_BASE_VERTEX");
1169 StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget =
1170 new StdMeshersGUI_SubShapeSelectorWdg(0, TopAbs_VERTEX);
1171 aDirectionWidget->SetMaxSize(1);
1172 QString anEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
1173 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
1175 anEntry = h->GetObjectEntry();
1176 aDirectionWidget->SetGeomShapeEntry(anEntry);
1177 aDirectionWidget->SetMainShapeEntry(aMainEntry);
1178 if (!isCreation()) {
1179 SMESH::long_array_var aVec = new SMESH::long_array;
1180 int vertID = h->GetTriaVertex();
1184 aDirectionWidget->SetListOfIDs(aVec);
1187 aDirectionWidget->showPreview(true);
1189 item.myName = tr("SMESH_QUAD_TYPE");
1192 StdMeshersGUI_QuadrangleParamWdg* aTypeWidget =
1193 new StdMeshersGUI_QuadrangleParamWdg();
1194 if (!isCreation()) {
1195 aTypeWidget->SetType(int(h->GetQuadType()));
1198 customWidgets()->append(aDirectionWidget);
1199 customWidgets()->append(aTypeWidget);
1206 //================================================================================
1208 * \brief tune "standard" control
1209 * \param w - control widget
1210 * \param int - parameter index
1212 //================================================================================
1214 void StdMeshersGUI_StdHypothesisCreator::attuneStdWidget (QWidget* w, const int) const
1216 SMESHGUI_SpinBox* sb = w->inherits( "SMESHGUI_SpinBox" ) ? ( SMESHGUI_SpinBox* )w : 0;
1219 if( hypType()=="LocalLength" )
1221 if (sb->objectName() == tr("SMESH_LOCAL_LENGTH_PARAM"))
1222 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1223 else if (sb->objectName() == tr("SMESH_LOCAL_LENGTH_PRECISION"))
1224 sb->RangeStepAndValidator( 0.0, 1.0, 0.05, "len_tol_precision" );
1226 else if( hypType()=="Arithmetic1D" )
1228 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "parametric_precision" );
1230 else if( hypType()=="MaxLength" )
1232 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1233 sb->setEnabled( !widget< QCheckBox >( 1 )->isChecked() );
1235 else if( hypType()=="MaxElementArea" )
1237 sb->RangeStepAndValidator( VALUE_SMALL_2, VALUE_MAX_2, 1.0, "area_precision" );
1239 else if( hypType()=="MaxElementVolume" )
1241 sb->RangeStepAndValidator( VALUE_SMALL_3, VALUE_MAX_3, 1.0, "vol_precision" );
1243 else if( hypType()=="StartEndLength" )
1245 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1247 else if( hypType()=="Deflection1D" )
1249 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "parametric_precision" );
1251 else if( hypType()=="ViscousLayers" )
1253 if (sb->objectName() == tr("SMESH_STRETCH_FACTOR"))
1254 sb->RangeStepAndValidator( 1.0, VALUE_MAX, 0.1, "parametric_precision" );
1256 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1258 else // default validator for possible ancestors
1260 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1263 // else if ( QtxIntSpinBox* ib = w->inherits( "QtxIntSpinBox" ) ? ( QtxIntSpinBox* )w : 0)
1265 // if( hypType()=="ViscousLayers" )
1271 //================================================================================
1273 * \brief Return dlg title
1274 * \retval QString - title string
1276 //================================================================================
1278 QString StdMeshersGUI_StdHypothesisCreator::caption() const
1280 return tr( QString( "SMESH_%1_TITLE" ).arg( hypTypeName( hypType() ) ).toLatin1().data() );
1283 //================================================================================
1285 * \brief return pixmap for dlg icon
1288 //================================================================================
1290 QPixmap StdMeshersGUI_StdHypothesisCreator::icon() const
1292 QString hypIconName = tr( QString( "ICON_DLG_%1" ).arg( hypTypeName( hypType() ) ).toLatin1().data() );
1293 return SMESHGUI::resourceMgr()->loadPixmap( "SMESH", hypIconName );
1296 //================================================================================
1298 * \brief Return hypothesis type name to show in dlg
1301 //================================================================================
1303 QString StdMeshersGUI_StdHypothesisCreator::type() const
1305 return tr( QString( "SMESH_%1_HYPOTHESIS" ).arg( hypTypeName( hypType() ) ).toLatin1().data() );
1308 //================================================================================
1310 * \brief String to insert in "SMESH_%1_HYPOTHESIS" to get hypothesis type name
1311 * from message resouce file
1312 * \param t - hypothesis type
1313 * \retval QString - result string
1315 //================================================================================
1317 QString StdMeshersGUI_StdHypothesisCreator::hypTypeName( const QString& t ) const
1319 static QMap<QString,QString> types;
1320 if( types.isEmpty() )
1322 types.insert( "LocalLength", "LOCAL_LENGTH" );
1323 types.insert( "NumberOfSegments", "NB_SEGMENTS" );
1324 types.insert( "MaxElementArea", "MAX_ELEMENT_AREA" );
1325 types.insert( "MaxElementVolume", "MAX_ELEMENT_VOLUME" );
1326 types.insert( "StartEndLength", "START_END_LENGTH" );
1327 types.insert( "Deflection1D", "DEFLECTION1D" );
1328 types.insert( "Arithmetic1D", "ARITHMETIC_1D" );
1329 types.insert( "FixedPoints1D", "FIXED_POINTS_1D" );
1330 types.insert( "AutomaticLength", "AUTOMATIC_LENGTH" );
1331 types.insert( "ProjectionSource1D", "PROJECTION_SOURCE_1D" );
1332 types.insert( "ProjectionSource2D", "PROJECTION_SOURCE_2D" );
1333 types.insert( "ProjectionSource3D", "PROJECTION_SOURCE_3D" );
1334 types.insert( "ImportSource1D", "IMPORT_SOURCE_1D" );
1335 types.insert( "ImportSource2D", "IMPORT_SOURCE_2D" );
1336 types.insert( "NumberOfLayers", "NUMBER_OF_LAYERS" );
1337 types.insert( "LayerDistribution", "LAYER_DISTRIBUTION" );
1338 types.insert( "NumberOfLayers2D", "NUMBER_OF_LAYERS_2D" );
1339 types.insert( "LayerDistribution2D", "LAYER_DISTRIBUTION" );
1340 types.insert( "SegmentLengthAroundVertex", "SEGMENT_LENGTH_AROUND_VERTEX" );
1341 types.insert( "MaxLength", "MAX_LENGTH" );
1342 types.insert( "ViscousLayers", "VISCOUS_LAYERS" );
1343 types.insert( "QuadrangleParams", "QUADRANGLE_PARAMS" );
1344 types.insert( "CartesianParameters3D", "CARTESIAN_PARAMS" );
1348 if( types.contains( t ) )
1355 //=======================================================================
1356 //function : getCustomWidget
1357 //purpose : is called from buildStdFrame()
1358 //=======================================================================
1360 QWidget* StdMeshersGUI_StdHypothesisCreator::getCustomWidget( const StdParam & param,
1362 const int index) const
1365 if ( index < customWidgets()->count() ) {
1366 w = customWidgets()->at( index );
1368 w->setParent( parent );
1369 w->move( QPoint( 0, 0 ) );
1375 //================================================================================
1377 * \brief Set param value taken from a custom widget
1378 * \param param - SMESHGUI_GenericHypothesisCreator::StdParam structure
1379 * \param widget - widget presenting param
1380 * \retval bool - success flag
1382 * this method is called from getStdParamFromDlg()
1384 //================================================================================
1386 bool StdMeshersGUI_StdHypothesisCreator::getParamFromCustomWidget( StdParam & param,
1387 QWidget* widget) const
1389 if ( hypType()=="AutomaticLength" ) {
1390 SMESHGUI_SpinBox* w = dynamic_cast<SMESHGUI_SpinBox*>( widget );
1392 param.myValue = w->GetValue();
1396 if ( hypType() == "MaxLength" ) {
1400 if ( widget->inherits( "StdMeshersGUI_ObjectReferenceParamWdg" ))
1402 // show only 1st reference value
1403 if ( true /*widget == getWidgetForParam( 0 )*/) {
1404 const StdMeshersGUI_ObjectReferenceParamWdg * w =
1405 static_cast<const StdMeshersGUI_ObjectReferenceParamWdg*>( widget );
1406 param.myValue = w->GetValue();
1410 if ( widget->inherits( "StdMeshersGUI_LayerDistributionParamWdg" ))
1412 const StdMeshersGUI_LayerDistributionParamWdg * w =
1413 static_cast<const StdMeshersGUI_LayerDistributionParamWdg*>( widget );
1414 param.myValue = w->GetValue();
1417 if ( widget->inherits( "StdMeshersGUI_SubShapeSelectorWdg" ))
1419 const StdMeshersGUI_SubShapeSelectorWdg * w =
1420 static_cast<const StdMeshersGUI_SubShapeSelectorWdg*>( widget );
1421 param.myValue = w->GetValue();
1424 if ( widget->inherits( "StdMeshersGUI_QuadrangleParamWdg" ))
1426 //const StdMeshersGUI_QuadrangleParamWdg * w =
1427 // static_cast<const StdMeshersGUI_QuadrangleParamWdg*>( widget );
1428 param.myValue = "QuadType";
1431 if ( widget->inherits( "StdMeshersGUI_FixedPointsParamWdg" ))
1433 const StdMeshersGUI_FixedPointsParamWdg * w =
1434 static_cast<const StdMeshersGUI_FixedPointsParamWdg*>( widget );
1435 param.myValue = w->GetValue();
1438 if ( widget->inherits( "QCheckBox" ))
1440 //const QCheckBox * w = static_cast<const QCheckBox*>( widget );
1441 //param.myValue = w->isChecked();
1447 //================================================================================
1449 * \brief called when operation cancelled
1451 //================================================================================
1453 void StdMeshersGUI_StdHypothesisCreator::onReject()
1455 if ( hypType().startsWith("ProjectionSource" ) ||
1456 hypType().startsWith("ImportSource" ))
1458 // Uninstall filters of StdMeshersGUI_ObjectReferenceParamWdg
1459 deactivateObjRefParamWdg( customWidgets() );
1463 //================================================================================
1465 * \brief Update widgets dependent on paramWidget
1467 //================================================================================
1469 void StdMeshersGUI_StdHypothesisCreator::valueChanged( QWidget* paramWidget)
1471 if ( hypType() == "MaxLength" && paramWidget == getWidgetForParam(1) )
1473 getWidgetForParam(0)->setEnabled( !widget< QCheckBox >( 1 )->isChecked() );
1474 if ( !getWidgetForParam(0)->isEnabled() ) {
1475 StdMeshers::StdMeshers_MaxLength_var h =
1476 StdMeshers::StdMeshers_MaxLength::_narrow( initParamsHypothesis() );
1477 widget< QtxDoubleSpinBox >( 0 )->setValue( h->GetPreestimatedLength() );
1480 else if ( hypType().startsWith("ImportSource") && paramWidget == getWidgetForParam(1) )
1482 QCheckBox* toCopyMesh = (QCheckBox*) paramWidget;
1483 QCheckBox* toCopyGroups = widget< QCheckBox >( 2 );
1484 if ( !toCopyMesh->isChecked() )
1486 toCopyGroups->setChecked( false );
1487 toCopyGroups->setEnabled( false );
1491 toCopyGroups->setEnabled( true );
1496 //================================================================================
1500 //================================================================================
1502 bool StdMeshersGUI_StdHypothesisCreator::initVariableName(SMESH::ListOfParameters_var theParameters,
1503 StdParam &theParams,
1506 QString aVaribaleName = (theParameters->length() > order) ? QString(theParameters[order].in()) : QString("");
1507 theParams.isVariable = !aVaribaleName.isEmpty();
1508 if(theParams.isVariable)
1509 theParams.myValue = aVaribaleName;
1511 return theParams.isVariable;