Salome HOME
Add “Grading” parameter to Adaptive 1D hypothesis
[modules/smesh.git] / src / StdMeshersGUI / StdMeshersGUI_StdHypothesisCreator.cxx
1 // Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
10 //
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.
15 //
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
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 //  File   : StdMeshersGUI_StdHypothesisCreator.cxx
23 //  Author : Alexander SOLOVYOV, Open CASCADE S.A.S.
24 //  SMESH includes
25
26 #include "StdMeshersGUI_StdHypothesisCreator.h"
27
28 #include <SMESHGUI.h>
29 #include <SMESHGUI_SpinBox.h>
30 #include <SMESHGUI_HypothesesUtils.h>
31 #include <SMESHGUI_Utils.h>
32 #include <SMESHGUI_GEOMGenUtils.h>
33
34 #include <SMESH_TypeFilter.hxx>
35 #include <SMESH_NumberFilter.hxx>
36
37 #include "StdMeshersGUI_FixedPointsParamWdg.h"
38 #include "StdMeshersGUI_LayerDistributionParamWdg.h"
39 #include "StdMeshersGUI_ObjectReferenceParamWdg.h"
40 #include "StdMeshersGUI_QuadrangleParamWdg.h"
41 #include "StdMeshersGUI_SubShapeSelectorWdg.h"
42 #include "StdMeshersGUI_RadioButtonsGrpWdg.h"
43
44 #include <SALOMEDSClient_Study.hxx>
45
46 #include <GEOM_wrap.hxx>
47
48 // SALOME GUI includes
49 #include <SUIT_ResourceMgr.h>
50
51 // IDL includes
52 #include <SALOMEconfig.h>
53 #include CORBA_SERVER_HEADER(SMESH_BasicHypothesis)
54 #include CORBA_SERVER_HEADER(SMESH_Mesh)
55 #include CORBA_SERVER_HEADER(SMESH_Group)
56
57 // Qt includes
58 #include <QHBoxLayout>
59 #include <QSlider>
60 #include <QLabel>
61 #include <QCheckBox>
62 #include <QButtonGroup>
63
64 const double VALUE_MAX = 1.0e+15, // COORD_MAX
65              VALUE_MAX_2  = VALUE_MAX * VALUE_MAX,
66              VALUE_MAX_3  = VALUE_MAX_2 * VALUE_MAX,
67              VALUE_SMALL = 1.0e-15,
68              VALUE_SMALL_2 = VALUE_SMALL * VALUE_SMALL,
69              VALUE_SMALL_3 = VALUE_SMALL_2 * VALUE_SMALL;
70
71 //================================================================================
72 /*!
73  * \brief Constructor
74   * \param type - hypothesis type
75  */
76 //================================================================================
77
78 StdMeshersGUI_StdHypothesisCreator::StdMeshersGUI_StdHypothesisCreator( const QString& type )
79 : SMESHGUI_GenericHypothesisCreator( type )
80 {
81 }
82
83 //================================================================================
84 /*!
85  * \brief Destructor
86  */
87 //================================================================================
88
89 StdMeshersGUI_StdHypothesisCreator::~StdMeshersGUI_StdHypothesisCreator()
90 {
91 }
92
93 //================================================================================
94 /*!
95  * \brief Return widget for i-th hypothesis parameter (got from myParamWidgets)
96   * \param i - index of hypothesis parameter
97   * \retval QWidget* - found widget
98  */
99 //================================================================================
100
101 QWidget* StdMeshersGUI_StdHypothesisCreator::getWidgetForParam( int i ) const
102 {
103   QWidget* w = 0;
104   if ( isCreation() ) ++i; // skip widget of 'name' parameter
105
106   if ( i < myCustomWidgets.count() ) {
107     QList<QWidget*>::const_iterator anIt  = myCustomWidgets.begin();
108     QList<QWidget*>::const_iterator aLast = myCustomWidgets.end();
109     for ( int j = 0 ; !w && anIt != aLast; ++anIt, ++j )
110       if ( i == j )
111         w = *anIt;
112   }
113   if ( !w ) {
114     // list has no at() const, so we iterate
115     QList<QWidget*>::const_iterator anIt  = widgets().begin();
116     QList<QWidget*>::const_iterator aLast = widgets().end();
117     for( int j = 0; !w && anIt!=aLast; anIt++, ++j ) {
118       if ( i == j )
119         w = *anIt;
120     }
121   }
122   return w;
123 }
124
125 //================================================================================
126 /*!
127  * \brief Allow modifing myCustomWidgets in const methods
128   * \retval ListOfWidgets* - non-const pointer to myCustomWidgets
129  */
130 //================================================================================
131
132 StdMeshersGUI_StdHypothesisCreator::ListOfWidgets*
133 StdMeshersGUI_StdHypothesisCreator::customWidgets() const
134 {
135   return const_cast< ListOfWidgets* >( & myCustomWidgets );
136 }
137
138 //================================================================================
139 /*!
140  * \brief Builds dlg layout
141   * \retval QFrame* - the built widget
142  */
143 //================================================================================
144
145 QFrame* StdMeshersGUI_StdHypothesisCreator::buildFrame()
146 {
147   return buildStdFrame();
148 }
149
150 //================================================================================
151 /*!
152  * \brief Initialise parameter values in controls
153  */
154 //================================================================================
155
156 void StdMeshersGUI_StdHypothesisCreator::retrieveParams() const
157 {
158   // buildStdFrame() sets values itself calling stdParams()
159
160   if ( hypType().startsWith("ProjectionSource" ))
161   {
162     // we use this method to connect depending custom widgets
163     StdMeshersGUI_ObjectReferenceParamWdg* widgetToActivate = 0;
164     ListOfWidgets::const_iterator anIt = myCustomWidgets.begin();
165     for ( ; anIt != myCustomWidgets.end(); anIt++)
166     {
167       if ( *anIt && (*anIt)->inherits("StdMeshersGUI_ObjectReferenceParamWdg"))
168       {
169         StdMeshersGUI_ObjectReferenceParamWdg * w1 =
170           ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
171         ListOfWidgets::const_iterator anIt2 = anIt;
172         for ( ++anIt2; anIt2 != myCustomWidgets.end(); anIt2++)
173           if ( *anIt2 && (*anIt2)->inherits("StdMeshersGUI_ObjectReferenceParamWdg"))
174           {
175             StdMeshersGUI_ObjectReferenceParamWdg * w2 =
176               ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt2 );
177             w1->AvoidSimultaneousSelection( w2 );
178           }
179         if ( !widgetToActivate )
180           widgetToActivate = w1;
181       }
182     }
183     if ( widgetToActivate )
184       widgetToActivate->activateSelection();
185   }
186
187   if ( dlg() )
188     dlg()->setMinimumSize( dlg()->minimumSizeHint().width(), dlg()->minimumSizeHint().height() );
189 }
190
191 namespace {
192
193   //================================================================================
194   /*!
195    * \brief Widget: slider with left and right labels
196    */
197   //================================================================================
198
199   class TDoubleSliderWith2Labels: public QWidget
200   {
201   public:
202     TDoubleSliderWith2Labels( const QString& leftLabel, const QString& rightLabel,
203                               const double   initValue, const double   bottom,
204                               const double   top      , const double   precision,
205                               QWidget *      parent=0 , const char *   name=0 )
206       :QWidget(parent), _bottom(bottom), _precision(precision)
207     {
208       setObjectName(name);
209
210       QHBoxLayout* aHBoxL = new QHBoxLayout(this);
211
212       if ( !leftLabel.isEmpty() ) {
213         QLabel* aLeftLabel = new QLabel( this );
214         aLeftLabel->setText( leftLabel );
215         aHBoxL->addWidget( aLeftLabel );
216       }
217
218       _slider = new QSlider( Qt::Horizontal, this );
219       _slider->setRange( 0, toInt( top ));
220       _slider->setValue( toInt( initValue ));
221       aHBoxL->addWidget( _slider );
222
223       if ( !rightLabel.isEmpty() ) {
224         QLabel* aRightLabel = new QLabel( this );
225         aRightLabel->setText( rightLabel );
226         aHBoxL->addWidget( aRightLabel );
227       }
228
229       setLayout( aHBoxL );
230     }
231     double value() const { return _bottom + _slider->value() * _precision; }
232     QSlider * getSlider() const { return _slider; }
233     int toInt( double val ) const { return (int) ceil(( val - _bottom ) / _precision ); }
234   private:
235     double _bottom, _precision;
236     QSlider * _slider;
237   };
238
239   //================================================================================
240   /*!
241    * \brief Retrieve GEOM_Object held by widget
242    */
243   //================================================================================
244
245   inline GEOM::GEOM_Object_var geomFromWdg(const QWidget* wdg)
246   {
247     const StdMeshersGUI_ObjectReferenceParamWdg * objRefWdg =
248       dynamic_cast<const StdMeshersGUI_ObjectReferenceParamWdg*>( wdg );
249     if ( objRefWdg )
250       return objRefWdg->GetObject< GEOM::GEOM_Object >();
251
252     return GEOM::GEOM_Object::_nil();
253   }
254   //================================================================================
255   /*!
256    * \brief Retrieve SMESH_Mesh held by widget
257    */
258   //================================================================================
259
260   inline SMESH::SMESH_Mesh_var meshFromWdg(const QWidget* wdg)
261   {
262     const StdMeshersGUI_ObjectReferenceParamWdg * objRefWdg =
263       dynamic_cast<const StdMeshersGUI_ObjectReferenceParamWdg*>( wdg );
264     if ( objRefWdg )
265       return objRefWdg->GetObject< SMESH::SMESH_Mesh >();
266
267     return SMESH::SMESH_Mesh::_nil();
268   }
269   //================================================================================
270   /*!
271    * \brief Retrieve SMESH_Mesh held by widget
272    */
273   //================================================================================
274
275   inline SMESH::ListOfGroups_var groupsFromWdg(const QWidget* wdg)
276   {
277     SMESH::ListOfGroups_var groups = new SMESH::ListOfGroups;
278     const StdMeshersGUI_ObjectReferenceParamWdg * objRefWdg =
279       dynamic_cast<const StdMeshersGUI_ObjectReferenceParamWdg*>( wdg );
280     if ( objRefWdg )
281     {
282       groups->length( objRefWdg->NbObjects() );
283       for ( unsigned i = 0; i < groups->length(); ++i )
284         groups[i] = objRefWdg->GetObject< SMESH::SMESH_GroupBase >(i);
285     }
286     return groups;
287   }
288   //================================================================================
289   /*!
290    * \brief creates a filter for selection of shapes of given dimension
291     * \param dim - dimension
292     * \param subShapeType - required type of sub-shapes, number of which must be \a nbSubShapes
293     * \param nbSubShapes - number of sub-shapes of given type
294     * \param closed - required closeness flag of a shape
295     * \retval SUIT_SelectionFilter* - created filter
296    */
297   //================================================================================
298
299   SUIT_SelectionFilter* filterForShapeOfDim(const int        dim,
300                                             TopAbs_ShapeEnum subShapeType = TopAbs_SHAPE,
301                                             const int        nbSubShapes = 0,
302                                             bool             closed = false)
303   {
304     TColStd_MapOfInteger shapeTypes;
305     switch ( dim ) {
306     case 0: shapeTypes.Add( TopAbs_VERTEX ); break;
307     case 1:
308       if ( subShapeType == TopAbs_SHAPE ) subShapeType = TopAbs_EDGE;
309       shapeTypes.Add( TopAbs_EDGE );
310       shapeTypes.Add( TopAbs_COMPOUND ); // for a group
311       break;
312     case 2:
313       if ( subShapeType == TopAbs_SHAPE ) subShapeType = TopAbs_FACE;
314       shapeTypes.Add( TopAbs_FACE );
315       shapeTypes.Add( TopAbs_COMPOUND ); // for a group
316       break;
317     case 3:
318       shapeTypes.Add( TopAbs_SHELL );
319       shapeTypes.Add( TopAbs_SOLID );
320       shapeTypes.Add( TopAbs_COMPSOLID );
321       shapeTypes.Add( TopAbs_COMPOUND );
322       break;
323     }
324     return new SMESH_NumberFilter("GEOM", subShapeType, nbSubShapes,
325                                   shapeTypes, GEOM::GEOM_Object::_nil(), closed);
326   }
327
328   //================================================================================
329   /*!
330    * \brief Create a widget for object selection
331     * \param object - initial object
332     * \param filter - selection filter
333     * \retval QWidget* - created widget
334    */
335   //================================================================================
336
337   QWidget* newObjRefParamWdg( SUIT_SelectionFilter* filter,
338                               CORBA::Object_var     object)
339   {
340     StdMeshersGUI_ObjectReferenceParamWdg* w =
341       new StdMeshersGUI_ObjectReferenceParamWdg( filter, 0);
342     w->SetObject( object.in() );
343     return w;
344   }
345   QWidget* newObjRefParamWdg( SUIT_SelectionFilter*    filter,
346                               SMESH::string_array_var& objEntries)
347   {
348     StdMeshersGUI_ObjectReferenceParamWdg* w =
349       new StdMeshersGUI_ObjectReferenceParamWdg( filter, 0, /*multiSel=*/true);
350     //RNV: Firstly, activate selection, then set objects
351     w->activateSelection();
352     w->SetObjects( objEntries );
353     return w;
354   }
355
356   //================================================================================
357   /*!
358    * \brief calls deactivateSelection() for StdMeshersGUI_ObjectReferenceParamWdg
359     * \param widgetList - list of widgets
360    */
361   //================================================================================
362
363   void deactivateObjRefParamWdg( QList<QWidget*>* widgetList )
364   {
365     StdMeshersGUI_ObjectReferenceParamWdg* w = 0;
366     QList<QWidget*>::iterator anIt  = widgetList->begin();
367     QList<QWidget*>::iterator aLast = widgetList->end();
368     for ( ; anIt != aLast; anIt++ ) {
369       if ( (*anIt) && (*anIt)->inherits( "StdMeshersGUI_ObjectReferenceParamWdg" ))
370       {
371         w = (StdMeshersGUI_ObjectReferenceParamWdg* )( *anIt );
372         w->deactivateSelection();
373       }
374     }
375   }
376 }
377
378 //================================================================================
379 /*!
380  * \brief Check parameter values before accept()
381   * \retval bool - true if OK
382  */
383 //================================================================================
384
385 bool StdMeshersGUI_StdHypothesisCreator::checkParams( QString& msg ) const
386 {
387   if( !SMESHGUI_GenericHypothesisCreator::checkParams( msg ) )
388     return false;
389
390   // check if object reference parameter is set, as it has no default value
391   bool ok = true;
392   if ( hypType().startsWith("ProjectionSource" ))
393   {
394     StdMeshersGUI_ObjectReferenceParamWdg* w =
395       widget< StdMeshersGUI_ObjectReferenceParamWdg >( 0 );
396     ok = ( w->IsObjectSelected() );
397     if ( !ok ) w->SetObject( CORBA::Object::_nil() );
398     int nbAssocVert = ( hypType() == "ProjectionSource1D" ? 1 : 2 );
399     int nbNonEmptyAssoc = 0;
400     for ( int i = 0; ok && i < nbAssocVert*2; i += 2)
401     {
402       QString srcV, tgtV;
403       StdMeshersGUI_ObjectReferenceParamWdg* w1 =
404         widget< StdMeshersGUI_ObjectReferenceParamWdg >( i+2 );
405       StdMeshersGUI_ObjectReferenceParamWdg* w2 =
406         widget< StdMeshersGUI_ObjectReferenceParamWdg >( i+3 );
407       srcV = w1->GetValue();
408       tgtV = w2->GetValue();
409       ok = (( srcV.isEmpty()  && tgtV.isEmpty() ) ||
410             ( !srcV.isEmpty() && !tgtV.isEmpty() && srcV != tgtV ));
411       if ( !ok ) {
412         w1->SetObject( CORBA::Object::_nil() );
413         w2->SetObject( CORBA::Object::_nil() );
414       }
415       nbNonEmptyAssoc += !srcV.isEmpty();
416     }
417     if ( ok && nbNonEmptyAssoc == 1 && nbAssocVert == 2 )
418     {
419       // only one pair of VERTEXes is given for a FACE,
420       // then the FACE must have only one VERTEX
421       GEOM::GEOM_Object_var face = w->GetObject< GEOM::GEOM_Object >();
422
423       GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen();
424       _PTR(Study)         aStudy = SMESH::GetActiveStudyDocument();
425       GEOM::GEOM_IShapesOperations_wrap shapeOp;
426       if ( !geomGen->_is_nil() && aStudy )
427         shapeOp = geomGen->GetIShapesOperations( aStudy->StudyId() );
428       if ( !shapeOp->_is_nil() )
429       {
430         GEOM::ListOfLong_var vertices =
431           shapeOp->GetAllSubShapesIDs (face, GEOM::VERTEX, /*isSorted=*/false);
432         ok = ( vertices->length() == 1 );
433       }
434     }
435     // Uninstall filters of StdMeshersGUI_ObjectReferenceParamWdg
436     if ( ok )
437       deactivateObjRefParamWdg( customWidgets() );
438   }
439   else if ( hypType().startsWith("ImportSource" ))
440   {
441     StdMeshersGUI_ObjectReferenceParamWdg* w =
442       widget< StdMeshersGUI_ObjectReferenceParamWdg >( 0 );
443     ok = ( w->IsObjectSelected() );
444   }
445   else if ( hypType() == "LayerDistribution" || hypType() == "LayerDistribution2D" )
446   {
447     StdMeshersGUI_LayerDistributionParamWdg* w = 
448       widget< StdMeshersGUI_LayerDistributionParamWdg >( 0 );
449     ok = ( w && w->IsOk() );
450   }
451
452   return ok;
453 }
454
455 //================================================================================
456 /*!
457  * \brief Store params from GUI controls to a hypothesis
458   * \retval QString - text representation of parameters
459  */
460 //================================================================================
461
462 QString StdMeshersGUI_StdHypothesisCreator::storeParams() const
463 {
464   ListOfStdParams params;
465   bool res = getStdParamFromDlg( params );
466   if( isCreation() )
467   {
468     SMESH::SetName( SMESH::FindSObject( hypothesis() ), params[0].myValue.toString().toLatin1().data() );
469     params.erase( params.begin() );
470   }
471
472   QString valueStr = stdParamValues( params );
473   //QStringList aVariablesList = getVariablesFromDlg();
474
475   if( res && !params.isEmpty() )
476   {
477     if( hypType()=="LocalLength" )
478     {
479       StdMeshers::StdMeshers_LocalLength_var h =
480         StdMeshers::StdMeshers_LocalLength::_narrow( hypothesis() );
481
482       h->SetVarParameter( params[0].text(), "SetLength" );
483       h->SetLength( params[0].myValue.toDouble() );
484       h->SetVarParameter( params[1].text(), "SetPrecision" );
485       h->SetPrecision( params[1].myValue.toDouble() );
486     }
487     else if( hypType()=="MaxLength" )
488     {
489       StdMeshers::StdMeshers_MaxLength_var h =
490         StdMeshers::StdMeshers_MaxLength::_narrow( hypothesis() );
491
492       h->SetVarParameter( params[0].text(), "SetLength" );
493       h->SetLength( params[0].myValue.toDouble() );
494       h->SetUsePreestimatedLength( widget< QCheckBox >( 1 )->isChecked() );
495       if ( !h->HavePreestimatedLength() && !h->_is_equivalent( initParamsHypothesis() )) {
496         StdMeshers::StdMeshers_MaxLength_var hInit =
497           StdMeshers::StdMeshers_MaxLength::_narrow( initParamsHypothesis() );
498         h->SetPreestimatedLength( hInit->GetPreestimatedLength() );
499       }
500     }
501     else if( hypType()=="SegmentLengthAroundVertex" )
502     {
503       StdMeshers::StdMeshers_SegmentLengthAroundVertex_var h =
504         StdMeshers::StdMeshers_SegmentLengthAroundVertex::_narrow( hypothesis() );
505
506       h->SetVarParameter( params[0].text(), "SetLength" );
507       h->SetLength( params[0].myValue.toDouble() );
508     }
509     else if( hypType()=="Arithmetic1D" )
510     {
511       StdMeshers::StdMeshers_Arithmetic1D_var h =
512         StdMeshers::StdMeshers_Arithmetic1D::_narrow( hypothesis() );
513
514       StdMeshersGUI_SubShapeSelectorWdg* w = 
515         widget< StdMeshersGUI_SubShapeSelectorWdg >( 2 );
516
517       h->SetVarParameter( params[0].text(), "SetStartLength" );
518       h->SetStartLength( params[0].myValue.toDouble() );
519       h->SetVarParameter( params[1].text(), "SetEndLength" );
520       h->SetEndLength( params[1].myValue.toDouble() );
521       if (w) {
522         h->SetReversedEdges( w->GetListOfIDs() );
523         h->SetObjectEntry( w->GetMainShapeEntry() );
524       }
525     }
526     else if( hypType()=="GeometricProgression" )
527     {
528       StdMeshers::StdMeshers_Geometric1D_var h =
529         StdMeshers::StdMeshers_Geometric1D::_narrow( hypothesis() );
530
531       StdMeshersGUI_SubShapeSelectorWdg* w = 
532         widget< StdMeshersGUI_SubShapeSelectorWdg >( 2 );
533
534       h->SetVarParameter( params[0].text(), "SetStartLength" );
535       h->SetStartLength( params[0].myValue.toDouble() );
536       h->SetVarParameter( params[1].text(), "SetCommonRatio" );
537       h->SetCommonRatio( params[1].myValue.toDouble() );
538       if (w) {
539         h->SetReversedEdges( w->GetListOfIDs() );
540         h->SetObjectEntry( w->GetMainShapeEntry() );
541       }
542     }
543     else if( hypType()=="FixedPoints1D" )
544     {
545       StdMeshers::StdMeshers_FixedPoints1D_var h =
546         StdMeshers::StdMeshers_FixedPoints1D::_narrow( hypothesis() );
547
548       StdMeshersGUI_FixedPointsParamWdg* w1 = 
549         widget< StdMeshersGUI_FixedPointsParamWdg >( 0 );
550
551       StdMeshersGUI_SubShapeSelectorWdg* w2 = 
552         widget< StdMeshersGUI_SubShapeSelectorWdg >( 1 );
553
554       if (w1) {
555         h->SetPoints( w1->GetListOfPoints() );
556         h->SetNbSegments( w1->GetListOfSegments() );
557       }
558       if (w2) {
559         h->SetReversedEdges( w2->GetListOfIDs() );
560         h->SetObjectEntry( w2->GetMainShapeEntry() );
561       }
562     }
563     else if( hypType()=="MaxElementArea" )
564     {
565       StdMeshers::StdMeshers_MaxElementArea_var h =
566         StdMeshers::StdMeshers_MaxElementArea::_narrow( hypothesis() );
567       h->SetVarParameter( params[0].text(), "SetMaxElementArea" );
568       h->SetMaxElementArea( params[0].myValue.toDouble() );
569     }
570     else if( hypType()=="MaxElementVolume" )
571     {
572       StdMeshers::StdMeshers_MaxElementVolume_var h =
573         StdMeshers::StdMeshers_MaxElementVolume::_narrow( hypothesis() );
574
575       h->SetVarParameter( params[0].text(), "SetMaxElementVolume" );
576       h->SetMaxElementVolume( params[0].myValue.toDouble() );
577     }
578     else if( hypType()=="StartEndLength" )
579     {
580       StdMeshers::StdMeshers_StartEndLength_var h =
581         StdMeshers::StdMeshers_StartEndLength::_narrow( hypothesis() );
582
583       StdMeshersGUI_SubShapeSelectorWdg* w = 
584         widget< StdMeshersGUI_SubShapeSelectorWdg >( 2 );
585
586       h->SetVarParameter( params[0].text(), "SetStartLength" );
587       h->SetStartLength( params[0].myValue.toDouble() );
588       h->SetVarParameter( params[1].text(), "SetEndLength" );
589       h->SetEndLength( params[1].myValue.toDouble() );
590       if (w) {
591         h->SetReversedEdges( w->GetListOfIDs() );
592         h->SetObjectEntry( w->GetMainShapeEntry() );
593       }
594     }
595     else if( hypType()=="Deflection1D" )
596     {
597       StdMeshers::StdMeshers_Deflection1D_var h =
598         StdMeshers::StdMeshers_Deflection1D::_narrow( hypothesis() );
599       h->SetVarParameter( params[0].text(), "SetDeflection" );
600       h->SetDeflection( params[0].myValue.toDouble() );
601     }
602     else if( hypType()=="Adaptive1D" )
603     {
604       StdMeshers::StdMeshers_Adaptive1D_var h =
605         StdMeshers::StdMeshers_Adaptive1D::_narrow( hypothesis() );
606       h->SetVarParameter( params[0].text(), "SetMinSize" );
607       h->SetMinSize( params[0].myValue.toDouble() );
608       h->SetVarParameter( params[0].text(), "SetMaxSize" );
609       h->SetMaxSize( params[1].myValue.toDouble() );
610       h->SetVarParameter( params[0].text(), "SetDeflection" );
611       h->SetDeflection( params[2].myValue.toDouble() );
612       h->SetVarParameter( params[0].text(), "SetGrading" );
613       h->SetGrading( params[3].myValue.toDouble() );
614     }
615     else if( hypType()=="AutomaticLength" )
616     {
617       StdMeshers::StdMeshers_AutomaticLength_var h =
618         StdMeshers::StdMeshers_AutomaticLength::_narrow( hypothesis() );
619
620       h->SetVarParameter( params[0].text(), "SetFineness" );
621       h->SetFineness( params[0].myValue.toDouble() );
622     }
623     else if( hypType()=="NumberOfLayers" )
624     {
625       StdMeshers::StdMeshers_NumberOfLayers_var h =
626         StdMeshers::StdMeshers_NumberOfLayers::_narrow( hypothesis() );
627
628       h->SetVarParameter( params[0].text(), "SetNumberOfLayers" );
629       h->SetNumberOfLayers( params[0].myValue.toInt() );
630     }
631     else if( hypType()=="LayerDistribution" )
632     {
633       StdMeshers::StdMeshers_LayerDistribution_var h =
634         StdMeshers::StdMeshers_LayerDistribution::_narrow( hypothesis() );
635       StdMeshersGUI_LayerDistributionParamWdg* w = 
636         widget< StdMeshersGUI_LayerDistributionParamWdg >( 0 );
637       
638       h->SetLayerDistribution( w->GetHypothesis() );
639     }
640     else if( hypType()=="NumberOfLayers2D" )
641     {
642       StdMeshers::StdMeshers_NumberOfLayers2D_var h =
643         StdMeshers::StdMeshers_NumberOfLayers2D::_narrow( hypothesis() );
644
645       h->SetVarParameter( params[0].text(), "SetNumberOfLayers" );
646       h->SetNumberOfLayers( params[0].myValue.toInt() );
647     }
648     else if( hypType()=="LayerDistribution2D" )
649     {
650       StdMeshers::StdMeshers_LayerDistribution2D_var h =
651         StdMeshers::StdMeshers_LayerDistribution2D::_narrow( hypothesis() );
652       StdMeshersGUI_LayerDistributionParamWdg* w = 
653         widget< StdMeshersGUI_LayerDistributionParamWdg >( 0 );
654       
655       h->SetLayerDistribution( w->GetHypothesis() );
656     }
657     else if( hypType()=="ProjectionSource1D" )
658     {
659       StdMeshers::StdMeshers_ProjectionSource1D_var h =
660         StdMeshers::StdMeshers_ProjectionSource1D::_narrow( hypothesis() );
661
662       h->SetSourceEdge       ( geomFromWdg ( getWidgetForParam( 0 )));
663       h->SetSourceMesh       ( meshFromWdg ( getWidgetForParam( 1 )));
664       h->SetVertexAssociation( geomFromWdg ( getWidgetForParam( 2 )),
665                                geomFromWdg ( getWidgetForParam( 3 )));
666     }
667     else if( hypType()=="ProjectionSource2D" )
668     {
669       StdMeshers::StdMeshers_ProjectionSource2D_var h =
670         StdMeshers::StdMeshers_ProjectionSource2D::_narrow( hypothesis() );
671
672       h->SetSourceFace       ( geomFromWdg ( getWidgetForParam( 0 )));
673       h->SetSourceMesh       ( meshFromWdg ( getWidgetForParam( 1 )));
674       h->SetVertexAssociation( geomFromWdg ( getWidgetForParam( 2 )), // src1
675                                geomFromWdg ( getWidgetForParam( 4 )), // src2
676                                geomFromWdg ( getWidgetForParam( 3 )), // tgt1
677                                geomFromWdg ( getWidgetForParam( 5 ))); // tgt2
678     }
679     else if( hypType()=="ProjectionSource3D" )
680     {
681       StdMeshers::StdMeshers_ProjectionSource3D_var h =
682         StdMeshers::StdMeshers_ProjectionSource3D::_narrow( hypothesis() );
683
684       h->SetSource3DShape    ( geomFromWdg ( getWidgetForParam( 0 )));
685       h->SetSourceMesh       ( meshFromWdg ( getWidgetForParam( 1 )));
686       h->SetVertexAssociation( geomFromWdg ( getWidgetForParam( 2 )), // src1
687                                geomFromWdg ( getWidgetForParam( 4 )), // src2
688                                geomFromWdg ( getWidgetForParam( 3 )), // tgt1
689                                geomFromWdg ( getWidgetForParam( 5 ))); // tgt2
690     }
691     else if( hypType()=="ImportSource1D" )
692     {
693       StdMeshers::StdMeshers_ImportSource1D_var h =
694         StdMeshers::StdMeshers_ImportSource1D::_narrow( hypothesis() );
695
696       SMESH::ListOfGroups_var groups = groupsFromWdg( getWidgetForParam( 0 ));
697       h->SetSourceEdges( groups.in() );
698       QCheckBox* toCopyMesh   = widget< QCheckBox >( 1 );
699       QCheckBox* toCopyGroups = widget< QCheckBox >( 2 );
700       h->SetCopySourceMesh( toCopyMesh->isChecked(), toCopyGroups->isChecked());
701     }
702     else if( hypType()=="ImportSource2D" )
703     {
704       StdMeshers::StdMeshers_ImportSource2D_var h =
705         StdMeshers::StdMeshers_ImportSource2D::_narrow( hypothesis() );
706
707       SMESH::ListOfGroups_var groups = groupsFromWdg( getWidgetForParam( 0 ));
708       h->SetSourceFaces( groups.in() );
709       QCheckBox* toCopyMesh   = widget< QCheckBox >( 1 );
710       QCheckBox* toCopyGroups = widget< QCheckBox >( 2 );
711       h->SetCopySourceMesh( toCopyMesh->isChecked(), toCopyGroups->isChecked());
712     }
713     else if( hypType()=="ViscousLayers" )
714     {
715       StdMeshers::StdMeshers_ViscousLayers_var h =
716         StdMeshers::StdMeshers_ViscousLayers::_narrow( hypothesis() );
717
718       h->SetVarParameter( params[0].text(), "SetTotalThickness" );
719       h->SetTotalThickness( params[0].myValue.toDouble() );
720       h->SetVarParameter( params[1].text(), "SetNumberLayers" );
721       h->SetNumberLayers  ( params[1].myValue.toInt() );
722       h->SetVarParameter( params[2].text(), "SetStretchFactor" );
723       h->SetStretchFactor ( params[2].myValue.toDouble() );
724
725       if ( StdMeshersGUI_SubShapeSelectorWdg* idsWg = 
726            widget< StdMeshersGUI_SubShapeSelectorWdg >( 4 ))
727       {
728         h->SetFaces( idsWg->GetListOfIDs(), params[3].myValue.toInt() );
729       }
730     }
731     else if( hypType()=="ViscousLayers2D" )
732     {
733       StdMeshers::StdMeshers_ViscousLayers2D_var h =
734         StdMeshers::StdMeshers_ViscousLayers2D::_narrow( hypothesis() );
735
736       h->SetVarParameter( params[0].text(), "SetTotalThickness" );
737       h->SetTotalThickness( params[0].myValue.toDouble() );
738       h->SetVarParameter( params[1].text(), "SetNumberLayers" );
739       h->SetNumberLayers  ( params[1].myValue.toInt() );
740       h->SetVarParameter( params[2].text(), "SetStretchFactor" );
741       h->SetStretchFactor ( params[2].myValue.toDouble() );
742
743       if ( StdMeshersGUI_SubShapeSelectorWdg* idsWg =
744            widget< StdMeshersGUI_SubShapeSelectorWdg >( 4 ))
745       {
746         h->SetEdges( idsWg->GetListOfIDs(), params[3].myValue.toInt() );
747       }
748     }
749     // else if( hypType()=="QuadrangleParams" )
750     // {
751     //   StdMeshers::StdMeshers_QuadrangleParams_var h =
752     //     StdMeshers::StdMeshers_QuadrangleParams::_narrow( hypothesis() );
753     //   StdMeshersGUI_SubShapeSelectorWdg* w1 =
754     //     widget< StdMeshersGUI_SubShapeSelectorWdg >( 0 );
755     //   StdMeshersGUI_QuadrangleParamWdg* w2 =
756     //     widget< StdMeshersGUI_QuadrangleParamWdg >( 1 );
757     //   if (w1 && w2) {
758     //     if (w1->GetListSize() > 0) {
759     //       h->SetTriaVertex(w1->GetListOfIDs()[0]); // getlist must be called once
760     //       const char * entry = w1->GetMainShapeEntry();
761     //       h->SetObjectEntry(entry);
762     //     }
763     //     h->SetQuadType(StdMeshers::QuadType(w2->GetType()));
764     //   }
765     // }
766   }
767   return valueStr;
768 }
769
770 //================================================================================
771 /*!
772  * \brief Return parameter values as SMESHGUI_GenericHypothesisCreator::StdParam
773  * \param p - list of parameters
774  * \retval bool - success flag
775  *
776  * Is called from SMESHGUI_GenericHypothesisCreator::buildStdFrame().
777  * Parameters will be shown using "standard" controls:
778  *   Int by QtxIntSpinBox
779  *   Double by SMESHGUI_SpinBox
780  *   String by QLineEdit
781  * getCustomWidget() allows to redefine control for a parameter
782  */
783 //================================================================================
784
785 bool StdMeshersGUI_StdHypothesisCreator::stdParams( ListOfStdParams& p ) const
786 {
787   bool res = true;
788   SMESHGUI_GenericHypothesisCreator::StdParam item;
789
790   p.clear();
791   customWidgets()->clear();
792   if( isCreation() )
793   {
794     HypothesisData* data = SMESH::GetHypothesisData( hypType() );
795     item.myName = tr( "SMESH_NAME" );
796     item.myValue = data ? hypName() : QString();
797     p.append( item );
798     customWidgets()->append(0);
799   }
800
801   SMESH::SMESH_Hypothesis_var hyp = initParamsHypothesis();
802   //SMESH::ListOfParameters_var aParameters = hyp->GetLastParameters();
803
804   if( hypType()=="LocalLength" )
805   {
806     StdMeshers::StdMeshers_LocalLength_var h =
807       StdMeshers::StdMeshers_LocalLength::_narrow( hyp );
808
809     item.myName = tr("SMESH_LOCAL_LENGTH_PARAM");
810     if(!initVariableName( hyp, item, "SetLength"))
811       item.myValue = h->GetLength();
812     p.append( item );     
813
814     item.myName = tr("SMESH_LOCAL_LENGTH_PRECISION");
815     if(!initVariableName( hyp, item, "SetPrecision"))
816       item.myValue = h->GetPrecision(); 
817     p.append( item );
818   }
819   else if( hypType()=="MaxLength" )
820   {
821     StdMeshers::StdMeshers_MaxLength_var h =
822       StdMeshers::StdMeshers_MaxLength::_narrow( hyp );
823     // try to set a right preestimated length to edited hypothesis
824     bool noPreestimatedAtEdition = false;
825     if ( !isCreation() ) {
826       StdMeshers::StdMeshers_MaxLength_var initHyp =
827         StdMeshers::StdMeshers_MaxLength::_narrow( initParamsHypothesis(true) );
828       noPreestimatedAtEdition =
829         ( initHyp->_is_nil() || !initHyp->HavePreestimatedLength() );
830       if ( !noPreestimatedAtEdition )
831         h->SetPreestimatedLength( initHyp->GetPreestimatedLength() );
832     }
833
834     item.myName = tr("SMESH_LOCAL_LENGTH_PARAM");
835     if(!initVariableName( hyp, item, "SetLength"))
836       item.myValue = h->GetLength();
837     p.append( item );
838     customWidgets()->append(0);
839
840     item.myName = tr("SMESH_USE_PREESTIMATED_LENGTH");
841     p.append( item );
842     QCheckBox* aQCheckBox = new QCheckBox(dlg());
843     if ( !noPreestimatedAtEdition && h->HavePreestimatedLength() ) {
844       aQCheckBox->setChecked( h->GetUsePreestimatedLength() );
845       connect( aQCheckBox, SIGNAL(  stateChanged(int) ), this, SLOT( onValueChanged() ) );
846     }
847     else {
848       aQCheckBox->setChecked( false );
849       aQCheckBox->setEnabled( false );
850     }
851     customWidgets()->append( aQCheckBox );
852   }
853   else if( hypType()=="SegmentLengthAroundVertex" )
854   {
855     StdMeshers::StdMeshers_SegmentLengthAroundVertex_var h =
856       StdMeshers::StdMeshers_SegmentLengthAroundVertex::_narrow( hyp );
857
858     item.myName = tr("SMESH_LOCAL_LENGTH_PARAM");
859     if(!initVariableName( hyp, item, "SetLength"))
860       item.myValue = h->GetLength();
861     
862     p.append( item );
863   }
864   else if( hypType()=="Arithmetic1D" )
865   {
866     StdMeshers::StdMeshers_Arithmetic1D_var h =
867       StdMeshers::StdMeshers_Arithmetic1D::_narrow( hyp );
868
869     item.myName = tr( "SMESH_START_LENGTH_PARAM" );
870     if(!initVariableName( hyp, item, "SetStartLength" ))
871       item.myValue = h->GetLength( true );
872     p.append( item );
873
874     customWidgets()->append (0);
875
876     item.myName = tr( "SMESH_END_LENGTH_PARAM" );
877     if(!initVariableName( hyp, item, "SetEndLength" ))
878       item.myValue = h->GetLength( false );
879     p.append( item );
880
881     customWidgets()->append (0);
882
883     item.myName = tr( "SMESH_REVERSED_EDGES" );
884     p.append( item );
885
886     StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget =
887       new StdMeshersGUI_SubShapeSelectorWdg();
888     QString aGeomEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
889     QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
890     if ( aGeomEntry == "" )
891       aGeomEntry = h->GetObjectEntry();
892
893     aDirectionWidget->SetGeomShapeEntry( aGeomEntry );
894     aDirectionWidget->SetMainShapeEntry( aMainEntry );
895     aDirectionWidget->SetListOfIDs( h->GetReversedEdges() );
896     aDirectionWidget->showPreview( true );
897     customWidgets()->append ( aDirectionWidget );
898   }
899
900   else if( hypType()=="GeometricProgression" )
901   {
902     StdMeshers::StdMeshers_Geometric1D_var h =
903       StdMeshers::StdMeshers_Geometric1D::_narrow( hyp );
904
905     item.myName = tr( "SMESH_START_LENGTH_PARAM" );
906     if(!initVariableName( hyp, item, "SetStartLength" ))
907       item.myValue = h->GetStartLength();
908     p.append( item );
909
910     customWidgets()->append (0);
911
912     item.myName = tr( "SMESH_COMMON_RATIO" );
913     if(!initVariableName( hyp, item, "SetCommonRatio" ))
914       item.myValue = h->GetCommonRatio();
915     p.append( item );
916
917     customWidgets()->append (0);
918
919     item.myName = tr( "SMESH_REVERSED_EDGES" );
920     p.append( item );
921
922     StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget =
923       new StdMeshersGUI_SubShapeSelectorWdg();
924     QString aGeomEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
925     QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
926     if ( aGeomEntry == "" )
927       aGeomEntry = h->GetObjectEntry();
928
929     aDirectionWidget->SetGeomShapeEntry( aGeomEntry );
930     aDirectionWidget->SetMainShapeEntry( aMainEntry );
931     aDirectionWidget->SetListOfIDs( h->GetReversedEdges() );
932     aDirectionWidget->showPreview( true );
933     customWidgets()->append ( aDirectionWidget );
934   }
935
936   else if( hypType()=="FixedPoints1D" )
937   {
938     StdMeshers::StdMeshers_FixedPoints1D_var h =
939       StdMeshers::StdMeshers_FixedPoints1D::_narrow( hyp );
940
941     item.myName = tr( "SMESH_FIXED_POINTS" );
942     p.append( item );
943
944     StdMeshersGUI_FixedPointsParamWdg* aFixedPointsWidget =
945       new StdMeshersGUI_FixedPointsParamWdg();
946
947     if ( !isCreation() ) {
948       aFixedPointsWidget->SetListOfPoints( h->GetPoints() );
949       aFixedPointsWidget->SetListOfSegments( h->GetNbSegments() );
950     }
951     customWidgets()->append( aFixedPointsWidget );
952
953     item.myName = tr( "SMESH_REVERSED_EDGES" );
954     p.append( item );
955
956     StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget =
957       new StdMeshersGUI_SubShapeSelectorWdg();
958     QString anEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
959     QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
960     if ( anEntry == "" )
961       anEntry = h->GetObjectEntry();
962     aDirectionWidget->SetGeomShapeEntry( anEntry );
963     aDirectionWidget->SetMainShapeEntry( aMainEntry );
964     aDirectionWidget->SetListOfIDs( h->GetReversedEdges() );
965     aDirectionWidget->showPreview( true );
966     customWidgets()->append ( aDirectionWidget );
967   }
968
969
970   else if( hypType()=="MaxElementArea" )
971   {
972     StdMeshers::StdMeshers_MaxElementArea_var h =
973       StdMeshers::StdMeshers_MaxElementArea::_narrow( hyp );
974
975     item.myName = tr( "SMESH_MAX_ELEMENT_AREA_PARAM" );
976     if(!initVariableName( hyp, item, "SetMaxElementArea" ))
977       item.myValue = h->GetMaxElementArea();
978     p.append( item );
979     
980   }
981   else if( hypType()=="MaxElementVolume" )
982   {
983     StdMeshers::StdMeshers_MaxElementVolume_var h =
984       StdMeshers::StdMeshers_MaxElementVolume::_narrow( hyp );
985
986     item.myName = tr( "SMESH_MAX_ELEMENT_VOLUME_PARAM" );
987     if(!initVariableName( hyp, item, "SetMaxElementVolume" ))
988       item.myValue = h->GetMaxElementVolume();
989     p.append( item );
990   }
991   else if( hypType()=="StartEndLength" )
992   {
993     StdMeshers::StdMeshers_StartEndLength_var h =
994       StdMeshers::StdMeshers_StartEndLength::_narrow( hyp );
995
996     item.myName = tr( "SMESH_START_LENGTH_PARAM" );
997
998     if(!initVariableName( hyp, item, "SetStartLength" )) 
999       item.myValue = h->GetLength( true );
1000     p.append( item );
1001     customWidgets()->append(0);
1002
1003     item.myName = tr( "SMESH_END_LENGTH_PARAM" );
1004     if(!initVariableName( hyp, item, "SetEndLength" )) 
1005       item.myValue = h->GetLength( false );
1006     p.append( item );
1007     customWidgets()->append(0);
1008
1009     item.myName = tr( "SMESH_REVERSED_EDGES" );
1010     p.append( item );
1011
1012     StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget =
1013       new StdMeshersGUI_SubShapeSelectorWdg();
1014     QString anEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
1015     QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
1016     if ( anEntry == "" )
1017       anEntry = h->GetObjectEntry();
1018     aDirectionWidget->SetGeomShapeEntry( anEntry );
1019     aDirectionWidget->SetMainShapeEntry( aMainEntry );
1020     aDirectionWidget->SetListOfIDs( h->GetReversedEdges() );
1021     aDirectionWidget->showPreview( true );
1022     customWidgets()->append ( aDirectionWidget );
1023   }
1024   else if( hypType()=="Deflection1D" )
1025   {
1026     StdMeshers::StdMeshers_Deflection1D_var h =
1027       StdMeshers::StdMeshers_Deflection1D::_narrow( hyp );
1028
1029     item.myName = tr( "SMESH_DEFLECTION1D_PARAM" );
1030     if(!initVariableName( hyp, item, "SetDeflection" )) 
1031       item.myValue = h->GetDeflection();
1032     p.append( item );
1033   }
1034   else if( hypType()=="Adaptive1D" )
1035   {
1036     StdMeshers::StdMeshers_Adaptive1D_var h =
1037       StdMeshers::StdMeshers_Adaptive1D::_narrow( hyp );
1038
1039     item.myName = tr( "SMESH_MIN_SIZE" );
1040     if(!initVariableName( hyp, item, "SetMinSize" )) 
1041       item.myValue = h->GetMinSize();
1042     p.append( item );
1043
1044     item.myName = tr( "SMESH_MAX_SIZE" );
1045     if(!initVariableName( hyp, item, "SetMaxSize" )) 
1046       item.myValue = h->GetMaxSize();
1047     p.append( item );
1048
1049     item.myName = tr( "SMESH_DEFLECTION1D_PARAM" );
1050     if(!initVariableName( hyp, item, "SetDeflection" )) 
1051       item.myValue = h->GetDeflection();
1052     p.append( item );
1053
1054     item.myName = tr( "SMESH_GRADING1D_PARAM" );
1055     if(!initVariableName( hyp, item, "SetGrading" ))
1056       item.myValue = h->GetGrading();
1057     p.append( item );
1058   }
1059   else if( hypType()=="AutomaticLength" )
1060   {
1061     StdMeshers::StdMeshers_AutomaticLength_var h =
1062       StdMeshers::StdMeshers_AutomaticLength::_narrow( hyp );
1063
1064     item.myName = tr( "SMESH_FINENESS_PARAM" );
1065     //item.myValue = h->GetFineness();
1066     p.append( item );
1067     SMESHGUI_SpinBox* _autoLengthSpinBox = new SMESHGUI_SpinBox(dlg());
1068     _autoLengthSpinBox->RangeStepAndValidator(0, 1, 0.01, "length_precision");
1069     _autoLengthSpinBox->SetValue(h->GetFineness());
1070     customWidgets()->append( _autoLengthSpinBox);
1071   }
1072   else if( hypType()=="NumberOfLayers" )
1073   {
1074     StdMeshers::StdMeshers_NumberOfLayers_var h =
1075       StdMeshers::StdMeshers_NumberOfLayers::_narrow( hyp );
1076
1077     item.myName = tr( "SMESH_NUMBER_OF_LAYERS" );
1078     if(!initVariableName( hyp, item, "SetNumberOfLayers" ))     
1079       item.myValue = (int) h->GetNumberOfLayers();
1080     p.append( item );
1081   }
1082   else if( hypType()=="LayerDistribution" )
1083   {
1084     StdMeshers::StdMeshers_LayerDistribution_var h =
1085       StdMeshers::StdMeshers_LayerDistribution::_narrow( hyp );
1086     
1087     item.myName = tr( "SMESH_LAYERS_DISTRIBUTION" ); p.append( item );
1088     initVariableName( hyp, item, "SetLayerDistribution" );
1089     customWidgets()->append ( new StdMeshersGUI_LayerDistributionParamWdg
1090                               ( h, h->GetLayerDistribution(), hypName(), dlg() ));
1091   }
1092   else if( hypType()=="NumberOfLayers2D" )
1093   {
1094     StdMeshers::StdMeshers_NumberOfLayers2D_var h =
1095       StdMeshers::StdMeshers_NumberOfLayers2D::_narrow( hyp );
1096     
1097     item.myName = tr( "SMESH_NUMBER_OF_LAYERS" );
1098     if(!initVariableName( hyp, item, "SetNumberOfLayers" ))     
1099       item.myValue = (int) h->GetNumberOfLayers();
1100     p.append( item );
1101   }
1102   else if( hypType()=="LayerDistribution2D" )
1103   {
1104     StdMeshers::StdMeshers_LayerDistribution2D_var h =
1105       StdMeshers::StdMeshers_LayerDistribution2D::_narrow( hyp );
1106
1107     item.myName = tr( "SMESH_LAYERS_DISTRIBUTION" ); p.append( item );
1108     initVariableName( hyp, item, "SetLayerDistribution" );
1109     customWidgets()->append ( new StdMeshersGUI_LayerDistributionParamWdg
1110                               ( h, h->GetLayerDistribution(), hypName(), dlg() ));
1111   }
1112   else if( hypType()=="ProjectionSource1D" )
1113   {
1114     StdMeshers::StdMeshers_ProjectionSource1D_var h =
1115       StdMeshers::StdMeshers_ProjectionSource1D::_narrow( hyp );
1116
1117     item.myName = tr( "SMESH_SOURCE_EDGE" ); p.append( item );
1118     customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 1 ),
1119                                                h->GetSourceEdge()));
1120     item.myName = tr( "SMESH_SOURCE_MESH" ); p.append( item );
1121     customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( SMESH::MESH ),
1122                                                h->GetSourceMesh()));
1123     item.myName = tr( "SMESH_SOURCE_VERTEX" ); p.append( item );
1124     customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1125                                                h->GetSourceVertex()));
1126     item.myName = tr( "SMESH_TARGET_VERTEX" ); p.append( item );
1127     customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1128                                                h->GetTargetVertex()));
1129   }
1130   else if( hypType()=="ProjectionSource2D" )
1131   {
1132     StdMeshers::StdMeshers_ProjectionSource2D_var h =
1133       StdMeshers::StdMeshers_ProjectionSource2D::_narrow( hyp );
1134
1135     item.myName = tr( "SMESH_SOURCE_FACE" ); p.append( item );
1136     customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 2 ),
1137                                                h->GetSourceFace()));
1138     item.myName = tr( "SMESH_SOURCE_MESH" ); p.append( item );
1139     customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( SMESH::MESH ),
1140                                                h->GetSourceMesh()));
1141     item.myName = tr( "SMESH_SOURCE_VERTEX1" ); p.append( item );
1142     customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1143                                                h->GetSourceVertex( 1 )));
1144     item.myName = tr( "SMESH_TARGET_VERTEX1" ); p.append( item );
1145     customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1146                                                h->GetTargetVertex( 1 )));
1147     item.myName = tr( "SMESH_SOURCE_VERTEX2" ); p.append( item );
1148     customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1149                                                h->GetSourceVertex( 2 )));
1150     item.myName = tr( "SMESH_TARGET_VERTEX2" ); p.append( item );
1151     customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1152                                                h->GetTargetVertex( 2 )));
1153   }
1154   else if( hypType()=="ProjectionSource3D" )
1155   {
1156     StdMeshers::StdMeshers_ProjectionSource3D_var h =
1157       StdMeshers::StdMeshers_ProjectionSource3D::_narrow( hyp );
1158
1159     item.myName = tr( "SMESH_SOURCE_3DSHAPE" ); p.append( item );
1160     customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 3, TopAbs_FACE, 6, true ),
1161                                                h->GetSource3DShape()));
1162     item.myName = tr( "SMESH_SOURCE_MESH" ); p.append( item );
1163     customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( SMESH::MESH ),
1164                                                h->GetSourceMesh()));
1165     item.myName = tr( "SMESH_SOURCE_VERTEX1" ); p.append( item );
1166     customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1167                                                h->GetSourceVertex( 1 )));
1168     item.myName = tr( "SMESH_TARGET_VERTEX1" ); p.append( item );
1169     customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1170                                                h->GetTargetVertex( 1 )));
1171     item.myName = tr( "SMESH_SOURCE_VERTEX2" ); p.append( item );
1172     customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1173                                                h->GetSourceVertex( 2 )));
1174     item.myName = tr( "SMESH_TARGET_VERTEX2" ); p.append( item );
1175     customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1176                                                h->GetTargetVertex( 2 )));
1177   }
1178   else if( hypType()=="ImportSource1D" )
1179   {
1180     StdMeshers::StdMeshers_ImportSource1D_var h =
1181       StdMeshers::StdMeshers_ImportSource1D::_narrow( hyp );
1182
1183     SMESH::string_array_var groupEntries = h->GetSourceEdges();
1184     CORBA::Boolean toCopyMesh, toCopyGroups;
1185     h->GetCopySourceMesh(toCopyMesh, toCopyGroups);
1186
1187     item.myName = tr( "SMESH_SOURCE_EDGES" ); p.append( item );
1188     customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( SMESH::GROUP_EDGE ), 
1189                                                 groupEntries));
1190
1191     item.myName = tr( "SMESH_COPY_MESH" ); p.append( item );
1192     QCheckBox* aQCheckBox = new QCheckBox(dlg());
1193     aQCheckBox->setChecked( toCopyMesh );
1194     connect( aQCheckBox, SIGNAL(  stateChanged(int) ), this, SLOT( onValueChanged() ));
1195     customWidgets()->append( aQCheckBox );
1196
1197     item.myName = tr( "SMESH_TO_COPY_GROUPS" ); p.append( item );
1198     aQCheckBox = new QCheckBox(dlg());
1199     aQCheckBox->setChecked( toCopyGroups );
1200     aQCheckBox->setEnabled( toCopyMesh );
1201     customWidgets()->append( aQCheckBox );
1202   }
1203   else if( hypType()=="ImportSource2D" )
1204   {
1205     StdMeshers::StdMeshers_ImportSource2D_var h =
1206       StdMeshers::StdMeshers_ImportSource2D::_narrow( hyp );
1207
1208     SMESH::string_array_var groupEntries = h->GetSourceFaces();
1209     CORBA::Boolean toCopyMesh, toCopyGroups;
1210     h->GetCopySourceMesh(toCopyMesh, toCopyGroups);
1211
1212     item.myName = tr( "SMESH_SOURCE_FACES" ); p.append( item );
1213     customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( SMESH::GROUP_FACE ), 
1214                                                 groupEntries));
1215
1216     item.myName = tr( "SMESH_COPY_MESH" ); p.append( item );
1217     QCheckBox* aQCheckBox = new QCheckBox(dlg());
1218     aQCheckBox->setChecked( toCopyMesh );
1219     connect( aQCheckBox, SIGNAL(  stateChanged(int) ), this, SLOT( onValueChanged() ));
1220     customWidgets()->append( aQCheckBox );
1221
1222     item.myName = tr( "SMESH_COPY_GROUPS" ); p.append( item );
1223     aQCheckBox = new QCheckBox(dlg());
1224     aQCheckBox->setChecked( toCopyGroups );
1225     aQCheckBox->setEnabled( toCopyMesh );
1226     customWidgets()->append( aQCheckBox );
1227   }
1228   else if( hypType()=="ViscousLayers" )
1229   {
1230     StdMeshers::StdMeshers_ViscousLayers_var h =
1231       StdMeshers::StdMeshers_ViscousLayers::_narrow( hyp );
1232
1233     item.myName = tr( "SMESH_TOTAL_THICKNESS" );
1234     if(!initVariableName( hyp, item, "SetTotalThickness" ))
1235       item.myValue = h->GetTotalThickness();
1236     p.append( item );
1237     customWidgets()->append (0);
1238
1239     item.myName = tr( "SMESH_NUMBER_OF_LAYERS" );
1240     if(!initVariableName( hyp, item, "SetNumberLayers" ))
1241       item.myValue = h->GetNumberLayers();
1242     p.append( item );
1243     customWidgets()->append (0);
1244
1245     item.myName = tr( "SMESH_STRETCH_FACTOR" );
1246     if(!initVariableName( hyp, item, "SetStretchFactor" ))
1247       item.myValue = h->GetStretchFactor();
1248     p.append( item );
1249     customWidgets()->append (0);
1250
1251     QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
1252     QString aSubEntry  = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
1253     if ( !aMainEntry.isEmpty() )
1254     {
1255       item.myName = tr( "TO_IGNORE_FACES_OR_NOT" );
1256       p.append( item );
1257
1258       StdMeshersGUI_RadioButtonsGrpWdg* ignoreWdg = new StdMeshersGUI_RadioButtonsGrpWdg("");
1259       ignoreWdg->setButtonLabels ( QStringList()
1260                                    << tr("NOT_TO_IGNORE_FACES")
1261                                    << tr("TO_IGNORE_FACES") );
1262       ignoreWdg->setChecked( h->GetIsToIgnoreFaces() );
1263       connect(ignoreWdg->getButtonGroup(),SIGNAL(buttonClicked(int)),this,SLOT(onValueChanged()));
1264       customWidgets()->append( ignoreWdg );
1265
1266       item.myName =
1267         tr( h->GetIsToIgnoreFaces() ? "SMESH_FACES_WO_LAYERS" : "SMESH_FACES_WITH_LAYERS" );
1268       p.append( item );
1269
1270       StdMeshersGUI_SubShapeSelectorWdg* idsWg =
1271         new StdMeshersGUI_SubShapeSelectorWdg(0,TopAbs_FACE);
1272
1273       idsWg->SetMainShapeEntry( aMainEntry );
1274       idsWg->SetGeomShapeEntry( aSubEntry.isEmpty() ? aMainEntry : aSubEntry );
1275       idsWg->SetListOfIDs( h->GetFaces() );
1276       idsWg->showPreview( true );
1277       customWidgets()->append ( idsWg );
1278     }
1279   }
1280   else if( hypType()=="ViscousLayers2D" )
1281   {
1282     StdMeshers::StdMeshers_ViscousLayers2D_var h =
1283       StdMeshers::StdMeshers_ViscousLayers2D::_narrow( hyp );
1284
1285     item.myName = tr( "SMESH_TOTAL_THICKNESS" );
1286     if(!initVariableName( hyp, item, "SetTotalThickness" ))
1287       item.myValue = h->GetTotalThickness();
1288     p.append( item );
1289     customWidgets()->append (0);
1290
1291     item.myName = tr( "SMESH_NUMBER_OF_LAYERS" );
1292     if(!initVariableName( hyp, item, "SetNumberLayers" ))
1293       item.myValue = h->GetNumberLayers();
1294     p.append( item );
1295     customWidgets()->append (0);
1296
1297     item.myName = tr( "SMESH_STRETCH_FACTOR" );
1298     if(!initVariableName( hyp, item, "SetStretchFactor" ))
1299       item.myValue = h->GetStretchFactor();
1300     p.append( item );
1301     customWidgets()->append (0);
1302
1303     QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
1304     QString aSubEntry  = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
1305     if ( !aMainEntry.isEmpty() )
1306     {
1307       item.myName = tr("TO_IGNORE_EDGES_OR_NOT");
1308       p.append( item );
1309
1310       StdMeshersGUI_RadioButtonsGrpWdg* ignoreWdg = new StdMeshersGUI_RadioButtonsGrpWdg("");
1311       ignoreWdg->setButtonLabels ( QStringList()
1312                                    << tr("NOT_TO_IGNORE_EDGES")
1313                                    << tr("TO_IGNORE_EDGES") );
1314       ignoreWdg->setChecked( h->GetIsToIgnoreEdges() );
1315       connect(ignoreWdg->getButtonGroup(),SIGNAL(buttonClicked(int)),this,SLOT(onValueChanged()));
1316       customWidgets()->append( ignoreWdg );
1317
1318       item.myName =
1319         tr( h->GetIsToIgnoreEdges() ? "SMESH_EDGES_WO_LAYERS" : "SMESH_EDGES_WITH_LAYERS" );
1320       p.append( item );
1321
1322       StdMeshersGUI_SubShapeSelectorWdg* idsWg =
1323         new StdMeshersGUI_SubShapeSelectorWdg(0,TopAbs_EDGE);
1324
1325       idsWg->SetMainShapeEntry( aMainEntry );
1326       idsWg->SetGeomShapeEntry( aSubEntry.isEmpty() ? aMainEntry : aSubEntry );
1327       idsWg->SetListOfIDs( h->GetEdges() );
1328       idsWg->showPreview( true );
1329       customWidgets()->append ( idsWg );
1330     }
1331   }
1332   // else if (hypType() == "QuadrangleParams")
1333   // {
1334   //   StdMeshers::StdMeshers_QuadrangleParams_var h =
1335   //     StdMeshers::StdMeshers_QuadrangleParams::_narrow(hyp);
1336
1337   //   item.myName = tr("SMESH_BASE_VERTEX");
1338   //   p.append(item);
1339
1340   //   StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget =
1341   //     new StdMeshersGUI_SubShapeSelectorWdg(0, TopAbs_VERTEX);
1342   //   aDirectionWidget->SetMaxSize(1);
1343   //   QString anEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
1344   //   QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
1345   //   if (anEntry == "")
1346   //     anEntry = h->GetObjectEntry();
1347   //   aDirectionWidget->SetGeomShapeEntry(anEntry);
1348   //   aDirectionWidget->SetMainShapeEntry(aMainEntry);
1349   //   if (!isCreation()) {
1350   //     SMESH::long_array_var aVec = new SMESH::long_array;
1351   //     int vertID = h->GetTriaVertex();
1352   //     if (vertID > 0) {
1353   //       aVec->length(1);
1354   //       aVec[0] = vertID;
1355   //       aDirectionWidget->SetListOfIDs(aVec);
1356   //     }
1357   //   }
1358   //   aDirectionWidget->showPreview(true);
1359
1360   //   item.myName = tr("SMESH_QUAD_TYPE");
1361   //   p.append(item);
1362
1363   //   StdMeshersGUI_QuadrangleParamWdg* aTypeWidget =
1364   //     new StdMeshersGUI_QuadrangleParamWdg();
1365   //   if (!isCreation()) {
1366   //     aTypeWidget->SetType(int(h->GetQuadType()));
1367   //   }
1368
1369   //   customWidgets()->append(aDirectionWidget);
1370   //   customWidgets()->append(aTypeWidget);
1371   // }
1372   else
1373     res = false;
1374   return res;
1375 }
1376
1377 //================================================================================
1378 /*!
1379  * \brief tune "standard" control
1380  *  \param w - control widget
1381  *  \param int - parameter index
1382  */
1383 //================================================================================
1384
1385 void StdMeshersGUI_StdHypothesisCreator::attuneStdWidget (QWidget* w, const int) const
1386 {
1387   SMESHGUI_SpinBox* sb = w->inherits( "SMESHGUI_SpinBox" ) ? ( SMESHGUI_SpinBox* )w : 0;
1388   if ( sb )
1389   {
1390     if( hypType()=="LocalLength" )
1391     {
1392       if (sb->objectName() == tr("SMESH_LOCAL_LENGTH_PARAM"))
1393         sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1394       else if (sb->objectName() == tr("SMESH_LOCAL_LENGTH_PRECISION"))
1395         sb->RangeStepAndValidator( 0.0, 1.0, 0.05, "len_tol_precision" );
1396     }
1397     else if( hypType()=="Arithmetic1D" )
1398     {
1399       sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "parametric_precision" );
1400     }
1401     else if( hypType()=="GeometricProgression" )
1402     {
1403       if (sb->objectName() == tr("SMESH_START_LENGTH_PARAM"))
1404         sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1405       else if (sb->objectName() == tr("SMESH_COMMON_RATIO"))
1406         sb->RangeStepAndValidator( -VALUE_MAX, VALUE_MAX, 0.5, "len_tol_precision" );
1407     }
1408     else if( hypType()=="MaxLength" )
1409     {
1410       sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1411       sb->setEnabled( !widget< QCheckBox >( 1 )->isChecked() );
1412     }
1413     else if( hypType()=="MaxElementArea" )
1414     {
1415       sb->RangeStepAndValidator( VALUE_SMALL_2, VALUE_MAX_2, 1.0, "area_precision" );
1416     }
1417     else if( hypType()=="MaxElementVolume" )
1418     {
1419       sb->RangeStepAndValidator( VALUE_SMALL_3, VALUE_MAX_3, 1.0, "vol_precision" );
1420     }
1421     else if( hypType()=="StartEndLength" )
1422     {
1423       sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1424     }
1425     else if( hypType()=="Deflection1D" )
1426     {
1427       sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "parametric_precision" );
1428     }
1429     else if( hypType()=="Adaptive1D" )
1430     {
1431       if (sb->objectName() == tr("SMESH_GRADING1D_PARAM"))
1432         sb->RangeStepAndValidator( 0.0, 2.0, 0.1, "length_precision" );
1433       else
1434         sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1435     }
1436     else if( hypType().startsWith( "ViscousLayers" ))
1437     {
1438       if (sb->objectName() == tr("SMESH_STRETCH_FACTOR"))
1439         sb->RangeStepAndValidator( 1.0, VALUE_MAX, 0.1, "parametric_precision" );
1440       else
1441         sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1442     }
1443     else // default validator for possible ancestors
1444     {
1445       sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1446     }
1447   }
1448 }
1449
1450 //================================================================================
1451 /*!
1452  * \brief Return dlg title
1453   * \retval QString - title string
1454  */
1455 //================================================================================
1456
1457 QString StdMeshersGUI_StdHypothesisCreator::caption() const
1458 {
1459   return tr( QString( "SMESH_%1_TITLE" ).arg( hypTypeName( hypType() ) ).toLatin1().data() );
1460 }
1461
1462 //================================================================================
1463 /*!
1464  * \brief return pixmap for dlg icon
1465   * \retval QPixmap - 
1466  */
1467 //================================================================================
1468
1469 QPixmap StdMeshersGUI_StdHypothesisCreator::icon() const
1470 {
1471   QString hypIconName = tr( QString( "ICON_DLG_%1" ).arg( hypTypeName( hypType() ) ).toLatin1().data() );
1472   return SMESHGUI::resourceMgr()->loadPixmap( "SMESH", hypIconName );
1473 }
1474
1475 //================================================================================
1476 /*!
1477  * \brief Return hypothesis type name to show in dlg
1478   * \retval QString - 
1479  */
1480 //================================================================================
1481
1482 QString StdMeshersGUI_StdHypothesisCreator::type() const
1483 {
1484   return tr( QString( "SMESH_%1_HYPOTHESIS" ).arg( hypTypeName( hypType() ) ).toLatin1().data() );
1485 }
1486
1487 //================================================================================
1488 /*!
1489  * \brief String to insert in "SMESH_%1_HYPOTHESIS" to get hypothesis type name
1490  * from message resouce file
1491   * \param t - hypothesis type
1492   * \retval QString - result string
1493  */
1494 //================================================================================
1495
1496 QString StdMeshersGUI_StdHypothesisCreator::hypTypeName( const QString& t ) const
1497 {
1498   static QMap<QString,QString>  types;
1499   if( types.isEmpty() )
1500   {
1501     types.insert( "LocalLength", "LOCAL_LENGTH" );
1502     types.insert( "NumberOfSegments", "NB_SEGMENTS" );
1503     types.insert( "MaxElementArea", "MAX_ELEMENT_AREA" );
1504     types.insert( "MaxElementVolume", "MAX_ELEMENT_VOLUME" );
1505     types.insert( "StartEndLength", "START_END_LENGTH" );
1506     types.insert( "Deflection1D", "DEFLECTION1D" );
1507     types.insert( "Adaptive1D", "ADAPTIVE1D" );
1508     types.insert( "Arithmetic1D", "ARITHMETIC_1D" );
1509     types.insert( "GeometricProgression", "GEOMETRIC_1D" );
1510     types.insert( "FixedPoints1D", "FIXED_POINTS_1D" );
1511     types.insert( "AutomaticLength", "AUTOMATIC_LENGTH" );
1512     types.insert( "ProjectionSource1D", "PROJECTION_SOURCE_1D" );
1513     types.insert( "ProjectionSource2D", "PROJECTION_SOURCE_2D" );
1514     types.insert( "ProjectionSource3D", "PROJECTION_SOURCE_3D" );
1515     types.insert( "ImportSource1D", "IMPORT_SOURCE_1D" );
1516     types.insert( "ImportSource2D", "IMPORT_SOURCE_2D" );
1517     types.insert( "NumberOfLayers", "NUMBER_OF_LAYERS" );
1518     types.insert( "LayerDistribution", "LAYER_DISTRIBUTION" );
1519     types.insert( "NumberOfLayers2D", "NUMBER_OF_LAYERS_2D" );
1520     types.insert( "LayerDistribution2D", "LAYER_DISTRIBUTION" );
1521     types.insert( "SegmentLengthAroundVertex", "SEGMENT_LENGTH_AROUND_VERTEX" );
1522     types.insert( "MaxLength", "MAX_LENGTH" );
1523     types.insert( "ViscousLayers", "VISCOUS_LAYERS" );
1524     types.insert( "ViscousLayers2D", "VISCOUS_LAYERS" );
1525     types.insert( "QuadrangleParams", "QUADRANGLE_PARAMS" );
1526     types.insert( "CartesianParameters3D", "CARTESIAN_PARAMS" );
1527   }
1528
1529   QString res;
1530   if( types.contains( t ) )
1531     res = types[ t ];
1532
1533   return res;
1534 }
1535
1536
1537 //=======================================================================
1538 //function : getCustomWidget
1539 //purpose  : is called from buildStdFrame()
1540 //=======================================================================
1541
1542 QWidget* StdMeshersGUI_StdHypothesisCreator::getCustomWidget( const StdParam & param,
1543                                                               QWidget*         parent,
1544                                                               const int        index) const
1545 {
1546   QWidget* w = 0;
1547   if ( index < customWidgets()->count() ) {
1548     w = customWidgets()->at( index );
1549     if ( w ) {
1550       w->setParent( parent );
1551       w->move( QPoint( 0, 0 ) );
1552     }
1553   }
1554   return w;
1555 }
1556
1557 //================================================================================
1558 /*!
1559  * \brief Set param value taken from a custom widget
1560   * \param param - SMESHGUI_GenericHypothesisCreator::StdParam structure
1561   * \param widget - widget presenting param
1562   * \retval bool - success flag
1563  * 
1564  * this method is called from getStdParamFromDlg()
1565  */
1566 //================================================================================
1567
1568 bool StdMeshersGUI_StdHypothesisCreator::getParamFromCustomWidget( StdParam & param,
1569                                                                    QWidget*   widget) const
1570 {
1571   if ( hypType()=="AutomaticLength" ) {
1572     SMESHGUI_SpinBox* w = dynamic_cast<SMESHGUI_SpinBox*>( widget );
1573     if ( w ) {
1574       param.myValue = w->GetValue();
1575       return true;
1576     }
1577   }
1578   if ( hypType() == "MaxLength" ) {
1579     param.myValue = "";
1580     return true;
1581   }
1582   if ( widget->inherits( "StdMeshersGUI_ObjectReferenceParamWdg" ))
1583   {
1584     // show only 1st reference value
1585     if ( true /*widget == getWidgetForParam( 0 )*/) {
1586       const StdMeshersGUI_ObjectReferenceParamWdg * w =
1587         static_cast<const StdMeshersGUI_ObjectReferenceParamWdg*>( widget );
1588       param.myValue = w->GetValue();
1589     }
1590     return true;
1591   }
1592   if ( widget->inherits( "StdMeshersGUI_LayerDistributionParamWdg" ))
1593   {
1594     const StdMeshersGUI_LayerDistributionParamWdg * w =
1595       static_cast<const StdMeshersGUI_LayerDistributionParamWdg*>( widget );
1596     param.myValue = w->GetValue();
1597     return true;
1598   }
1599   if ( widget->inherits( "StdMeshersGUI_SubShapeSelectorWdg" ))
1600   {
1601     const StdMeshersGUI_SubShapeSelectorWdg * w =
1602       static_cast<const StdMeshersGUI_SubShapeSelectorWdg*>( widget );
1603     param.myValue = w->GetValue();
1604     return true;
1605   }
1606   // if ( widget->inherits( "StdMeshersGUI_QuadrangleParamWdg" ))
1607   // {
1608   //   param.myValue = "QuadType";
1609   //   return true;
1610   // }
1611   if ( widget->inherits( "StdMeshersGUI_FixedPointsParamWdg" ))
1612   {
1613     const StdMeshersGUI_FixedPointsParamWdg * w =
1614       static_cast<const StdMeshersGUI_FixedPointsParamWdg*>( widget );
1615     param.myValue = w->GetValue();
1616     return true;
1617   }
1618   if ( widget->inherits( "QCheckBox" ))
1619   {
1620     //const QCheckBox * w = static_cast<const QCheckBox*>( widget );
1621     //param.myValue = w->isChecked();
1622     return true;
1623   }
1624   if ( widget->inherits( "StdMeshersGUI_RadioButtonsGrpWdg" ))
1625   {
1626     const StdMeshersGUI_RadioButtonsGrpWdg * w =
1627       static_cast<const StdMeshersGUI_RadioButtonsGrpWdg*>( widget );
1628     param.myValue = w->checkedId();
1629     return true;
1630   }
1631   return false;
1632 }
1633
1634 //================================================================================
1635 /*!
1636  * \brief called when operation cancelled
1637  */
1638 //================================================================================
1639
1640 void StdMeshersGUI_StdHypothesisCreator::onReject()
1641 {
1642   if ( hypType().startsWith("ProjectionSource" ) ||
1643        hypType().startsWith("ImportSource" ))
1644   {
1645     // Uninstall filters of StdMeshersGUI_ObjectReferenceParamWdg
1646     deactivateObjRefParamWdg( customWidgets() );
1647   }
1648 }
1649
1650 //================================================================================
1651 /*!
1652  * \brief Update widgets dependent on paramWidget
1653  */
1654 //================================================================================
1655
1656 void StdMeshersGUI_StdHypothesisCreator::valueChanged( QWidget* paramWidget)
1657 {
1658   if ( hypType() == "MaxLength" && paramWidget == getWidgetForParam(1) )
1659   {
1660     getWidgetForParam(0)->setEnabled( !widget< QCheckBox >( 1 )->isChecked() );
1661     if ( !getWidgetForParam(0)->isEnabled() ) {
1662       StdMeshers::StdMeshers_MaxLength_var h =
1663         StdMeshers::StdMeshers_MaxLength::_narrow( initParamsHypothesis() );
1664       widget< QtxDoubleSpinBox >( 0 )->setValue( h->GetPreestimatedLength() );
1665     }
1666   }
1667   else if ( hypType().startsWith("ImportSource") && paramWidget == getWidgetForParam(1) )
1668   {
1669     QCheckBox* toCopyMesh   = (QCheckBox*) paramWidget;
1670     QCheckBox* toCopyGroups = widget< QCheckBox >( 2 );
1671     if ( !toCopyMesh->isChecked() )
1672     {
1673       toCopyGroups->setChecked( false );
1674       toCopyGroups->setEnabled( false );
1675     }
1676     else
1677     {
1678       toCopyGroups->setEnabled( true );
1679     }
1680   }
1681   else if ( hypType().startsWith( "ViscousLayers" ) && paramWidget->inherits("QButtonGroup"))
1682   {
1683     if ( QLabel* label = getLabel(4) )
1684     {
1685       bool toIgnore = widget< StdMeshersGUI_RadioButtonsGrpWdg >( 3 )->checkedId();
1686       if ( hypType() == "ViscousLayers2D" )
1687         label->setText( tr( toIgnore ? "SMESH_EDGES_WO_LAYERS" : "SMESH_EDGES_WITH_LAYERS" ));
1688       else
1689         label->setText( tr( toIgnore ? "SMESH_FACES_WO_LAYERS" : "SMESH_FACES_WITH_LAYERS" ));
1690     }
1691   }
1692 }
1693
1694 //================================================================================
1695 /*!
1696  *
1697  */
1698 //================================================================================
1699
1700 bool StdMeshersGUI_StdHypothesisCreator::initVariableName(SMESH::SMESH_Hypothesis_var theHyp, 
1701                                                           StdParam &                  theParams, 
1702                                                           const char*                 theMethod) const
1703 {
1704   QString aVaribaleName = getVariableName( theMethod );
1705   theParams.isVariable = !aVaribaleName.isEmpty();
1706   if (theParams.isVariable)
1707     theParams.myValue = aVaribaleName;
1708
1709   return theParams.isVariable;
1710 }