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