1 // Copyright (C) 2007-2010 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>
33 #include <SMESH_TypeFilter.hxx>
34 #include <SMESH_NumberFilter.hxx>
36 #include "StdMeshersGUI_FixedPointsParamWdg.h"
37 #include "StdMeshersGUI_LayerDistributionParamWdg.h"
38 #include "StdMeshersGUI_ObjectReferenceParamWdg.h"
39 #include "StdMeshersGUI_QuadrangleParamWdg.h"
40 #include "StdMeshersGUI_SubShapeSelectorWdg.h"
42 #include <SALOMEDSClient_Study.hxx>
44 // SALOME GUI includes
45 #include <SUIT_ResourceMgr.h>
48 #include <SALOMEconfig.h>
49 #include CORBA_SERVER_HEADER(SMESH_BasicHypothesis)
50 #include CORBA_SERVER_HEADER(SMESH_Mesh)
51 #include CORBA_SERVER_HEADER(SMESH_Group)
54 #include <QHBoxLayout>
59 const double VALUE_MAX = 1.0e+15, // COORD_MAX
60 VALUE_MAX_2 = VALUE_MAX * VALUE_MAX,
61 VALUE_MAX_3 = VALUE_MAX_2 * VALUE_MAX,
62 VALUE_SMALL = 1.0e-15,
63 VALUE_SMALL_2 = VALUE_SMALL * VALUE_SMALL,
64 VALUE_SMALL_3 = VALUE_SMALL_2 * VALUE_SMALL;
66 //================================================================================
69 * \param type - hypothesis type
71 //================================================================================
73 StdMeshersGUI_StdHypothesisCreator::StdMeshersGUI_StdHypothesisCreator( const QString& type )
74 : SMESHGUI_GenericHypothesisCreator( type )
78 //================================================================================
82 //================================================================================
84 StdMeshersGUI_StdHypothesisCreator::~StdMeshersGUI_StdHypothesisCreator()
88 //================================================================================
90 * \brief Return widget for i-th hypothesis parameter (got from myParamWidgets)
91 * \param i - index of hypothesis parameter
92 * \retval QWidget* - found widget
94 //================================================================================
96 QWidget* StdMeshersGUI_StdHypothesisCreator::getWidgetForParam( int i ) const
99 if ( isCreation() ) ++i; // skip widget of 'name' parameter
101 if ( i < myCustomWidgets.count() ) {
102 QList<QWidget*>::const_iterator anIt = myCustomWidgets.begin();
103 QList<QWidget*>::const_iterator aLast = myCustomWidgets.end();
104 for ( int j = 0 ; !w && anIt != aLast; ++anIt, ++j )
109 // list has no at() const, so we iterate
110 QList<QWidget*>::const_iterator anIt = widgets().begin();
111 QList<QWidget*>::const_iterator aLast = widgets().end();
112 for( int j = 0; !w && anIt!=aLast; anIt++, ++j ) {
120 //================================================================================
122 * \brief Allow modifing myCustomWidgets in const methods
123 * \retval ListOfWidgets* - non-const pointer to myCustomWidgets
125 //================================================================================
127 StdMeshersGUI_StdHypothesisCreator::ListOfWidgets*
128 StdMeshersGUI_StdHypothesisCreator::customWidgets() const
130 return const_cast< ListOfWidgets* >( & myCustomWidgets );
133 //================================================================================
135 * \brief Builds dlg layout
136 * \retval QFrame* - the built widget
138 //================================================================================
140 QFrame* StdMeshersGUI_StdHypothesisCreator::buildFrame()
142 return buildStdFrame();
145 //================================================================================
147 * \brief Initialise parameter values in controls
149 //================================================================================
151 void StdMeshersGUI_StdHypothesisCreator::retrieveParams() const
153 // buildStdFrame() sets values itself calling stdParams()
155 if ( hypType().startsWith("ProjectionSource" ))
157 // we use this method to connect depending custom widgets
158 StdMeshersGUI_ObjectReferenceParamWdg* widgetToActivate = 0;
159 ListOfWidgets::const_iterator anIt = myCustomWidgets.begin();
160 for ( ; anIt != myCustomWidgets.end(); anIt++)
162 if ( *anIt && (*anIt)->inherits("StdMeshersGUI_ObjectReferenceParamWdg"))
164 StdMeshersGUI_ObjectReferenceParamWdg * w1 =
165 ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
166 ListOfWidgets::const_iterator anIt2 = anIt;
167 for ( ++anIt2; anIt2 != myCustomWidgets.end(); anIt2++)
168 if ( *anIt2 && (*anIt2)->inherits("StdMeshersGUI_ObjectReferenceParamWdg"))
170 StdMeshersGUI_ObjectReferenceParamWdg * w2 =
171 ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt2 );
172 w1->AvoidSimultaneousSelection( w2 );
174 if ( !widgetToActivate )
175 widgetToActivate = w1;
178 if ( widgetToActivate )
179 widgetToActivate->activateSelection();
183 dlg()->setMinimumSize( dlg()->minimumSizeHint().width(), dlg()->minimumSizeHint().height() );
188 //================================================================================
190 * \brief Widget: slider with left and right labels
192 //================================================================================
194 class TDoubleSliderWith2Labels: public QWidget
197 TDoubleSliderWith2Labels( const QString& leftLabel, const QString& rightLabel,
198 const double initValue, const double bottom,
199 const double top , const double precision,
200 QWidget * parent=0 , const char * name=0 )
201 :QWidget(parent), _bottom(bottom), _precision(precision)
205 QHBoxLayout* aHBoxL = new QHBoxLayout(this);
207 if ( !leftLabel.isEmpty() ) {
208 QLabel* aLeftLabel = new QLabel( this );
209 aLeftLabel->setText( leftLabel );
210 aHBoxL->addWidget( aLeftLabel );
213 _slider = new QSlider( Qt::Horizontal, this );
214 _slider->setRange( 0, toInt( top ));
215 _slider->setValue( toInt( initValue ));
216 aHBoxL->addWidget( _slider );
218 if ( !rightLabel.isEmpty() ) {
219 QLabel* aRightLabel = new QLabel( this );
220 aRightLabel->setText( rightLabel );
221 aHBoxL->addWidget( aRightLabel );
226 double value() const { return _bottom + _slider->value() * _precision; }
227 QSlider * getSlider() const { return _slider; }
228 int toInt( double val ) const { return (int) ceil(( val - _bottom ) / _precision ); }
230 double _bottom, _precision;
234 //================================================================================
236 * \brief Retrieve GEOM_Object held by widget
238 //================================================================================
240 inline GEOM::GEOM_Object_var geomFromWdg(const QWidget* wdg)
242 const StdMeshersGUI_ObjectReferenceParamWdg * objRefWdg =
243 dynamic_cast<const StdMeshersGUI_ObjectReferenceParamWdg*>( wdg );
245 return objRefWdg->GetObject< GEOM::GEOM_Object >();
247 return GEOM::GEOM_Object::_nil();
249 //================================================================================
251 * \brief Retrieve SMESH_Mesh held by widget
253 //================================================================================
255 inline SMESH::SMESH_Mesh_var meshFromWdg(const QWidget* wdg)
257 const StdMeshersGUI_ObjectReferenceParamWdg * objRefWdg =
258 dynamic_cast<const StdMeshersGUI_ObjectReferenceParamWdg*>( wdg );
260 return objRefWdg->GetObject< SMESH::SMESH_Mesh >();
262 return SMESH::SMESH_Mesh::_nil();
264 //================================================================================
266 * \brief Retrieve SMESH_Mesh held by widget
268 //================================================================================
270 inline SMESH::ListOfGroups_var groupsFromWdg(const QWidget* wdg)
272 SMESH::ListOfGroups_var groups = new SMESH::ListOfGroups;
273 const StdMeshersGUI_ObjectReferenceParamWdg * objRefWdg =
274 dynamic_cast<const StdMeshersGUI_ObjectReferenceParamWdg*>( wdg );
277 groups->length( objRefWdg->NbObjects() );
278 for ( unsigned i = 0; i < groups->length(); ++i )
279 groups[i] = objRefWdg->GetObject< SMESH::SMESH_GroupBase >(i);
283 //================================================================================
285 * \brief creates a filter for selection of shapes of given dimension
286 * \param dim - dimension
287 * \param subShapeType - required type of subshapes, number of which must be \a nbSubShapes
288 * \param nbSubShapes - number of subshapes of given type
289 * \param closed - required closeness flag of a shape
290 * \retval SUIT_SelectionFilter* - created filter
292 //================================================================================
294 SUIT_SelectionFilter* filterForShapeOfDim(const int dim,
295 TopAbs_ShapeEnum subShapeType = TopAbs_SHAPE,
296 const int nbSubShapes = 0,
299 TColStd_MapOfInteger shapeTypes;
301 case 0: shapeTypes.Add( TopAbs_VERTEX ); break;
303 if ( subShapeType == TopAbs_SHAPE ) subShapeType = TopAbs_EDGE;
304 shapeTypes.Add( TopAbs_EDGE );
305 shapeTypes.Add( TopAbs_COMPOUND ); // for a group
308 if ( subShapeType == TopAbs_SHAPE ) subShapeType = TopAbs_FACE;
309 shapeTypes.Add( TopAbs_FACE );
310 shapeTypes.Add( TopAbs_COMPOUND ); // for a group
313 shapeTypes.Add( TopAbs_SHELL );
314 shapeTypes.Add( TopAbs_SOLID );
315 shapeTypes.Add( TopAbs_COMPSOLID );
316 shapeTypes.Add( TopAbs_COMPOUND );
319 return new SMESH_NumberFilter("GEOM", subShapeType, nbSubShapes,
320 shapeTypes, GEOM::GEOM_Object::_nil(), closed);
323 //================================================================================
325 * \brief Create a widget for object selection
326 * \param object - initial object
327 * \param filter - selection filter
328 * \retval QWidget* - created widget
330 //================================================================================
332 QWidget* newObjRefParamWdg( SUIT_SelectionFilter* filter,
333 CORBA::Object_var object)
335 StdMeshersGUI_ObjectReferenceParamWdg* w =
336 new StdMeshersGUI_ObjectReferenceParamWdg( filter, 0);
337 w->SetObject( object.in() );
340 QWidget* newObjRefParamWdg( SUIT_SelectionFilter* filter,
341 SMESH::string_array_var& objEntries)
343 StdMeshersGUI_ObjectReferenceParamWdg* w =
344 new StdMeshersGUI_ObjectReferenceParamWdg( filter, 0, /*multiSel=*/true);
345 w->SetObjects( objEntries );
346 w->activateSelection();
350 //================================================================================
352 * \brief calls deactivateSelection() for StdMeshersGUI_ObjectReferenceParamWdg
353 * \param widgetList - list of widgets
355 //================================================================================
357 void deactivateObjRefParamWdg( QList<QWidget*>* widgetList )
359 StdMeshersGUI_ObjectReferenceParamWdg* w = 0;
360 QList<QWidget*>::iterator anIt = widgetList->begin();
361 QList<QWidget*>::iterator aLast = widgetList->end();
362 for ( ; anIt != aLast; anIt++ ) {
363 if ( (*anIt) && (*anIt)->inherits( "StdMeshersGUI_ObjectReferenceParamWdg" ))
365 w = (StdMeshersGUI_ObjectReferenceParamWdg* )( *anIt );
366 w->deactivateSelection();
372 //================================================================================
374 * \brief Check parameter values before accept()
375 * \retval bool - true if OK
377 //================================================================================
379 bool StdMeshersGUI_StdHypothesisCreator::checkParams( QString& msg ) const
381 if( !SMESHGUI_GenericHypothesisCreator::checkParams( msg ) )
384 // check if object reference parameter is set, as it has no default value
386 if ( hypType().startsWith("ProjectionSource" ))
388 StdMeshersGUI_ObjectReferenceParamWdg* w =
389 widget< StdMeshersGUI_ObjectReferenceParamWdg >( 0 );
390 ok = ( w->IsObjectSelected() );
391 if ( !ok ) w->SetObject( CORBA::Object::_nil() );
392 int nbAssocVert = ( hypType() == "ProjectionSource1D" ? 1 : 2 );
393 for ( int i = 0; ok && i < nbAssocVert; i += 2)
396 StdMeshersGUI_ObjectReferenceParamWdg* w1 =
397 widget< StdMeshersGUI_ObjectReferenceParamWdg >( i+2 );
398 StdMeshersGUI_ObjectReferenceParamWdg* w2 =
399 widget< StdMeshersGUI_ObjectReferenceParamWdg >( i+3 );
400 srcV = w1->GetValue();
401 tgtV = w2->GetValue();
402 ok = (( srcV.isEmpty() && tgtV.isEmpty() ) ||
403 ( !srcV.isEmpty() && !tgtV.isEmpty() && srcV != tgtV ));
405 w1->SetObject( CORBA::Object::_nil() );
406 w2->SetObject( CORBA::Object::_nil() );
410 // Uninstall filters of StdMeshersGUI_ObjectReferenceParamWdg
412 deactivateObjRefParamWdg( customWidgets() );
414 else if ( hypType().startsWith("ImportSource" ))
416 StdMeshersGUI_ObjectReferenceParamWdg* w =
417 widget< StdMeshersGUI_ObjectReferenceParamWdg >( 0 );
418 ok = ( w->IsObjectSelected() );
420 else if ( hypType() == "LayerDistribution" || hypType() == "LayerDistribution2D" )
422 StdMeshersGUI_LayerDistributionParamWdg* w =
423 widget< StdMeshersGUI_LayerDistributionParamWdg >( 0 );
424 ok = ( w && w->IsOk() );
426 else if ( hypType() == "QuadrangleParams" )
428 //StdMeshersGUI_SubShapeSelectorWdg* w =
429 // widget< StdMeshersGUI_SubShapeSelectorWdg >( 0 );
430 //ok = ( w->GetListSize() > 0 );
431 //StdMeshersGUI_QuadrangleParamWdg* w =
432 // widget< StdMeshersGUI_QuadrangleParamWdg >( 1 );
437 //================================================================================
439 * \brief Store params from GUI controls to a hypothesis
440 * \retval QString - text representation of parameters
442 //================================================================================
444 QString StdMeshersGUI_StdHypothesisCreator::storeParams() const
446 ListOfStdParams params;
447 bool res = getStdParamFromDlg( params );
450 SMESH::SetName( SMESH::FindSObject( hypothesis() ), params[0].myValue.toString().toLatin1().data() );
451 params.erase( params.begin() );
454 QString valueStr = stdParamValues( params );
455 QStringList aVariablesList = getVariablesFromDlg();
457 if( res && !params.isEmpty() )
459 if( hypType()=="LocalLength" )
461 StdMeshers::StdMeshers_LocalLength_var h =
462 StdMeshers::StdMeshers_LocalLength::_narrow( hypothesis() );
464 h->SetLength( params[0].myValue.toDouble() );
465 h->SetParameters(aVariablesList.join(":").toLatin1().constData());
466 h->SetPrecision( params[1].myValue.toDouble() );
467 h->SetParameters(aVariablesList.join(":").toLatin1().constData());
469 else if( hypType()=="MaxLength" )
471 StdMeshers::StdMeshers_MaxLength_var h =
472 StdMeshers::StdMeshers_MaxLength::_narrow( hypothesis() );
474 h->SetLength( params[0].myValue.toDouble() );
475 h->SetParameters(aVariablesList.join(":").toLatin1().constData());
476 h->SetUsePreestimatedLength( widget< QCheckBox >( 1 )->isChecked() );
477 if ( !h->HavePreestimatedLength() && !h->_is_equivalent( initParamsHypothesis() )) {
478 StdMeshers::StdMeshers_MaxLength_var hInit =
479 StdMeshers::StdMeshers_MaxLength::_narrow( initParamsHypothesis() );
480 h->SetPreestimatedLength( hInit->GetPreestimatedLength() );
483 else if( hypType()=="SegmentLengthAroundVertex" )
485 StdMeshers::StdMeshers_SegmentLengthAroundVertex_var h =
486 StdMeshers::StdMeshers_SegmentLengthAroundVertex::_narrow( hypothesis() );
488 h->SetLength( params[0].myValue.toDouble() );
489 h->SetParameters(aVariablesList.join(":").toLatin1().constData());
491 else if( hypType()=="Arithmetic1D" )
493 StdMeshers::StdMeshers_Arithmetic1D_var h =
494 StdMeshers::StdMeshers_Arithmetic1D::_narrow( hypothesis() );
496 StdMeshersGUI_SubShapeSelectorWdg* w =
497 widget< StdMeshersGUI_SubShapeSelectorWdg >( 2 );
499 h->SetStartLength( params[0].myValue.toDouble() );
500 h->SetParameters(aVariablesList.join(":").toLatin1().constData());
501 h->SetEndLength( params[1].myValue.toDouble() );
502 h->SetParameters(aVariablesList.join(":").toLatin1().constData());
504 h->SetReversedEdges( w->GetListOfIDs() );
505 h->SetObjectEntry( w->GetMainShapeEntry() );
508 else if( hypType()=="FixedPoints1D" )
510 StdMeshers::StdMeshers_FixedPoints1D_var h =
511 StdMeshers::StdMeshers_FixedPoints1D::_narrow( hypothesis() );
513 StdMeshersGUI_FixedPointsParamWdg* w1 =
514 widget< StdMeshersGUI_FixedPointsParamWdg >( 0 );
516 StdMeshersGUI_SubShapeSelectorWdg* w2 =
517 widget< StdMeshersGUI_SubShapeSelectorWdg >( 1 );
520 h->SetParameters(aVariablesList.join(":").toLatin1().constData());
521 h->SetPoints( w1->GetListOfPoints() );
522 h->SetNbSegments( w1->GetListOfSegments() );
525 h->SetReversedEdges( w2->GetListOfIDs() );
526 h->SetObjectEntry( w2->GetMainShapeEntry() );
529 else if( hypType()=="MaxElementArea" )
531 StdMeshers::StdMeshers_MaxElementArea_var h =
532 StdMeshers::StdMeshers_MaxElementArea::_narrow( hypothesis() );
533 h->SetParameters(aVariablesList.join(":").toLatin1().constData());
534 h->SetMaxElementArea( params[0].myValue.toDouble() );
536 else if( hypType()=="MaxElementVolume" )
538 StdMeshers::StdMeshers_MaxElementVolume_var h =
539 StdMeshers::StdMeshers_MaxElementVolume::_narrow( hypothesis() );
541 h->SetMaxElementVolume( params[0].myValue.toDouble() );
542 h->SetParameters(aVariablesList.join(":").toLatin1().constData());
544 else if( hypType()=="StartEndLength" )
546 StdMeshers::StdMeshers_StartEndLength_var h =
547 StdMeshers::StdMeshers_StartEndLength::_narrow( hypothesis() );
549 StdMeshersGUI_SubShapeSelectorWdg* w =
550 widget< StdMeshersGUI_SubShapeSelectorWdg >( 2 );
552 h->SetStartLength( params[0].myValue.toDouble() );
553 h->SetParameters(aVariablesList.join(":").toLatin1().constData());
554 h->SetEndLength( params[1].myValue.toDouble() );
555 h->SetParameters(aVariablesList.join(":").toLatin1().constData());
557 h->SetReversedEdges( w->GetListOfIDs() );
558 h->SetObjectEntry( w->GetMainShapeEntry() );
561 else if( hypType()=="Deflection1D" )
563 StdMeshers::StdMeshers_Deflection1D_var h =
564 StdMeshers::StdMeshers_Deflection1D::_narrow( hypothesis() );
565 h->SetParameters(aVariablesList.join(":").toLatin1().constData());
566 h->SetDeflection( params[0].myValue.toDouble() );
568 else if( hypType()=="AutomaticLength" )
570 StdMeshers::StdMeshers_AutomaticLength_var h =
571 StdMeshers::StdMeshers_AutomaticLength::_narrow( hypothesis() );
573 h->SetFineness( params[0].myValue.toDouble() );
575 else if( hypType()=="NumberOfLayers" )
577 StdMeshers::StdMeshers_NumberOfLayers_var h =
578 StdMeshers::StdMeshers_NumberOfLayers::_narrow( hypothesis() );
580 h->SetNumberOfLayers( params[0].myValue.toInt() );
581 h->SetParameters(aVariablesList.join(":").toLatin1().constData());
583 else if( hypType()=="LayerDistribution" )
585 StdMeshers::StdMeshers_LayerDistribution_var h =
586 StdMeshers::StdMeshers_LayerDistribution::_narrow( hypothesis() );
587 StdMeshersGUI_LayerDistributionParamWdg* w =
588 widget< StdMeshersGUI_LayerDistributionParamWdg >( 0 );
590 h->SetLayerDistribution( w->GetHypothesis() );
591 h->SetParameters(w->GetHypothesis()->GetParameters());
592 w->GetHypothesis()->ClearParameters();
594 else if( hypType()=="NumberOfLayers2D" )
596 StdMeshers::StdMeshers_NumberOfLayers2D_var h =
597 StdMeshers::StdMeshers_NumberOfLayers2D::_narrow( hypothesis() );
599 h->SetNumberOfLayers( params[0].myValue.toInt() );
600 h->SetParameters(aVariablesList.join(":").toLatin1().constData());
602 else if( hypType()=="LayerDistribution2D" )
604 StdMeshers::StdMeshers_LayerDistribution2D_var h =
605 StdMeshers::StdMeshers_LayerDistribution2D::_narrow( hypothesis() );
606 StdMeshersGUI_LayerDistributionParamWdg* w =
607 widget< StdMeshersGUI_LayerDistributionParamWdg >( 0 );
609 h->SetLayerDistribution( w->GetHypothesis() );
610 h->SetParameters(w->GetHypothesis()->GetParameters());
611 w->GetHypothesis()->ClearParameters();
613 else if( hypType()=="ProjectionSource1D" )
615 StdMeshers::StdMeshers_ProjectionSource1D_var h =
616 StdMeshers::StdMeshers_ProjectionSource1D::_narrow( hypothesis() );
618 h->SetSourceEdge ( geomFromWdg ( getWidgetForParam( 0 )));
619 h->SetSourceMesh ( meshFromWdg ( getWidgetForParam( 1 )));
620 h->SetVertexAssociation( geomFromWdg ( getWidgetForParam( 2 )),
621 geomFromWdg ( getWidgetForParam( 3 )));
623 else if( hypType()=="ProjectionSource2D" )
625 StdMeshers::StdMeshers_ProjectionSource2D_var h =
626 StdMeshers::StdMeshers_ProjectionSource2D::_narrow( hypothesis() );
628 h->SetSourceFace ( geomFromWdg ( getWidgetForParam( 0 )));
629 h->SetSourceMesh ( meshFromWdg ( getWidgetForParam( 1 )));
630 h->SetVertexAssociation( geomFromWdg ( getWidgetForParam( 2 )), // src1
631 geomFromWdg ( getWidgetForParam( 4 )), // src2
632 geomFromWdg ( getWidgetForParam( 3 )), // tgt1
633 geomFromWdg ( getWidgetForParam( 5 ))); // tgt2
635 else if( hypType()=="ProjectionSource3D" )
637 StdMeshers::StdMeshers_ProjectionSource3D_var h =
638 StdMeshers::StdMeshers_ProjectionSource3D::_narrow( hypothesis() );
640 h->SetSource3DShape ( 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()=="ImportSource1D" )
649 StdMeshers::StdMeshers_ImportSource1D_var h =
650 StdMeshers::StdMeshers_ImportSource1D::_narrow( hypothesis() );
652 SMESH::ListOfGroups_var groups = groupsFromWdg( getWidgetForParam( 0 ));
653 h->SetSourceEdges( groups.in() );
654 QCheckBox* toCopyMesh = widget< QCheckBox >( 1 );
655 QCheckBox* toCopyGroups = widget< QCheckBox >( 2 );
656 h->SetCopySourceMesh( toCopyMesh->isChecked(), toCopyGroups->isChecked());
658 else if( hypType()=="ImportSource2D" )
660 StdMeshers::StdMeshers_ImportSource2D_var h =
661 StdMeshers::StdMeshers_ImportSource2D::_narrow( hypothesis() );
663 SMESH::ListOfGroups_var groups = groupsFromWdg( getWidgetForParam( 0 ));
664 h->SetSourceFaces( groups.in() );
665 QCheckBox* toCopyMesh = widget< QCheckBox >( 1 );
666 QCheckBox* toCopyGroups = widget< QCheckBox >( 2 );
667 h->SetCopySourceMesh( toCopyMesh->isChecked(), toCopyGroups->isChecked());
669 else if( hypType()=="ViscousLayers" )
671 StdMeshers::StdMeshers_ViscousLayers_var h =
672 StdMeshers::StdMeshers_ViscousLayers::_narrow( hypothesis() );
674 h->SetTotalThickness( params[0].myValue.toDouble() );
675 /* */ h->SetParameters(aVariablesList.join(":").toLatin1().constData());
676 h->SetNumberLayers ( params[1].myValue.toInt() );
677 /* */ h->SetParameters(aVariablesList.join(":").toLatin1().constData());
678 h->SetStretchFactor ( params[2].myValue.toInt() );
679 /* */ h->SetParameters(aVariablesList.join(":").toLatin1().constData());
681 if ( StdMeshersGUI_SubShapeSelectorWdg* idsWg =
682 widget< StdMeshersGUI_SubShapeSelectorWdg >( 3 ))
684 h->SetIgnoreFaces( idsWg->GetListOfIDs() );
685 //h->SetObjectEntry( idsWg->GetMainShapeEntry() );
688 else if( hypType()=="QuadrangleParams" )
690 StdMeshers::StdMeshers_QuadrangleParams_var h =
691 StdMeshers::StdMeshers_QuadrangleParams::_narrow( hypothesis() );
692 StdMeshersGUI_SubShapeSelectorWdg* w1 =
693 widget< StdMeshersGUI_SubShapeSelectorWdg >( 0 );
694 StdMeshersGUI_QuadrangleParamWdg* w2 =
695 widget< StdMeshersGUI_QuadrangleParamWdg >( 1 );
697 if (w1->GetListSize() > 0) {
698 h->SetTriaVertex(w1->GetListOfIDs()[0]); // getlist must be called once
699 const char * entry = w1->GetMainShapeEntry();
700 h->SetObjectEntry(entry);
702 h->SetQuadType(StdMeshers::QuadType(w2->GetType()));
709 //================================================================================
711 * \brief Return parameter values as SMESHGUI_GenericHypothesisCreator::StdParam
712 * \param p - list of parameters
713 * \retval bool - success flag
715 * Is called from SMESHGUI_GenericHypothesisCreator::buildStdFrame().
716 * Parameters will be shown using "standard" controls:
717 * Int by QtxIntSpinBox
718 * Double by SMESHGUI_SpinBox
719 * String by QLineEdit
720 * getCustomWidget() allows to redefine control for a parameter
722 //================================================================================
724 bool StdMeshersGUI_StdHypothesisCreator::stdParams( ListOfStdParams& p ) const
727 SMESHGUI_GenericHypothesisCreator::StdParam item;
730 customWidgets()->clear();
733 HypothesisData* data = SMESH::GetHypothesisData( hypType() );
734 item.myName = tr( "SMESH_NAME" );
735 item.myValue = data ? hypName() : QString();
737 customWidgets()->append(0);
740 SMESH::SMESH_Hypothesis_var hyp = initParamsHypothesis();
741 SMESH::ListOfParameters_var aParameters = hyp->GetLastParameters();
743 if( hypType()=="LocalLength" )
745 StdMeshers::StdMeshers_LocalLength_var h =
746 StdMeshers::StdMeshers_LocalLength::_narrow( hyp );
748 item.myName = tr("SMESH_LOCAL_LENGTH_PARAM");
749 if(!initVariableName(aParameters,item,0))
750 item.myValue = h->GetLength();
753 item.myName = tr("SMESH_LOCAL_LENGTH_PRECISION");
754 if(!initVariableName(aParameters,item,1))
755 item.myValue = h->GetPrecision();
759 else if( hypType()=="MaxLength" )
761 StdMeshers::StdMeshers_MaxLength_var h =
762 StdMeshers::StdMeshers_MaxLength::_narrow( hyp );
763 // try to set a right preestimated length to edited hypothesis
764 bool noPreestimatedAtEdition = false;
765 if ( !isCreation() ) {
766 StdMeshers::StdMeshers_MaxLength_var initHyp =
767 StdMeshers::StdMeshers_MaxLength::_narrow( initParamsHypothesis(true) );
768 noPreestimatedAtEdition =
769 ( initHyp->_is_nil() || !initHyp->HavePreestimatedLength() );
770 if ( !noPreestimatedAtEdition )
771 h->SetPreestimatedLength( initHyp->GetPreestimatedLength() );
774 item.myName = tr("SMESH_LOCAL_LENGTH_PARAM");
775 if(!initVariableName(aParameters,item,0))
776 item.myValue = h->GetLength();
778 customWidgets()->append(0);
780 item.myName = tr("SMESH_USE_PREESTIMATED_LENGTH");
782 QCheckBox* aQCheckBox = new QCheckBox(dlg());
783 if ( !noPreestimatedAtEdition && h->HavePreestimatedLength() ) {
784 aQCheckBox->setChecked( h->GetUsePreestimatedLength() );
785 connect( aQCheckBox, SIGNAL( stateChanged(int) ), this, SLOT( onValueChanged() ) );
788 aQCheckBox->setChecked( false );
789 aQCheckBox->setEnabled( false );
791 customWidgets()->append( aQCheckBox );
793 else if( hypType()=="SegmentLengthAroundVertex" )
795 StdMeshers::StdMeshers_SegmentLengthAroundVertex_var h =
796 StdMeshers::StdMeshers_SegmentLengthAroundVertex::_narrow( hyp );
798 item.myName = tr("SMESH_LOCAL_LENGTH_PARAM");
799 if(!initVariableName(aParameters,item,0))
800 item.myValue = h->GetLength();
804 else if( hypType()=="Arithmetic1D" )
806 StdMeshers::StdMeshers_Arithmetic1D_var h =
807 StdMeshers::StdMeshers_Arithmetic1D::_narrow( hyp );
809 item.myName = tr( "SMESH_START_LENGTH_PARAM" );
810 if(!initVariableName(aParameters,item,0))
811 item.myValue = h->GetLength( true );
814 customWidgets()->append (0);
816 item.myName = tr( "SMESH_END_LENGTH_PARAM" );
817 if(!initVariableName(aParameters,item,1))
818 item.myValue = h->GetLength( false );
821 customWidgets()->append (0);
823 item.myName = tr( "SMESH_REVERSED_EDGES" );
826 StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget =
827 new StdMeshersGUI_SubShapeSelectorWdg();
828 QString aGeomEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
829 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
830 if ( aGeomEntry == "" )
831 aGeomEntry = h->GetObjectEntry();
833 aDirectionWidget->SetGeomShapeEntry( aGeomEntry );
834 aDirectionWidget->SetMainShapeEntry( aMainEntry );
835 aDirectionWidget->SetListOfIDs( h->GetReversedEdges() );
836 aDirectionWidget->showPreview( true );
837 customWidgets()->append ( aDirectionWidget );
841 else if( hypType()=="FixedPoints1D" )
843 StdMeshers::StdMeshers_FixedPoints1D_var h =
844 StdMeshers::StdMeshers_FixedPoints1D::_narrow( hyp );
846 item.myName = tr( "SMESH_FIXED_POINTS" );
849 StdMeshersGUI_FixedPointsParamWdg* aFixedPointsWidget =
850 new StdMeshersGUI_FixedPointsParamWdg();
852 if ( !isCreation() ) {
853 aFixedPointsWidget->SetListOfPoints( h->GetPoints() );
854 aFixedPointsWidget->SetListOfSegments( h->GetNbSegments() );
856 customWidgets()->append( aFixedPointsWidget );
858 item.myName = tr( "SMESH_REVERSED_EDGES" );
861 StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget =
862 new StdMeshersGUI_SubShapeSelectorWdg();
863 QString anEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
864 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
866 anEntry = h->GetObjectEntry();
867 aDirectionWidget->SetGeomShapeEntry( anEntry );
868 aDirectionWidget->SetMainShapeEntry( aMainEntry );
869 aDirectionWidget->SetListOfIDs( h->GetReversedEdges() );
870 aDirectionWidget->showPreview( true );
871 customWidgets()->append ( aDirectionWidget );
875 else if( hypType()=="MaxElementArea" )
877 StdMeshers::StdMeshers_MaxElementArea_var h =
878 StdMeshers::StdMeshers_MaxElementArea::_narrow( hyp );
880 item.myName = tr( "SMESH_MAX_ELEMENT_AREA_PARAM" );
881 if(!initVariableName(aParameters,item,0))
882 item.myValue = h->GetMaxElementArea();
886 else if( hypType()=="MaxElementVolume" )
888 StdMeshers::StdMeshers_MaxElementVolume_var h =
889 StdMeshers::StdMeshers_MaxElementVolume::_narrow( hyp );
891 item.myName = tr( "SMESH_MAX_ELEMENT_VOLUME_PARAM" );
892 if(!initVariableName(aParameters,item,0))
893 item.myValue = h->GetMaxElementVolume();
896 else if( hypType()=="StartEndLength" )
898 StdMeshers::StdMeshers_StartEndLength_var h =
899 StdMeshers::StdMeshers_StartEndLength::_narrow( hyp );
901 item.myName = tr( "SMESH_START_LENGTH_PARAM" );
903 if(!initVariableName(aParameters,item,0))
904 item.myValue = h->GetLength( true );
906 customWidgets()->append(0);
908 item.myName = tr( "SMESH_END_LENGTH_PARAM" );
909 if(!initVariableName(aParameters,item,1))
910 item.myValue = h->GetLength( false );
912 customWidgets()->append(0);
914 item.myName = tr( "SMESH_REVERSED_EDGES" );
917 StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget =
918 new StdMeshersGUI_SubShapeSelectorWdg();
919 QString anEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
920 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
922 anEntry = h->GetObjectEntry();
923 aDirectionWidget->SetGeomShapeEntry( anEntry );
924 aDirectionWidget->SetMainShapeEntry( aMainEntry );
925 aDirectionWidget->SetListOfIDs( h->GetReversedEdges() );
926 aDirectionWidget->showPreview( true );
927 customWidgets()->append ( aDirectionWidget );
929 else if( hypType()=="Deflection1D" )
931 StdMeshers::StdMeshers_Deflection1D_var h =
932 StdMeshers::StdMeshers_Deflection1D::_narrow( hyp );
934 item.myName = tr( "SMESH_DEFLECTION1D_PARAM" );
935 if(!initVariableName(aParameters,item,0))
936 item.myValue = h->GetDeflection();
939 else if( hypType()=="AutomaticLength" )
941 StdMeshers::StdMeshers_AutomaticLength_var h =
942 StdMeshers::StdMeshers_AutomaticLength::_narrow( hyp );
944 item.myName = tr( "SMESH_FINENESS_PARAM" );
945 //item.myValue = h->GetFineness();
947 SMESHGUI_SpinBox* _autoLengthSpinBox = new SMESHGUI_SpinBox(dlg());
948 _autoLengthSpinBox->RangeStepAndValidator(0, 1, 0.01, "length_precision");
949 _autoLengthSpinBox->SetValue(h->GetFineness());
950 customWidgets()->append( _autoLengthSpinBox);
952 else if( hypType()=="NumberOfLayers" )
954 StdMeshers::StdMeshers_NumberOfLayers_var h =
955 StdMeshers::StdMeshers_NumberOfLayers::_narrow( hyp );
957 item.myName = tr( "SMESH_NUMBER_OF_LAYERS" );
958 if(!initVariableName(aParameters,item,0))
959 item.myValue = (int) h->GetNumberOfLayers();
962 else if( hypType()=="LayerDistribution" ) {
963 StdMeshers::StdMeshers_LayerDistribution_var h =
964 StdMeshers::StdMeshers_LayerDistribution::_narrow( hyp );
966 item.myName = tr( "SMESH_LAYERS_DISTRIBUTION" ); p.append( item );
968 //Set into not published hypo last variables
969 QStringList aLastVarsList;
970 for(int i = 0;i<aParameters->length();i++)
971 aLastVarsList.append(QString(aParameters[i].in()));
973 if(!aLastVarsList.isEmpty())
974 h->GetLayerDistribution()->SetLastParameters(aLastVarsList.join(":").toLatin1().constData());
976 customWidgets()->append
977 ( new StdMeshersGUI_LayerDistributionParamWdg( h->GetLayerDistribution(), hypName(), dlg()));
979 else if( hypType()=="NumberOfLayers2D" ) {
980 StdMeshers::StdMeshers_NumberOfLayers2D_var h =
981 StdMeshers::StdMeshers_NumberOfLayers2D::_narrow( hyp );
983 item.myName = tr( "SMESH_NUMBER_OF_LAYERS" );
984 if(!initVariableName(aParameters,item,0))
985 item.myValue = (int) h->GetNumberOfLayers();
988 else if( hypType()=="LayerDistribution2D" ) {
989 StdMeshers::StdMeshers_LayerDistribution2D_var h =
990 StdMeshers::StdMeshers_LayerDistribution2D::_narrow( hyp );
992 item.myName = tr( "SMESH_LAYERS_DISTRIBUTION" ); p.append( item );
994 //Set into not published hypo last variables
995 QStringList aLastVarsList;
996 for(int i = 0;i<aParameters->length();i++)
997 aLastVarsList.append(QString(aParameters[i].in()));
999 if(!aLastVarsList.isEmpty())
1000 h->GetLayerDistribution()->SetLastParameters(aLastVarsList.join(":").toLatin1().constData());
1002 customWidgets()->append
1003 ( new StdMeshersGUI_LayerDistributionParamWdg( h->GetLayerDistribution(), hypName(), dlg()));
1005 else if( hypType()=="ProjectionSource1D" )
1007 StdMeshers::StdMeshers_ProjectionSource1D_var h =
1008 StdMeshers::StdMeshers_ProjectionSource1D::_narrow( hyp );
1010 item.myName = tr( "SMESH_SOURCE_EDGE" ); p.append( item );
1011 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 1 ),
1012 h->GetSourceEdge()));
1013 item.myName = tr( "SMESH_SOURCE_MESH" ); p.append( item );
1014 customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( MESH ),
1015 h->GetSourceMesh()));
1016 item.myName = tr( "SMESH_SOURCE_VERTEX" ); p.append( item );
1017 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1018 h->GetSourceVertex()));
1019 item.myName = tr( "SMESH_TARGET_VERTEX" ); p.append( item );
1020 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1021 h->GetTargetVertex()));
1023 else if( hypType()=="ProjectionSource2D" )
1025 StdMeshers::StdMeshers_ProjectionSource2D_var h =
1026 StdMeshers::StdMeshers_ProjectionSource2D::_narrow( hyp );
1028 item.myName = tr( "SMESH_SOURCE_FACE" ); p.append( item );
1029 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 2 ),
1030 h->GetSourceFace()));
1031 item.myName = tr( "SMESH_SOURCE_MESH" ); p.append( item );
1032 customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( MESH ),
1033 h->GetSourceMesh()));
1034 item.myName = tr( "SMESH_SOURCE_VERTEX1" ); p.append( item );
1035 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1036 h->GetSourceVertex( 1 )));
1037 item.myName = tr( "SMESH_TARGET_VERTEX1" ); p.append( item );
1038 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1039 h->GetTargetVertex( 1 )));
1040 item.myName = tr( "SMESH_SOURCE_VERTEX2" ); p.append( item );
1041 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1042 h->GetSourceVertex( 2 )));
1043 item.myName = tr( "SMESH_TARGET_VERTEX2" ); p.append( item );
1044 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1045 h->GetTargetVertex( 2 )));
1047 else if( hypType()=="ProjectionSource3D" )
1049 StdMeshers::StdMeshers_ProjectionSource3D_var h =
1050 StdMeshers::StdMeshers_ProjectionSource3D::_narrow( hyp );
1052 item.myName = tr( "SMESH_SOURCE_3DSHAPE" ); p.append( item );
1053 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 3, TopAbs_FACE, 6, true ),
1054 h->GetSource3DShape()));
1055 item.myName = tr( "SMESH_SOURCE_MESH" ); p.append( item );
1056 customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( MESH ),
1057 h->GetSourceMesh()));
1058 item.myName = tr( "SMESH_SOURCE_VERTEX1" ); p.append( item );
1059 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1060 h->GetSourceVertex( 1 )));
1061 item.myName = tr( "SMESH_TARGET_VERTEX1" ); p.append( item );
1062 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1063 h->GetTargetVertex( 1 )));
1064 item.myName = tr( "SMESH_SOURCE_VERTEX2" ); p.append( item );
1065 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1066 h->GetSourceVertex( 2 )));
1067 item.myName = tr( "SMESH_TARGET_VERTEX2" ); p.append( item );
1068 customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1069 h->GetTargetVertex( 2 )));
1071 else if( hypType()=="ImportSource1D" )
1073 StdMeshers::StdMeshers_ImportSource1D_var h =
1074 StdMeshers::StdMeshers_ImportSource1D::_narrow( hyp );
1076 SMESH::string_array_var groupEntries = h->GetSourceEdges();
1077 CORBA::Boolean toCopyMesh, toCopyGroups;
1078 h->GetCopySourceMesh(toCopyMesh, toCopyGroups);
1080 item.myName = tr( "SMESH_SOURCE_EDGES" ); p.append( item );
1081 customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( GROUP_EDGE ),
1084 item.myName = tr( "SMESH_COPY_MESH" ); p.append( item );
1085 QCheckBox* aQCheckBox = new QCheckBox(dlg());
1086 aQCheckBox->setChecked( toCopyMesh );
1087 connect( aQCheckBox, SIGNAL( stateChanged(int) ), this, SLOT( onValueChanged() ));
1088 customWidgets()->append( aQCheckBox );
1090 item.myName = tr( "SMESH_TO_COPY_GROUPS" ); p.append( item );
1091 aQCheckBox = new QCheckBox(dlg());
1092 aQCheckBox->setChecked( toCopyGroups );
1093 aQCheckBox->setEnabled( toCopyMesh );
1094 customWidgets()->append( aQCheckBox );
1096 else if( hypType()=="ImportSource2D" )
1098 StdMeshers::StdMeshers_ImportSource2D_var h =
1099 StdMeshers::StdMeshers_ImportSource2D::_narrow( hyp );
1101 SMESH::string_array_var groupEntries = h->GetSourceFaces();
1102 CORBA::Boolean toCopyMesh, toCopyGroups;
1103 h->GetCopySourceMesh(toCopyMesh, toCopyGroups);
1105 item.myName = tr( "SMESH_SOURCE_FACES" ); p.append( item );
1106 customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( GROUP_FACE ),
1109 item.myName = tr( "SMESH_COPY_MESH" ); p.append( item );
1110 QCheckBox* aQCheckBox = new QCheckBox(dlg());
1111 aQCheckBox->setChecked( toCopyMesh );
1112 connect( aQCheckBox, SIGNAL( stateChanged(int) ), this, SLOT( onValueChanged() ));
1113 customWidgets()->append( aQCheckBox );
1115 item.myName = tr( "SMESH_COPY_GROUPS" ); p.append( item );
1116 aQCheckBox = new QCheckBox(dlg());
1117 aQCheckBox->setChecked( toCopyGroups );
1118 aQCheckBox->setEnabled( toCopyMesh );
1119 customWidgets()->append( aQCheckBox );
1121 else if( hypType()=="ViscousLayers" )
1123 StdMeshers::StdMeshers_ViscousLayers_var h =
1124 StdMeshers::StdMeshers_ViscousLayers::_narrow( hyp );
1126 item.myName = tr( "SMESH_TOTAL_THICKNESS" );
1127 if(!initVariableName(aParameters,item,0))
1128 item.myValue = h->GetTotalThickness();
1130 customWidgets()->append (0);
1132 item.myName = tr( "SMESH_NUMBER_OF_LAYERS" );
1133 if(!initVariableName(aParameters,item,1))
1134 item.myValue = h->GetNumberLayers();
1136 customWidgets()->append (0);
1138 item.myName = tr( "SMESH_STRETCH_FACTOR" );
1139 if(!initVariableName(aParameters,item,2))
1140 item.myValue = h->GetStretchFactor();
1142 customWidgets()->append (0);
1144 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
1145 if ( !aMainEntry.isEmpty() )
1147 item.myName = tr( "SMESH_FACES_WO_LAYERS" );
1150 StdMeshersGUI_SubShapeSelectorWdg* idsWg =
1151 new StdMeshersGUI_SubShapeSelectorWdg(0,TopAbs_FACE);
1153 idsWg->SetGeomShapeEntry( aMainEntry );
1154 idsWg->SetMainShapeEntry( aMainEntry );
1155 idsWg->SetListOfIDs( h->GetIgnoreFaces() );
1156 idsWg->showPreview( true );
1157 customWidgets()->append ( idsWg );
1160 else if (hypType() == "QuadrangleParams")
1162 StdMeshers::StdMeshers_QuadrangleParams_var h =
1163 StdMeshers::StdMeshers_QuadrangleParams::_narrow(hyp);
1165 item.myName = tr("SMESH_BASE_VERTEX");
1168 StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget =
1169 new StdMeshersGUI_SubShapeSelectorWdg(0, TopAbs_VERTEX);
1170 aDirectionWidget->SetMaxSize(1);
1171 QString anEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
1172 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
1174 anEntry = h->GetObjectEntry();
1175 aDirectionWidget->SetGeomShapeEntry(anEntry);
1176 aDirectionWidget->SetMainShapeEntry(aMainEntry);
1177 if (!isCreation()) {
1178 int vertID = h->GetTriaVertex();
1180 SMESH::long_array_var aVec = new SMESH::long_array;
1183 aDirectionWidget->SetListOfIDs(aVec);
1186 aDirectionWidget->showPreview(true);
1188 item.myName = tr("SMESH_QUAD_TYPE");
1191 StdMeshersGUI_QuadrangleParamWdg* aTypeWidget =
1192 new StdMeshersGUI_QuadrangleParamWdg();
1193 if (!isCreation()) {
1194 aTypeWidget->SetType(int(h->GetQuadType()));
1197 customWidgets()->append(aDirectionWidget);
1198 customWidgets()->append(aTypeWidget);
1205 //================================================================================
1207 * \brief tune "standard" control
1208 * \param w - control widget
1209 * \param int - parameter index
1211 //================================================================================
1213 void StdMeshersGUI_StdHypothesisCreator::attuneStdWidget (QWidget* w, const int) const
1215 SMESHGUI_SpinBox* sb = w->inherits( "SMESHGUI_SpinBox" ) ? ( SMESHGUI_SpinBox* )w : 0;
1218 if( hypType()=="LocalLength" )
1220 if (sb->objectName() == tr("SMESH_LOCAL_LENGTH_PARAM"))
1221 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1222 else if (sb->objectName() == tr("SMESH_LOCAL_LENGTH_PRECISION"))
1223 sb->RangeStepAndValidator( 0.0, 1.0, 0.05, "len_tol_precision" );
1225 else if( hypType()=="Arithmetic1D" )
1227 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "parametric_precision" );
1229 else if( hypType()=="MaxLength" )
1231 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1232 sb->setEnabled( !widget< QCheckBox >( 1 )->isChecked() );
1234 else if( hypType()=="MaxElementArea" )
1236 sb->RangeStepAndValidator( VALUE_SMALL_2, VALUE_MAX_2, 1.0, "area_precision" );
1238 else if( hypType()=="MaxElementVolume" )
1240 sb->RangeStepAndValidator( VALUE_SMALL_3, VALUE_MAX_3, 1.0, "vol_precision" );
1242 else if( hypType()=="StartEndLength" )
1244 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1246 else if( hypType()=="Deflection1D" )
1248 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "parametric_precision" );
1250 else if( hypType()=="ViscousLayers" )
1252 if (sb->objectName() == tr("SMESH_STRETCH_FACTOR"))
1253 sb->RangeStepAndValidator( 1.0, VALUE_MAX, 0.1, "parametric_precision" );
1255 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1257 else // default validator for possible ancestors
1259 sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1262 // else if ( QtxIntSpinBox* ib = w->inherits( "QtxIntSpinBox" ) ? ( QtxIntSpinBox* )w : 0)
1264 // if( hypType()=="ViscousLayers" )
1270 //================================================================================
1272 * \brief Return dlg title
1273 * \retval QString - title string
1275 //================================================================================
1277 QString StdMeshersGUI_StdHypothesisCreator::caption() const
1279 return tr( QString( "SMESH_%1_TITLE" ).arg( hypTypeName( hypType() ) ).toLatin1().data() );
1282 //================================================================================
1284 * \brief return pixmap for dlg icon
1287 //================================================================================
1289 QPixmap StdMeshersGUI_StdHypothesisCreator::icon() const
1291 QString hypIconName = tr( QString( "ICON_DLG_%1" ).arg( hypTypeName( hypType() ) ).toLatin1().data() );
1292 return SMESHGUI::resourceMgr()->loadPixmap( "SMESH", hypIconName );
1295 //================================================================================
1297 * \brief Return hypothesis type name to show in dlg
1300 //================================================================================
1302 QString StdMeshersGUI_StdHypothesisCreator::type() const
1304 return tr( QString( "SMESH_%1_HYPOTHESIS" ).arg( hypTypeName( hypType() ) ).toLatin1().data() );
1307 //================================================================================
1309 * \brief String to insert in "SMESH_%1_HYPOTHESIS" to get hypothesis type name
1310 * from message resouce file
1311 * \param t - hypothesis type
1312 * \retval QString - result string
1314 //================================================================================
1316 QString StdMeshersGUI_StdHypothesisCreator::hypTypeName( const QString& t ) const
1318 static QMap<QString,QString> types;
1319 if( types.isEmpty() )
1321 types.insert( "LocalLength", "LOCAL_LENGTH" );
1322 types.insert( "NumberOfSegments", "NB_SEGMENTS" );
1323 types.insert( "MaxElementArea", "MAX_ELEMENT_AREA" );
1324 types.insert( "MaxElementVolume", "MAX_ELEMENT_VOLUME" );
1325 types.insert( "StartEndLength", "START_END_LENGTH" );
1326 types.insert( "Deflection1D", "DEFLECTION1D" );
1327 types.insert( "Arithmetic1D", "ARITHMETIC_1D" );
1328 types.insert( "FixedPoints1D", "FIXED_POINTS_1D" );
1329 types.insert( "AutomaticLength", "AUTOMATIC_LENGTH" );
1330 types.insert( "ProjectionSource1D", "PROJECTION_SOURCE_1D" );
1331 types.insert( "ProjectionSource2D", "PROJECTION_SOURCE_2D" );
1332 types.insert( "ProjectionSource3D", "PROJECTION_SOURCE_3D" );
1333 types.insert( "ImportSource1D", "IMPORT_SOURCE_1D" );
1334 types.insert( "ImportSource2D", "IMPORT_SOURCE_2D" );
1335 types.insert( "NumberOfLayers", "NUMBER_OF_LAYERS" );
1336 types.insert( "LayerDistribution", "LAYER_DISTRIBUTION" );
1337 types.insert( "NumberOfLayers2D", "NUMBER_OF_LAYERS_2D" );
1338 types.insert( "LayerDistribution2D", "LAYER_DISTRIBUTION" );
1339 types.insert( "SegmentLengthAroundVertex", "SEGMENT_LENGTH_AROUND_VERTEX" );
1340 types.insert( "MaxLength", "MAX_LENGTH" );
1341 types.insert( "QuadrangleParams", "QUADRANGLE_PARAMS" );
1342 types.insert( "ViscousLayers", "VISCOUS_LAYERS" );
1346 if( types.contains( t ) )
1353 //=======================================================================
1354 //function : getCustomWidget
1355 //purpose : is called from buildStdFrame()
1356 //=======================================================================
1358 QWidget* StdMeshersGUI_StdHypothesisCreator::getCustomWidget( const StdParam & param,
1360 const int index) const
1363 if ( index < customWidgets()->count() ) {
1364 w = customWidgets()->at( index );
1366 w->setParent( parent );
1367 w->move( QPoint( 0, 0 ) );
1373 //================================================================================
1375 * \brief Set param value taken from a custom widget
1376 * \param param - SMESHGUI_GenericHypothesisCreator::StdParam structure
1377 * \param widget - widget presenting param
1378 * \retval bool - success flag
1380 * this method is called from getStdParamFromDlg()
1382 //================================================================================
1384 bool StdMeshersGUI_StdHypothesisCreator::getParamFromCustomWidget( StdParam & param,
1385 QWidget* widget) const
1387 if ( hypType()=="AutomaticLength" ) {
1388 SMESHGUI_SpinBox* w = dynamic_cast<SMESHGUI_SpinBox*>( widget );
1390 param.myValue = w->GetValue();
1394 if ( hypType() == "MaxLength" ) {
1398 if ( widget->inherits( "StdMeshersGUI_ObjectReferenceParamWdg" ))
1400 // show only 1st reference value
1401 if ( true /*widget == getWidgetForParam( 0 )*/) {
1402 const StdMeshersGUI_ObjectReferenceParamWdg * w =
1403 static_cast<const StdMeshersGUI_ObjectReferenceParamWdg*>( widget );
1404 param.myValue = w->GetValue();
1408 if ( widget->inherits( "StdMeshersGUI_LayerDistributionParamWdg" ))
1410 const StdMeshersGUI_LayerDistributionParamWdg * w =
1411 static_cast<const StdMeshersGUI_LayerDistributionParamWdg*>( widget );
1412 param.myValue = w->GetValue();
1415 if ( widget->inherits( "StdMeshersGUI_SubShapeSelectorWdg" ))
1417 const StdMeshersGUI_SubShapeSelectorWdg * w =
1418 static_cast<const StdMeshersGUI_SubShapeSelectorWdg*>( widget );
1419 param.myValue = w->GetValue();
1422 if ( widget->inherits( "StdMeshersGUI_QuadrangleParamWdg" ))
1424 //const StdMeshersGUI_QuadrangleParamWdg * w =
1425 // static_cast<const StdMeshersGUI_QuadrangleParamWdg*>( widget );
1426 param.myValue = "QuadType";
1429 if ( widget->inherits( "StdMeshersGUI_FixedPointsParamWdg" ))
1431 const StdMeshersGUI_FixedPointsParamWdg * w =
1432 static_cast<const StdMeshersGUI_FixedPointsParamWdg*>( widget );
1433 param.myValue = w->GetValue();
1436 if ( widget->inherits( "QCheckBox" ))
1438 //const QCheckBox * w = static_cast<const QCheckBox*>( widget );
1439 //param.myValue = w->isChecked();
1445 //================================================================================
1447 * \brief called when operation cancelled
1449 //================================================================================
1451 void StdMeshersGUI_StdHypothesisCreator::onReject()
1453 if ( hypType().startsWith("ProjectionSource" ) ||
1454 hypType().startsWith("ImportSource" ))
1456 // Uninstall filters of StdMeshersGUI_ObjectReferenceParamWdg
1457 deactivateObjRefParamWdg( customWidgets() );
1461 //================================================================================
1463 * \brief Update widgets dependent on paramWidget
1465 //================================================================================
1467 void StdMeshersGUI_StdHypothesisCreator::valueChanged( QWidget* paramWidget)
1469 if ( hypType() == "MaxLength" && paramWidget == getWidgetForParam(1) )
1471 getWidgetForParam(0)->setEnabled( !widget< QCheckBox >( 1 )->isChecked() );
1472 if ( !getWidgetForParam(0)->isEnabled() ) {
1473 StdMeshers::StdMeshers_MaxLength_var h =
1474 StdMeshers::StdMeshers_MaxLength::_narrow( initParamsHypothesis() );
1475 widget< QtxDoubleSpinBox >( 0 )->setValue( h->GetPreestimatedLength() );
1478 else if ( hypType().startsWith("ImportSource") && paramWidget == getWidgetForParam(1) )
1480 QCheckBox* toCopyMesh = (QCheckBox*) paramWidget;
1481 QCheckBox* toCopyGroups = widget< QCheckBox >( 2 );
1482 if ( !toCopyMesh->isChecked() )
1484 toCopyGroups->setChecked( false );
1485 toCopyGroups->setEnabled( false );
1489 toCopyGroups->setEnabled( true );
1494 //================================================================================
1498 //================================================================================
1500 bool StdMeshersGUI_StdHypothesisCreator::initVariableName(SMESH::ListOfParameters_var theParameters,
1501 StdParam &theParams,
1504 QString aVaribaleName = (theParameters->length() > order) ? QString(theParameters[order].in()) : QString("");
1505 theParams.isVariable = !aVaribaleName.isEmpty();
1506 if(theParams.isVariable)
1507 theParams.myValue = aVaribaleName;
1509 return theParams.isVariable;