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 // SALOME GUI includes
46 #include <SUIT_ResourceMgr.h>
49 #include <SALOMEconfig.h>
50 #include CORBA_SERVER_HEADER(SMESH_BasicHypothesis)
51 #include CORBA_SERVER_HEADER(SMESH_Mesh)
52 #include CORBA_SERVER_HEADER(SMESH_Group)
55 #include <QHBoxLayout>
60 const double VALUE_MAX = 1.0e+15, // COORD_MAX
61 VALUE_MAX_2 = VALUE_MAX * VALUE_MAX,
62 VALUE_MAX_3 = VALUE_MAX_2 * VALUE_MAX,
63 VALUE_SMALL = 1.0e-15,
64 VALUE_SMALL_2 = VALUE_SMALL * VALUE_SMALL,
65 VALUE_SMALL_3 = VALUE_SMALL_2 * VALUE_SMALL;
67 //================================================================================
70 * \param type - hypothesis type
72 //================================================================================
74 StdMeshersGUI_StdHypothesisCreator::StdMeshersGUI_StdHypothesisCreator( const QString& type )
75 : SMESHGUI_GenericHypothesisCreator( type )
79 //================================================================================
83 //================================================================================
85 StdMeshersGUI_StdHypothesisCreator::~StdMeshersGUI_StdHypothesisCreator()
89 //================================================================================
91 * \brief Return widget for i-th hypothesis parameter (got from myParamWidgets)
92 * \param i - index of hypothesis parameter
93 * \retval QWidget* - found widget
95 //================================================================================
97 QWidget* StdMeshersGUI_StdHypothesisCreator::getWidgetForParam( int i ) const
100 if ( isCreation() ) ++i; // skip widget of 'name' parameter
102 if ( i < myCustomWidgets.count() ) {
103 QList<QWidget*>::const_iterator anIt = myCustomWidgets.begin();
104 QList<QWidget*>::const_iterator aLast = myCustomWidgets.end();
105 for ( int j = 0 ; !w && anIt != aLast; ++anIt, ++j )
110 // list has no at() const, so we iterate
111 QList<QWidget*>::const_iterator anIt = widgets().begin();
112 QList<QWidget*>::const_iterator aLast = widgets().end();
113 for( int j = 0; !w && anIt!=aLast; anIt++, ++j ) {
121 //================================================================================
123 * \brief Allow modifing myCustomWidgets in const methods
124 * \retval ListOfWidgets* - non-const pointer to myCustomWidgets
126 //================================================================================
128 StdMeshersGUI_StdHypothesisCreator::ListOfWidgets*
129 StdMeshersGUI_StdHypothesisCreator::customWidgets() const
131 return const_cast< ListOfWidgets* >( & myCustomWidgets );
134 //================================================================================
136 * \brief Builds dlg layout
137 * \retval QFrame* - the built widget
139 //================================================================================
141 QFrame* StdMeshersGUI_StdHypothesisCreator::buildFrame()
143 return buildStdFrame();
146 //================================================================================
148 * \brief Initialise parameter values in controls
150 //================================================================================
152 void StdMeshersGUI_StdHypothesisCreator::retrieveParams() const
154 // buildStdFrame() sets values itself calling stdParams()
156 if ( hypType().startsWith("ProjectionSource" ))
158 // we use this method to connect depending custom widgets
159 StdMeshersGUI_ObjectReferenceParamWdg* widgetToActivate = 0;
160 ListOfWidgets::const_iterator anIt = myCustomWidgets.begin();
161 for ( ; anIt != myCustomWidgets.end(); anIt++)
163 if ( *anIt && (*anIt)->inherits("StdMeshersGUI_ObjectReferenceParamWdg"))
165 StdMeshersGUI_ObjectReferenceParamWdg * w1 =
166 ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
167 ListOfWidgets::const_iterator anIt2 = anIt;
168 for ( ++anIt2; anIt2 != myCustomWidgets.end(); anIt2++)
169 if ( *anIt2 && (*anIt2)->inherits("StdMeshersGUI_ObjectReferenceParamWdg"))
171 StdMeshersGUI_ObjectReferenceParamWdg * w2 =
172 ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt2 );
173 w1->AvoidSimultaneousSelection( w2 );
175 if ( !widgetToActivate )
176 widgetToActivate = w1;
179 if ( widgetToActivate )
180 widgetToActivate->activateSelection();
184 dlg()->setMinimumSize( dlg()->minimumSizeHint().width(), dlg()->minimumSizeHint().height() );
189 //================================================================================
191 * \brief Widget: slider with left and right labels
193 //================================================================================
195 class TDoubleSliderWith2Labels: public QWidget
198 TDoubleSliderWith2Labels( const QString& leftLabel, const QString& rightLabel,
199 const double initValue, const double bottom,
200 const double top , const double precision,
201 QWidget * parent=0 , const char * name=0 )
202 :QWidget(parent), _bottom(bottom), _precision(precision)
206 QHBoxLayout* aHBoxL = new QHBoxLayout(this);
208 if ( !leftLabel.isEmpty() ) {
209 QLabel* aLeftLabel = new QLabel( this );
210 aLeftLabel->setText( leftLabel );
211 aHBoxL->addWidget( aLeftLabel );
214 _slider = new QSlider( Qt::Horizontal, this );
215 _slider->setRange( 0, toInt( top ));
216 _slider->setValue( toInt( initValue ));
217 aHBoxL->addWidget( _slider );
219 if ( !rightLabel.isEmpty() ) {
220 QLabel* aRightLabel = new QLabel( this );
221 aRightLabel->setText( rightLabel );
222 aHBoxL->addWidget( aRightLabel );
227 double value() const { return _bottom + _slider->value() * _precision; }
228 QSlider * getSlider() const { return _slider; }
229 int toInt( double val ) const { return (int) ceil(( val - _bottom ) / _precision ); }
231 double _bottom, _precision;
235 //================================================================================
237 * \brief Retrieve GEOM_Object held by widget
239 //================================================================================
241 inline GEOM::GEOM_Object_var geomFromWdg(const QWidget* wdg)
243 const StdMeshersGUI_ObjectReferenceParamWdg * objRefWdg =
244 dynamic_cast<const StdMeshersGUI_ObjectReferenceParamWdg*>( wdg );
246 return objRefWdg->GetObject< GEOM::GEOM_Object >();
248 return GEOM::GEOM_Object::_nil();
250 //================================================================================
252 * \brief Retrieve SMESH_Mesh held by widget
254 //================================================================================
256 inline SMESH::SMESH_Mesh_var meshFromWdg(const QWidget* wdg)
258 const StdMeshersGUI_ObjectReferenceParamWdg * objRefWdg =
259 dynamic_cast<const StdMeshersGUI_ObjectReferenceParamWdg*>( wdg );
261 return objRefWdg->GetObject< SMESH::SMESH_Mesh >();
263 return SMESH::SMESH_Mesh::_nil();
265 //================================================================================
267 * \brief Retrieve SMESH_Mesh held by widget
269 //================================================================================
271 inline SMESH::ListOfGroups_var groupsFromWdg(const QWidget* wdg)
273 SMESH::ListOfGroups_var groups = new SMESH::ListOfGroups;
274 const StdMeshersGUI_ObjectReferenceParamWdg * objRefWdg =
275 dynamic_cast<const StdMeshersGUI_ObjectReferenceParamWdg*>( wdg );
278 groups->length( objRefWdg->NbObjects() );
279 for ( unsigned i = 0; i < groups->length(); ++i )
280 groups[i] = objRefWdg->GetObject< SMESH::SMESH_GroupBase >(i);
284 //================================================================================
286 * \brief creates a filter for selection of shapes of given dimension
287 * \param dim - dimension
288 * \param subShapeType - required type of sub-shapes, number of which must be \a nbSubShapes
289 * \param nbSubShapes - number of sub-shapes of given type
290 * \param closed - required closeness flag of a shape
291 * \retval SUIT_SelectionFilter* - created filter
293 //================================================================================
295 SUIT_SelectionFilter* filterForShapeOfDim(const int dim,
296 TopAbs_ShapeEnum subShapeType = TopAbs_SHAPE,
297 const int nbSubShapes = 0,
300 TColStd_MapOfInteger shapeTypes;
302 case 0: shapeTypes.Add( TopAbs_VERTEX ); break;
304 if ( subShapeType == TopAbs_SHAPE ) subShapeType = TopAbs_EDGE;
305 shapeTypes.Add( TopAbs_EDGE );
306 shapeTypes.Add( TopAbs_COMPOUND ); // for a group
309 if ( subShapeType == TopAbs_SHAPE ) subShapeType = TopAbs_FACE;
310 shapeTypes.Add( TopAbs_FACE );
311 shapeTypes.Add( TopAbs_COMPOUND ); // for a group
314 shapeTypes.Add( TopAbs_SHELL );
315 shapeTypes.Add( TopAbs_SOLID );
316 shapeTypes.Add( TopAbs_COMPSOLID );
317 shapeTypes.Add( TopAbs_COMPOUND );
320 return new SMESH_NumberFilter("GEOM", subShapeType, nbSubShapes,
321 shapeTypes, GEOM::GEOM_Object::_nil(), closed);
324 //================================================================================
326 * \brief Create a widget for object selection
327 * \param object - initial object
328 * \param filter - selection filter
329 * \retval QWidget* - created widget
331 //================================================================================
333 QWidget* newObjRefParamWdg( SUIT_SelectionFilter* filter,
334 CORBA::Object_var object)
336 StdMeshersGUI_ObjectReferenceParamWdg* w =
337 new StdMeshersGUI_ObjectReferenceParamWdg( filter, 0);
338 w->SetObject( object.in() );
341 QWidget* newObjRefParamWdg( SUIT_SelectionFilter* filter,
342 SMESH::string_array_var& objEntries)
344 StdMeshersGUI_ObjectReferenceParamWdg* w =
345 new StdMeshersGUI_ObjectReferenceParamWdg( filter, 0, /*multiSel=*/true);
346 //RNV: Firstly, activate selection, then set objects
347 w->activateSelection();
348 w->SetObjects( objEntries );
352 //================================================================================
354 * \brief calls deactivateSelection() for StdMeshersGUI_ObjectReferenceParamWdg
355 * \param widgetList - list of widgets
357 //================================================================================
359 void deactivateObjRefParamWdg( QList<QWidget*>* widgetList )
361 StdMeshersGUI_ObjectReferenceParamWdg* w = 0;
362 QList<QWidget*>::iterator anIt = widgetList->begin();
363 QList<QWidget*>::iterator aLast = widgetList->end();
364 for ( ; anIt != aLast; anIt++ ) {
365 if ( (*anIt) && (*anIt)->inherits( "StdMeshersGUI_ObjectReferenceParamWdg" ))
367 w = (StdMeshersGUI_ObjectReferenceParamWdg* )( *anIt );
368 w->deactivateSelection();
374 //================================================================================
376 * \brief Check parameter values before accept()
377 * \retval bool - true if OK
379 //================================================================================
381 bool StdMeshersGUI_StdHypothesisCreator::checkParams( QString& msg ) const
383 if( !SMESHGUI_GenericHypothesisCreator::checkParams( msg ) )
386 // check if object reference parameter is set, as it has no default value
388 if ( hypType().startsWith("ProjectionSource" ))
390 StdMeshersGUI_ObjectReferenceParamWdg* w =
391 widget< StdMeshersGUI_ObjectReferenceParamWdg >( 0 );
392 ok = ( w->IsObjectSelected() );
393 if ( !ok ) w->SetObject( CORBA::Object::_nil() );
394 int nbAssocVert = ( hypType() == "ProjectionSource1D" ? 1 : 2 );
395 int nbNonEmptyAssoc = 0;
396 for ( int i = 0; ok && i < nbAssocVert*2; i += 2)
399 StdMeshersGUI_ObjectReferenceParamWdg* w1 =
400 widget< StdMeshersGUI_ObjectReferenceParamWdg >( i+2 );
401 StdMeshersGUI_ObjectReferenceParamWdg* w2 =
402 widget< StdMeshersGUI_ObjectReferenceParamWdg >( i+3 );
403 srcV = w1->GetValue();
404 tgtV = w2->GetValue();
405 ok = (( srcV.isEmpty() && tgtV.isEmpty() ) ||
406 ( !srcV.isEmpty() && !tgtV.isEmpty() && srcV != tgtV ));
408 w1->SetObject( CORBA::Object::_nil() );
409 w2->SetObject( CORBA::Object::_nil() );
411 nbNonEmptyAssoc += !srcV.isEmpty();
413 if ( ok && nbNonEmptyAssoc == 1 && nbAssocVert == 2 )
415 // only one pair of VERTEXes is given for a FACE,
416 // then the FACE must have only one VERTEX
417 GEOM::GEOM_Object_var face = w->GetObject< GEOM::GEOM_Object >();
419 GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen();
420 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
421 GEOM::GEOM_IShapesOperations_var shapeOp;
422 if ( !geomGen->_is_nil() && aStudy )
423 shapeOp = geomGen->GetIShapesOperations( aStudy->StudyId() );
424 if ( !shapeOp->_is_nil() )
426 GEOM::ListOfLong_var vertices =
427 shapeOp->GetAllSubShapesIDs (face, GEOM::VERTEX, /*isSorted=*/false);
428 ok = ( vertices->length() == 1 );
431 // Uninstall filters of StdMeshersGUI_ObjectReferenceParamWdg
433 deactivateObjRefParamWdg( customWidgets() );
435 else if ( hypType().startsWith("ImportSource" ))
437 StdMeshersGUI_ObjectReferenceParamWdg* w =
438 widget< StdMeshersGUI_ObjectReferenceParamWdg >( 0 );
439 ok = ( w->IsObjectSelected() );
441 else if ( hypType() == "LayerDistribution" || hypType() == "LayerDistribution2D" )
443 StdMeshersGUI_LayerDistributionParamWdg* w =
444 widget< StdMeshersGUI_LayerDistributionParamWdg >( 0 );
445 ok = ( w && w->IsOk() );
451 //================================================================================
453 * \brief Store params from GUI controls to a hypothesis
454 * \retval QString - text representation of parameters
456 //================================================================================
458 QString StdMeshersGUI_StdHypothesisCreator::storeParams() const
460 ListOfStdParams params;
461 bool res = getStdParamFromDlg( params );
464 SMESH::SetName( SMESH::FindSObject( hypothesis() ), params[0].myValue.toString().toLatin1().data() );
465 params.erase( params.begin() );
468 QString valueStr = stdParamValues( params );
469 //QStringList aVariablesList = getVariablesFromDlg();
471 if( res && !params.isEmpty() )
473 if( hypType()=="LocalLength" )
475 StdMeshers::StdMeshers_LocalLength_var h =
476 StdMeshers::StdMeshers_LocalLength::_narrow( hypothesis() );
478 h->SetVarParameter( params[0].text(), "SetLength" );
479 h->SetLength( params[0].myValue.toDouble() );
480 h->SetVarParameter( params[1].text(), "SetPrecision" );
481 h->SetPrecision( params[1].myValue.toDouble() );
483 else if( hypType()=="MaxLength" )
485 StdMeshers::StdMeshers_MaxLength_var h =
486 StdMeshers::StdMeshers_MaxLength::_narrow( hypothesis() );
488 h->SetVarParameter( params[0].text(), "SetLength" );
489 h->SetLength( params[0].myValue.toDouble() );
490 h->SetUsePreestimatedLength( widget< QCheckBox >( 1 )->isChecked() );
491 if ( !h->HavePreestimatedLength() && !h->_is_equivalent( initParamsHypothesis() )) {
492 StdMeshers::StdMeshers_MaxLength_var hInit =
493 StdMeshers::StdMeshers_MaxLength::_narrow( initParamsHypothesis() );
494 h->SetPreestimatedLength( hInit->GetPreestimatedLength() );
497 else if( hypType()=="SegmentLengthAroundVertex" )
499 StdMeshers::StdMeshers_SegmentLengthAroundVertex_var h =
500 StdMeshers::StdMeshers_SegmentLengthAroundVertex::_narrow( hypothesis() );
502 h->SetVarParameter( params[0].text(), "SetLength" );
503 h->SetLength( params[0].myValue.toDouble() );
505 else if( hypType()=="Arithmetic1D" )
507 StdMeshers::StdMeshers_Arithmetic1D_var h =
508 StdMeshers::StdMeshers_Arithmetic1D::_narrow( hypothesis() );
510 StdMeshersGUI_SubShapeSelectorWdg* w =
511 widget< StdMeshersGUI_SubShapeSelectorWdg >( 2 );
513 h->SetVarParameter( params[0].text(), "SetStartLength" );
514 h->SetStartLength( params[0].myValue.toDouble() );
515 h->SetVarParameter( params[1].text(), "SetEndLength" );
516 h->SetEndLength( params[1].myValue.toDouble() );
518 h->SetReversedEdges( w->GetListOfIDs() );
519 h->SetObjectEntry( w->GetMainShapeEntry() );
522 else if( hypType()=="FixedPoints1D" )
524 StdMeshers::StdMeshers_FixedPoints1D_var h =
525 StdMeshers::StdMeshers_FixedPoints1D::_narrow( hypothesis() );
527 StdMeshersGUI_FixedPointsParamWdg* w1 =
528 widget< StdMeshersGUI_FixedPointsParamWdg >( 0 );
530 StdMeshersGUI_SubShapeSelectorWdg* w2 =
531 widget< StdMeshersGUI_SubShapeSelectorWdg >( 1 );
534 h->SetPoints( w1->GetListOfPoints() );
535 h->SetNbSegments( w1->GetListOfSegments() );
538 h->SetReversedEdges( w2->GetListOfIDs() );
539 h->SetObjectEntry( w2->GetMainShapeEntry() );
542 else if( hypType()=="MaxElementArea" )
544 StdMeshers::StdMeshers_MaxElementArea_var h =
545 StdMeshers::StdMeshers_MaxElementArea::_narrow( hypothesis() );
546 h->SetVarParameter( params[0].text(), "SetMaxElementArea" );
547 h->SetMaxElementArea( params[0].myValue.toDouble() );
549 else if( hypType()=="MaxElementVolume" )
551 StdMeshers::StdMeshers_MaxElementVolume_var h =
552 StdMeshers::StdMeshers_MaxElementVolume::_narrow( hypothesis() );
554 h->SetVarParameter( params[0].text(), "SetMaxElementVolume" );
555 h->SetMaxElementVolume( params[0].myValue.toDouble() );
557 else if( hypType()=="StartEndLength" )
559 StdMeshers::StdMeshers_StartEndLength_var h =
560 StdMeshers::StdMeshers_StartEndLength::_narrow( hypothesis() );
562 StdMeshersGUI_SubShapeSelectorWdg* w =
563 widget< StdMeshersGUI_SubShapeSelectorWdg >( 2 );
565 h->SetVarParameter( params[0].text(), "SetStartLength" );
566 h->SetStartLength( params[0].myValue.toDouble() );
567 h->SetVarParameter( params[1].text(), "SetEndLength" );
568 h->SetEndLength( params[1].myValue.toDouble() );
570 h->SetReversedEdges( w->GetListOfIDs() );
571 h->SetObjectEntry( w->GetMainShapeEntry() );
574 else if( hypType()=="Deflection1D" )
576 StdMeshers::StdMeshers_Deflection1D_var h =
577 StdMeshers::StdMeshers_Deflection1D::_narrow( hypothesis() );
578 h->SetVarParameter( params[0].text(), "SetDeflection" );
579 h->SetDeflection( params[0].myValue.toDouble() );
581 else if( hypType()=="AutomaticLength" )
583 StdMeshers::StdMeshers_AutomaticLength_var h =
584 StdMeshers::StdMeshers_AutomaticLength::_narrow( hypothesis() );
586 h->SetVarParameter( params[0].text(), "SetFineness" );
587 h->SetFineness( params[0].myValue.toDouble() );
589 else if( hypType()=="NumberOfLayers" )
591 StdMeshers::StdMeshers_NumberOfLayers_var h =
592 StdMeshers::StdMeshers_NumberOfLayers::_narrow( hypothesis() );
594 h->SetVarParameter( params[0].text(), "SetNumberOfLayers" );
595 h->SetNumberOfLayers( params[0].myValue.toInt() );
597 else if( hypType()=="LayerDistribution" )
599 StdMeshers::StdMeshers_LayerDistribution_var h =
600 StdMeshers::StdMeshers_LayerDistribution::_narrow( hypothesis() );
601 StdMeshersGUI_LayerDistributionParamWdg* w =
602 widget< StdMeshersGUI_LayerDistributionParamWdg >( 0 );
604 h->SetLayerDistribution( w->GetHypothesis() );
606 else if( hypType()=="NumberOfLayers2D" )
608 StdMeshers::StdMeshers_NumberOfLayers2D_var h =
609 StdMeshers::StdMeshers_NumberOfLayers2D::_narrow( hypothesis() );
611 h->SetVarParameter( params[0].text(), "SetNumberOfLayers" );
612 h->SetNumberOfLayers( params[0].myValue.toInt() );
614 else if( hypType()=="LayerDistribution2D" )
616 StdMeshers::StdMeshers_LayerDistribution2D_var h =
617 StdMeshers::StdMeshers_LayerDistribution2D::_narrow( hypothesis() );
618 StdMeshersGUI_LayerDistributionParamWdg* w =
619 widget< StdMeshersGUI_LayerDistributionParamWdg >( 0 );
621 h->SetLayerDistribution( w->GetHypothesis() );
623 else if( hypType()=="ProjectionSource1D" )
625 StdMeshers::StdMeshers_ProjectionSource1D_var h =
626 StdMeshers::StdMeshers_ProjectionSource1D::_narrow( hypothesis() );
628 h->SetSourceEdge ( geomFromWdg ( getWidgetForParam( 0 )));
629 h->SetSourceMesh ( meshFromWdg ( getWidgetForParam( 1 )));
630 h->SetVertexAssociation( geomFromWdg ( getWidgetForParam( 2 )),
631 geomFromWdg ( getWidgetForParam( 3 )));
633 else if( hypType()=="ProjectionSource2D" )
635 StdMeshers::StdMeshers_ProjectionSource2D_var h =
636 StdMeshers::StdMeshers_ProjectionSource2D::_narrow( hypothesis() );
638 h->SetSourceFace ( geomFromWdg ( getWidgetForParam( 0 )));
639 h->SetSourceMesh ( meshFromWdg ( getWidgetForParam( 1 )));
640 h->SetVertexAssociation( geomFromWdg ( getWidgetForParam( 2 )), // src1
641 geomFromWdg ( getWidgetForParam( 4 )), // src2
642 geomFromWdg ( getWidgetForParam( 3 )), // tgt1
643 geomFromWdg ( getWidgetForParam( 5 ))); // tgt2
645 else if( hypType()=="ProjectionSource3D" )
647 StdMeshers::StdMeshers_ProjectionSource3D_var h =
648 StdMeshers::StdMeshers_ProjectionSource3D::_narrow( hypothesis() );
650 h->SetSource3DShape ( geomFromWdg ( getWidgetForParam( 0 )));
651 h->SetSourceMesh ( meshFromWdg ( getWidgetForParam( 1 )));
652 h->SetVertexAssociation( geomFromWdg ( getWidgetForParam( 2 )), // src1
653 geomFromWdg ( getWidgetForParam( 4 )), // src2
654 geomFromWdg ( getWidgetForParam( 3 )), // tgt1
655 geomFromWdg ( getWidgetForParam( 5 ))); // tgt2
657 else if( hypType()=="ImportSource1D" )
659 StdMeshers::StdMeshers_ImportSource1D_var h =
660 StdMeshers::StdMeshers_ImportSource1D::_narrow( hypothesis() );
662 SMESH::ListOfGroups_var groups = groupsFromWdg( getWidgetForParam( 0 ));
663 h->SetSourceEdges( groups.in() );
664 QCheckBox* toCopyMesh = widget< QCheckBox >( 1 );
665 QCheckBox* toCopyGroups = widget< QCheckBox >( 2 );
666 h->SetCopySourceMesh( toCopyMesh->isChecked(), toCopyGroups->isChecked());
668 else if( hypType()=="ImportSource2D" )
670 StdMeshers::StdMeshers_ImportSource2D_var h =
671 StdMeshers::StdMeshers_ImportSource2D::_narrow( hypothesis() );
673 SMESH::ListOfGroups_var groups = groupsFromWdg( getWidgetForParam( 0 ));
674 h->SetSourceFaces( groups.in() );
675 QCheckBox* toCopyMesh = widget< QCheckBox >( 1 );
676 QCheckBox* toCopyGroups = widget< QCheckBox >( 2 );
677 h->SetCopySourceMesh( toCopyMesh->isChecked(), toCopyGroups->isChecked());
679 else if( hypType()=="ViscousLayers" )
681 StdMeshers::StdMeshers_ViscousLayers_var h =
682 StdMeshers::StdMeshers_ViscousLayers::_narrow( hypothesis() );
684 h->SetVarParameter( params[0].text(), "SetTotalThickness" );
685 h->SetTotalThickness( params[0].myValue.toDouble() );
686 h->SetVarParameter( params[1].text(), "SetNumberLayers" );
687 h->SetNumberLayers ( params[1].myValue.toInt() );
688 h->SetVarParameter( params[2].text(), "SetStretchFactor" );
689 h->SetStretchFactor ( params[2].myValue.toDouble() );
691 if ( StdMeshersGUI_SubShapeSelectorWdg* idsWg =
692 widget< StdMeshersGUI_SubShapeSelectorWdg >( 3 ))
694 h->SetIgnoreFaces( idsWg->GetListOfIDs() );
697 else if( hypType()=="QuadrangleParams" )
699 StdMeshers::StdMeshers_QuadrangleParams_var h =
700 StdMeshers::StdMeshers_QuadrangleParams::_narrow( hypothesis() );
701 StdMeshersGUI_SubShapeSelectorWdg* w1 =
702 widget< StdMeshersGUI_SubShapeSelectorWdg >( 0 );
703 StdMeshersGUI_QuadrangleParamWdg* w2 =
704 widget< StdMeshersGUI_QuadrangleParamWdg >( 1 );
706 if (w1->GetListSize() > 0) {
707 h->SetTriaVertex(w1->GetListOfIDs()[0]); // getlist must be called once
708 const char * entry = w1->GetMainShapeEntry();
709 h->SetObjectEntry(entry);
711 h->SetQuadType(StdMeshers::QuadType(w2->GetType()));
718 //================================================================================
720 * \brief Return parameter values as SMESHGUI_GenericHypothesisCreator::StdParam
721 * \param p - list of parameters
722 * \retval bool - success flag
724 * Is called from SMESHGUI_GenericHypothesisCreator::buildStdFrame().
725 * Parameters will be shown using "standard" controls:
726 * Int by QtxIntSpinBox
727 * Double by SMESHGUI_SpinBox
728 * String by QLineEdit
729 * getCustomWidget() allows to redefine control for a parameter
731 //================================================================================
733 bool StdMeshersGUI_StdHypothesisCreator::stdParams( ListOfStdParams& p ) const
736 SMESHGUI_GenericHypothesisCreator::StdParam item;
739 customWidgets()->clear();
742 HypothesisData* data = SMESH::GetHypothesisData( hypType() );
743 item.myName = tr( "SMESH_NAME" );
744 item.myValue = data ? hypName() : QString();
746 customWidgets()->append(0);
749 SMESH::SMESH_Hypothesis_var hyp = initParamsHypothesis();
750 //SMESH::ListOfParameters_var aParameters = hyp->GetLastParameters();
752 if( hypType()=="LocalLength" )
754 StdMeshers::StdMeshers_LocalLength_var h =
755 StdMeshers::StdMeshers_LocalLength::_narrow( hyp );
757 item.myName = tr("SMESH_LOCAL_LENGTH_PARAM");
758 if(!initVariableName( hyp, item, "SetLength"))
759 item.myValue = h->GetLength();
762 item.myName = tr("SMESH_LOCAL_LENGTH_PRECISION");
763 if(!initVariableName( hyp, item, "SetPrecision"))
764 item.myValue = h->GetPrecision();
767 else if( hypType()=="MaxLength" )
769 StdMeshers::StdMeshers_MaxLength_var h =
770 StdMeshers::StdMeshers_MaxLength::_narrow( hyp );
771 // try to set a right preestimated length to edited hypothesis
772 bool noPreestimatedAtEdition = false;
773 if ( !isCreation() ) {
774 StdMeshers::StdMeshers_MaxLength_var initHyp =
775 StdMeshers::StdMeshers_MaxLength::_narrow( initParamsHypothesis(true) );
776 noPreestimatedAtEdition =
777 ( initHyp->_is_nil() || !initHyp->HavePreestimatedLength() );
778 if ( !noPreestimatedAtEdition )
779 h->SetPreestimatedLength( initHyp->GetPreestimatedLength() );
782 item.myName = tr("SMESH_LOCAL_LENGTH_PARAM");
783 if(!initVariableName( hyp, item, "SetLength"))
784 item.myValue = h->GetLength();
786 customWidgets()->append(0);
788 item.myName = tr("SMESH_USE_PREESTIMATED_LENGTH");
790 QCheckBox* aQCheckBox = new QCheckBox(dlg());
791 if ( !noPreestimatedAtEdition && h->HavePreestimatedLength() ) {
792 aQCheckBox->setChecked( h->GetUsePreestimatedLength() );
793 connect( aQCheckBox, SIGNAL( stateChanged(int) ), this, SLOT( onValueChanged() ) );
796 aQCheckBox->setChecked( false );
797 aQCheckBox->setEnabled( false );
799 customWidgets()->append( aQCheckBox );
801 else if( hypType()=="SegmentLengthAroundVertex" )
803 StdMeshers::StdMeshers_SegmentLengthAroundVertex_var h =
804 StdMeshers::StdMeshers_SegmentLengthAroundVertex::_narrow( hyp );
806 item.myName = tr("SMESH_LOCAL_LENGTH_PARAM");
807 if(!initVariableName( hyp, item, "SetLength"))
808 item.myValue = h->GetLength();
812 else if( hypType()=="Arithmetic1D" )
814 StdMeshers::StdMeshers_Arithmetic1D_var h =
815 StdMeshers::StdMeshers_Arithmetic1D::_narrow( hyp );
817 item.myName = tr( "SMESH_START_LENGTH_PARAM" );
818 if(!initVariableName( hyp, item, "SetStartLength" ))
819 item.myValue = h->GetLength( true );
822 customWidgets()->append (0);
824 item.myName = tr( "SMESH_END_LENGTH_PARAM" );
825 if(!initVariableName( hyp, item, "SetEndLength" ))
826 item.myValue = h->GetLength( false );
829 customWidgets()->append (0);
831 item.myName = tr( "SMESH_REVERSED_EDGES" );
834 StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget =
835 new StdMeshersGUI_SubShapeSelectorWdg();
836 QString aGeomEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
837 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
838 if ( aGeomEntry == "" )
839 aGeomEntry = h->GetObjectEntry();
841 aDirectionWidget->SetGeomShapeEntry( aGeomEntry );
842 aDirectionWidget->SetMainShapeEntry( aMainEntry );
843 aDirectionWidget->SetListOfIDs( h->GetReversedEdges() );
844 aDirectionWidget->showPreview( true );
845 customWidgets()->append ( aDirectionWidget );
849 else if( hypType()=="FixedPoints1D" )
851 StdMeshers::StdMeshers_FixedPoints1D_var h =
852 StdMeshers::StdMeshers_FixedPoints1D::_narrow( hyp );
854 item.myName = tr( "SMESH_FIXED_POINTS" );
857 StdMeshersGUI_FixedPointsParamWdg* aFixedPointsWidget =
858 new StdMeshersGUI_FixedPointsParamWdg();
860 if ( !isCreation() ) {
861 aFixedPointsWidget->SetListOfPoints( h->GetPoints() );
862 aFixedPointsWidget->SetListOfSegments( h->GetNbSegments() );
864 customWidgets()->append( aFixedPointsWidget );
866 item.myName = tr( "SMESH_REVERSED_EDGES" );
869 StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget =
870 new StdMeshersGUI_SubShapeSelectorWdg();
871 QString anEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
872 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
874 anEntry = h->GetObjectEntry();
875 aDirectionWidget->SetGeomShapeEntry( anEntry );
876 aDirectionWidget->SetMainShapeEntry( aMainEntry );
877 aDirectionWidget->SetListOfIDs( h->GetReversedEdges() );
878 aDirectionWidget->showPreview( true );
879 customWidgets()->append ( aDirectionWidget );
883 else if( hypType()=="MaxElementArea" )
885 StdMeshers::StdMeshers_MaxElementArea_var h =
886 StdMeshers::StdMeshers_MaxElementArea::_narrow( hyp );
888 item.myName = tr( "SMESH_MAX_ELEMENT_AREA_PARAM" );
889 if(!initVariableName( hyp, item, "SetMaxElementArea" ))
890 item.myValue = h->GetMaxElementArea();
894 else if( hypType()=="MaxElementVolume" )
896 StdMeshers::StdMeshers_MaxElementVolume_var h =
897 StdMeshers::StdMeshers_MaxElementVolume::_narrow( hyp );
899 item.myName = tr( "SMESH_MAX_ELEMENT_VOLUME_PARAM" );
900 if(!initVariableName( hyp, item, "SetMaxElementVolume" ))
901 item.myValue = h->GetMaxElementVolume();
904 else if( hypType()=="StartEndLength" )
906 StdMeshers::StdMeshers_StartEndLength_var h =
907 StdMeshers::StdMeshers_StartEndLength::_narrow( hyp );
909 item.myName = tr( "SMESH_START_LENGTH_PARAM" );
911 if(!initVariableName( hyp, item, "SetStartLength" ))
912 item.myValue = h->GetLength( true );
914 customWidgets()->append(0);
916 item.myName = tr( "SMESH_END_LENGTH_PARAM" );
917 if(!initVariableName( hyp, item, "SetEndLength" ))
918 item.myValue = h->GetLength( false );
920 customWidgets()->append(0);
922 item.myName = tr( "SMESH_REVERSED_EDGES" );
925 StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget =
926 new StdMeshersGUI_SubShapeSelectorWdg();
927 QString anEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
928 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
930 anEntry = h->GetObjectEntry();
931 aDirectionWidget->SetGeomShapeEntry( anEntry );
932 aDirectionWidget->SetMainShapeEntry( aMainEntry );
933 aDirectionWidget->SetListOfIDs( h->GetReversedEdges() );
934 aDirectionWidget->showPreview( true );
935 customWidgets()->append ( aDirectionWidget );
937 else if( hypType()=="Deflection1D" )
939 StdMeshers::StdMeshers_Deflection1D_var h =
940 StdMeshers::StdMeshers_Deflection1D::_narrow( hyp );
942 item.myName = tr( "SMESH_DEFLECTION1D_PARAM" );
943 if(!initVariableName( hyp, item, "SetDeflection" ))
944 item.myValue = h->GetDeflection();
947 else if( hypType()=="AutomaticLength" )
949 StdMeshers::StdMeshers_AutomaticLength_var h =
950 StdMeshers::StdMeshers_AutomaticLength::_narrow( hyp );
952 item.myName = tr( "SMESH_FINENESS_PARAM" );
953 //item.myValue = h->GetFineness();
955 SMESHGUI_SpinBox* _autoLengthSpinBox = new SMESHGUI_SpinBox(dlg());
956 _autoLengthSpinBox->RangeStepAndValidator(0, 1, 0.01, "length_precision");
957 _autoLengthSpinBox->SetValue(h->GetFineness());
958 customWidgets()->append( _autoLengthSpinBox);
960 else if( hypType()=="NumberOfLayers" )
962 StdMeshers::StdMeshers_NumberOfLayers_var h =
963 StdMeshers::StdMeshers_NumberOfLayers::_narrow( hyp );
965 item.myName = tr( "SMESH_NUMBER_OF_LAYERS" );
966 if(!initVariableName( hyp, item, "SetNumberOfLayers" ))
967 item.myValue = (int) h->GetNumberOfLayers();
970 else if( hypType()=="LayerDistribution" )
972 StdMeshers::StdMeshers_LayerDistribution_var h =
973 StdMeshers::StdMeshers_LayerDistribution::_narrow( hyp );
975 item.myName = tr( "SMESH_LAYERS_DISTRIBUTION" ); p.append( item );
976 initVariableName( hyp, item, "SetLayerDistribution" );
977 customWidgets()->append
978 ( new StdMeshersGUI_LayerDistributionParamWdg( h->GetLayerDistribution(), hypName(), dlg()));
980 else if( hypType()=="NumberOfLayers2D" )
982 StdMeshers::StdMeshers_NumberOfLayers2D_var h =
983 StdMeshers::StdMeshers_NumberOfLayers2D::_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()=="LayerDistribution2D" )
992 StdMeshers::StdMeshers_LayerDistribution2D_var h =
993 StdMeshers::StdMeshers_LayerDistribution2D::_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()=="ProjectionSource1D" )
1002 StdMeshers::StdMeshers_ProjectionSource1D_var h =
1003 StdMeshers::StdMeshers_ProjectionSource1D::_narrow( hyp );
1005 item.myName = tr( "SMESH_SOURCE_EDGE" ); p.append( item );
1006 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 1 ),
1007 h->GetSourceEdge()));
1008 item.myName = tr( "SMESH_SOURCE_MESH" ); p.append( item );
1009 customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( MESH ),
1010 h->GetSourceMesh()));
1011 item.myName = tr( "SMESH_SOURCE_VERTEX" ); p.append( item );
1012 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1013 h->GetSourceVertex()));
1014 item.myName = tr( "SMESH_TARGET_VERTEX" ); p.append( item );
1015 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1016 h->GetTargetVertex()));
1018 else if( hypType()=="ProjectionSource2D" )
1020 StdMeshers::StdMeshers_ProjectionSource2D_var h =
1021 StdMeshers::StdMeshers_ProjectionSource2D::_narrow( hyp );
1023 item.myName = tr( "SMESH_SOURCE_FACE" ); p.append( item );
1024 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 2 ),
1025 h->GetSourceFace()));
1026 item.myName = tr( "SMESH_SOURCE_MESH" ); p.append( item );
1027 customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( MESH ),
1028 h->GetSourceMesh()));
1029 item.myName = tr( "SMESH_SOURCE_VERTEX1" ); p.append( item );
1030 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1031 h->GetSourceVertex( 1 )));
1032 item.myName = tr( "SMESH_TARGET_VERTEX1" ); p.append( item );
1033 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1034 h->GetTargetVertex( 1 )));
1035 item.myName = tr( "SMESH_SOURCE_VERTEX2" ); p.append( item );
1036 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1037 h->GetSourceVertex( 2 )));
1038 item.myName = tr( "SMESH_TARGET_VERTEX2" ); p.append( item );
1039 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1040 h->GetTargetVertex( 2 )));
1042 else if( hypType()=="ProjectionSource3D" )
1044 StdMeshers::StdMeshers_ProjectionSource3D_var h =
1045 StdMeshers::StdMeshers_ProjectionSource3D::_narrow( hyp );
1047 item.myName = tr( "SMESH_SOURCE_3DSHAPE" ); p.append( item );
1048 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 3, TopAbs_FACE, 6, true ),
1049 h->GetSource3DShape()));
1050 item.myName = tr( "SMESH_SOURCE_MESH" ); p.append( item );
1051 customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( MESH ),
1052 h->GetSourceMesh()));
1053 item.myName = tr( "SMESH_SOURCE_VERTEX1" ); p.append( item );
1054 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1055 h->GetSourceVertex( 1 )));
1056 item.myName = tr( "SMESH_TARGET_VERTEX1" ); p.append( item );
1057 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1058 h->GetTargetVertex( 1 )));
1059 item.myName = tr( "SMESH_SOURCE_VERTEX2" ); p.append( item );
1060 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1061 h->GetSourceVertex( 2 )));
1062 item.myName = tr( "SMESH_TARGET_VERTEX2" ); p.append( item );
1063 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1064 h->GetTargetVertex( 2 )));
1066 else if( hypType()=="ImportSource1D" )
1068 StdMeshers::StdMeshers_ImportSource1D_var h =
1069 StdMeshers::StdMeshers_ImportSource1D::_narrow( hyp );
1071 SMESH::string_array_var groupEntries = h->GetSourceEdges();
1072 CORBA::Boolean toCopyMesh, toCopyGroups;
1073 h->GetCopySourceMesh(toCopyMesh, toCopyGroups);
1075 item.myName = tr( "SMESH_SOURCE_EDGES" ); p.append( item );
1076 customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( GROUP_EDGE ),
1079 item.myName = tr( "SMESH_COPY_MESH" ); p.append( item );
1080 QCheckBox* aQCheckBox = new QCheckBox(dlg());
1081 aQCheckBox->setChecked( toCopyMesh );
1082 connect( aQCheckBox, SIGNAL( stateChanged(int) ), this, SLOT( onValueChanged() ));
1083 customWidgets()->append( aQCheckBox );
1085 item.myName = tr( "SMESH_TO_COPY_GROUPS" ); p.append( item );
1086 aQCheckBox = new QCheckBox(dlg());
1087 aQCheckBox->setChecked( toCopyGroups );
1088 aQCheckBox->setEnabled( toCopyMesh );
1089 customWidgets()->append( aQCheckBox );
1091 else if( hypType()=="ImportSource2D" )
1093 StdMeshers::StdMeshers_ImportSource2D_var h =
1094 StdMeshers::StdMeshers_ImportSource2D::_narrow( hyp );
1096 SMESH::string_array_var groupEntries = h->GetSourceFaces();
1097 CORBA::Boolean toCopyMesh, toCopyGroups;
1098 h->GetCopySourceMesh(toCopyMesh, toCopyGroups);
1100 item.myName = tr( "SMESH_SOURCE_FACES" ); p.append( item );
1101 customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( GROUP_FACE ),
1104 item.myName = tr( "SMESH_COPY_MESH" ); p.append( item );
1105 QCheckBox* aQCheckBox = new QCheckBox(dlg());
1106 aQCheckBox->setChecked( toCopyMesh );
1107 connect( aQCheckBox, SIGNAL( stateChanged(int) ), this, SLOT( onValueChanged() ));
1108 customWidgets()->append( aQCheckBox );
1110 item.myName = tr( "SMESH_COPY_GROUPS" ); p.append( item );
1111 aQCheckBox = new QCheckBox(dlg());
1112 aQCheckBox->setChecked( toCopyGroups );
1113 aQCheckBox->setEnabled( toCopyMesh );
1114 customWidgets()->append( aQCheckBox );
1116 else if( hypType()=="ViscousLayers" )
1118 StdMeshers::StdMeshers_ViscousLayers_var h =
1119 StdMeshers::StdMeshers_ViscousLayers::_narrow( hyp );
1121 item.myName = tr( "SMESH_TOTAL_THICKNESS" );
1122 if(!initVariableName( hyp, item, "SetTotalThickness" ))
1123 item.myValue = h->GetTotalThickness();
1125 customWidgets()->append (0);
1127 item.myName = tr( "SMESH_NUMBER_OF_LAYERS" );
1128 if(!initVariableName( hyp, item, "SetNumberLayers" ))
1129 item.myValue = h->GetNumberLayers();
1131 customWidgets()->append (0);
1133 item.myName = tr( "SMESH_STRETCH_FACTOR" );
1134 if(!initVariableName( hyp, item, "SetStretchFactor" ))
1135 item.myValue = h->GetStretchFactor();
1137 customWidgets()->append (0);
1139 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
1140 if ( !aMainEntry.isEmpty() )
1142 item.myName = tr( "SMESH_FACES_WO_LAYERS" );
1145 StdMeshersGUI_SubShapeSelectorWdg* idsWg =
1146 new StdMeshersGUI_SubShapeSelectorWdg(0,TopAbs_FACE);
1148 idsWg->SetGeomShapeEntry( aMainEntry );
1149 idsWg->SetMainShapeEntry( aMainEntry );
1150 idsWg->SetListOfIDs( h->GetIgnoreFaces() );
1151 idsWg->showPreview( true );
1152 customWidgets()->append ( idsWg );
1155 else if (hypType() == "QuadrangleParams")
1157 StdMeshers::StdMeshers_QuadrangleParams_var h =
1158 StdMeshers::StdMeshers_QuadrangleParams::_narrow(hyp);
1160 item.myName = tr("SMESH_BASE_VERTEX");
1163 StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget =
1164 new StdMeshersGUI_SubShapeSelectorWdg(0, TopAbs_VERTEX);
1165 aDirectionWidget->SetMaxSize(1);
1166 QString anEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
1167 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
1169 anEntry = h->GetObjectEntry();
1170 aDirectionWidget->SetGeomShapeEntry(anEntry);
1171 aDirectionWidget->SetMainShapeEntry(aMainEntry);
1172 if (!isCreation()) {
1173 SMESH::long_array_var aVec = new SMESH::long_array;
1174 int vertID = h->GetTriaVertex();
1178 aDirectionWidget->SetListOfIDs(aVec);
1181 aDirectionWidget->showPreview(true);
1183 item.myName = tr("SMESH_QUAD_TYPE");
1186 StdMeshersGUI_QuadrangleParamWdg* aTypeWidget =
1187 new StdMeshersGUI_QuadrangleParamWdg();
1188 if (!isCreation()) {
1189 aTypeWidget->SetType(int(h->GetQuadType()));
1192 customWidgets()->append(aDirectionWidget);
1193 customWidgets()->append(aTypeWidget);
1200 //================================================================================
1202 * \brief tune "standard" control
1203 * \param w - control widget
1204 * \param int - parameter index
1206 //================================================================================
1208 void StdMeshersGUI_StdHypothesisCreator::attuneStdWidget (QWidget* w, const int) const
1210 SMESHGUI_SpinBox* sb = w->inherits( "SMESHGUI_SpinBox" ) ? ( SMESHGUI_SpinBox* )w : 0;
1213 if( hypType()=="LocalLength" )
1215 if (sb->objectName() == tr("SMESH_LOCAL_LENGTH_PARAM"))
1216 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1217 else if (sb->objectName() == tr("SMESH_LOCAL_LENGTH_PRECISION"))
1218 sb->RangeStepAndValidator( 0.0, 1.0, 0.05, "len_tol_precision" );
1220 else if( hypType()=="Arithmetic1D" )
1222 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "parametric_precision" );
1224 else if( hypType()=="MaxLength" )
1226 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1227 sb->setEnabled( !widget< QCheckBox >( 1 )->isChecked() );
1229 else if( hypType()=="MaxElementArea" )
1231 sb->RangeStepAndValidator( VALUE_SMALL_2, VALUE_MAX_2, 1.0, "area_precision" );
1233 else if( hypType()=="MaxElementVolume" )
1235 sb->RangeStepAndValidator( VALUE_SMALL_3, VALUE_MAX_3, 1.0, "vol_precision" );
1237 else if( hypType()=="StartEndLength" )
1239 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1241 else if( hypType()=="Deflection1D" )
1243 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "parametric_precision" );
1245 else if( hypType()=="ViscousLayers" )
1247 if (sb->objectName() == tr("SMESH_STRETCH_FACTOR"))
1248 sb->RangeStepAndValidator( 1.0, VALUE_MAX, 0.1, "parametric_precision" );
1250 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1252 else // default validator for possible ancestors
1254 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1257 // else if ( QtxIntSpinBox* ib = w->inherits( "QtxIntSpinBox" ) ? ( QtxIntSpinBox* )w : 0)
1259 // if( hypType()=="ViscousLayers" )
1265 //================================================================================
1267 * \brief Return dlg title
1268 * \retval QString - title string
1270 //================================================================================
1272 QString StdMeshersGUI_StdHypothesisCreator::caption() const
1274 return tr( QString( "SMESH_%1_TITLE" ).arg( hypTypeName( hypType() ) ).toLatin1().data() );
1277 //================================================================================
1279 * \brief return pixmap for dlg icon
1282 //================================================================================
1284 QPixmap StdMeshersGUI_StdHypothesisCreator::icon() const
1286 QString hypIconName = tr( QString( "ICON_DLG_%1" ).arg( hypTypeName( hypType() ) ).toLatin1().data() );
1287 return SMESHGUI::resourceMgr()->loadPixmap( "SMESH", hypIconName );
1290 //================================================================================
1292 * \brief Return hypothesis type name to show in dlg
1295 //================================================================================
1297 QString StdMeshersGUI_StdHypothesisCreator::type() const
1299 return tr( QString( "SMESH_%1_HYPOTHESIS" ).arg( hypTypeName( hypType() ) ).toLatin1().data() );
1302 //================================================================================
1304 * \brief String to insert in "SMESH_%1_HYPOTHESIS" to get hypothesis type name
1305 * from message resouce file
1306 * \param t - hypothesis type
1307 * \retval QString - result string
1309 //================================================================================
1311 QString StdMeshersGUI_StdHypothesisCreator::hypTypeName( const QString& t ) const
1313 static QMap<QString,QString> types;
1314 if( types.isEmpty() )
1316 types.insert( "LocalLength", "LOCAL_LENGTH" );
1317 types.insert( "NumberOfSegments", "NB_SEGMENTS" );
1318 types.insert( "MaxElementArea", "MAX_ELEMENT_AREA" );
1319 types.insert( "MaxElementVolume", "MAX_ELEMENT_VOLUME" );
1320 types.insert( "StartEndLength", "START_END_LENGTH" );
1321 types.insert( "Deflection1D", "DEFLECTION1D" );
1322 types.insert( "Arithmetic1D", "ARITHMETIC_1D" );
1323 types.insert( "FixedPoints1D", "FIXED_POINTS_1D" );
1324 types.insert( "AutomaticLength", "AUTOMATIC_LENGTH" );
1325 types.insert( "ProjectionSource1D", "PROJECTION_SOURCE_1D" );
1326 types.insert( "ProjectionSource2D", "PROJECTION_SOURCE_2D" );
1327 types.insert( "ProjectionSource3D", "PROJECTION_SOURCE_3D" );
1328 types.insert( "ImportSource1D", "IMPORT_SOURCE_1D" );
1329 types.insert( "ImportSource2D", "IMPORT_SOURCE_2D" );
1330 types.insert( "NumberOfLayers", "NUMBER_OF_LAYERS" );
1331 types.insert( "LayerDistribution", "LAYER_DISTRIBUTION" );
1332 types.insert( "NumberOfLayers2D", "NUMBER_OF_LAYERS_2D" );
1333 types.insert( "LayerDistribution2D", "LAYER_DISTRIBUTION" );
1334 types.insert( "SegmentLengthAroundVertex", "SEGMENT_LENGTH_AROUND_VERTEX" );
1335 types.insert( "MaxLength", "MAX_LENGTH" );
1336 types.insert( "ViscousLayers", "VISCOUS_LAYERS" );
1337 types.insert( "QuadrangleParams", "QUADRANGLE_PARAMS" );
1338 types.insert( "CartesianParameters3D", "CARTESIAN_PARAMS" );
1342 if( types.contains( t ) )
1349 //=======================================================================
1350 //function : getCustomWidget
1351 //purpose : is called from buildStdFrame()
1352 //=======================================================================
1354 QWidget* StdMeshersGUI_StdHypothesisCreator::getCustomWidget( const StdParam & param,
1356 const int index) const
1359 if ( index < customWidgets()->count() ) {
1360 w = customWidgets()->at( index );
1362 w->setParent( parent );
1363 w->move( QPoint( 0, 0 ) );
1369 //================================================================================
1371 * \brief Set param value taken from a custom widget
1372 * \param param - SMESHGUI_GenericHypothesisCreator::StdParam structure
1373 * \param widget - widget presenting param
1374 * \retval bool - success flag
1376 * this method is called from getStdParamFromDlg()
1378 //================================================================================
1380 bool StdMeshersGUI_StdHypothesisCreator::getParamFromCustomWidget( StdParam & param,
1381 QWidget* widget) const
1383 if ( hypType()=="AutomaticLength" ) {
1384 SMESHGUI_SpinBox* w = dynamic_cast<SMESHGUI_SpinBox*>( widget );
1386 param.myValue = w->GetValue();
1390 if ( hypType() == "MaxLength" ) {
1394 if ( widget->inherits( "StdMeshersGUI_ObjectReferenceParamWdg" ))
1396 // show only 1st reference value
1397 if ( true /*widget == getWidgetForParam( 0 )*/) {
1398 const StdMeshersGUI_ObjectReferenceParamWdg * w =
1399 static_cast<const StdMeshersGUI_ObjectReferenceParamWdg*>( widget );
1400 param.myValue = w->GetValue();
1404 if ( widget->inherits( "StdMeshersGUI_LayerDistributionParamWdg" ))
1406 const StdMeshersGUI_LayerDistributionParamWdg * w =
1407 static_cast<const StdMeshersGUI_LayerDistributionParamWdg*>( widget );
1408 param.myValue = w->GetValue();
1411 if ( widget->inherits( "StdMeshersGUI_SubShapeSelectorWdg" ))
1413 const StdMeshersGUI_SubShapeSelectorWdg * w =
1414 static_cast<const StdMeshersGUI_SubShapeSelectorWdg*>( widget );
1415 param.myValue = w->GetValue();
1418 if ( widget->inherits( "StdMeshersGUI_QuadrangleParamWdg" ))
1420 //const StdMeshersGUI_QuadrangleParamWdg * w =
1421 // static_cast<const StdMeshersGUI_QuadrangleParamWdg*>( widget );
1422 param.myValue = "QuadType";
1425 if ( widget->inherits( "StdMeshersGUI_FixedPointsParamWdg" ))
1427 const StdMeshersGUI_FixedPointsParamWdg * w =
1428 static_cast<const StdMeshersGUI_FixedPointsParamWdg*>( widget );
1429 param.myValue = w->GetValue();
1432 if ( widget->inherits( "QCheckBox" ))
1434 //const QCheckBox * w = static_cast<const QCheckBox*>( widget );
1435 //param.myValue = w->isChecked();
1441 //================================================================================
1443 * \brief called when operation cancelled
1445 //================================================================================
1447 void StdMeshersGUI_StdHypothesisCreator::onReject()
1449 if ( hypType().startsWith("ProjectionSource" ) ||
1450 hypType().startsWith("ImportSource" ))
1452 // Uninstall filters of StdMeshersGUI_ObjectReferenceParamWdg
1453 deactivateObjRefParamWdg( customWidgets() );
1457 //================================================================================
1459 * \brief Update widgets dependent on paramWidget
1461 //================================================================================
1463 void StdMeshersGUI_StdHypothesisCreator::valueChanged( QWidget* paramWidget)
1465 if ( hypType() == "MaxLength" && paramWidget == getWidgetForParam(1) )
1467 getWidgetForParam(0)->setEnabled( !widget< QCheckBox >( 1 )->isChecked() );
1468 if ( !getWidgetForParam(0)->isEnabled() ) {
1469 StdMeshers::StdMeshers_MaxLength_var h =
1470 StdMeshers::StdMeshers_MaxLength::_narrow( initParamsHypothesis() );
1471 widget< QtxDoubleSpinBox >( 0 )->setValue( h->GetPreestimatedLength() );
1474 else if ( hypType().startsWith("ImportSource") && paramWidget == getWidgetForParam(1) )
1476 QCheckBox* toCopyMesh = (QCheckBox*) paramWidget;
1477 QCheckBox* toCopyGroups = widget< QCheckBox >( 2 );
1478 if ( !toCopyMesh->isChecked() )
1480 toCopyGroups->setChecked( false );
1481 toCopyGroups->setEnabled( false );
1485 toCopyGroups->setEnabled( true );
1490 //================================================================================
1494 //================================================================================
1496 bool StdMeshersGUI_StdHypothesisCreator::initVariableName(SMESH::SMESH_Hypothesis_var theHyp,
1497 StdParam & theParams,
1498 const char* theMethod) const
1500 QString aVaribaleName = getVariableName( theMethod );
1501 theParams.isVariable = !aVaribaleName.isEmpty();
1502 if (theParams.isVariable)
1503 theParams.myValue = aVaribaleName;
1505 return theParams.isVariable;