mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Swap axis settings when swapping Grid Cross Plot axes + fix inverted axes for summary plot
This commit is contained in:
@@ -18,8 +18,6 @@
|
||||
|
||||
#include "RimSummaryCurvesCalculator.h"
|
||||
|
||||
#include "RigStatisticsCalculator.h"
|
||||
|
||||
#include "RiaDefines.h"
|
||||
#include "RimSummaryCurve.h"
|
||||
#include "RimPlotAxisProperties.h"
|
||||
@@ -319,86 +317,3 @@ std::string RimSummaryPlotYAxisFormatter::shortCalculationName(const std::string
|
||||
return calculationShortName.toStdString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimSummaryPlotYAxisRangeCalculator::RimSummaryPlotYAxisRangeCalculator(
|
||||
const std::vector<QwtPlotCurve*>& qwtCurves,
|
||||
const std::vector<double>& yValuesForAllCurves)
|
||||
:
|
||||
m_singleCurves(qwtCurves),
|
||||
m_yValuesForAllCurves(yValuesForAllCurves)
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryPlotYAxisRangeCalculator::computeYRange(double* min, double* max) const
|
||||
{
|
||||
double minValue = HUGE_VAL;
|
||||
double maxValue = -HUGE_VAL;
|
||||
|
||||
for (QwtPlotCurve* curve : m_singleCurves)
|
||||
{
|
||||
double minCurveValue = HUGE_VAL;
|
||||
double maxCurveValue = -HUGE_VAL;
|
||||
|
||||
if (curveValueRangeY(curve, &minCurveValue, &maxCurveValue))
|
||||
{
|
||||
if (minCurveValue < minValue)
|
||||
{
|
||||
minValue = minCurveValue;
|
||||
}
|
||||
|
||||
if (maxCurveValue > maxValue)
|
||||
{
|
||||
maxValue = maxCurveValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (minValue == HUGE_VAL)
|
||||
{
|
||||
minValue = RiaDefines::minimumDefaultValuePlot();
|
||||
maxValue = RiaDefines::maximumDefaultValuePlot();
|
||||
}
|
||||
|
||||
// For logarithmic auto scaling, compute positive curve value closest to zero and use
|
||||
// this value as the plot visible minimum
|
||||
|
||||
double pos = HUGE_VAL;
|
||||
double neg = -HUGE_VAL;
|
||||
|
||||
RigStatisticsCalculator::posNegClosestToZero(m_yValuesForAllCurves, pos, neg);
|
||||
|
||||
if (pos != HUGE_VAL)
|
||||
{
|
||||
minValue = pos;
|
||||
}
|
||||
|
||||
*min = minValue;
|
||||
*max = maxValue;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimSummaryPlotYAxisRangeCalculator::curveValueRangeY(const QwtPlotCurve* qwtCurve, double* min, double* max) const
|
||||
{
|
||||
if (!qwtCurve) return false;
|
||||
|
||||
if (qwtCurve->data()->size() < 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
*min = qwtCurve->minYValue();
|
||||
*max = qwtCurve->maxYValue();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
#include <vector>
|
||||
#include <set>
|
||||
|
||||
#include <qwt_plot.h>
|
||||
|
||||
class RimAsciiDataCurve;
|
||||
class RimSummaryCurve;
|
||||
class RimPlotAxisProperties;
|
||||
@@ -46,26 +48,9 @@ private:
|
||||
static std::string shortCalculationName(const std::string& calculationName);
|
||||
|
||||
private:
|
||||
RimPlotAxisProperties* m_axisProperties;
|
||||
RimPlotAxisProperties* m_axisProperties;
|
||||
const std::vector<RimSummaryCurve*> m_summaryCurves;
|
||||
const std::vector<RimAsciiDataCurve*> m_asciiDataCurves;
|
||||
const std::set<QString> m_timeHistoryCurveQuantities;
|
||||
};
|
||||
|
||||
|
||||
class RimSummaryPlotYAxisRangeCalculator
|
||||
{
|
||||
public:
|
||||
RimSummaryPlotYAxisRangeCalculator( const std::vector<QwtPlotCurve*>& qwtCurves,
|
||||
const std::vector<double>& yValuesForAllCurves);
|
||||
|
||||
void computeYRange(double* min, double* max) const;
|
||||
|
||||
private:
|
||||
bool curveValueRangeY(const QwtPlotCurve* qwtCurve, double* min, double* max) const;
|
||||
|
||||
private:
|
||||
const std::vector<QwtPlotCurve*> m_singleCurves;
|
||||
const std::vector<double> m_yValuesForAllCurves;
|
||||
};
|
||||
|
||||
|
||||
@@ -54,6 +54,7 @@
|
||||
#include "qwt_plot_curve.h"
|
||||
#include "qwt_plot_renderer.h"
|
||||
#include "qwt_plot_textlabel.h"
|
||||
#include "qwt_scale_engine.h"
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QString>
|
||||
@@ -659,8 +660,13 @@ void RimSummaryPlot::updateZoomForAxis(RiaDefines::PlotAxis plotAxis)
|
||||
}
|
||||
|
||||
double min, max;
|
||||
RimSummaryPlotYAxisRangeCalculator calc(plotCurves, yValues);
|
||||
calc.computeYRange(&min, &max);
|
||||
RimPlotAxisRangeCalculator calc(QwtPlot::yLeft, plotCurves, yValues);
|
||||
calc.computeAxisRange(&min, &max);
|
||||
|
||||
if (yAxisProps->isAxisInverted())
|
||||
{
|
||||
std::swap(min, max);
|
||||
}
|
||||
|
||||
m_qwtPlot->setAxisScale(yAxisProps->qwtPlotAxisType(), min, max);
|
||||
}
|
||||
@@ -673,6 +679,8 @@ void RimSummaryPlot::updateZoomForAxis(RiaDefines::PlotAxis plotAxis)
|
||||
{
|
||||
m_qwtPlot->setAxisScale(yAxisProps->qwtPlotAxisType(), yAxisProps->visibleRangeMin(), yAxisProps->visibleRangeMax());
|
||||
}
|
||||
|
||||
m_qwtPlot->axisScaleEngine(yAxisProps->qwtPlotAxisType())->setAttribute(QwtScaleEngine::Inverted, yAxisProps->isAxisInverted());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user