1 // Copyright (C) 2007-2012 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"
43 #include <SALOMEDSClient_Study.hxx>
45 #include <GEOM_wrap.hxx>
47 // SALOME GUI includes
48 #include <SUIT_ResourceMgr.h>
51 #include <SALOMEconfig.h>
52 #include CORBA_SERVER_HEADER(SMESH_BasicHypothesis)
53 #include CORBA_SERVER_HEADER(SMESH_Mesh)
54 #include CORBA_SERVER_HEADER(SMESH_Group)
57 #include <QHBoxLayout>
62 const double VALUE_MAX = 1.0e+15, // COORD_MAX
63 VALUE_MAX_2 = VALUE_MAX * VALUE_MAX,
64 VALUE_MAX_3 = VALUE_MAX_2 * VALUE_MAX,
65 VALUE_SMALL = 1.0e-15,
66 VALUE_SMALL_2 = VALUE_SMALL * VALUE_SMALL,
67 VALUE_SMALL_3 = VALUE_SMALL_2 * VALUE_SMALL;
69 //================================================================================
72 * \param type - hypothesis type
74 //================================================================================
76 StdMeshersGUI_StdHypothesisCreator::StdMeshersGUI_StdHypothesisCreator( const QString& type )
77 : SMESHGUI_GenericHypothesisCreator( type )
81 //================================================================================
85 //================================================================================
87 StdMeshersGUI_StdHypothesisCreator::~StdMeshersGUI_StdHypothesisCreator()
91 //================================================================================
93 * \brief Return widget for i-th hypothesis parameter (got from myParamWidgets)
94 * \param i - index of hypothesis parameter
95 * \retval QWidget* - found widget
97 //================================================================================
99 QWidget* StdMeshersGUI_StdHypothesisCreator::getWidgetForParam( int i ) const
102 if ( isCreation() ) ++i; // skip widget of 'name' parameter
104 if ( i < myCustomWidgets.count() ) {
105 QList<QWidget*>::const_iterator anIt = myCustomWidgets.begin();
106 QList<QWidget*>::const_iterator aLast = myCustomWidgets.end();
107 for ( int j = 0 ; !w && anIt != aLast; ++anIt, ++j )
112 // list has no at() const, so we iterate
113 QList<QWidget*>::const_iterator anIt = widgets().begin();
114 QList<QWidget*>::const_iterator aLast = widgets().end();
115 for( int j = 0; !w && anIt!=aLast; anIt++, ++j ) {
123 //================================================================================
125 * \brief Allow modifing myCustomWidgets in const methods
126 * \retval ListOfWidgets* - non-const pointer to myCustomWidgets
128 //================================================================================
130 StdMeshersGUI_StdHypothesisCreator::ListOfWidgets*
131 StdMeshersGUI_StdHypothesisCreator::customWidgets() const
133 return const_cast< ListOfWidgets* >( & myCustomWidgets );
136 //================================================================================
138 * \brief Builds dlg layout
139 * \retval QFrame* - the built widget
141 //================================================================================
143 QFrame* StdMeshersGUI_StdHypothesisCreator::buildFrame()
145 return buildStdFrame();
148 //================================================================================
150 * \brief Initialise parameter values in controls
152 //================================================================================
154 void StdMeshersGUI_StdHypothesisCreator::retrieveParams() const
156 // buildStdFrame() sets values itself calling stdParams()
158 if ( hypType().startsWith("ProjectionSource" ))
160 // we use this method to connect depending custom widgets
161 StdMeshersGUI_ObjectReferenceParamWdg* widgetToActivate = 0;
162 ListOfWidgets::const_iterator anIt = myCustomWidgets.begin();
163 for ( ; anIt != myCustomWidgets.end(); anIt++)
165 if ( *anIt && (*anIt)->inherits("StdMeshersGUI_ObjectReferenceParamWdg"))
167 StdMeshersGUI_ObjectReferenceParamWdg * w1 =
168 ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
169 ListOfWidgets::const_iterator anIt2 = anIt;
170 for ( ++anIt2; anIt2 != myCustomWidgets.end(); anIt2++)
171 if ( *anIt2 && (*anIt2)->inherits("StdMeshersGUI_ObjectReferenceParamWdg"))
173 StdMeshersGUI_ObjectReferenceParamWdg * w2 =
174 ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt2 );
175 w1->AvoidSimultaneousSelection( w2 );
177 if ( !widgetToActivate )
178 widgetToActivate = w1;
181 if ( widgetToActivate )
182 widgetToActivate->activateSelection();
186 dlg()->setMinimumSize( dlg()->minimumSizeHint().width(), dlg()->minimumSizeHint().height() );
191 //================================================================================
193 * \brief Widget: slider with left and right labels
195 //================================================================================
197 class TDoubleSliderWith2Labels: public QWidget
200 TDoubleSliderWith2Labels( const QString& leftLabel, const QString& rightLabel,
201 const double initValue, const double bottom,
202 const double top , const double precision,
203 QWidget * parent=0 , const char * name=0 )
204 :QWidget(parent), _bottom(bottom), _precision(precision)
208 QHBoxLayout* aHBoxL = new QHBoxLayout(this);
210 if ( !leftLabel.isEmpty() ) {
211 QLabel* aLeftLabel = new QLabel( this );
212 aLeftLabel->setText( leftLabel );
213 aHBoxL->addWidget( aLeftLabel );
216 _slider = new QSlider( Qt::Horizontal, this );
217 _slider->setRange( 0, toInt( top ));
218 _slider->setValue( toInt( initValue ));
219 aHBoxL->addWidget( _slider );
221 if ( !rightLabel.isEmpty() ) {
222 QLabel* aRightLabel = new QLabel( this );
223 aRightLabel->setText( rightLabel );
224 aHBoxL->addWidget( aRightLabel );
229 double value() const { return _bottom + _slider->value() * _precision; }
230 QSlider * getSlider() const { return _slider; }
231 int toInt( double val ) const { return (int) ceil(( val - _bottom ) / _precision ); }
233 double _bottom, _precision;
237 //================================================================================
239 * \brief Retrieve GEOM_Object held by widget
241 //================================================================================
243 inline GEOM::GEOM_Object_var geomFromWdg(const QWidget* wdg)
245 const StdMeshersGUI_ObjectReferenceParamWdg * objRefWdg =
246 dynamic_cast<const StdMeshersGUI_ObjectReferenceParamWdg*>( wdg );
248 return objRefWdg->GetObject< GEOM::GEOM_Object >();
250 return GEOM::GEOM_Object::_nil();
252 //================================================================================
254 * \brief Retrieve SMESH_Mesh held by widget
256 //================================================================================
258 inline SMESH::SMESH_Mesh_var meshFromWdg(const QWidget* wdg)
260 const StdMeshersGUI_ObjectReferenceParamWdg * objRefWdg =
261 dynamic_cast<const StdMeshersGUI_ObjectReferenceParamWdg*>( wdg );
263 return objRefWdg->GetObject< SMESH::SMESH_Mesh >();
265 return SMESH::SMESH_Mesh::_nil();
267 //================================================================================
269 * \brief Retrieve SMESH_Mesh held by widget
271 //================================================================================
273 inline SMESH::ListOfGroups_var groupsFromWdg(const QWidget* wdg)
275 SMESH::ListOfGroups_var groups = new SMESH::ListOfGroups;
276 const StdMeshersGUI_ObjectReferenceParamWdg * objRefWdg =
277 dynamic_cast<const StdMeshersGUI_ObjectReferenceParamWdg*>( wdg );
280 groups->length( objRefWdg->NbObjects() );
281 for ( unsigned i = 0; i < groups->length(); ++i )
282 groups[i] = objRefWdg->GetObject< SMESH::SMESH_GroupBase >(i);
286 //================================================================================
288 * \brief creates a filter for selection of shapes of given dimension
289 * \param dim - dimension
290 * \param subShapeType - required type of sub-shapes, number of which must be \a nbSubShapes
291 * \param nbSubShapes - number of sub-shapes of given type
292 * \param closed - required closeness flag of a shape
293 * \retval SUIT_SelectionFilter* - created filter
295 //================================================================================
297 SUIT_SelectionFilter* filterForShapeOfDim(const int dim,
298 TopAbs_ShapeEnum subShapeType = TopAbs_SHAPE,
299 const int nbSubShapes = 0,
302 TColStd_MapOfInteger shapeTypes;
304 case 0: shapeTypes.Add( TopAbs_VERTEX ); break;
306 if ( subShapeType == TopAbs_SHAPE ) subShapeType = TopAbs_EDGE;
307 shapeTypes.Add( TopAbs_EDGE );
308 shapeTypes.Add( TopAbs_COMPOUND ); // for a group
311 if ( subShapeType == TopAbs_SHAPE ) subShapeType = TopAbs_FACE;
312 shapeTypes.Add( TopAbs_FACE );
313 shapeTypes.Add( TopAbs_COMPOUND ); // for a group
316 shapeTypes.Add( TopAbs_SHELL );
317 shapeTypes.Add( TopAbs_SOLID );
318 shapeTypes.Add( TopAbs_COMPSOLID );
319 shapeTypes.Add( TopAbs_COMPOUND );
322 return new SMESH_NumberFilter("GEOM", subShapeType, nbSubShapes,
323 shapeTypes, GEOM::GEOM_Object::_nil(), closed);
326 //================================================================================
328 * \brief Create a widget for object selection
329 * \param object - initial object
330 * \param filter - selection filter
331 * \retval QWidget* - created widget
333 //================================================================================
335 QWidget* newObjRefParamWdg( SUIT_SelectionFilter* filter,
336 CORBA::Object_var object)
338 StdMeshersGUI_ObjectReferenceParamWdg* w =
339 new StdMeshersGUI_ObjectReferenceParamWdg( filter, 0);
340 w->SetObject( object.in() );
343 QWidget* newObjRefParamWdg( SUIT_SelectionFilter* filter,
344 SMESH::string_array_var& objEntries)
346 StdMeshersGUI_ObjectReferenceParamWdg* w =
347 new StdMeshersGUI_ObjectReferenceParamWdg( filter, 0, /*multiSel=*/true);
348 //RNV: Firstly, activate selection, then set objects
349 w->activateSelection();
350 w->SetObjects( objEntries );
354 //================================================================================
356 * \brief calls deactivateSelection() for StdMeshersGUI_ObjectReferenceParamWdg
357 * \param widgetList - list of widgets
359 //================================================================================
361 void deactivateObjRefParamWdg( QList<QWidget*>* widgetList )
363 StdMeshersGUI_ObjectReferenceParamWdg* w = 0;
364 QList<QWidget*>::iterator anIt = widgetList->begin();
365 QList<QWidget*>::iterator aLast = widgetList->end();
366 for ( ; anIt != aLast; anIt++ ) {
367 if ( (*anIt) && (*anIt)->inherits( "StdMeshersGUI_ObjectReferenceParamWdg" ))
369 w = (StdMeshersGUI_ObjectReferenceParamWdg* )( *anIt );
370 w->deactivateSelection();
376 //================================================================================
378 * \brief Check parameter values before accept()
379 * \retval bool - true if OK
381 //================================================================================
383 bool StdMeshersGUI_StdHypothesisCreator::checkParams( QString& msg ) const
385 if( !SMESHGUI_GenericHypothesisCreator::checkParams( msg ) )
388 // check if object reference parameter is set, as it has no default value
390 if ( hypType().startsWith("ProjectionSource" ))
392 StdMeshersGUI_ObjectReferenceParamWdg* w =
393 widget< StdMeshersGUI_ObjectReferenceParamWdg >( 0 );
394 ok = ( w->IsObjectSelected() );
395 if ( !ok ) w->SetObject( CORBA::Object::_nil() );
396 int nbAssocVert = ( hypType() == "ProjectionSource1D" ? 1 : 2 );
397 int nbNonEmptyAssoc = 0;
398 for ( int i = 0; ok && i < nbAssocVert*2; i += 2)
401 StdMeshersGUI_ObjectReferenceParamWdg* w1 =
402 widget< StdMeshersGUI_ObjectReferenceParamWdg >( i+2 );
403 StdMeshersGUI_ObjectReferenceParamWdg* w2 =
404 widget< StdMeshersGUI_ObjectReferenceParamWdg >( i+3 );
405 srcV = w1->GetValue();
406 tgtV = w2->GetValue();
407 ok = (( srcV.isEmpty() && tgtV.isEmpty() ) ||
408 ( !srcV.isEmpty() && !tgtV.isEmpty() && srcV != tgtV ));
410 w1->SetObject( CORBA::Object::_nil() );
411 w2->SetObject( CORBA::Object::_nil() );
413 nbNonEmptyAssoc += !srcV.isEmpty();
415 if ( ok && nbNonEmptyAssoc == 1 && nbAssocVert == 2 )
417 // only one pair of VERTEXes is given for a FACE,
418 // then the FACE must have only one VERTEX
419 GEOM::GEOM_Object_var face = w->GetObject< GEOM::GEOM_Object >();
421 GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen();
422 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
423 GEOM::GEOM_IShapesOperations_wrap shapeOp;
424 if ( !geomGen->_is_nil() && aStudy )
425 shapeOp = geomGen->GetIShapesOperations( aStudy->StudyId() );
426 if ( !shapeOp->_is_nil() )
428 GEOM::ListOfLong_var vertices =
429 shapeOp->GetAllSubShapesIDs (face, GEOM::VERTEX, /*isSorted=*/false);
430 ok = ( vertices->length() == 1 );
433 // Uninstall filters of StdMeshersGUI_ObjectReferenceParamWdg
435 deactivateObjRefParamWdg( customWidgets() );
437 else if ( hypType().startsWith("ImportSource" ))
439 StdMeshersGUI_ObjectReferenceParamWdg* w =
440 widget< StdMeshersGUI_ObjectReferenceParamWdg >( 0 );
441 ok = ( w->IsObjectSelected() );
443 else if ( hypType() == "LayerDistribution" || hypType() == "LayerDistribution2D" )
445 StdMeshersGUI_LayerDistributionParamWdg* w =
446 widget< StdMeshersGUI_LayerDistributionParamWdg >( 0 );
447 ok = ( w && w->IsOk() );
453 //================================================================================
455 * \brief Store params from GUI controls to a hypothesis
456 * \retval QString - text representation of parameters
458 //================================================================================
460 QString StdMeshersGUI_StdHypothesisCreator::storeParams() const
462 ListOfStdParams params;
463 bool res = getStdParamFromDlg( params );
466 SMESH::SetName( SMESH::FindSObject( hypothesis() ), params[0].myValue.toString().toLatin1().data() );
467 params.erase( params.begin() );
470 QString valueStr = stdParamValues( params );
471 //QStringList aVariablesList = getVariablesFromDlg();
473 if( res && !params.isEmpty() )
475 if( hypType()=="LocalLength" )
477 StdMeshers::StdMeshers_LocalLength_var h =
478 StdMeshers::StdMeshers_LocalLength::_narrow( hypothesis() );
480 h->SetVarParameter( params[0].text(), "SetLength" );
481 h->SetLength( params[0].myValue.toDouble() );
482 h->SetVarParameter( params[1].text(), "SetPrecision" );
483 h->SetPrecision( params[1].myValue.toDouble() );
485 else if( hypType()=="MaxLength" )
487 StdMeshers::StdMeshers_MaxLength_var h =
488 StdMeshers::StdMeshers_MaxLength::_narrow( hypothesis() );
490 h->SetVarParameter( params[0].text(), "SetLength" );
491 h->SetLength( params[0].myValue.toDouble() );
492 h->SetUsePreestimatedLength( widget< QCheckBox >( 1 )->isChecked() );
493 if ( !h->HavePreestimatedLength() && !h->_is_equivalent( initParamsHypothesis() )) {
494 StdMeshers::StdMeshers_MaxLength_var hInit =
495 StdMeshers::StdMeshers_MaxLength::_narrow( initParamsHypothesis() );
496 h->SetPreestimatedLength( hInit->GetPreestimatedLength() );
499 else if( hypType()=="SegmentLengthAroundVertex" )
501 StdMeshers::StdMeshers_SegmentLengthAroundVertex_var h =
502 StdMeshers::StdMeshers_SegmentLengthAroundVertex::_narrow( hypothesis() );
504 h->SetVarParameter( params[0].text(), "SetLength" );
505 h->SetLength( params[0].myValue.toDouble() );
507 else if( hypType()=="Arithmetic1D" )
509 StdMeshers::StdMeshers_Arithmetic1D_var h =
510 StdMeshers::StdMeshers_Arithmetic1D::_narrow( hypothesis() );
512 StdMeshersGUI_SubShapeSelectorWdg* w =
513 widget< StdMeshersGUI_SubShapeSelectorWdg >( 2 );
515 h->SetVarParameter( params[0].text(), "SetStartLength" );
516 h->SetStartLength( params[0].myValue.toDouble() );
517 h->SetVarParameter( params[1].text(), "SetEndLength" );
518 h->SetEndLength( params[1].myValue.toDouble() );
520 h->SetReversedEdges( w->GetListOfIDs() );
521 h->SetObjectEntry( w->GetMainShapeEntry() );
524 else if( hypType()=="FixedPoints1D" )
526 StdMeshers::StdMeshers_FixedPoints1D_var h =
527 StdMeshers::StdMeshers_FixedPoints1D::_narrow( hypothesis() );
529 StdMeshersGUI_FixedPointsParamWdg* w1 =
530 widget< StdMeshersGUI_FixedPointsParamWdg >( 0 );
532 StdMeshersGUI_SubShapeSelectorWdg* w2 =
533 widget< StdMeshersGUI_SubShapeSelectorWdg >( 1 );
536 h->SetPoints( w1->GetListOfPoints() );
537 h->SetNbSegments( w1->GetListOfSegments() );
540 h->SetReversedEdges( w2->GetListOfIDs() );
541 h->SetObjectEntry( w2->GetMainShapeEntry() );
544 else if( hypType()=="MaxElementArea" )
546 StdMeshers::StdMeshers_MaxElementArea_var h =
547 StdMeshers::StdMeshers_MaxElementArea::_narrow( hypothesis() );
548 h->SetVarParameter( params[0].text(), "SetMaxElementArea" );
549 h->SetMaxElementArea( params[0].myValue.toDouble() );
551 else if( hypType()=="MaxElementVolume" )
553 StdMeshers::StdMeshers_MaxElementVolume_var h =
554 StdMeshers::StdMeshers_MaxElementVolume::_narrow( hypothesis() );
556 h->SetVarParameter( params[0].text(), "SetMaxElementVolume" );
557 h->SetMaxElementVolume( params[0].myValue.toDouble() );
559 else if( hypType()=="StartEndLength" )
561 StdMeshers::StdMeshers_StartEndLength_var h =
562 StdMeshers::StdMeshers_StartEndLength::_narrow( hypothesis() );
564 StdMeshersGUI_SubShapeSelectorWdg* w =
565 widget< StdMeshersGUI_SubShapeSelectorWdg >( 2 );
567 h->SetVarParameter( params[0].text(), "SetStartLength" );
568 h->SetStartLength( params[0].myValue.toDouble() );
569 h->SetVarParameter( params[1].text(), "SetEndLength" );
570 h->SetEndLength( params[1].myValue.toDouble() );
572 h->SetReversedEdges( w->GetListOfIDs() );
573 h->SetObjectEntry( w->GetMainShapeEntry() );
576 else if( hypType()=="Deflection1D" )
578 StdMeshers::StdMeshers_Deflection1D_var h =
579 StdMeshers::StdMeshers_Deflection1D::_narrow( hypothesis() );
580 h->SetVarParameter( params[0].text(), "SetDeflection" );
581 h->SetDeflection( params[0].myValue.toDouble() );
583 else if( hypType()=="AutomaticLength" )
585 StdMeshers::StdMeshers_AutomaticLength_var h =
586 StdMeshers::StdMeshers_AutomaticLength::_narrow( hypothesis() );
588 h->SetVarParameter( params[0].text(), "SetFineness" );
589 h->SetFineness( params[0].myValue.toDouble() );
591 else if( hypType()=="NumberOfLayers" )
593 StdMeshers::StdMeshers_NumberOfLayers_var h =
594 StdMeshers::StdMeshers_NumberOfLayers::_narrow( hypothesis() );
596 h->SetVarParameter( params[0].text(), "SetNumberOfLayers" );
597 h->SetNumberOfLayers( params[0].myValue.toInt() );
599 else if( hypType()=="LayerDistribution" )
601 StdMeshers::StdMeshers_LayerDistribution_var h =
602 StdMeshers::StdMeshers_LayerDistribution::_narrow( hypothesis() );
603 StdMeshersGUI_LayerDistributionParamWdg* w =
604 widget< StdMeshersGUI_LayerDistributionParamWdg >( 0 );
606 h->SetLayerDistribution( w->GetHypothesis() );
608 else if( hypType()=="NumberOfLayers2D" )
610 StdMeshers::StdMeshers_NumberOfLayers2D_var h =
611 StdMeshers::StdMeshers_NumberOfLayers2D::_narrow( hypothesis() );
613 h->SetVarParameter( params[0].text(), "SetNumberOfLayers" );
614 h->SetNumberOfLayers( params[0].myValue.toInt() );
616 else if( hypType()=="LayerDistribution2D" )
618 StdMeshers::StdMeshers_LayerDistribution2D_var h =
619 StdMeshers::StdMeshers_LayerDistribution2D::_narrow( hypothesis() );
620 StdMeshersGUI_LayerDistributionParamWdg* w =
621 widget< StdMeshersGUI_LayerDistributionParamWdg >( 0 );
623 h->SetLayerDistribution( w->GetHypothesis() );
625 else if( hypType()=="ProjectionSource1D" )
627 StdMeshers::StdMeshers_ProjectionSource1D_var h =
628 StdMeshers::StdMeshers_ProjectionSource1D::_narrow( hypothesis() );
630 h->SetSourceEdge ( geomFromWdg ( getWidgetForParam( 0 )));
631 h->SetSourceMesh ( meshFromWdg ( getWidgetForParam( 1 )));
632 h->SetVertexAssociation( geomFromWdg ( getWidgetForParam( 2 )),
633 geomFromWdg ( getWidgetForParam( 3 )));
635 else if( hypType()=="ProjectionSource2D" )
637 StdMeshers::StdMeshers_ProjectionSource2D_var h =
638 StdMeshers::StdMeshers_ProjectionSource2D::_narrow( hypothesis() );
640 h->SetSourceFace ( geomFromWdg ( getWidgetForParam( 0 )));
641 h->SetSourceMesh ( meshFromWdg ( getWidgetForParam( 1 )));
642 h->SetVertexAssociation( geomFromWdg ( getWidgetForParam( 2 )), // src1
643 geomFromWdg ( getWidgetForParam( 4 )), // src2
644 geomFromWdg ( getWidgetForParam( 3 )), // tgt1
645 geomFromWdg ( getWidgetForParam( 5 ))); // tgt2
647 else if( hypType()=="ProjectionSource3D" )
649 StdMeshers::StdMeshers_ProjectionSource3D_var h =
650 StdMeshers::StdMeshers_ProjectionSource3D::_narrow( hypothesis() );
652 h->SetSource3DShape ( geomFromWdg ( getWidgetForParam( 0 )));
653 h->SetSourceMesh ( meshFromWdg ( getWidgetForParam( 1 )));
654 h->SetVertexAssociation( geomFromWdg ( getWidgetForParam( 2 )), // src1
655 geomFromWdg ( getWidgetForParam( 4 )), // src2
656 geomFromWdg ( getWidgetForParam( 3 )), // tgt1
657 geomFromWdg ( getWidgetForParam( 5 ))); // tgt2
659 else if( hypType()=="ImportSource1D" )
661 StdMeshers::StdMeshers_ImportSource1D_var h =
662 StdMeshers::StdMeshers_ImportSource1D::_narrow( hypothesis() );
664 SMESH::ListOfGroups_var groups = groupsFromWdg( getWidgetForParam( 0 ));
665 h->SetSourceEdges( groups.in() );
666 QCheckBox* toCopyMesh = widget< QCheckBox >( 1 );
667 QCheckBox* toCopyGroups = widget< QCheckBox >( 2 );
668 h->SetCopySourceMesh( toCopyMesh->isChecked(), toCopyGroups->isChecked());
670 else if( hypType()=="ImportSource2D" )
672 StdMeshers::StdMeshers_ImportSource2D_var h =
673 StdMeshers::StdMeshers_ImportSource2D::_narrow( hypothesis() );
675 SMESH::ListOfGroups_var groups = groupsFromWdg( getWidgetForParam( 0 ));
676 h->SetSourceFaces( groups.in() );
677 QCheckBox* toCopyMesh = widget< QCheckBox >( 1 );
678 QCheckBox* toCopyGroups = widget< QCheckBox >( 2 );
679 h->SetCopySourceMesh( toCopyMesh->isChecked(), toCopyGroups->isChecked());
681 else if( hypType()=="ViscousLayers" )
683 StdMeshers::StdMeshers_ViscousLayers_var h =
684 StdMeshers::StdMeshers_ViscousLayers::_narrow( hypothesis() );
686 h->SetVarParameter( params[0].text(), "SetTotalThickness" );
687 h->SetTotalThickness( params[0].myValue.toDouble() );
688 h->SetVarParameter( params[1].text(), "SetNumberLayers" );
689 h->SetNumberLayers ( params[1].myValue.toInt() );
690 h->SetVarParameter( params[2].text(), "SetStretchFactor" );
691 h->SetStretchFactor ( params[2].myValue.toDouble() );
693 if ( StdMeshersGUI_SubShapeSelectorWdg* idsWg =
694 widget< StdMeshersGUI_SubShapeSelectorWdg >( 3 ))
696 h->SetIgnoreFaces( idsWg->GetListOfIDs() );
699 else if( hypType()=="ViscousLayers2D" )
701 StdMeshers::StdMeshers_ViscousLayers2D_var h =
702 StdMeshers::StdMeshers_ViscousLayers2D::_narrow( hypothesis() );
704 h->SetVarParameter( params[0].text(), "SetTotalThickness" );
705 h->SetTotalThickness( params[0].myValue.toDouble() );
706 h->SetVarParameter( params[1].text(), "SetNumberLayers" );
707 h->SetNumberLayers ( params[1].myValue.toInt() );
708 h->SetVarParameter( params[2].text(), "SetStretchFactor" );
709 h->SetStretchFactor ( params[2].myValue.toDouble() );
711 if ( StdMeshersGUI_SubShapeSelectorWdg* idsWg =
712 widget< StdMeshersGUI_SubShapeSelectorWdg >( 3 ))
714 h->SetIgnoreEdges( idsWg->GetListOfIDs() );
717 else if( hypType()=="QuadrangleParams" )
719 StdMeshers::StdMeshers_QuadrangleParams_var h =
720 StdMeshers::StdMeshers_QuadrangleParams::_narrow( hypothesis() );
721 StdMeshersGUI_SubShapeSelectorWdg* w1 =
722 widget< StdMeshersGUI_SubShapeSelectorWdg >( 0 );
723 StdMeshersGUI_QuadrangleParamWdg* w2 =
724 widget< StdMeshersGUI_QuadrangleParamWdg >( 1 );
726 if (w1->GetListSize() > 0) {
727 h->SetTriaVertex(w1->GetListOfIDs()[0]); // getlist must be called once
728 const char * entry = w1->GetMainShapeEntry();
729 h->SetObjectEntry(entry);
731 h->SetQuadType(StdMeshers::QuadType(w2->GetType()));
738 //================================================================================
740 * \brief Return parameter values as SMESHGUI_GenericHypothesisCreator::StdParam
741 * \param p - list of parameters
742 * \retval bool - success flag
744 * Is called from SMESHGUI_GenericHypothesisCreator::buildStdFrame().
745 * Parameters will be shown using "standard" controls:
746 * Int by QtxIntSpinBox
747 * Double by SMESHGUI_SpinBox
748 * String by QLineEdit
749 * getCustomWidget() allows to redefine control for a parameter
751 //================================================================================
753 bool StdMeshersGUI_StdHypothesisCreator::stdParams( ListOfStdParams& p ) const
756 SMESHGUI_GenericHypothesisCreator::StdParam item;
759 customWidgets()->clear();
762 HypothesisData* data = SMESH::GetHypothesisData( hypType() );
763 item.myName = tr( "SMESH_NAME" );
764 item.myValue = data ? hypName() : QString();
766 customWidgets()->append(0);
769 SMESH::SMESH_Hypothesis_var hyp = initParamsHypothesis();
770 //SMESH::ListOfParameters_var aParameters = hyp->GetLastParameters();
772 if( hypType()=="LocalLength" )
774 StdMeshers::StdMeshers_LocalLength_var h =
775 StdMeshers::StdMeshers_LocalLength::_narrow( hyp );
777 item.myName = tr("SMESH_LOCAL_LENGTH_PARAM");
778 if(!initVariableName( hyp, item, "SetLength"))
779 item.myValue = h->GetLength();
782 item.myName = tr("SMESH_LOCAL_LENGTH_PRECISION");
783 if(!initVariableName( hyp, item, "SetPrecision"))
784 item.myValue = h->GetPrecision();
787 else if( hypType()=="MaxLength" )
789 StdMeshers::StdMeshers_MaxLength_var h =
790 StdMeshers::StdMeshers_MaxLength::_narrow( hyp );
791 // try to set a right preestimated length to edited hypothesis
792 bool noPreestimatedAtEdition = false;
793 if ( !isCreation() ) {
794 StdMeshers::StdMeshers_MaxLength_var initHyp =
795 StdMeshers::StdMeshers_MaxLength::_narrow( initParamsHypothesis(true) );
796 noPreestimatedAtEdition =
797 ( initHyp->_is_nil() || !initHyp->HavePreestimatedLength() );
798 if ( !noPreestimatedAtEdition )
799 h->SetPreestimatedLength( initHyp->GetPreestimatedLength() );
802 item.myName = tr("SMESH_LOCAL_LENGTH_PARAM");
803 if(!initVariableName( hyp, item, "SetLength"))
804 item.myValue = h->GetLength();
806 customWidgets()->append(0);
808 item.myName = tr("SMESH_USE_PREESTIMATED_LENGTH");
810 QCheckBox* aQCheckBox = new QCheckBox(dlg());
811 if ( !noPreestimatedAtEdition && h->HavePreestimatedLength() ) {
812 aQCheckBox->setChecked( h->GetUsePreestimatedLength() );
813 connect( aQCheckBox, SIGNAL( stateChanged(int) ), this, SLOT( onValueChanged() ) );
816 aQCheckBox->setChecked( false );
817 aQCheckBox->setEnabled( false );
819 customWidgets()->append( aQCheckBox );
821 else if( hypType()=="SegmentLengthAroundVertex" )
823 StdMeshers::StdMeshers_SegmentLengthAroundVertex_var h =
824 StdMeshers::StdMeshers_SegmentLengthAroundVertex::_narrow( hyp );
826 item.myName = tr("SMESH_LOCAL_LENGTH_PARAM");
827 if(!initVariableName( hyp, item, "SetLength"))
828 item.myValue = h->GetLength();
832 else if( hypType()=="Arithmetic1D" )
834 StdMeshers::StdMeshers_Arithmetic1D_var h =
835 StdMeshers::StdMeshers_Arithmetic1D::_narrow( hyp );
837 item.myName = tr( "SMESH_START_LENGTH_PARAM" );
838 if(!initVariableName( hyp, item, "SetStartLength" ))
839 item.myValue = h->GetLength( true );
842 customWidgets()->append (0);
844 item.myName = tr( "SMESH_END_LENGTH_PARAM" );
845 if(!initVariableName( hyp, item, "SetEndLength" ))
846 item.myValue = h->GetLength( false );
849 customWidgets()->append (0);
851 item.myName = tr( "SMESH_REVERSED_EDGES" );
854 StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget =
855 new StdMeshersGUI_SubShapeSelectorWdg();
856 QString aGeomEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
857 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
858 if ( aGeomEntry == "" )
859 aGeomEntry = h->GetObjectEntry();
861 aDirectionWidget->SetGeomShapeEntry( aGeomEntry );
862 aDirectionWidget->SetMainShapeEntry( aMainEntry );
863 aDirectionWidget->SetListOfIDs( h->GetReversedEdges() );
864 aDirectionWidget->showPreview( true );
865 customWidgets()->append ( aDirectionWidget );
869 else if( hypType()=="FixedPoints1D" )
871 StdMeshers::StdMeshers_FixedPoints1D_var h =
872 StdMeshers::StdMeshers_FixedPoints1D::_narrow( hyp );
874 item.myName = tr( "SMESH_FIXED_POINTS" );
877 StdMeshersGUI_FixedPointsParamWdg* aFixedPointsWidget =
878 new StdMeshersGUI_FixedPointsParamWdg();
880 if ( !isCreation() ) {
881 aFixedPointsWidget->SetListOfPoints( h->GetPoints() );
882 aFixedPointsWidget->SetListOfSegments( h->GetNbSegments() );
884 customWidgets()->append( aFixedPointsWidget );
886 item.myName = tr( "SMESH_REVERSED_EDGES" );
889 StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget =
890 new StdMeshersGUI_SubShapeSelectorWdg();
891 QString anEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
892 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
894 anEntry = h->GetObjectEntry();
895 aDirectionWidget->SetGeomShapeEntry( anEntry );
896 aDirectionWidget->SetMainShapeEntry( aMainEntry );
897 aDirectionWidget->SetListOfIDs( h->GetReversedEdges() );
898 aDirectionWidget->showPreview( true );
899 customWidgets()->append ( aDirectionWidget );
903 else if( hypType()=="MaxElementArea" )
905 StdMeshers::StdMeshers_MaxElementArea_var h =
906 StdMeshers::StdMeshers_MaxElementArea::_narrow( hyp );
908 item.myName = tr( "SMESH_MAX_ELEMENT_AREA_PARAM" );
909 if(!initVariableName( hyp, item, "SetMaxElementArea" ))
910 item.myValue = h->GetMaxElementArea();
914 else if( hypType()=="MaxElementVolume" )
916 StdMeshers::StdMeshers_MaxElementVolume_var h =
917 StdMeshers::StdMeshers_MaxElementVolume::_narrow( hyp );
919 item.myName = tr( "SMESH_MAX_ELEMENT_VOLUME_PARAM" );
920 if(!initVariableName( hyp, item, "SetMaxElementVolume" ))
921 item.myValue = h->GetMaxElementVolume();
924 else if( hypType()=="StartEndLength" )
926 StdMeshers::StdMeshers_StartEndLength_var h =
927 StdMeshers::StdMeshers_StartEndLength::_narrow( hyp );
929 item.myName = tr( "SMESH_START_LENGTH_PARAM" );
931 if(!initVariableName( hyp, item, "SetStartLength" ))
932 item.myValue = h->GetLength( true );
934 customWidgets()->append(0);
936 item.myName = tr( "SMESH_END_LENGTH_PARAM" );
937 if(!initVariableName( hyp, item, "SetEndLength" ))
938 item.myValue = h->GetLength( false );
940 customWidgets()->append(0);
942 item.myName = tr( "SMESH_REVERSED_EDGES" );
945 StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget =
946 new StdMeshersGUI_SubShapeSelectorWdg();
947 QString anEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
948 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
950 anEntry = h->GetObjectEntry();
951 aDirectionWidget->SetGeomShapeEntry( anEntry );
952 aDirectionWidget->SetMainShapeEntry( aMainEntry );
953 aDirectionWidget->SetListOfIDs( h->GetReversedEdges() );
954 aDirectionWidget->showPreview( true );
955 customWidgets()->append ( aDirectionWidget );
957 else if( hypType()=="Deflection1D" )
959 StdMeshers::StdMeshers_Deflection1D_var h =
960 StdMeshers::StdMeshers_Deflection1D::_narrow( hyp );
962 item.myName = tr( "SMESH_DEFLECTION1D_PARAM" );
963 if(!initVariableName( hyp, item, "SetDeflection" ))
964 item.myValue = h->GetDeflection();
967 else if( hypType()=="AutomaticLength" )
969 StdMeshers::StdMeshers_AutomaticLength_var h =
970 StdMeshers::StdMeshers_AutomaticLength::_narrow( hyp );
972 item.myName = tr( "SMESH_FINENESS_PARAM" );
973 //item.myValue = h->GetFineness();
975 SMESHGUI_SpinBox* _autoLengthSpinBox = new SMESHGUI_SpinBox(dlg());
976 _autoLengthSpinBox->RangeStepAndValidator(0, 1, 0.01, "length_precision");
977 _autoLengthSpinBox->SetValue(h->GetFineness());
978 customWidgets()->append( _autoLengthSpinBox);
980 else if( hypType()=="NumberOfLayers" )
982 StdMeshers::StdMeshers_NumberOfLayers_var h =
983 StdMeshers::StdMeshers_NumberOfLayers::_narrow( hyp );
985 item.myName = tr( "SMESH_NUMBER_OF_LAYERS" );
986 if(!initVariableName( hyp, item, "SetNumberOfLayers" ))
987 item.myValue = (int) h->GetNumberOfLayers();
990 else if( hypType()=="LayerDistribution" )
992 StdMeshers::StdMeshers_LayerDistribution_var h =
993 StdMeshers::StdMeshers_LayerDistribution::_narrow( hyp );
995 item.myName = tr( "SMESH_LAYERS_DISTRIBUTION" ); p.append( item );
996 initVariableName( hyp, item, "SetLayerDistribution" );
997 customWidgets()->append
998 ( new StdMeshersGUI_LayerDistributionParamWdg( h->GetLayerDistribution(), hypName(), dlg()));
1000 else if( hypType()=="NumberOfLayers2D" )
1002 StdMeshers::StdMeshers_NumberOfLayers2D_var h =
1003 StdMeshers::StdMeshers_NumberOfLayers2D::_narrow( hyp );
1005 item.myName = tr( "SMESH_NUMBER_OF_LAYERS" );
1006 if(!initVariableName( hyp, item, "SetNumberOfLayers" ))
1007 item.myValue = (int) h->GetNumberOfLayers();
1010 else if( hypType()=="LayerDistribution2D" )
1012 StdMeshers::StdMeshers_LayerDistribution2D_var h =
1013 StdMeshers::StdMeshers_LayerDistribution2D::_narrow( hyp );
1015 item.myName = tr( "SMESH_LAYERS_DISTRIBUTION" ); p.append( item );
1016 initVariableName( hyp, item, "SetLayerDistribution" );
1017 customWidgets()->append
1018 ( new StdMeshersGUI_LayerDistributionParamWdg( h->GetLayerDistribution(), hypName(), dlg()));
1020 else if( hypType()=="ProjectionSource1D" )
1022 StdMeshers::StdMeshers_ProjectionSource1D_var h =
1023 StdMeshers::StdMeshers_ProjectionSource1D::_narrow( hyp );
1025 item.myName = tr( "SMESH_SOURCE_EDGE" ); p.append( item );
1026 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 1 ),
1027 h->GetSourceEdge()));
1028 item.myName = tr( "SMESH_SOURCE_MESH" ); p.append( item );
1029 customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( SMESH::MESH ),
1030 h->GetSourceMesh()));
1031 item.myName = tr( "SMESH_SOURCE_VERTEX" ); p.append( item );
1032 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1033 h->GetSourceVertex()));
1034 item.myName = tr( "SMESH_TARGET_VERTEX" ); p.append( item );
1035 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1036 h->GetTargetVertex()));
1038 else if( hypType()=="ProjectionSource2D" )
1040 StdMeshers::StdMeshers_ProjectionSource2D_var h =
1041 StdMeshers::StdMeshers_ProjectionSource2D::_narrow( hyp );
1043 item.myName = tr( "SMESH_SOURCE_FACE" ); p.append( item );
1044 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 2 ),
1045 h->GetSourceFace()));
1046 item.myName = tr( "SMESH_SOURCE_MESH" ); p.append( item );
1047 customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( SMESH::MESH ),
1048 h->GetSourceMesh()));
1049 item.myName = tr( "SMESH_SOURCE_VERTEX1" ); p.append( item );
1050 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1051 h->GetSourceVertex( 1 )));
1052 item.myName = tr( "SMESH_TARGET_VERTEX1" ); p.append( item );
1053 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1054 h->GetTargetVertex( 1 )));
1055 item.myName = tr( "SMESH_SOURCE_VERTEX2" ); p.append( item );
1056 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1057 h->GetSourceVertex( 2 )));
1058 item.myName = tr( "SMESH_TARGET_VERTEX2" ); p.append( item );
1059 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1060 h->GetTargetVertex( 2 )));
1062 else if( hypType()=="ProjectionSource3D" )
1064 StdMeshers::StdMeshers_ProjectionSource3D_var h =
1065 StdMeshers::StdMeshers_ProjectionSource3D::_narrow( hyp );
1067 item.myName = tr( "SMESH_SOURCE_3DSHAPE" ); p.append( item );
1068 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 3, TopAbs_FACE, 6, true ),
1069 h->GetSource3DShape()));
1070 item.myName = tr( "SMESH_SOURCE_MESH" ); p.append( item );
1071 customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( SMESH::MESH ),
1072 h->GetSourceMesh()));
1073 item.myName = tr( "SMESH_SOURCE_VERTEX1" ); p.append( item );
1074 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1075 h->GetSourceVertex( 1 )));
1076 item.myName = tr( "SMESH_TARGET_VERTEX1" ); p.append( item );
1077 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1078 h->GetTargetVertex( 1 )));
1079 item.myName = tr( "SMESH_SOURCE_VERTEX2" ); p.append( item );
1080 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1081 h->GetSourceVertex( 2 )));
1082 item.myName = tr( "SMESH_TARGET_VERTEX2" ); p.append( item );
1083 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1084 h->GetTargetVertex( 2 )));
1086 else if( hypType()=="ImportSource1D" )
1088 StdMeshers::StdMeshers_ImportSource1D_var h =
1089 StdMeshers::StdMeshers_ImportSource1D::_narrow( hyp );
1091 SMESH::string_array_var groupEntries = h->GetSourceEdges();
1092 CORBA::Boolean toCopyMesh, toCopyGroups;
1093 h->GetCopySourceMesh(toCopyMesh, toCopyGroups);
1095 item.myName = tr( "SMESH_SOURCE_EDGES" ); p.append( item );
1096 customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( SMESH::GROUP_EDGE ),
1099 item.myName = tr( "SMESH_COPY_MESH" ); p.append( item );
1100 QCheckBox* aQCheckBox = new QCheckBox(dlg());
1101 aQCheckBox->setChecked( toCopyMesh );
1102 connect( aQCheckBox, SIGNAL( stateChanged(int) ), this, SLOT( onValueChanged() ));
1103 customWidgets()->append( aQCheckBox );
1105 item.myName = tr( "SMESH_TO_COPY_GROUPS" ); p.append( item );
1106 aQCheckBox = new QCheckBox(dlg());
1107 aQCheckBox->setChecked( toCopyGroups );
1108 aQCheckBox->setEnabled( toCopyMesh );
1109 customWidgets()->append( aQCheckBox );
1111 else if( hypType()=="ImportSource2D" )
1113 StdMeshers::StdMeshers_ImportSource2D_var h =
1114 StdMeshers::StdMeshers_ImportSource2D::_narrow( hyp );
1116 SMESH::string_array_var groupEntries = h->GetSourceFaces();
1117 CORBA::Boolean toCopyMesh, toCopyGroups;
1118 h->GetCopySourceMesh(toCopyMesh, toCopyGroups);
1120 item.myName = tr( "SMESH_SOURCE_FACES" ); p.append( item );
1121 customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( SMESH::GROUP_FACE ),
1124 item.myName = tr( "SMESH_COPY_MESH" ); p.append( item );
1125 QCheckBox* aQCheckBox = new QCheckBox(dlg());
1126 aQCheckBox->setChecked( toCopyMesh );
1127 connect( aQCheckBox, SIGNAL( stateChanged(int) ), this, SLOT( onValueChanged() ));
1128 customWidgets()->append( aQCheckBox );
1130 item.myName = tr( "SMESH_COPY_GROUPS" ); p.append( item );
1131 aQCheckBox = new QCheckBox(dlg());
1132 aQCheckBox->setChecked( toCopyGroups );
1133 aQCheckBox->setEnabled( toCopyMesh );
1134 customWidgets()->append( aQCheckBox );
1136 else if( hypType()=="ViscousLayers" )
1138 StdMeshers::StdMeshers_ViscousLayers_var h =
1139 StdMeshers::StdMeshers_ViscousLayers::_narrow( hyp );
1141 item.myName = tr( "SMESH_TOTAL_THICKNESS" );
1142 if(!initVariableName( hyp, item, "SetTotalThickness" ))
1143 item.myValue = h->GetTotalThickness();
1145 customWidgets()->append (0);
1147 item.myName = tr( "SMESH_NUMBER_OF_LAYERS" );
1148 if(!initVariableName( hyp, item, "SetNumberLayers" ))
1149 item.myValue = h->GetNumberLayers();
1151 customWidgets()->append (0);
1153 item.myName = tr( "SMESH_STRETCH_FACTOR" );
1154 if(!initVariableName( hyp, item, "SetStretchFactor" ))
1155 item.myValue = h->GetStretchFactor();
1157 customWidgets()->append (0);
1159 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
1160 if ( !aMainEntry.isEmpty() )
1162 item.myName = tr( "SMESH_FACES_WO_LAYERS" );
1165 StdMeshersGUI_SubShapeSelectorWdg* idsWg =
1166 new StdMeshersGUI_SubShapeSelectorWdg(0,TopAbs_FACE);
1168 idsWg->SetGeomShapeEntry( aMainEntry );
1169 idsWg->SetMainShapeEntry( aMainEntry );
1170 idsWg->SetListOfIDs( h->GetIgnoreFaces() );
1171 idsWg->showPreview( true );
1172 customWidgets()->append ( idsWg );
1175 else if( hypType()=="ViscousLayers2D" )
1177 StdMeshers::StdMeshers_ViscousLayers2D_var h =
1178 StdMeshers::StdMeshers_ViscousLayers2D::_narrow( hyp );
1180 item.myName = tr( "SMESH_TOTAL_THICKNESS" );
1181 if(!initVariableName( hyp, item, "SetTotalThickness" ))
1182 item.myValue = h->GetTotalThickness();
1184 customWidgets()->append (0);
1186 item.myName = tr( "SMESH_NUMBER_OF_LAYERS" );
1187 if(!initVariableName( hyp, item, "SetNumberLayers" ))
1188 item.myValue = h->GetNumberLayers();
1190 customWidgets()->append (0);
1192 item.myName = tr( "SMESH_STRETCH_FACTOR" );
1193 if(!initVariableName( hyp, item, "SetStretchFactor" ))
1194 item.myValue = h->GetStretchFactor();
1196 customWidgets()->append (0);
1198 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
1199 if ( !aMainEntry.isEmpty() )
1201 item.myName = tr( "SMESH_EDGES_WO_LAYERS" );
1204 StdMeshersGUI_SubShapeSelectorWdg* idsWg =
1205 new StdMeshersGUI_SubShapeSelectorWdg(0,TopAbs_EDGE);
1207 idsWg->SetGeomShapeEntry( aMainEntry );
1208 idsWg->SetMainShapeEntry( aMainEntry );
1209 idsWg->SetListOfIDs( h->GetIgnoreEdges() );
1210 idsWg->showPreview( true );
1211 customWidgets()->append ( idsWg );
1214 else if (hypType() == "QuadrangleParams")
1216 StdMeshers::StdMeshers_QuadrangleParams_var h =
1217 StdMeshers::StdMeshers_QuadrangleParams::_narrow(hyp);
1219 item.myName = tr("SMESH_BASE_VERTEX");
1222 StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget =
1223 new StdMeshersGUI_SubShapeSelectorWdg(0, TopAbs_VERTEX);
1224 aDirectionWidget->SetMaxSize(1);
1225 QString anEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
1226 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
1228 anEntry = h->GetObjectEntry();
1229 aDirectionWidget->SetGeomShapeEntry(anEntry);
1230 aDirectionWidget->SetMainShapeEntry(aMainEntry);
1231 if (!isCreation()) {
1232 SMESH::long_array_var aVec = new SMESH::long_array;
1233 int vertID = h->GetTriaVertex();
1237 aDirectionWidget->SetListOfIDs(aVec);
1240 aDirectionWidget->showPreview(true);
1242 item.myName = tr("SMESH_QUAD_TYPE");
1245 StdMeshersGUI_QuadrangleParamWdg* aTypeWidget =
1246 new StdMeshersGUI_QuadrangleParamWdg();
1247 if (!isCreation()) {
1248 aTypeWidget->SetType(int(h->GetQuadType()));
1251 customWidgets()->append(aDirectionWidget);
1252 customWidgets()->append(aTypeWidget);
1259 //================================================================================
1261 * \brief tune "standard" control
1262 * \param w - control widget
1263 * \param int - parameter index
1265 //================================================================================
1267 void StdMeshersGUI_StdHypothesisCreator::attuneStdWidget (QWidget* w, const int) const
1269 SMESHGUI_SpinBox* sb = w->inherits( "SMESHGUI_SpinBox" ) ? ( SMESHGUI_SpinBox* )w : 0;
1272 if( hypType()=="LocalLength" )
1274 if (sb->objectName() == tr("SMESH_LOCAL_LENGTH_PARAM"))
1275 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1276 else if (sb->objectName() == tr("SMESH_LOCAL_LENGTH_PRECISION"))
1277 sb->RangeStepAndValidator( 0.0, 1.0, 0.05, "len_tol_precision" );
1279 else if( hypType()=="Arithmetic1D" )
1281 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "parametric_precision" );
1283 else if( hypType()=="MaxLength" )
1285 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1286 sb->setEnabled( !widget< QCheckBox >( 1 )->isChecked() );
1288 else if( hypType()=="MaxElementArea" )
1290 sb->RangeStepAndValidator( VALUE_SMALL_2, VALUE_MAX_2, 1.0, "area_precision" );
1292 else if( hypType()=="MaxElementVolume" )
1294 sb->RangeStepAndValidator( VALUE_SMALL_3, VALUE_MAX_3, 1.0, "vol_precision" );
1296 else if( hypType()=="StartEndLength" )
1298 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1300 else if( hypType()=="Deflection1D" )
1302 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "parametric_precision" );
1304 else if( hypType().startsWith( "ViscousLayers" ))
1306 if (sb->objectName() == tr("SMESH_STRETCH_FACTOR"))
1307 sb->RangeStepAndValidator( 1.0, VALUE_MAX, 0.1, "parametric_precision" );
1309 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1311 else // default validator for possible ancestors
1313 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1318 //================================================================================
1320 * \brief Return dlg title
1321 * \retval QString - title string
1323 //================================================================================
1325 QString StdMeshersGUI_StdHypothesisCreator::caption() const
1327 return tr( QString( "SMESH_%1_TITLE" ).arg( hypTypeName( hypType() ) ).toLatin1().data() );
1330 //================================================================================
1332 * \brief return pixmap for dlg icon
1335 //================================================================================
1337 QPixmap StdMeshersGUI_StdHypothesisCreator::icon() const
1339 QString hypIconName = tr( QString( "ICON_DLG_%1" ).arg( hypTypeName( hypType() ) ).toLatin1().data() );
1340 return SMESHGUI::resourceMgr()->loadPixmap( "SMESH", hypIconName );
1343 //================================================================================
1345 * \brief Return hypothesis type name to show in dlg
1348 //================================================================================
1350 QString StdMeshersGUI_StdHypothesisCreator::type() const
1352 return tr( QString( "SMESH_%1_HYPOTHESIS" ).arg( hypTypeName( hypType() ) ).toLatin1().data() );
1355 //================================================================================
1357 * \brief String to insert in "SMESH_%1_HYPOTHESIS" to get hypothesis type name
1358 * from message resouce file
1359 * \param t - hypothesis type
1360 * \retval QString - result string
1362 //================================================================================
1364 QString StdMeshersGUI_StdHypothesisCreator::hypTypeName( const QString& t ) const
1366 static QMap<QString,QString> types;
1367 if( types.isEmpty() )
1369 types.insert( "LocalLength", "LOCAL_LENGTH" );
1370 types.insert( "NumberOfSegments", "NB_SEGMENTS" );
1371 types.insert( "MaxElementArea", "MAX_ELEMENT_AREA" );
1372 types.insert( "MaxElementVolume", "MAX_ELEMENT_VOLUME" );
1373 types.insert( "StartEndLength", "START_END_LENGTH" );
1374 types.insert( "Deflection1D", "DEFLECTION1D" );
1375 types.insert( "Arithmetic1D", "ARITHMETIC_1D" );
1376 types.insert( "FixedPoints1D", "FIXED_POINTS_1D" );
1377 types.insert( "AutomaticLength", "AUTOMATIC_LENGTH" );
1378 types.insert( "ProjectionSource1D", "PROJECTION_SOURCE_1D" );
1379 types.insert( "ProjectionSource2D", "PROJECTION_SOURCE_2D" );
1380 types.insert( "ProjectionSource3D", "PROJECTION_SOURCE_3D" );
1381 types.insert( "ImportSource1D", "IMPORT_SOURCE_1D" );
1382 types.insert( "ImportSource2D", "IMPORT_SOURCE_2D" );
1383 types.insert( "NumberOfLayers", "NUMBER_OF_LAYERS" );
1384 types.insert( "LayerDistribution", "LAYER_DISTRIBUTION" );
1385 types.insert( "NumberOfLayers2D", "NUMBER_OF_LAYERS_2D" );
1386 types.insert( "LayerDistribution2D", "LAYER_DISTRIBUTION" );
1387 types.insert( "SegmentLengthAroundVertex", "SEGMENT_LENGTH_AROUND_VERTEX" );
1388 types.insert( "MaxLength", "MAX_LENGTH" );
1389 types.insert( "ViscousLayers", "VISCOUS_LAYERS" );
1390 types.insert( "ViscousLayers2D", "VISCOUS_LAYERS" );
1391 types.insert( "QuadrangleParams", "QUADRANGLE_PARAMS" );
1392 types.insert( "CartesianParameters3D", "CARTESIAN_PARAMS" );
1396 if( types.contains( t ) )
1403 //=======================================================================
1404 //function : getCustomWidget
1405 //purpose : is called from buildStdFrame()
1406 //=======================================================================
1408 QWidget* StdMeshersGUI_StdHypothesisCreator::getCustomWidget( const StdParam & param,
1410 const int index) const
1413 if ( index < customWidgets()->count() ) {
1414 w = customWidgets()->at( index );
1416 w->setParent( parent );
1417 w->move( QPoint( 0, 0 ) );
1423 //================================================================================
1425 * \brief Set param value taken from a custom widget
1426 * \param param - SMESHGUI_GenericHypothesisCreator::StdParam structure
1427 * \param widget - widget presenting param
1428 * \retval bool - success flag
1430 * this method is called from getStdParamFromDlg()
1432 //================================================================================
1434 bool StdMeshersGUI_StdHypothesisCreator::getParamFromCustomWidget( StdParam & param,
1435 QWidget* widget) const
1437 if ( hypType()=="AutomaticLength" ) {
1438 SMESHGUI_SpinBox* w = dynamic_cast<SMESHGUI_SpinBox*>( widget );
1440 param.myValue = w->GetValue();
1444 if ( hypType() == "MaxLength" ) {
1448 if ( widget->inherits( "StdMeshersGUI_ObjectReferenceParamWdg" ))
1450 // show only 1st reference value
1451 if ( true /*widget == getWidgetForParam( 0 )*/) {
1452 const StdMeshersGUI_ObjectReferenceParamWdg * w =
1453 static_cast<const StdMeshersGUI_ObjectReferenceParamWdg*>( widget );
1454 param.myValue = w->GetValue();
1458 if ( widget->inherits( "StdMeshersGUI_LayerDistributionParamWdg" ))
1460 const StdMeshersGUI_LayerDistributionParamWdg * w =
1461 static_cast<const StdMeshersGUI_LayerDistributionParamWdg*>( widget );
1462 param.myValue = w->GetValue();
1465 if ( widget->inherits( "StdMeshersGUI_SubShapeSelectorWdg" ))
1467 const StdMeshersGUI_SubShapeSelectorWdg * w =
1468 static_cast<const StdMeshersGUI_SubShapeSelectorWdg*>( widget );
1469 param.myValue = w->GetValue();
1472 if ( widget->inherits( "StdMeshersGUI_QuadrangleParamWdg" ))
1474 //const StdMeshersGUI_QuadrangleParamWdg * w =
1475 // static_cast<const StdMeshersGUI_QuadrangleParamWdg*>( widget );
1476 param.myValue = "QuadType";
1479 if ( widget->inherits( "StdMeshersGUI_FixedPointsParamWdg" ))
1481 const StdMeshersGUI_FixedPointsParamWdg * w =
1482 static_cast<const StdMeshersGUI_FixedPointsParamWdg*>( widget );
1483 param.myValue = w->GetValue();
1486 if ( widget->inherits( "QCheckBox" ))
1488 //const QCheckBox * w = static_cast<const QCheckBox*>( widget );
1489 //param.myValue = w->isChecked();
1495 //================================================================================
1497 * \brief called when operation cancelled
1499 //================================================================================
1501 void StdMeshersGUI_StdHypothesisCreator::onReject()
1503 if ( hypType().startsWith("ProjectionSource" ) ||
1504 hypType().startsWith("ImportSource" ))
1506 // Uninstall filters of StdMeshersGUI_ObjectReferenceParamWdg
1507 deactivateObjRefParamWdg( customWidgets() );
1511 //================================================================================
1513 * \brief Update widgets dependent on paramWidget
1515 //================================================================================
1517 void StdMeshersGUI_StdHypothesisCreator::valueChanged( QWidget* paramWidget)
1519 if ( hypType() == "MaxLength" && paramWidget == getWidgetForParam(1) )
1521 getWidgetForParam(0)->setEnabled( !widget< QCheckBox >( 1 )->isChecked() );
1522 if ( !getWidgetForParam(0)->isEnabled() ) {
1523 StdMeshers::StdMeshers_MaxLength_var h =
1524 StdMeshers::StdMeshers_MaxLength::_narrow( initParamsHypothesis() );
1525 widget< QtxDoubleSpinBox >( 0 )->setValue( h->GetPreestimatedLength() );
1528 else if ( hypType().startsWith("ImportSource") && paramWidget == getWidgetForParam(1) )
1530 QCheckBox* toCopyMesh = (QCheckBox*) paramWidget;
1531 QCheckBox* toCopyGroups = widget< QCheckBox >( 2 );
1532 if ( !toCopyMesh->isChecked() )
1534 toCopyGroups->setChecked( false );
1535 toCopyGroups->setEnabled( false );
1539 toCopyGroups->setEnabled( true );
1544 //================================================================================
1548 //================================================================================
1550 bool StdMeshersGUI_StdHypothesisCreator::initVariableName(SMESH::SMESH_Hypothesis_var theHyp,
1551 StdParam & theParams,
1552 const char* theMethod) const
1554 QString aVaribaleName = getVariableName( theMethod );
1555 theParams.isVariable = !aVaribaleName.isEmpty();
1556 if (theParams.isVariable)
1557 theParams.myValue = aVaribaleName;
1559 return theParams.isVariable;