Salome HOME
PAL10953. Add Fineness parameter to Automatic Length hypothesis
[modules/smesh.git] / src / StdMeshersGUI / StdMeshersGUI_Parameters.cxx
1 //  SMESH StdMeshersGUI : GUI for standard meshers
2 //
3 //  Copyright (C) 2003  CEA
4 // 
5 //  This library is free software; you can redistribute it and/or 
6 //  modify it under the terms of the GNU Lesser General Public 
7 //  License as published by the Free Software Foundation; either 
8 //  version 2.1 of the License. 
9 // 
10 //  This library is distributed in the hope that it will be useful, 
11 //  but WITHOUT ANY WARRANTY; without even the implied warranty of 
12 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
13 //  Lesser General Public License for more details. 
14 // 
15 //  You should have received a copy of the GNU Lesser General Public 
16 //  License along with this library; if not, write to the Free Software 
17 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
18 // 
19 //  See http://www.salome-platform.org or email : webmaster.salome@opencascade.org
20 //
21 //
22 //
23 //  File   : StdMeshersGUI_Parameters.cxx
24 //  Module : SMESH
25 //  $Header$
26
27 #include "StdMeshersGUI_Parameters.h"
28
29 #include <qobject.h>
30 #include <qhbox.h>
31 #include <qslider.h>
32 #include <qlabel.h>
33
34 #include <math.h>
35 //#include <float.h>
36
37 using namespace std;
38
39 #define VALUE_MAX   1.0e+15 // COORD_MAX
40 #define VALUE_MAX_2 (VALUE_MAX*VALUE_MAX)
41 #define VALUE_MAX_3 (VALUE_MAX*VALUE_MAX*VALUE_MAX)
42
43 #define VALUE_SMALL   1.0e-15
44 #define VALUE_SMALL_2 (VALUE_SMALL*VALUE_SMALL)
45 #define VALUE_SMALL_3 (VALUE_SMALL*VALUE_SMALL*VALUE_SMALL)
46
47 //=======================================================================
48 //function : HasParameters
49 //purpose  : 
50 //=======================================================================
51
52 bool StdMeshersGUI_Parameters::HasParameters (const QString& hypType)
53 {
54   return ((hypType.compare("LocalLength") == 0) ||
55           (hypType.compare("NumberOfSegments") == 0) ||
56           (hypType.compare("MaxElementArea") == 0) ||
57           (hypType.compare("MaxElementVolume") == 0) ||
58           (hypType.compare("StartEndLength") == 0) ||
59           (hypType.compare("Deflection1D") == 0) ||
60           (hypType.compare("AutomaticLength") == 0) ||
61           (hypType.compare("Arithmetic1D") == 0));
62 }
63
64 //=======================================================================
65 //function : SetInitValue
66 //purpose  : 
67 //=======================================================================
68
69 void StdMeshersGUI_Parameters::SetInitValue(SMESHGUI_aParameterPtr param,
70                                             int                    initValue)
71 {
72   SMESHGUI_intParameter* p = dynamic_cast<SMESHGUI_intParameter*>(param.get());
73   if ( p )
74   {
75     p->InitValue() = initValue;
76     return;
77   }
78   
79   SMESHGUI_enumParameter* q = dynamic_cast<SMESHGUI_enumParameter*>(param.get());
80   if( q )
81   {
82     q->InitValue() = initValue;
83     return;
84   }
85
86   SMESHGUI_boolParameter* b = dynamic_cast<SMESHGUI_boolParameter*>(param.get());
87   if( b )
88   {
89     b->InitValue() = (bool)initValue;
90     return;
91   }
92 }
93
94 //=======================================================================
95 //function : SetInitValue
96 //purpose  : 
97 //=======================================================================
98
99 void StdMeshersGUI_Parameters::SetInitValue(SMESHGUI_aParameterPtr param,
100                                             double                 initValue)
101 {
102   SMESHGUI_doubleParameter* p = dynamic_cast<SMESHGUI_doubleParameter*>(param.get());
103   if ( p ) p->InitValue() = initValue;
104 }
105
106 //=======================================================================
107 //function : SetInitValue
108 //purpose  : 
109 //=======================================================================
110
111 void StdMeshersGUI_Parameters::SetInitValue(SMESHGUI_aParameterPtr param,
112                                             const char*            initValue)
113 {
114   SMESHGUI_strParameter* p = dynamic_cast<SMESHGUI_strParameter*>(param.get());
115   if ( p ) p->InitValue() = initValue;
116 }
117
118 //=======================================================================
119 //function : SetInitValue
120 //purpose  :
121 //=======================================================================
122 void StdMeshersGUI_Parameters::SetInitValue( SMESHGUI_aParameterPtr param,
123                                              SMESH::double_array&   initValue)
124 {
125   SMESHGUI_tableParameter* p = dynamic_cast<SMESHGUI_tableParameter*>(param.get());
126   if( p )
127   {
128     p->setRowCount( initValue.length()/2 );
129     p->setData( initValue );
130   }
131 }
132
133 //================================================================================
134 /*!
135  * \brief Macros to comfortably create SMESHGUI_aParameterPtr of different types
136  */
137 //================================================================================
138
139 // SMESHGUI_doubleParameter( initValue, label, bottom, top, step, decimals )
140 #define DOUBLE_PARAM(v,l,b,t,s,d) SMESHGUI_aParameterPtr(new SMESHGUI_doubleParameter(v,l,b,t,s,d))
141 #define INT_PARAM(v,l,b,t) SMESHGUI_aParameterPtr(new SMESHGUI_intParameter(v,l,b,t))
142 #define ENUM_PARAM(v,i,l) SMESHGUI_aParameterPtr(new SMESHGUI_enumParameter(v,i,l))
143 #define STR_PARAM(i,l,preview) SMESHGUI_aParameterPtr(new SMESHGUI_strParameter(i,l,preview))
144 #define BOOL_PARAM(i,l,preview) SMESHGUI_aParameterPtr(new SMESHGUI_boolParameter(i,l,preview))
145
146 //================================================================================
147 /*!
148  * \brief Fill parameter list with default values
149   * \param hypType - The name of hypothesis type
150   * \param paramList - The list to fill
151  */
152 //================================================================================
153
154 void StdMeshersGUI_Parameters::GetParameters (const QString&                 hypType,
155                                               list<SMESHGUI_aParameterPtr> & paramList )
156 {
157   paramList.clear();
158
159   if (hypType.compare("LocalLength") == 0)
160   {
161     paramList.push_back( DOUBLE_PARAM (1.0,
162                                        QObject::tr("SMESH_LOCAL_LENGTH_PARAM"),
163                                        VALUE_SMALL, VALUE_MAX, 1.0, 6));
164   }
165   else if (hypType.compare("NumberOfSegments") == 0)
166   {
167     //0-th parameter in list
168     paramList.push_back ( INT_PARAM (3,
169                                      QObject::tr("SMESH_NB_SEGMENTS_PARAM"),
170                                      1, 9999 ));
171     QStringList types;
172     types.append( QObject::tr( "SMESH_DISTR_REGULAR" ) );
173     types.append( QObject::tr( "SMESH_DISTR_SCALE"   ) );
174     types.append( QObject::tr( "SMESH_DISTR_TAB"     ) );
175     types.append( QObject::tr( "SMESH_DISTR_EXPR"    ) );
176     //string description of distribution types
177
178     SMESHGUI_enumParameter* type = new SMESHGUI_enumParameter( types, 0, QObject::tr( "SMESH_DISTR_TYPE" ) );
179     SMESHGUI_dependParameter::ShownMap& aMap = type->shownMap();
180     aMap[0].append( 0 ); // if DistrType=0 (regular), then number of segments and types are shown (0-th and 1-th)
181     aMap[0].append( 1 );
182     aMap[1].append( 0 ); // if DistrType=1 (scale), then number of segments, types and scale are shown
183     aMap[1].append( 1 );
184     aMap[1].append( 2 );
185     aMap[2].append( 0 ); // if DistrType=2 (table), then number of segments, types, table and exponent are shown
186     aMap[2].append( 1 );
187     aMap[2].append( 3 );
188     aMap[2].append( 5 );
189     aMap[3].append( 0 ); // if DistrType=3 (expression), then number of segments, types, expression and exponent are shown
190     aMap[3].append( 1 );
191     aMap[3].append( 4 );
192     aMap[3].append( 5 );
193     //1-th parameter in list
194     paramList.push_back ( SMESHGUI_aParameterPtr( type ) );
195
196     //2-th parameter in list
197     paramList.push_back ( DOUBLE_PARAM (1.0,
198                                      QObject::tr("SMESH_NB_SEGMENTS_SCALE_PARAM"),
199                                      VALUE_SMALL, VALUE_MAX, 0.1, 6 ));
200     SMESHGUI_tableParameter* tab = new SMESHGUI_tableParameter( 0.0, QObject::tr( "SMESH_TAB_FUNC" ), true );
201     tab->setRowCount( 5 );
202     tab->setColCount( 2 );
203     //default size of table: 5x2
204     
205     tab->setColName( 0, "t" );
206     tab->setColName( 1, "f(t)" );    
207     tab->setValidator( 0, 0.0, 1.0, 3 );
208     tab->setValidator( 1, 1E-7, 1E+300, 3 );
209     tab->setEditRows( true );
210
211     //3-th parameter in list
212     paramList.push_back ( SMESHGUI_aParameterPtr( tab ) );
213
214     //4-th parameter in list
215     paramList.push_back ( STR_PARAM ( "", QObject::tr( "SMESH_EXPR_FUNC" ), true ) );
216
217     //5-th parameter in list
218     paramList.push_back ( BOOL_PARAM ( false, QObject::tr( "SMESH_EXP_MODE" ), true ) );
219   }
220   else if (hypType.compare("Arithmetic1D") == 0)
221   {
222     paramList.push_back( DOUBLE_PARAM ( 1.0,
223                                       QObject::tr("SMESH_START_LENGTH_PARAM"), 
224                                       VALUE_SMALL, VALUE_MAX, 1, 6));
225     paramList.push_back( DOUBLE_PARAM ( 10.0,
226                                        QObject::tr("SMESH_END_LENGTH_PARAM"),
227                                        VALUE_SMALL, VALUE_MAX, 1, 6));
228   }
229   else if (hypType.compare("MaxElementArea") == 0)
230   {
231     paramList.push_back( DOUBLE_PARAM (1.0,
232                                        QObject::tr("SMESH_MAX_ELEMENT_AREA_PARAM"), 
233                                        VALUE_SMALL_2, VALUE_MAX_2, 1.0, 6));
234   }
235   else if (hypType.compare("MaxElementVolume") == 0)
236   {
237     paramList.push_back( DOUBLE_PARAM ( 1.0,
238                                        QObject::tr("SMESH_MAX_ELEMENT_VOLUME_PARAM"), 
239                                        VALUE_SMALL_3, VALUE_MAX_3, 1.0, 6));
240   }
241   else if (hypType.compare("StartEndLength") == 0)
242   {
243     paramList.push_back( DOUBLE_PARAM ( 1.0,
244                                       QObject::tr("SMESH_START_LENGTH_PARAM"), 
245                                       VALUE_SMALL, VALUE_MAX, 1, 6));
246     paramList.push_back( DOUBLE_PARAM ( 10.0,
247                                        QObject::tr("SMESH_END_LENGTH_PARAM"),
248                                        VALUE_SMALL, VALUE_MAX, 1, 6));
249   }
250   else if (hypType.compare("Deflection1D") == 0)
251   {
252     paramList.push_back( DOUBLE_PARAM ( 1.0,
253                                        QObject::tr("SMESH_DEFLECTION1D_PARAM"), 
254                                        VALUE_SMALL, VALUE_MAX, 1, 6));
255   }
256   else if (hypType.compare("AutomaticLength") == 0)
257   {
258     SMESHGUI_aParameter * param =
259       new StdMeshersGUI_doubleSliderParameter ( QObject::tr("SMESH_FINENESS_PARAM"),
260                                                 "0 ", " 1",
261                                                 0.0, 0.0, 1.0, 0.05);
262     paramList.push_back( SMESHGUI_aParameterPtr( param ));
263   }
264 }
265
266 //================================================================================
267 /*!
268  * \brief  Fill parameter list with real values the hypothesis has
269   * \param theHyp - The hypothesis to retrieve parameter values from
270   * \param paramList - The list to fill
271  */
272 //================================================================================
273
274 void StdMeshersGUI_Parameters::GetParameters (SMESH::SMESH_Hypothesis_ptr    theHyp,
275                                               list<SMESHGUI_aParameterPtr> & paramList )
276 {
277   paramList.clear();
278
279   if (theHyp->_is_nil()) return;
280
281   QString hypType = theHyp->GetName();
282   GetParameters( hypType, paramList ); // get default parameters
283   if ( paramList.empty() )
284     return;
285
286   // set current values
287   if (hypType.compare("LocalLength") == 0)
288   {
289     StdMeshers::StdMeshers_LocalLength_var LL =
290       StdMeshers::StdMeshers_LocalLength::_narrow(theHyp);
291     SetInitValue( paramList.front(), LL->GetLength() );
292   }
293   else if (hypType.compare("NumberOfSegments") == 0)
294   {
295     StdMeshers::StdMeshers_NumberOfSegments_var NOS =
296       StdMeshers::StdMeshers_NumberOfSegments::_narrow(theHyp);
297       
298     list<SMESHGUI_aParameterPtr>::iterator anIt = paramList.begin();
299     SetInitValue( *anIt, (int) NOS->GetNumberOfSegments()); anIt++;
300     int DType = (int) NOS->GetDistrType();
301     SetInitValue( *anIt, DType ); anIt++;
302     
303     if( DType==1 )
304       SetInitValue( *anIt, NOS->GetScaleFactor());
305     anIt++;
306
307     if( DType==2 )
308     {
309       SMESH::double_array* tab_func = NOS->GetTableFunction();
310       SetInitValue( *anIt, *tab_func );
311       delete tab_func;
312     }
313     anIt++;
314
315     if( DType==3 )
316     {
317       char* expr_func = NOS->GetExpressionFunction();
318       SetInitValue( *anIt, expr_func );
319       //delete expr_func;
320     }
321     anIt++;
322
323     if( DType==2 || DType==3 )
324       SetInitValue( *anIt, (bool)NOS->IsExponentMode());
325   }
326   else if (hypType.compare("Arithmetic1D") == 0)
327   {
328     StdMeshers::StdMeshers_Arithmetic1D_var hyp =
329       StdMeshers::StdMeshers_Arithmetic1D::_narrow(theHyp);
330     SetInitValue( paramList.front(), hyp->GetLength( true )) ;
331     SetInitValue( paramList.back(), hyp->GetLength( false )) ;
332   }
333   else if (hypType.compare("MaxElementArea") == 0)
334   {
335     StdMeshers::StdMeshers_MaxElementArea_var MEA =
336       StdMeshers::StdMeshers_MaxElementArea::_narrow(theHyp);
337     SetInitValue( paramList.front(), MEA->GetMaxElementArea() );
338   }
339   else if (hypType.compare("MaxElementVolume") == 0)
340   {
341     StdMeshers::StdMeshers_MaxElementVolume_var MEV =
342       StdMeshers::StdMeshers_MaxElementVolume::_narrow(theHyp);
343     SetInitValue( paramList.front(), MEV->GetMaxElementVolume() );
344   }
345   else if (hypType.compare("StartEndLength") == 0)
346   {
347     StdMeshers::StdMeshers_StartEndLength_var hyp =
348       StdMeshers::StdMeshers_StartEndLength::_narrow(theHyp);
349     SetInitValue( paramList.front(), hyp->GetLength( true ));
350     SetInitValue( paramList.back(),  hyp->GetLength( false ));
351   }
352   else if (hypType.compare("Deflection1D") == 0)
353   {
354     StdMeshers::StdMeshers_Deflection1D_var hyp =
355       StdMeshers::StdMeshers_Deflection1D::_narrow(theHyp);
356     SetInitValue( paramList.back(),  hyp->GetDeflection()) ;
357   }
358   else if (hypType.compare("AutomaticLength") == 0)
359   {
360     StdMeshers::StdMeshers_AutomaticLength_var hyp =
361       StdMeshers::StdMeshers_AutomaticLength::_narrow(theHyp);
362     SetInitValue( paramList.back(),  hyp->GetFineness());
363   }
364 }
365
366 //================================================================================
367 /*!
368  * \brief Return parameter values as a string
369   * \param hyp - not used
370   * \param paramList - list of parameter values
371   * \param params - output string
372  */
373 //================================================================================
374
375 void StdMeshersGUI_Parameters::GetParameters (SMESH::SMESH_Hypothesis_ptr         ,
376                                               const list<SMESHGUI_aParameterPtr>& paramList,
377                                               QString&                            params)
378 {
379   params = "";
380   list<SMESHGUI_aParameterPtr>::const_iterator paramIt = paramList.begin();
381   for ( ; paramIt != paramList.end(); paramIt++) {
382     if (params.compare("")) params += " ; ";
383
384     SMESHGUI_aParameter::Type t = (*paramIt)->GetType();
385     if( t==SMESHGUI_aParameter::DOUBLE )
386     {
387       double aDoubleValue = 0.;
388       (*paramIt)->GetNewDouble(aDoubleValue);
389       params += QString::number(aDoubleValue);
390     }
391     else if( t==SMESHGUI_aParameter::STRING || t==SMESHGUI_aParameter::ENUM )
392     {
393       QString aStrValue( "" );
394       (*paramIt)->GetNewText(aStrValue);
395       params += aStrValue.simplifyWhiteSpace();
396     }
397     else if( t==SMESHGUI_aParameter::TABLE )
398     {
399       params += "TABLE";
400     }
401     else
402     {
403       int aIntValue = 0;
404       (*paramIt)->GetNewInt(aIntValue);
405       params += QString::number(aIntValue);
406     }
407   }
408 }
409
410 //=======================================================================
411 //function : SetParameters
412 //purpose  : 
413 //=======================================================================
414
415 //================================================================================
416 /*!
417  * \brief Set parameter values from the list into a hypothesis
418   * \param theHyp - The hypothesis to modify
419   * \param paramList - list of parameter values
420   * \retval bool - true if any parameter value changed
421  */
422 //================================================================================
423
424 bool StdMeshersGUI_Parameters::SetParameters(SMESH::SMESH_Hypothesis_ptr          theHyp,
425                                              const list<SMESHGUI_aParameterPtr> & paramList )
426 {
427   if (theHyp->_is_nil() || paramList.empty()) return false;
428
429   bool modified = false;
430
431   QString hypType = theHyp->GetName();
432
433   if (hypType.compare("LocalLength") == 0)
434   {
435     StdMeshers::StdMeshers_LocalLength_var LL =
436       StdMeshers::StdMeshers_LocalLength::_narrow(theHyp);
437     double length = LL->GetLength();
438     modified = paramList.front()->GetNewDouble( length );
439     LL->SetLength(length);
440   }
441   else if (hypType.compare("NumberOfSegments") == 0)
442   {
443     StdMeshers::StdMeshers_NumberOfSegments_var NOS =
444       StdMeshers::StdMeshers_NumberOfSegments::_narrow(theHyp);
445
446     list<SMESHGUI_aParameterPtr>::const_iterator anIt = paramList.begin();
447     int NbSeg, DType;
448     double Scale;
449     SMESH::double_array TabF;
450     QString exprF;
451     int expType;
452
453     modified = (*anIt)->GetNewInt( NbSeg ); anIt++;
454     modified = (*anIt)->GetNewInt( DType ) || modified; anIt++;
455     modified = (*anIt)->GetNewDouble( Scale ) || modified; anIt++;
456     SMESHGUI_aParameterPtr p = *anIt;
457     ((SMESHGUI_tableParameter*)p.get())->data( TabF ); anIt++; modified = true;
458     modified = (*anIt)->GetNewText( exprF ) || modified; anIt++;
459     modified = (*anIt)->GetNewInt( expType ) || modified;
460     
461     NOS->SetNumberOfSegments( NbSeg );
462     NOS->SetDistrType( DType );
463     if( DType==1 )
464       NOS->SetScaleFactor( Scale );
465     if( DType==2 )
466       NOS->SetTableFunction( TabF );
467     if( DType==3 )
468       NOS->SetExpressionFunction( CORBA::string_dup( exprF.latin1() ) );
469     if( DType==2 || DType==3 )
470       NOS->SetExponentMode( (bool)expType );
471   }
472   else if (hypType.compare("Arithmetic1D") == 0)
473   {
474     if ( paramList.size() != 2 )
475       return false;
476     StdMeshers::StdMeshers_Arithmetic1D_var hyp =
477       StdMeshers::StdMeshers_Arithmetic1D::_narrow(theHyp);
478     double begLength = hyp->GetLength( true ) ;
479     double endLength = hyp->GetLength( false ) ;
480     modified = paramList.front()->GetNewDouble( begLength );
481     modified = paramList.back()->GetNewDouble( endLength ) || modified;
482     hyp->SetLength( begLength, true );
483     hyp->SetLength( endLength, false );
484   }
485   else if (hypType.compare("MaxElementArea") == 0)
486   {
487     StdMeshers::StdMeshers_MaxElementArea_var MEA =
488       StdMeshers::StdMeshers_MaxElementArea::_narrow(theHyp);
489     double MaxArea = MEA->GetMaxElementArea();
490     modified = paramList.front()->GetNewDouble( MaxArea );
491     MEA->SetMaxElementArea(MaxArea);
492   }
493   else if (hypType.compare("MaxElementVolume") == 0)
494   {
495     StdMeshers::StdMeshers_MaxElementVolume_var MEV =
496       StdMeshers::StdMeshers_MaxElementVolume::_narrow(theHyp);
497     double MaxVolume = MEV->GetMaxElementVolume() ;
498     modified = paramList.front()->GetNewDouble( MaxVolume );
499     MEV->SetMaxElementVolume(MaxVolume);
500   }
501   else if (hypType.compare("StartEndLength") == 0)
502   {
503     if ( paramList.size() != 2 )
504       return false;
505     StdMeshers::StdMeshers_StartEndLength_var hyp =
506       StdMeshers::StdMeshers_StartEndLength::_narrow(theHyp);
507     double begLength = hyp->GetLength( true ) ;
508     double endLength = hyp->GetLength( false ) ;
509     modified = paramList.front()->GetNewDouble( begLength );
510     modified = paramList.back()->GetNewDouble( endLength ) || modified;
511     hyp->SetLength( begLength, true );
512     hyp->SetLength( endLength, false );
513   }
514   else if (hypType.compare("Deflection1D") == 0)
515   {
516     StdMeshers::StdMeshers_Deflection1D_var hyp =
517       StdMeshers::StdMeshers_Deflection1D::_narrow(theHyp);
518     double value = hyp->GetDeflection() ;
519     modified = paramList.front()->GetNewDouble( value );
520     hyp->SetDeflection( value );
521   }
522   else if (hypType.compare("AutomaticLength") == 0)
523   {
524     StdMeshers::StdMeshers_AutomaticLength_var hyp =
525       StdMeshers::StdMeshers_AutomaticLength::_narrow(theHyp);
526     double value = hyp->GetFineness() ;
527     modified = paramList.front()->GetNewDouble( value );
528     hyp->SetFineness( value );
529   }
530   return modified ;
531 }
532
533 //================================================================================
534 /*!
535  * \brief Widget: slider with left and right labels
536  */
537 //================================================================================
538
539 class StdMeshersGUI_SliderWith2Lables: public QHBox
540 {
541 public:
542   StdMeshersGUI_SliderWith2Lables( const QString& leftLabel,
543                                    const QString& rightLabel,
544                                    QWidget * parent =0,
545                                    const char * name=0 );
546   QSlider * getSlider() const { return _slider; }
547 private:
548   QSlider * _slider;
549 };
550
551 StdMeshersGUI_SliderWith2Lables::StdMeshersGUI_SliderWith2Lables( const QString& leftLabel,
552                                                                   const QString& rightLabel,
553                                                                   QWidget *      parent,
554                                                                   const char *   name )
555   :QHBox(parent,name)
556 {
557   if ( !leftLabel.isEmpty() )
558     (new QLabel( this ))->setText( leftLabel );
559
560   _slider = new QSlider( Horizontal, this );
561
562   if ( !rightLabel.isEmpty() )
563     (new QLabel( this ))->setText( rightLabel );
564 }
565
566 //================================================================================
567 /*!
568  * \brief Constructor
569   * \param label - main label
570   * \param leftLabel - label to the left of slider
571   * \param rightLabel - label to the right of slider
572   * \param initValue - initial slider value
573   * \param bottom - least slider value
574   * \param top - maximal slider value
575   * \param precision - slider value precision
576  */
577 //================================================================================
578
579 StdMeshersGUI_doubleSliderParameter::
580 StdMeshersGUI_doubleSliderParameter (const QString& label,
581                                      const QString& leftLabel,
582                                      const QString& rightLabel,
583                                      const double   initValue,
584                                      const double   bottom,
585                                      const double   top   ,
586                                      const double   precision)
587   :SMESHGUI_doubleParameter(initValue,label,bottom,top,precision),
588    _leftLabel(leftLabel), _rightLabel(rightLabel)
589 {
590 }
591
592 QWidget* StdMeshersGUI_doubleSliderParameter::CreateWidget( QWidget* parent ) const
593 {
594   return new StdMeshersGUI_SliderWith2Lables( _leftLabel, _rightLabel, parent );
595 }
596
597 void StdMeshersGUI_doubleSliderParameter::InitializeWidget( QWidget* aWidget) const
598 {
599   StdMeshersGUI_SliderWith2Lables * paramWidget =
600     dynamic_cast<StdMeshersGUI_SliderWith2Lables*> (aWidget);
601   if ( paramWidget && paramWidget->getSlider() )
602   {
603     QSlider * slider = paramWidget->getSlider();
604     slider->setRange( 0, toInt( _top ));
605     slider->setValue( toInt( _initValue ));
606   }
607 }
608
609 void StdMeshersGUI_doubleSliderParameter::TakeValue( QWidget* aWidget)
610 {
611   StdMeshersGUI_SliderWith2Lables * paramWidget =
612     dynamic_cast<StdMeshersGUI_SliderWith2Lables*> (aWidget);
613   if ( paramWidget && paramWidget->getSlider() )
614   {
615     int val = paramWidget->getSlider()->value();
616     _newValue = Bottom() + val * Step();
617   }
618 }
619 int StdMeshersGUI_doubleSliderParameter::toInt( double val ) const
620 {
621   return (int) ceil(( val - _bottom ) / _step );
622 }