]> SALOME platform Git repositories - modules/smesh.git/blob - src/StdMeshersGUI/StdMeshersGUI_StdHypothesisCreator.cxx
Salome HOME
IPAL16934: Selection works incorrectly if Source and Target Vertices in Projection...
[modules/smesh.git] / src / StdMeshersGUI / StdMeshersGUI_StdHypothesisCreator.cxx
1 // Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 //  File   : StdMeshersGUI_StdHypothesisCreator.cxx
23 //  Author : Alexander SOLOVYOV, Open CASCADE S.A.S.
24 //  SMESH includes
25
26 #include "StdMeshersGUI_StdHypothesisCreator.h"
27
28 #include <SMESHGUI.h>
29 #include <SMESHGUI_SpinBox.h>
30 #include <SMESHGUI_HypothesesUtils.h>
31 #include <SMESHGUI_Utils.h>
32 #include <SMESHGUI_GEOMGenUtils.h>
33
34 #include <SMESH_TypeFilter.hxx>
35 #include <SMESH_NumberFilter.hxx>
36
37 #include "StdMeshersGUI_FixedPointsParamWdg.h"
38 #include "StdMeshersGUI_LayerDistributionParamWdg.h"
39 #include "StdMeshersGUI_ObjectReferenceParamWdg.h"
40 #include "StdMeshersGUI_QuadrangleParamWdg.h"
41 #include "StdMeshersGUI_SubShapeSelectorWdg.h"
42 #include "StdMeshersGUI_RadioButtonsGrpWdg.h"
43
44 #include <SALOMEDSClient_Study.hxx>
45
46 #include <GEOM_wrap.hxx>
47
48 // SALOME GUI includes
49 #include <SUIT_ResourceMgr.h>
50 #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
724       if ( StdMeshersGUI_SubShapeSelectorWdg* idsWg = 
725            widget< StdMeshersGUI_SubShapeSelectorWdg >( 4 ))
726       {
727         h->SetFaces( idsWg->GetListOfIDs(), params[3].myValue.toInt() );
728       }
729     }
730     else if( hypType()=="ViscousLayers2D" )
731     {
732       StdMeshers::StdMeshers_ViscousLayers2D_var h =
733         StdMeshers::StdMeshers_ViscousLayers2D::_narrow( hypothesis() );
734
735       h->SetVarParameter( params[0].text(), "SetTotalThickness" );
736       h->SetTotalThickness( params[0].myValue.toDouble() );
737       h->SetVarParameter( params[1].text(), "SetNumberLayers" );
738       h->SetNumberLayers  ( params[1].myValue.toInt() );
739       h->SetVarParameter( params[2].text(), "SetStretchFactor" );
740       h->SetStretchFactor ( params[2].myValue.toDouble() );
741
742       if ( StdMeshersGUI_SubShapeSelectorWdg* idsWg =
743            widget< StdMeshersGUI_SubShapeSelectorWdg >( 4 ))
744       {
745         h->SetEdges( idsWg->GetListOfIDs(), params[3].myValue.toInt() );
746       }
747     }
748     // else if( hypType()=="QuadrangleParams" )
749     // {
750     //   StdMeshers::StdMeshers_QuadrangleParams_var h =
751     //     StdMeshers::StdMeshers_QuadrangleParams::_narrow( hypothesis() );
752     //   StdMeshersGUI_SubShapeSelectorWdg* w1 =
753     //     widget< StdMeshersGUI_SubShapeSelectorWdg >( 0 );
754     //   StdMeshersGUI_QuadrangleParamWdg* w2 =
755     //     widget< StdMeshersGUI_QuadrangleParamWdg >( 1 );
756     //   if (w1 && w2) {
757     //     if (w1->GetListSize() > 0) {
758     //       h->SetTriaVertex(w1->GetListOfIDs()[0]); // getlist must be called once
759     //       const char * entry = w1->GetMainShapeEntry();
760     //       h->SetObjectEntry(entry);
761     //     }
762     //     h->SetQuadType(StdMeshers::QuadType(w2->GetType()));
763     //   }
764     // }
765   }
766   return valueStr;
767 }
768
769 //================================================================================
770 /*!
771  * \brief Return parameter values as SMESHGUI_GenericHypothesisCreator::StdParam
772  * \param p - list of parameters
773  * \retval bool - success flag
774  *
775  * Is called from SMESHGUI_GenericHypothesisCreator::buildStdFrame().
776  * Parameters will be shown using "standard" controls:
777  *   Int by QtxIntSpinBox
778  *   Double by SMESHGUI_SpinBox
779  *   String by QLineEdit
780  * getCustomWidget() allows to redefine control for a parameter
781  */
782 //================================================================================
783
784 bool StdMeshersGUI_StdHypothesisCreator::stdParams( ListOfStdParams& p ) const
785 {
786   bool res = true;
787   SMESHGUI_GenericHypothesisCreator::StdParam item;
788
789   p.clear();
790   customWidgets()->clear();
791   if( isCreation() )
792   {
793     HypothesisData* data = SMESH::GetHypothesisData( hypType() );
794     item.myName = tr( "SMESH_NAME" );
795     item.myValue = data ? hypName() : QString();
796     p.append( item );
797     customWidgets()->append(0);
798   }
799
800   SMESH::SMESH_Hypothesis_var hyp = initParamsHypothesis();
801   //SMESH::ListOfParameters_var aParameters = hyp->GetLastParameters();
802
803   if( hypType()=="LocalLength" )
804   {
805     StdMeshers::StdMeshers_LocalLength_var h =
806       StdMeshers::StdMeshers_LocalLength::_narrow( hyp );
807
808     item.myName = tr("SMESH_LOCAL_LENGTH_PARAM");
809     if(!initVariableName( hyp, item, "SetLength"))
810       item.myValue = h->GetLength();
811     p.append( item );     
812
813     item.myName = tr("SMESH_LOCAL_LENGTH_PRECISION");
814     if(!initVariableName( hyp, item, "SetPrecision"))
815       item.myValue = h->GetPrecision(); 
816     p.append( item );
817   }
818   else if( hypType()=="MaxLength" )
819   {
820     StdMeshers::StdMeshers_MaxLength_var h =
821       StdMeshers::StdMeshers_MaxLength::_narrow( hyp );
822     // try to set a right preestimated length to edited hypothesis
823     bool noPreestimatedAtEdition = false;
824     if ( !isCreation() ) {
825       StdMeshers::StdMeshers_MaxLength_var initHyp =
826         StdMeshers::StdMeshers_MaxLength::_narrow( initParamsHypothesis(true) );
827       noPreestimatedAtEdition =
828         ( initHyp->_is_nil() || !initHyp->HavePreestimatedLength() );
829       if ( !noPreestimatedAtEdition )
830         h->SetPreestimatedLength( initHyp->GetPreestimatedLength() );
831     }
832
833     item.myName = tr("SMESH_LOCAL_LENGTH_PARAM");
834     if(!initVariableName( hyp, item, "SetLength"))
835       item.myValue = h->GetLength();
836     p.append( item );
837     customWidgets()->append(0);
838
839     item.myName = tr("SMESH_USE_PREESTIMATED_LENGTH");
840     p.append( item );
841     QCheckBox* aQCheckBox = new QCheckBox(dlg());
842     if ( !noPreestimatedAtEdition && h->HavePreestimatedLength() ) {
843       aQCheckBox->setChecked( h->GetUsePreestimatedLength() );
844       connect( aQCheckBox, SIGNAL(  stateChanged(int) ), this, SLOT( onValueChanged() ) );
845     }
846     else {
847       aQCheckBox->setChecked( false );
848       aQCheckBox->setEnabled( false );
849     }
850     customWidgets()->append( aQCheckBox );
851   }
852   else if( hypType()=="SegmentLengthAroundVertex" )
853   {
854     StdMeshers::StdMeshers_SegmentLengthAroundVertex_var h =
855       StdMeshers::StdMeshers_SegmentLengthAroundVertex::_narrow( hyp );
856
857     item.myName = tr("SMESH_LOCAL_LENGTH_PARAM");
858     if(!initVariableName( hyp, item, "SetLength"))
859       item.myValue = h->GetLength();
860     
861     p.append( item );
862   }
863   else if( hypType()=="Arithmetic1D" )
864   {
865     StdMeshers::StdMeshers_Arithmetic1D_var h =
866       StdMeshers::StdMeshers_Arithmetic1D::_narrow( hyp );
867
868     item.myName = tr( "SMESH_START_LENGTH_PARAM" );
869     if(!initVariableName( hyp, item, "SetStartLength" ))
870       item.myValue = h->GetLength( true );
871     p.append( item );
872
873     customWidgets()->append (0);
874
875     item.myName = tr( "SMESH_END_LENGTH_PARAM" );
876     if(!initVariableName( hyp, item, "SetEndLength" ))
877       item.myValue = h->GetLength( false );
878     p.append( item );
879
880     customWidgets()->append (0);
881
882     item.myName = tr( "SMESH_REVERSED_EDGES" );
883     p.append( item );
884
885     StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget =
886       new StdMeshersGUI_SubShapeSelectorWdg();
887     QString aGeomEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
888     QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
889     if ( aGeomEntry == "" )
890       aGeomEntry = h->GetObjectEntry();
891
892     aDirectionWidget->SetGeomShapeEntry( aGeomEntry );
893     aDirectionWidget->SetMainShapeEntry( aMainEntry );
894     aDirectionWidget->SetListOfIDs( h->GetReversedEdges() );
895     aDirectionWidget->showPreview( true );
896     customWidgets()->append ( aDirectionWidget );
897   }
898
899   else if( hypType()=="GeometricProgression" )
900   {
901     StdMeshers::StdMeshers_Geometric1D_var h =
902       StdMeshers::StdMeshers_Geometric1D::_narrow( hyp );
903
904     item.myName = tr( "SMESH_START_LENGTH_PARAM" );
905     if(!initVariableName( hyp, item, "SetStartLength" ))
906       item.myValue = h->GetStartLength();
907     p.append( item );
908
909     customWidgets()->append (0);
910
911     item.myName = tr( "SMESH_COMMON_RATIO" );
912     if(!initVariableName( hyp, item, "SetCommonRatio" ))
913       item.myValue = h->GetCommonRatio();
914     p.append( item );
915
916     customWidgets()->append (0);
917
918     item.myName = tr( "SMESH_REVERSED_EDGES" );
919     p.append( item );
920
921     StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget =
922       new StdMeshersGUI_SubShapeSelectorWdg();
923     QString aGeomEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
924     QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
925     if ( aGeomEntry == "" )
926       aGeomEntry = h->GetObjectEntry();
927
928     aDirectionWidget->SetGeomShapeEntry( aGeomEntry );
929     aDirectionWidget->SetMainShapeEntry( aMainEntry );
930     aDirectionWidget->SetListOfIDs( h->GetReversedEdges() );
931     aDirectionWidget->showPreview( true );
932     customWidgets()->append ( aDirectionWidget );
933   }
934
935   else if( hypType()=="FixedPoints1D" )
936   {
937     StdMeshers::StdMeshers_FixedPoints1D_var h =
938       StdMeshers::StdMeshers_FixedPoints1D::_narrow( hyp );
939
940     item.myName = tr( "SMESH_FIXED_POINTS" );
941     p.append( item );
942
943     StdMeshersGUI_FixedPointsParamWdg* aFixedPointsWidget =
944       new StdMeshersGUI_FixedPointsParamWdg();
945
946     if ( !isCreation() ) {
947       aFixedPointsWidget->SetListOfPoints( h->GetPoints() );
948       aFixedPointsWidget->SetListOfSegments( h->GetNbSegments() );
949     }
950     customWidgets()->append( aFixedPointsWidget );
951
952     item.myName = tr( "SMESH_REVERSED_EDGES" );
953     p.append( item );
954
955     StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget =
956       new StdMeshersGUI_SubShapeSelectorWdg();
957     QString anEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
958     QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
959     if ( anEntry == "" )
960       anEntry = h->GetObjectEntry();
961     aDirectionWidget->SetGeomShapeEntry( anEntry );
962     aDirectionWidget->SetMainShapeEntry( aMainEntry );
963     aDirectionWidget->SetListOfIDs( h->GetReversedEdges() );
964     aDirectionWidget->showPreview( true );
965     customWidgets()->append ( aDirectionWidget );
966   }
967
968
969   else if( hypType()=="MaxElementArea" )
970   {
971     StdMeshers::StdMeshers_MaxElementArea_var h =
972       StdMeshers::StdMeshers_MaxElementArea::_narrow( hyp );
973
974     item.myName = tr( "SMESH_MAX_ELEMENT_AREA_PARAM" );
975     if(!initVariableName( hyp, item, "SetMaxElementArea" ))
976       item.myValue = h->GetMaxElementArea();
977     p.append( item );
978     
979   }
980   else if( hypType()=="MaxElementVolume" )
981   {
982     StdMeshers::StdMeshers_MaxElementVolume_var h =
983       StdMeshers::StdMeshers_MaxElementVolume::_narrow( hyp );
984
985     item.myName = tr( "SMESH_MAX_ELEMENT_VOLUME_PARAM" );
986     if(!initVariableName( hyp, item, "SetMaxElementVolume" ))
987       item.myValue = h->GetMaxElementVolume();
988     p.append( item );
989   }
990   else if( hypType()=="StartEndLength" )
991   {
992     StdMeshers::StdMeshers_StartEndLength_var h =
993       StdMeshers::StdMeshers_StartEndLength::_narrow( hyp );
994
995     item.myName = tr( "SMESH_START_LENGTH_PARAM" );
996
997     if(!initVariableName( hyp, item, "SetStartLength" )) 
998       item.myValue = h->GetLength( true );
999     p.append( item );
1000     customWidgets()->append(0);
1001
1002     item.myName = tr( "SMESH_END_LENGTH_PARAM" );
1003     if(!initVariableName( hyp, item, "SetEndLength" )) 
1004       item.myValue = h->GetLength( false );
1005     p.append( item );
1006     customWidgets()->append(0);
1007
1008     item.myName = tr( "SMESH_REVERSED_EDGES" );
1009     p.append( item );
1010
1011     StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget =
1012       new StdMeshersGUI_SubShapeSelectorWdg();
1013     QString anEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
1014     QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
1015     if ( anEntry == "" )
1016       anEntry = h->GetObjectEntry();
1017     aDirectionWidget->SetGeomShapeEntry( anEntry );
1018     aDirectionWidget->SetMainShapeEntry( aMainEntry );
1019     aDirectionWidget->SetListOfIDs( h->GetReversedEdges() );
1020     aDirectionWidget->showPreview( true );
1021     customWidgets()->append ( aDirectionWidget );
1022   }
1023   else if( hypType()=="Deflection1D" )
1024   {
1025     StdMeshers::StdMeshers_Deflection1D_var h =
1026       StdMeshers::StdMeshers_Deflection1D::_narrow( hyp );
1027
1028     item.myName = tr( "SMESH_DEFLECTION1D_PARAM" );
1029     if(!initVariableName( hyp, item, "SetDeflection" )) 
1030       item.myValue = h->GetDeflection();
1031     p.append( item );
1032   }
1033   else if( hypType()=="Adaptive1D" )
1034   {
1035     StdMeshers::StdMeshers_Adaptive1D_var h =
1036       StdMeshers::StdMeshers_Adaptive1D::_narrow( hyp );
1037
1038     item.myName = tr( "SMESH_MIN_SIZE" );
1039     if(!initVariableName( hyp, item, "SetMinSize" )) 
1040       item.myValue = h->GetMinSize();
1041     p.append( item );
1042
1043     item.myName = tr( "SMESH_MAX_SIZE" );
1044     if(!initVariableName( hyp, item, "SetMaxSize" )) 
1045       item.myValue = h->GetMaxSize();
1046     p.append( item );
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()=="AutomaticLength" )
1054   {
1055     StdMeshers::StdMeshers_AutomaticLength_var h =
1056       StdMeshers::StdMeshers_AutomaticLength::_narrow( hyp );
1057
1058     item.myName = tr( "SMESH_FINENESS_PARAM" );
1059     //item.myValue = h->GetFineness();
1060     p.append( item );
1061     SMESHGUI_SpinBox* _autoLengthSpinBox = new SMESHGUI_SpinBox(dlg());
1062     _autoLengthSpinBox->RangeStepAndValidator(0, 1, 0.01, "length_precision");
1063     _autoLengthSpinBox->SetValue(h->GetFineness());
1064     customWidgets()->append( _autoLengthSpinBox);
1065   }
1066   else if( hypType()=="NumberOfLayers" )
1067   {
1068     StdMeshers::StdMeshers_NumberOfLayers_var h =
1069       StdMeshers::StdMeshers_NumberOfLayers::_narrow( hyp );
1070
1071     item.myName = tr( "SMESH_NUMBER_OF_LAYERS" );
1072     if(!initVariableName( hyp, item, "SetNumberOfLayers" ))     
1073       item.myValue = (int) h->GetNumberOfLayers();
1074     p.append( item );
1075   }
1076   else if( hypType()=="LayerDistribution" )
1077   {
1078     StdMeshers::StdMeshers_LayerDistribution_var h =
1079       StdMeshers::StdMeshers_LayerDistribution::_narrow( hyp );
1080     
1081     item.myName = tr( "SMESH_LAYERS_DISTRIBUTION" ); p.append( item );
1082     initVariableName( hyp, item, "SetLayerDistribution" );
1083     customWidgets()->append ( new StdMeshersGUI_LayerDistributionParamWdg
1084                               ( h, h->GetLayerDistribution(), hypName(), dlg() ));
1085   }
1086   else if( hypType()=="NumberOfLayers2D" )
1087   {
1088     StdMeshers::StdMeshers_NumberOfLayers2D_var h =
1089       StdMeshers::StdMeshers_NumberOfLayers2D::_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()=="LayerDistribution2D" )
1097   {
1098     StdMeshers::StdMeshers_LayerDistribution2D_var h =
1099       StdMeshers::StdMeshers_LayerDistribution2D::_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()=="ProjectionSource1D" )
1107   {
1108     StdMeshers::StdMeshers_ProjectionSource1D_var h =
1109       StdMeshers::StdMeshers_ProjectionSource1D::_narrow( hyp );
1110
1111     item.myName = tr( "SMESH_SOURCE_EDGE" ); p.append( item );
1112     customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 1 ),
1113                                                h->GetSourceEdge()));
1114     item.myName = tr( "SMESH_SOURCE_MESH" ); p.append( item );
1115     customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( SMESH::MESH ),
1116                                                h->GetSourceMesh()));
1117     item.myName = tr( "SMESH_SOURCE_VERTEX" ); p.append( item );
1118     customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1119                                                h->GetSourceVertex()));
1120     item.myName = tr( "SMESH_TARGET_VERTEX" ); p.append( item );
1121     customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1122                                                h->GetTargetVertex()));
1123   }
1124   else if( hypType()=="ProjectionSource2D" )
1125   {
1126     StdMeshers::StdMeshers_ProjectionSource2D_var h =
1127       StdMeshers::StdMeshers_ProjectionSource2D::_narrow( hyp );
1128
1129     item.myName = tr( "SMESH_SOURCE_FACE" ); p.append( item );
1130     customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 2 ),
1131                                                h->GetSourceFace()));
1132     item.myName = tr( "SMESH_SOURCE_MESH" ); p.append( item );
1133     customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( SMESH::MESH ),
1134                                                h->GetSourceMesh()));
1135     item.myName = tr( "SMESH_SOURCE_VERTEX1" ); p.append( item );
1136     customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1137                                                h->GetSourceVertex( 1 )));
1138     item.myName = tr( "SMESH_TARGET_VERTEX1" ); p.append( item );
1139     customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1140                                                h->GetTargetVertex( 1 )));
1141     item.myName = tr( "SMESH_SOURCE_VERTEX2" ); p.append( item );
1142     customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1143                                                h->GetSourceVertex( 2 )));
1144     item.myName = tr( "SMESH_TARGET_VERTEX2" ); p.append( item );
1145     customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1146                                                h->GetTargetVertex( 2 )));
1147   }
1148   else if( hypType()=="ProjectionSource3D" )
1149   {
1150     StdMeshers::StdMeshers_ProjectionSource3D_var h =
1151       StdMeshers::StdMeshers_ProjectionSource3D::_narrow( hyp );
1152
1153     item.myName = tr( "SMESH_SOURCE_3DSHAPE" ); p.append( item );
1154     customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 3, TopAbs_FACE, 6, true ),
1155                                                h->GetSource3DShape()));
1156     item.myName = tr( "SMESH_SOURCE_MESH" ); p.append( item );
1157     customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( SMESH::MESH ),
1158                                                h->GetSourceMesh()));
1159     item.myName = tr( "SMESH_SOURCE_VERTEX1" ); p.append( item );
1160     customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1161                                                h->GetSourceVertex( 1 )));
1162     item.myName = tr( "SMESH_TARGET_VERTEX1" ); p.append( item );
1163     customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1164                                                h->GetTargetVertex( 1 )));
1165     item.myName = tr( "SMESH_SOURCE_VERTEX2" ); p.append( item );
1166     customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1167                                                h->GetSourceVertex( 2 )));
1168     item.myName = tr( "SMESH_TARGET_VERTEX2" ); p.append( item );
1169     customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1170                                                h->GetTargetVertex( 2 )));
1171   }
1172   else if( hypType()=="ImportSource1D" )
1173   {
1174     StdMeshers::StdMeshers_ImportSource1D_var h =
1175       StdMeshers::StdMeshers_ImportSource1D::_narrow( hyp );
1176
1177     SMESH::string_array_var groupEntries = h->GetSourceEdges();
1178     CORBA::Boolean toCopyMesh, toCopyGroups;
1179     h->GetCopySourceMesh(toCopyMesh, toCopyGroups);
1180
1181     item.myName = tr( "SMESH_SOURCE_EDGES" ); p.append( item );
1182     customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( SMESH::GROUP_EDGE ), 
1183                                                 groupEntries));
1184
1185     item.myName = tr( "SMESH_COPY_MESH" ); p.append( item );
1186     QCheckBox* aQCheckBox = new QCheckBox(dlg());
1187     aQCheckBox->setChecked( toCopyMesh );
1188     connect( aQCheckBox, SIGNAL(  stateChanged(int) ), this, SLOT( onValueChanged() ));
1189     customWidgets()->append( aQCheckBox );
1190
1191     item.myName = tr( "SMESH_TO_COPY_GROUPS" ); p.append( item );
1192     aQCheckBox = new QCheckBox(dlg());
1193     aQCheckBox->setChecked( toCopyGroups );
1194     aQCheckBox->setEnabled( toCopyMesh );
1195     customWidgets()->append( aQCheckBox );
1196   }
1197   else if( hypType()=="ImportSource2D" )
1198   {
1199     StdMeshers::StdMeshers_ImportSource2D_var h =
1200       StdMeshers::StdMeshers_ImportSource2D::_narrow( hyp );
1201
1202     SMESH::string_array_var groupEntries = h->GetSourceFaces();
1203     CORBA::Boolean toCopyMesh, toCopyGroups;
1204     h->GetCopySourceMesh(toCopyMesh, toCopyGroups);
1205
1206     item.myName = tr( "SMESH_SOURCE_FACES" ); p.append( item );
1207     customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( SMESH::GROUP_FACE ), 
1208                                                 groupEntries));
1209
1210     item.myName = tr( "SMESH_COPY_MESH" ); p.append( item );
1211     QCheckBox* aQCheckBox = new QCheckBox(dlg());
1212     aQCheckBox->setChecked( toCopyMesh );
1213     connect( aQCheckBox, SIGNAL(  stateChanged(int) ), this, SLOT( onValueChanged() ));
1214     customWidgets()->append( aQCheckBox );
1215
1216     item.myName = tr( "SMESH_COPY_GROUPS" ); p.append( item );
1217     aQCheckBox = new QCheckBox(dlg());
1218     aQCheckBox->setChecked( toCopyGroups );
1219     aQCheckBox->setEnabled( toCopyMesh );
1220     customWidgets()->append( aQCheckBox );
1221   }
1222   else if( hypType()=="ViscousLayers" )
1223   {
1224     StdMeshers::StdMeshers_ViscousLayers_var h =
1225       StdMeshers::StdMeshers_ViscousLayers::_narrow( hyp );
1226
1227     item.myName = tr( "SMESH_TOTAL_THICKNESS" );
1228     if(!initVariableName( hyp, item, "SetTotalThickness" ))
1229       item.myValue = h->GetTotalThickness();
1230     p.append( item );
1231     customWidgets()->append (0);
1232
1233     item.myName = tr( "SMESH_NUMBER_OF_LAYERS" );
1234     if(!initVariableName( hyp, item, "SetNumberLayers" ))
1235       item.myValue = h->GetNumberLayers();
1236     p.append( item );
1237     customWidgets()->append (0);
1238
1239     item.myName = tr( "SMESH_STRETCH_FACTOR" );
1240     if(!initVariableName( hyp, item, "SetStretchFactor" ))
1241       item.myValue = h->GetStretchFactor();
1242     p.append( item );
1243     customWidgets()->append (0);
1244
1245     QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
1246     QString aSubEntry  = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
1247     if ( !aMainEntry.isEmpty() )
1248     {
1249       item.myName = tr( "TO_IGNORE_FACES_OR_NOT" );
1250       p.append( item );
1251
1252       StdMeshersGUI_RadioButtonsGrpWdg* ignoreWdg = new StdMeshersGUI_RadioButtonsGrpWdg("");
1253       ignoreWdg->setButtonLabels ( QStringList()
1254                                    << tr("NOT_TO_IGNORE_FACES")
1255                                    << tr("TO_IGNORE_FACES") );
1256       ignoreWdg->setChecked( h->GetIsToIgnoreFaces() );
1257       connect(ignoreWdg->getButtonGroup(),SIGNAL(buttonClicked(int)),this,SLOT(onValueChanged()));
1258       customWidgets()->append( ignoreWdg );
1259
1260       item.myName =
1261         tr( h->GetIsToIgnoreFaces() ? "SMESH_FACES_WO_LAYERS" : "SMESH_FACES_WITH_LAYERS" );
1262       p.append( item );
1263
1264       StdMeshersGUI_SubShapeSelectorWdg* idsWg =
1265         new StdMeshersGUI_SubShapeSelectorWdg(0,TopAbs_FACE);
1266
1267       idsWg->SetMainShapeEntry( aMainEntry );
1268       idsWg->SetGeomShapeEntry( aSubEntry.isEmpty() ? aMainEntry : aSubEntry );
1269       if ( idsWg->SetListOfIDs( h->GetFaces() ))
1270       {
1271         idsWg->showPreview( true );
1272       }
1273       else
1274       {
1275         SUIT_MessageBox::warning( dlg(),tr( "SMESH_WRN_WARNING" ),tr( "BAD_FACES_WARNING" ));
1276         idsWg->setEnabled( false );
1277       }
1278       customWidgets()->append ( idsWg );
1279     }
1280   }
1281   else if( hypType()=="ViscousLayers2D" )
1282   {
1283     StdMeshers::StdMeshers_ViscousLayers2D_var h =
1284       StdMeshers::StdMeshers_ViscousLayers2D::_narrow( hyp );
1285
1286     item.myName = tr( "SMESH_TOTAL_THICKNESS" );
1287     if(!initVariableName( hyp, item, "SetTotalThickness" ))
1288       item.myValue = h->GetTotalThickness();
1289     p.append( item );
1290     customWidgets()->append (0);
1291
1292     item.myName = tr( "SMESH_NUMBER_OF_LAYERS" );
1293     if(!initVariableName( hyp, item, "SetNumberLayers" ))
1294       item.myValue = h->GetNumberLayers();
1295     p.append( item );
1296     customWidgets()->append (0);
1297
1298     item.myName = tr( "SMESH_STRETCH_FACTOR" );
1299     if(!initVariableName( hyp, item, "SetStretchFactor" ))
1300       item.myValue = h->GetStretchFactor();
1301     p.append( item );
1302     customWidgets()->append (0);
1303
1304     QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
1305     QString aSubEntry  = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
1306     if ( !aMainEntry.isEmpty() )
1307     {
1308       item.myName = tr("TO_IGNORE_EDGES_OR_NOT");
1309       p.append( item );
1310
1311       StdMeshersGUI_RadioButtonsGrpWdg* ignoreWdg = new StdMeshersGUI_RadioButtonsGrpWdg("");
1312       ignoreWdg->setButtonLabels ( QStringList()
1313                                    << tr("NOT_TO_IGNORE_EDGES")
1314                                    << tr("TO_IGNORE_EDGES") );
1315       ignoreWdg->setChecked( h->GetIsToIgnoreEdges() );
1316       connect(ignoreWdg->getButtonGroup(),SIGNAL(buttonClicked(int)),this,SLOT(onValueChanged()));
1317       customWidgets()->append( ignoreWdg );
1318
1319       item.myName =
1320         tr( h->GetIsToIgnoreEdges() ? "SMESH_EDGES_WO_LAYERS" : "SMESH_EDGES_WITH_LAYERS" );
1321       p.append( item );
1322
1323       StdMeshersGUI_SubShapeSelectorWdg* idsWg =
1324         new StdMeshersGUI_SubShapeSelectorWdg(0,TopAbs_EDGE);
1325
1326       idsWg->SetMainShapeEntry( aMainEntry );
1327       idsWg->SetGeomShapeEntry( aSubEntry.isEmpty() ? aMainEntry : aSubEntry );
1328       if ( idsWg->SetListOfIDs( h->GetEdges() ))
1329       {
1330         idsWg->showPreview( true );
1331       }
1332       else
1333       {
1334         SUIT_MessageBox::warning( dlg(),tr( "SMESH_WRN_WARNING" ),tr( "BAD_EDGES_WARNING" ));
1335         idsWg->setEnabled( false );
1336       }
1337       customWidgets()->append ( idsWg );
1338     }
1339   }
1340   // else if (hypType() == "QuadrangleParams")
1341   // {
1342   //   StdMeshers::StdMeshers_QuadrangleParams_var h =
1343   //     StdMeshers::StdMeshers_QuadrangleParams::_narrow(hyp);
1344
1345   //   item.myName = tr("SMESH_BASE_VERTEX");
1346   //   p.append(item);
1347
1348   //   StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget =
1349   //     new StdMeshersGUI_SubShapeSelectorWdg(0, TopAbs_VERTEX);
1350   //   aDirectionWidget->SetMaxSize(1);
1351   //   QString anEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
1352   //   QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
1353   //   if (anEntry == "")
1354   //     anEntry = h->GetObjectEntry();
1355   //   aDirectionWidget->SetGeomShapeEntry(anEntry);
1356   //   aDirectionWidget->SetMainShapeEntry(aMainEntry);
1357   //   if (!isCreation()) {
1358   //     SMESH::long_array_var aVec = new SMESH::long_array;
1359   //     int vertID = h->GetTriaVertex();
1360   //     if (vertID > 0) {
1361   //       aVec->length(1);
1362   //       aVec[0] = vertID;
1363   //       aDirectionWidget->SetListOfIDs(aVec);
1364   //     }
1365   //   }
1366   //   aDirectionWidget->showPreview(true);
1367
1368   //   item.myName = tr("SMESH_QUAD_TYPE");
1369   //   p.append(item);
1370
1371   //   StdMeshersGUI_QuadrangleParamWdg* aTypeWidget =
1372   //     new StdMeshersGUI_QuadrangleParamWdg();
1373   //   if (!isCreation()) {
1374   //     aTypeWidget->SetType(int(h->GetQuadType()));
1375   //   }
1376
1377   //   customWidgets()->append(aDirectionWidget);
1378   //   customWidgets()->append(aTypeWidget);
1379   // }
1380   else
1381     res = false;
1382   return res;
1383 }
1384
1385 //================================================================================
1386 /*!
1387  * \brief tune "standard" control
1388  *  \param w - control widget
1389  *  \param int - parameter index
1390  */
1391 //================================================================================
1392
1393 void StdMeshersGUI_StdHypothesisCreator::attuneStdWidget (QWidget* w, const int) const
1394 {
1395   SMESHGUI_SpinBox* sb = w->inherits( "SMESHGUI_SpinBox" ) ? ( SMESHGUI_SpinBox* )w : 0;
1396   if ( sb )
1397   {
1398     if( hypType()=="LocalLength" )
1399     {
1400       if (sb->objectName() == tr("SMESH_LOCAL_LENGTH_PARAM"))
1401         sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1402       else if (sb->objectName() == tr("SMESH_LOCAL_LENGTH_PRECISION"))
1403         sb->RangeStepAndValidator( 0.0, 1.0, 0.05, "len_tol_precision" );
1404     }
1405     else if( hypType()=="Arithmetic1D" )
1406     {
1407       sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "parametric_precision" );
1408     }
1409     else if( hypType()=="GeometricProgression" )
1410     {
1411       if (sb->objectName() == tr("SMESH_START_LENGTH_PARAM"))
1412         sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1413       else if (sb->objectName() == tr("SMESH_COMMON_RATIO"))
1414         sb->RangeStepAndValidator( -VALUE_MAX, VALUE_MAX, 0.5, "len_tol_precision" );
1415     }
1416     else if( hypType()=="MaxLength" )
1417     {
1418       sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1419       sb->setEnabled( !widget< QCheckBox >( 1 )->isChecked() );
1420     }
1421     else if( hypType()=="MaxElementArea" )
1422     {
1423       sb->RangeStepAndValidator( VALUE_SMALL_2, VALUE_MAX_2, 1.0, "area_precision" );
1424     }
1425     else if( hypType()=="MaxElementVolume" )
1426     {
1427       sb->RangeStepAndValidator( VALUE_SMALL_3, VALUE_MAX_3, 1.0, "vol_precision" );
1428     }
1429     else if( hypType()=="StartEndLength" )
1430     {
1431       sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1432     }
1433     else if( hypType()=="Deflection1D" )
1434     {
1435       sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "parametric_precision" );
1436     }
1437     else if( hypType()=="Adaptive1D" )
1438     {
1439       sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1440     }
1441     else if( hypType().startsWith( "ViscousLayers" ))
1442     {
1443       if (sb->objectName() == tr("SMESH_STRETCH_FACTOR"))
1444         sb->RangeStepAndValidator( 1.0, VALUE_MAX, 0.1, "parametric_precision" );
1445       else
1446         sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1447     }
1448     else // default validator for possible ancestors
1449     {
1450       sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1451     }
1452   }
1453 }
1454
1455 //================================================================================
1456 /*!
1457  * \brief Return dlg title
1458   * \retval QString - title string
1459  */
1460 //================================================================================
1461
1462 QString StdMeshersGUI_StdHypothesisCreator::caption() const
1463 {
1464   return tr( QString( "SMESH_%1_TITLE" ).arg( hypTypeName( hypType() ) ).toLatin1().data() );
1465 }
1466
1467 //================================================================================
1468 /*!
1469  * \brief return pixmap for dlg icon
1470   * \retval QPixmap - 
1471  */
1472 //================================================================================
1473
1474 QPixmap StdMeshersGUI_StdHypothesisCreator::icon() const
1475 {
1476   QString hypIconName = tr( QString( "ICON_DLG_%1" ).arg( hypTypeName( hypType() ) ).toLatin1().data() );
1477   return SMESHGUI::resourceMgr()->loadPixmap( "SMESH", hypIconName );
1478 }
1479
1480 //================================================================================
1481 /*!
1482  * \brief Return hypothesis type name to show in dlg
1483   * \retval QString - 
1484  */
1485 //================================================================================
1486
1487 QString StdMeshersGUI_StdHypothesisCreator::type() const
1488 {
1489   return tr( QString( "SMESH_%1_HYPOTHESIS" ).arg( hypTypeName( hypType() ) ).toLatin1().data() );
1490 }
1491
1492 //================================================================================
1493 /*!
1494  * \brief String to insert in "SMESH_%1_HYPOTHESIS" to get hypothesis type name
1495  * from message resouce file
1496   * \param t - hypothesis type
1497   * \retval QString - result string
1498  */
1499 //================================================================================
1500
1501 QString StdMeshersGUI_StdHypothesisCreator::hypTypeName( const QString& t ) const
1502 {
1503   static QMap<QString,QString>  types;
1504   if( types.isEmpty() )
1505   {
1506     types.insert( "LocalLength", "LOCAL_LENGTH" );
1507     types.insert( "NumberOfSegments", "NB_SEGMENTS" );
1508     types.insert( "MaxElementArea", "MAX_ELEMENT_AREA" );
1509     types.insert( "MaxElementVolume", "MAX_ELEMENT_VOLUME" );
1510     types.insert( "StartEndLength", "START_END_LENGTH" );
1511     types.insert( "Deflection1D", "DEFLECTION1D" );
1512     types.insert( "Adaptive1D", "ADAPTIVE1D" );
1513     types.insert( "Arithmetic1D", "ARITHMETIC_1D" );
1514     types.insert( "GeometricProgression", "GEOMETRIC_1D" );
1515     types.insert( "FixedPoints1D", "FIXED_POINTS_1D" );
1516     types.insert( "AutomaticLength", "AUTOMATIC_LENGTH" );
1517     types.insert( "ProjectionSource1D", "PROJECTION_SOURCE_1D" );
1518     types.insert( "ProjectionSource2D", "PROJECTION_SOURCE_2D" );
1519     types.insert( "ProjectionSource3D", "PROJECTION_SOURCE_3D" );
1520     types.insert( "ImportSource1D", "IMPORT_SOURCE_1D" );
1521     types.insert( "ImportSource2D", "IMPORT_SOURCE_2D" );
1522     types.insert( "NumberOfLayers", "NUMBER_OF_LAYERS" );
1523     types.insert( "LayerDistribution", "LAYER_DISTRIBUTION" );
1524     types.insert( "NumberOfLayers2D", "NUMBER_OF_LAYERS_2D" );
1525     types.insert( "LayerDistribution2D", "LAYER_DISTRIBUTION" );
1526     types.insert( "SegmentLengthAroundVertex", "SEGMENT_LENGTH_AROUND_VERTEX" );
1527     types.insert( "MaxLength", "MAX_LENGTH" );
1528     types.insert( "ViscousLayers", "VISCOUS_LAYERS" );
1529     types.insert( "ViscousLayers2D", "VISCOUS_LAYERS" );
1530     types.insert( "QuadrangleParams", "QUADRANGLE_PARAMS" );
1531     types.insert( "CartesianParameters3D", "CARTESIAN_PARAMS" );
1532   }
1533
1534   QString res;
1535   if( types.contains( t ) )
1536     res = types[ t ];
1537
1538   return res;
1539 }
1540
1541
1542 //=======================================================================
1543 //function : getCustomWidget
1544 //purpose  : is called from buildStdFrame()
1545 //=======================================================================
1546
1547 QWidget* StdMeshersGUI_StdHypothesisCreator::getCustomWidget( const StdParam & param,
1548                                                               QWidget*         parent,
1549                                                               const int        index) const
1550 {
1551   QWidget* w = 0;
1552   if ( index < customWidgets()->count() ) {
1553     w = customWidgets()->at( index );
1554     if ( w ) {
1555       w->setParent( parent );
1556       w->move( QPoint( 0, 0 ) );
1557     }
1558   }
1559   return w;
1560 }
1561
1562 //================================================================================
1563 /*!
1564  * \brief Set param value taken from a custom widget
1565   * \param param - SMESHGUI_GenericHypothesisCreator::StdParam structure
1566   * \param widget - widget presenting param
1567   * \retval bool - success flag
1568  * 
1569  * this method is called from getStdParamFromDlg()
1570  */
1571 //================================================================================
1572
1573 bool StdMeshersGUI_StdHypothesisCreator::getParamFromCustomWidget( StdParam & param,
1574                                                                    QWidget*   widget) const
1575 {
1576   if ( hypType()=="AutomaticLength" ) {
1577     SMESHGUI_SpinBox* w = dynamic_cast<SMESHGUI_SpinBox*>( widget );
1578     if ( w ) {
1579       param.myValue = w->GetValue();
1580       return true;
1581     }
1582   }
1583   if ( hypType() == "MaxLength" ) {
1584     param.myValue = "";
1585     return true;
1586   }
1587   if ( widget->inherits( "StdMeshersGUI_ObjectReferenceParamWdg" ))
1588   {
1589     // show only 1st reference value
1590     if ( true /*widget == getWidgetForParam( 0 )*/) {
1591       const StdMeshersGUI_ObjectReferenceParamWdg * w =
1592         static_cast<const StdMeshersGUI_ObjectReferenceParamWdg*>( widget );
1593       param.myValue = w->GetValue();
1594     }
1595     return true;
1596   }
1597   if ( widget->inherits( "StdMeshersGUI_LayerDistributionParamWdg" ))
1598   {
1599     const StdMeshersGUI_LayerDistributionParamWdg * w =
1600       static_cast<const StdMeshersGUI_LayerDistributionParamWdg*>( widget );
1601     param.myValue = w->GetValue();
1602     return true;
1603   }
1604   if ( widget->inherits( "StdMeshersGUI_SubShapeSelectorWdg" ))
1605   {
1606     const StdMeshersGUI_SubShapeSelectorWdg * w =
1607       static_cast<const StdMeshersGUI_SubShapeSelectorWdg*>( widget );
1608     param.myValue = w->GetValue();
1609     return true;
1610   }
1611   // if ( widget->inherits( "StdMeshersGUI_QuadrangleParamWdg" ))
1612   // {
1613   //   param.myValue = "QuadType";
1614   //   return true;
1615   // }
1616   if ( widget->inherits( "StdMeshersGUI_FixedPointsParamWdg" ))
1617   {
1618     const StdMeshersGUI_FixedPointsParamWdg * w =
1619       static_cast<const StdMeshersGUI_FixedPointsParamWdg*>( widget );
1620     param.myValue = w->GetValue();
1621     return true;
1622   }
1623   if ( widget->inherits( "QCheckBox" ))
1624   {
1625     //const QCheckBox * w = static_cast<const QCheckBox*>( widget );
1626     //param.myValue = w->isChecked();
1627     return true;
1628   }
1629   if ( widget->inherits( "StdMeshersGUI_RadioButtonsGrpWdg" ))
1630   {
1631     const StdMeshersGUI_RadioButtonsGrpWdg * w =
1632       static_cast<const StdMeshersGUI_RadioButtonsGrpWdg*>( widget );
1633     param.myValue = w->checkedId();
1634     return true;
1635   }
1636   return false;
1637 }
1638
1639 //================================================================================
1640 /*!
1641  * \brief called when operation cancelled
1642  */
1643 //================================================================================
1644
1645 void StdMeshersGUI_StdHypothesisCreator::onReject()
1646 {
1647   if ( hypType().startsWith("ProjectionSource" ) ||
1648        hypType().startsWith("ImportSource" ))
1649   {
1650     // Uninstall filters of StdMeshersGUI_ObjectReferenceParamWdg
1651     deactivateObjRefParamWdg( customWidgets() );
1652   }
1653 }
1654
1655 //================================================================================
1656 /*!
1657  * \brief Update widgets dependent on paramWidget
1658  */
1659 //================================================================================
1660
1661 void StdMeshersGUI_StdHypothesisCreator::valueChanged( QWidget* paramWidget)
1662 {
1663   if ( hypType() == "MaxLength" && paramWidget == getWidgetForParam(1) )
1664   {
1665     getWidgetForParam(0)->setEnabled( !widget< QCheckBox >( 1 )->isChecked() );
1666     if ( !getWidgetForParam(0)->isEnabled() ) {
1667       StdMeshers::StdMeshers_MaxLength_var h =
1668         StdMeshers::StdMeshers_MaxLength::_narrow( initParamsHypothesis() );
1669       widget< QtxDoubleSpinBox >( 0 )->setValue( h->GetPreestimatedLength() );
1670     }
1671   }
1672   else if ( hypType().startsWith("ImportSource") && paramWidget == getWidgetForParam(1) )
1673   {
1674     QCheckBox* toCopyMesh   = (QCheckBox*) paramWidget;
1675     QCheckBox* toCopyGroups = widget< QCheckBox >( 2 );
1676     if ( !toCopyMesh->isChecked() )
1677     {
1678       toCopyGroups->setChecked( false );
1679       toCopyGroups->setEnabled( false );
1680     }
1681     else
1682     {
1683       toCopyGroups->setEnabled( true );
1684     }
1685   }
1686   else if ( hypType().startsWith( "ViscousLayers" ) && paramWidget->inherits("QButtonGroup"))
1687   {
1688     if ( QLabel* label = getLabel(4) )
1689     {
1690       bool toIgnore = widget< StdMeshersGUI_RadioButtonsGrpWdg >( 3 )->checkedId();
1691       if ( hypType() == "ViscousLayers2D" )
1692         label->setText( tr( toIgnore ? "SMESH_EDGES_WO_LAYERS" : "SMESH_EDGES_WITH_LAYERS" ));
1693       else
1694         label->setText( tr( toIgnore ? "SMESH_FACES_WO_LAYERS" : "SMESH_FACES_WITH_LAYERS" ));
1695     }
1696   }
1697 }
1698
1699 //================================================================================
1700 /*!
1701  *
1702  */
1703 //================================================================================
1704
1705 bool StdMeshersGUI_StdHypothesisCreator::initVariableName(SMESH::SMESH_Hypothesis_var theHyp, 
1706                                                           StdParam &                  theParams, 
1707                                                           const char*                 theMethod) const
1708 {
1709   QString aVaribaleName = getVariableName( theMethod );
1710   theParams.isVariable = !aVaribaleName.isEmpty();
1711   if (theParams.isVariable)
1712     theParams.myValue = aVaribaleName;
1713
1714   return theParams.isVariable;
1715 }