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() );
613 else if( hypType()=="AutomaticLength" )
615 StdMeshers::StdMeshers_AutomaticLength_var h =
616 StdMeshers::StdMeshers_AutomaticLength::_narrow( hypothesis() );
618 h->SetVarParameter( params[0].text(), "SetFineness" );
619 h->SetFineness( params[0].myValue.toDouble() );
621 else if( hypType()=="NumberOfLayers" )
623 StdMeshers::StdMeshers_NumberOfLayers_var h =
624 StdMeshers::StdMeshers_NumberOfLayers::_narrow( hypothesis() );
626 h->SetVarParameter( params[0].text(), "SetNumberOfLayers" );
627 h->SetNumberOfLayers( params[0].myValue.toInt() );
629 else if( hypType()=="LayerDistribution" )
631 StdMeshers::StdMeshers_LayerDistribution_var h =
632 StdMeshers::StdMeshers_LayerDistribution::_narrow( hypothesis() );
633 StdMeshersGUI_LayerDistributionParamWdg* w =
634 widget< StdMeshersGUI_LayerDistributionParamWdg >( 0 );
636 h->SetLayerDistribution( w->GetHypothesis() );
638 else if( hypType()=="NumberOfLayers2D" )
640 StdMeshers::StdMeshers_NumberOfLayers2D_var h =
641 StdMeshers::StdMeshers_NumberOfLayers2D::_narrow( hypothesis() );
643 h->SetVarParameter( params[0].text(), "SetNumberOfLayers" );
644 h->SetNumberOfLayers( params[0].myValue.toInt() );
646 else if( hypType()=="LayerDistribution2D" )
648 StdMeshers::StdMeshers_LayerDistribution2D_var h =
649 StdMeshers::StdMeshers_LayerDistribution2D::_narrow( hypothesis() );
650 StdMeshersGUI_LayerDistributionParamWdg* w =
651 widget< StdMeshersGUI_LayerDistributionParamWdg >( 0 );
653 h->SetLayerDistribution( w->GetHypothesis() );
655 else if( hypType()=="ProjectionSource1D" )
657 StdMeshers::StdMeshers_ProjectionSource1D_var h =
658 StdMeshers::StdMeshers_ProjectionSource1D::_narrow( hypothesis() );
660 h->SetSourceEdge ( geomFromWdg ( getWidgetForParam( 0 )));
661 h->SetSourceMesh ( meshFromWdg ( getWidgetForParam( 1 )));
662 h->SetVertexAssociation( geomFromWdg ( getWidgetForParam( 2 )),
663 geomFromWdg ( getWidgetForParam( 3 )));
665 else if( hypType()=="ProjectionSource2D" )
667 StdMeshers::StdMeshers_ProjectionSource2D_var h =
668 StdMeshers::StdMeshers_ProjectionSource2D::_narrow( hypothesis() );
670 h->SetSourceFace ( geomFromWdg ( getWidgetForParam( 0 )));
671 h->SetSourceMesh ( meshFromWdg ( getWidgetForParam( 1 )));
672 h->SetVertexAssociation( geomFromWdg ( getWidgetForParam( 2 )), // src1
673 geomFromWdg ( getWidgetForParam( 4 )), // src2
674 geomFromWdg ( getWidgetForParam( 3 )), // tgt1
675 geomFromWdg ( getWidgetForParam( 5 ))); // tgt2
677 else if( hypType()=="ProjectionSource3D" )
679 StdMeshers::StdMeshers_ProjectionSource3D_var h =
680 StdMeshers::StdMeshers_ProjectionSource3D::_narrow( hypothesis() );
682 h->SetSource3DShape ( geomFromWdg ( getWidgetForParam( 0 )));
683 h->SetSourceMesh ( meshFromWdg ( getWidgetForParam( 1 )));
684 h->SetVertexAssociation( geomFromWdg ( getWidgetForParam( 2 )), // src1
685 geomFromWdg ( getWidgetForParam( 4 )), // src2
686 geomFromWdg ( getWidgetForParam( 3 )), // tgt1
687 geomFromWdg ( getWidgetForParam( 5 ))); // tgt2
689 else if( hypType()=="ImportSource1D" )
691 StdMeshers::StdMeshers_ImportSource1D_var h =
692 StdMeshers::StdMeshers_ImportSource1D::_narrow( hypothesis() );
694 SMESH::ListOfGroups_var groups = groupsFromWdg( getWidgetForParam( 0 ));
695 h->SetSourceEdges( groups.in() );
696 QCheckBox* toCopyMesh = widget< QCheckBox >( 1 );
697 QCheckBox* toCopyGroups = widget< QCheckBox >( 2 );
698 h->SetCopySourceMesh( toCopyMesh->isChecked(), toCopyGroups->isChecked());
700 else if( hypType()=="ImportSource2D" )
702 StdMeshers::StdMeshers_ImportSource2D_var h =
703 StdMeshers::StdMeshers_ImportSource2D::_narrow( hypothesis() );
705 SMESH::ListOfGroups_var groups = groupsFromWdg( getWidgetForParam( 0 ));
706 h->SetSourceFaces( groups.in() );
707 QCheckBox* toCopyMesh = widget< QCheckBox >( 1 );
708 QCheckBox* toCopyGroups = widget< QCheckBox >( 2 );
709 h->SetCopySourceMesh( toCopyMesh->isChecked(), toCopyGroups->isChecked());
711 else if( hypType()=="ViscousLayers" )
713 StdMeshers::StdMeshers_ViscousLayers_var h =
714 StdMeshers::StdMeshers_ViscousLayers::_narrow( hypothesis() );
716 h->SetVarParameter( params[0].text(), "SetTotalThickness" );
717 h->SetTotalThickness( params[0].myValue.toDouble() );
718 h->SetVarParameter( params[1].text(), "SetNumberLayers" );
719 h->SetNumberLayers ( params[1].myValue.toInt() );
720 h->SetVarParameter( params[2].text(), "SetStretchFactor" );
721 h->SetStretchFactor ( params[2].myValue.toDouble() );
723 if ( StdMeshersGUI_SubShapeSelectorWdg* idsWg =
724 widget< StdMeshersGUI_SubShapeSelectorWdg >( 4 ))
726 h->SetFaces( idsWg->GetListOfIDs(), params[3].myValue.toInt() );
729 else if( hypType()=="ViscousLayers2D" )
731 StdMeshers::StdMeshers_ViscousLayers2D_var h =
732 StdMeshers::StdMeshers_ViscousLayers2D::_narrow( hypothesis() );
734 h->SetVarParameter( params[0].text(), "SetTotalThickness" );
735 h->SetTotalThickness( params[0].myValue.toDouble() );
736 h->SetVarParameter( params[1].text(), "SetNumberLayers" );
737 h->SetNumberLayers ( params[1].myValue.toInt() );
738 h->SetVarParameter( params[2].text(), "SetStretchFactor" );
739 h->SetStretchFactor ( params[2].myValue.toDouble() );
741 if ( StdMeshersGUI_SubShapeSelectorWdg* idsWg =
742 widget< StdMeshersGUI_SubShapeSelectorWdg >( 4 ))
744 h->SetEdges( idsWg->GetListOfIDs(), params[3].myValue.toInt() );
747 // else if( hypType()=="QuadrangleParams" )
749 // StdMeshers::StdMeshers_QuadrangleParams_var h =
750 // StdMeshers::StdMeshers_QuadrangleParams::_narrow( hypothesis() );
751 // StdMeshersGUI_SubShapeSelectorWdg* w1 =
752 // widget< StdMeshersGUI_SubShapeSelectorWdg >( 0 );
753 // StdMeshersGUI_QuadrangleParamWdg* w2 =
754 // widget< StdMeshersGUI_QuadrangleParamWdg >( 1 );
756 // if (w1->GetListSize() > 0) {
757 // h->SetTriaVertex(w1->GetListOfIDs()[0]); // getlist must be called once
758 // const char * entry = w1->GetMainShapeEntry();
759 // h->SetObjectEntry(entry);
761 // h->SetQuadType(StdMeshers::QuadType(w2->GetType()));
768 //================================================================================
770 * \brief Return parameter values as SMESHGUI_GenericHypothesisCreator::StdParam
771 * \param p - list of parameters
772 * \retval bool - success flag
774 * Is called from SMESHGUI_GenericHypothesisCreator::buildStdFrame().
775 * Parameters will be shown using "standard" controls:
776 * Int by QtxIntSpinBox
777 * Double by SMESHGUI_SpinBox
778 * String by QLineEdit
779 * getCustomWidget() allows to redefine control for a parameter
781 //================================================================================
783 bool StdMeshersGUI_StdHypothesisCreator::stdParams( ListOfStdParams& p ) const
786 SMESHGUI_GenericHypothesisCreator::StdParam item;
789 customWidgets()->clear();
792 HypothesisData* data = SMESH::GetHypothesisData( hypType() );
793 item.myName = tr( "SMESH_NAME" );
794 item.myValue = data ? hypName() : QString();
796 customWidgets()->append(0);
799 SMESH::SMESH_Hypothesis_var hyp = initParamsHypothesis();
800 //SMESH::ListOfParameters_var aParameters = hyp->GetLastParameters();
802 if( hypType()=="LocalLength" )
804 StdMeshers::StdMeshers_LocalLength_var h =
805 StdMeshers::StdMeshers_LocalLength::_narrow( hyp );
807 item.myName = tr("SMESH_LOCAL_LENGTH_PARAM");
808 if(!initVariableName( hyp, item, "SetLength"))
809 item.myValue = h->GetLength();
812 item.myName = tr("SMESH_LOCAL_LENGTH_PRECISION");
813 if(!initVariableName( hyp, item, "SetPrecision"))
814 item.myValue = h->GetPrecision();
817 else if( hypType()=="MaxLength" )
819 StdMeshers::StdMeshers_MaxLength_var h =
820 StdMeshers::StdMeshers_MaxLength::_narrow( hyp );
821 // try to set a right preestimated length to edited hypothesis
822 bool noPreestimatedAtEdition = false;
823 if ( !isCreation() ) {
824 StdMeshers::StdMeshers_MaxLength_var initHyp =
825 StdMeshers::StdMeshers_MaxLength::_narrow( initParamsHypothesis(true) );
826 noPreestimatedAtEdition =
827 ( initHyp->_is_nil() || !initHyp->HavePreestimatedLength() );
828 if ( !noPreestimatedAtEdition )
829 h->SetPreestimatedLength( initHyp->GetPreestimatedLength() );
832 item.myName = tr("SMESH_LOCAL_LENGTH_PARAM");
833 if(!initVariableName( hyp, item, "SetLength"))
834 item.myValue = h->GetLength();
836 customWidgets()->append(0);
838 item.myName = tr("SMESH_USE_PREESTIMATED_LENGTH");
840 QCheckBox* aQCheckBox = new QCheckBox(dlg());
841 if ( !noPreestimatedAtEdition && h->HavePreestimatedLength() ) {
842 aQCheckBox->setChecked( h->GetUsePreestimatedLength() );
843 connect( aQCheckBox, SIGNAL( stateChanged(int) ), this, SLOT( onValueChanged() ) );
846 aQCheckBox->setChecked( false );
847 aQCheckBox->setEnabled( false );
849 customWidgets()->append( aQCheckBox );
851 else if( hypType()=="SegmentLengthAroundVertex" )
853 StdMeshers::StdMeshers_SegmentLengthAroundVertex_var h =
854 StdMeshers::StdMeshers_SegmentLengthAroundVertex::_narrow( hyp );
856 item.myName = tr("SMESH_LOCAL_LENGTH_PARAM");
857 if(!initVariableName( hyp, item, "SetLength"))
858 item.myValue = h->GetLength();
862 else if( hypType()=="Arithmetic1D" )
864 StdMeshers::StdMeshers_Arithmetic1D_var h =
865 StdMeshers::StdMeshers_Arithmetic1D::_narrow( hyp );
867 item.myName = tr( "SMESH_START_LENGTH_PARAM" );
868 if(!initVariableName( hyp, item, "SetStartLength" ))
869 item.myValue = h->GetLength( true );
872 customWidgets()->append (0);
874 item.myName = tr( "SMESH_END_LENGTH_PARAM" );
875 if(!initVariableName( hyp, item, "SetEndLength" ))
876 item.myValue = h->GetLength( false );
879 customWidgets()->append (0);
881 item.myName = tr( "SMESH_REVERSED_EDGES" );
884 StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget =
885 new StdMeshersGUI_SubShapeSelectorWdg();
886 QString aGeomEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
887 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
888 if ( aGeomEntry == "" )
889 aGeomEntry = h->GetObjectEntry();
891 aDirectionWidget->SetGeomShapeEntry( aGeomEntry );
892 aDirectionWidget->SetMainShapeEntry( aMainEntry );
893 aDirectionWidget->SetListOfIDs( h->GetReversedEdges() );
894 aDirectionWidget->showPreview( true );
895 customWidgets()->append ( aDirectionWidget );
898 else if( hypType()=="GeometricProgression" )
900 StdMeshers::StdMeshers_Geometric1D_var h =
901 StdMeshers::StdMeshers_Geometric1D::_narrow( hyp );
903 item.myName = tr( "SMESH_START_LENGTH_PARAM" );
904 if(!initVariableName( hyp, item, "SetStartLength" ))
905 item.myValue = h->GetStartLength();
908 customWidgets()->append (0);
910 item.myName = tr( "SMESH_COMMON_RATIO" );
911 if(!initVariableName( hyp, item, "SetCommonRatio" ))
912 item.myValue = h->GetCommonRatio();
915 customWidgets()->append (0);
917 item.myName = tr( "SMESH_REVERSED_EDGES" );
920 StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget =
921 new StdMeshersGUI_SubShapeSelectorWdg();
922 QString aGeomEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
923 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
924 if ( aGeomEntry == "" )
925 aGeomEntry = h->GetObjectEntry();
927 aDirectionWidget->SetGeomShapeEntry( aGeomEntry );
928 aDirectionWidget->SetMainShapeEntry( aMainEntry );
929 aDirectionWidget->SetListOfIDs( h->GetReversedEdges() );
930 aDirectionWidget->showPreview( true );
931 customWidgets()->append ( aDirectionWidget );
934 else if( hypType()=="FixedPoints1D" )
936 StdMeshers::StdMeshers_FixedPoints1D_var h =
937 StdMeshers::StdMeshers_FixedPoints1D::_narrow( hyp );
939 item.myName = tr( "SMESH_FIXED_POINTS" );
942 StdMeshersGUI_FixedPointsParamWdg* aFixedPointsWidget =
943 new StdMeshersGUI_FixedPointsParamWdg();
945 if ( !isCreation() ) {
946 aFixedPointsWidget->SetListOfPoints( h->GetPoints() );
947 aFixedPointsWidget->SetListOfSegments( h->GetNbSegments() );
949 customWidgets()->append( aFixedPointsWidget );
951 item.myName = tr( "SMESH_REVERSED_EDGES" );
954 StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget =
955 new StdMeshersGUI_SubShapeSelectorWdg();
956 QString anEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
957 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
959 anEntry = h->GetObjectEntry();
960 aDirectionWidget->SetGeomShapeEntry( anEntry );
961 aDirectionWidget->SetMainShapeEntry( aMainEntry );
962 aDirectionWidget->SetListOfIDs( h->GetReversedEdges() );
963 aDirectionWidget->showPreview( true );
964 customWidgets()->append ( aDirectionWidget );
968 else if( hypType()=="MaxElementArea" )
970 StdMeshers::StdMeshers_MaxElementArea_var h =
971 StdMeshers::StdMeshers_MaxElementArea::_narrow( hyp );
973 item.myName = tr( "SMESH_MAX_ELEMENT_AREA_PARAM" );
974 if(!initVariableName( hyp, item, "SetMaxElementArea" ))
975 item.myValue = h->GetMaxElementArea();
979 else if( hypType()=="MaxElementVolume" )
981 StdMeshers::StdMeshers_MaxElementVolume_var h =
982 StdMeshers::StdMeshers_MaxElementVolume::_narrow( hyp );
984 item.myName = tr( "SMESH_MAX_ELEMENT_VOLUME_PARAM" );
985 if(!initVariableName( hyp, item, "SetMaxElementVolume" ))
986 item.myValue = h->GetMaxElementVolume();
989 else if( hypType()=="StartEndLength" )
991 StdMeshers::StdMeshers_StartEndLength_var h =
992 StdMeshers::StdMeshers_StartEndLength::_narrow( hyp );
994 item.myName = tr( "SMESH_START_LENGTH_PARAM" );
996 if(!initVariableName( hyp, item, "SetStartLength" ))
997 item.myValue = h->GetLength( true );
999 customWidgets()->append(0);
1001 item.myName = tr( "SMESH_END_LENGTH_PARAM" );
1002 if(!initVariableName( hyp, item, "SetEndLength" ))
1003 item.myValue = h->GetLength( false );
1005 customWidgets()->append(0);
1007 item.myName = tr( "SMESH_REVERSED_EDGES" );
1010 StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget =
1011 new StdMeshersGUI_SubShapeSelectorWdg();
1012 QString anEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
1013 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
1014 if ( anEntry == "" )
1015 anEntry = h->GetObjectEntry();
1016 aDirectionWidget->SetGeomShapeEntry( anEntry );
1017 aDirectionWidget->SetMainShapeEntry( aMainEntry );
1018 aDirectionWidget->SetListOfIDs( h->GetReversedEdges() );
1019 aDirectionWidget->showPreview( true );
1020 customWidgets()->append ( aDirectionWidget );
1022 else if( hypType()=="Deflection1D" )
1024 StdMeshers::StdMeshers_Deflection1D_var h =
1025 StdMeshers::StdMeshers_Deflection1D::_narrow( hyp );
1027 item.myName = tr( "SMESH_DEFLECTION1D_PARAM" );
1028 if(!initVariableName( hyp, item, "SetDeflection" ))
1029 item.myValue = h->GetDeflection();
1032 else if( hypType()=="Adaptive1D" )
1034 StdMeshers::StdMeshers_Adaptive1D_var h =
1035 StdMeshers::StdMeshers_Adaptive1D::_narrow( hyp );
1037 item.myName = tr( "SMESH_MIN_SIZE" );
1038 if(!initVariableName( hyp, item, "SetMinSize" ))
1039 item.myValue = h->GetMinSize();
1042 item.myName = tr( "SMESH_MAX_SIZE" );
1043 if(!initVariableName( hyp, item, "SetMaxSize" ))
1044 item.myValue = h->GetMaxSize();
1047 item.myName = tr( "SMESH_DEFLECTION1D_PARAM" );
1048 if(!initVariableName( hyp, item, "SetDeflection" ))
1049 item.myValue = h->GetDeflection();
1052 else if( hypType()=="AutomaticLength" )
1054 StdMeshers::StdMeshers_AutomaticLength_var h =
1055 StdMeshers::StdMeshers_AutomaticLength::_narrow( hyp );
1057 item.myName = tr( "SMESH_FINENESS_PARAM" );
1058 //item.myValue = h->GetFineness();
1060 SMESHGUI_SpinBox* _autoLengthSpinBox = new SMESHGUI_SpinBox(dlg());
1061 _autoLengthSpinBox->RangeStepAndValidator(0, 1, 0.01, "length_precision");
1062 _autoLengthSpinBox->SetValue(h->GetFineness());
1063 customWidgets()->append( _autoLengthSpinBox);
1065 else if( hypType()=="NumberOfLayers" )
1067 StdMeshers::StdMeshers_NumberOfLayers_var h =
1068 StdMeshers::StdMeshers_NumberOfLayers::_narrow( hyp );
1070 item.myName = tr( "SMESH_NUMBER_OF_LAYERS" );
1071 if(!initVariableName( hyp, item, "SetNumberOfLayers" ))
1072 item.myValue = (int) h->GetNumberOfLayers();
1075 else if( hypType()=="LayerDistribution" )
1077 StdMeshers::StdMeshers_LayerDistribution_var h =
1078 StdMeshers::StdMeshers_LayerDistribution::_narrow( hyp );
1080 item.myName = tr( "SMESH_LAYERS_DISTRIBUTION" ); p.append( item );
1081 initVariableName( hyp, item, "SetLayerDistribution" );
1082 customWidgets()->append ( new StdMeshersGUI_LayerDistributionParamWdg
1083 ( h, h->GetLayerDistribution(), hypName(), dlg() ));
1085 else if( hypType()=="NumberOfLayers2D" )
1087 StdMeshers::StdMeshers_NumberOfLayers2D_var h =
1088 StdMeshers::StdMeshers_NumberOfLayers2D::_narrow( hyp );
1090 item.myName = tr( "SMESH_NUMBER_OF_LAYERS" );
1091 if(!initVariableName( hyp, item, "SetNumberOfLayers" ))
1092 item.myValue = (int) h->GetNumberOfLayers();
1095 else if( hypType()=="LayerDistribution2D" )
1097 StdMeshers::StdMeshers_LayerDistribution2D_var h =
1098 StdMeshers::StdMeshers_LayerDistribution2D::_narrow( hyp );
1100 item.myName = tr( "SMESH_LAYERS_DISTRIBUTION" ); p.append( item );
1101 initVariableName( hyp, item, "SetLayerDistribution" );
1102 customWidgets()->append ( new StdMeshersGUI_LayerDistributionParamWdg
1103 ( h, h->GetLayerDistribution(), hypName(), dlg() ));
1105 else if( hypType()=="ProjectionSource1D" )
1107 StdMeshers::StdMeshers_ProjectionSource1D_var h =
1108 StdMeshers::StdMeshers_ProjectionSource1D::_narrow( hyp );
1110 item.myName = tr( "SMESH_SOURCE_EDGE" ); p.append( item );
1111 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 1 ),
1112 h->GetSourceEdge()));
1113 item.myName = tr( "SMESH_SOURCE_MESH" ); p.append( item );
1114 customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( SMESH::MESH ),
1115 h->GetSourceMesh()));
1116 item.myName = tr( "SMESH_SOURCE_VERTEX" ); p.append( item );
1117 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1118 h->GetSourceVertex()));
1119 item.myName = tr( "SMESH_TARGET_VERTEX" ); p.append( item );
1120 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1121 h->GetTargetVertex()));
1123 else if( hypType()=="ProjectionSource2D" )
1125 StdMeshers::StdMeshers_ProjectionSource2D_var h =
1126 StdMeshers::StdMeshers_ProjectionSource2D::_narrow( hyp );
1128 item.myName = tr( "SMESH_SOURCE_FACE" ); p.append( item );
1129 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 2 ),
1130 h->GetSourceFace()));
1131 item.myName = tr( "SMESH_SOURCE_MESH" ); p.append( item );
1132 customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( SMESH::MESH ),
1133 h->GetSourceMesh()));
1134 item.myName = tr( "SMESH_SOURCE_VERTEX1" ); p.append( item );
1135 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1136 h->GetSourceVertex( 1 )));
1137 item.myName = tr( "SMESH_TARGET_VERTEX1" ); p.append( item );
1138 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1139 h->GetTargetVertex( 1 )));
1140 item.myName = tr( "SMESH_SOURCE_VERTEX2" ); p.append( item );
1141 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1142 h->GetSourceVertex( 2 )));
1143 item.myName = tr( "SMESH_TARGET_VERTEX2" ); p.append( item );
1144 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1145 h->GetTargetVertex( 2 )));
1147 else if( hypType()=="ProjectionSource3D" )
1149 StdMeshers::StdMeshers_ProjectionSource3D_var h =
1150 StdMeshers::StdMeshers_ProjectionSource3D::_narrow( hyp );
1152 item.myName = tr( "SMESH_SOURCE_3DSHAPE" ); p.append( item );
1153 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 3, TopAbs_FACE, 6, true ),
1154 h->GetSource3DShape()));
1155 item.myName = tr( "SMESH_SOURCE_MESH" ); p.append( item );
1156 customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( SMESH::MESH ),
1157 h->GetSourceMesh()));
1158 item.myName = tr( "SMESH_SOURCE_VERTEX1" ); p.append( item );
1159 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1160 h->GetSourceVertex( 1 )));
1161 item.myName = tr( "SMESH_TARGET_VERTEX1" ); p.append( item );
1162 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1163 h->GetTargetVertex( 1 )));
1164 item.myName = tr( "SMESH_SOURCE_VERTEX2" ); p.append( item );
1165 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1166 h->GetSourceVertex( 2 )));
1167 item.myName = tr( "SMESH_TARGET_VERTEX2" ); p.append( item );
1168 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1169 h->GetTargetVertex( 2 )));
1171 else if( hypType()=="ImportSource1D" )
1173 StdMeshers::StdMeshers_ImportSource1D_var h =
1174 StdMeshers::StdMeshers_ImportSource1D::_narrow( hyp );
1176 SMESH::string_array_var groupEntries = h->GetSourceEdges();
1177 CORBA::Boolean toCopyMesh, toCopyGroups;
1178 h->GetCopySourceMesh(toCopyMesh, toCopyGroups);
1180 item.myName = tr( "SMESH_SOURCE_EDGES" ); p.append( item );
1181 customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( SMESH::GROUP_EDGE ),
1184 item.myName = tr( "SMESH_COPY_MESH" ); p.append( item );
1185 QCheckBox* aQCheckBox = new QCheckBox(dlg());
1186 aQCheckBox->setChecked( toCopyMesh );
1187 connect( aQCheckBox, SIGNAL( stateChanged(int) ), this, SLOT( onValueChanged() ));
1188 customWidgets()->append( aQCheckBox );
1190 item.myName = tr( "SMESH_TO_COPY_GROUPS" ); p.append( item );
1191 aQCheckBox = new QCheckBox(dlg());
1192 aQCheckBox->setChecked( toCopyGroups );
1193 aQCheckBox->setEnabled( toCopyMesh );
1194 customWidgets()->append( aQCheckBox );
1196 else if( hypType()=="ImportSource2D" )
1198 StdMeshers::StdMeshers_ImportSource2D_var h =
1199 StdMeshers::StdMeshers_ImportSource2D::_narrow( hyp );
1201 SMESH::string_array_var groupEntries = h->GetSourceFaces();
1202 CORBA::Boolean toCopyMesh, toCopyGroups;
1203 h->GetCopySourceMesh(toCopyMesh, toCopyGroups);
1205 item.myName = tr( "SMESH_SOURCE_FACES" ); p.append( item );
1206 customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( SMESH::GROUP_FACE ),
1209 item.myName = tr( "SMESH_COPY_MESH" ); p.append( item );
1210 QCheckBox* aQCheckBox = new QCheckBox(dlg());
1211 aQCheckBox->setChecked( toCopyMesh );
1212 connect( aQCheckBox, SIGNAL( stateChanged(int) ), this, SLOT( onValueChanged() ));
1213 customWidgets()->append( aQCheckBox );
1215 item.myName = tr( "SMESH_COPY_GROUPS" ); p.append( item );
1216 aQCheckBox = new QCheckBox(dlg());
1217 aQCheckBox->setChecked( toCopyGroups );
1218 aQCheckBox->setEnabled( toCopyMesh );
1219 customWidgets()->append( aQCheckBox );
1221 else if( hypType()=="ViscousLayers" )
1223 StdMeshers::StdMeshers_ViscousLayers_var h =
1224 StdMeshers::StdMeshers_ViscousLayers::_narrow( hyp );
1226 item.myName = tr( "SMESH_TOTAL_THICKNESS" );
1227 if(!initVariableName( hyp, item, "SetTotalThickness" ))
1228 item.myValue = h->GetTotalThickness();
1230 customWidgets()->append (0);
1232 item.myName = tr( "SMESH_NUMBER_OF_LAYERS" );
1233 if(!initVariableName( hyp, item, "SetNumberLayers" ))
1234 item.myValue = h->GetNumberLayers();
1236 customWidgets()->append (0);
1238 item.myName = tr( "SMESH_STRETCH_FACTOR" );
1239 if(!initVariableName( hyp, item, "SetStretchFactor" ))
1240 item.myValue = h->GetStretchFactor();
1242 customWidgets()->append (0);
1244 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
1245 QString aSubEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
1246 if ( !aMainEntry.isEmpty() )
1248 item.myName = tr( "TO_IGNORE_FACES_OR_NOT" );
1251 StdMeshersGUI_RadioButtonsGrpWdg* ignoreWdg = new StdMeshersGUI_RadioButtonsGrpWdg("");
1252 ignoreWdg->setButtonLabels ( QStringList()
1253 << tr("NOT_TO_IGNORE_FACES")
1254 << tr("TO_IGNORE_FACES") );
1255 ignoreWdg->setChecked( h->GetIsToIgnoreFaces() );
1256 connect(ignoreWdg->getButtonGroup(),SIGNAL(buttonClicked(int)),this,SLOT(onValueChanged()));
1257 customWidgets()->append( ignoreWdg );
1260 tr( h->GetIsToIgnoreFaces() ? "SMESH_FACES_WO_LAYERS" : "SMESH_FACES_WITH_LAYERS" );
1263 StdMeshersGUI_SubShapeSelectorWdg* idsWg =
1264 new StdMeshersGUI_SubShapeSelectorWdg(0,TopAbs_FACE);
1266 idsWg->SetMainShapeEntry( aMainEntry );
1267 idsWg->SetGeomShapeEntry( aSubEntry.isEmpty() ? aMainEntry : aSubEntry );
1268 idsWg->SetListOfIDs( h->GetFaces() );
1269 idsWg->showPreview( true );
1270 customWidgets()->append ( idsWg );
1273 else if( hypType()=="ViscousLayers2D" )
1275 StdMeshers::StdMeshers_ViscousLayers2D_var h =
1276 StdMeshers::StdMeshers_ViscousLayers2D::_narrow( hyp );
1278 item.myName = tr( "SMESH_TOTAL_THICKNESS" );
1279 if(!initVariableName( hyp, item, "SetTotalThickness" ))
1280 item.myValue = h->GetTotalThickness();
1282 customWidgets()->append (0);
1284 item.myName = tr( "SMESH_NUMBER_OF_LAYERS" );
1285 if(!initVariableName( hyp, item, "SetNumberLayers" ))
1286 item.myValue = h->GetNumberLayers();
1288 customWidgets()->append (0);
1290 item.myName = tr( "SMESH_STRETCH_FACTOR" );
1291 if(!initVariableName( hyp, item, "SetStretchFactor" ))
1292 item.myValue = h->GetStretchFactor();
1294 customWidgets()->append (0);
1296 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
1297 QString aSubEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
1298 if ( !aMainEntry.isEmpty() )
1300 item.myName = tr("TO_IGNORE_EDGES_OR_NOT");
1303 StdMeshersGUI_RadioButtonsGrpWdg* ignoreWdg = new StdMeshersGUI_RadioButtonsGrpWdg("");
1304 ignoreWdg->setButtonLabels ( QStringList()
1305 << tr("NOT_TO_IGNORE_EDGES")
1306 << tr("TO_IGNORE_EDGES") );
1307 ignoreWdg->setChecked( h->GetIsToIgnoreEdges() );
1308 connect(ignoreWdg->getButtonGroup(),SIGNAL(buttonClicked(int)),this,SLOT(onValueChanged()));
1309 customWidgets()->append( ignoreWdg );
1312 tr( h->GetIsToIgnoreEdges() ? "SMESH_EDGES_WO_LAYERS" : "SMESH_EDGES_WITH_LAYERS" );
1315 StdMeshersGUI_SubShapeSelectorWdg* idsWg =
1316 new StdMeshersGUI_SubShapeSelectorWdg(0,TopAbs_EDGE);
1318 idsWg->SetMainShapeEntry( aMainEntry );
1319 idsWg->SetGeomShapeEntry( aSubEntry.isEmpty() ? aMainEntry : aSubEntry );
1320 idsWg->SetListOfIDs( h->GetEdges() );
1321 idsWg->showPreview( true );
1322 customWidgets()->append ( idsWg );
1325 // else if (hypType() == "QuadrangleParams")
1327 // StdMeshers::StdMeshers_QuadrangleParams_var h =
1328 // StdMeshers::StdMeshers_QuadrangleParams::_narrow(hyp);
1330 // item.myName = tr("SMESH_BASE_VERTEX");
1333 // StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget =
1334 // new StdMeshersGUI_SubShapeSelectorWdg(0, TopAbs_VERTEX);
1335 // aDirectionWidget->SetMaxSize(1);
1336 // QString anEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
1337 // QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
1338 // if (anEntry == "")
1339 // anEntry = h->GetObjectEntry();
1340 // aDirectionWidget->SetGeomShapeEntry(anEntry);
1341 // aDirectionWidget->SetMainShapeEntry(aMainEntry);
1342 // if (!isCreation()) {
1343 // SMESH::long_array_var aVec = new SMESH::long_array;
1344 // int vertID = h->GetTriaVertex();
1345 // if (vertID > 0) {
1347 // aVec[0] = vertID;
1348 // aDirectionWidget->SetListOfIDs(aVec);
1351 // aDirectionWidget->showPreview(true);
1353 // item.myName = tr("SMESH_QUAD_TYPE");
1356 // StdMeshersGUI_QuadrangleParamWdg* aTypeWidget =
1357 // new StdMeshersGUI_QuadrangleParamWdg();
1358 // if (!isCreation()) {
1359 // aTypeWidget->SetType(int(h->GetQuadType()));
1362 // customWidgets()->append(aDirectionWidget);
1363 // customWidgets()->append(aTypeWidget);
1370 //================================================================================
1372 * \brief tune "standard" control
1373 * \param w - control widget
1374 * \param int - parameter index
1376 //================================================================================
1378 void StdMeshersGUI_StdHypothesisCreator::attuneStdWidget (QWidget* w, const int) const
1380 SMESHGUI_SpinBox* sb = w->inherits( "SMESHGUI_SpinBox" ) ? ( SMESHGUI_SpinBox* )w : 0;
1383 if( hypType()=="LocalLength" )
1385 if (sb->objectName() == tr("SMESH_LOCAL_LENGTH_PARAM"))
1386 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1387 else if (sb->objectName() == tr("SMESH_LOCAL_LENGTH_PRECISION"))
1388 sb->RangeStepAndValidator( 0.0, 1.0, 0.05, "len_tol_precision" );
1390 else if( hypType()=="Arithmetic1D" )
1392 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "parametric_precision" );
1394 else if( hypType()=="GeometricProgression" )
1396 if (sb->objectName() == tr("SMESH_START_LENGTH_PARAM"))
1397 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1398 else if (sb->objectName() == tr("SMESH_COMMON_RATIO"))
1399 sb->RangeStepAndValidator( -VALUE_MAX, VALUE_MAX, 0.5, "len_tol_precision" );
1401 else if( hypType()=="MaxLength" )
1403 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1404 sb->setEnabled( !widget< QCheckBox >( 1 )->isChecked() );
1406 else if( hypType()=="MaxElementArea" )
1408 sb->RangeStepAndValidator( VALUE_SMALL_2, VALUE_MAX_2, 1.0, "area_precision" );
1410 else if( hypType()=="MaxElementVolume" )
1412 sb->RangeStepAndValidator( VALUE_SMALL_3, VALUE_MAX_3, 1.0, "vol_precision" );
1414 else if( hypType()=="StartEndLength" )
1416 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1418 else if( hypType()=="Deflection1D" )
1420 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "parametric_precision" );
1422 else if( hypType()=="Adaptive1D" )
1424 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1426 else if( hypType().startsWith( "ViscousLayers" ))
1428 if (sb->objectName() == tr("SMESH_STRETCH_FACTOR"))
1429 sb->RangeStepAndValidator( 1.0, VALUE_MAX, 0.1, "parametric_precision" );
1431 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1433 else // default validator for possible ancestors
1435 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1440 //================================================================================
1442 * \brief Return dlg title
1443 * \retval QString - title string
1445 //================================================================================
1447 QString StdMeshersGUI_StdHypothesisCreator::caption() const
1449 return tr( QString( "SMESH_%1_TITLE" ).arg( hypTypeName( hypType() ) ).toLatin1().data() );
1452 //================================================================================
1454 * \brief return pixmap for dlg icon
1457 //================================================================================
1459 QPixmap StdMeshersGUI_StdHypothesisCreator::icon() const
1461 QString hypIconName = tr( QString( "ICON_DLG_%1" ).arg( hypTypeName( hypType() ) ).toLatin1().data() );
1462 return SMESHGUI::resourceMgr()->loadPixmap( "SMESH", hypIconName );
1465 //================================================================================
1467 * \brief Return hypothesis type name to show in dlg
1470 //================================================================================
1472 QString StdMeshersGUI_StdHypothesisCreator::type() const
1474 return tr( QString( "SMESH_%1_HYPOTHESIS" ).arg( hypTypeName( hypType() ) ).toLatin1().data() );
1477 //================================================================================
1479 * \brief String to insert in "SMESH_%1_HYPOTHESIS" to get hypothesis type name
1480 * from message resouce file
1481 * \param t - hypothesis type
1482 * \retval QString - result string
1484 //================================================================================
1486 QString StdMeshersGUI_StdHypothesisCreator::hypTypeName( const QString& t ) const
1488 static QMap<QString,QString> types;
1489 if( types.isEmpty() )
1491 types.insert( "LocalLength", "LOCAL_LENGTH" );
1492 types.insert( "NumberOfSegments", "NB_SEGMENTS" );
1493 types.insert( "MaxElementArea", "MAX_ELEMENT_AREA" );
1494 types.insert( "MaxElementVolume", "MAX_ELEMENT_VOLUME" );
1495 types.insert( "StartEndLength", "START_END_LENGTH" );
1496 types.insert( "Deflection1D", "DEFLECTION1D" );
1497 types.insert( "Adaptive1D", "ADAPTIVE1D" );
1498 types.insert( "Arithmetic1D", "ARITHMETIC_1D" );
1499 types.insert( "GeometricProgression", "GEOMETRIC_1D" );
1500 types.insert( "FixedPoints1D", "FIXED_POINTS_1D" );
1501 types.insert( "AutomaticLength", "AUTOMATIC_LENGTH" );
1502 types.insert( "ProjectionSource1D", "PROJECTION_SOURCE_1D" );
1503 types.insert( "ProjectionSource2D", "PROJECTION_SOURCE_2D" );
1504 types.insert( "ProjectionSource3D", "PROJECTION_SOURCE_3D" );
1505 types.insert( "ImportSource1D", "IMPORT_SOURCE_1D" );
1506 types.insert( "ImportSource2D", "IMPORT_SOURCE_2D" );
1507 types.insert( "NumberOfLayers", "NUMBER_OF_LAYERS" );
1508 types.insert( "LayerDistribution", "LAYER_DISTRIBUTION" );
1509 types.insert( "NumberOfLayers2D", "NUMBER_OF_LAYERS_2D" );
1510 types.insert( "LayerDistribution2D", "LAYER_DISTRIBUTION" );
1511 types.insert( "SegmentLengthAroundVertex", "SEGMENT_LENGTH_AROUND_VERTEX" );
1512 types.insert( "MaxLength", "MAX_LENGTH" );
1513 types.insert( "ViscousLayers", "VISCOUS_LAYERS" );
1514 types.insert( "ViscousLayers2D", "VISCOUS_LAYERS" );
1515 types.insert( "QuadrangleParams", "QUADRANGLE_PARAMS" );
1516 types.insert( "CartesianParameters3D", "CARTESIAN_PARAMS" );
1520 if( types.contains( t ) )
1527 //=======================================================================
1528 //function : getCustomWidget
1529 //purpose : is called from buildStdFrame()
1530 //=======================================================================
1532 QWidget* StdMeshersGUI_StdHypothesisCreator::getCustomWidget( const StdParam & param,
1534 const int index) const
1537 if ( index < customWidgets()->count() ) {
1538 w = customWidgets()->at( index );
1540 w->setParent( parent );
1541 w->move( QPoint( 0, 0 ) );
1547 //================================================================================
1549 * \brief Set param value taken from a custom widget
1550 * \param param - SMESHGUI_GenericHypothesisCreator::StdParam structure
1551 * \param widget - widget presenting param
1552 * \retval bool - success flag
1554 * this method is called from getStdParamFromDlg()
1556 //================================================================================
1558 bool StdMeshersGUI_StdHypothesisCreator::getParamFromCustomWidget( StdParam & param,
1559 QWidget* widget) const
1561 if ( hypType()=="AutomaticLength" ) {
1562 SMESHGUI_SpinBox* w = dynamic_cast<SMESHGUI_SpinBox*>( widget );
1564 param.myValue = w->GetValue();
1568 if ( hypType() == "MaxLength" ) {
1572 if ( widget->inherits( "StdMeshersGUI_ObjectReferenceParamWdg" ))
1574 // show only 1st reference value
1575 if ( true /*widget == getWidgetForParam( 0 )*/) {
1576 const StdMeshersGUI_ObjectReferenceParamWdg * w =
1577 static_cast<const StdMeshersGUI_ObjectReferenceParamWdg*>( widget );
1578 param.myValue = w->GetValue();
1582 if ( widget->inherits( "StdMeshersGUI_LayerDistributionParamWdg" ))
1584 const StdMeshersGUI_LayerDistributionParamWdg * w =
1585 static_cast<const StdMeshersGUI_LayerDistributionParamWdg*>( widget );
1586 param.myValue = w->GetValue();
1589 if ( widget->inherits( "StdMeshersGUI_SubShapeSelectorWdg" ))
1591 const StdMeshersGUI_SubShapeSelectorWdg * w =
1592 static_cast<const StdMeshersGUI_SubShapeSelectorWdg*>( widget );
1593 param.myValue = w->GetValue();
1596 // if ( widget->inherits( "StdMeshersGUI_QuadrangleParamWdg" ))
1598 // param.myValue = "QuadType";
1601 if ( widget->inherits( "StdMeshersGUI_FixedPointsParamWdg" ))
1603 const StdMeshersGUI_FixedPointsParamWdg * w =
1604 static_cast<const StdMeshersGUI_FixedPointsParamWdg*>( widget );
1605 param.myValue = w->GetValue();
1608 if ( widget->inherits( "QCheckBox" ))
1610 //const QCheckBox * w = static_cast<const QCheckBox*>( widget );
1611 //param.myValue = w->isChecked();
1614 if ( widget->inherits( "StdMeshersGUI_RadioButtonsGrpWdg" ))
1616 const StdMeshersGUI_RadioButtonsGrpWdg * w =
1617 static_cast<const StdMeshersGUI_RadioButtonsGrpWdg*>( widget );
1618 param.myValue = w->checkedId();
1624 //================================================================================
1626 * \brief called when operation cancelled
1628 //================================================================================
1630 void StdMeshersGUI_StdHypothesisCreator::onReject()
1632 if ( hypType().startsWith("ProjectionSource" ) ||
1633 hypType().startsWith("ImportSource" ))
1635 // Uninstall filters of StdMeshersGUI_ObjectReferenceParamWdg
1636 deactivateObjRefParamWdg( customWidgets() );
1640 //================================================================================
1642 * \brief Update widgets dependent on paramWidget
1644 //================================================================================
1646 void StdMeshersGUI_StdHypothesisCreator::valueChanged( QWidget* paramWidget)
1648 if ( hypType() == "MaxLength" && paramWidget == getWidgetForParam(1) )
1650 getWidgetForParam(0)->setEnabled( !widget< QCheckBox >( 1 )->isChecked() );
1651 if ( !getWidgetForParam(0)->isEnabled() ) {
1652 StdMeshers::StdMeshers_MaxLength_var h =
1653 StdMeshers::StdMeshers_MaxLength::_narrow( initParamsHypothesis() );
1654 widget< QtxDoubleSpinBox >( 0 )->setValue( h->GetPreestimatedLength() );
1657 else if ( hypType().startsWith("ImportSource") && paramWidget == getWidgetForParam(1) )
1659 QCheckBox* toCopyMesh = (QCheckBox*) paramWidget;
1660 QCheckBox* toCopyGroups = widget< QCheckBox >( 2 );
1661 if ( !toCopyMesh->isChecked() )
1663 toCopyGroups->setChecked( false );
1664 toCopyGroups->setEnabled( false );
1668 toCopyGroups->setEnabled( true );
1671 else if ( hypType().startsWith( "ViscousLayers" ) && paramWidget->inherits("QButtonGroup"))
1673 if ( QLabel* label = getLabel(4) )
1675 bool toIgnore = widget< StdMeshersGUI_RadioButtonsGrpWdg >( 3 )->checkedId();
1676 if ( hypType() == "ViscousLayers2D" )
1677 label->setText( tr( toIgnore ? "SMESH_EDGES_WO_LAYERS" : "SMESH_EDGES_WITH_LAYERS" ));
1679 label->setText( tr( toIgnore ? "SMESH_FACES_WO_LAYERS" : "SMESH_FACES_WITH_LAYERS" ));
1684 //================================================================================
1688 //================================================================================
1690 bool StdMeshersGUI_StdHypothesisCreator::initVariableName(SMESH::SMESH_Hypothesis_var theHyp,
1691 StdParam & theParams,
1692 const char* theMethod) const
1694 QString aVaribaleName = getVariableName( theMethod );
1695 theParams.isVariable = !aVaribaleName.isEmpty();
1696 if (theParams.isVariable)
1697 theParams.myValue = aVaribaleName;
1699 return theParams.isVariable;