mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#896 Made the resolution of the slider better
This commit is contained in:
parent
585eeef726
commit
8f6744adcb
@ -116,6 +116,8 @@ void PdmUiDoubleSliderEditor::configureAndUpdateUi(const QString& uiConfigName)
|
|||||||
uiObject->editorAttribute(field()->fieldHandle(), uiConfigName, &m_attributes);
|
uiObject->editorAttribute(field()->fieldHandle(), uiConfigName, &m_attributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_slider->setMaximum(m_attributes.m_sliderResolution);
|
||||||
|
|
||||||
PdmDoubleValidator* pdmValidator = new PdmDoubleValidator(m_attributes.m_minimum, m_attributes.m_maximum, m_attributes.m_decimals, this);
|
PdmDoubleValidator* pdmValidator = new PdmDoubleValidator(m_attributes.m_minimum, m_attributes.m_maximum, m_attributes.m_decimals, this);
|
||||||
m_lineEdit->setValidator(pdmValidator);
|
m_lineEdit->setValidator(pdmValidator);
|
||||||
|
|
||||||
@ -142,6 +144,8 @@ QWidget* PdmUiDoubleSliderEditor::createEditorWidget(QWidget * parent)
|
|||||||
connect(m_lineEdit, SIGNAL(editingFinished()), this, SLOT(slotEditingFinished()));
|
connect(m_lineEdit, SIGNAL(editingFinished()), this, SLOT(slotEditingFinished()));
|
||||||
|
|
||||||
m_slider = new QSlider(Qt::Horizontal, containerWidget);
|
m_slider = new QSlider(Qt::Horizontal, containerWidget);
|
||||||
|
|
||||||
|
|
||||||
layout->addWidget(m_lineEdit);
|
layout->addWidget(m_lineEdit);
|
||||||
layout->addWidget(m_slider);
|
layout->addWidget(m_slider);
|
||||||
|
|
||||||
@ -218,7 +222,7 @@ int PdmUiDoubleSliderEditor::convertToSliderValue(double value)
|
|||||||
{
|
{
|
||||||
double exactSliderValue = m_slider->maximum() * (value - m_attributes.m_minimum) / (m_attributes.m_maximum - m_attributes.m_minimum);
|
double exactSliderValue = m_slider->maximum() * (value - m_attributes.m_minimum) / (m_attributes.m_maximum - m_attributes.m_minimum);
|
||||||
|
|
||||||
int sliderValue = static_cast<int>(exactSliderValue);
|
int sliderValue = static_cast<int>(nearbyint( exactSliderValue));
|
||||||
sliderValue = qBound(m_slider->minimum(), sliderValue, m_slider->maximum());
|
sliderValue = qBound(m_slider->minimum(), sliderValue, m_slider->maximum());
|
||||||
|
|
||||||
return sliderValue;
|
return sliderValue;
|
||||||
|
@ -62,12 +62,14 @@ public:
|
|||||||
m_minimum = 0;
|
m_minimum = 0;
|
||||||
m_maximum = 10;
|
m_maximum = 10;
|
||||||
m_decimals = 6;
|
m_decimals = 6;
|
||||||
|
m_sliderResolution = 2000;
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
double m_minimum;
|
double m_minimum;
|
||||||
double m_maximum;
|
double m_maximum;
|
||||||
int m_decimals;
|
int m_decimals;
|
||||||
|
int m_sliderResolution;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user