1 // Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File : StdMeshersGUI_StdHypothesisCreator.cxx
23 // Author : Alexander SOLOVYOV, Open CASCADE S.A.S.
26 #include "StdMeshersGUI_StdHypothesisCreator.h"
29 #include <SMESHGUI_SpinBox.h>
30 #include <SMESHGUI_HypothesesUtils.h>
31 #include <SMESHGUI_Utils.h>
32 #include <SMESHGUI_GEOMGenUtils.h>
34 #include <SMESH_TypeFilter.hxx>
35 #include <SMESH_NumberFilter.hxx>
37 #include "StdMeshersGUI_FixedPointsParamWdg.h"
38 #include "StdMeshersGUI_LayerDistributionParamWdg.h"
39 #include "StdMeshersGUI_ObjectReferenceParamWdg.h"
40 #include "StdMeshersGUI_QuadrangleParamWdg.h"
41 #include "StdMeshersGUI_SubShapeSelectorWdg.h"
42 #include "StdMeshersGUI_RadioButtonsGrpWdg.h"
44 #include <SALOMEDSClient_Study.hxx>
46 #include <GEOM_wrap.hxx>
48 // SALOME GUI includes
49 #include <SUIT_ResourceMgr.h>
52 #include <SALOMEconfig.h>
53 #include CORBA_SERVER_HEADER(SMESH_BasicHypothesis)
54 #include CORBA_SERVER_HEADER(SMESH_Mesh)
55 #include CORBA_SERVER_HEADER(SMESH_Group)
58 #include <QHBoxLayout>
62 #include <QButtonGroup>
64 const double VALUE_MAX = 1.0e+15, // COORD_MAX
65 VALUE_MAX_2 = VALUE_MAX * VALUE_MAX,
66 VALUE_MAX_3 = VALUE_MAX_2 * VALUE_MAX,
67 VALUE_SMALL = 1.0e-15,
68 VALUE_SMALL_2 = VALUE_SMALL * VALUE_SMALL,
69 VALUE_SMALL_3 = VALUE_SMALL_2 * VALUE_SMALL;
71 //================================================================================
74 * \param type - hypothesis type
76 //================================================================================
78 StdMeshersGUI_StdHypothesisCreator::StdMeshersGUI_StdHypothesisCreator( const QString& type )
79 : SMESHGUI_GenericHypothesisCreator( type )
83 //================================================================================
87 //================================================================================
89 StdMeshersGUI_StdHypothesisCreator::~StdMeshersGUI_StdHypothesisCreator()
93 //================================================================================
95 * \brief Return widget for i-th hypothesis parameter (got from myParamWidgets)
96 * \param i - index of hypothesis parameter
97 * \retval QWidget* - found widget
99 //================================================================================
101 QWidget* StdMeshersGUI_StdHypothesisCreator::getWidgetForParam( int i ) const
104 if ( isCreation() ) ++i; // skip widget of 'name' parameter
106 if ( i < myCustomWidgets.count() ) {
107 QList<QWidget*>::const_iterator anIt = myCustomWidgets.begin();
108 QList<QWidget*>::const_iterator aLast = myCustomWidgets.end();
109 for ( int j = 0 ; !w && anIt != aLast; ++anIt, ++j )
114 // list has no at() const, so we iterate
115 QList<QWidget*>::const_iterator anIt = widgets().begin();
116 QList<QWidget*>::const_iterator aLast = widgets().end();
117 for( int j = 0; !w && anIt!=aLast; anIt++, ++j ) {
125 //================================================================================
127 * \brief Allow modifing myCustomWidgets in const methods
128 * \retval ListOfWidgets* - non-const pointer to myCustomWidgets
130 //================================================================================
132 StdMeshersGUI_StdHypothesisCreator::ListOfWidgets*
133 StdMeshersGUI_StdHypothesisCreator::customWidgets() const
135 return const_cast< ListOfWidgets* >( & myCustomWidgets );
138 //================================================================================
140 * \brief Builds dlg layout
141 * \retval QFrame* - the built widget
143 //================================================================================
145 QFrame* StdMeshersGUI_StdHypothesisCreator::buildFrame()
147 return buildStdFrame();
150 //================================================================================
152 * \brief Initialise parameter values in controls
154 //================================================================================
156 void StdMeshersGUI_StdHypothesisCreator::retrieveParams() const
158 // buildStdFrame() sets values itself calling stdParams()
160 if ( hypType().startsWith("ProjectionSource" ))
162 // we use this method to connect depending custom widgets
163 StdMeshersGUI_ObjectReferenceParamWdg* widgetToActivate = 0;
164 ListOfWidgets::const_iterator anIt = myCustomWidgets.begin();
165 for ( ; anIt != myCustomWidgets.end(); anIt++)
167 if ( *anIt && (*anIt)->inherits("StdMeshersGUI_ObjectReferenceParamWdg"))
169 StdMeshersGUI_ObjectReferenceParamWdg * w1 =
170 ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
171 ListOfWidgets::const_iterator anIt2 = anIt;
172 for ( ++anIt2; anIt2 != myCustomWidgets.end(); anIt2++)
173 if ( *anIt2 && (*anIt2)->inherits("StdMeshersGUI_ObjectReferenceParamWdg"))
175 StdMeshersGUI_ObjectReferenceParamWdg * w2 =
176 ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt2 );
177 w1->AvoidSimultaneousSelection( w2 );
179 if ( !widgetToActivate )
180 widgetToActivate = w1;
183 if ( widgetToActivate )
184 widgetToActivate->activateSelection();
188 dlg()->setMinimumSize( dlg()->minimumSizeHint().width(), dlg()->minimumSizeHint().height() );
193 //================================================================================
195 * \brief Widget: slider with left and right labels
197 //================================================================================
199 class TDoubleSliderWith2Labels: public QWidget
202 TDoubleSliderWith2Labels( const QString& leftLabel, const QString& rightLabel,
203 const double initValue, const double bottom,
204 const double top , const double precision,
205 QWidget * parent=0 , const char * name=0 )
206 :QWidget(parent), _bottom(bottom), _precision(precision)
210 QHBoxLayout* aHBoxL = new QHBoxLayout(this);
212 if ( !leftLabel.isEmpty() ) {
213 QLabel* aLeftLabel = new QLabel( this );
214 aLeftLabel->setText( leftLabel );
215 aHBoxL->addWidget( aLeftLabel );
218 _slider = new QSlider( Qt::Horizontal, this );
219 _slider->setRange( 0, toInt( top ));
220 _slider->setValue( toInt( initValue ));
221 aHBoxL->addWidget( _slider );
223 if ( !rightLabel.isEmpty() ) {
224 QLabel* aRightLabel = new QLabel( this );
225 aRightLabel->setText( rightLabel );
226 aHBoxL->addWidget( aRightLabel );
231 double value() const { return _bottom + _slider->value() * _precision; }
232 QSlider * getSlider() const { return _slider; }
233 int toInt( double val ) const { return (int) ceil(( val - _bottom ) / _precision ); }
235 double _bottom, _precision;
239 //================================================================================
241 * \brief Retrieve GEOM_Object held by widget
243 //================================================================================
245 inline GEOM::GEOM_Object_var geomFromWdg(const QWidget* wdg)
247 const StdMeshersGUI_ObjectReferenceParamWdg * objRefWdg =
248 dynamic_cast<const StdMeshersGUI_ObjectReferenceParamWdg*>( wdg );
250 return objRefWdg->GetObject< GEOM::GEOM_Object >();
252 return GEOM::GEOM_Object::_nil();
254 //================================================================================
256 * \brief Retrieve SMESH_Mesh held by widget
258 //================================================================================
260 inline SMESH::SMESH_Mesh_var meshFromWdg(const QWidget* wdg)
262 const StdMeshersGUI_ObjectReferenceParamWdg * objRefWdg =
263 dynamic_cast<const StdMeshersGUI_ObjectReferenceParamWdg*>( wdg );
265 return objRefWdg->GetObject< SMESH::SMESH_Mesh >();
267 return SMESH::SMESH_Mesh::_nil();
269 //================================================================================
271 * \brief Retrieve SMESH_Mesh held by widget
273 //================================================================================
275 inline SMESH::ListOfGroups_var groupsFromWdg(const QWidget* wdg)
277 SMESH::ListOfGroups_var groups = new SMESH::ListOfGroups;
278 const StdMeshersGUI_ObjectReferenceParamWdg * objRefWdg =
279 dynamic_cast<const StdMeshersGUI_ObjectReferenceParamWdg*>( wdg );
282 groups->length( objRefWdg->NbObjects() );
283 for ( unsigned i = 0; i < groups->length(); ++i )
284 groups[i] = objRefWdg->GetObject< SMESH::SMESH_GroupBase >(i);
288 //================================================================================
290 * \brief creates a filter for selection of shapes of given dimension
291 * \param dim - dimension
292 * \param subShapeType - required type of sub-shapes, number of which must be \a nbSubShapes
293 * \param nbSubShapes - number of sub-shapes of given type
294 * \param closed - required closeness flag of a shape
295 * \retval SUIT_SelectionFilter* - created filter
297 //================================================================================
299 SUIT_SelectionFilter* filterForShapeOfDim(const int dim,
300 TopAbs_ShapeEnum subShapeType = TopAbs_SHAPE,
301 const int nbSubShapes = 0,
304 TColStd_MapOfInteger shapeTypes;
306 case 0: shapeTypes.Add( TopAbs_VERTEX ); break;
308 if ( subShapeType == TopAbs_SHAPE ) subShapeType = TopAbs_EDGE;
309 shapeTypes.Add( TopAbs_EDGE );
310 shapeTypes.Add( TopAbs_COMPOUND ); // for a group
313 if ( subShapeType == TopAbs_SHAPE ) subShapeType = TopAbs_FACE;
314 shapeTypes.Add( TopAbs_FACE );
315 shapeTypes.Add( TopAbs_COMPOUND ); // for a group
318 shapeTypes.Add( TopAbs_SHELL );
319 shapeTypes.Add( TopAbs_SOLID );
320 shapeTypes.Add( TopAbs_COMPSOLID );
321 shapeTypes.Add( TopAbs_COMPOUND );
324 return new SMESH_NumberFilter("GEOM", subShapeType, nbSubShapes,
325 shapeTypes, GEOM::GEOM_Object::_nil(), closed);
328 //================================================================================
330 * \brief Create a widget for object selection
331 * \param object - initial object
332 * \param filter - selection filter
333 * \retval QWidget* - created widget
335 //================================================================================
337 QWidget* newObjRefParamWdg( SUIT_SelectionFilter* filter,
338 CORBA::Object_var object)
340 StdMeshersGUI_ObjectReferenceParamWdg* w =
341 new StdMeshersGUI_ObjectReferenceParamWdg( filter, 0);
342 w->SetObject( object.in() );
345 QWidget* newObjRefParamWdg( SUIT_SelectionFilter* filter,
346 SMESH::string_array_var& objEntries)
348 StdMeshersGUI_ObjectReferenceParamWdg* w =
349 new StdMeshersGUI_ObjectReferenceParamWdg( filter, 0, /*multiSel=*/true);
350 //RNV: Firstly, activate selection, then set objects
351 w->activateSelection();
352 w->SetObjects( objEntries );
356 //================================================================================
358 * \brief calls deactivateSelection() for StdMeshersGUI_ObjectReferenceParamWdg
359 * \param widgetList - list of widgets
361 //================================================================================
363 void deactivateObjRefParamWdg( QList<QWidget*>* widgetList )
365 StdMeshersGUI_ObjectReferenceParamWdg* w = 0;
366 QList<QWidget*>::iterator anIt = widgetList->begin();
367 QList<QWidget*>::iterator aLast = widgetList->end();
368 for ( ; anIt != aLast; anIt++ ) {
369 if ( (*anIt) && (*anIt)->inherits( "StdMeshersGUI_ObjectReferenceParamWdg" ))
371 w = (StdMeshersGUI_ObjectReferenceParamWdg* )( *anIt );
372 w->deactivateSelection();
378 //================================================================================
380 * \brief Check parameter values before accept()
381 * \retval bool - true if OK
383 //================================================================================
385 bool StdMeshersGUI_StdHypothesisCreator::checkParams( QString& msg ) const
387 if( !SMESHGUI_GenericHypothesisCreator::checkParams( msg ) )
390 // check if object reference parameter is set, as it has no default value
392 if ( hypType().startsWith("ProjectionSource" ))
394 StdMeshersGUI_ObjectReferenceParamWdg* w =
395 widget< StdMeshersGUI_ObjectReferenceParamWdg >( 0 );
396 ok = ( w->IsObjectSelected() );
397 if ( !ok ) w->SetObject( CORBA::Object::_nil() );
398 int nbAssocVert = ( hypType() == "ProjectionSource1D" ? 1 : 2 );
399 int nbNonEmptyAssoc = 0;
400 for ( int i = 0; ok && i < nbAssocVert*2; i += 2)
403 StdMeshersGUI_ObjectReferenceParamWdg* w1 =
404 widget< StdMeshersGUI_ObjectReferenceParamWdg >( i+2 );
405 StdMeshersGUI_ObjectReferenceParamWdg* w2 =
406 widget< StdMeshersGUI_ObjectReferenceParamWdg >( i+3 );
407 srcV = w1->GetValue();
408 tgtV = w2->GetValue();
409 ok = (( srcV.isEmpty() && tgtV.isEmpty() ) ||
410 ( !srcV.isEmpty() && !tgtV.isEmpty() && srcV != tgtV ));
412 w1->SetObject( CORBA::Object::_nil() );
413 w2->SetObject( CORBA::Object::_nil() );
415 nbNonEmptyAssoc += !srcV.isEmpty();
417 if ( ok && nbNonEmptyAssoc == 1 && nbAssocVert == 2 )
419 // only one pair of VERTEXes is given for a FACE,
420 // then the FACE must have only one VERTEX
421 GEOM::GEOM_Object_var face = w->GetObject< GEOM::GEOM_Object >();
423 GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen();
424 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
425 GEOM::GEOM_IShapesOperations_wrap shapeOp;
426 if ( !geomGen->_is_nil() && aStudy )
427 shapeOp = geomGen->GetIShapesOperations( aStudy->StudyId() );
428 if ( !shapeOp->_is_nil() )
430 GEOM::ListOfLong_var vertices =
431 shapeOp->GetAllSubShapesIDs (face, GEOM::VERTEX, /*isSorted=*/false);
432 ok = ( vertices->length() == 1 );
435 // Uninstall filters of StdMeshersGUI_ObjectReferenceParamWdg
437 deactivateObjRefParamWdg( customWidgets() );
439 else if ( hypType().startsWith("ImportSource" ))
441 StdMeshersGUI_ObjectReferenceParamWdg* w =
442 widget< StdMeshersGUI_ObjectReferenceParamWdg >( 0 );
443 ok = ( w->IsObjectSelected() );
445 else if ( hypType() == "LayerDistribution" || hypType() == "LayerDistribution2D" )
447 StdMeshersGUI_LayerDistributionParamWdg* w =
448 widget< StdMeshersGUI_LayerDistributionParamWdg >( 0 );
449 ok = ( w && w->IsOk() );
455 //================================================================================
457 * \brief Store params from GUI controls to a hypothesis
458 * \retval QString - text representation of parameters
460 //================================================================================
462 QString StdMeshersGUI_StdHypothesisCreator::storeParams() const
464 ListOfStdParams params;
465 bool res = getStdParamFromDlg( params );
468 SMESH::SetName( SMESH::FindSObject( hypothesis() ), params[0].myValue.toString().toLatin1().data() );
469 params.erase( params.begin() );
472 QString valueStr = stdParamValues( params );
473 //QStringList aVariablesList = getVariablesFromDlg();
475 if( res && !params.isEmpty() )
477 if( hypType()=="LocalLength" )
479 StdMeshers::StdMeshers_LocalLength_var h =
480 StdMeshers::StdMeshers_LocalLength::_narrow( hypothesis() );
482 h->SetVarParameter( params[0].text(), "SetLength" );
483 h->SetLength( params[0].myValue.toDouble() );
484 h->SetVarParameter( params[1].text(), "SetPrecision" );
485 h->SetPrecision( params[1].myValue.toDouble() );
487 else if( hypType()=="MaxLength" )
489 StdMeshers::StdMeshers_MaxLength_var h =
490 StdMeshers::StdMeshers_MaxLength::_narrow( hypothesis() );
492 h->SetVarParameter( params[0].text(), "SetLength" );
493 h->SetLength( params[0].myValue.toDouble() );
494 h->SetUsePreestimatedLength( widget< QCheckBox >( 1 )->isChecked() );
495 if ( !h->HavePreestimatedLength() && !h->_is_equivalent( initParamsHypothesis() )) {
496 StdMeshers::StdMeshers_MaxLength_var hInit =
497 StdMeshers::StdMeshers_MaxLength::_narrow( initParamsHypothesis() );
498 h->SetPreestimatedLength( hInit->GetPreestimatedLength() );
501 else if( hypType()=="SegmentLengthAroundVertex" )
503 StdMeshers::StdMeshers_SegmentLengthAroundVertex_var h =
504 StdMeshers::StdMeshers_SegmentLengthAroundVertex::_narrow( hypothesis() );
506 h->SetVarParameter( params[0].text(), "SetLength" );
507 h->SetLength( params[0].myValue.toDouble() );
509 else if( hypType()=="Arithmetic1D" )
511 StdMeshers::StdMeshers_Arithmetic1D_var h =
512 StdMeshers::StdMeshers_Arithmetic1D::_narrow( hypothesis() );
514 StdMeshersGUI_SubShapeSelectorWdg* w =
515 widget< StdMeshersGUI_SubShapeSelectorWdg >( 2 );
517 h->SetVarParameter( params[0].text(), "SetStartLength" );
518 h->SetStartLength( params[0].myValue.toDouble() );
519 h->SetVarParameter( params[1].text(), "SetEndLength" );
520 h->SetEndLength( params[1].myValue.toDouble() );
522 h->SetReversedEdges( w->GetListOfIDs() );
523 h->SetObjectEntry( w->GetMainShapeEntry() );
526 else if( hypType()=="FixedPoints1D" )
528 StdMeshers::StdMeshers_FixedPoints1D_var h =
529 StdMeshers::StdMeshers_FixedPoints1D::_narrow( hypothesis() );
531 StdMeshersGUI_FixedPointsParamWdg* w1 =
532 widget< StdMeshersGUI_FixedPointsParamWdg >( 0 );
534 StdMeshersGUI_SubShapeSelectorWdg* w2 =
535 widget< StdMeshersGUI_SubShapeSelectorWdg >( 1 );
538 h->SetPoints( w1->GetListOfPoints() );
539 h->SetNbSegments( w1->GetListOfSegments() );
542 h->SetReversedEdges( w2->GetListOfIDs() );
543 h->SetObjectEntry( w2->GetMainShapeEntry() );
546 else if( hypType()=="MaxElementArea" )
548 StdMeshers::StdMeshers_MaxElementArea_var h =
549 StdMeshers::StdMeshers_MaxElementArea::_narrow( hypothesis() );
550 h->SetVarParameter( params[0].text(), "SetMaxElementArea" );
551 h->SetMaxElementArea( params[0].myValue.toDouble() );
553 else if( hypType()=="MaxElementVolume" )
555 StdMeshers::StdMeshers_MaxElementVolume_var h =
556 StdMeshers::StdMeshers_MaxElementVolume::_narrow( hypothesis() );
558 h->SetVarParameter( params[0].text(), "SetMaxElementVolume" );
559 h->SetMaxElementVolume( params[0].myValue.toDouble() );
561 else if( hypType()=="StartEndLength" )
563 StdMeshers::StdMeshers_StartEndLength_var h =
564 StdMeshers::StdMeshers_StartEndLength::_narrow( hypothesis() );
566 StdMeshersGUI_SubShapeSelectorWdg* w =
567 widget< StdMeshersGUI_SubShapeSelectorWdg >( 2 );
569 h->SetVarParameter( params[0].text(), "SetStartLength" );
570 h->SetStartLength( params[0].myValue.toDouble() );
571 h->SetVarParameter( params[1].text(), "SetEndLength" );
572 h->SetEndLength( params[1].myValue.toDouble() );
574 h->SetReversedEdges( w->GetListOfIDs() );
575 h->SetObjectEntry( w->GetMainShapeEntry() );
578 else if( hypType()=="Deflection1D" )
580 StdMeshers::StdMeshers_Deflection1D_var h =
581 StdMeshers::StdMeshers_Deflection1D::_narrow( hypothesis() );
582 h->SetVarParameter( params[0].text(), "SetDeflection" );
583 h->SetDeflection( params[0].myValue.toDouble() );
585 else if( hypType()=="AutomaticLength" )
587 StdMeshers::StdMeshers_AutomaticLength_var h =
588 StdMeshers::StdMeshers_AutomaticLength::_narrow( hypothesis() );
590 h->SetVarParameter( params[0].text(), "SetFineness" );
591 h->SetFineness( params[0].myValue.toDouble() );
593 else if( hypType()=="NumberOfLayers" )
595 StdMeshers::StdMeshers_NumberOfLayers_var h =
596 StdMeshers::StdMeshers_NumberOfLayers::_narrow( hypothesis() );
598 h->SetVarParameter( params[0].text(), "SetNumberOfLayers" );
599 h->SetNumberOfLayers( params[0].myValue.toInt() );
601 else if( hypType()=="LayerDistribution" )
603 StdMeshers::StdMeshers_LayerDistribution_var h =
604 StdMeshers::StdMeshers_LayerDistribution::_narrow( hypothesis() );
605 StdMeshersGUI_LayerDistributionParamWdg* w =
606 widget< StdMeshersGUI_LayerDistributionParamWdg >( 0 );
608 h->SetLayerDistribution( w->GetHypothesis() );
610 else if( hypType()=="NumberOfLayers2D" )
612 StdMeshers::StdMeshers_NumberOfLayers2D_var h =
613 StdMeshers::StdMeshers_NumberOfLayers2D::_narrow( hypothesis() );
615 h->SetVarParameter( params[0].text(), "SetNumberOfLayers" );
616 h->SetNumberOfLayers( params[0].myValue.toInt() );
618 else if( hypType()=="LayerDistribution2D" )
620 StdMeshers::StdMeshers_LayerDistribution2D_var h =
621 StdMeshers::StdMeshers_LayerDistribution2D::_narrow( hypothesis() );
622 StdMeshersGUI_LayerDistributionParamWdg* w =
623 widget< StdMeshersGUI_LayerDistributionParamWdg >( 0 );
625 h->SetLayerDistribution( w->GetHypothesis() );
627 else if( hypType()=="ProjectionSource1D" )
629 StdMeshers::StdMeshers_ProjectionSource1D_var h =
630 StdMeshers::StdMeshers_ProjectionSource1D::_narrow( hypothesis() );
632 h->SetSourceEdge ( geomFromWdg ( getWidgetForParam( 0 )));
633 h->SetSourceMesh ( meshFromWdg ( getWidgetForParam( 1 )));
634 h->SetVertexAssociation( geomFromWdg ( getWidgetForParam( 2 )),
635 geomFromWdg ( getWidgetForParam( 3 )));
637 else if( hypType()=="ProjectionSource2D" )
639 StdMeshers::StdMeshers_ProjectionSource2D_var h =
640 StdMeshers::StdMeshers_ProjectionSource2D::_narrow( hypothesis() );
642 h->SetSourceFace ( geomFromWdg ( getWidgetForParam( 0 )));
643 h->SetSourceMesh ( meshFromWdg ( getWidgetForParam( 1 )));
644 h->SetVertexAssociation( geomFromWdg ( getWidgetForParam( 2 )), // src1
645 geomFromWdg ( getWidgetForParam( 4 )), // src2
646 geomFromWdg ( getWidgetForParam( 3 )), // tgt1
647 geomFromWdg ( getWidgetForParam( 5 ))); // tgt2
649 else if( hypType()=="ProjectionSource3D" )
651 StdMeshers::StdMeshers_ProjectionSource3D_var h =
652 StdMeshers::StdMeshers_ProjectionSource3D::_narrow( hypothesis() );
654 h->SetSource3DShape ( geomFromWdg ( getWidgetForParam( 0 )));
655 h->SetSourceMesh ( meshFromWdg ( getWidgetForParam( 1 )));
656 h->SetVertexAssociation( geomFromWdg ( getWidgetForParam( 2 )), // src1
657 geomFromWdg ( getWidgetForParam( 4 )), // src2
658 geomFromWdg ( getWidgetForParam( 3 )), // tgt1
659 geomFromWdg ( getWidgetForParam( 5 ))); // tgt2
661 else if( hypType()=="ImportSource1D" )
663 StdMeshers::StdMeshers_ImportSource1D_var h =
664 StdMeshers::StdMeshers_ImportSource1D::_narrow( hypothesis() );
666 SMESH::ListOfGroups_var groups = groupsFromWdg( getWidgetForParam( 0 ));
667 h->SetSourceEdges( groups.in() );
668 QCheckBox* toCopyMesh = widget< QCheckBox >( 1 );
669 QCheckBox* toCopyGroups = widget< QCheckBox >( 2 );
670 h->SetCopySourceMesh( toCopyMesh->isChecked(), toCopyGroups->isChecked());
672 else if( hypType()=="ImportSource2D" )
674 StdMeshers::StdMeshers_ImportSource2D_var h =
675 StdMeshers::StdMeshers_ImportSource2D::_narrow( hypothesis() );
677 SMESH::ListOfGroups_var groups = groupsFromWdg( getWidgetForParam( 0 ));
678 h->SetSourceFaces( groups.in() );
679 QCheckBox* toCopyMesh = widget< QCheckBox >( 1 );
680 QCheckBox* toCopyGroups = widget< QCheckBox >( 2 );
681 h->SetCopySourceMesh( toCopyMesh->isChecked(), toCopyGroups->isChecked());
683 else if( hypType()=="ViscousLayers" )
685 StdMeshers::StdMeshers_ViscousLayers_var h =
686 StdMeshers::StdMeshers_ViscousLayers::_narrow( hypothesis() );
688 h->SetVarParameter( params[0].text(), "SetTotalThickness" );
689 h->SetTotalThickness( params[0].myValue.toDouble() );
690 h->SetVarParameter( params[1].text(), "SetNumberLayers" );
691 h->SetNumberLayers ( params[1].myValue.toInt() );
692 h->SetVarParameter( params[2].text(), "SetStretchFactor" );
693 h->SetStretchFactor ( params[2].myValue.toDouble() );
695 if ( StdMeshersGUI_SubShapeSelectorWdg* idsWg =
696 widget< StdMeshersGUI_SubShapeSelectorWdg >( 3 ))
698 h->SetIgnoreFaces( idsWg->GetListOfIDs() );
701 else if( hypType()=="ViscousLayers2D" )
703 StdMeshers::StdMeshers_ViscousLayers2D_var h =
704 StdMeshers::StdMeshers_ViscousLayers2D::_narrow( hypothesis() );
706 h->SetVarParameter( params[0].text(), "SetTotalThickness" );
707 h->SetTotalThickness( params[0].myValue.toDouble() );
708 h->SetVarParameter( params[1].text(), "SetNumberLayers" );
709 h->SetNumberLayers ( params[1].myValue.toInt() );
710 h->SetVarParameter( params[2].text(), "SetStretchFactor" );
711 h->SetStretchFactor ( params[2].myValue.toDouble() );
713 if ( StdMeshersGUI_SubShapeSelectorWdg* idsWg =
714 widget< StdMeshersGUI_SubShapeSelectorWdg >( 4 ))
716 h->SetEdges( idsWg->GetListOfIDs(), params[3].myValue.toInt() );
719 else if( hypType()=="QuadrangleParams" )
721 StdMeshers::StdMeshers_QuadrangleParams_var h =
722 StdMeshers::StdMeshers_QuadrangleParams::_narrow( hypothesis() );
723 StdMeshersGUI_SubShapeSelectorWdg* w1 =
724 widget< StdMeshersGUI_SubShapeSelectorWdg >( 0 );
725 StdMeshersGUI_QuadrangleParamWdg* w2 =
726 widget< StdMeshersGUI_QuadrangleParamWdg >( 1 );
728 if (w1->GetListSize() > 0) {
729 h->SetTriaVertex(w1->GetListOfIDs()[0]); // getlist must be called once
730 const char * entry = w1->GetMainShapeEntry();
731 h->SetObjectEntry(entry);
733 h->SetQuadType(StdMeshers::QuadType(w2->GetType()));
740 //================================================================================
742 * \brief Return parameter values as SMESHGUI_GenericHypothesisCreator::StdParam
743 * \param p - list of parameters
744 * \retval bool - success flag
746 * Is called from SMESHGUI_GenericHypothesisCreator::buildStdFrame().
747 * Parameters will be shown using "standard" controls:
748 * Int by QtxIntSpinBox
749 * Double by SMESHGUI_SpinBox
750 * String by QLineEdit
751 * getCustomWidget() allows to redefine control for a parameter
753 //================================================================================
755 bool StdMeshersGUI_StdHypothesisCreator::stdParams( ListOfStdParams& p ) const
758 SMESHGUI_GenericHypothesisCreator::StdParam item;
761 customWidgets()->clear();
764 HypothesisData* data = SMESH::GetHypothesisData( hypType() );
765 item.myName = tr( "SMESH_NAME" );
766 item.myValue = data ? hypName() : QString();
768 customWidgets()->append(0);
771 SMESH::SMESH_Hypothesis_var hyp = initParamsHypothesis();
772 //SMESH::ListOfParameters_var aParameters = hyp->GetLastParameters();
774 if( hypType()=="LocalLength" )
776 StdMeshers::StdMeshers_LocalLength_var h =
777 StdMeshers::StdMeshers_LocalLength::_narrow( hyp );
779 item.myName = tr("SMESH_LOCAL_LENGTH_PARAM");
780 if(!initVariableName( hyp, item, "SetLength"))
781 item.myValue = h->GetLength();
784 item.myName = tr("SMESH_LOCAL_LENGTH_PRECISION");
785 if(!initVariableName( hyp, item, "SetPrecision"))
786 item.myValue = h->GetPrecision();
789 else if( hypType()=="MaxLength" )
791 StdMeshers::StdMeshers_MaxLength_var h =
792 StdMeshers::StdMeshers_MaxLength::_narrow( hyp );
793 // try to set a right preestimated length to edited hypothesis
794 bool noPreestimatedAtEdition = false;
795 if ( !isCreation() ) {
796 StdMeshers::StdMeshers_MaxLength_var initHyp =
797 StdMeshers::StdMeshers_MaxLength::_narrow( initParamsHypothesis(true) );
798 noPreestimatedAtEdition =
799 ( initHyp->_is_nil() || !initHyp->HavePreestimatedLength() );
800 if ( !noPreestimatedAtEdition )
801 h->SetPreestimatedLength( initHyp->GetPreestimatedLength() );
804 item.myName = tr("SMESH_LOCAL_LENGTH_PARAM");
805 if(!initVariableName( hyp, item, "SetLength"))
806 item.myValue = h->GetLength();
808 customWidgets()->append(0);
810 item.myName = tr("SMESH_USE_PREESTIMATED_LENGTH");
812 QCheckBox* aQCheckBox = new QCheckBox(dlg());
813 if ( !noPreestimatedAtEdition && h->HavePreestimatedLength() ) {
814 aQCheckBox->setChecked( h->GetUsePreestimatedLength() );
815 connect( aQCheckBox, SIGNAL( stateChanged(int) ), this, SLOT( onValueChanged() ) );
818 aQCheckBox->setChecked( false );
819 aQCheckBox->setEnabled( false );
821 customWidgets()->append( aQCheckBox );
823 else if( hypType()=="SegmentLengthAroundVertex" )
825 StdMeshers::StdMeshers_SegmentLengthAroundVertex_var h =
826 StdMeshers::StdMeshers_SegmentLengthAroundVertex::_narrow( hyp );
828 item.myName = tr("SMESH_LOCAL_LENGTH_PARAM");
829 if(!initVariableName( hyp, item, "SetLength"))
830 item.myValue = h->GetLength();
834 else if( hypType()=="Arithmetic1D" )
836 StdMeshers::StdMeshers_Arithmetic1D_var h =
837 StdMeshers::StdMeshers_Arithmetic1D::_narrow( hyp );
839 item.myName = tr( "SMESH_START_LENGTH_PARAM" );
840 if(!initVariableName( hyp, item, "SetStartLength" ))
841 item.myValue = h->GetLength( true );
844 customWidgets()->append (0);
846 item.myName = tr( "SMESH_END_LENGTH_PARAM" );
847 if(!initVariableName( hyp, item, "SetEndLength" ))
848 item.myValue = h->GetLength( false );
851 customWidgets()->append (0);
853 item.myName = tr( "SMESH_REVERSED_EDGES" );
856 StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget =
857 new StdMeshersGUI_SubShapeSelectorWdg();
858 QString aGeomEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
859 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
860 if ( aGeomEntry == "" )
861 aGeomEntry = h->GetObjectEntry();
863 aDirectionWidget->SetGeomShapeEntry( aGeomEntry );
864 aDirectionWidget->SetMainShapeEntry( aMainEntry );
865 aDirectionWidget->SetListOfIDs( h->GetReversedEdges() );
866 aDirectionWidget->showPreview( true );
867 customWidgets()->append ( aDirectionWidget );
871 else if( hypType()=="FixedPoints1D" )
873 StdMeshers::StdMeshers_FixedPoints1D_var h =
874 StdMeshers::StdMeshers_FixedPoints1D::_narrow( hyp );
876 item.myName = tr( "SMESH_FIXED_POINTS" );
879 StdMeshersGUI_FixedPointsParamWdg* aFixedPointsWidget =
880 new StdMeshersGUI_FixedPointsParamWdg();
882 if ( !isCreation() ) {
883 aFixedPointsWidget->SetListOfPoints( h->GetPoints() );
884 aFixedPointsWidget->SetListOfSegments( h->GetNbSegments() );
886 customWidgets()->append( aFixedPointsWidget );
888 item.myName = tr( "SMESH_REVERSED_EDGES" );
891 StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget =
892 new StdMeshersGUI_SubShapeSelectorWdg();
893 QString anEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
894 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
896 anEntry = h->GetObjectEntry();
897 aDirectionWidget->SetGeomShapeEntry( anEntry );
898 aDirectionWidget->SetMainShapeEntry( aMainEntry );
899 aDirectionWidget->SetListOfIDs( h->GetReversedEdges() );
900 aDirectionWidget->showPreview( true );
901 customWidgets()->append ( aDirectionWidget );
905 else if( hypType()=="MaxElementArea" )
907 StdMeshers::StdMeshers_MaxElementArea_var h =
908 StdMeshers::StdMeshers_MaxElementArea::_narrow( hyp );
910 item.myName = tr( "SMESH_MAX_ELEMENT_AREA_PARAM" );
911 if(!initVariableName( hyp, item, "SetMaxElementArea" ))
912 item.myValue = h->GetMaxElementArea();
916 else if( hypType()=="MaxElementVolume" )
918 StdMeshers::StdMeshers_MaxElementVolume_var h =
919 StdMeshers::StdMeshers_MaxElementVolume::_narrow( hyp );
921 item.myName = tr( "SMESH_MAX_ELEMENT_VOLUME_PARAM" );
922 if(!initVariableName( hyp, item, "SetMaxElementVolume" ))
923 item.myValue = h->GetMaxElementVolume();
926 else if( hypType()=="StartEndLength" )
928 StdMeshers::StdMeshers_StartEndLength_var h =
929 StdMeshers::StdMeshers_StartEndLength::_narrow( hyp );
931 item.myName = tr( "SMESH_START_LENGTH_PARAM" );
933 if(!initVariableName( hyp, item, "SetStartLength" ))
934 item.myValue = h->GetLength( true );
936 customWidgets()->append(0);
938 item.myName = tr( "SMESH_END_LENGTH_PARAM" );
939 if(!initVariableName( hyp, item, "SetEndLength" ))
940 item.myValue = h->GetLength( false );
942 customWidgets()->append(0);
944 item.myName = tr( "SMESH_REVERSED_EDGES" );
947 StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget =
948 new StdMeshersGUI_SubShapeSelectorWdg();
949 QString anEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
950 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
952 anEntry = h->GetObjectEntry();
953 aDirectionWidget->SetGeomShapeEntry( anEntry );
954 aDirectionWidget->SetMainShapeEntry( aMainEntry );
955 aDirectionWidget->SetListOfIDs( h->GetReversedEdges() );
956 aDirectionWidget->showPreview( true );
957 customWidgets()->append ( aDirectionWidget );
959 else if( hypType()=="Deflection1D" )
961 StdMeshers::StdMeshers_Deflection1D_var h =
962 StdMeshers::StdMeshers_Deflection1D::_narrow( hyp );
964 item.myName = tr( "SMESH_DEFLECTION1D_PARAM" );
965 if(!initVariableName( hyp, item, "SetDeflection" ))
966 item.myValue = h->GetDeflection();
969 else if( hypType()=="AutomaticLength" )
971 StdMeshers::StdMeshers_AutomaticLength_var h =
972 StdMeshers::StdMeshers_AutomaticLength::_narrow( hyp );
974 item.myName = tr( "SMESH_FINENESS_PARAM" );
975 //item.myValue = h->GetFineness();
977 SMESHGUI_SpinBox* _autoLengthSpinBox = new SMESHGUI_SpinBox(dlg());
978 _autoLengthSpinBox->RangeStepAndValidator(0, 1, 0.01, "length_precision");
979 _autoLengthSpinBox->SetValue(h->GetFineness());
980 customWidgets()->append( _autoLengthSpinBox);
982 else if( hypType()=="NumberOfLayers" )
984 StdMeshers::StdMeshers_NumberOfLayers_var h =
985 StdMeshers::StdMeshers_NumberOfLayers::_narrow( hyp );
987 item.myName = tr( "SMESH_NUMBER_OF_LAYERS" );
988 if(!initVariableName( hyp, item, "SetNumberOfLayers" ))
989 item.myValue = (int) h->GetNumberOfLayers();
992 else if( hypType()=="LayerDistribution" )
994 StdMeshers::StdMeshers_LayerDistribution_var h =
995 StdMeshers::StdMeshers_LayerDistribution::_narrow( hyp );
997 item.myName = tr( "SMESH_LAYERS_DISTRIBUTION" ); p.append( item );
998 initVariableName( hyp, item, "SetLayerDistribution" );
999 customWidgets()->append ( new StdMeshersGUI_LayerDistributionParamWdg
1000 ( h, h->GetLayerDistribution(), hypName(), dlg() ));
1002 else if( hypType()=="NumberOfLayers2D" )
1004 StdMeshers::StdMeshers_NumberOfLayers2D_var h =
1005 StdMeshers::StdMeshers_NumberOfLayers2D::_narrow( hyp );
1007 item.myName = tr( "SMESH_NUMBER_OF_LAYERS" );
1008 if(!initVariableName( hyp, item, "SetNumberOfLayers" ))
1009 item.myValue = (int) h->GetNumberOfLayers();
1012 else if( hypType()=="LayerDistribution2D" )
1014 StdMeshers::StdMeshers_LayerDistribution2D_var h =
1015 StdMeshers::StdMeshers_LayerDistribution2D::_narrow( hyp );
1017 item.myName = tr( "SMESH_LAYERS_DISTRIBUTION" ); p.append( item );
1018 initVariableName( hyp, item, "SetLayerDistribution" );
1019 customWidgets()->append ( new StdMeshersGUI_LayerDistributionParamWdg
1020 ( h, h->GetLayerDistribution(), hypName(), dlg() ));
1022 else if( hypType()=="ProjectionSource1D" )
1024 StdMeshers::StdMeshers_ProjectionSource1D_var h =
1025 StdMeshers::StdMeshers_ProjectionSource1D::_narrow( hyp );
1027 item.myName = tr( "SMESH_SOURCE_EDGE" ); p.append( item );
1028 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 1 ),
1029 h->GetSourceEdge()));
1030 item.myName = tr( "SMESH_SOURCE_MESH" ); p.append( item );
1031 customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( SMESH::MESH ),
1032 h->GetSourceMesh()));
1033 item.myName = tr( "SMESH_SOURCE_VERTEX" ); p.append( item );
1034 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1035 h->GetSourceVertex()));
1036 item.myName = tr( "SMESH_TARGET_VERTEX" ); p.append( item );
1037 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1038 h->GetTargetVertex()));
1040 else if( hypType()=="ProjectionSource2D" )
1042 StdMeshers::StdMeshers_ProjectionSource2D_var h =
1043 StdMeshers::StdMeshers_ProjectionSource2D::_narrow( hyp );
1045 item.myName = tr( "SMESH_SOURCE_FACE" ); p.append( item );
1046 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 2 ),
1047 h->GetSourceFace()));
1048 item.myName = tr( "SMESH_SOURCE_MESH" ); p.append( item );
1049 customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( SMESH::MESH ),
1050 h->GetSourceMesh()));
1051 item.myName = tr( "SMESH_SOURCE_VERTEX1" ); p.append( item );
1052 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1053 h->GetSourceVertex( 1 )));
1054 item.myName = tr( "SMESH_TARGET_VERTEX1" ); p.append( item );
1055 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1056 h->GetTargetVertex( 1 )));
1057 item.myName = tr( "SMESH_SOURCE_VERTEX2" ); p.append( item );
1058 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1059 h->GetSourceVertex( 2 )));
1060 item.myName = tr( "SMESH_TARGET_VERTEX2" ); p.append( item );
1061 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1062 h->GetTargetVertex( 2 )));
1064 else if( hypType()=="ProjectionSource3D" )
1066 StdMeshers::StdMeshers_ProjectionSource3D_var h =
1067 StdMeshers::StdMeshers_ProjectionSource3D::_narrow( hyp );
1069 item.myName = tr( "SMESH_SOURCE_3DSHAPE" ); p.append( item );
1070 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 3, TopAbs_FACE, 6, true ),
1071 h->GetSource3DShape()));
1072 item.myName = tr( "SMESH_SOURCE_MESH" ); p.append( item );
1073 customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( SMESH::MESH ),
1074 h->GetSourceMesh()));
1075 item.myName = tr( "SMESH_SOURCE_VERTEX1" ); p.append( item );
1076 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1077 h->GetSourceVertex( 1 )));
1078 item.myName = tr( "SMESH_TARGET_VERTEX1" ); p.append( item );
1079 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1080 h->GetTargetVertex( 1 )));
1081 item.myName = tr( "SMESH_SOURCE_VERTEX2" ); p.append( item );
1082 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1083 h->GetSourceVertex( 2 )));
1084 item.myName = tr( "SMESH_TARGET_VERTEX2" ); p.append( item );
1085 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1086 h->GetTargetVertex( 2 )));
1088 else if( hypType()=="ImportSource1D" )
1090 StdMeshers::StdMeshers_ImportSource1D_var h =
1091 StdMeshers::StdMeshers_ImportSource1D::_narrow( hyp );
1093 SMESH::string_array_var groupEntries = h->GetSourceEdges();
1094 CORBA::Boolean toCopyMesh, toCopyGroups;
1095 h->GetCopySourceMesh(toCopyMesh, toCopyGroups);
1097 item.myName = tr( "SMESH_SOURCE_EDGES" ); p.append( item );
1098 customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( SMESH::GROUP_EDGE ),
1101 item.myName = tr( "SMESH_COPY_MESH" ); p.append( item );
1102 QCheckBox* aQCheckBox = new QCheckBox(dlg());
1103 aQCheckBox->setChecked( toCopyMesh );
1104 connect( aQCheckBox, SIGNAL( stateChanged(int) ), this, SLOT( onValueChanged() ));
1105 customWidgets()->append( aQCheckBox );
1107 item.myName = tr( "SMESH_TO_COPY_GROUPS" ); p.append( item );
1108 aQCheckBox = new QCheckBox(dlg());
1109 aQCheckBox->setChecked( toCopyGroups );
1110 aQCheckBox->setEnabled( toCopyMesh );
1111 customWidgets()->append( aQCheckBox );
1113 else if( hypType()=="ImportSource2D" )
1115 StdMeshers::StdMeshers_ImportSource2D_var h =
1116 StdMeshers::StdMeshers_ImportSource2D::_narrow( hyp );
1118 SMESH::string_array_var groupEntries = h->GetSourceFaces();
1119 CORBA::Boolean toCopyMesh, toCopyGroups;
1120 h->GetCopySourceMesh(toCopyMesh, toCopyGroups);
1122 item.myName = tr( "SMESH_SOURCE_FACES" ); p.append( item );
1123 customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( SMESH::GROUP_FACE ),
1126 item.myName = tr( "SMESH_COPY_MESH" ); p.append( item );
1127 QCheckBox* aQCheckBox = new QCheckBox(dlg());
1128 aQCheckBox->setChecked( toCopyMesh );
1129 connect( aQCheckBox, SIGNAL( stateChanged(int) ), this, SLOT( onValueChanged() ));
1130 customWidgets()->append( aQCheckBox );
1132 item.myName = tr( "SMESH_COPY_GROUPS" ); p.append( item );
1133 aQCheckBox = new QCheckBox(dlg());
1134 aQCheckBox->setChecked( toCopyGroups );
1135 aQCheckBox->setEnabled( toCopyMesh );
1136 customWidgets()->append( aQCheckBox );
1138 else if( hypType()=="ViscousLayers" )
1140 StdMeshers::StdMeshers_ViscousLayers_var h =
1141 StdMeshers::StdMeshers_ViscousLayers::_narrow( hyp );
1143 item.myName = tr( "SMESH_TOTAL_THICKNESS" );
1144 if(!initVariableName( hyp, item, "SetTotalThickness" ))
1145 item.myValue = h->GetTotalThickness();
1147 customWidgets()->append (0);
1149 item.myName = tr( "SMESH_NUMBER_OF_LAYERS" );
1150 if(!initVariableName( hyp, item, "SetNumberLayers" ))
1151 item.myValue = h->GetNumberLayers();
1153 customWidgets()->append (0);
1155 item.myName = tr( "SMESH_STRETCH_FACTOR" );
1156 if(!initVariableName( hyp, item, "SetStretchFactor" ))
1157 item.myValue = h->GetStretchFactor();
1159 customWidgets()->append (0);
1161 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
1162 if ( !aMainEntry.isEmpty() )
1164 item.myName = tr( "SMESH_FACES_WO_LAYERS" );
1167 StdMeshersGUI_SubShapeSelectorWdg* idsWg =
1168 new StdMeshersGUI_SubShapeSelectorWdg(0,TopAbs_FACE);
1170 idsWg->SetGeomShapeEntry( aMainEntry );
1171 idsWg->SetMainShapeEntry( aMainEntry );
1172 idsWg->SetListOfIDs( h->GetIgnoreFaces() );
1173 idsWg->showPreview( true );
1174 customWidgets()->append ( idsWg );
1177 else if( hypType()=="ViscousLayers2D" )
1179 StdMeshers::StdMeshers_ViscousLayers2D_var h =
1180 StdMeshers::StdMeshers_ViscousLayers2D::_narrow( hyp );
1182 item.myName = tr( "SMESH_TOTAL_THICKNESS" );
1183 if(!initVariableName( hyp, item, "SetTotalThickness" ))
1184 item.myValue = h->GetTotalThickness();
1186 customWidgets()->append (0);
1188 item.myName = tr( "SMESH_NUMBER_OF_LAYERS" );
1189 if(!initVariableName( hyp, item, "SetNumberLayers" ))
1190 item.myValue = h->GetNumberLayers();
1192 customWidgets()->append (0);
1194 item.myName = tr( "SMESH_STRETCH_FACTOR" );
1195 if(!initVariableName( hyp, item, "SetStretchFactor" ))
1196 item.myValue = h->GetStretchFactor();
1198 customWidgets()->append (0);
1200 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
1201 if ( !aMainEntry.isEmpty() )
1203 item.myName = tr("TO_IGNORE_EDGES_OR_NOT");
1206 StdMeshersGUI_RadioButtonsGrpWdg* ignoreWdg = new StdMeshersGUI_RadioButtonsGrpWdg("");
1207 ignoreWdg->setButtonLabels ( QStringList()
1208 << tr("NOT_TO_IGNORE_EDGES")
1209 << tr("TO_IGNORE_EDGES") );
1210 ignoreWdg->setChecked( h->GetIsToIgnoreEdges() );
1211 connect(ignoreWdg->getButtonGroup(),SIGNAL(buttonClicked(int)),this,SLOT(onValueChanged()));
1212 customWidgets()->append( ignoreWdg );
1215 tr( h->GetIsToIgnoreEdges() ? "SMESH_EDGES_WO_LAYERS" : "SMESH_EDGES_WITH_LAYERS" );
1218 StdMeshersGUI_SubShapeSelectorWdg* idsWg =
1219 new StdMeshersGUI_SubShapeSelectorWdg(0,TopAbs_EDGE);
1221 idsWg->SetGeomShapeEntry( aMainEntry );
1222 idsWg->SetMainShapeEntry( aMainEntry );
1223 idsWg->SetListOfIDs( h->GetEdges() );
1224 idsWg->showPreview( true );
1225 customWidgets()->append ( idsWg );
1228 else if (hypType() == "QuadrangleParams")
1230 StdMeshers::StdMeshers_QuadrangleParams_var h =
1231 StdMeshers::StdMeshers_QuadrangleParams::_narrow(hyp);
1233 item.myName = tr("SMESH_BASE_VERTEX");
1236 StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget =
1237 new StdMeshersGUI_SubShapeSelectorWdg(0, TopAbs_VERTEX);
1238 aDirectionWidget->SetMaxSize(1);
1239 QString anEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
1240 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
1242 anEntry = h->GetObjectEntry();
1243 aDirectionWidget->SetGeomShapeEntry(anEntry);
1244 aDirectionWidget->SetMainShapeEntry(aMainEntry);
1245 if (!isCreation()) {
1246 SMESH::long_array_var aVec = new SMESH::long_array;
1247 int vertID = h->GetTriaVertex();
1251 aDirectionWidget->SetListOfIDs(aVec);
1254 aDirectionWidget->showPreview(true);
1256 item.myName = tr("SMESH_QUAD_TYPE");
1259 StdMeshersGUI_QuadrangleParamWdg* aTypeWidget =
1260 new StdMeshersGUI_QuadrangleParamWdg();
1261 if (!isCreation()) {
1262 aTypeWidget->SetType(int(h->GetQuadType()));
1265 customWidgets()->append(aDirectionWidget);
1266 customWidgets()->append(aTypeWidget);
1273 //================================================================================
1275 * \brief tune "standard" control
1276 * \param w - control widget
1277 * \param int - parameter index
1279 //================================================================================
1281 void StdMeshersGUI_StdHypothesisCreator::attuneStdWidget (QWidget* w, const int) const
1283 SMESHGUI_SpinBox* sb = w->inherits( "SMESHGUI_SpinBox" ) ? ( SMESHGUI_SpinBox* )w : 0;
1286 if( hypType()=="LocalLength" )
1288 if (sb->objectName() == tr("SMESH_LOCAL_LENGTH_PARAM"))
1289 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1290 else if (sb->objectName() == tr("SMESH_LOCAL_LENGTH_PRECISION"))
1291 sb->RangeStepAndValidator( 0.0, 1.0, 0.05, "len_tol_precision" );
1293 else if( hypType()=="Arithmetic1D" )
1295 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "parametric_precision" );
1297 else if( hypType()=="MaxLength" )
1299 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1300 sb->setEnabled( !widget< QCheckBox >( 1 )->isChecked() );
1302 else if( hypType()=="MaxElementArea" )
1304 sb->RangeStepAndValidator( VALUE_SMALL_2, VALUE_MAX_2, 1.0, "area_precision" );
1306 else if( hypType()=="MaxElementVolume" )
1308 sb->RangeStepAndValidator( VALUE_SMALL_3, VALUE_MAX_3, 1.0, "vol_precision" );
1310 else if( hypType()=="StartEndLength" )
1312 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1314 else if( hypType()=="Deflection1D" )
1316 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "parametric_precision" );
1318 else if( hypType().startsWith( "ViscousLayers" ))
1320 if (sb->objectName() == tr("SMESH_STRETCH_FACTOR"))
1321 sb->RangeStepAndValidator( 1.0, VALUE_MAX, 0.1, "parametric_precision" );
1323 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1325 else // default validator for possible ancestors
1327 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1332 //================================================================================
1334 * \brief Return dlg title
1335 * \retval QString - title string
1337 //================================================================================
1339 QString StdMeshersGUI_StdHypothesisCreator::caption() const
1341 return tr( QString( "SMESH_%1_TITLE" ).arg( hypTypeName( hypType() ) ).toLatin1().data() );
1344 //================================================================================
1346 * \brief return pixmap for dlg icon
1349 //================================================================================
1351 QPixmap StdMeshersGUI_StdHypothesisCreator::icon() const
1353 QString hypIconName = tr( QString( "ICON_DLG_%1" ).arg( hypTypeName( hypType() ) ).toLatin1().data() );
1354 return SMESHGUI::resourceMgr()->loadPixmap( "SMESH", hypIconName );
1357 //================================================================================
1359 * \brief Return hypothesis type name to show in dlg
1362 //================================================================================
1364 QString StdMeshersGUI_StdHypothesisCreator::type() const
1366 return tr( QString( "SMESH_%1_HYPOTHESIS" ).arg( hypTypeName( hypType() ) ).toLatin1().data() );
1369 //================================================================================
1371 * \brief String to insert in "SMESH_%1_HYPOTHESIS" to get hypothesis type name
1372 * from message resouce file
1373 * \param t - hypothesis type
1374 * \retval QString - result string
1376 //================================================================================
1378 QString StdMeshersGUI_StdHypothesisCreator::hypTypeName( const QString& t ) const
1380 static QMap<QString,QString> types;
1381 if( types.isEmpty() )
1383 types.insert( "LocalLength", "LOCAL_LENGTH" );
1384 types.insert( "NumberOfSegments", "NB_SEGMENTS" );
1385 types.insert( "MaxElementArea", "MAX_ELEMENT_AREA" );
1386 types.insert( "MaxElementVolume", "MAX_ELEMENT_VOLUME" );
1387 types.insert( "StartEndLength", "START_END_LENGTH" );
1388 types.insert( "Deflection1D", "DEFLECTION1D" );
1389 types.insert( "Arithmetic1D", "ARITHMETIC_1D" );
1390 types.insert( "FixedPoints1D", "FIXED_POINTS_1D" );
1391 types.insert( "AutomaticLength", "AUTOMATIC_LENGTH" );
1392 types.insert( "ProjectionSource1D", "PROJECTION_SOURCE_1D" );
1393 types.insert( "ProjectionSource2D", "PROJECTION_SOURCE_2D" );
1394 types.insert( "ProjectionSource3D", "PROJECTION_SOURCE_3D" );
1395 types.insert( "ImportSource1D", "IMPORT_SOURCE_1D" );
1396 types.insert( "ImportSource2D", "IMPORT_SOURCE_2D" );
1397 types.insert( "NumberOfLayers", "NUMBER_OF_LAYERS" );
1398 types.insert( "LayerDistribution", "LAYER_DISTRIBUTION" );
1399 types.insert( "NumberOfLayers2D", "NUMBER_OF_LAYERS_2D" );
1400 types.insert( "LayerDistribution2D", "LAYER_DISTRIBUTION" );
1401 types.insert( "SegmentLengthAroundVertex", "SEGMENT_LENGTH_AROUND_VERTEX" );
1402 types.insert( "MaxLength", "MAX_LENGTH" );
1403 types.insert( "ViscousLayers", "VISCOUS_LAYERS" );
1404 types.insert( "ViscousLayers2D", "VISCOUS_LAYERS" );
1405 types.insert( "QuadrangleParams", "QUADRANGLE_PARAMS" );
1406 types.insert( "CartesianParameters3D", "CARTESIAN_PARAMS" );
1410 if( types.contains( t ) )
1417 //=======================================================================
1418 //function : getCustomWidget
1419 //purpose : is called from buildStdFrame()
1420 //=======================================================================
1422 QWidget* StdMeshersGUI_StdHypothesisCreator::getCustomWidget( const StdParam & param,
1424 const int index) const
1427 if ( index < customWidgets()->count() ) {
1428 w = customWidgets()->at( index );
1430 w->setParent( parent );
1431 w->move( QPoint( 0, 0 ) );
1437 //================================================================================
1439 * \brief Set param value taken from a custom widget
1440 * \param param - SMESHGUI_GenericHypothesisCreator::StdParam structure
1441 * \param widget - widget presenting param
1442 * \retval bool - success flag
1444 * this method is called from getStdParamFromDlg()
1446 //================================================================================
1448 bool StdMeshersGUI_StdHypothesisCreator::getParamFromCustomWidget( StdParam & param,
1449 QWidget* widget) const
1451 if ( hypType()=="AutomaticLength" ) {
1452 SMESHGUI_SpinBox* w = dynamic_cast<SMESHGUI_SpinBox*>( widget );
1454 param.myValue = w->GetValue();
1458 if ( hypType() == "MaxLength" ) {
1462 if ( widget->inherits( "StdMeshersGUI_ObjectReferenceParamWdg" ))
1464 // show only 1st reference value
1465 if ( true /*widget == getWidgetForParam( 0 )*/) {
1466 const StdMeshersGUI_ObjectReferenceParamWdg * w =
1467 static_cast<const StdMeshersGUI_ObjectReferenceParamWdg*>( widget );
1468 param.myValue = w->GetValue();
1472 if ( widget->inherits( "StdMeshersGUI_LayerDistributionParamWdg" ))
1474 const StdMeshersGUI_LayerDistributionParamWdg * w =
1475 static_cast<const StdMeshersGUI_LayerDistributionParamWdg*>( widget );
1476 param.myValue = w->GetValue();
1479 if ( widget->inherits( "StdMeshersGUI_SubShapeSelectorWdg" ))
1481 const StdMeshersGUI_SubShapeSelectorWdg * w =
1482 static_cast<const StdMeshersGUI_SubShapeSelectorWdg*>( widget );
1483 param.myValue = w->GetValue();
1486 if ( widget->inherits( "StdMeshersGUI_QuadrangleParamWdg" ))
1488 //const StdMeshersGUI_QuadrangleParamWdg * w =
1489 // static_cast<const StdMeshersGUI_QuadrangleParamWdg*>( widget );
1490 param.myValue = "QuadType";
1493 if ( widget->inherits( "StdMeshersGUI_FixedPointsParamWdg" ))
1495 const StdMeshersGUI_FixedPointsParamWdg * w =
1496 static_cast<const StdMeshersGUI_FixedPointsParamWdg*>( widget );
1497 param.myValue = w->GetValue();
1500 if ( widget->inherits( "QCheckBox" ))
1502 //const QCheckBox * w = static_cast<const QCheckBox*>( widget );
1503 //param.myValue = w->isChecked();
1506 if ( widget->inherits( "StdMeshersGUI_RadioButtonsGrpWdg" ))
1508 const StdMeshersGUI_RadioButtonsGrpWdg * w =
1509 static_cast<const StdMeshersGUI_RadioButtonsGrpWdg*>( widget );
1510 param.myValue = w->checkedId();
1516 //================================================================================
1518 * \brief called when operation cancelled
1520 //================================================================================
1522 void StdMeshersGUI_StdHypothesisCreator::onReject()
1524 if ( hypType().startsWith("ProjectionSource" ) ||
1525 hypType().startsWith("ImportSource" ))
1527 // Uninstall filters of StdMeshersGUI_ObjectReferenceParamWdg
1528 deactivateObjRefParamWdg( customWidgets() );
1532 //================================================================================
1534 * \brief Update widgets dependent on paramWidget
1536 //================================================================================
1538 void StdMeshersGUI_StdHypothesisCreator::valueChanged( QWidget* paramWidget)
1540 if ( hypType() == "MaxLength" && paramWidget == getWidgetForParam(1) )
1542 getWidgetForParam(0)->setEnabled( !widget< QCheckBox >( 1 )->isChecked() );
1543 if ( !getWidgetForParam(0)->isEnabled() ) {
1544 StdMeshers::StdMeshers_MaxLength_var h =
1545 StdMeshers::StdMeshers_MaxLength::_narrow( initParamsHypothesis() );
1546 widget< QtxDoubleSpinBox >( 0 )->setValue( h->GetPreestimatedLength() );
1549 else if ( hypType().startsWith("ImportSource") && paramWidget == getWidgetForParam(1) )
1551 QCheckBox* toCopyMesh = (QCheckBox*) paramWidget;
1552 QCheckBox* toCopyGroups = widget< QCheckBox >( 2 );
1553 if ( !toCopyMesh->isChecked() )
1555 toCopyGroups->setChecked( false );
1556 toCopyGroups->setEnabled( false );
1560 toCopyGroups->setEnabled( true );
1563 else if ( hypType() == "ViscousLayers2D" && paramWidget->inherits("QButtonGroup"))
1565 if ( QLabel* label = getLabel(4) )
1567 bool toIgnore = widget< StdMeshersGUI_RadioButtonsGrpWdg >( 3 )->checkedId();
1568 label->setText( tr( toIgnore ? "SMESH_EDGES_WO_LAYERS" : "SMESH_EDGES_WITH_LAYERS" ));
1573 //================================================================================
1577 //================================================================================
1579 bool StdMeshersGUI_StdHypothesisCreator::initVariableName(SMESH::SMESH_Hypothesis_var theHyp,
1580 StdParam & theParams,
1581 const char* theMethod) const
1583 QString aVaribaleName = getVariableName( theMethod );
1584 theParams.isVariable = !aVaribaleName.isEmpty();
1585 if (theParams.isVariable)
1586 theParams.myValue = aVaribaleName;
1588 return theParams.isVariable;