mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Merge branch 'dev' into annotation-items
This commit is contained in:
@@ -20,14 +20,19 @@
|
||||
#include "RimPlotAxisProperties.h"
|
||||
|
||||
#include "RiaDefines.h"
|
||||
#include "RigStatisticsCalculator.h"
|
||||
|
||||
#include "RimRiuQwtPlotOwnerInterface.h"
|
||||
#include "RimPlotAxisAnnotation.h"
|
||||
|
||||
#include "cafPdmUiSliderEditor.h"
|
||||
|
||||
#include "cvfVector2.h"
|
||||
|
||||
#include <cmath>
|
||||
|
||||
#include <qwt_plot_curve.h>
|
||||
|
||||
// clang-format off
|
||||
namespace caf
|
||||
{
|
||||
@@ -229,6 +234,14 @@ QwtPlot::Axis RimPlotAxisProperties::qwtPlotAxisType() const
|
||||
return m_axis;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimPlotAxisProperties::name() const
|
||||
{
|
||||
return m_name;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -373,3 +386,92 @@ caf::PdmFieldHandle* RimPlotAxisProperties::objectToggleField()
|
||||
{
|
||||
return &m_isActive;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimPlotAxisLogRangeCalculator::RimPlotAxisLogRangeCalculator(QwtPlot::Axis axis,
|
||||
const std::vector<const QwtPlotCurve*>& qwtCurves)
|
||||
: m_axis(axis)
|
||||
, m_curves(qwtCurves)
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimPlotAxisLogRangeCalculator::computeAxisRange(double* minPositive, double* max) const
|
||||
{
|
||||
double minPosValue = HUGE_VAL;
|
||||
double maxValue = -HUGE_VAL;
|
||||
|
||||
for (const QwtPlotCurve* curve : m_curves)
|
||||
{
|
||||
double minPosCurveValue = HUGE_VAL;
|
||||
double maxCurveValue = -HUGE_VAL;
|
||||
|
||||
if (curveValueRange(curve, &minPosCurveValue, &maxCurveValue))
|
||||
{
|
||||
if (minPosCurveValue < minPosValue)
|
||||
{
|
||||
CVF_ASSERT(minPosCurveValue > 0.0);
|
||||
minPosValue = minPosCurveValue;
|
||||
}
|
||||
|
||||
if (maxCurveValue > maxValue)
|
||||
{
|
||||
maxValue = maxCurveValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (minPosValue == HUGE_VAL)
|
||||
{
|
||||
minPosValue = RiaDefines::minimumDefaultLogValuePlot();
|
||||
maxValue = RiaDefines::maximumDefaultValuePlot();
|
||||
}
|
||||
|
||||
*minPositive = minPosValue;
|
||||
*max = maxValue;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimPlotAxisLogRangeCalculator::curveValueRange(const QwtPlotCurve* qwtCurve, double* minPositive, double* max) const
|
||||
{
|
||||
if (!qwtCurve) return false;
|
||||
|
||||
if (qwtCurve->data()->size() < 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
float minPosF = std::numeric_limits<float>::infinity();
|
||||
float maxF = -std::numeric_limits<float>::infinity();
|
||||
|
||||
int axisValueIndex = 0;
|
||||
if (m_axis == QwtPlot::yLeft || m_axis == QwtPlot::yRight)
|
||||
{
|
||||
axisValueIndex = 1;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < qwtCurve->dataSize(); ++i)
|
||||
{
|
||||
QPointF sample = qwtCurve->sample((int) i);
|
||||
cvf::Vec2f vec(sample.x(), sample.y());
|
||||
float value = vec[axisValueIndex];
|
||||
if (value == HUGE_VALF) continue;
|
||||
|
||||
maxF = std::max(maxF, value);
|
||||
if (value > 0.0f && value < minPosF)
|
||||
{
|
||||
minPosF = value;
|
||||
}
|
||||
}
|
||||
|
||||
*minPositive = minPosF;
|
||||
*max = maxF;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user