+
+//================================================================================
+/*!
+ * \brief Widget: slider with left and right labels
+ */
+//================================================================================
+
+class StdMeshersGUI_SliderWith2Lables: public QHBox
+{
+public:
+ StdMeshersGUI_SliderWith2Lables( const QString& leftLabel,
+ const QString& rightLabel,
+ QWidget * parent =0,
+ const char * name=0 );
+ QSlider * getSlider() const { return _slider; }
+private:
+ QSlider * _slider;
+};
+
+StdMeshersGUI_SliderWith2Lables::StdMeshersGUI_SliderWith2Lables( const QString& leftLabel,
+ const QString& rightLabel,
+ QWidget * parent,
+ const char * name )
+ :QHBox(parent,name)
+{
+ if ( !leftLabel.isEmpty() )
+ (new QLabel( this ))->setText( leftLabel );
+
+ _slider = new QSlider( Horizontal, this );
+
+ if ( !rightLabel.isEmpty() )
+ (new QLabel( this ))->setText( rightLabel );
+}
+
+//================================================================================
+/*!
+ * \brief Constructor
+ * \param label - main label
+ * \param leftLabel - label to the left of slider
+ * \param rightLabel - label to the right of slider
+ * \param initValue - initial slider value
+ * \param bottom - least slider value
+ * \param top - maximal slider value
+ * \param precision - slider value precision
+ */
+//================================================================================
+
+StdMeshersGUI_doubleSliderParameter::
+StdMeshersGUI_doubleSliderParameter (const QString& label,
+ const QString& leftLabel,
+ const QString& rightLabel,
+ const double initValue,
+ const double bottom,
+ const double top ,
+ const double precision)
+ :SMESHGUI_doubleParameter(initValue,label,bottom,top,precision),
+ _leftLabel(leftLabel), _rightLabel(rightLabel)
+{
+}
+
+QWidget* StdMeshersGUI_doubleSliderParameter::CreateWidget( QWidget* parent ) const
+{
+ return new StdMeshersGUI_SliderWith2Lables( _leftLabel, _rightLabel, parent );
+}
+
+void StdMeshersGUI_doubleSliderParameter::InitializeWidget( QWidget* aWidget) const
+{
+ StdMeshersGUI_SliderWith2Lables * paramWidget =
+ dynamic_cast<StdMeshersGUI_SliderWith2Lables*> (aWidget);
+ if ( paramWidget && paramWidget->getSlider() )
+ {
+ QSlider * slider = paramWidget->getSlider();
+ slider->setRange( 0, toInt( _top ));
+ slider->setValue( toInt( _initValue ));
+ }
+}
+
+void StdMeshersGUI_doubleSliderParameter::TakeValue( QWidget* aWidget)
+{
+ StdMeshersGUI_SliderWith2Lables * paramWidget =
+ dynamic_cast<StdMeshersGUI_SliderWith2Lables*> (aWidget);
+ if ( paramWidget && paramWidget->getSlider() )
+ {
+ int val = paramWidget->getSlider()->value();
+ _newValue = Bottom() + val * Step();
+ }
+}
+int StdMeshersGUI_doubleSliderParameter::toInt( double val ) const
+{
+ return (int) ceil(( val - _bottom ) / _step );
+}