Salome HOME
0020095: EDF 896 SMESH : Advanced Mesh info on a group
[modules/smesh.git] / src / StdMeshersGUI / StdMeshersGUI_StdHypothesisCreator.cxx
1 //  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 //  This library is free software; you can redistribute it and/or
7 //  modify it under the terms of the GNU Lesser General Public
8 //  License as published by the Free Software Foundation; either
9 //  version 2.1 of the License.
10 //
11 //  This library is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 //  Lesser General Public License for more details.
15 //
16 //  You should have received a copy of the GNU Lesser General Public
17 //  License along with this library; if not, write to the Free Software
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 // File   : StdMeshersGUI_StdHypothesisCreator.cxx
23 // Author : Alexander SOLOVYOV, Open CASCADE S.A.S.
24 // SMESH includes
25 //
26 #include "StdMeshersGUI_StdHypothesisCreator.h"
27
28 #include <SMESHGUI.h>
29 #include <SMESHGUI_SpinBox.h>
30 #include <SMESHGUI_HypothesesUtils.h>
31 #include <SMESHGUI_Utils.h>
32 #include <SMESH_TypeFilter.hxx>
33 #include <SMESH_NumberFilter.hxx>
34 #include "StdMeshersGUI_ObjectReferenceParamWdg.h"
35 #include "StdMeshersGUI_LayerDistributionParamWdg.h"
36 //#include "StdMeshersGUI_EdgeDirectionParamWdg.h"
37 #include "StdMeshersGUI_SubShapeSelectorWdg.h"
38 #include <SALOMEDSClient_Study.hxx>
39
40 // SALOME GUI includes
41 #include <SUIT_ResourceMgr.h>
42
43 // IDL includes
44 #include <SALOMEconfig.h>
45 #include CORBA_SERVER_HEADER(SMESH_BasicHypothesis)
46 #include CORBA_SERVER_HEADER(SMESH_Mesh)
47
48 // Qt includes
49 #include <QHBoxLayout>
50 #include <QSlider>
51 #include <QLabel>
52 #include <QCheckBox>
53
54 const double VALUE_MAX = 1.0e+15, // COORD_MAX
55              VALUE_MAX_2  = VALUE_MAX * VALUE_MAX,
56              VALUE_MAX_3  = VALUE_MAX_2 * VALUE_MAX,
57              VALUE_SMALL = 1.0e-15,
58              VALUE_SMALL_2 = VALUE_SMALL * VALUE_SMALL,
59              VALUE_SMALL_3 = VALUE_SMALL_2 * VALUE_SMALL;
60
61 //================================================================================
62 /*!
63  * \brief Constructor
64   * \param type - hypothesis type
65  */
66 //================================================================================
67
68 StdMeshersGUI_StdHypothesisCreator::StdMeshersGUI_StdHypothesisCreator( const QString& type )
69 : SMESHGUI_GenericHypothesisCreator( type )
70 {
71 }
72
73 //================================================================================
74 /*!
75  * \brief Destructor
76  */
77 //================================================================================
78
79 StdMeshersGUI_StdHypothesisCreator::~StdMeshersGUI_StdHypothesisCreator()
80 {
81 }
82
83 //================================================================================
84 /*!
85  * \brief Return widget for i-th hypothesis parameter (got from myParamWidgets)
86   * \param i - index of hypothesis parameter
87   * \retval QWidget* - found widget
88  */
89 //================================================================================
90
91 QWidget* StdMeshersGUI_StdHypothesisCreator::getWidgetForParam( int i ) const
92 {
93   QWidget* w = 0;
94   if ( isCreation() ) ++i; // skip widget of 'name' parameter
95
96   if ( i < myCustomWidgets.count() ) {
97     QList<QWidget*>::const_iterator anIt  = myCustomWidgets.begin();
98     QList<QWidget*>::const_iterator aLast = myCustomWidgets.end();
99     for ( int j = 0 ; !w && anIt != aLast; ++anIt, ++j )
100       if ( i == j )
101         w = *anIt;
102   }
103   if ( !w ) {
104     // list has no at() const, so we iterate
105     QList<QWidget*>::const_iterator anIt  = widgets().begin();
106     QList<QWidget*>::const_iterator aLast = widgets().end();
107     for( int j = 0; !w && anIt!=aLast; anIt++, ++j ) {
108       if ( i == j )
109         w = *anIt;
110     }
111   }
112   return w;
113 }
114
115 //================================================================================
116 /*!
117  * \brief Allow modifing myCustomWidgets in const methods
118   * \retval ListOfWidgets* - non-const pointer to myCustomWidgets
119  */
120 //================================================================================
121
122 StdMeshersGUI_StdHypothesisCreator::ListOfWidgets*
123 StdMeshersGUI_StdHypothesisCreator::customWidgets() const
124 {
125   return const_cast< ListOfWidgets* >( & myCustomWidgets );
126 }
127
128 //================================================================================
129 /*!
130  * \brief Builds dlg layout
131   * \retval QFrame* - the built widget
132  */
133 //================================================================================
134
135 QFrame* StdMeshersGUI_StdHypothesisCreator::buildFrame()
136 {
137   return buildStdFrame();
138 }
139
140 //================================================================================
141 /*!
142  * \brief Initialise parameter values in controls
143  */
144 //================================================================================
145
146 void StdMeshersGUI_StdHypothesisCreator::retrieveParams() const
147 {
148   // buildStdFrame() sets values itself calling stdParams()
149
150   if ( hypType().startsWith("ProjectionSource" ))
151   {
152     // we use this method to connect depending custom widgets
153     StdMeshersGUI_ObjectReferenceParamWdg* widgetToActivate = 0;
154     ListOfWidgets::const_iterator anIt = myCustomWidgets.begin();
155     for ( ; anIt != myCustomWidgets.end(); anIt++)
156     {
157       if ( *anIt && (*anIt)->inherits("StdMeshersGUI_ObjectReferenceParamWdg"))
158       {
159         StdMeshersGUI_ObjectReferenceParamWdg * w1 =
160           ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
161         ListOfWidgets::const_iterator anIt2 = anIt;
162         for ( ++anIt2; anIt2 != myCustomWidgets.end(); anIt2++)
163           if ( *anIt2 && (*anIt2)->inherits("StdMeshersGUI_ObjectReferenceParamWdg"))
164           {
165             StdMeshersGUI_ObjectReferenceParamWdg * w2 =
166               ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt2 );
167             w1->AvoidSimultaneousSelection( w2 );
168           }
169         if ( !widgetToActivate )
170           widgetToActivate = w1;
171       }
172     }
173     if ( widgetToActivate )
174       widgetToActivate->activateSelection();
175   }
176
177   if ( dlg() )
178     dlg()->setMinimumSize( dlg()->minimumSizeHint().width(), dlg()->minimumSizeHint().height() );
179 }
180
181 namespace {
182
183   //================================================================================
184   /*!
185    * \brief Widget: slider with left and right labels
186    */
187   //================================================================================
188
189   class TDoubleSliderWith2Lables: public QWidget
190   {
191   public:
192     TDoubleSliderWith2Lables( const QString& leftLabel, const QString& rightLabel,
193                               const double   initValue, const double   bottom,
194                               const double   top      , const double   precision,
195                               QWidget *      parent=0 , const char *   name=0 )
196       :QWidget(parent), _bottom(bottom), _precision(precision)
197     {
198       setObjectName(name);
199
200       QHBoxLayout* aHBoxL = new QHBoxLayout(this);
201       
202       if ( !leftLabel.isEmpty() ) {
203         QLabel* aLeftLabel = new QLabel( this );
204         aLeftLabel->setText( leftLabel );
205         aHBoxL->addWidget( aLeftLabel );
206       }
207
208       _slider = new QSlider( Qt::Horizontal, this );
209       _slider->setRange( 0, toInt( top ));
210       _slider->setValue( toInt( initValue ));
211       aHBoxL->addWidget( _slider );
212
213       if ( !rightLabel.isEmpty() ) {
214         QLabel* aRightLabel = new QLabel( this );
215         aRightLabel->setText( rightLabel );
216         aHBoxL->addWidget( aRightLabel );
217       }
218
219       setLayout( aHBoxL );
220     }
221     double value() const { return _bottom + _slider->value() * _precision; }
222     QSlider * getSlider() const { return _slider; }
223     int toInt( double val ) const { return (int) ceil(( val - _bottom ) / _precision ); }
224   private:
225     double _bottom, _precision;
226     QSlider * _slider;
227   };
228
229   //================================================================================
230   /*!
231    * \brief Retrieve GEOM_Object held by widget
232    */
233   //================================================================================
234
235   inline GEOM::GEOM_Object_var geomFromWdg(const QWidget* wdg)
236   {
237     const StdMeshersGUI_ObjectReferenceParamWdg * objRefWdg =
238       dynamic_cast<const StdMeshersGUI_ObjectReferenceParamWdg*>( wdg );
239     if ( objRefWdg )
240       return objRefWdg->GetObject< GEOM::GEOM_Object >();
241
242     return GEOM::GEOM_Object::_nil();
243   }
244   //================================================================================
245   /*!
246    * \brief Retrieve SMESH_Mesh held by widget
247    */
248   //================================================================================
249
250   inline SMESH::SMESH_Mesh_var meshFromWdg(const QWidget* wdg)
251   {
252     const StdMeshersGUI_ObjectReferenceParamWdg * objRefWdg =
253       dynamic_cast<const StdMeshersGUI_ObjectReferenceParamWdg*>( wdg );
254     if ( objRefWdg )
255       return objRefWdg->GetObject< SMESH::SMESH_Mesh >();
256
257     return SMESH::SMESH_Mesh::_nil();
258   }
259   //================================================================================
260   /*!
261    * \brief creates a filter for selection of shapes of given dimension
262     * \param dim - dimension
263     * \param subShapeType - required type of subshapes, number of which must be \a nbSubShapes
264     * \param nbSubShapes - number of subshapes of given type
265     * \param closed - required closeness flag of a shape
266     * \retval SUIT_SelectionFilter* - created filter
267    */
268   //================================================================================
269
270   SUIT_SelectionFilter* filterForShapeOfDim(const int        dim,
271                                             TopAbs_ShapeEnum subShapeType = TopAbs_SHAPE,
272                                             const int        nbSubShapes = 0,
273                                             bool             closed = false)
274   {
275     TColStd_MapOfInteger shapeTypes;
276     switch ( dim ) {
277     case 0: shapeTypes.Add( TopAbs_VERTEX ); break;
278     case 1:
279       if ( subShapeType == TopAbs_SHAPE ) subShapeType = TopAbs_EDGE;
280       shapeTypes.Add( TopAbs_EDGE );
281       shapeTypes.Add( TopAbs_COMPOUND ); // for a group
282       break;
283     case 2:
284       if ( subShapeType == TopAbs_SHAPE ) subShapeType = TopAbs_FACE;
285       shapeTypes.Add( TopAbs_FACE );
286       shapeTypes.Add( TopAbs_COMPOUND ); // for a group
287       break;
288     case 3:
289       shapeTypes.Add( TopAbs_SHELL );
290       shapeTypes.Add( TopAbs_SOLID );
291       shapeTypes.Add( TopAbs_COMPSOLID );
292       shapeTypes.Add( TopAbs_COMPOUND );
293       break;
294     }
295     return new SMESH_NumberFilter("GEOM", subShapeType, nbSubShapes,
296                                   shapeTypes, GEOM::GEOM_Object::_nil(), closed);
297   }
298
299   //================================================================================
300   /*!
301    * \brief Create a widget for object selection
302     * \param object - initial object
303     * \param filter - selection filter
304     * \retval QWidget* - created widget
305    */
306   //================================================================================
307
308   QWidget* newObjRefParamWdg( SUIT_SelectionFilter* filter,
309                               CORBA::Object_var     object)
310   {
311     StdMeshersGUI_ObjectReferenceParamWdg* w =
312       new StdMeshersGUI_ObjectReferenceParamWdg( filter, 0);
313     w->SetObject( object.in() );
314     return w;
315   }
316
317   //================================================================================
318   /*!
319    * \brief calls deactivateSelection() for StdMeshersGUI_ObjectReferenceParamWdg
320     * \param widgetList - list of widgets
321    */
322   //================================================================================
323
324   void deactivateObjRefParamWdg( QList<QWidget*>* widgetList )
325   {
326     StdMeshersGUI_ObjectReferenceParamWdg* w = 0;
327     QList<QWidget*>::iterator anIt  = widgetList->begin();
328     QList<QWidget*>::iterator aLast = widgetList->end();
329     for ( ; anIt != aLast; anIt++ ) {
330       if ( (*anIt) && (*anIt)->inherits( "StdMeshersGUI_ObjectReferenceParamWdg" ))
331       {
332         w = (StdMeshersGUI_ObjectReferenceParamWdg* )( *anIt );
333         w->deactivateSelection();
334       }
335     }
336   }
337 }
338
339 //================================================================================
340 /*!
341  * \brief Check parameter values before accept()
342   * \retval bool - true if OK
343  */
344 //================================================================================
345
346 bool StdMeshersGUI_StdHypothesisCreator::checkParams( QString& msg ) const
347 {
348   if( !SMESHGUI_GenericHypothesisCreator::checkParams( msg ) )
349     return false;
350
351   // check if object reference parameter is set, as it has no default value
352   bool ok = true;
353   if ( hypType().startsWith("ProjectionSource" ))
354   {
355     StdMeshersGUI_ObjectReferenceParamWdg* w =
356       widget< StdMeshersGUI_ObjectReferenceParamWdg >( 0 );
357     ok = ( w->IsObjectSelected() );
358     if ( !ok ) w->SetObject( CORBA::Object::_nil() );
359     int nbAssocVert = ( hypType() == "ProjectionSource1D" ? 1 : 2 );
360     for ( int i = 0; ok && i < nbAssocVert; i += 2)
361     {
362       QString srcV, tgtV;
363       StdMeshersGUI_ObjectReferenceParamWdg* w1 =
364         widget< StdMeshersGUI_ObjectReferenceParamWdg >( i+2 );
365       StdMeshersGUI_ObjectReferenceParamWdg* w2 =
366         widget< StdMeshersGUI_ObjectReferenceParamWdg >( i+3 );
367       srcV = w1->GetValue();
368       tgtV = w2->GetValue();
369       ok = (( srcV.isEmpty()  && tgtV.isEmpty() ) ||
370             ( !srcV.isEmpty() && !tgtV.isEmpty() && srcV != tgtV ));
371       if ( !ok ) {
372         w1->SetObject( CORBA::Object::_nil() );
373         w2->SetObject( CORBA::Object::_nil() );
374       }
375     }
376
377     // Uninstall filters of StdMeshersGUI_ObjectReferenceParamWdg
378     if ( ok )
379       deactivateObjRefParamWdg( customWidgets() );
380   }
381   else if ( hypType() == "LayerDistribution" )
382   {
383     StdMeshersGUI_LayerDistributionParamWdg* w = 
384       widget< StdMeshersGUI_LayerDistributionParamWdg >( 0 );
385     ok = ( w && w->IsOk() );
386   }
387   return ok;
388 }
389
390 //================================================================================
391 /*!
392  * \brief Store params from GUI controls to a hypothesis
393   * \retval QString - text representation of parameters
394  */
395 //================================================================================
396
397 QString StdMeshersGUI_StdHypothesisCreator::storeParams() const
398 {
399   ListOfStdParams params;
400   bool res = getStdParamFromDlg( params );
401   if( isCreation() )
402   {
403     SMESH::SetName( SMESH::FindSObject( hypothesis() ), params[0].myValue.toString().toLatin1().data() );
404     params.erase( params.begin() );
405   }
406
407   QString valueStr = stdParamValues( params );
408   QStringList aVariablesList = getVariablesFromDlg();
409
410   if( res && !params.isEmpty() )
411   {
412     if( hypType()=="LocalLength" )
413     {
414       StdMeshers::StdMeshers_LocalLength_var h =
415         StdMeshers::StdMeshers_LocalLength::_narrow( hypothesis() );
416
417       h->SetLength( params[0].myValue.toDouble() );
418       h->SetParameters(SMESHGUI::JoinObjectParameters(aVariablesList));
419       h->SetPrecision( params[1].myValue.toDouble() );
420       h->SetParameters(SMESHGUI::JoinObjectParameters(aVariablesList));
421     }
422     else if( hypType()=="MaxLength" )
423     {
424       StdMeshers::StdMeshers_MaxLength_var h =
425         StdMeshers::StdMeshers_MaxLength::_narrow( hypothesis() );
426
427       h->SetLength( params[0].myValue.toDouble() );
428       h->SetParameters(SMESHGUI::JoinObjectParameters(aVariablesList));
429       h->SetUsePreestimatedLength( widget< QCheckBox >( 1 )->isChecked() );
430       if ( !h->HavePreestimatedLength() && !h->_is_equivalent( initParamsHypothesis() )) {
431         StdMeshers::StdMeshers_MaxLength_var hInit =
432           StdMeshers::StdMeshers_MaxLength::_narrow( initParamsHypothesis() );
433         h->SetPreestimatedLength( hInit->GetPreestimatedLength() );
434       }
435     }
436     else if( hypType()=="SegmentLengthAroundVertex" )
437     {
438       StdMeshers::StdMeshers_SegmentLengthAroundVertex_var h =
439         StdMeshers::StdMeshers_SegmentLengthAroundVertex::_narrow( hypothesis() );
440
441       h->SetLength( params[0].myValue.toDouble() );
442       h->SetParameters(SMESHGUI::JoinObjectParameters(aVariablesList));
443     }
444     else if( hypType()=="Arithmetic1D" )
445     {
446       StdMeshers::StdMeshers_Arithmetic1D_var h =
447         StdMeshers::StdMeshers_Arithmetic1D::_narrow( hypothesis() );
448
449       //StdMeshersGUI_EdgeDirectionParamWdg* w = 
450       //  widget< StdMeshersGUI_EdgeDirectionParamWdg >( 2 );
451       StdMeshersGUI_SubShapeSelectorWdg* w = 
452         widget< StdMeshersGUI_SubShapeSelectorWdg >( 2 );
453
454       h->SetStartLength( params[0].myValue.toDouble() );
455       h->SetParameters(SMESHGUI::JoinObjectParameters(aVariablesList));
456       h->SetEndLength( params[1].myValue.toDouble() );
457       h->SetParameters(SMESHGUI::JoinObjectParameters(aVariablesList));
458       if (w) {
459         h->SetReversedEdges( w->GetListOfIDs() );
460         const char * entry = w->GetMainShapeEntry();
461         h->SetObjectEntry( entry );
462       }
463     }
464     else if( hypType()=="MaxElementArea" )
465     {
466       StdMeshers::StdMeshers_MaxElementArea_var h =
467         StdMeshers::StdMeshers_MaxElementArea::_narrow( hypothesis() );
468       h->SetParameters(SMESHGUI::JoinObjectParameters(aVariablesList));
469       h->SetMaxElementArea( params[0].myValue.toDouble() );
470     }
471     else if( hypType()=="MaxElementVolume" )
472     {
473       StdMeshers::StdMeshers_MaxElementVolume_var h =
474         StdMeshers::StdMeshers_MaxElementVolume::_narrow( hypothesis() );
475
476       h->SetMaxElementVolume( params[0].myValue.toDouble() );
477       h->SetParameters(SMESHGUI::JoinObjectParameters(aVariablesList));
478     }
479     else if( hypType()=="StartEndLength" )
480     {
481       StdMeshers::StdMeshers_StartEndLength_var h =
482         StdMeshers::StdMeshers_StartEndLength::_narrow( hypothesis() );
483
484       StdMeshersGUI_SubShapeSelectorWdg* w = 
485         widget< StdMeshersGUI_SubShapeSelectorWdg >( 2 );
486
487       h->SetStartLength( params[0].myValue.toDouble() );
488       h->SetParameters(SMESHGUI::JoinObjectParameters(aVariablesList));
489       h->SetEndLength( params[1].myValue.toDouble() );
490       h->SetParameters(SMESHGUI::JoinObjectParameters(aVariablesList));
491       if (w) {
492         h->SetReversedEdges( w->GetListOfIDs() );
493         h->SetObjectEntry( w->GetMainShapeEntry() );
494       }
495     }
496     else if( hypType()=="Deflection1D" )
497     {
498       StdMeshers::StdMeshers_Deflection1D_var h =
499         StdMeshers::StdMeshers_Deflection1D::_narrow( hypothesis() );
500       h->SetParameters(SMESHGUI::JoinObjectParameters(aVariablesList));
501       h->SetDeflection( params[0].myValue.toDouble() );
502     }
503     else if( hypType()=="AutomaticLength" )
504     {
505       StdMeshers::StdMeshers_AutomaticLength_var h =
506         StdMeshers::StdMeshers_AutomaticLength::_narrow( hypothesis() );
507
508       h->SetFineness( params[0].myValue.toDouble() );
509     }
510     else if( hypType()=="NumberOfLayers" )
511     {
512       StdMeshers::StdMeshers_NumberOfLayers_var h =
513         StdMeshers::StdMeshers_NumberOfLayers::_narrow( hypothesis() );
514
515       h->SetNumberOfLayers( params[0].myValue.toInt() );
516       h->SetParameters(SMESHGUI::JoinObjectParameters(aVariablesList));
517     }
518     else if( hypType()=="LayerDistribution" )
519     {
520       StdMeshers::StdMeshers_LayerDistribution_var h =
521         StdMeshers::StdMeshers_LayerDistribution::_narrow( hypothesis() );
522       StdMeshersGUI_LayerDistributionParamWdg* w = 
523         widget< StdMeshersGUI_LayerDistributionParamWdg >( 0 );
524       
525       h->SetLayerDistribution( w->GetHypothesis() );
526       h->SetParameters(w->GetHypothesis()->GetParameters());
527       w->GetHypothesis()->ClearParameters();
528     }
529     else if( hypType()=="ProjectionSource1D" )
530     {
531       StdMeshers::StdMeshers_ProjectionSource1D_var h =
532         StdMeshers::StdMeshers_ProjectionSource1D::_narrow( hypothesis() );
533
534       h->SetSourceEdge       ( geomFromWdg ( getWidgetForParam( 0 )));
535       h->SetSourceMesh       ( meshFromWdg ( getWidgetForParam( 1 )));
536       h->SetVertexAssociation( geomFromWdg ( getWidgetForParam( 2 )),
537                                geomFromWdg ( getWidgetForParam( 3 )));
538     }
539     else if( hypType()=="ProjectionSource2D" )
540     {
541       StdMeshers::StdMeshers_ProjectionSource2D_var h =
542         StdMeshers::StdMeshers_ProjectionSource2D::_narrow( hypothesis() );
543
544       h->SetSourceFace       ( geomFromWdg ( getWidgetForParam( 0 )));
545       h->SetSourceMesh       ( meshFromWdg ( getWidgetForParam( 1 )));
546       h->SetVertexAssociation( geomFromWdg ( getWidgetForParam( 2 )), // src1
547                                geomFromWdg ( getWidgetForParam( 4 )), // src2
548                                geomFromWdg ( getWidgetForParam( 3 )), // tgt1
549                                geomFromWdg ( getWidgetForParam( 5 ))); // tgt2
550     }
551     else if( hypType()=="ProjectionSource3D" )
552     {
553       StdMeshers::StdMeshers_ProjectionSource3D_var h =
554         StdMeshers::StdMeshers_ProjectionSource3D::_narrow( hypothesis() );
555
556       h->SetSource3DShape    ( geomFromWdg ( getWidgetForParam( 0 )));
557       h->SetSourceMesh       ( meshFromWdg ( getWidgetForParam( 1 )));
558       h->SetVertexAssociation( geomFromWdg ( getWidgetForParam( 2 )), // src1
559                                geomFromWdg ( getWidgetForParam( 4 )), // src2
560                                geomFromWdg ( getWidgetForParam( 3 )), // tgt1
561                                geomFromWdg ( getWidgetForParam( 5 ))); // tgt2
562     }
563     else if( hypType()=="QuadrangleParams" )
564     {
565       StdMeshers::StdMeshers_QuadrangleParams_var h =
566         StdMeshers::StdMeshers_QuadrangleParams::_narrow( hypothesis() );
567       StdMeshersGUI_SubShapeSelectorWdg* w = 
568         widget< StdMeshersGUI_SubShapeSelectorWdg >( 0 );
569       if (w) {
570         if( w->GetListOfIDs()->length()>0 ) {
571           h->SetTriaVertex( w->GetListOfIDs()[0] );
572         }
573         const char * entry = w->GetMainShapeEntry();
574         h->SetObjectEntry( entry );
575       }
576     }
577   }
578   return valueStr;
579 }
580
581 //================================================================================
582 /*!
583  * \brief Return parameter values as SMESHGUI_GenericHypothesisCreator::StdParam
584   * \param p - list of parameters
585   * \retval bool - success flag
586   *
587   * Is called from SMESHGUI_GenericHypothesisCreator::buildStdFrame().
588   * Parameters will be shown using "standard" controls:
589   *   Int by QtxIntSpinBox
590   *   Double by SMESHGUI_SpinBox
591   *   String by QLineEdit
592   * getCustomWidget() allows to redefine control for a parameter
593  */
594 //================================================================================
595
596 bool StdMeshersGUI_StdHypothesisCreator::stdParams( ListOfStdParams& p ) const
597 {
598   bool res = true;
599   SMESHGUI_GenericHypothesisCreator::StdParam item;
600
601   p.clear();
602   customWidgets()->clear();
603   if( isCreation() )
604   {
605     HypothesisData* data = SMESH::GetHypothesisData( hypType() );
606     item.myName = tr( "SMESH_NAME" );
607     item.myValue = data ? hypName() : QString();
608     p.append( item );
609     customWidgets()->append(0);
610   }
611   
612   SMESH::SMESH_Hypothesis_var hyp = initParamsHypothesis();
613   SMESH::ListOfParameters_var aParameters = hyp->GetLastParameters();
614
615   if( hypType()=="LocalLength" )
616   {
617     StdMeshers::StdMeshers_LocalLength_var h =
618       StdMeshers::StdMeshers_LocalLength::_narrow( hyp );
619     
620     item.myName = tr("SMESH_LOCAL_LENGTH_PARAM");
621     if(!initVariableName(aParameters,item,0))
622       item.myValue = h->GetLength();
623     p.append( item );     
624     
625     item.myName = tr("SMESH_LOCAL_LENGTH_PRECISION");
626     if(!initVariableName(aParameters,item,1))
627       item.myValue = h->GetPrecision(); 
628     p.append( item );
629     
630   }
631   else if( hypType()=="MaxLength" )
632   {
633     StdMeshers::StdMeshers_MaxLength_var h =
634       StdMeshers::StdMeshers_MaxLength::_narrow( hyp );
635     // try to set a right preestimated length to edited hypothesis
636     bool noPreestimatedAtEdition = false;
637     if ( !isCreation() ) {
638       StdMeshers::StdMeshers_MaxLength_var initHyp =
639         StdMeshers::StdMeshers_MaxLength::_narrow( initParamsHypothesis(true) );
640       noPreestimatedAtEdition =
641         ( initHyp->_is_nil() || !initHyp->HavePreestimatedLength() );
642       if ( !noPreestimatedAtEdition )
643         h->SetPreestimatedLength( initHyp->GetPreestimatedLength() );
644     }
645
646     item.myName = tr("SMESH_LOCAL_LENGTH_PARAM");
647     if(!initVariableName(aParameters,item,0))
648       item.myValue = h->GetLength();
649     p.append( item );
650     customWidgets()->append(0);
651
652     item.myName = tr("SMESH_USE_PREESTIMATED_LENGTH");
653     p.append( item );
654     QCheckBox* aQCheckBox = new QCheckBox(dlg());
655     if ( !noPreestimatedAtEdition && h->HavePreestimatedLength() ) {
656       aQCheckBox->setChecked( h->GetUsePreestimatedLength() );
657       connect( aQCheckBox, SIGNAL(  stateChanged(int) ), this, SLOT( onValueChanged() ) );
658     }
659     else {
660       aQCheckBox->setChecked( false );
661       aQCheckBox->setEnabled( false );
662     }
663     customWidgets()->append( aQCheckBox );
664   }
665   else if( hypType()=="SegmentLengthAroundVertex" )
666   {
667     StdMeshers::StdMeshers_SegmentLengthAroundVertex_var h =
668       StdMeshers::StdMeshers_SegmentLengthAroundVertex::_narrow( hyp );
669
670     item.myName = tr("SMESH_LOCAL_LENGTH_PARAM");
671     if(!initVariableName(aParameters,item,0))
672       item.myValue = h->GetLength();
673     
674     p.append( item );
675   }
676   else if( hypType()=="Arithmetic1D" )
677   {
678     StdMeshers::StdMeshers_Arithmetic1D_var h =
679       StdMeshers::StdMeshers_Arithmetic1D::_narrow( hyp );
680
681     item.myName = tr( "SMESH_START_LENGTH_PARAM" );
682     if(!initVariableName(aParameters,item,0))
683       item.myValue = h->GetLength( true );
684     p.append( item );
685
686     customWidgets()->append (0);
687
688     item.myName = tr( "SMESH_END_LENGTH_PARAM" );
689     if(!initVariableName(aParameters,item,1))
690       item.myValue = h->GetLength( false );
691     p.append( item );
692
693     customWidgets()->append (0);
694
695     item.myName = tr( "SMESH_REVERCE_EDGES" );
696     p.append( item );
697
698     //StdMeshersGUI_EdgeDirectionParamWdg* aDirectionWidget =
699     //  new StdMeshersGUI_EdgeDirectionParamWdg();
700     StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget =
701       new StdMeshersGUI_SubShapeSelectorWdg();
702     QString anEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
703     if ( anEntry == "" )
704       anEntry = h->GetObjectEntry();
705     aDirectionWidget->SetMainShapeEntry( anEntry );
706     aDirectionWidget->SetListOfIDs( h->GetReversedEdges() );
707     aDirectionWidget->showPreview( true );
708     customWidgets()->append ( aDirectionWidget );
709   }
710   else if( hypType()=="MaxElementArea" )
711   {
712     StdMeshers::StdMeshers_MaxElementArea_var h =
713       StdMeshers::StdMeshers_MaxElementArea::_narrow( hyp );
714
715     item.myName = tr( "SMESH_MAX_ELEMENT_AREA_PARAM" );
716     if(!initVariableName(aParameters,item,0))
717       item.myValue = h->GetMaxElementArea();
718     p.append( item );
719     
720   }
721   else if( hypType()=="MaxElementVolume" )
722   {
723     StdMeshers::StdMeshers_MaxElementVolume_var h =
724       StdMeshers::StdMeshers_MaxElementVolume::_narrow( hyp );
725
726     item.myName = tr( "SMESH_MAX_ELEMENT_VOLUME_PARAM" );
727     if(!initVariableName(aParameters,item,0))
728       item.myValue = h->GetMaxElementVolume();
729     p.append( item );
730   }
731   else if( hypType()=="StartEndLength" )
732   {
733     StdMeshers::StdMeshers_StartEndLength_var h =
734       StdMeshers::StdMeshers_StartEndLength::_narrow( hyp );
735
736     item.myName = tr( "SMESH_START_LENGTH_PARAM" );
737
738     if(!initVariableName(aParameters,item,0)) 
739       item.myValue = h->GetLength( true );
740     p.append( item );
741     customWidgets()->append(0);
742
743     item.myName = tr( "SMESH_END_LENGTH_PARAM" );
744     if(!initVariableName(aParameters,item,1)) 
745       item.myValue = h->GetLength( false );
746     p.append( item );
747     customWidgets()->append(0);
748
749     item.myName = tr( "SMESH_REVERCE_EDGES" );
750     p.append( item );
751
752     //StdMeshersGUI_EdgeDirectionParamWdg* aDirectionWidget =
753     //  new StdMeshersGUI_EdgeDirectionParamWdg();
754     StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget =
755       new StdMeshersGUI_SubShapeSelectorWdg();
756     QString anEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
757     if ( anEntry == "" )
758       anEntry = h->GetObjectEntry();
759     aDirectionWidget->SetMainShapeEntry( anEntry );
760     aDirectionWidget->SetListOfIDs( h->GetReversedEdges() );
761     aDirectionWidget->SetMainShapeEntry( h->GetObjectEntry() );
762     aDirectionWidget->showPreview( true );
763     customWidgets()->append ( aDirectionWidget );
764   }
765   else if( hypType()=="Deflection1D" )
766   {
767     StdMeshers::StdMeshers_Deflection1D_var h =
768       StdMeshers::StdMeshers_Deflection1D::_narrow( hyp );
769     
770     item.myName = tr( "SMESH_DEFLECTION1D_PARAM" );
771     if(!initVariableName(aParameters,item,0)) 
772       item.myValue = h->GetDeflection();
773     p.append( item );
774   }
775   else if( hypType()=="AutomaticLength" )
776   {
777     StdMeshers::StdMeshers_AutomaticLength_var h =
778       StdMeshers::StdMeshers_AutomaticLength::_narrow( hyp );
779
780     item.myName = tr( "SMESH_FINENESS_PARAM" );
781     //item.myValue = h->GetFineness();
782     p.append( item );
783     customWidgets()->append
784       ( new TDoubleSliderWith2Lables( "0 ", " 1", h->GetFineness(), 0, 1, 0.01, 0 ));
785   }
786   else if( hypType()=="NumberOfLayers" )
787   {
788     StdMeshers::StdMeshers_NumberOfLayers_var h =
789       StdMeshers::StdMeshers_NumberOfLayers::_narrow( hyp );
790
791     item.myName = tr( "SMESH_NUMBER_OF_LAYERS" );
792     if(!initVariableName(aParameters,item,0))     
793       item.myValue = (int) h->GetNumberOfLayers();
794     p.append( item );
795   }
796   else if( hypType()=="LayerDistribution" )
797     {
798       StdMeshers::StdMeshers_LayerDistribution_var h =
799       StdMeshers::StdMeshers_LayerDistribution::_narrow( hyp );
800
801     item.myName = tr( "SMESH_LAYERS_DISTRIBUTION" ); p.append( item );
802     
803     //Set into not published hypo last variables
804     QStringList aLastVarsList;
805     for(int i = 0;i<aParameters->length();i++) 
806       aLastVarsList.append(QString(aParameters[i].in()));
807
808     if(!aLastVarsList.isEmpty())
809       h->GetLayerDistribution()->SetLastParameters(SMESHGUI::JoinObjectParameters(aLastVarsList));
810     
811     customWidgets()->append
812       ( new StdMeshersGUI_LayerDistributionParamWdg( h->GetLayerDistribution(), hypName(), dlg()));
813   }
814   else if( hypType()=="ProjectionSource1D" )
815   {
816     StdMeshers::StdMeshers_ProjectionSource1D_var h =
817       StdMeshers::StdMeshers_ProjectionSource1D::_narrow( hyp );
818
819     item.myName = tr( "SMESH_SOURCE_EDGE" ); p.append( item );
820     customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 1 ),
821                                                h->GetSourceEdge()));
822     item.myName = tr( "SMESH_SOURCE_MESH" ); p.append( item );
823     customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( MESH ),
824                                                h->GetSourceMesh()));
825     item.myName = tr( "SMESH_SOURCE_VERTEX" ); p.append( item );
826     customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
827                                                h->GetSourceVertex()));
828     item.myName = tr( "SMESH_TARGET_VERTEX" ); p.append( item );
829     customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
830                                                h->GetTargetVertex()));
831   }
832   else if( hypType()=="ProjectionSource2D" )
833   {
834     StdMeshers::StdMeshers_ProjectionSource2D_var h =
835       StdMeshers::StdMeshers_ProjectionSource2D::_narrow( hyp );
836
837     item.myName = tr( "SMESH_SOURCE_FACE" ); p.append( item );
838     customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 2 ),
839                                                h->GetSourceFace()));
840     item.myName = tr( "SMESH_SOURCE_MESH" ); p.append( item );
841     customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( MESH ),
842                                                h->GetSourceMesh()));
843     item.myName = tr( "SMESH_SOURCE_VERTEX1" ); p.append( item );
844     customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
845                                                h->GetSourceVertex( 1 )));
846     item.myName = tr( "SMESH_TARGET_VERTEX1" ); p.append( item );
847     customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
848                                                h->GetTargetVertex( 1 )));
849     item.myName = tr( "SMESH_SOURCE_VERTEX2" ); p.append( item );
850     customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
851                                                h->GetSourceVertex( 2 )));
852     item.myName = tr( "SMESH_TARGET_VERTEX2" ); p.append( item );
853     customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
854                                                h->GetTargetVertex( 2 )));
855   }
856   else if( hypType()=="ProjectionSource3D" )
857   {
858     StdMeshers::StdMeshers_ProjectionSource3D_var h =
859       StdMeshers::StdMeshers_ProjectionSource3D::_narrow( hyp );
860
861     item.myName = tr( "SMESH_SOURCE_3DSHAPE" ); p.append( item );
862     customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 3, TopAbs_FACE, 6, true ),
863                                                h->GetSource3DShape()));
864     item.myName = tr( "SMESH_SOURCE_MESH" ); p.append( item );
865     customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( MESH ),
866                                                h->GetSourceMesh()));
867     item.myName = tr( "SMESH_SOURCE_VERTEX1" ); p.append( item );
868     customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
869                                                h->GetSourceVertex( 1 )));
870     item.myName = tr( "SMESH_TARGET_VERTEX1" ); p.append( item );
871     customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
872                                                h->GetTargetVertex( 1 )));
873     item.myName = tr( "SMESH_SOURCE_VERTEX2" ); p.append( item );
874     customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
875                                                h->GetSourceVertex( 2 )));
876     item.myName = tr( "SMESH_TARGET_VERTEX2" ); p.append( item );
877     customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
878                                                h->GetTargetVertex( 2 )));
879   }
880   else if( hypType()=="QuadrangleParams" )
881   {
882     StdMeshers::StdMeshers_QuadrangleParams_var h =
883       StdMeshers::StdMeshers_QuadrangleParams::_narrow( hyp );
884
885     item.myName = tr( "SMESH_BASE_VERTEX" );
886     p.append( item );
887
888     StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget =
889       new StdMeshersGUI_SubShapeSelectorWdg();
890     aDirectionWidget->SetMaxSize(1);
891     aDirectionWidget->SetSubShType(TopAbs_VERTEX);
892     QString anEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
893     if ( anEntry == "" )
894       anEntry = h->GetObjectEntry();
895     aDirectionWidget->SetMainShapeEntry( anEntry );
896     SMESH::long_array_var aVec = new SMESH::long_array;
897     int vertID = h->GetTriaVertex();
898     if(vertID>0) {
899       aVec->length(1);
900       aVec[0] = vertID;
901     }
902     aDirectionWidget->SetListOfIDs( aVec );
903     aDirectionWidget->showPreview( true );
904     customWidgets()->append ( aDirectionWidget );
905   }
906   else
907     res = false;
908   return res;
909 }
910
911 //================================================================================
912 /*!
913  * \brief tune "standard" control
914   * \param w - control widget
915   * \param int - parameter index
916  */
917 //================================================================================
918
919 void StdMeshersGUI_StdHypothesisCreator::attuneStdWidget (QWidget* w, const int) const
920 {
921   SMESHGUI_SpinBox* sb = w->inherits( "SMESHGUI_SpinBox" ) ? ( SMESHGUI_SpinBox* )w : 0;
922   if( hypType()=="LocalLength" &&  sb )
923   {
924     if (sb->objectName() == tr("SMESH_LOCAL_LENGTH_PARAM"))
925       sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, 6 );
926     else if (sb->objectName() == tr("SMESH_LOCAL_LENGTH_PRECISION"))
927       sb->RangeStepAndValidator( 0.0, 1.0, 0.05, 7 );
928   }
929   else if( hypType()=="Arithmetic1D" && sb )
930   {
931     sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, 6 );
932   }
933   else if( hypType()=="MaxLength" && sb )
934   {
935     sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, 6 );
936     sb->setEnabled( !widget< QCheckBox >( 1 )->isChecked() );
937   }
938   else if( hypType()=="MaxElementArea" && sb )
939   {
940     sb->RangeStepAndValidator( VALUE_SMALL_2, VALUE_MAX_2, 1.0, 6 );
941   }
942   else if( hypType()=="MaxElementVolume" && sb )
943   {
944     sb->RangeStepAndValidator( VALUE_SMALL_3, VALUE_MAX_3, 1.0, 6 );
945   }
946   else if( hypType()=="StartEndLength" && sb )
947   {
948     sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, 6 );
949   }
950   else if( hypType()=="Deflection1D" && sb )
951   {
952     sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, 6 );
953   }
954   else if ( sb ) // default validator for possible ancestors
955   {
956     sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, 6 );
957   }
958 }
959
960 //================================================================================
961 /*!
962  * \brief Return dlg title
963   * \retval QString - title string
964  */
965 //================================================================================
966
967 QString StdMeshersGUI_StdHypothesisCreator::caption() const
968 {
969   return tr( QString( "SMESH_%1_TITLE" ).arg( hypTypeName( hypType() ) ).toLatin1().data() );
970 }
971
972 //================================================================================
973 /*!
974  * \brief return pixmap for dlg icon
975   * \retval QPixmap - 
976  */
977 //================================================================================
978
979 QPixmap StdMeshersGUI_StdHypothesisCreator::icon() const
980 {
981   QString hypIconName = tr( QString( "ICON_DLG_%1" ).arg( hypTypeName( hypType() ) ).toLatin1().data() );
982   return SMESHGUI::resourceMgr()->loadPixmap( "SMESH", hypIconName );
983 }
984
985 //================================================================================
986 /*!
987  * \brief Return hypothesis type name to show in dlg
988   * \retval QString - 
989  */
990 //================================================================================
991
992 QString StdMeshersGUI_StdHypothesisCreator::type() const
993 {
994   return tr( QString( "SMESH_%1_HYPOTHESIS" ).arg( hypTypeName( hypType() ) ).toLatin1().data() );
995 }
996
997 //================================================================================
998 /*!
999  * \brief String to insert in "SMESH_%1_HYPOTHESIS" to get hypothesis type name
1000  * from message resouce file
1001   * \param t - hypothesis type
1002   * \retval QString - result string
1003  */
1004 //================================================================================
1005
1006 QString StdMeshersGUI_StdHypothesisCreator::hypTypeName( const QString& t ) const
1007 {
1008   static QMap<QString,QString>  types;
1009   if( types.isEmpty() )
1010   {
1011     types.insert( "LocalLength", "LOCAL_LENGTH" );
1012     types.insert( "NumberOfSegments", "NB_SEGMENTS" );
1013     types.insert( "MaxElementArea", "MAX_ELEMENT_AREA" );
1014     types.insert( "MaxElementVolume", "MAX_ELEMENT_VOLUME" );
1015     types.insert( "StartEndLength", "START_END_LENGTH" );
1016     types.insert( "Deflection1D", "DEFLECTION1D" );
1017     types.insert( "Arithmetic1D", "ARITHMETIC_1D" );
1018     types.insert( "AutomaticLength", "AUTOMATIC_LENGTH" );
1019     types.insert( "ProjectionSource1D", "PROJECTION_SOURCE_1D" );
1020     types.insert( "ProjectionSource2D", "PROJECTION_SOURCE_2D" );
1021     types.insert( "ProjectionSource3D", "PROJECTION_SOURCE_3D" );
1022     types.insert( "NumberOfLayers", "NUMBER_OF_LAYERS" );
1023     types.insert( "LayerDistribution", "LAYER_DISTRIBUTION" );
1024     types.insert( "SegmentLengthAroundVertex", "SEGMENT_LENGTH_AROUND_VERTEX" );
1025     types.insert( "MaxLength", "MAX_LENGTH" );
1026     types.insert( "QuadrangleParams", "QUADRANGLE_PARAMS" );
1027   }
1028
1029   QString res;
1030   if( types.contains( t ) )
1031     res = types[ t ];
1032
1033   return res;
1034 }
1035
1036
1037 //=======================================================================
1038 //function : getCustomWidget
1039 //purpose  : is called from buildStdFrame()
1040 //=======================================================================
1041
1042 QWidget* StdMeshersGUI_StdHypothesisCreator::getCustomWidget( const StdParam & param,
1043                                                               QWidget*         parent,
1044                                                               const int        index) const
1045 {
1046   QWidget* w = 0;
1047   if ( index < customWidgets()->count() ) {
1048     w = customWidgets()->at( index );
1049     if ( w ) {
1050       w->setParent( parent );
1051       w->move( QPoint( 0, 0 ) );
1052     }
1053   }
1054   return w;
1055 }
1056
1057 //================================================================================
1058 /*!
1059  * \brief Set param value taken from a custom widget
1060   * \param param - SMESHGUI_GenericHypothesisCreator::StdParam structure
1061   * \param widget - widget presenting param
1062   * \retval bool - success flag
1063  * 
1064  * this method is called from getStdParamFromDlg()
1065  */
1066 //================================================================================
1067
1068 bool StdMeshersGUI_StdHypothesisCreator::getParamFromCustomWidget( StdParam & param,
1069                                                                    QWidget*   widget) const
1070 {
1071   if ( hypType()=="AutomaticLength" ) {
1072     TDoubleSliderWith2Lables* w = dynamic_cast<TDoubleSliderWith2Lables*>( widget );
1073     if ( w ) {
1074       param.myValue = w->value();
1075       return true;
1076     }
1077   }
1078   if ( hypType() == "MaxLength" ) {
1079     param.myValue = "";
1080     return true;
1081   }
1082   if ( widget->inherits( "StdMeshersGUI_ObjectReferenceParamWdg" ))
1083   {
1084     // show only 1st reference value
1085     if ( true /*widget == getWidgetForParam( 0 )*/) {
1086       const StdMeshersGUI_ObjectReferenceParamWdg * w =
1087         static_cast<const StdMeshersGUI_ObjectReferenceParamWdg*>( widget );
1088       param.myValue = w->GetValue();
1089     }
1090     return true;
1091   }
1092   if ( widget->inherits( "StdMeshersGUI_LayerDistributionParamWdg" ))
1093   {
1094     const StdMeshersGUI_LayerDistributionParamWdg * w =
1095       static_cast<const StdMeshersGUI_LayerDistributionParamWdg*>( widget );
1096     param.myValue = w->GetValue();
1097     return true;
1098   }
1099   //if ( widget->inherits( "StdMeshersGUI_EdgeDirectionParamWdg" ))
1100   //{
1101   //  const StdMeshersGUI_EdgeDirectionParamWdg * w =
1102   //    static_cast<const StdMeshersGUI_EdgeDirectionParamWdg*>( widget );
1103   //  param.myValue = w->GetValue();
1104   //  return true;
1105   //}
1106   if ( widget->inherits( "StdMeshersGUI_SubShapeSelectorWdg" ))
1107   {
1108     const StdMeshersGUI_SubShapeSelectorWdg * w =
1109       static_cast<const StdMeshersGUI_SubShapeSelectorWdg*>( widget );
1110     param.myValue = w->GetValue();
1111     return true;
1112   }
1113   return false;
1114 }
1115
1116 //================================================================================
1117 /*!
1118  * \brief called when operation cancelled
1119  */
1120 //================================================================================
1121
1122 void StdMeshersGUI_StdHypothesisCreator::onReject()
1123 {
1124   if ( hypType().startsWith("ProjectionSource" ))
1125   {
1126     // Uninstall filters of StdMeshersGUI_ObjectReferenceParamWdg
1127     deactivateObjRefParamWdg( customWidgets() );
1128   }
1129 }
1130
1131 //================================================================================
1132 /*!
1133  * \brief 
1134  */
1135 //================================================================================
1136
1137 void StdMeshersGUI_StdHypothesisCreator::valueChanged( QWidget* paramWidget)
1138 {
1139   if ( hypType() == "MaxLength" && paramWidget == getWidgetForParam(1) ) {
1140     getWidgetForParam(0)->setEnabled( !widget< QCheckBox >( 1 )->isChecked() );
1141     if ( !getWidgetForParam(0)->isEnabled() ) {
1142       StdMeshers::StdMeshers_MaxLength_var h =
1143         StdMeshers::StdMeshers_MaxLength::_narrow( initParamsHypothesis() );
1144       widget< QtxDoubleSpinBox >( 0 )->setValue( h->GetPreestimatedLength() );
1145     }
1146   }
1147 }
1148
1149 //================================================================================
1150 /*!
1151  *
1152  */
1153 //================================================================================
1154
1155 bool StdMeshersGUI_StdHypothesisCreator::initVariableName(SMESH::ListOfParameters_var theParameters, 
1156                                                           StdParam &theParams, 
1157                                                           int order) const
1158 {
1159   QString aVaribaleName = (theParameters->length() > order) ? QString(theParameters[order].in()) : QString("");
1160   theParams.isVariable = !aVaribaleName.isEmpty();
1161   if(theParams.isVariable) 
1162     theParams.myValue = aVaribaleName;
1163
1164   return theParams.isVariable;
1165 }