1 // Copyright (C) 2007-2013 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>
32 #include <SMESHGUI_GEOMGenUtils.h>
34 #include <SMESH_TypeFilter.hxx>
35 #include <SMESH_NumberFilter.hxx>
37 #include "StdMeshersGUI_FixedPointsParamWdg.h"
38 #include "StdMeshersGUI_LayerDistributionParamWdg.h"
39 #include "StdMeshersGUI_ObjectReferenceParamWdg.h"
40 #include "StdMeshersGUI_QuadrangleParamWdg.h"
41 #include "StdMeshersGUI_SubShapeSelectorWdg.h"
42 #include "StdMeshersGUI_RadioButtonsGrpWdg.h"
44 #include <SALOMEDSClient_Study.hxx>
46 #include <GEOM_wrap.hxx>
48 // SALOME GUI includes
49 #include <SUIT_ResourceMgr.h>
52 #include <SALOMEconfig.h>
53 #include CORBA_SERVER_HEADER(SMESH_BasicHypothesis)
54 #include CORBA_SERVER_HEADER(SMESH_Mesh)
55 #include CORBA_SERVER_HEADER(SMESH_Group)
58 #include <QHBoxLayout>
62 #include <QButtonGroup>
64 const double VALUE_MAX = 1.0e+15, // COORD_MAX
65 VALUE_MAX_2 = VALUE_MAX * VALUE_MAX,
66 VALUE_MAX_3 = VALUE_MAX_2 * VALUE_MAX,
67 VALUE_SMALL = 1.0e-15,
68 VALUE_SMALL_2 = VALUE_SMALL * VALUE_SMALL,
69 VALUE_SMALL_3 = VALUE_SMALL_2 * VALUE_SMALL;
71 //================================================================================
74 * \param type - hypothesis type
76 //================================================================================
78 StdMeshersGUI_StdHypothesisCreator::StdMeshersGUI_StdHypothesisCreator( const QString& type )
79 : SMESHGUI_GenericHypothesisCreator( type )
83 //================================================================================
87 //================================================================================
89 StdMeshersGUI_StdHypothesisCreator::~StdMeshersGUI_StdHypothesisCreator()
93 //================================================================================
95 * \brief Return widget for i-th hypothesis parameter (got from myParamWidgets)
96 * \param i - index of hypothesis parameter
97 * \retval QWidget* - found widget
99 //================================================================================
101 QWidget* StdMeshersGUI_StdHypothesisCreator::getWidgetForParam( int i ) const
104 if ( isCreation() ) ++i; // skip widget of 'name' parameter
106 if ( i < myCustomWidgets.count() ) {
107 QList<QWidget*>::const_iterator anIt = myCustomWidgets.begin();
108 QList<QWidget*>::const_iterator aLast = myCustomWidgets.end();
109 for ( int j = 0 ; !w && anIt != aLast; ++anIt, ++j )
114 // list has no at() const, so we iterate
115 QList<QWidget*>::const_iterator anIt = widgets().begin();
116 QList<QWidget*>::const_iterator aLast = widgets().end();
117 for( int j = 0; !w && anIt!=aLast; anIt++, ++j ) {
125 //================================================================================
127 * \brief Allow modifing myCustomWidgets in const methods
128 * \retval ListOfWidgets* - non-const pointer to myCustomWidgets
130 //================================================================================
132 StdMeshersGUI_StdHypothesisCreator::ListOfWidgets*
133 StdMeshersGUI_StdHypothesisCreator::customWidgets() const
135 return const_cast< ListOfWidgets* >( & myCustomWidgets );
138 //================================================================================
140 * \brief Builds dlg layout
141 * \retval QFrame* - the built widget
143 //================================================================================
145 QFrame* StdMeshersGUI_StdHypothesisCreator::buildFrame()
147 return buildStdFrame();
150 //================================================================================
152 * \brief Initialise parameter values in controls
154 //================================================================================
156 void StdMeshersGUI_StdHypothesisCreator::retrieveParams() const
158 // buildStdFrame() sets values itself calling stdParams()
160 if ( hypType().startsWith("ProjectionSource" ))
162 // we use this method to connect depending custom widgets
163 StdMeshersGUI_ObjectReferenceParamWdg* widgetToActivate = 0;
164 ListOfWidgets::const_iterator anIt = myCustomWidgets.begin();
165 for ( ; anIt != myCustomWidgets.end(); anIt++)
167 if ( *anIt && (*anIt)->inherits("StdMeshersGUI_ObjectReferenceParamWdg"))
169 StdMeshersGUI_ObjectReferenceParamWdg * w1 =
170 ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
171 ListOfWidgets::const_iterator anIt2 = anIt;
172 for ( ++anIt2; anIt2 != myCustomWidgets.end(); anIt2++)
173 if ( *anIt2 && (*anIt2)->inherits("StdMeshersGUI_ObjectReferenceParamWdg"))
175 StdMeshersGUI_ObjectReferenceParamWdg * w2 =
176 ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt2 );
177 w1->AvoidSimultaneousSelection( w2 );
179 if ( !widgetToActivate )
180 widgetToActivate = w1;
183 if ( widgetToActivate )
184 widgetToActivate->activateSelection();
188 dlg()->setMinimumSize( dlg()->minimumSizeHint().width(), dlg()->minimumSizeHint().height() );
193 //================================================================================
195 * \brief Widget: slider with left and right labels
197 //================================================================================
199 class TDoubleSliderWith2Labels: public QWidget
202 TDoubleSliderWith2Labels( const QString& leftLabel, const QString& rightLabel,
203 const double initValue, const double bottom,
204 const double top , const double precision,
205 QWidget * parent=0 , const char * name=0 )
206 :QWidget(parent), _bottom(bottom), _precision(precision)
210 QHBoxLayout* aHBoxL = new QHBoxLayout(this);
212 if ( !leftLabel.isEmpty() ) {
213 QLabel* aLeftLabel = new QLabel( this );
214 aLeftLabel->setText( leftLabel );
215 aHBoxL->addWidget( aLeftLabel );
218 _slider = new QSlider( Qt::Horizontal, this );
219 _slider->setRange( 0, toInt( top ));
220 _slider->setValue( toInt( initValue ));
221 aHBoxL->addWidget( _slider );
223 if ( !rightLabel.isEmpty() ) {
224 QLabel* aRightLabel = new QLabel( this );
225 aRightLabel->setText( rightLabel );
226 aHBoxL->addWidget( aRightLabel );
231 double value() const { return _bottom + _slider->value() * _precision; }
232 QSlider * getSlider() const { return _slider; }
233 int toInt( double val ) const { return (int) ceil(( val - _bottom ) / _precision ); }
235 double _bottom, _precision;
239 //================================================================================
241 * \brief Retrieve GEOM_Object held by widget
243 //================================================================================
245 inline GEOM::GEOM_Object_var geomFromWdg(const QWidget* wdg)
247 const StdMeshersGUI_ObjectReferenceParamWdg * objRefWdg =
248 dynamic_cast<const StdMeshersGUI_ObjectReferenceParamWdg*>( wdg );
250 return objRefWdg->GetObject< GEOM::GEOM_Object >();
252 return GEOM::GEOM_Object::_nil();
254 //================================================================================
256 * \brief Retrieve SMESH_Mesh held by widget
258 //================================================================================
260 inline SMESH::SMESH_Mesh_var meshFromWdg(const QWidget* wdg)
262 const StdMeshersGUI_ObjectReferenceParamWdg * objRefWdg =
263 dynamic_cast<const StdMeshersGUI_ObjectReferenceParamWdg*>( wdg );
265 return objRefWdg->GetObject< SMESH::SMESH_Mesh >();
267 return SMESH::SMESH_Mesh::_nil();
269 //================================================================================
271 * \brief Retrieve SMESH_Mesh held by widget
273 //================================================================================
275 inline SMESH::ListOfGroups_var groupsFromWdg(const QWidget* wdg)
277 SMESH::ListOfGroups_var groups = new SMESH::ListOfGroups;
278 const StdMeshersGUI_ObjectReferenceParamWdg * objRefWdg =
279 dynamic_cast<const StdMeshersGUI_ObjectReferenceParamWdg*>( wdg );
282 groups->length( objRefWdg->NbObjects() );
283 for ( unsigned i = 0; i < groups->length(); ++i )
284 groups[i] = objRefWdg->GetObject< SMESH::SMESH_GroupBase >(i);
288 //================================================================================
290 * \brief creates a filter for selection of shapes of given dimension
291 * \param dim - dimension
292 * \param subShapeType - required type of sub-shapes, number of which must be \a nbSubShapes
293 * \param nbSubShapes - number of sub-shapes of given type
294 * \param closed - required closeness flag of a shape
295 * \retval SUIT_SelectionFilter* - created filter
297 //================================================================================
299 SUIT_SelectionFilter* filterForShapeOfDim(const int dim,
300 TopAbs_ShapeEnum subShapeType = TopAbs_SHAPE,
301 const int nbSubShapes = 0,
304 TColStd_MapOfInteger shapeTypes;
306 case 0: shapeTypes.Add( TopAbs_VERTEX ); break;
308 if ( subShapeType == TopAbs_SHAPE ) subShapeType = TopAbs_EDGE;
309 shapeTypes.Add( TopAbs_EDGE );
310 shapeTypes.Add( TopAbs_COMPOUND ); // for a group
313 if ( subShapeType == TopAbs_SHAPE ) subShapeType = TopAbs_FACE;
314 shapeTypes.Add( TopAbs_FACE );
315 shapeTypes.Add( TopAbs_COMPOUND ); // for a group
318 shapeTypes.Add( TopAbs_SHELL );
319 shapeTypes.Add( TopAbs_SOLID );
320 shapeTypes.Add( TopAbs_COMPSOLID );
321 shapeTypes.Add( TopAbs_COMPOUND );
324 return new SMESH_NumberFilter("GEOM", subShapeType, nbSubShapes,
325 shapeTypes, GEOM::GEOM_Object::_nil(), closed);
328 //================================================================================
330 * \brief Create a widget for object selection
331 * \param object - initial object
332 * \param filter - selection filter
333 * \retval QWidget* - created widget
335 //================================================================================
337 QWidget* newObjRefParamWdg( SUIT_SelectionFilter* filter,
338 CORBA::Object_var object)
340 StdMeshersGUI_ObjectReferenceParamWdg* w =
341 new StdMeshersGUI_ObjectReferenceParamWdg( filter, 0);
342 w->SetObject( object.in() );
345 QWidget* newObjRefParamWdg( SUIT_SelectionFilter* filter,
346 SMESH::string_array_var& objEntries)
348 StdMeshersGUI_ObjectReferenceParamWdg* w =
349 new StdMeshersGUI_ObjectReferenceParamWdg( filter, 0, /*multiSel=*/true);
350 //RNV: Firstly, activate selection, then set objects
351 w->activateSelection();
352 w->SetObjects( objEntries );
356 //================================================================================
358 * \brief calls deactivateSelection() for StdMeshersGUI_ObjectReferenceParamWdg
359 * \param widgetList - list of widgets
361 //================================================================================
363 void deactivateObjRefParamWdg( QList<QWidget*>* widgetList )
365 StdMeshersGUI_ObjectReferenceParamWdg* w = 0;
366 QList<QWidget*>::iterator anIt = widgetList->begin();
367 QList<QWidget*>::iterator aLast = widgetList->end();
368 for ( ; anIt != aLast; anIt++ ) {
369 if ( (*anIt) && (*anIt)->inherits( "StdMeshersGUI_ObjectReferenceParamWdg" ))
371 w = (StdMeshersGUI_ObjectReferenceParamWdg* )( *anIt );
372 w->deactivateSelection();
378 //================================================================================
380 * \brief Check parameter values before accept()
381 * \retval bool - true if OK
383 //================================================================================
385 bool StdMeshersGUI_StdHypothesisCreator::checkParams( QString& msg ) const
387 if( !SMESHGUI_GenericHypothesisCreator::checkParams( msg ) )
390 // check if object reference parameter is set, as it has no default value
392 if ( hypType().startsWith("ProjectionSource" ))
394 StdMeshersGUI_ObjectReferenceParamWdg* w =
395 widget< StdMeshersGUI_ObjectReferenceParamWdg >( 0 );
396 ok = ( w->IsObjectSelected() );
397 if ( !ok ) w->SetObject( CORBA::Object::_nil() );
398 int nbAssocVert = ( hypType() == "ProjectionSource1D" ? 1 : 2 );
399 int nbNonEmptyAssoc = 0;
400 for ( int i = 0; ok && i < nbAssocVert*2; i += 2)
403 StdMeshersGUI_ObjectReferenceParamWdg* w1 =
404 widget< StdMeshersGUI_ObjectReferenceParamWdg >( i+2 );
405 StdMeshersGUI_ObjectReferenceParamWdg* w2 =
406 widget< StdMeshersGUI_ObjectReferenceParamWdg >( i+3 );
407 srcV = w1->GetValue();
408 tgtV = w2->GetValue();
409 ok = (( srcV.isEmpty() && tgtV.isEmpty() ) ||
410 ( !srcV.isEmpty() && !tgtV.isEmpty() && srcV != tgtV ));
412 w1->SetObject( CORBA::Object::_nil() );
413 w2->SetObject( CORBA::Object::_nil() );
415 nbNonEmptyAssoc += !srcV.isEmpty();
417 if ( ok && nbNonEmptyAssoc == 1 && nbAssocVert == 2 )
419 // only one pair of VERTEXes is given for a FACE,
420 // then the FACE must have only one VERTEX
421 GEOM::GEOM_Object_var face = w->GetObject< GEOM::GEOM_Object >();
423 GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen();
424 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
425 GEOM::GEOM_IShapesOperations_wrap shapeOp;
426 if ( !geomGen->_is_nil() && aStudy )
427 shapeOp = geomGen->GetIShapesOperations( aStudy->StudyId() );
428 if ( !shapeOp->_is_nil() )
430 GEOM::ListOfLong_var vertices =
431 shapeOp->GetAllSubShapesIDs (face, GEOM::VERTEX, /*isSorted=*/false);
432 ok = ( vertices->length() == 1 );
435 // Uninstall filters of StdMeshersGUI_ObjectReferenceParamWdg
437 deactivateObjRefParamWdg( customWidgets() );
439 else if ( hypType().startsWith("ImportSource" ))
441 StdMeshersGUI_ObjectReferenceParamWdg* w =
442 widget< StdMeshersGUI_ObjectReferenceParamWdg >( 0 );
443 ok = ( w->IsObjectSelected() );
445 else if ( hypType() == "LayerDistribution" || hypType() == "LayerDistribution2D" )
447 StdMeshersGUI_LayerDistributionParamWdg* w =
448 widget< StdMeshersGUI_LayerDistributionParamWdg >( 0 );
449 ok = ( w && w->IsOk() );
455 //================================================================================
457 * \brief Store params from GUI controls to a hypothesis
458 * \retval QString - text representation of parameters
460 //================================================================================
462 QString StdMeshersGUI_StdHypothesisCreator::storeParams() const
464 ListOfStdParams params;
465 bool res = getStdParamFromDlg( params );
468 SMESH::SetName( SMESH::FindSObject( hypothesis() ), params[0].myValue.toString().toLatin1().data() );
469 params.erase( params.begin() );
472 QString valueStr = stdParamValues( params );
473 //QStringList aVariablesList = getVariablesFromDlg();
475 if( res && !params.isEmpty() )
477 if( hypType()=="LocalLength" )
479 StdMeshers::StdMeshers_LocalLength_var h =
480 StdMeshers::StdMeshers_LocalLength::_narrow( hypothesis() );
482 h->SetVarParameter( params[0].text(), "SetLength" );
483 h->SetLength( params[0].myValue.toDouble() );
484 h->SetVarParameter( params[1].text(), "SetPrecision" );
485 h->SetPrecision( params[1].myValue.toDouble() );
487 else if( hypType()=="MaxLength" )
489 StdMeshers::StdMeshers_MaxLength_var h =
490 StdMeshers::StdMeshers_MaxLength::_narrow( hypothesis() );
492 h->SetVarParameter( params[0].text(), "SetLength" );
493 h->SetLength( params[0].myValue.toDouble() );
494 h->SetUsePreestimatedLength( widget< QCheckBox >( 1 )->isChecked() );
495 if ( !h->HavePreestimatedLength() && !h->_is_equivalent( initParamsHypothesis() )) {
496 StdMeshers::StdMeshers_MaxLength_var hInit =
497 StdMeshers::StdMeshers_MaxLength::_narrow( initParamsHypothesis() );
498 h->SetPreestimatedLength( hInit->GetPreestimatedLength() );
501 else if( hypType()=="SegmentLengthAroundVertex" )
503 StdMeshers::StdMeshers_SegmentLengthAroundVertex_var h =
504 StdMeshers::StdMeshers_SegmentLengthAroundVertex::_narrow( hypothesis() );
506 h->SetVarParameter( params[0].text(), "SetLength" );
507 h->SetLength( params[0].myValue.toDouble() );
509 else if( hypType()=="Arithmetic1D" )
511 StdMeshers::StdMeshers_Arithmetic1D_var h =
512 StdMeshers::StdMeshers_Arithmetic1D::_narrow( hypothesis() );
514 StdMeshersGUI_SubShapeSelectorWdg* w =
515 widget< StdMeshersGUI_SubShapeSelectorWdg >( 2 );
517 h->SetVarParameter( params[0].text(), "SetStartLength" );
518 h->SetStartLength( params[0].myValue.toDouble() );
519 h->SetVarParameter( params[1].text(), "SetEndLength" );
520 h->SetEndLength( params[1].myValue.toDouble() );
522 h->SetReversedEdges( w->GetListOfIDs() );
523 h->SetObjectEntry( w->GetMainShapeEntry() );
526 else if( hypType()=="FixedPoints1D" )
528 StdMeshers::StdMeshers_FixedPoints1D_var h =
529 StdMeshers::StdMeshers_FixedPoints1D::_narrow( hypothesis() );
531 StdMeshersGUI_FixedPointsParamWdg* w1 =
532 widget< StdMeshersGUI_FixedPointsParamWdg >( 0 );
534 StdMeshersGUI_SubShapeSelectorWdg* w2 =
535 widget< StdMeshersGUI_SubShapeSelectorWdg >( 1 );
538 h->SetPoints( w1->GetListOfPoints() );
539 h->SetNbSegments( w1->GetListOfSegments() );
542 h->SetReversedEdges( w2->GetListOfIDs() );
543 h->SetObjectEntry( w2->GetMainShapeEntry() );
546 else if( hypType()=="MaxElementArea" )
548 StdMeshers::StdMeshers_MaxElementArea_var h =
549 StdMeshers::StdMeshers_MaxElementArea::_narrow( hypothesis() );
550 h->SetVarParameter( params[0].text(), "SetMaxElementArea" );
551 h->SetMaxElementArea( params[0].myValue.toDouble() );
553 else if( hypType()=="MaxElementVolume" )
555 StdMeshers::StdMeshers_MaxElementVolume_var h =
556 StdMeshers::StdMeshers_MaxElementVolume::_narrow( hypothesis() );
558 h->SetVarParameter( params[0].text(), "SetMaxElementVolume" );
559 h->SetMaxElementVolume( params[0].myValue.toDouble() );
561 else if( hypType()=="StartEndLength" )
563 StdMeshers::StdMeshers_StartEndLength_var h =
564 StdMeshers::StdMeshers_StartEndLength::_narrow( hypothesis() );
566 StdMeshersGUI_SubShapeSelectorWdg* w =
567 widget< StdMeshersGUI_SubShapeSelectorWdg >( 2 );
569 h->SetVarParameter( params[0].text(), "SetStartLength" );
570 h->SetStartLength( params[0].myValue.toDouble() );
571 h->SetVarParameter( params[1].text(), "SetEndLength" );
572 h->SetEndLength( params[1].myValue.toDouble() );
574 h->SetReversedEdges( w->GetListOfIDs() );
575 h->SetObjectEntry( w->GetMainShapeEntry() );
578 else if( hypType()=="Deflection1D" )
580 StdMeshers::StdMeshers_Deflection1D_var h =
581 StdMeshers::StdMeshers_Deflection1D::_narrow( hypothesis() );
582 h->SetVarParameter( params[0].text(), "SetDeflection" );
583 h->SetDeflection( params[0].myValue.toDouble() );
585 else if( hypType()=="Adaptive1D" )
587 StdMeshers::StdMeshers_Adaptive1D_var h =
588 StdMeshers::StdMeshers_Adaptive1D::_narrow( hypothesis() );
589 h->SetVarParameter( params[0].text(), "SetMinSize" );
590 h->SetMinSize( params[0].myValue.toDouble() );
591 h->SetVarParameter( params[0].text(), "SetMaxSize" );
592 h->SetMaxSize( params[1].myValue.toDouble() );
593 h->SetVarParameter( params[0].text(), "SetDeflection" );
594 h->SetDeflection( params[2].myValue.toDouble() );
596 else if( hypType()=="AutomaticLength" )
598 StdMeshers::StdMeshers_AutomaticLength_var h =
599 StdMeshers::StdMeshers_AutomaticLength::_narrow( hypothesis() );
601 h->SetVarParameter( params[0].text(), "SetFineness" );
602 h->SetFineness( params[0].myValue.toDouble() );
604 else if( hypType()=="NumberOfLayers" )
606 StdMeshers::StdMeshers_NumberOfLayers_var h =
607 StdMeshers::StdMeshers_NumberOfLayers::_narrow( hypothesis() );
609 h->SetVarParameter( params[0].text(), "SetNumberOfLayers" );
610 h->SetNumberOfLayers( params[0].myValue.toInt() );
612 else if( hypType()=="LayerDistribution" )
614 StdMeshers::StdMeshers_LayerDistribution_var h =
615 StdMeshers::StdMeshers_LayerDistribution::_narrow( hypothesis() );
616 StdMeshersGUI_LayerDistributionParamWdg* w =
617 widget< StdMeshersGUI_LayerDistributionParamWdg >( 0 );
619 h->SetLayerDistribution( w->GetHypothesis() );
621 else if( hypType()=="NumberOfLayers2D" )
623 StdMeshers::StdMeshers_NumberOfLayers2D_var h =
624 StdMeshers::StdMeshers_NumberOfLayers2D::_narrow( hypothesis() );
626 h->SetVarParameter( params[0].text(), "SetNumberOfLayers" );
627 h->SetNumberOfLayers( params[0].myValue.toInt() );
629 else if( hypType()=="LayerDistribution2D" )
631 StdMeshers::StdMeshers_LayerDistribution2D_var h =
632 StdMeshers::StdMeshers_LayerDistribution2D::_narrow( hypothesis() );
633 StdMeshersGUI_LayerDistributionParamWdg* w =
634 widget< StdMeshersGUI_LayerDistributionParamWdg >( 0 );
636 h->SetLayerDistribution( w->GetHypothesis() );
638 else if( hypType()=="ProjectionSource1D" )
640 StdMeshers::StdMeshers_ProjectionSource1D_var h =
641 StdMeshers::StdMeshers_ProjectionSource1D::_narrow( hypothesis() );
643 h->SetSourceEdge ( geomFromWdg ( getWidgetForParam( 0 )));
644 h->SetSourceMesh ( meshFromWdg ( getWidgetForParam( 1 )));
645 h->SetVertexAssociation( geomFromWdg ( getWidgetForParam( 2 )),
646 geomFromWdg ( getWidgetForParam( 3 )));
648 else if( hypType()=="ProjectionSource2D" )
650 StdMeshers::StdMeshers_ProjectionSource2D_var h =
651 StdMeshers::StdMeshers_ProjectionSource2D::_narrow( hypothesis() );
653 h->SetSourceFace ( geomFromWdg ( getWidgetForParam( 0 )));
654 h->SetSourceMesh ( meshFromWdg ( getWidgetForParam( 1 )));
655 h->SetVertexAssociation( geomFromWdg ( getWidgetForParam( 2 )), // src1
656 geomFromWdg ( getWidgetForParam( 4 )), // src2
657 geomFromWdg ( getWidgetForParam( 3 )), // tgt1
658 geomFromWdg ( getWidgetForParam( 5 ))); // tgt2
660 else if( hypType()=="ProjectionSource3D" )
662 StdMeshers::StdMeshers_ProjectionSource3D_var h =
663 StdMeshers::StdMeshers_ProjectionSource3D::_narrow( hypothesis() );
665 h->SetSource3DShape ( geomFromWdg ( getWidgetForParam( 0 )));
666 h->SetSourceMesh ( meshFromWdg ( getWidgetForParam( 1 )));
667 h->SetVertexAssociation( geomFromWdg ( getWidgetForParam( 2 )), // src1
668 geomFromWdg ( getWidgetForParam( 4 )), // src2
669 geomFromWdg ( getWidgetForParam( 3 )), // tgt1
670 geomFromWdg ( getWidgetForParam( 5 ))); // tgt2
672 else if( hypType()=="ImportSource1D" )
674 StdMeshers::StdMeshers_ImportSource1D_var h =
675 StdMeshers::StdMeshers_ImportSource1D::_narrow( hypothesis() );
677 SMESH::ListOfGroups_var groups = groupsFromWdg( getWidgetForParam( 0 ));
678 h->SetSourceEdges( groups.in() );
679 QCheckBox* toCopyMesh = widget< QCheckBox >( 1 );
680 QCheckBox* toCopyGroups = widget< QCheckBox >( 2 );
681 h->SetCopySourceMesh( toCopyMesh->isChecked(), toCopyGroups->isChecked());
683 else if( hypType()=="ImportSource2D" )
685 StdMeshers::StdMeshers_ImportSource2D_var h =
686 StdMeshers::StdMeshers_ImportSource2D::_narrow( hypothesis() );
688 SMESH::ListOfGroups_var groups = groupsFromWdg( getWidgetForParam( 0 ));
689 h->SetSourceFaces( groups.in() );
690 QCheckBox* toCopyMesh = widget< QCheckBox >( 1 );
691 QCheckBox* toCopyGroups = widget< QCheckBox >( 2 );
692 h->SetCopySourceMesh( toCopyMesh->isChecked(), toCopyGroups->isChecked());
694 else if( hypType()=="ViscousLayers" )
696 StdMeshers::StdMeshers_ViscousLayers_var h =
697 StdMeshers::StdMeshers_ViscousLayers::_narrow( hypothesis() );
699 h->SetVarParameter( params[0].text(), "SetTotalThickness" );
700 h->SetTotalThickness( params[0].myValue.toDouble() );
701 h->SetVarParameter( params[1].text(), "SetNumberLayers" );
702 h->SetNumberLayers ( params[1].myValue.toInt() );
703 h->SetVarParameter( params[2].text(), "SetStretchFactor" );
704 h->SetStretchFactor ( params[2].myValue.toDouble() );
706 if ( StdMeshersGUI_SubShapeSelectorWdg* idsWg =
707 widget< StdMeshersGUI_SubShapeSelectorWdg >( 3 ))
709 h->SetIgnoreFaces( idsWg->GetListOfIDs() );
712 else if( hypType()=="ViscousLayers2D" )
714 StdMeshers::StdMeshers_ViscousLayers2D_var h =
715 StdMeshers::StdMeshers_ViscousLayers2D::_narrow( hypothesis() );
717 h->SetVarParameter( params[0].text(), "SetTotalThickness" );
718 h->SetTotalThickness( params[0].myValue.toDouble() );
719 h->SetVarParameter( params[1].text(), "SetNumberLayers" );
720 h->SetNumberLayers ( params[1].myValue.toInt() );
721 h->SetVarParameter( params[2].text(), "SetStretchFactor" );
722 h->SetStretchFactor ( params[2].myValue.toDouble() );
724 if ( StdMeshersGUI_SubShapeSelectorWdg* idsWg =
725 widget< StdMeshersGUI_SubShapeSelectorWdg >( 4 ))
727 h->SetEdges( idsWg->GetListOfIDs(), params[3].myValue.toInt() );
730 else if( hypType()=="QuadrangleParams" )
732 StdMeshers::StdMeshers_QuadrangleParams_var h =
733 StdMeshers::StdMeshers_QuadrangleParams::_narrow( hypothesis() );
734 StdMeshersGUI_SubShapeSelectorWdg* w1 =
735 widget< StdMeshersGUI_SubShapeSelectorWdg >( 0 );
736 StdMeshersGUI_QuadrangleParamWdg* w2 =
737 widget< StdMeshersGUI_QuadrangleParamWdg >( 1 );
739 if (w1->GetListSize() > 0) {
740 h->SetTriaVertex(w1->GetListOfIDs()[0]); // getlist must be called once
741 const char * entry = w1->GetMainShapeEntry();
742 h->SetObjectEntry(entry);
744 h->SetQuadType(StdMeshers::QuadType(w2->GetType()));
751 //================================================================================
753 * \brief Return parameter values as SMESHGUI_GenericHypothesisCreator::StdParam
754 * \param p - list of parameters
755 * \retval bool - success flag
757 * Is called from SMESHGUI_GenericHypothesisCreator::buildStdFrame().
758 * Parameters will be shown using "standard" controls:
759 * Int by QtxIntSpinBox
760 * Double by SMESHGUI_SpinBox
761 * String by QLineEdit
762 * getCustomWidget() allows to redefine control for a parameter
764 //================================================================================
766 bool StdMeshersGUI_StdHypothesisCreator::stdParams( ListOfStdParams& p ) const
769 SMESHGUI_GenericHypothesisCreator::StdParam item;
772 customWidgets()->clear();
775 HypothesisData* data = SMESH::GetHypothesisData( hypType() );
776 item.myName = tr( "SMESH_NAME" );
777 item.myValue = data ? hypName() : QString();
779 customWidgets()->append(0);
782 SMESH::SMESH_Hypothesis_var hyp = initParamsHypothesis();
783 //SMESH::ListOfParameters_var aParameters = hyp->GetLastParameters();
785 if( hypType()=="LocalLength" )
787 StdMeshers::StdMeshers_LocalLength_var h =
788 StdMeshers::StdMeshers_LocalLength::_narrow( hyp );
790 item.myName = tr("SMESH_LOCAL_LENGTH_PARAM");
791 if(!initVariableName( hyp, item, "SetLength"))
792 item.myValue = h->GetLength();
795 item.myName = tr("SMESH_LOCAL_LENGTH_PRECISION");
796 if(!initVariableName( hyp, item, "SetPrecision"))
797 item.myValue = h->GetPrecision();
800 else if( hypType()=="MaxLength" )
802 StdMeshers::StdMeshers_MaxLength_var h =
803 StdMeshers::StdMeshers_MaxLength::_narrow( hyp );
804 // try to set a right preestimated length to edited hypothesis
805 bool noPreestimatedAtEdition = false;
806 if ( !isCreation() ) {
807 StdMeshers::StdMeshers_MaxLength_var initHyp =
808 StdMeshers::StdMeshers_MaxLength::_narrow( initParamsHypothesis(true) );
809 noPreestimatedAtEdition =
810 ( initHyp->_is_nil() || !initHyp->HavePreestimatedLength() );
811 if ( !noPreestimatedAtEdition )
812 h->SetPreestimatedLength( initHyp->GetPreestimatedLength() );
815 item.myName = tr("SMESH_LOCAL_LENGTH_PARAM");
816 if(!initVariableName( hyp, item, "SetLength"))
817 item.myValue = h->GetLength();
819 customWidgets()->append(0);
821 item.myName = tr("SMESH_USE_PREESTIMATED_LENGTH");
823 QCheckBox* aQCheckBox = new QCheckBox(dlg());
824 if ( !noPreestimatedAtEdition && h->HavePreestimatedLength() ) {
825 aQCheckBox->setChecked( h->GetUsePreestimatedLength() );
826 connect( aQCheckBox, SIGNAL( stateChanged(int) ), this, SLOT( onValueChanged() ) );
829 aQCheckBox->setChecked( false );
830 aQCheckBox->setEnabled( false );
832 customWidgets()->append( aQCheckBox );
834 else if( hypType()=="SegmentLengthAroundVertex" )
836 StdMeshers::StdMeshers_SegmentLengthAroundVertex_var h =
837 StdMeshers::StdMeshers_SegmentLengthAroundVertex::_narrow( hyp );
839 item.myName = tr("SMESH_LOCAL_LENGTH_PARAM");
840 if(!initVariableName( hyp, item, "SetLength"))
841 item.myValue = h->GetLength();
845 else if( hypType()=="Arithmetic1D" )
847 StdMeshers::StdMeshers_Arithmetic1D_var h =
848 StdMeshers::StdMeshers_Arithmetic1D::_narrow( hyp );
850 item.myName = tr( "SMESH_START_LENGTH_PARAM" );
851 if(!initVariableName( hyp, item, "SetStartLength" ))
852 item.myValue = h->GetLength( true );
855 customWidgets()->append (0);
857 item.myName = tr( "SMESH_END_LENGTH_PARAM" );
858 if(!initVariableName( hyp, item, "SetEndLength" ))
859 item.myValue = h->GetLength( false );
862 customWidgets()->append (0);
864 item.myName = tr( "SMESH_REVERSED_EDGES" );
867 StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget =
868 new StdMeshersGUI_SubShapeSelectorWdg();
869 QString aGeomEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
870 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
871 if ( aGeomEntry == "" )
872 aGeomEntry = h->GetObjectEntry();
874 aDirectionWidget->SetGeomShapeEntry( aGeomEntry );
875 aDirectionWidget->SetMainShapeEntry( aMainEntry );
876 aDirectionWidget->SetListOfIDs( h->GetReversedEdges() );
877 aDirectionWidget->showPreview( true );
878 customWidgets()->append ( aDirectionWidget );
882 else if( hypType()=="FixedPoints1D" )
884 StdMeshers::StdMeshers_FixedPoints1D_var h =
885 StdMeshers::StdMeshers_FixedPoints1D::_narrow( hyp );
887 item.myName = tr( "SMESH_FIXED_POINTS" );
890 StdMeshersGUI_FixedPointsParamWdg* aFixedPointsWidget =
891 new StdMeshersGUI_FixedPointsParamWdg();
893 if ( !isCreation() ) {
894 aFixedPointsWidget->SetListOfPoints( h->GetPoints() );
895 aFixedPointsWidget->SetListOfSegments( h->GetNbSegments() );
897 customWidgets()->append( aFixedPointsWidget );
899 item.myName = tr( "SMESH_REVERSED_EDGES" );
902 StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget =
903 new StdMeshersGUI_SubShapeSelectorWdg();
904 QString anEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
905 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
907 anEntry = h->GetObjectEntry();
908 aDirectionWidget->SetGeomShapeEntry( anEntry );
909 aDirectionWidget->SetMainShapeEntry( aMainEntry );
910 aDirectionWidget->SetListOfIDs( h->GetReversedEdges() );
911 aDirectionWidget->showPreview( true );
912 customWidgets()->append ( aDirectionWidget );
916 else if( hypType()=="MaxElementArea" )
918 StdMeshers::StdMeshers_MaxElementArea_var h =
919 StdMeshers::StdMeshers_MaxElementArea::_narrow( hyp );
921 item.myName = tr( "SMESH_MAX_ELEMENT_AREA_PARAM" );
922 if(!initVariableName( hyp, item, "SetMaxElementArea" ))
923 item.myValue = h->GetMaxElementArea();
927 else if( hypType()=="MaxElementVolume" )
929 StdMeshers::StdMeshers_MaxElementVolume_var h =
930 StdMeshers::StdMeshers_MaxElementVolume::_narrow( hyp );
932 item.myName = tr( "SMESH_MAX_ELEMENT_VOLUME_PARAM" );
933 if(!initVariableName( hyp, item, "SetMaxElementVolume" ))
934 item.myValue = h->GetMaxElementVolume();
937 else if( hypType()=="StartEndLength" )
939 StdMeshers::StdMeshers_StartEndLength_var h =
940 StdMeshers::StdMeshers_StartEndLength::_narrow( hyp );
942 item.myName = tr( "SMESH_START_LENGTH_PARAM" );
944 if(!initVariableName( hyp, item, "SetStartLength" ))
945 item.myValue = h->GetLength( true );
947 customWidgets()->append(0);
949 item.myName = tr( "SMESH_END_LENGTH_PARAM" );
950 if(!initVariableName( hyp, item, "SetEndLength" ))
951 item.myValue = h->GetLength( false );
953 customWidgets()->append(0);
955 item.myName = tr( "SMESH_REVERSED_EDGES" );
958 StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget =
959 new StdMeshersGUI_SubShapeSelectorWdg();
960 QString anEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
961 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
963 anEntry = h->GetObjectEntry();
964 aDirectionWidget->SetGeomShapeEntry( anEntry );
965 aDirectionWidget->SetMainShapeEntry( aMainEntry );
966 aDirectionWidget->SetListOfIDs( h->GetReversedEdges() );
967 aDirectionWidget->showPreview( true );
968 customWidgets()->append ( aDirectionWidget );
970 else if( hypType()=="Deflection1D" )
972 StdMeshers::StdMeshers_Deflection1D_var h =
973 StdMeshers::StdMeshers_Deflection1D::_narrow( hyp );
975 item.myName = tr( "SMESH_DEFLECTION1D_PARAM" );
976 if(!initVariableName( hyp, item, "SetDeflection" ))
977 item.myValue = h->GetDeflection();
980 else if( hypType()=="Adaptive1D" )
982 StdMeshers::StdMeshers_Adaptive1D_var h =
983 StdMeshers::StdMeshers_Adaptive1D::_narrow( hyp );
985 item.myName = tr( "SMESH_MIN_SIZE" );
986 if(!initVariableName( hyp, item, "SetMinSize" ))
987 item.myValue = h->GetMinSize();
990 item.myName = tr( "SMESH_MAX_SIZE" );
991 if(!initVariableName( hyp, item, "SetMaxSize" ))
992 item.myValue = h->GetMaxSize();
995 item.myName = tr( "SMESH_DEFLECTION1D_PARAM" );
996 if(!initVariableName( hyp, item, "SetDeflection" ))
997 item.myValue = h->GetDeflection();
1000 else if( hypType()=="AutomaticLength" )
1002 StdMeshers::StdMeshers_AutomaticLength_var h =
1003 StdMeshers::StdMeshers_AutomaticLength::_narrow( hyp );
1005 item.myName = tr( "SMESH_FINENESS_PARAM" );
1006 //item.myValue = h->GetFineness();
1008 SMESHGUI_SpinBox* _autoLengthSpinBox = new SMESHGUI_SpinBox(dlg());
1009 _autoLengthSpinBox->RangeStepAndValidator(0, 1, 0.01, "length_precision");
1010 _autoLengthSpinBox->SetValue(h->GetFineness());
1011 customWidgets()->append( _autoLengthSpinBox);
1013 else if( hypType()=="NumberOfLayers" )
1015 StdMeshers::StdMeshers_NumberOfLayers_var h =
1016 StdMeshers::StdMeshers_NumberOfLayers::_narrow( hyp );
1018 item.myName = tr( "SMESH_NUMBER_OF_LAYERS" );
1019 if(!initVariableName( hyp, item, "SetNumberOfLayers" ))
1020 item.myValue = (int) h->GetNumberOfLayers();
1023 else if( hypType()=="LayerDistribution" )
1025 StdMeshers::StdMeshers_LayerDistribution_var h =
1026 StdMeshers::StdMeshers_LayerDistribution::_narrow( hyp );
1028 item.myName = tr( "SMESH_LAYERS_DISTRIBUTION" ); p.append( item );
1029 initVariableName( hyp, item, "SetLayerDistribution" );
1030 customWidgets()->append ( new StdMeshersGUI_LayerDistributionParamWdg
1031 ( h, h->GetLayerDistribution(), hypName(), dlg() ));
1033 else if( hypType()=="NumberOfLayers2D" )
1035 StdMeshers::StdMeshers_NumberOfLayers2D_var h =
1036 StdMeshers::StdMeshers_NumberOfLayers2D::_narrow( hyp );
1038 item.myName = tr( "SMESH_NUMBER_OF_LAYERS" );
1039 if(!initVariableName( hyp, item, "SetNumberOfLayers" ))
1040 item.myValue = (int) h->GetNumberOfLayers();
1043 else if( hypType()=="LayerDistribution2D" )
1045 StdMeshers::StdMeshers_LayerDistribution2D_var h =
1046 StdMeshers::StdMeshers_LayerDistribution2D::_narrow( hyp );
1048 item.myName = tr( "SMESH_LAYERS_DISTRIBUTION" ); p.append( item );
1049 initVariableName( hyp, item, "SetLayerDistribution" );
1050 customWidgets()->append ( new StdMeshersGUI_LayerDistributionParamWdg
1051 ( h, h->GetLayerDistribution(), hypName(), dlg() ));
1053 else if( hypType()=="ProjectionSource1D" )
1055 StdMeshers::StdMeshers_ProjectionSource1D_var h =
1056 StdMeshers::StdMeshers_ProjectionSource1D::_narrow( hyp );
1058 item.myName = tr( "SMESH_SOURCE_EDGE" ); p.append( item );
1059 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 1 ),
1060 h->GetSourceEdge()));
1061 item.myName = tr( "SMESH_SOURCE_MESH" ); p.append( item );
1062 customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( SMESH::MESH ),
1063 h->GetSourceMesh()));
1064 item.myName = tr( "SMESH_SOURCE_VERTEX" ); p.append( item );
1065 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1066 h->GetSourceVertex()));
1067 item.myName = tr( "SMESH_TARGET_VERTEX" ); p.append( item );
1068 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1069 h->GetTargetVertex()));
1071 else if( hypType()=="ProjectionSource2D" )
1073 StdMeshers::StdMeshers_ProjectionSource2D_var h =
1074 StdMeshers::StdMeshers_ProjectionSource2D::_narrow( hyp );
1076 item.myName = tr( "SMESH_SOURCE_FACE" ); p.append( item );
1077 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 2 ),
1078 h->GetSourceFace()));
1079 item.myName = tr( "SMESH_SOURCE_MESH" ); p.append( item );
1080 customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( SMESH::MESH ),
1081 h->GetSourceMesh()));
1082 item.myName = tr( "SMESH_SOURCE_VERTEX1" ); p.append( item );
1083 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1084 h->GetSourceVertex( 1 )));
1085 item.myName = tr( "SMESH_TARGET_VERTEX1" ); p.append( item );
1086 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1087 h->GetTargetVertex( 1 )));
1088 item.myName = tr( "SMESH_SOURCE_VERTEX2" ); p.append( item );
1089 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1090 h->GetSourceVertex( 2 )));
1091 item.myName = tr( "SMESH_TARGET_VERTEX2" ); p.append( item );
1092 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1093 h->GetTargetVertex( 2 )));
1095 else if( hypType()=="ProjectionSource3D" )
1097 StdMeshers::StdMeshers_ProjectionSource3D_var h =
1098 StdMeshers::StdMeshers_ProjectionSource3D::_narrow( hyp );
1100 item.myName = tr( "SMESH_SOURCE_3DSHAPE" ); p.append( item );
1101 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 3, TopAbs_FACE, 6, true ),
1102 h->GetSource3DShape()));
1103 item.myName = tr( "SMESH_SOURCE_MESH" ); p.append( item );
1104 customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( SMESH::MESH ),
1105 h->GetSourceMesh()));
1106 item.myName = tr( "SMESH_SOURCE_VERTEX1" ); p.append( item );
1107 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1108 h->GetSourceVertex( 1 )));
1109 item.myName = tr( "SMESH_TARGET_VERTEX1" ); p.append( item );
1110 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1111 h->GetTargetVertex( 1 )));
1112 item.myName = tr( "SMESH_SOURCE_VERTEX2" ); p.append( item );
1113 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1114 h->GetSourceVertex( 2 )));
1115 item.myName = tr( "SMESH_TARGET_VERTEX2" ); p.append( item );
1116 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1117 h->GetTargetVertex( 2 )));
1119 else if( hypType()=="ImportSource1D" )
1121 StdMeshers::StdMeshers_ImportSource1D_var h =
1122 StdMeshers::StdMeshers_ImportSource1D::_narrow( hyp );
1124 SMESH::string_array_var groupEntries = h->GetSourceEdges();
1125 CORBA::Boolean toCopyMesh, toCopyGroups;
1126 h->GetCopySourceMesh(toCopyMesh, toCopyGroups);
1128 item.myName = tr( "SMESH_SOURCE_EDGES" ); p.append( item );
1129 customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( SMESH::GROUP_EDGE ),
1132 item.myName = tr( "SMESH_COPY_MESH" ); p.append( item );
1133 QCheckBox* aQCheckBox = new QCheckBox(dlg());
1134 aQCheckBox->setChecked( toCopyMesh );
1135 connect( aQCheckBox, SIGNAL( stateChanged(int) ), this, SLOT( onValueChanged() ));
1136 customWidgets()->append( aQCheckBox );
1138 item.myName = tr( "SMESH_TO_COPY_GROUPS" ); p.append( item );
1139 aQCheckBox = new QCheckBox(dlg());
1140 aQCheckBox->setChecked( toCopyGroups );
1141 aQCheckBox->setEnabled( toCopyMesh );
1142 customWidgets()->append( aQCheckBox );
1144 else if( hypType()=="ImportSource2D" )
1146 StdMeshers::StdMeshers_ImportSource2D_var h =
1147 StdMeshers::StdMeshers_ImportSource2D::_narrow( hyp );
1149 SMESH::string_array_var groupEntries = h->GetSourceFaces();
1150 CORBA::Boolean toCopyMesh, toCopyGroups;
1151 h->GetCopySourceMesh(toCopyMesh, toCopyGroups);
1153 item.myName = tr( "SMESH_SOURCE_FACES" ); p.append( item );
1154 customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( SMESH::GROUP_FACE ),
1157 item.myName = tr( "SMESH_COPY_MESH" ); p.append( item );
1158 QCheckBox* aQCheckBox = new QCheckBox(dlg());
1159 aQCheckBox->setChecked( toCopyMesh );
1160 connect( aQCheckBox, SIGNAL( stateChanged(int) ), this, SLOT( onValueChanged() ));
1161 customWidgets()->append( aQCheckBox );
1163 item.myName = tr( "SMESH_COPY_GROUPS" ); p.append( item );
1164 aQCheckBox = new QCheckBox(dlg());
1165 aQCheckBox->setChecked( toCopyGroups );
1166 aQCheckBox->setEnabled( toCopyMesh );
1167 customWidgets()->append( aQCheckBox );
1169 else if( hypType()=="ViscousLayers" )
1171 StdMeshers::StdMeshers_ViscousLayers_var h =
1172 StdMeshers::StdMeshers_ViscousLayers::_narrow( hyp );
1174 item.myName = tr( "SMESH_TOTAL_THICKNESS" );
1175 if(!initVariableName( hyp, item, "SetTotalThickness" ))
1176 item.myValue = h->GetTotalThickness();
1178 customWidgets()->append (0);
1180 item.myName = tr( "SMESH_NUMBER_OF_LAYERS" );
1181 if(!initVariableName( hyp, item, "SetNumberLayers" ))
1182 item.myValue = h->GetNumberLayers();
1184 customWidgets()->append (0);
1186 item.myName = tr( "SMESH_STRETCH_FACTOR" );
1187 if(!initVariableName( hyp, item, "SetStretchFactor" ))
1188 item.myValue = h->GetStretchFactor();
1190 customWidgets()->append (0);
1192 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
1193 if ( !aMainEntry.isEmpty() )
1195 item.myName = tr( "SMESH_FACES_WO_LAYERS" );
1198 StdMeshersGUI_SubShapeSelectorWdg* idsWg =
1199 new StdMeshersGUI_SubShapeSelectorWdg(0,TopAbs_FACE);
1201 idsWg->SetGeomShapeEntry( aMainEntry );
1202 idsWg->SetMainShapeEntry( aMainEntry );
1203 idsWg->SetListOfIDs( h->GetIgnoreFaces() );
1204 idsWg->showPreview( true );
1205 customWidgets()->append ( idsWg );
1208 else if( hypType()=="ViscousLayers2D" )
1210 StdMeshers::StdMeshers_ViscousLayers2D_var h =
1211 StdMeshers::StdMeshers_ViscousLayers2D::_narrow( hyp );
1213 item.myName = tr( "SMESH_TOTAL_THICKNESS" );
1214 if(!initVariableName( hyp, item, "SetTotalThickness" ))
1215 item.myValue = h->GetTotalThickness();
1217 customWidgets()->append (0);
1219 item.myName = tr( "SMESH_NUMBER_OF_LAYERS" );
1220 if(!initVariableName( hyp, item, "SetNumberLayers" ))
1221 item.myValue = h->GetNumberLayers();
1223 customWidgets()->append (0);
1225 item.myName = tr( "SMESH_STRETCH_FACTOR" );
1226 if(!initVariableName( hyp, item, "SetStretchFactor" ))
1227 item.myValue = h->GetStretchFactor();
1229 customWidgets()->append (0);
1231 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
1232 if ( !aMainEntry.isEmpty() )
1234 item.myName = tr("TO_IGNORE_EDGES_OR_NOT");
1237 StdMeshersGUI_RadioButtonsGrpWdg* ignoreWdg = new StdMeshersGUI_RadioButtonsGrpWdg("");
1238 ignoreWdg->setButtonLabels ( QStringList()
1239 << tr("NOT_TO_IGNORE_EDGES")
1240 << tr("TO_IGNORE_EDGES") );
1241 ignoreWdg->setChecked( h->GetIsToIgnoreEdges() );
1242 connect(ignoreWdg->getButtonGroup(),SIGNAL(buttonClicked(int)),this,SLOT(onValueChanged()));
1243 customWidgets()->append( ignoreWdg );
1246 tr( h->GetIsToIgnoreEdges() ? "SMESH_EDGES_WO_LAYERS" : "SMESH_EDGES_WITH_LAYERS" );
1249 StdMeshersGUI_SubShapeSelectorWdg* idsWg =
1250 new StdMeshersGUI_SubShapeSelectorWdg(0,TopAbs_EDGE);
1252 idsWg->SetGeomShapeEntry( aMainEntry );
1253 idsWg->SetMainShapeEntry( aMainEntry );
1254 idsWg->SetListOfIDs( h->GetEdges() );
1255 idsWg->showPreview( true );
1256 customWidgets()->append ( idsWg );
1259 else if (hypType() == "QuadrangleParams")
1261 StdMeshers::StdMeshers_QuadrangleParams_var h =
1262 StdMeshers::StdMeshers_QuadrangleParams::_narrow(hyp);
1264 item.myName = tr("SMESH_BASE_VERTEX");
1267 StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget =
1268 new StdMeshersGUI_SubShapeSelectorWdg(0, TopAbs_VERTEX);
1269 aDirectionWidget->SetMaxSize(1);
1270 QString anEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
1271 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
1273 anEntry = h->GetObjectEntry();
1274 aDirectionWidget->SetGeomShapeEntry(anEntry);
1275 aDirectionWidget->SetMainShapeEntry(aMainEntry);
1276 if (!isCreation()) {
1277 SMESH::long_array_var aVec = new SMESH::long_array;
1278 int vertID = h->GetTriaVertex();
1282 aDirectionWidget->SetListOfIDs(aVec);
1285 aDirectionWidget->showPreview(true);
1287 item.myName = tr("SMESH_QUAD_TYPE");
1290 StdMeshersGUI_QuadrangleParamWdg* aTypeWidget =
1291 new StdMeshersGUI_QuadrangleParamWdg();
1292 if (!isCreation()) {
1293 aTypeWidget->SetType(int(h->GetQuadType()));
1296 customWidgets()->append(aDirectionWidget);
1297 customWidgets()->append(aTypeWidget);
1304 //================================================================================
1306 * \brief tune "standard" control
1307 * \param w - control widget
1308 * \param int - parameter index
1310 //================================================================================
1312 void StdMeshersGUI_StdHypothesisCreator::attuneStdWidget (QWidget* w, const int) const
1314 SMESHGUI_SpinBox* sb = w->inherits( "SMESHGUI_SpinBox" ) ? ( SMESHGUI_SpinBox* )w : 0;
1317 if( hypType()=="LocalLength" )
1319 if (sb->objectName() == tr("SMESH_LOCAL_LENGTH_PARAM"))
1320 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1321 else if (sb->objectName() == tr("SMESH_LOCAL_LENGTH_PRECISION"))
1322 sb->RangeStepAndValidator( 0.0, 1.0, 0.05, "len_tol_precision" );
1324 else if( hypType()=="Arithmetic1D" )
1326 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "parametric_precision" );
1328 else if( hypType()=="MaxLength" )
1330 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1331 sb->setEnabled( !widget< QCheckBox >( 1 )->isChecked() );
1333 else if( hypType()=="MaxElementArea" )
1335 sb->RangeStepAndValidator( VALUE_SMALL_2, VALUE_MAX_2, 1.0, "area_precision" );
1337 else if( hypType()=="MaxElementVolume" )
1339 sb->RangeStepAndValidator( VALUE_SMALL_3, VALUE_MAX_3, 1.0, "vol_precision" );
1341 else if( hypType()=="StartEndLength" )
1343 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1345 else if( hypType()=="Deflection1D" )
1347 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "parametric_precision" );
1349 else if( hypType()=="Adaptive1D" )
1351 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1353 else if( hypType().startsWith( "ViscousLayers" ))
1355 if (sb->objectName() == tr("SMESH_STRETCH_FACTOR"))
1356 sb->RangeStepAndValidator( 1.0, VALUE_MAX, 0.1, "parametric_precision" );
1358 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1360 else // default validator for possible ancestors
1362 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1367 //================================================================================
1369 * \brief Return dlg title
1370 * \retval QString - title string
1372 //================================================================================
1374 QString StdMeshersGUI_StdHypothesisCreator::caption() const
1376 return tr( QString( "SMESH_%1_TITLE" ).arg( hypTypeName( hypType() ) ).toLatin1().data() );
1379 //================================================================================
1381 * \brief return pixmap for dlg icon
1384 //================================================================================
1386 QPixmap StdMeshersGUI_StdHypothesisCreator::icon() const
1388 QString hypIconName = tr( QString( "ICON_DLG_%1" ).arg( hypTypeName( hypType() ) ).toLatin1().data() );
1389 return SMESHGUI::resourceMgr()->loadPixmap( "SMESH", hypIconName );
1392 //================================================================================
1394 * \brief Return hypothesis type name to show in dlg
1397 //================================================================================
1399 QString StdMeshersGUI_StdHypothesisCreator::type() const
1401 return tr( QString( "SMESH_%1_HYPOTHESIS" ).arg( hypTypeName( hypType() ) ).toLatin1().data() );
1404 //================================================================================
1406 * \brief String to insert in "SMESH_%1_HYPOTHESIS" to get hypothesis type name
1407 * from message resouce file
1408 * \param t - hypothesis type
1409 * \retval QString - result string
1411 //================================================================================
1413 QString StdMeshersGUI_StdHypothesisCreator::hypTypeName( const QString& t ) const
1415 static QMap<QString,QString> types;
1416 if( types.isEmpty() )
1418 types.insert( "LocalLength", "LOCAL_LENGTH" );
1419 types.insert( "NumberOfSegments", "NB_SEGMENTS" );
1420 types.insert( "MaxElementArea", "MAX_ELEMENT_AREA" );
1421 types.insert( "MaxElementVolume", "MAX_ELEMENT_VOLUME" );
1422 types.insert( "StartEndLength", "START_END_LENGTH" );
1423 types.insert( "Deflection1D", "DEFLECTION1D" );
1424 types.insert( "Adaptive1D", "ADAPTIVE1D" );
1425 types.insert( "Arithmetic1D", "ARITHMETIC_1D" );
1426 types.insert( "FixedPoints1D", "FIXED_POINTS_1D" );
1427 types.insert( "AutomaticLength", "AUTOMATIC_LENGTH" );
1428 types.insert( "ProjectionSource1D", "PROJECTION_SOURCE_1D" );
1429 types.insert( "ProjectionSource2D", "PROJECTION_SOURCE_2D" );
1430 types.insert( "ProjectionSource3D", "PROJECTION_SOURCE_3D" );
1431 types.insert( "ImportSource1D", "IMPORT_SOURCE_1D" );
1432 types.insert( "ImportSource2D", "IMPORT_SOURCE_2D" );
1433 types.insert( "NumberOfLayers", "NUMBER_OF_LAYERS" );
1434 types.insert( "LayerDistribution", "LAYER_DISTRIBUTION" );
1435 types.insert( "NumberOfLayers2D", "NUMBER_OF_LAYERS_2D" );
1436 types.insert( "LayerDistribution2D", "LAYER_DISTRIBUTION" );
1437 types.insert( "SegmentLengthAroundVertex", "SEGMENT_LENGTH_AROUND_VERTEX" );
1438 types.insert( "MaxLength", "MAX_LENGTH" );
1439 types.insert( "ViscousLayers", "VISCOUS_LAYERS" );
1440 types.insert( "ViscousLayers2D", "VISCOUS_LAYERS" );
1441 types.insert( "QuadrangleParams", "QUADRANGLE_PARAMS" );
1442 types.insert( "CartesianParameters3D", "CARTESIAN_PARAMS" );
1446 if( types.contains( t ) )
1453 //=======================================================================
1454 //function : getCustomWidget
1455 //purpose : is called from buildStdFrame()
1456 //=======================================================================
1458 QWidget* StdMeshersGUI_StdHypothesisCreator::getCustomWidget( const StdParam & param,
1460 const int index) const
1463 if ( index < customWidgets()->count() ) {
1464 w = customWidgets()->at( index );
1466 w->setParent( parent );
1467 w->move( QPoint( 0, 0 ) );
1473 //================================================================================
1475 * \brief Set param value taken from a custom widget
1476 * \param param - SMESHGUI_GenericHypothesisCreator::StdParam structure
1477 * \param widget - widget presenting param
1478 * \retval bool - success flag
1480 * this method is called from getStdParamFromDlg()
1482 //================================================================================
1484 bool StdMeshersGUI_StdHypothesisCreator::getParamFromCustomWidget( StdParam & param,
1485 QWidget* widget) const
1487 if ( hypType()=="AutomaticLength" ) {
1488 SMESHGUI_SpinBox* w = dynamic_cast<SMESHGUI_SpinBox*>( widget );
1490 param.myValue = w->GetValue();
1494 if ( hypType() == "MaxLength" ) {
1498 if ( widget->inherits( "StdMeshersGUI_ObjectReferenceParamWdg" ))
1500 // show only 1st reference value
1501 if ( true /*widget == getWidgetForParam( 0 )*/) {
1502 const StdMeshersGUI_ObjectReferenceParamWdg * w =
1503 static_cast<const StdMeshersGUI_ObjectReferenceParamWdg*>( widget );
1504 param.myValue = w->GetValue();
1508 if ( widget->inherits( "StdMeshersGUI_LayerDistributionParamWdg" ))
1510 const StdMeshersGUI_LayerDistributionParamWdg * w =
1511 static_cast<const StdMeshersGUI_LayerDistributionParamWdg*>( widget );
1512 param.myValue = w->GetValue();
1515 if ( widget->inherits( "StdMeshersGUI_SubShapeSelectorWdg" ))
1517 const StdMeshersGUI_SubShapeSelectorWdg * w =
1518 static_cast<const StdMeshersGUI_SubShapeSelectorWdg*>( widget );
1519 param.myValue = w->GetValue();
1522 if ( widget->inherits( "StdMeshersGUI_QuadrangleParamWdg" ))
1524 //const StdMeshersGUI_QuadrangleParamWdg * w =
1525 // static_cast<const StdMeshersGUI_QuadrangleParamWdg*>( widget );
1526 param.myValue = "QuadType";
1529 if ( widget->inherits( "StdMeshersGUI_FixedPointsParamWdg" ))
1531 const StdMeshersGUI_FixedPointsParamWdg * w =
1532 static_cast<const StdMeshersGUI_FixedPointsParamWdg*>( widget );
1533 param.myValue = w->GetValue();
1536 if ( widget->inherits( "QCheckBox" ))
1538 //const QCheckBox * w = static_cast<const QCheckBox*>( widget );
1539 //param.myValue = w->isChecked();
1542 if ( widget->inherits( "StdMeshersGUI_RadioButtonsGrpWdg" ))
1544 const StdMeshersGUI_RadioButtonsGrpWdg * w =
1545 static_cast<const StdMeshersGUI_RadioButtonsGrpWdg*>( widget );
1546 param.myValue = w->checkedId();
1552 //================================================================================
1554 * \brief called when operation cancelled
1556 //================================================================================
1558 void StdMeshersGUI_StdHypothesisCreator::onReject()
1560 if ( hypType().startsWith("ProjectionSource" ) ||
1561 hypType().startsWith("ImportSource" ))
1563 // Uninstall filters of StdMeshersGUI_ObjectReferenceParamWdg
1564 deactivateObjRefParamWdg( customWidgets() );
1568 //================================================================================
1570 * \brief Update widgets dependent on paramWidget
1572 //================================================================================
1574 void StdMeshersGUI_StdHypothesisCreator::valueChanged( QWidget* paramWidget)
1576 if ( hypType() == "MaxLength" && paramWidget == getWidgetForParam(1) )
1578 getWidgetForParam(0)->setEnabled( !widget< QCheckBox >( 1 )->isChecked() );
1579 if ( !getWidgetForParam(0)->isEnabled() ) {
1580 StdMeshers::StdMeshers_MaxLength_var h =
1581 StdMeshers::StdMeshers_MaxLength::_narrow( initParamsHypothesis() );
1582 widget< QtxDoubleSpinBox >( 0 )->setValue( h->GetPreestimatedLength() );
1585 else if ( hypType().startsWith("ImportSource") && paramWidget == getWidgetForParam(1) )
1587 QCheckBox* toCopyMesh = (QCheckBox*) paramWidget;
1588 QCheckBox* toCopyGroups = widget< QCheckBox >( 2 );
1589 if ( !toCopyMesh->isChecked() )
1591 toCopyGroups->setChecked( false );
1592 toCopyGroups->setEnabled( false );
1596 toCopyGroups->setEnabled( true );
1599 else if ( hypType() == "ViscousLayers2D" && paramWidget->inherits("QButtonGroup"))
1601 if ( QLabel* label = getLabel(4) )
1603 bool toIgnore = widget< StdMeshersGUI_RadioButtonsGrpWdg >( 3 )->checkedId();
1604 label->setText( tr( toIgnore ? "SMESH_EDGES_WO_LAYERS" : "SMESH_EDGES_WITH_LAYERS" ));
1609 //================================================================================
1613 //================================================================================
1615 bool StdMeshersGUI_StdHypothesisCreator::initVariableName(SMESH::SMESH_Hypothesis_var theHyp,
1616 StdParam & theParams,
1617 const char* theMethod) const
1619 QString aVaribaleName = getVariableName( theMethod );
1620 theParams.isVariable = !aVaribaleName.isEmpty();
1621 if (theParams.isVariable)
1622 theParams.myValue = aVaribaleName;
1624 return theParams.isVariable;