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