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