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