1 // Copyright (C) 2007-2014 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, or (at your option) any later version.
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()=="GeometricProgression" )
528 StdMeshers::StdMeshers_Geometric1D_var h =
529 StdMeshers::StdMeshers_Geometric1D::_narrow( hypothesis() );
531 StdMeshersGUI_SubShapeSelectorWdg* w =
532 widget< StdMeshersGUI_SubShapeSelectorWdg >( 2 );
534 h->SetVarParameter( params[0].text(), "SetStartLength" );
535 h->SetStartLength( params[0].myValue.toDouble() );
536 h->SetVarParameter( params[1].text(), "SetCommonRatio" );
537 h->SetCommonRatio( params[1].myValue.toDouble() );
539 h->SetReversedEdges( w->GetListOfIDs() );
540 h->SetObjectEntry( w->GetMainShapeEntry() );
543 else if( hypType()=="FixedPoints1D" )
545 StdMeshers::StdMeshers_FixedPoints1D_var h =
546 StdMeshers::StdMeshers_FixedPoints1D::_narrow( hypothesis() );
548 StdMeshersGUI_FixedPointsParamWdg* w1 =
549 widget< StdMeshersGUI_FixedPointsParamWdg >( 0 );
551 StdMeshersGUI_SubShapeSelectorWdg* w2 =
552 widget< StdMeshersGUI_SubShapeSelectorWdg >( 1 );
555 h->SetPoints( w1->GetListOfPoints() );
556 h->SetNbSegments( w1->GetListOfSegments() );
559 h->SetReversedEdges( w2->GetListOfIDs() );
560 h->SetObjectEntry( w2->GetMainShapeEntry() );
563 else if( hypType()=="MaxElementArea" )
565 StdMeshers::StdMeshers_MaxElementArea_var h =
566 StdMeshers::StdMeshers_MaxElementArea::_narrow( hypothesis() );
567 h->SetVarParameter( params[0].text(), "SetMaxElementArea" );
568 h->SetMaxElementArea( params[0].myValue.toDouble() );
570 else if( hypType()=="MaxElementVolume" )
572 StdMeshers::StdMeshers_MaxElementVolume_var h =
573 StdMeshers::StdMeshers_MaxElementVolume::_narrow( hypothesis() );
575 h->SetVarParameter( params[0].text(), "SetMaxElementVolume" );
576 h->SetMaxElementVolume( params[0].myValue.toDouble() );
578 else if( hypType()=="StartEndLength" )
580 StdMeshers::StdMeshers_StartEndLength_var h =
581 StdMeshers::StdMeshers_StartEndLength::_narrow( hypothesis() );
583 StdMeshersGUI_SubShapeSelectorWdg* w =
584 widget< StdMeshersGUI_SubShapeSelectorWdg >( 2 );
586 h->SetVarParameter( params[0].text(), "SetStartLength" );
587 h->SetStartLength( params[0].myValue.toDouble() );
588 h->SetVarParameter( params[1].text(), "SetEndLength" );
589 h->SetEndLength( params[1].myValue.toDouble() );
591 h->SetReversedEdges( w->GetListOfIDs() );
592 h->SetObjectEntry( w->GetMainShapeEntry() );
595 else if( hypType()=="Deflection1D" )
597 StdMeshers::StdMeshers_Deflection1D_var h =
598 StdMeshers::StdMeshers_Deflection1D::_narrow( hypothesis() );
599 h->SetVarParameter( params[0].text(), "SetDeflection" );
600 h->SetDeflection( params[0].myValue.toDouble() );
602 else if( hypType()=="Adaptive1D" )
604 StdMeshers::StdMeshers_Adaptive1D_var h =
605 StdMeshers::StdMeshers_Adaptive1D::_narrow( hypothesis() );
606 h->SetVarParameter( params[0].text(), "SetMinSize" );
607 h->SetMinSize( params[0].myValue.toDouble() );
608 h->SetVarParameter( params[0].text(), "SetMaxSize" );
609 h->SetMaxSize( params[1].myValue.toDouble() );
610 h->SetVarParameter( params[0].text(), "SetDeflection" );
611 h->SetDeflection( params[2].myValue.toDouble() );
612 h->SetVarParameter( params[0].text(), "SetGrading" );
613 h->SetGrading( params[3].myValue.toDouble() );
615 else if( hypType()=="AutomaticLength" )
617 StdMeshers::StdMeshers_AutomaticLength_var h =
618 StdMeshers::StdMeshers_AutomaticLength::_narrow( hypothesis() );
620 h->SetVarParameter( params[0].text(), "SetFineness" );
621 h->SetFineness( params[0].myValue.toDouble() );
623 else if( hypType()=="NumberOfLayers" )
625 StdMeshers::StdMeshers_NumberOfLayers_var h =
626 StdMeshers::StdMeshers_NumberOfLayers::_narrow( hypothesis() );
628 h->SetVarParameter( params[0].text(), "SetNumberOfLayers" );
629 h->SetNumberOfLayers( params[0].myValue.toInt() );
631 else if( hypType()=="LayerDistribution" )
633 StdMeshers::StdMeshers_LayerDistribution_var h =
634 StdMeshers::StdMeshers_LayerDistribution::_narrow( hypothesis() );
635 StdMeshersGUI_LayerDistributionParamWdg* w =
636 widget< StdMeshersGUI_LayerDistributionParamWdg >( 0 );
638 h->SetLayerDistribution( w->GetHypothesis() );
640 else if( hypType()=="NumberOfLayers2D" )
642 StdMeshers::StdMeshers_NumberOfLayers2D_var h =
643 StdMeshers::StdMeshers_NumberOfLayers2D::_narrow( hypothesis() );
645 h->SetVarParameter( params[0].text(), "SetNumberOfLayers" );
646 h->SetNumberOfLayers( params[0].myValue.toInt() );
648 else if( hypType()=="LayerDistribution2D" )
650 StdMeshers::StdMeshers_LayerDistribution2D_var h =
651 StdMeshers::StdMeshers_LayerDistribution2D::_narrow( hypothesis() );
652 StdMeshersGUI_LayerDistributionParamWdg* w =
653 widget< StdMeshersGUI_LayerDistributionParamWdg >( 0 );
655 h->SetLayerDistribution( w->GetHypothesis() );
657 else if( hypType()=="ProjectionSource1D" )
659 StdMeshers::StdMeshers_ProjectionSource1D_var h =
660 StdMeshers::StdMeshers_ProjectionSource1D::_narrow( hypothesis() );
662 h->SetSourceEdge ( geomFromWdg ( getWidgetForParam( 0 )));
663 h->SetSourceMesh ( meshFromWdg ( getWidgetForParam( 1 )));
664 h->SetVertexAssociation( geomFromWdg ( getWidgetForParam( 2 )),
665 geomFromWdg ( getWidgetForParam( 3 )));
667 else if( hypType()=="ProjectionSource2D" )
669 StdMeshers::StdMeshers_ProjectionSource2D_var h =
670 StdMeshers::StdMeshers_ProjectionSource2D::_narrow( hypothesis() );
672 h->SetSourceFace ( geomFromWdg ( getWidgetForParam( 0 )));
673 h->SetSourceMesh ( meshFromWdg ( getWidgetForParam( 1 )));
674 h->SetVertexAssociation( geomFromWdg ( getWidgetForParam( 2 )), // src1
675 geomFromWdg ( getWidgetForParam( 4 )), // src2
676 geomFromWdg ( getWidgetForParam( 3 )), // tgt1
677 geomFromWdg ( getWidgetForParam( 5 ))); // tgt2
679 else if( hypType()=="ProjectionSource3D" )
681 StdMeshers::StdMeshers_ProjectionSource3D_var h =
682 StdMeshers::StdMeshers_ProjectionSource3D::_narrow( hypothesis() );
684 h->SetSource3DShape ( geomFromWdg ( getWidgetForParam( 0 )));
685 h->SetSourceMesh ( meshFromWdg ( getWidgetForParam( 1 )));
686 h->SetVertexAssociation( geomFromWdg ( getWidgetForParam( 2 )), // src1
687 geomFromWdg ( getWidgetForParam( 4 )), // src2
688 geomFromWdg ( getWidgetForParam( 3 )), // tgt1
689 geomFromWdg ( getWidgetForParam( 5 ))); // tgt2
691 else if( hypType()=="ImportSource1D" )
693 StdMeshers::StdMeshers_ImportSource1D_var h =
694 StdMeshers::StdMeshers_ImportSource1D::_narrow( hypothesis() );
696 SMESH::ListOfGroups_var groups = groupsFromWdg( getWidgetForParam( 0 ));
697 h->SetSourceEdges( groups.in() );
698 QCheckBox* toCopyMesh = widget< QCheckBox >( 1 );
699 QCheckBox* toCopyGroups = widget< QCheckBox >( 2 );
700 h->SetCopySourceMesh( toCopyMesh->isChecked(), toCopyGroups->isChecked());
702 else if( hypType()=="ImportSource2D" )
704 StdMeshers::StdMeshers_ImportSource2D_var h =
705 StdMeshers::StdMeshers_ImportSource2D::_narrow( hypothesis() );
707 SMESH::ListOfGroups_var groups = groupsFromWdg( getWidgetForParam( 0 ));
708 h->SetSourceFaces( groups.in() );
709 QCheckBox* toCopyMesh = widget< QCheckBox >( 1 );
710 QCheckBox* toCopyGroups = widget< QCheckBox >( 2 );
711 h->SetCopySourceMesh( toCopyMesh->isChecked(), toCopyGroups->isChecked());
713 else if( hypType()=="ViscousLayers" )
715 StdMeshers::StdMeshers_ViscousLayers_var h =
716 StdMeshers::StdMeshers_ViscousLayers::_narrow( hypothesis() );
718 h->SetVarParameter( params[0].text(), "SetTotalThickness" );
719 h->SetTotalThickness( params[0].myValue.toDouble() );
720 h->SetVarParameter( params[1].text(), "SetNumberLayers" );
721 h->SetNumberLayers ( params[1].myValue.toInt() );
722 h->SetVarParameter( params[2].text(), "SetStretchFactor" );
723 h->SetStretchFactor ( params[2].myValue.toDouble() );
725 if ( StdMeshersGUI_SubShapeSelectorWdg* idsWg =
726 widget< StdMeshersGUI_SubShapeSelectorWdg >( 4 ))
728 h->SetFaces( idsWg->GetListOfIDs(), params[3].myValue.toInt() );
731 else if( hypType()=="ViscousLayers2D" )
733 StdMeshers::StdMeshers_ViscousLayers2D_var h =
734 StdMeshers::StdMeshers_ViscousLayers2D::_narrow( hypothesis() );
736 h->SetVarParameter( params[0].text(), "SetTotalThickness" );
737 h->SetTotalThickness( params[0].myValue.toDouble() );
738 h->SetVarParameter( params[1].text(), "SetNumberLayers" );
739 h->SetNumberLayers ( params[1].myValue.toInt() );
740 h->SetVarParameter( params[2].text(), "SetStretchFactor" );
741 h->SetStretchFactor ( params[2].myValue.toDouble() );
743 if ( StdMeshersGUI_SubShapeSelectorWdg* idsWg =
744 widget< StdMeshersGUI_SubShapeSelectorWdg >( 4 ))
746 h->SetEdges( idsWg->GetListOfIDs(), params[3].myValue.toInt() );
749 // else if( hypType()=="QuadrangleParams" )
751 // StdMeshers::StdMeshers_QuadrangleParams_var h =
752 // StdMeshers::StdMeshers_QuadrangleParams::_narrow( hypothesis() );
753 // StdMeshersGUI_SubShapeSelectorWdg* w1 =
754 // widget< StdMeshersGUI_SubShapeSelectorWdg >( 0 );
755 // StdMeshersGUI_QuadrangleParamWdg* w2 =
756 // widget< StdMeshersGUI_QuadrangleParamWdg >( 1 );
758 // if (w1->GetListSize() > 0) {
759 // h->SetTriaVertex(w1->GetListOfIDs()[0]); // getlist must be called once
760 // const char * entry = w1->GetMainShapeEntry();
761 // h->SetObjectEntry(entry);
763 // h->SetQuadType(StdMeshers::QuadType(w2->GetType()));
770 //================================================================================
772 * \brief Return parameter values as SMESHGUI_GenericHypothesisCreator::StdParam
773 * \param p - list of parameters
774 * \retval bool - success flag
776 * Is called from SMESHGUI_GenericHypothesisCreator::buildStdFrame().
777 * Parameters will be shown using "standard" controls:
778 * Int by QtxIntSpinBox
779 * Double by SMESHGUI_SpinBox
780 * String by QLineEdit
781 * getCustomWidget() allows to redefine control for a parameter
783 //================================================================================
785 bool StdMeshersGUI_StdHypothesisCreator::stdParams( ListOfStdParams& p ) const
788 SMESHGUI_GenericHypothesisCreator::StdParam item;
791 customWidgets()->clear();
794 HypothesisData* data = SMESH::GetHypothesisData( hypType() );
795 item.myName = tr( "SMESH_NAME" );
796 item.myValue = data ? hypName() : QString();
798 customWidgets()->append(0);
801 SMESH::SMESH_Hypothesis_var hyp = initParamsHypothesis();
802 //SMESH::ListOfParameters_var aParameters = hyp->GetLastParameters();
804 if( hypType()=="LocalLength" )
806 StdMeshers::StdMeshers_LocalLength_var h =
807 StdMeshers::StdMeshers_LocalLength::_narrow( hyp );
809 item.myName = tr("SMESH_LOCAL_LENGTH_PARAM");
810 if(!initVariableName( hyp, item, "SetLength"))
811 item.myValue = h->GetLength();
814 item.myName = tr("SMESH_LOCAL_LENGTH_PRECISION");
815 if(!initVariableName( hyp, item, "SetPrecision"))
816 item.myValue = h->GetPrecision();
819 else if( hypType()=="MaxLength" )
821 StdMeshers::StdMeshers_MaxLength_var h =
822 StdMeshers::StdMeshers_MaxLength::_narrow( hyp );
823 // try to set a right preestimated length to edited hypothesis
824 bool noPreestimatedAtEdition = false;
825 if ( !isCreation() ) {
826 StdMeshers::StdMeshers_MaxLength_var initHyp =
827 StdMeshers::StdMeshers_MaxLength::_narrow( initParamsHypothesis(true) );
828 noPreestimatedAtEdition =
829 ( initHyp->_is_nil() || !initHyp->HavePreestimatedLength() );
830 if ( !noPreestimatedAtEdition )
831 h->SetPreestimatedLength( initHyp->GetPreestimatedLength() );
834 item.myName = tr("SMESH_LOCAL_LENGTH_PARAM");
835 if(!initVariableName( hyp, item, "SetLength"))
836 item.myValue = h->GetLength();
838 customWidgets()->append(0);
840 item.myName = tr("SMESH_USE_PREESTIMATED_LENGTH");
842 QCheckBox* aQCheckBox = new QCheckBox(dlg());
843 if ( !noPreestimatedAtEdition && h->HavePreestimatedLength() ) {
844 aQCheckBox->setChecked( h->GetUsePreestimatedLength() );
845 connect( aQCheckBox, SIGNAL( stateChanged(int) ), this, SLOT( onValueChanged() ) );
848 aQCheckBox->setChecked( false );
849 aQCheckBox->setEnabled( false );
851 customWidgets()->append( aQCheckBox );
853 else if( hypType()=="SegmentLengthAroundVertex" )
855 StdMeshers::StdMeshers_SegmentLengthAroundVertex_var h =
856 StdMeshers::StdMeshers_SegmentLengthAroundVertex::_narrow( hyp );
858 item.myName = tr("SMESH_LOCAL_LENGTH_PARAM");
859 if(!initVariableName( hyp, item, "SetLength"))
860 item.myValue = h->GetLength();
864 else if( hypType()=="Arithmetic1D" )
866 StdMeshers::StdMeshers_Arithmetic1D_var h =
867 StdMeshers::StdMeshers_Arithmetic1D::_narrow( hyp );
869 item.myName = tr( "SMESH_START_LENGTH_PARAM" );
870 if(!initVariableName( hyp, item, "SetStartLength" ))
871 item.myValue = h->GetLength( true );
874 customWidgets()->append (0);
876 item.myName = tr( "SMESH_END_LENGTH_PARAM" );
877 if(!initVariableName( hyp, item, "SetEndLength" ))
878 item.myValue = h->GetLength( false );
881 customWidgets()->append (0);
883 item.myName = tr( "SMESH_REVERSED_EDGES" );
886 StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget =
887 new StdMeshersGUI_SubShapeSelectorWdg();
888 QString aGeomEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
889 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
890 if ( aGeomEntry == "" )
891 aGeomEntry = h->GetObjectEntry();
893 aDirectionWidget->SetGeomShapeEntry( aGeomEntry );
894 aDirectionWidget->SetMainShapeEntry( aMainEntry );
895 aDirectionWidget->SetListOfIDs( h->GetReversedEdges() );
896 aDirectionWidget->showPreview( true );
897 customWidgets()->append ( aDirectionWidget );
900 else if( hypType()=="GeometricProgression" )
902 StdMeshers::StdMeshers_Geometric1D_var h =
903 StdMeshers::StdMeshers_Geometric1D::_narrow( hyp );
905 item.myName = tr( "SMESH_START_LENGTH_PARAM" );
906 if(!initVariableName( hyp, item, "SetStartLength" ))
907 item.myValue = h->GetStartLength();
910 customWidgets()->append (0);
912 item.myName = tr( "SMESH_COMMON_RATIO" );
913 if(!initVariableName( hyp, item, "SetCommonRatio" ))
914 item.myValue = h->GetCommonRatio();
917 customWidgets()->append (0);
919 item.myName = tr( "SMESH_REVERSED_EDGES" );
922 StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget =
923 new StdMeshersGUI_SubShapeSelectorWdg();
924 QString aGeomEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
925 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
926 if ( aGeomEntry == "" )
927 aGeomEntry = h->GetObjectEntry();
929 aDirectionWidget->SetGeomShapeEntry( aGeomEntry );
930 aDirectionWidget->SetMainShapeEntry( aMainEntry );
931 aDirectionWidget->SetListOfIDs( h->GetReversedEdges() );
932 aDirectionWidget->showPreview( true );
933 customWidgets()->append ( aDirectionWidget );
936 else if( hypType()=="FixedPoints1D" )
938 StdMeshers::StdMeshers_FixedPoints1D_var h =
939 StdMeshers::StdMeshers_FixedPoints1D::_narrow( hyp );
941 item.myName = tr( "SMESH_FIXED_POINTS" );
944 StdMeshersGUI_FixedPointsParamWdg* aFixedPointsWidget =
945 new StdMeshersGUI_FixedPointsParamWdg();
947 if ( !isCreation() ) {
948 aFixedPointsWidget->SetListOfPoints( h->GetPoints() );
949 aFixedPointsWidget->SetListOfSegments( h->GetNbSegments() );
951 customWidgets()->append( aFixedPointsWidget );
953 item.myName = tr( "SMESH_REVERSED_EDGES" );
956 StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget =
957 new StdMeshersGUI_SubShapeSelectorWdg();
958 QString anEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
959 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
961 anEntry = h->GetObjectEntry();
962 aDirectionWidget->SetGeomShapeEntry( anEntry );
963 aDirectionWidget->SetMainShapeEntry( aMainEntry );
964 aDirectionWidget->SetListOfIDs( h->GetReversedEdges() );
965 aDirectionWidget->showPreview( true );
966 customWidgets()->append ( aDirectionWidget );
970 else if( hypType()=="MaxElementArea" )
972 StdMeshers::StdMeshers_MaxElementArea_var h =
973 StdMeshers::StdMeshers_MaxElementArea::_narrow( hyp );
975 item.myName = tr( "SMESH_MAX_ELEMENT_AREA_PARAM" );
976 if(!initVariableName( hyp, item, "SetMaxElementArea" ))
977 item.myValue = h->GetMaxElementArea();
981 else if( hypType()=="MaxElementVolume" )
983 StdMeshers::StdMeshers_MaxElementVolume_var h =
984 StdMeshers::StdMeshers_MaxElementVolume::_narrow( hyp );
986 item.myName = tr( "SMESH_MAX_ELEMENT_VOLUME_PARAM" );
987 if(!initVariableName( hyp, item, "SetMaxElementVolume" ))
988 item.myValue = h->GetMaxElementVolume();
991 else if( hypType()=="StartEndLength" )
993 StdMeshers::StdMeshers_StartEndLength_var h =
994 StdMeshers::StdMeshers_StartEndLength::_narrow( hyp );
996 item.myName = tr( "SMESH_START_LENGTH_PARAM" );
998 if(!initVariableName( hyp, item, "SetStartLength" ))
999 item.myValue = h->GetLength( true );
1001 customWidgets()->append(0);
1003 item.myName = tr( "SMESH_END_LENGTH_PARAM" );
1004 if(!initVariableName( hyp, item, "SetEndLength" ))
1005 item.myValue = h->GetLength( false );
1007 customWidgets()->append(0);
1009 item.myName = tr( "SMESH_REVERSED_EDGES" );
1012 StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget =
1013 new StdMeshersGUI_SubShapeSelectorWdg();
1014 QString anEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
1015 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
1016 if ( anEntry == "" )
1017 anEntry = h->GetObjectEntry();
1018 aDirectionWidget->SetGeomShapeEntry( anEntry );
1019 aDirectionWidget->SetMainShapeEntry( aMainEntry );
1020 aDirectionWidget->SetListOfIDs( h->GetReversedEdges() );
1021 aDirectionWidget->showPreview( true );
1022 customWidgets()->append ( aDirectionWidget );
1024 else if( hypType()=="Deflection1D" )
1026 StdMeshers::StdMeshers_Deflection1D_var h =
1027 StdMeshers::StdMeshers_Deflection1D::_narrow( hyp );
1029 item.myName = tr( "SMESH_DEFLECTION1D_PARAM" );
1030 if(!initVariableName( hyp, item, "SetDeflection" ))
1031 item.myValue = h->GetDeflection();
1034 else if( hypType()=="Adaptive1D" )
1036 StdMeshers::StdMeshers_Adaptive1D_var h =
1037 StdMeshers::StdMeshers_Adaptive1D::_narrow( hyp );
1039 item.myName = tr( "SMESH_MIN_SIZE" );
1040 if(!initVariableName( hyp, item, "SetMinSize" ))
1041 item.myValue = h->GetMinSize();
1044 item.myName = tr( "SMESH_MAX_SIZE" );
1045 if(!initVariableName( hyp, item, "SetMaxSize" ))
1046 item.myValue = h->GetMaxSize();
1049 item.myName = tr( "SMESH_DEFLECTION1D_PARAM" );
1050 if(!initVariableName( hyp, item, "SetDeflection" ))
1051 item.myValue = h->GetDeflection();
1054 item.myName = tr( "SMESH_GRADING1D_PARAM" );
1055 if(!initVariableName( hyp, item, "SetGrading" ))
1056 item.myValue = h->GetGrading();
1059 else if( hypType()=="AutomaticLength" )
1061 StdMeshers::StdMeshers_AutomaticLength_var h =
1062 StdMeshers::StdMeshers_AutomaticLength::_narrow( hyp );
1064 item.myName = tr( "SMESH_FINENESS_PARAM" );
1065 //item.myValue = h->GetFineness();
1067 SMESHGUI_SpinBox* _autoLengthSpinBox = new SMESHGUI_SpinBox(dlg());
1068 _autoLengthSpinBox->RangeStepAndValidator(0, 1, 0.01, "length_precision");
1069 _autoLengthSpinBox->SetValue(h->GetFineness());
1070 customWidgets()->append( _autoLengthSpinBox);
1072 else if( hypType()=="NumberOfLayers" )
1074 StdMeshers::StdMeshers_NumberOfLayers_var h =
1075 StdMeshers::StdMeshers_NumberOfLayers::_narrow( hyp );
1077 item.myName = tr( "SMESH_NUMBER_OF_LAYERS" );
1078 if(!initVariableName( hyp, item, "SetNumberOfLayers" ))
1079 item.myValue = (int) h->GetNumberOfLayers();
1082 else if( hypType()=="LayerDistribution" )
1084 StdMeshers::StdMeshers_LayerDistribution_var h =
1085 StdMeshers::StdMeshers_LayerDistribution::_narrow( hyp );
1087 item.myName = tr( "SMESH_LAYERS_DISTRIBUTION" ); p.append( item );
1088 initVariableName( hyp, item, "SetLayerDistribution" );
1089 customWidgets()->append ( new StdMeshersGUI_LayerDistributionParamWdg
1090 ( h, h->GetLayerDistribution(), hypName(), dlg() ));
1092 else if( hypType()=="NumberOfLayers2D" )
1094 StdMeshers::StdMeshers_NumberOfLayers2D_var h =
1095 StdMeshers::StdMeshers_NumberOfLayers2D::_narrow( hyp );
1097 item.myName = tr( "SMESH_NUMBER_OF_LAYERS" );
1098 if(!initVariableName( hyp, item, "SetNumberOfLayers" ))
1099 item.myValue = (int) h->GetNumberOfLayers();
1102 else if( hypType()=="LayerDistribution2D" )
1104 StdMeshers::StdMeshers_LayerDistribution2D_var h =
1105 StdMeshers::StdMeshers_LayerDistribution2D::_narrow( hyp );
1107 item.myName = tr( "SMESH_LAYERS_DISTRIBUTION" ); p.append( item );
1108 initVariableName( hyp, item, "SetLayerDistribution" );
1109 customWidgets()->append ( new StdMeshersGUI_LayerDistributionParamWdg
1110 ( h, h->GetLayerDistribution(), hypName(), dlg() ));
1112 else if( hypType()=="ProjectionSource1D" )
1114 StdMeshers::StdMeshers_ProjectionSource1D_var h =
1115 StdMeshers::StdMeshers_ProjectionSource1D::_narrow( hyp );
1117 item.myName = tr( "SMESH_SOURCE_EDGE" ); p.append( item );
1118 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 1 ),
1119 h->GetSourceEdge()));
1120 item.myName = tr( "SMESH_SOURCE_MESH" ); p.append( item );
1121 customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( SMESH::MESH ),
1122 h->GetSourceMesh()));
1123 item.myName = tr( "SMESH_SOURCE_VERTEX" ); p.append( item );
1124 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1125 h->GetSourceVertex()));
1126 item.myName = tr( "SMESH_TARGET_VERTEX" ); p.append( item );
1127 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1128 h->GetTargetVertex()));
1130 else if( hypType()=="ProjectionSource2D" )
1132 StdMeshers::StdMeshers_ProjectionSource2D_var h =
1133 StdMeshers::StdMeshers_ProjectionSource2D::_narrow( hyp );
1135 item.myName = tr( "SMESH_SOURCE_FACE" ); p.append( item );
1136 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 2 ),
1137 h->GetSourceFace()));
1138 item.myName = tr( "SMESH_SOURCE_MESH" ); p.append( item );
1139 customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( SMESH::MESH ),
1140 h->GetSourceMesh()));
1141 item.myName = tr( "SMESH_SOURCE_VERTEX1" ); p.append( item );
1142 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1143 h->GetSourceVertex( 1 )));
1144 item.myName = tr( "SMESH_TARGET_VERTEX1" ); p.append( item );
1145 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1146 h->GetTargetVertex( 1 )));
1147 item.myName = tr( "SMESH_SOURCE_VERTEX2" ); p.append( item );
1148 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1149 h->GetSourceVertex( 2 )));
1150 item.myName = tr( "SMESH_TARGET_VERTEX2" ); p.append( item );
1151 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1152 h->GetTargetVertex( 2 )));
1154 else if( hypType()=="ProjectionSource3D" )
1156 StdMeshers::StdMeshers_ProjectionSource3D_var h =
1157 StdMeshers::StdMeshers_ProjectionSource3D::_narrow( hyp );
1159 item.myName = tr( "SMESH_SOURCE_3DSHAPE" ); p.append( item );
1160 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 3, TopAbs_FACE, 6, true ),
1161 h->GetSource3DShape()));
1162 item.myName = tr( "SMESH_SOURCE_MESH" ); p.append( item );
1163 customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( SMESH::MESH ),
1164 h->GetSourceMesh()));
1165 item.myName = tr( "SMESH_SOURCE_VERTEX1" ); p.append( item );
1166 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1167 h->GetSourceVertex( 1 )));
1168 item.myName = tr( "SMESH_TARGET_VERTEX1" ); p.append( item );
1169 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1170 h->GetTargetVertex( 1 )));
1171 item.myName = tr( "SMESH_SOURCE_VERTEX2" ); p.append( item );
1172 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1173 h->GetSourceVertex( 2 )));
1174 item.myName = tr( "SMESH_TARGET_VERTEX2" ); p.append( item );
1175 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1176 h->GetTargetVertex( 2 )));
1178 else if( hypType()=="ImportSource1D" )
1180 StdMeshers::StdMeshers_ImportSource1D_var h =
1181 StdMeshers::StdMeshers_ImportSource1D::_narrow( hyp );
1183 SMESH::string_array_var groupEntries = h->GetSourceEdges();
1184 CORBA::Boolean toCopyMesh, toCopyGroups;
1185 h->GetCopySourceMesh(toCopyMesh, toCopyGroups);
1187 item.myName = tr( "SMESH_SOURCE_EDGES" ); p.append( item );
1188 customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( SMESH::GROUP_EDGE ),
1191 item.myName = tr( "SMESH_COPY_MESH" ); p.append( item );
1192 QCheckBox* aQCheckBox = new QCheckBox(dlg());
1193 aQCheckBox->setChecked( toCopyMesh );
1194 connect( aQCheckBox, SIGNAL( stateChanged(int) ), this, SLOT( onValueChanged() ));
1195 customWidgets()->append( aQCheckBox );
1197 item.myName = tr( "SMESH_TO_COPY_GROUPS" ); p.append( item );
1198 aQCheckBox = new QCheckBox(dlg());
1199 aQCheckBox->setChecked( toCopyGroups );
1200 aQCheckBox->setEnabled( toCopyMesh );
1201 customWidgets()->append( aQCheckBox );
1203 else if( hypType()=="ImportSource2D" )
1205 StdMeshers::StdMeshers_ImportSource2D_var h =
1206 StdMeshers::StdMeshers_ImportSource2D::_narrow( hyp );
1208 SMESH::string_array_var groupEntries = h->GetSourceFaces();
1209 CORBA::Boolean toCopyMesh, toCopyGroups;
1210 h->GetCopySourceMesh(toCopyMesh, toCopyGroups);
1212 item.myName = tr( "SMESH_SOURCE_FACES" ); p.append( item );
1213 customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( SMESH::GROUP_FACE ),
1216 item.myName = tr( "SMESH_COPY_MESH" ); p.append( item );
1217 QCheckBox* aQCheckBox = new QCheckBox(dlg());
1218 aQCheckBox->setChecked( toCopyMesh );
1219 connect( aQCheckBox, SIGNAL( stateChanged(int) ), this, SLOT( onValueChanged() ));
1220 customWidgets()->append( aQCheckBox );
1222 item.myName = tr( "SMESH_COPY_GROUPS" ); p.append( item );
1223 aQCheckBox = new QCheckBox(dlg());
1224 aQCheckBox->setChecked( toCopyGroups );
1225 aQCheckBox->setEnabled( toCopyMesh );
1226 customWidgets()->append( aQCheckBox );
1228 else if( hypType()=="ViscousLayers" )
1230 StdMeshers::StdMeshers_ViscousLayers_var h =
1231 StdMeshers::StdMeshers_ViscousLayers::_narrow( hyp );
1233 item.myName = tr( "SMESH_TOTAL_THICKNESS" );
1234 if(!initVariableName( hyp, item, "SetTotalThickness" ))
1235 item.myValue = h->GetTotalThickness();
1237 customWidgets()->append (0);
1239 item.myName = tr( "SMESH_NUMBER_OF_LAYERS" );
1240 if(!initVariableName( hyp, item, "SetNumberLayers" ))
1241 item.myValue = h->GetNumberLayers();
1243 customWidgets()->append (0);
1245 item.myName = tr( "SMESH_STRETCH_FACTOR" );
1246 if(!initVariableName( hyp, item, "SetStretchFactor" ))
1247 item.myValue = h->GetStretchFactor();
1249 customWidgets()->append (0);
1251 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
1252 QString aSubEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
1253 if ( !aMainEntry.isEmpty() )
1255 item.myName = tr( "TO_IGNORE_FACES_OR_NOT" );
1258 StdMeshersGUI_RadioButtonsGrpWdg* ignoreWdg = new StdMeshersGUI_RadioButtonsGrpWdg("");
1259 ignoreWdg->setButtonLabels ( QStringList()
1260 << tr("NOT_TO_IGNORE_FACES")
1261 << tr("TO_IGNORE_FACES") );
1262 ignoreWdg->setChecked( h->GetIsToIgnoreFaces() );
1263 connect(ignoreWdg->getButtonGroup(),SIGNAL(buttonClicked(int)),this,SLOT(onValueChanged()));
1264 customWidgets()->append( ignoreWdg );
1267 tr( h->GetIsToIgnoreFaces() ? "SMESH_FACES_WO_LAYERS" : "SMESH_FACES_WITH_LAYERS" );
1270 StdMeshersGUI_SubShapeSelectorWdg* idsWg =
1271 new StdMeshersGUI_SubShapeSelectorWdg(0,TopAbs_FACE);
1273 idsWg->SetMainShapeEntry( aMainEntry );
1274 idsWg->SetGeomShapeEntry( aSubEntry.isEmpty() ? aMainEntry : aSubEntry );
1275 idsWg->SetListOfIDs( h->GetFaces() );
1276 idsWg->showPreview( true );
1277 customWidgets()->append ( idsWg );
1280 else if( hypType()=="ViscousLayers2D" )
1282 StdMeshers::StdMeshers_ViscousLayers2D_var h =
1283 StdMeshers::StdMeshers_ViscousLayers2D::_narrow( hyp );
1285 item.myName = tr( "SMESH_TOTAL_THICKNESS" );
1286 if(!initVariableName( hyp, item, "SetTotalThickness" ))
1287 item.myValue = h->GetTotalThickness();
1289 customWidgets()->append (0);
1291 item.myName = tr( "SMESH_NUMBER_OF_LAYERS" );
1292 if(!initVariableName( hyp, item, "SetNumberLayers" ))
1293 item.myValue = h->GetNumberLayers();
1295 customWidgets()->append (0);
1297 item.myName = tr( "SMESH_STRETCH_FACTOR" );
1298 if(!initVariableName( hyp, item, "SetStretchFactor" ))
1299 item.myValue = h->GetStretchFactor();
1301 customWidgets()->append (0);
1303 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
1304 QString aSubEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
1305 if ( !aMainEntry.isEmpty() )
1307 item.myName = tr("TO_IGNORE_EDGES_OR_NOT");
1310 StdMeshersGUI_RadioButtonsGrpWdg* ignoreWdg = new StdMeshersGUI_RadioButtonsGrpWdg("");
1311 ignoreWdg->setButtonLabels ( QStringList()
1312 << tr("NOT_TO_IGNORE_EDGES")
1313 << tr("TO_IGNORE_EDGES") );
1314 ignoreWdg->setChecked( h->GetIsToIgnoreEdges() );
1315 connect(ignoreWdg->getButtonGroup(),SIGNAL(buttonClicked(int)),this,SLOT(onValueChanged()));
1316 customWidgets()->append( ignoreWdg );
1319 tr( h->GetIsToIgnoreEdges() ? "SMESH_EDGES_WO_LAYERS" : "SMESH_EDGES_WITH_LAYERS" );
1322 StdMeshersGUI_SubShapeSelectorWdg* idsWg =
1323 new StdMeshersGUI_SubShapeSelectorWdg(0,TopAbs_EDGE);
1325 idsWg->SetMainShapeEntry( aMainEntry );
1326 idsWg->SetGeomShapeEntry( aSubEntry.isEmpty() ? aMainEntry : aSubEntry );
1327 idsWg->SetListOfIDs( h->GetEdges() );
1328 idsWg->showPreview( true );
1329 customWidgets()->append ( idsWg );
1332 // else if (hypType() == "QuadrangleParams")
1334 // StdMeshers::StdMeshers_QuadrangleParams_var h =
1335 // StdMeshers::StdMeshers_QuadrangleParams::_narrow(hyp);
1337 // item.myName = tr("SMESH_BASE_VERTEX");
1340 // StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget =
1341 // new StdMeshersGUI_SubShapeSelectorWdg(0, TopAbs_VERTEX);
1342 // aDirectionWidget->SetMaxSize(1);
1343 // QString anEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
1344 // QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
1345 // if (anEntry == "")
1346 // anEntry = h->GetObjectEntry();
1347 // aDirectionWidget->SetGeomShapeEntry(anEntry);
1348 // aDirectionWidget->SetMainShapeEntry(aMainEntry);
1349 // if (!isCreation()) {
1350 // SMESH::long_array_var aVec = new SMESH::long_array;
1351 // int vertID = h->GetTriaVertex();
1352 // if (vertID > 0) {
1354 // aVec[0] = vertID;
1355 // aDirectionWidget->SetListOfIDs(aVec);
1358 // aDirectionWidget->showPreview(true);
1360 // item.myName = tr("SMESH_QUAD_TYPE");
1363 // StdMeshersGUI_QuadrangleParamWdg* aTypeWidget =
1364 // new StdMeshersGUI_QuadrangleParamWdg();
1365 // if (!isCreation()) {
1366 // aTypeWidget->SetType(int(h->GetQuadType()));
1369 // customWidgets()->append(aDirectionWidget);
1370 // customWidgets()->append(aTypeWidget);
1377 //================================================================================
1379 * \brief tune "standard" control
1380 * \param w - control widget
1381 * \param int - parameter index
1383 //================================================================================
1385 void StdMeshersGUI_StdHypothesisCreator::attuneStdWidget (QWidget* w, const int) const
1387 SMESHGUI_SpinBox* sb = w->inherits( "SMESHGUI_SpinBox" ) ? ( SMESHGUI_SpinBox* )w : 0;
1390 if( hypType()=="LocalLength" )
1392 if (sb->objectName() == tr("SMESH_LOCAL_LENGTH_PARAM"))
1393 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1394 else if (sb->objectName() == tr("SMESH_LOCAL_LENGTH_PRECISION"))
1395 sb->RangeStepAndValidator( 0.0, 1.0, 0.05, "len_tol_precision" );
1397 else if( hypType()=="Arithmetic1D" )
1399 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "parametric_precision" );
1401 else if( hypType()=="GeometricProgression" )
1403 if (sb->objectName() == tr("SMESH_START_LENGTH_PARAM"))
1404 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1405 else if (sb->objectName() == tr("SMESH_COMMON_RATIO"))
1406 sb->RangeStepAndValidator( -VALUE_MAX, VALUE_MAX, 0.5, "len_tol_precision" );
1408 else if( hypType()=="MaxLength" )
1410 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1411 sb->setEnabled( !widget< QCheckBox >( 1 )->isChecked() );
1413 else if( hypType()=="MaxElementArea" )
1415 sb->RangeStepAndValidator( VALUE_SMALL_2, VALUE_MAX_2, 1.0, "area_precision" );
1417 else if( hypType()=="MaxElementVolume" )
1419 sb->RangeStepAndValidator( VALUE_SMALL_3, VALUE_MAX_3, 1.0, "vol_precision" );
1421 else if( hypType()=="StartEndLength" )
1423 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1425 else if( hypType()=="Deflection1D" )
1427 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "parametric_precision" );
1429 else if( hypType()=="Adaptive1D" )
1431 if (sb->objectName() == tr("SMESH_GRADING1D_PARAM"))
1432 sb->RangeStepAndValidator( 0.0, 2.0, 0.1, "length_precision" );
1434 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1436 else if( hypType().startsWith( "ViscousLayers" ))
1438 if (sb->objectName() == tr("SMESH_STRETCH_FACTOR"))
1439 sb->RangeStepAndValidator( 1.0, VALUE_MAX, 0.1, "parametric_precision" );
1441 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1443 else // default validator for possible ancestors
1445 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1450 //================================================================================
1452 * \brief Return dlg title
1453 * \retval QString - title string
1455 //================================================================================
1457 QString StdMeshersGUI_StdHypothesisCreator::caption() const
1459 return tr( QString( "SMESH_%1_TITLE" ).arg( hypTypeName( hypType() ) ).toLatin1().data() );
1462 //================================================================================
1464 * \brief return pixmap for dlg icon
1467 //================================================================================
1469 QPixmap StdMeshersGUI_StdHypothesisCreator::icon() const
1471 QString hypIconName = tr( QString( "ICON_DLG_%1" ).arg( hypTypeName( hypType() ) ).toLatin1().data() );
1472 return SMESHGUI::resourceMgr()->loadPixmap( "SMESH", hypIconName );
1475 //================================================================================
1477 * \brief Return hypothesis type name to show in dlg
1480 //================================================================================
1482 QString StdMeshersGUI_StdHypothesisCreator::type() const
1484 return tr( QString( "SMESH_%1_HYPOTHESIS" ).arg( hypTypeName( hypType() ) ).toLatin1().data() );
1487 //================================================================================
1489 * \brief String to insert in "SMESH_%1_HYPOTHESIS" to get hypothesis type name
1490 * from message resouce file
1491 * \param t - hypothesis type
1492 * \retval QString - result string
1494 //================================================================================
1496 QString StdMeshersGUI_StdHypothesisCreator::hypTypeName( const QString& t ) const
1498 static QMap<QString,QString> types;
1499 if( types.isEmpty() )
1501 types.insert( "LocalLength", "LOCAL_LENGTH" );
1502 types.insert( "NumberOfSegments", "NB_SEGMENTS" );
1503 types.insert( "MaxElementArea", "MAX_ELEMENT_AREA" );
1504 types.insert( "MaxElementVolume", "MAX_ELEMENT_VOLUME" );
1505 types.insert( "StartEndLength", "START_END_LENGTH" );
1506 types.insert( "Deflection1D", "DEFLECTION1D" );
1507 types.insert( "Adaptive1D", "ADAPTIVE1D" );
1508 types.insert( "Arithmetic1D", "ARITHMETIC_1D" );
1509 types.insert( "GeometricProgression", "GEOMETRIC_1D" );
1510 types.insert( "FixedPoints1D", "FIXED_POINTS_1D" );
1511 types.insert( "AutomaticLength", "AUTOMATIC_LENGTH" );
1512 types.insert( "ProjectionSource1D", "PROJECTION_SOURCE_1D" );
1513 types.insert( "ProjectionSource2D", "PROJECTION_SOURCE_2D" );
1514 types.insert( "ProjectionSource3D", "PROJECTION_SOURCE_3D" );
1515 types.insert( "ImportSource1D", "IMPORT_SOURCE_1D" );
1516 types.insert( "ImportSource2D", "IMPORT_SOURCE_2D" );
1517 types.insert( "NumberOfLayers", "NUMBER_OF_LAYERS" );
1518 types.insert( "LayerDistribution", "LAYER_DISTRIBUTION" );
1519 types.insert( "NumberOfLayers2D", "NUMBER_OF_LAYERS_2D" );
1520 types.insert( "LayerDistribution2D", "LAYER_DISTRIBUTION" );
1521 types.insert( "SegmentLengthAroundVertex", "SEGMENT_LENGTH_AROUND_VERTEX" );
1522 types.insert( "MaxLength", "MAX_LENGTH" );
1523 types.insert( "ViscousLayers", "VISCOUS_LAYERS" );
1524 types.insert( "ViscousLayers2D", "VISCOUS_LAYERS" );
1525 types.insert( "QuadrangleParams", "QUADRANGLE_PARAMS" );
1526 types.insert( "CartesianParameters3D", "CARTESIAN_PARAMS" );
1530 if( types.contains( t ) )
1537 //=======================================================================
1538 //function : getCustomWidget
1539 //purpose : is called from buildStdFrame()
1540 //=======================================================================
1542 QWidget* StdMeshersGUI_StdHypothesisCreator::getCustomWidget( const StdParam & param,
1544 const int index) const
1547 if ( index < customWidgets()->count() ) {
1548 w = customWidgets()->at( index );
1550 w->setParent( parent );
1551 w->move( QPoint( 0, 0 ) );
1557 //================================================================================
1559 * \brief Set param value taken from a custom widget
1560 * \param param - SMESHGUI_GenericHypothesisCreator::StdParam structure
1561 * \param widget - widget presenting param
1562 * \retval bool - success flag
1564 * this method is called from getStdParamFromDlg()
1566 //================================================================================
1568 bool StdMeshersGUI_StdHypothesisCreator::getParamFromCustomWidget( StdParam & param,
1569 QWidget* widget) const
1571 if ( hypType()=="AutomaticLength" ) {
1572 SMESHGUI_SpinBox* w = dynamic_cast<SMESHGUI_SpinBox*>( widget );
1574 param.myValue = w->GetValue();
1578 if ( hypType() == "MaxLength" ) {
1582 if ( widget->inherits( "StdMeshersGUI_ObjectReferenceParamWdg" ))
1584 // show only 1st reference value
1585 if ( true /*widget == getWidgetForParam( 0 )*/) {
1586 const StdMeshersGUI_ObjectReferenceParamWdg * w =
1587 static_cast<const StdMeshersGUI_ObjectReferenceParamWdg*>( widget );
1588 param.myValue = w->GetValue();
1592 if ( widget->inherits( "StdMeshersGUI_LayerDistributionParamWdg" ))
1594 const StdMeshersGUI_LayerDistributionParamWdg * w =
1595 static_cast<const StdMeshersGUI_LayerDistributionParamWdg*>( widget );
1596 param.myValue = w->GetValue();
1599 if ( widget->inherits( "StdMeshersGUI_SubShapeSelectorWdg" ))
1601 const StdMeshersGUI_SubShapeSelectorWdg * w =
1602 static_cast<const StdMeshersGUI_SubShapeSelectorWdg*>( widget );
1603 param.myValue = w->GetValue();
1606 // if ( widget->inherits( "StdMeshersGUI_QuadrangleParamWdg" ))
1608 // param.myValue = "QuadType";
1611 if ( widget->inherits( "StdMeshersGUI_FixedPointsParamWdg" ))
1613 const StdMeshersGUI_FixedPointsParamWdg * w =
1614 static_cast<const StdMeshersGUI_FixedPointsParamWdg*>( widget );
1615 param.myValue = w->GetValue();
1618 if ( widget->inherits( "QCheckBox" ))
1620 //const QCheckBox * w = static_cast<const QCheckBox*>( widget );
1621 //param.myValue = w->isChecked();
1624 if ( widget->inherits( "StdMeshersGUI_RadioButtonsGrpWdg" ))
1626 const StdMeshersGUI_RadioButtonsGrpWdg * w =
1627 static_cast<const StdMeshersGUI_RadioButtonsGrpWdg*>( widget );
1628 param.myValue = w->checkedId();
1634 //================================================================================
1636 * \brief called when operation cancelled
1638 //================================================================================
1640 void StdMeshersGUI_StdHypothesisCreator::onReject()
1642 if ( hypType().startsWith("ProjectionSource" ) ||
1643 hypType().startsWith("ImportSource" ))
1645 // Uninstall filters of StdMeshersGUI_ObjectReferenceParamWdg
1646 deactivateObjRefParamWdg( customWidgets() );
1650 //================================================================================
1652 * \brief Update widgets dependent on paramWidget
1654 //================================================================================
1656 void StdMeshersGUI_StdHypothesisCreator::valueChanged( QWidget* paramWidget)
1658 if ( hypType() == "MaxLength" && paramWidget == getWidgetForParam(1) )
1660 getWidgetForParam(0)->setEnabled( !widget< QCheckBox >( 1 )->isChecked() );
1661 if ( !getWidgetForParam(0)->isEnabled() ) {
1662 StdMeshers::StdMeshers_MaxLength_var h =
1663 StdMeshers::StdMeshers_MaxLength::_narrow( initParamsHypothesis() );
1664 widget< QtxDoubleSpinBox >( 0 )->setValue( h->GetPreestimatedLength() );
1667 else if ( hypType().startsWith("ImportSource") && paramWidget == getWidgetForParam(1) )
1669 QCheckBox* toCopyMesh = (QCheckBox*) paramWidget;
1670 QCheckBox* toCopyGroups = widget< QCheckBox >( 2 );
1671 if ( !toCopyMesh->isChecked() )
1673 toCopyGroups->setChecked( false );
1674 toCopyGroups->setEnabled( false );
1678 toCopyGroups->setEnabled( true );
1681 else if ( hypType().startsWith( "ViscousLayers" ) && paramWidget->inherits("QButtonGroup"))
1683 if ( QLabel* label = getLabel(4) )
1685 bool toIgnore = widget< StdMeshersGUI_RadioButtonsGrpWdg >( 3 )->checkedId();
1686 if ( hypType() == "ViscousLayers2D" )
1687 label->setText( tr( toIgnore ? "SMESH_EDGES_WO_LAYERS" : "SMESH_EDGES_WITH_LAYERS" ));
1689 label->setText( tr( toIgnore ? "SMESH_FACES_WO_LAYERS" : "SMESH_FACES_WITH_LAYERS" ));
1694 //================================================================================
1698 //================================================================================
1700 bool StdMeshersGUI_StdHypothesisCreator::initVariableName(SMESH::SMESH_Hypothesis_var theHyp,
1701 StdParam & theParams,
1702 const char* theMethod) const
1704 QString aVaribaleName = getVariableName( theMethod );
1705 theParams.isVariable = !aVaribaleName.isEmpty();
1706 if (theParams.isVariable)
1707 theParams.myValue = aVaribaleName;
1709 return theParams.isVariable;