mirror of
https://github.com/OPM/ResInsight.git
synced 2025-01-24 07:16:53 -06:00
(#460) Added logarithmic x-axis for tracks
This commit is contained in:
parent
2a53054f2d
commit
8e0e16447e
@ -27,7 +27,11 @@
|
||||
#include "RiuMainWindow.h"
|
||||
|
||||
#include "cafPdmUiTreeView.h"
|
||||
|
||||
#include "cvfAssert.h"
|
||||
#include "cvfMath.h"
|
||||
|
||||
#include "qwt_scale_engine.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
@ -56,7 +60,9 @@ RimWellLogTrack::RimWellLogTrack()
|
||||
CAF_PDM_InitField(&m_visibleXRangeMin, "VisibleXRangeMin", RI_LOGPLOTTRACK_MINX_DEFAULT, "Min", "", "", "");
|
||||
CAF_PDM_InitField(&m_visibleXRangeMax, "VisibleXRangeMax", RI_LOGPLOTTRACK_MAXX_DEFAULT, "Max", "", "", "");
|
||||
|
||||
CAF_PDM_InitField(&m_isAutoScaleXEnabled, "AutoScaleX", true, "Auto Scale", "", "", "");
|
||||
CAF_PDM_InitField(&m_isAutoScaleXEnabled, "AutoScaleX", true, "Auto Scale", "", "", "");
|
||||
|
||||
CAF_PDM_InitField(&m_isLogarithmicScaleEnabled, "LogarithmicScaleX", false, "Logarithmic Scale", "", "", "");
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -98,18 +104,33 @@ void RimWellLogTrack::fieldChangedByUi(const caf::PdmFieldHandle* changedField,
|
||||
}
|
||||
else if (changedField == &m_visibleXRangeMin || changedField == &m_visibleXRangeMax)
|
||||
{
|
||||
clampMinimumXRangeForLogarithmicScale();
|
||||
|
||||
m_wellLogTrackPlotWidget->setXRange(m_visibleXRangeMin, m_visibleXRangeMax);
|
||||
m_wellLogTrackPlotWidget->replot();
|
||||
m_isAutoScaleXEnabled = false;
|
||||
}
|
||||
else if (changedField == &m_isAutoScaleXEnabled )
|
||||
else if (changedField == &m_isAutoScaleXEnabled)
|
||||
{
|
||||
if (m_isAutoScaleXEnabled())
|
||||
{
|
||||
this->zoomAllXAxisIfAutoScale();
|
||||
clampMinimumXRangeForLogarithmicScale();
|
||||
|
||||
if (m_wellLogTrackPlotWidget) m_wellLogTrackPlotWidget->replot();
|
||||
}
|
||||
}
|
||||
else if (changedField == &m_isLogarithmicScaleEnabled)
|
||||
{
|
||||
updateAxisScaleEngine();
|
||||
|
||||
this->zoomAllXAxisIfAutoScale();
|
||||
clampMinimumXRangeForLogarithmicScale();
|
||||
|
||||
m_wellLogTrackPlotWidget->setXRange(m_visibleXRangeMin, m_visibleXRangeMax);
|
||||
|
||||
m_wellLogTrackPlotWidget->replot();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -238,6 +259,7 @@ void RimWellLogTrack::recreateViewer()
|
||||
if (m_wellLogTrackPlotWidget == NULL)
|
||||
{
|
||||
m_wellLogTrackPlotWidget = new RiuWellLogTrack(this);
|
||||
updateAxisScaleEngine();
|
||||
|
||||
for (size_t cIdx = 0; cIdx < curves.size(); ++cIdx)
|
||||
{
|
||||
@ -315,6 +337,8 @@ void RimWellLogTrack::zoomAllXAxisIfAutoScale()
|
||||
m_visibleXRangeMin = minValue;
|
||||
m_visibleXRangeMax = maxValue;
|
||||
|
||||
clampMinimumXRangeForLogarithmicScale();
|
||||
|
||||
if (m_wellLogTrackPlotWidget) m_wellLogTrackPlotWidget->setXRange(m_visibleXRangeMin, m_visibleXRangeMax);
|
||||
|
||||
updateConnectedEditors();
|
||||
@ -347,7 +371,7 @@ void RimWellLogTrack::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering&
|
||||
gridGroup->add(&m_isAutoScaleXEnabled);
|
||||
gridGroup->add(&m_visibleXRangeMin);
|
||||
gridGroup->add(&m_visibleXRangeMax);
|
||||
|
||||
gridGroup->add(&m_isLogarithmicScaleEnabled);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -365,3 +389,33 @@ bool RimWellLogTrack::isVisible()
|
||||
{
|
||||
return m_show;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellLogTrack::updateAxisScaleEngine()
|
||||
{
|
||||
if (m_isLogarithmicScaleEnabled)
|
||||
{
|
||||
m_wellLogTrackPlotWidget->setAxisScaleEngine(QwtPlot::xTop, new QwtLogScaleEngine);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_wellLogTrackPlotWidget->setAxisScaleEngine(QwtPlot::xTop, new QwtLinearScaleEngine);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellLogTrack::clampMinimumXRangeForLogarithmicScale()
|
||||
{
|
||||
if (m_isLogarithmicScaleEnabled)
|
||||
{
|
||||
double minValue = m_visibleXRangeMin;
|
||||
|
||||
minValue = cvf::Math::clamp(minValue, 0.01, m_visibleXRangeMax());
|
||||
|
||||
m_visibleXRangeMin = minValue;
|
||||
}
|
||||
}
|
||||
|
@ -65,14 +65,18 @@ public:
|
||||
RimWellLogCurve* curveDefinitionFromCurve(const QwtPlotCurve* curve) const;
|
||||
|
||||
protected:
|
||||
|
||||
// Overridden PDM methods
|
||||
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue);
|
||||
|
||||
void clampMinimumXRangeForLogarithmicScale();
|
||||
|
||||
virtual caf::PdmFieldHandle* objectToggleField();
|
||||
virtual caf::PdmFieldHandle* userDescriptionField();
|
||||
virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering);
|
||||
|
||||
private:
|
||||
void updateAxisScaleEngine();
|
||||
|
||||
private:
|
||||
caf::PdmField<bool> m_show;
|
||||
caf::PdmField<QString> m_userName;
|
||||
@ -80,6 +84,7 @@ private:
|
||||
caf::PdmField<double> m_visibleXRangeMin;
|
||||
caf::PdmField<double> m_visibleXRangeMax;
|
||||
caf::PdmField<bool> m_isAutoScaleXEnabled;
|
||||
caf::PdmField<bool> m_isLogarithmicScaleEnabled;
|
||||
|
||||
QPointer<RiuWellLogTrack> m_wellLogTrackPlotWidget;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user