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