Add legend levels field to Contor Map projection and make sliders delay update until release

This commit is contained in:
Gaute Lindkvist
2019-01-22 15:48:21 +01:00
parent 19bf92c336
commit d9f7e68739
5 changed files with 36 additions and 6 deletions

View File

@@ -84,7 +84,7 @@ RimContourMapProjection::RimContourMapProjection()
{
CAF_PDM_InitObject("RimContourMapProjection", ":/2DMapProjection16x16.png", "", "");
CAF_PDM_InitField(&m_relativeSampleSpacing, "SampleSpacing", 0.75, "Sample Spacing Factor", "", "", "");
CAF_PDM_InitField(&m_relativeSampleSpacing, "SampleSpacing", 0.8, "Sample Spacing Factor", "", "", "");
m_relativeSampleSpacing.uiCapability()->setUiEditorTypeName(caf::PdmUiDoubleSliderEditor::uiEditorTypeName());
CAF_PDM_InitFieldNoDefault(&m_resultAggregation, "ResultAggregation", "Result Aggregation", "", "", "");
@@ -1691,6 +1691,8 @@ void RimContourMapProjection::defineEditorAttribute(const caf::PdmFieldHandle* f
{
myAttr->m_minimum = 0.2;
myAttr->m_maximum = 2.0;
myAttr->m_sliderTickCount = 9;
myAttr->m_delaySliderUpdateUntilRelease = true;
}
}
}
@@ -1701,14 +1703,14 @@ void RimContourMapProjection::defineEditorAttribute(const caf::PdmFieldHandle* f
void RimContourMapProjection::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering)
{
caf::PdmUiGroup* mainGroup = uiOrdering.addNewGroup("Projection Settings");
mainGroup->add(&m_resultAggregation);
legendConfig()->uiOrdering("NumLevelsOnly", *mainGroup);
mainGroup->add(&m_relativeSampleSpacing);
mainGroup->add(&m_showContourLines);
mainGroup->add(&m_showContourLabels);
m_showContourLabels.uiCapability()->setUiReadOnly(!m_showContourLines());
mainGroup->add(&m_smoothContourLines);
m_smoothContourLines.uiCapability()->setUiReadOnly(!m_showContourLines());
mainGroup->add(&m_resultAggregation);
uiOrdering.skipRemainingFields(true);
}

View File

@@ -564,6 +564,7 @@ void RimGeoMechContourMapProjection::defineEditorAttribute(const caf::PdmFieldHa
myAttr->m_minimum = 0.0;
myAttr->m_maximum = 1.0;
myAttr->m_sliderTickCount = 4;
myAttr->m_delaySliderUpdateUntilRelease = true;
}
}
}

View File

@@ -823,6 +823,12 @@ cvf::Color3ubArray RimRegularLegendConfig::colorArrayFromColorType(ColorRangesTy
//--------------------------------------------------------------------------------------------------
void RimRegularLegendConfig::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering)
{
if (uiConfigName == "NumLevelsOnly")
{
uiOrdering.add(&m_numLevels);
uiOrdering.skipRemainingFields(true);
}
else
{
caf::PdmUiOrdering * formatGr = uiOrdering.addNewGroup("Format");
formatGr->add(&m_numLevels);
@@ -836,7 +842,6 @@ void RimRegularLegendConfig::defineUiOrdering(QString uiConfigName, caf::PdmUiOr
mappingGr->add(&m_userDefinedMaxValue);
mappingGr->add(&m_userDefinedMinValue);
}
updateFieldVisibility();
}

View File

@@ -112,6 +112,7 @@ void PdmUiDoubleSliderEditor::configureAndUpdateUi(const QString& uiConfigName)
m_lineEdit->setValidator(pdmValidator);
m_lineEdit->setText(textValue);
m_sliderValue = doubleValue;
updateSliderPosition(doubleValue);
}
@@ -136,7 +137,7 @@ QWidget* PdmUiDoubleSliderEditor::createEditorWidget(QWidget * parent)
layout->addWidget(m_slider);
connect(m_slider, SIGNAL(valueChanged(int)), this, SLOT(slotSliderValueChanged(int)));
connect(m_slider, SIGNAL(sliderReleased()), this, SLOT(slotSliderReleased()));
return containerWidget;
}
@@ -159,6 +160,7 @@ void PdmUiDoubleSliderEditor::slotEditingFinished()
double doubleVal = textValue.toDouble();
doubleVal = qBound(m_attributes.m_minimum, doubleVal, m_attributes.m_maximum);
m_sliderValue = doubleVal;
writeValueToField(doubleVal);
}
@@ -169,8 +171,24 @@ void PdmUiDoubleSliderEditor::slotEditingFinished()
void PdmUiDoubleSliderEditor::slotSliderValueChanged(int value)
{
double newDoubleValue = convertFromSliderValue(value);
m_sliderValue = newDoubleValue;
writeValueToField(newDoubleValue);
if (m_attributes.m_delaySliderUpdateUntilRelease)
{
m_lineEdit->setText(QString("%1").arg(m_sliderValue));
}
else
{
writeValueToField(m_sliderValue);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void PdmUiDoubleSliderEditor::slotSliderReleased()
{
writeValueToField(m_sliderValue);
}
//--------------------------------------------------------------------------------------------------

View File

@@ -61,6 +61,7 @@ public:
m_maximum = 10;
m_decimals = 6;
m_sliderTickCount = 2000;
m_delaySliderUpdateUntilRelease = false;
}
public:
@@ -68,6 +69,7 @@ public:
double m_maximum;
int m_decimals;
int m_sliderTickCount;
bool m_delaySliderUpdateUntilRelease;
};
@@ -91,6 +93,7 @@ protected:
protected slots:
void slotEditingFinished();
void slotSliderValueChanged(int value);
void slotSliderReleased();
private:
void updateSliderPosition(double value);
@@ -103,6 +106,7 @@ private:
QPointer<QLineEdit> m_lineEdit;
QPointer<QSlider> m_slider;
QPointer<QLabel> m_label;
double m_sliderValue;
PdmUiDoubleSliderEditorAttribute m_attributes;
};