mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
(#504) Do not use autoscale for x-axis - simplified track/plot update code
This commit is contained in:
@@ -62,7 +62,7 @@ RimWellLogPlotTrack::RimWellLogPlotTrack()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimWellLogPlotTrack::~RimWellLogPlotTrack()
|
||||
{
|
||||
delete m_viewer;
|
||||
delete m_wellLogTrackPlotWidget;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -80,12 +80,12 @@ void RimWellLogPlotTrack::fieldChangedByUi(const caf::PdmFieldHandle* changedFie
|
||||
{
|
||||
if (changedField == &m_show)
|
||||
{
|
||||
if (m_viewer) m_viewer->setVisible(m_show());
|
||||
if (m_wellLogTrackPlotWidget) m_wellLogTrackPlotWidget->setVisible(m_show());
|
||||
}
|
||||
else if (changedField == &m_visibleXRangeMin || changedField == &m_visibleXRangeMax)
|
||||
{
|
||||
m_viewer->setAxisScale(QwtPlot::xTop, m_visibleXRangeMin, m_visibleXRangeMax);
|
||||
m_viewer->replot();
|
||||
m_wellLogTrackPlotWidget->setXRange(m_visibleXRangeMin, m_visibleXRangeMax);
|
||||
m_wellLogTrackPlotWidget->replot();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,9 +112,9 @@ void RimWellLogPlotTrack::addCurve(RimWellLogPlotCurve* curve)
|
||||
{
|
||||
curves.push_back(curve);
|
||||
|
||||
if (m_viewer)
|
||||
if (m_wellLogTrackPlotWidget)
|
||||
{
|
||||
curve->setPlot(m_viewer);
|
||||
curve->setPlot(m_wellLogTrackPlotWidget);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ void RimWellLogPlotTrack::addCurve(RimWellLogPlotCurve* curve)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiuWellLogTrackPlot* RimWellLogPlotTrack::viewer()
|
||||
{
|
||||
return m_viewer;
|
||||
return m_wellLogTrackPlotWidget;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -178,21 +178,19 @@ bool RimWellLogPlotTrack::availableDepthRange(double* minimumDepth, double* maxi
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellLogPlotTrack::loadDataAndUpdate()
|
||||
{
|
||||
CVF_ASSERT(m_viewer);
|
||||
CVF_ASSERT(m_wellLogTrackPlotWidget);
|
||||
|
||||
RimWellLogPlot* wellLogPlot;
|
||||
firstAnchestorOrThisOfType(wellLogPlot);
|
||||
if (wellLogPlot)
|
||||
{
|
||||
m_viewer->setDepthTitle(wellLogPlot->depthPlotTitle());
|
||||
m_wellLogTrackPlotWidget->setDepthTitle(wellLogPlot->depthPlotTitle());
|
||||
}
|
||||
|
||||
for (size_t cIdx = 0; cIdx < curves.size(); ++cIdx)
|
||||
{
|
||||
curves[cIdx]->updatePlotData();
|
||||
}
|
||||
|
||||
updateXAxisRangeFromCurves();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -200,12 +198,12 @@ void RimWellLogPlotTrack::loadDataAndUpdate()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellLogPlotTrack::recreateViewer()
|
||||
{
|
||||
CVF_ASSERT(m_viewer == NULL);
|
||||
CVF_ASSERT(m_wellLogTrackPlotWidget == NULL);
|
||||
|
||||
m_viewer = new RiuWellLogTrackPlot(this);
|
||||
m_wellLogTrackPlotWidget = new RiuWellLogTrackPlot(this);
|
||||
for (size_t cIdx = 0; cIdx < curves.size(); ++cIdx)
|
||||
{
|
||||
curves[cIdx]->setPlot(this->m_viewer);
|
||||
curves[cIdx]->setPlot(this->m_wellLogTrackPlotWidget);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -225,9 +223,7 @@ void RimWellLogPlotTrack::detachAllCurves()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellLogPlotTrack::updateAxisRangesAndReplot()
|
||||
{
|
||||
bool rangesChanged = false;
|
||||
|
||||
if (m_viewer)
|
||||
if (m_wellLogTrackPlotWidget)
|
||||
{
|
||||
RimWellLogPlot* wellLogPlot;
|
||||
firstAnchestorOrThisOfType(wellLogPlot);
|
||||
@@ -236,21 +232,13 @@ void RimWellLogPlotTrack::updateAxisRangesAndReplot()
|
||||
double minimumDepth, maximumDepth;
|
||||
wellLogPlot->visibleDepthRange(&minimumDepth, &maximumDepth);
|
||||
|
||||
m_viewer->setDepthRange(minimumDepth, maximumDepth);
|
||||
rangesChanged = true;
|
||||
m_wellLogTrackPlotWidget->setDepthRange(minimumDepth, maximumDepth);
|
||||
}
|
||||
|
||||
// Assume auto-scaling on X-axis as long as curves exist, reset to default if not
|
||||
if (curves.size() < 1)
|
||||
{
|
||||
m_viewer->setAxisScale(QwtPlot::xTop, RI_LOGPLOTTRACK_MINX_DEFAULT, RI_LOGPLOTTRACK_MAXX_DEFAULT);
|
||||
rangesChanged = true;
|
||||
}
|
||||
updateXAxisRangeFromCurves();
|
||||
m_wellLogTrackPlotWidget->setXRange(m_visibleXRangeMin, m_visibleXRangeMax);
|
||||
|
||||
if (rangesChanged)
|
||||
{
|
||||
m_viewer->replot();
|
||||
}
|
||||
m_wellLogTrackPlotWidget->replot();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -262,12 +250,7 @@ void RimWellLogPlotTrack::updateXAxisRangeFromCurves()
|
||||
double minValue = HUGE_VAL;
|
||||
double maxValue = -HUGE_VAL;
|
||||
|
||||
size_t curveCount = curves.size();
|
||||
if (curveCount < 1) return;
|
||||
|
||||
bool rangeUpdated = false;
|
||||
|
||||
for (size_t cIdx = 0; cIdx < curveCount; cIdx++)
|
||||
for (size_t cIdx = 0; cIdx < curves.size(); cIdx++)
|
||||
{
|
||||
double minCurveValue = HUGE_VAL;
|
||||
double maxCurveValue = -HUGE_VAL;
|
||||
@@ -277,24 +260,25 @@ void RimWellLogPlotTrack::updateXAxisRangeFromCurves()
|
||||
if (minCurveValue < minValue)
|
||||
{
|
||||
minValue = minCurveValue;
|
||||
rangeUpdated = true;
|
||||
}
|
||||
|
||||
if (maxCurveValue > maxValue)
|
||||
{
|
||||
maxValue = maxCurveValue;
|
||||
rangeUpdated = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (rangeUpdated)
|
||||
if (minValue == HUGE_VAL)
|
||||
{
|
||||
m_visibleXRangeMin = minValue;
|
||||
m_visibleXRangeMax = maxValue;
|
||||
|
||||
updateConnectedEditors();
|
||||
minValue = RI_LOGPLOTTRACK_MINX_DEFAULT;
|
||||
maxValue = RI_LOGPLOTTRACK_MAXX_DEFAULT;
|
||||
}
|
||||
|
||||
m_visibleXRangeMin = minValue;
|
||||
m_visibleXRangeMax = maxValue;
|
||||
|
||||
updateConnectedEditors();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user