Salome HOME
Merge from V5_1_3_BR branch (07/12/09)
[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_SubShapeSelectorWdg.h"
37 #include "StdMeshersGUI_FixedPointsParamWdg.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" || hypType() == "LayerDistribution2D" )
382   {
383     StdMeshersGUI_LayerDistributionParamWdg* w = 
384       widget< StdMeshersGUI_LayerDistributionParamWdg >( 0 );
385     ok = ( w && w->IsOk() );
386   }
387   else if ( hypType() == "QuadrangleParams" )
388   {
389     StdMeshersGUI_SubShapeSelectorWdg* w = 
390       widget< StdMeshersGUI_SubShapeSelectorWdg >( 0 );
391     ok = ( w->GetListSize() > 0 );
392   }
393   return ok;
394 }
395
396 //================================================================================
397 /*!
398  * \brief Store params from GUI controls to a hypothesis
399   * \retval QString - text representation of parameters
400  */
401 //================================================================================
402
403 QString StdMeshersGUI_StdHypothesisCreator::storeParams() const
404 {
405   ListOfStdParams params;
406   bool res = getStdParamFromDlg( params );
407   if( isCreation() )
408   {
409     SMESH::SetName( SMESH::FindSObject( hypothesis() ), params[0].myValue.toString().toLatin1().data() );
410     params.erase( params.begin() );
411   }
412
413   QString valueStr = stdParamValues( params );
414   QStringList aVariablesList = getVariablesFromDlg();
415
416   if( res && !params.isEmpty() )
417   {
418     if( hypType()=="LocalLength" )
419     {
420       StdMeshers::StdMeshers_LocalLength_var h =
421         StdMeshers::StdMeshers_LocalLength::_narrow( hypothesis() );
422
423       h->SetLength( params[0].myValue.toDouble() );
424       h->SetParameters(aVariablesList.join(":").toLatin1().constData());
425       h->SetPrecision( params[1].myValue.toDouble() );
426       h->SetParameters(aVariablesList.join(":").toLatin1().constData());
427     }
428     else if( hypType()=="MaxLength" )
429     {
430       StdMeshers::StdMeshers_MaxLength_var h =
431         StdMeshers::StdMeshers_MaxLength::_narrow( hypothesis() );
432
433       h->SetLength( params[0].myValue.toDouble() );
434       h->SetParameters(aVariablesList.join(":").toLatin1().constData());
435       h->SetUsePreestimatedLength( widget< QCheckBox >( 1 )->isChecked() );
436       if ( !h->HavePreestimatedLength() && !h->_is_equivalent( initParamsHypothesis() )) {
437         StdMeshers::StdMeshers_MaxLength_var hInit =
438           StdMeshers::StdMeshers_MaxLength::_narrow( initParamsHypothesis() );
439         h->SetPreestimatedLength( hInit->GetPreestimatedLength() );
440       }
441     }
442     else if( hypType()=="SegmentLengthAroundVertex" )
443     {
444       StdMeshers::StdMeshers_SegmentLengthAroundVertex_var h =
445         StdMeshers::StdMeshers_SegmentLengthAroundVertex::_narrow( hypothesis() );
446
447       h->SetLength( params[0].myValue.toDouble() );
448       h->SetParameters(aVariablesList.join(":").toLatin1().constData());
449     }
450     else if( hypType()=="Arithmetic1D" )
451     {
452       StdMeshers::StdMeshers_Arithmetic1D_var h =
453         StdMeshers::StdMeshers_Arithmetic1D::_narrow( hypothesis() );
454
455       StdMeshersGUI_SubShapeSelectorWdg* w = 
456         widget< StdMeshersGUI_SubShapeSelectorWdg >( 2 );
457
458       h->SetStartLength( params[0].myValue.toDouble() );
459       h->SetParameters(aVariablesList.join(":").toLatin1().constData());
460       h->SetEndLength( params[1].myValue.toDouble() );
461       h->SetParameters(aVariablesList.join(":").toLatin1().constData());
462       if (w) {
463         h->SetReversedEdges( w->GetListOfIDs() );
464         h->SetObjectEntry( w->GetMainShapeEntry() );
465       }
466     }
467     else if( hypType()=="FixedPoints1D" )
468     {
469       StdMeshers::StdMeshers_FixedPoints1D_var h =
470         StdMeshers::StdMeshers_FixedPoints1D::_narrow( hypothesis() );
471
472       StdMeshersGUI_FixedPointsParamWdg* w1 = 
473         widget< StdMeshersGUI_FixedPointsParamWdg >( 0 );
474
475       StdMeshersGUI_SubShapeSelectorWdg* w2 = 
476         widget< StdMeshersGUI_SubShapeSelectorWdg >( 1 );
477
478       if (w1) {
479         h->SetParameters(aVariablesList.join(":").toLatin1().constData());
480         h->SetPoints( w1->GetListOfPoints() );
481         h->SetNbSegments( w1->GetListOfSegments() );
482       }
483       if (w2) {
484         h->SetReversedEdges( w2->GetListOfIDs() );
485         h->SetObjectEntry( w2->GetMainShapeEntry() );
486       }
487     }
488     else if( hypType()=="MaxElementArea" )
489     {
490       StdMeshers::StdMeshers_MaxElementArea_var h =
491         StdMeshers::StdMeshers_MaxElementArea::_narrow( hypothesis() );
492       h->SetParameters(aVariablesList.join(":").toLatin1().constData());
493       h->SetMaxElementArea( params[0].myValue.toDouble() );
494     }
495     else if( hypType()=="MaxElementVolume" )
496     {
497       StdMeshers::StdMeshers_MaxElementVolume_var h =
498         StdMeshers::StdMeshers_MaxElementVolume::_narrow( hypothesis() );
499
500       h->SetMaxElementVolume( params[0].myValue.toDouble() );
501       h->SetParameters(aVariablesList.join(":").toLatin1().constData());
502     }
503     else if( hypType()=="StartEndLength" )
504     {
505       StdMeshers::StdMeshers_StartEndLength_var h =
506         StdMeshers::StdMeshers_StartEndLength::_narrow( hypothesis() );
507
508       StdMeshersGUI_SubShapeSelectorWdg* w = 
509         widget< StdMeshersGUI_SubShapeSelectorWdg >( 2 );
510
511       h->SetStartLength( params[0].myValue.toDouble() );
512       h->SetParameters(aVariablesList.join(":").toLatin1().constData());
513       h->SetEndLength( params[1].myValue.toDouble() );
514       h->SetParameters(aVariablesList.join(":").toLatin1().constData());
515       if (w) {
516         h->SetReversedEdges( w->GetListOfIDs() );
517         h->SetObjectEntry( w->GetMainShapeEntry() );
518       }
519     }
520     else if( hypType()=="Deflection1D" )
521     {
522       StdMeshers::StdMeshers_Deflection1D_var h =
523         StdMeshers::StdMeshers_Deflection1D::_narrow( hypothesis() );
524       h->SetParameters(aVariablesList.join(":").toLatin1().constData());
525       h->SetDeflection( params[0].myValue.toDouble() );
526     }
527     else if( hypType()=="AutomaticLength" )
528     {
529       StdMeshers::StdMeshers_AutomaticLength_var h =
530         StdMeshers::StdMeshers_AutomaticLength::_narrow( hypothesis() );
531
532       h->SetFineness( params[0].myValue.toDouble() );
533     }
534     else if( hypType()=="NumberOfLayers" )
535     {
536       StdMeshers::StdMeshers_NumberOfLayers_var h =
537         StdMeshers::StdMeshers_NumberOfLayers::_narrow( hypothesis() );
538
539       h->SetNumberOfLayers( params[0].myValue.toInt() );
540       h->SetParameters(aVariablesList.join(":").toLatin1().constData());
541     }
542     else if( hypType()=="LayerDistribution" )
543     {
544       StdMeshers::StdMeshers_LayerDistribution_var h =
545         StdMeshers::StdMeshers_LayerDistribution::_narrow( hypothesis() );
546       StdMeshersGUI_LayerDistributionParamWdg* w = 
547         widget< StdMeshersGUI_LayerDistributionParamWdg >( 0 );
548       
549       h->SetLayerDistribution( w->GetHypothesis() );
550       h->SetParameters(w->GetHypothesis()->GetParameters());
551       w->GetHypothesis()->ClearParameters();
552     }
553     else if( hypType()=="NumberOfLayers2D" )
554     {
555       StdMeshers::StdMeshers_NumberOfLayers2D_var h =
556         StdMeshers::StdMeshers_NumberOfLayers2D::_narrow( hypothesis() );
557
558       h->SetNumberOfLayers( params[0].myValue.toInt() );
559       h->SetParameters(aVariablesList.join(":").toLatin1().constData());
560     }
561     else if( hypType()=="LayerDistribution2D" )
562     {
563       StdMeshers::StdMeshers_LayerDistribution2D_var h =
564         StdMeshers::StdMeshers_LayerDistribution2D::_narrow( hypothesis() );
565       StdMeshersGUI_LayerDistributionParamWdg* w = 
566         widget< StdMeshersGUI_LayerDistributionParamWdg >( 0 );
567       
568       h->SetLayerDistribution( w->GetHypothesis() );
569       h->SetParameters(w->GetHypothesis()->GetParameters());
570       w->GetHypothesis()->ClearParameters();
571     }
572     else if( hypType()=="ProjectionSource1D" )
573     {
574       StdMeshers::StdMeshers_ProjectionSource1D_var h =
575         StdMeshers::StdMeshers_ProjectionSource1D::_narrow( hypothesis() );
576
577       h->SetSourceEdge       ( geomFromWdg ( getWidgetForParam( 0 )));
578       h->SetSourceMesh       ( meshFromWdg ( getWidgetForParam( 1 )));
579       h->SetVertexAssociation( geomFromWdg ( getWidgetForParam( 2 )),
580                                geomFromWdg ( getWidgetForParam( 3 )));
581     }
582     else if( hypType()=="ProjectionSource2D" )
583     {
584       StdMeshers::StdMeshers_ProjectionSource2D_var h =
585         StdMeshers::StdMeshers_ProjectionSource2D::_narrow( hypothesis() );
586
587       h->SetSourceFace       ( geomFromWdg ( getWidgetForParam( 0 )));
588       h->SetSourceMesh       ( meshFromWdg ( getWidgetForParam( 1 )));
589       h->SetVertexAssociation( geomFromWdg ( getWidgetForParam( 2 )), // src1
590                                geomFromWdg ( getWidgetForParam( 4 )), // src2
591                                geomFromWdg ( getWidgetForParam( 3 )), // tgt1
592                                geomFromWdg ( getWidgetForParam( 5 ))); // tgt2
593     }
594     else if( hypType()=="ProjectionSource3D" )
595     {
596       StdMeshers::StdMeshers_ProjectionSource3D_var h =
597         StdMeshers::StdMeshers_ProjectionSource3D::_narrow( hypothesis() );
598
599       h->SetSource3DShape    ( geomFromWdg ( getWidgetForParam( 0 )));
600       h->SetSourceMesh       ( meshFromWdg ( getWidgetForParam( 1 )));
601       h->SetVertexAssociation( geomFromWdg ( getWidgetForParam( 2 )), // src1
602                                geomFromWdg ( getWidgetForParam( 4 )), // src2
603                                geomFromWdg ( getWidgetForParam( 3 )), // tgt1
604                                geomFromWdg ( getWidgetForParam( 5 ))); // tgt2
605     }
606     else if( hypType()=="QuadrangleParams" )
607     {
608       StdMeshers::StdMeshers_QuadrangleParams_var h =
609         StdMeshers::StdMeshers_QuadrangleParams::_narrow( hypothesis() );
610       StdMeshersGUI_SubShapeSelectorWdg* w = 
611         widget< StdMeshersGUI_SubShapeSelectorWdg >( 0 );
612       if (w) {
613         if( w->GetListSize() > 0 ) {
614           h->SetTriaVertex( w->GetListOfIDs()[0] ); // getlist must be called once
615           const char * entry = w->GetMainShapeEntry();
616           h->SetObjectEntry( entry );
617         }
618       }
619     }
620   }
621   return valueStr;
622 }
623
624 //================================================================================
625 /*!
626  * \brief Return parameter values as SMESHGUI_GenericHypothesisCreator::StdParam
627   * \param p - list of parameters
628   * \retval bool - success flag
629   *
630   * Is called from SMESHGUI_GenericHypothesisCreator::buildStdFrame().
631   * Parameters will be shown using "standard" controls:
632   *   Int by QtxIntSpinBox
633   *   Double by SMESHGUI_SpinBox
634   *   String by QLineEdit
635   * getCustomWidget() allows to redefine control for a parameter
636  */
637 //================================================================================
638
639 bool StdMeshersGUI_StdHypothesisCreator::stdParams( ListOfStdParams& p ) const
640 {
641   bool res = true;
642   SMESHGUI_GenericHypothesisCreator::StdParam item;
643
644   p.clear();
645   customWidgets()->clear();
646   if( isCreation() )
647   {
648     HypothesisData* data = SMESH::GetHypothesisData( hypType() );
649     item.myName = tr( "SMESH_NAME" );
650     item.myValue = data ? hypName() : QString();
651     p.append( item );
652     customWidgets()->append(0);
653   }
654   
655   SMESH::SMESH_Hypothesis_var hyp = initParamsHypothesis();
656   SMESH::ListOfParameters_var aParameters = hyp->GetLastParameters();
657
658   if( hypType()=="LocalLength" )
659   {
660     StdMeshers::StdMeshers_LocalLength_var h =
661       StdMeshers::StdMeshers_LocalLength::_narrow( hyp );
662     
663     item.myName = tr("SMESH_LOCAL_LENGTH_PARAM");
664     if(!initVariableName(aParameters,item,0))
665       item.myValue = h->GetLength();
666     p.append( item );     
667     
668     item.myName = tr("SMESH_LOCAL_LENGTH_PRECISION");
669     if(!initVariableName(aParameters,item,1))
670       item.myValue = h->GetPrecision(); 
671     p.append( item );
672     
673   }
674   else if( hypType()=="MaxLength" )
675   {
676     StdMeshers::StdMeshers_MaxLength_var h =
677       StdMeshers::StdMeshers_MaxLength::_narrow( hyp );
678     // try to set a right preestimated length to edited hypothesis
679     bool noPreestimatedAtEdition = false;
680     if ( !isCreation() ) {
681       StdMeshers::StdMeshers_MaxLength_var initHyp =
682         StdMeshers::StdMeshers_MaxLength::_narrow( initParamsHypothesis(true) );
683       noPreestimatedAtEdition =
684         ( initHyp->_is_nil() || !initHyp->HavePreestimatedLength() );
685       if ( !noPreestimatedAtEdition )
686         h->SetPreestimatedLength( initHyp->GetPreestimatedLength() );
687     }
688
689     item.myName = tr("SMESH_LOCAL_LENGTH_PARAM");
690     if(!initVariableName(aParameters,item,0))
691       item.myValue = h->GetLength();
692     p.append( item );
693     customWidgets()->append(0);
694
695     item.myName = tr("SMESH_USE_PREESTIMATED_LENGTH");
696     p.append( item );
697     QCheckBox* aQCheckBox = new QCheckBox(dlg());
698     if ( !noPreestimatedAtEdition && h->HavePreestimatedLength() ) {
699       aQCheckBox->setChecked( h->GetUsePreestimatedLength() );
700       connect( aQCheckBox, SIGNAL(  stateChanged(int) ), this, SLOT( onValueChanged() ) );
701     }
702     else {
703       aQCheckBox->setChecked( false );
704       aQCheckBox->setEnabled( false );
705     }
706     customWidgets()->append( aQCheckBox );
707   }
708   else if( hypType()=="SegmentLengthAroundVertex" )
709   {
710     StdMeshers::StdMeshers_SegmentLengthAroundVertex_var h =
711       StdMeshers::StdMeshers_SegmentLengthAroundVertex::_narrow( hyp );
712
713     item.myName = tr("SMESH_LOCAL_LENGTH_PARAM");
714     if(!initVariableName(aParameters,item,0))
715       item.myValue = h->GetLength();
716     
717     p.append( item );
718   }
719   else if( hypType()=="Arithmetic1D" )
720   {
721     StdMeshers::StdMeshers_Arithmetic1D_var h =
722       StdMeshers::StdMeshers_Arithmetic1D::_narrow( hyp );
723
724     item.myName = tr( "SMESH_START_LENGTH_PARAM" );
725     if(!initVariableName(aParameters,item,0))
726       item.myValue = h->GetLength( true );
727     p.append( item );
728
729     customWidgets()->append (0);
730
731     item.myName = tr( "SMESH_END_LENGTH_PARAM" );
732     if(!initVariableName(aParameters,item,1))
733       item.myValue = h->GetLength( false );
734     p.append( item );
735
736     customWidgets()->append (0);
737
738     item.myName = tr( "SMESH_REVERSED_EDGES" );
739     p.append( item );
740
741     StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget =
742       new StdMeshersGUI_SubShapeSelectorWdg();
743     QString aGeomEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
744     QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
745     if ( aGeomEntry == "" )
746       aGeomEntry = h->GetObjectEntry();
747
748     aDirectionWidget->SetGeomShapeEntry( aGeomEntry );
749     aDirectionWidget->SetMainShapeEntry( aMainEntry );
750     aDirectionWidget->SetListOfIDs( h->GetReversedEdges() );
751     aDirectionWidget->showPreview( true );
752     customWidgets()->append ( aDirectionWidget );
753   }
754
755
756   else if( hypType()=="FixedPoints1D" )
757   {
758     StdMeshers::StdMeshers_FixedPoints1D_var h =
759       StdMeshers::StdMeshers_FixedPoints1D::_narrow( hyp );
760
761     item.myName = tr( "SMESH_FIXED_POINTS" );
762     p.append( item );
763
764     StdMeshersGUI_FixedPointsParamWdg* aFixedPointsWidget =
765       new StdMeshersGUI_FixedPointsParamWdg();
766
767     if ( !isCreation() ) {
768       aFixedPointsWidget->SetListOfPoints( h->GetPoints() );
769       aFixedPointsWidget->SetListOfSegments( h->GetNbSegments() );
770     }
771     customWidgets()->append( aFixedPointsWidget );
772
773     item.myName = tr( "SMESH_REVERSED_EDGES" );
774     p.append( item );
775
776     StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget =
777       new StdMeshersGUI_SubShapeSelectorWdg();
778     QString anEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
779     QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
780     if ( anEntry == "" )
781       anEntry = h->GetObjectEntry();
782     aDirectionWidget->SetGeomShapeEntry( anEntry );
783     aDirectionWidget->SetMainShapeEntry( aMainEntry );
784     aDirectionWidget->SetListOfIDs( h->GetReversedEdges() );
785     aDirectionWidget->showPreview( true );
786     customWidgets()->append ( aDirectionWidget );
787   }
788
789
790   else if( hypType()=="MaxElementArea" )
791   {
792     StdMeshers::StdMeshers_MaxElementArea_var h =
793       StdMeshers::StdMeshers_MaxElementArea::_narrow( hyp );
794
795     item.myName = tr( "SMESH_MAX_ELEMENT_AREA_PARAM" );
796     if(!initVariableName(aParameters,item,0))
797       item.myValue = h->GetMaxElementArea();
798     p.append( item );
799     
800   }
801   else if( hypType()=="MaxElementVolume" )
802   {
803     StdMeshers::StdMeshers_MaxElementVolume_var h =
804       StdMeshers::StdMeshers_MaxElementVolume::_narrow( hyp );
805
806     item.myName = tr( "SMESH_MAX_ELEMENT_VOLUME_PARAM" );
807     if(!initVariableName(aParameters,item,0))
808       item.myValue = h->GetMaxElementVolume();
809     p.append( item );
810   }
811   else if( hypType()=="StartEndLength" )
812   {
813     StdMeshers::StdMeshers_StartEndLength_var h =
814       StdMeshers::StdMeshers_StartEndLength::_narrow( hyp );
815
816     item.myName = tr( "SMESH_START_LENGTH_PARAM" );
817
818     if(!initVariableName(aParameters,item,0)) 
819       item.myValue = h->GetLength( true );
820     p.append( item );
821     customWidgets()->append(0);
822
823     item.myName = tr( "SMESH_END_LENGTH_PARAM" );
824     if(!initVariableName(aParameters,item,1)) 
825       item.myValue = h->GetLength( false );
826     p.append( item );
827     customWidgets()->append(0);
828
829     item.myName = tr( "SMESH_REVERSED_EDGES" );
830     p.append( item );
831
832     StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget =
833       new StdMeshersGUI_SubShapeSelectorWdg();
834     QString anEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
835     QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
836     if ( anEntry == "" )
837       anEntry = h->GetObjectEntry();
838     aDirectionWidget->SetGeomShapeEntry( anEntry );
839     aDirectionWidget->SetMainShapeEntry( aMainEntry );
840     aDirectionWidget->SetListOfIDs( h->GetReversedEdges() );
841     aDirectionWidget->showPreview( true );
842     customWidgets()->append ( aDirectionWidget );
843   }
844   else if( hypType()=="Deflection1D" )
845   {
846     StdMeshers::StdMeshers_Deflection1D_var h =
847       StdMeshers::StdMeshers_Deflection1D::_narrow( hyp );
848     
849     item.myName = tr( "SMESH_DEFLECTION1D_PARAM" );
850     if(!initVariableName(aParameters,item,0)) 
851       item.myValue = h->GetDeflection();
852     p.append( item );
853   }
854   else if( hypType()=="AutomaticLength" )
855   {
856     StdMeshers::StdMeshers_AutomaticLength_var h =
857       StdMeshers::StdMeshers_AutomaticLength::_narrow( hyp );
858
859     item.myName = tr( "SMESH_FINENESS_PARAM" );
860     //item.myValue = h->GetFineness();
861     p.append( item );
862     customWidgets()->append
863       ( new TDoubleSliderWith2Lables( "0 ", " 1", h->GetFineness(), 0, 1, 0.01, 0 ));
864   }
865   else if( hypType()=="NumberOfLayers" )
866   {
867     StdMeshers::StdMeshers_NumberOfLayers_var h =
868       StdMeshers::StdMeshers_NumberOfLayers::_narrow( hyp );
869
870     item.myName = tr( "SMESH_NUMBER_OF_LAYERS" );
871     if(!initVariableName(aParameters,item,0))     
872       item.myValue = (int) h->GetNumberOfLayers();
873     p.append( item );
874   }
875   else if( hypType()=="LayerDistribution" ) {
876     StdMeshers::StdMeshers_LayerDistribution_var h =
877       StdMeshers::StdMeshers_LayerDistribution::_narrow( hyp );
878     
879     item.myName = tr( "SMESH_LAYERS_DISTRIBUTION" ); p.append( item );
880     
881     //Set into not published hypo last variables
882     QStringList aLastVarsList;
883     for(int i = 0;i<aParameters->length();i++) 
884       aLastVarsList.append(QString(aParameters[i].in()));
885
886     if(!aLastVarsList.isEmpty())
887       h->GetLayerDistribution()->SetLastParameters(aLastVarsList.join(":").toLatin1().constData());
888     
889     customWidgets()->append
890       ( new StdMeshersGUI_LayerDistributionParamWdg( h->GetLayerDistribution(), hypName(), dlg()));
891   }
892   else if( hypType()=="NumberOfLayers2D" ) {
893     StdMeshers::StdMeshers_NumberOfLayers2D_var h =
894       StdMeshers::StdMeshers_NumberOfLayers2D::_narrow( hyp );
895     
896     item.myName = tr( "SMESH_NUMBER_OF_LAYERS" );
897     if(!initVariableName(aParameters,item,0))     
898       item.myValue = (int) h->GetNumberOfLayers();
899     p.append( item );
900   }
901   else if( hypType()=="LayerDistribution2D" ) {
902     StdMeshers::StdMeshers_LayerDistribution2D_var h =
903       StdMeshers::StdMeshers_LayerDistribution2D::_narrow( hyp );
904
905     item.myName = tr( "SMESH_LAYERS_DISTRIBUTION" ); p.append( item );
906     
907     //Set into not published hypo last variables
908     QStringList aLastVarsList;
909     for(int i = 0;i<aParameters->length();i++) 
910       aLastVarsList.append(QString(aParameters[i].in()));
911
912     if(!aLastVarsList.isEmpty())
913       h->GetLayerDistribution()->SetLastParameters(aLastVarsList.join(":").toLatin1().constData());
914     
915     customWidgets()->append
916       ( new StdMeshersGUI_LayerDistributionParamWdg( h->GetLayerDistribution(), hypName(), dlg()));
917   }
918   else if( hypType()=="ProjectionSource1D" )
919   {
920     StdMeshers::StdMeshers_ProjectionSource1D_var h =
921       StdMeshers::StdMeshers_ProjectionSource1D::_narrow( hyp );
922
923     item.myName = tr( "SMESH_SOURCE_EDGE" ); p.append( item );
924     customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 1 ),
925                                                h->GetSourceEdge()));
926     item.myName = tr( "SMESH_SOURCE_MESH" ); p.append( item );
927     customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( MESH ),
928                                                h->GetSourceMesh()));
929     item.myName = tr( "SMESH_SOURCE_VERTEX" ); p.append( item );
930     customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
931                                                h->GetSourceVertex()));
932     item.myName = tr( "SMESH_TARGET_VERTEX" ); p.append( item );
933     customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
934                                                h->GetTargetVertex()));
935   }
936   else if( hypType()=="ProjectionSource2D" )
937   {
938     StdMeshers::StdMeshers_ProjectionSource2D_var h =
939       StdMeshers::StdMeshers_ProjectionSource2D::_narrow( hyp );
940
941     item.myName = tr( "SMESH_SOURCE_FACE" ); p.append( item );
942     customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 2 ),
943                                                h->GetSourceFace()));
944     item.myName = tr( "SMESH_SOURCE_MESH" ); p.append( item );
945     customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( MESH ),
946                                                h->GetSourceMesh()));
947     item.myName = tr( "SMESH_SOURCE_VERTEX1" ); p.append( item );
948     customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
949                                                h->GetSourceVertex( 1 )));
950     item.myName = tr( "SMESH_TARGET_VERTEX1" ); p.append( item );
951     customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
952                                                h->GetTargetVertex( 1 )));
953     item.myName = tr( "SMESH_SOURCE_VERTEX2" ); p.append( item );
954     customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
955                                                h->GetSourceVertex( 2 )));
956     item.myName = tr( "SMESH_TARGET_VERTEX2" ); p.append( item );
957     customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
958                                                h->GetTargetVertex( 2 )));
959   }
960   else if( hypType()=="ProjectionSource3D" )
961   {
962     StdMeshers::StdMeshers_ProjectionSource3D_var h =
963       StdMeshers::StdMeshers_ProjectionSource3D::_narrow( hyp );
964
965     item.myName = tr( "SMESH_SOURCE_3DSHAPE" ); p.append( item );
966     customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 3, TopAbs_FACE, 6, true ),
967                                                h->GetSource3DShape()));
968     item.myName = tr( "SMESH_SOURCE_MESH" ); p.append( item );
969     customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( MESH ),
970                                                h->GetSourceMesh()));
971     item.myName = tr( "SMESH_SOURCE_VERTEX1" ); p.append( item );
972     customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
973                                                h->GetSourceVertex( 1 )));
974     item.myName = tr( "SMESH_TARGET_VERTEX1" ); p.append( item );
975     customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
976                                                h->GetTargetVertex( 1 )));
977     item.myName = tr( "SMESH_SOURCE_VERTEX2" ); p.append( item );
978     customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
979                                                h->GetSourceVertex( 2 )));
980     item.myName = tr( "SMESH_TARGET_VERTEX2" ); p.append( item );
981     customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
982                                                h->GetTargetVertex( 2 )));
983   }
984   else if( hypType()=="QuadrangleParams" )
985   {
986     StdMeshers::StdMeshers_QuadrangleParams_var h =
987       StdMeshers::StdMeshers_QuadrangleParams::_narrow( hyp );
988
989     item.myName = tr( "SMESH_BASE_VERTEX" );
990     p.append( item );
991
992     StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget =
993       new StdMeshersGUI_SubShapeSelectorWdg();
994     aDirectionWidget->SetMaxSize(1);
995     aDirectionWidget->SetSubShType(TopAbs_VERTEX);
996     QString anEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
997     QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
998     if ( anEntry == "" )
999       anEntry = h->GetObjectEntry();
1000     aDirectionWidget->SetGeomShapeEntry( anEntry );
1001     aDirectionWidget->SetMainShapeEntry( aMainEntry );
1002     SMESH::long_array_var aVec = new SMESH::long_array;
1003     int vertID = h->GetTriaVertex();
1004     if(vertID>0) {
1005       aVec->length(1);
1006       aVec[0] = vertID;
1007     }
1008     aDirectionWidget->SetListOfIDs( aVec );
1009     aDirectionWidget->showPreview( true );
1010     customWidgets()->append ( aDirectionWidget );
1011   }
1012   else
1013     res = false;
1014   return res;
1015 }
1016
1017 //================================================================================
1018 /*!
1019  * \brief tune "standard" control
1020   * \param w - control widget
1021   * \param int - parameter index
1022  */
1023 //================================================================================
1024
1025 void StdMeshersGUI_StdHypothesisCreator::attuneStdWidget (QWidget* w, const int) const
1026 {
1027   SMESHGUI_SpinBox* sb = w->inherits( "SMESHGUI_SpinBox" ) ? ( SMESHGUI_SpinBox* )w : 0;
1028   if( hypType()=="LocalLength" &&  sb )
1029   {
1030     if (sb->objectName() == tr("SMESH_LOCAL_LENGTH_PARAM"))
1031       sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, 6 );
1032     else if (sb->objectName() == tr("SMESH_LOCAL_LENGTH_PRECISION"))
1033       sb->RangeStepAndValidator( 0.0, 1.0, 0.05, 7 );
1034   }
1035   else if( hypType()=="Arithmetic1D" && sb )
1036   {
1037     sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, 6 );
1038   }
1039   else if( hypType()=="MaxLength" && sb )
1040   {
1041     sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, 6 );
1042     sb->setEnabled( !widget< QCheckBox >( 1 )->isChecked() );
1043   }
1044   else if( hypType()=="MaxElementArea" && sb )
1045   {
1046     sb->RangeStepAndValidator( VALUE_SMALL_2, VALUE_MAX_2, 1.0, 6 );
1047   }
1048   else if( hypType()=="MaxElementVolume" && sb )
1049   {
1050     sb->RangeStepAndValidator( VALUE_SMALL_3, VALUE_MAX_3, 1.0, 6 );
1051   }
1052   else if( hypType()=="StartEndLength" && sb )
1053   {
1054     sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, 6 );
1055   }
1056   else if( hypType()=="Deflection1D" && sb )
1057   {
1058     sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, 6 );
1059   }
1060   else if ( sb ) // default validator for possible ancestors
1061   {
1062     sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, 6 );
1063   }
1064 }
1065
1066 //================================================================================
1067 /*!
1068  * \brief Return dlg title
1069   * \retval QString - title string
1070  */
1071 //================================================================================
1072
1073 QString StdMeshersGUI_StdHypothesisCreator::caption() const
1074 {
1075   return tr( QString( "SMESH_%1_TITLE" ).arg( hypTypeName( hypType() ) ).toLatin1().data() );
1076 }
1077
1078 //================================================================================
1079 /*!
1080  * \brief return pixmap for dlg icon
1081   * \retval QPixmap - 
1082  */
1083 //================================================================================
1084
1085 QPixmap StdMeshersGUI_StdHypothesisCreator::icon() const
1086 {
1087   QString hypIconName = tr( QString( "ICON_DLG_%1" ).arg( hypTypeName( hypType() ) ).toLatin1().data() );
1088   return SMESHGUI::resourceMgr()->loadPixmap( "SMESH", hypIconName );
1089 }
1090
1091 //================================================================================
1092 /*!
1093  * \brief Return hypothesis type name to show in dlg
1094   * \retval QString - 
1095  */
1096 //================================================================================
1097
1098 QString StdMeshersGUI_StdHypothesisCreator::type() const
1099 {
1100   return tr( QString( "SMESH_%1_HYPOTHESIS" ).arg( hypTypeName( hypType() ) ).toLatin1().data() );
1101 }
1102
1103 //================================================================================
1104 /*!
1105  * \brief String to insert in "SMESH_%1_HYPOTHESIS" to get hypothesis type name
1106  * from message resouce file
1107   * \param t - hypothesis type
1108   * \retval QString - result string
1109  */
1110 //================================================================================
1111
1112 QString StdMeshersGUI_StdHypothesisCreator::hypTypeName( const QString& t ) const
1113 {
1114   static QMap<QString,QString>  types;
1115   if( types.isEmpty() )
1116   {
1117     types.insert( "LocalLength", "LOCAL_LENGTH" );
1118     types.insert( "NumberOfSegments", "NB_SEGMENTS" );
1119     types.insert( "MaxElementArea", "MAX_ELEMENT_AREA" );
1120     types.insert( "MaxElementVolume", "MAX_ELEMENT_VOLUME" );
1121     types.insert( "StartEndLength", "START_END_LENGTH" );
1122     types.insert( "Deflection1D", "DEFLECTION1D" );
1123     types.insert( "Arithmetic1D", "ARITHMETIC_1D" );
1124     types.insert( "FixedPoints1D", "FIXED_POINTS_1D" );
1125     types.insert( "AutomaticLength", "AUTOMATIC_LENGTH" );
1126     types.insert( "ProjectionSource1D", "PROJECTION_SOURCE_1D" );
1127     types.insert( "ProjectionSource2D", "PROJECTION_SOURCE_2D" );
1128     types.insert( "ProjectionSource3D", "PROJECTION_SOURCE_3D" );
1129     types.insert( "NumberOfLayers", "NUMBER_OF_LAYERS" );
1130     types.insert( "LayerDistribution", "LAYER_DISTRIBUTION" );
1131     types.insert( "NumberOfLayers2D", "NUMBER_OF_LAYERS_2D" );
1132     types.insert( "LayerDistribution2D", "LAYER_DISTRIBUTION" );
1133     types.insert( "SegmentLengthAroundVertex", "SEGMENT_LENGTH_AROUND_VERTEX" );
1134     types.insert( "MaxLength", "MAX_LENGTH" );
1135     types.insert( "QuadrangleParams", "QUADRANGLE_PARAMS" );
1136   }
1137
1138   QString res;
1139   if( types.contains( t ) )
1140     res = types[ t ];
1141
1142   return res;
1143 }
1144
1145
1146 //=======================================================================
1147 //function : getCustomWidget
1148 //purpose  : is called from buildStdFrame()
1149 //=======================================================================
1150
1151 QWidget* StdMeshersGUI_StdHypothesisCreator::getCustomWidget( const StdParam & param,
1152                                                               QWidget*         parent,
1153                                                               const int        index) const
1154 {
1155   QWidget* w = 0;
1156   if ( index < customWidgets()->count() ) {
1157     w = customWidgets()->at( index );
1158     if ( w ) {
1159       w->setParent( parent );
1160       w->move( QPoint( 0, 0 ) );
1161     }
1162   }
1163   return w;
1164 }
1165
1166 //================================================================================
1167 /*!
1168  * \brief Set param value taken from a custom widget
1169   * \param param - SMESHGUI_GenericHypothesisCreator::StdParam structure
1170   * \param widget - widget presenting param
1171   * \retval bool - success flag
1172  * 
1173  * this method is called from getStdParamFromDlg()
1174  */
1175 //================================================================================
1176
1177 bool StdMeshersGUI_StdHypothesisCreator::getParamFromCustomWidget( StdParam & param,
1178                                                                    QWidget*   widget) const
1179 {
1180   if ( hypType()=="AutomaticLength" ) {
1181     TDoubleSliderWith2Lables* w = dynamic_cast<TDoubleSliderWith2Lables*>( widget );
1182     if ( w ) {
1183       param.myValue = w->value();
1184       return true;
1185     }
1186   }
1187   if ( hypType() == "MaxLength" ) {
1188     param.myValue = "";
1189     return true;
1190   }
1191   if ( widget->inherits( "StdMeshersGUI_ObjectReferenceParamWdg" ))
1192   {
1193     // show only 1st reference value
1194     if ( true /*widget == getWidgetForParam( 0 )*/) {
1195       const StdMeshersGUI_ObjectReferenceParamWdg * w =
1196         static_cast<const StdMeshersGUI_ObjectReferenceParamWdg*>( widget );
1197       param.myValue = w->GetValue();
1198     }
1199     return true;
1200   }
1201   if ( widget->inherits( "StdMeshersGUI_LayerDistributionParamWdg" ))
1202   {
1203     const StdMeshersGUI_LayerDistributionParamWdg * w =
1204       static_cast<const StdMeshersGUI_LayerDistributionParamWdg*>( widget );
1205     param.myValue = w->GetValue();
1206     return true;
1207   }
1208   if ( widget->inherits( "StdMeshersGUI_SubShapeSelectorWdg" ))
1209   {
1210     const StdMeshersGUI_SubShapeSelectorWdg * w =
1211       static_cast<const StdMeshersGUI_SubShapeSelectorWdg*>( widget );
1212     param.myValue = w->GetValue();
1213     return true;
1214   }
1215   if ( widget->inherits( "StdMeshersGUI_FixedPointsParamWdg" ))
1216   {
1217     const StdMeshersGUI_FixedPointsParamWdg * w =
1218       static_cast<const StdMeshersGUI_FixedPointsParamWdg*>( widget );
1219     param.myValue = w->GetValue();
1220     return true;
1221   }
1222   return false;
1223 }
1224
1225 //================================================================================
1226 /*!
1227  * \brief called when operation cancelled
1228  */
1229 //================================================================================
1230
1231 void StdMeshersGUI_StdHypothesisCreator::onReject()
1232 {
1233   if ( hypType().startsWith("ProjectionSource" ))
1234   {
1235     // Uninstall filters of StdMeshersGUI_ObjectReferenceParamWdg
1236     deactivateObjRefParamWdg( customWidgets() );
1237   }
1238 }
1239
1240 //================================================================================
1241 /*!
1242  * \brief 
1243  */
1244 //================================================================================
1245
1246 void StdMeshersGUI_StdHypothesisCreator::valueChanged( QWidget* paramWidget)
1247 {
1248   if ( hypType() == "MaxLength" && paramWidget == getWidgetForParam(1) ) {
1249     getWidgetForParam(0)->setEnabled( !widget< QCheckBox >( 1 )->isChecked() );
1250     if ( !getWidgetForParam(0)->isEnabled() ) {
1251       StdMeshers::StdMeshers_MaxLength_var h =
1252         StdMeshers::StdMeshers_MaxLength::_narrow( initParamsHypothesis() );
1253       widget< QtxDoubleSpinBox >( 0 )->setValue( h->GetPreestimatedLength() );
1254     }
1255   }
1256 }
1257
1258 //================================================================================
1259 /*!
1260  *
1261  */
1262 //================================================================================
1263
1264 bool StdMeshersGUI_StdHypothesisCreator::initVariableName(SMESH::ListOfParameters_var theParameters, 
1265                                                           StdParam &theParams, 
1266                                                           int order) const
1267 {
1268   QString aVaribaleName = (theParameters->length() > order) ? QString(theParameters[order].in()) : QString("");
1269   theParams.isVariable = !aVaribaleName.isEmpty();
1270   if(theParams.isVariable) 
1271     theParams.myValue = aVaribaleName;
1272
1273   return theParams.isVariable;
1274 }