mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Logarithmic curve support and renaming (#8546)
* Add test for both positive and negative numbers * Remove redundant sample count from parameter list * Propagate useLogarithmicScale * Renaming
This commit is contained in:
@@ -239,8 +239,8 @@ void RiuFlowCharacteristicsPlot::addFlowCapStorageCapCurve( const QDateTime&
|
||||
|
||||
RiuQwtPlotCurve* plotCurve =
|
||||
createEmptyCurve( m_flowCapVsStorageCapPlot, dateTime.toString(), m_dateToColorMap[dateTime] );
|
||||
bool isLogCurve = false;
|
||||
plotCurve->setSamplesFromXValuesAndYValues( xVals, yVals, isLogCurve );
|
||||
bool useLogarithmicScale = false;
|
||||
plotCurve->setSamplesFromXValuesAndYValues( xVals, yVals, useLogarithmicScale );
|
||||
m_flowCapVsStorageCapPlot->replot();
|
||||
}
|
||||
|
||||
@@ -253,9 +253,9 @@ void RiuFlowCharacteristicsPlot::addSweepEfficiencyCurve( const QDateTime&
|
||||
{
|
||||
CVF_ASSERT( !m_dateToColorMap.empty() );
|
||||
|
||||
RiuQwtPlotCurve* plotCurve = createEmptyCurve( m_sweepEffPlot, dateTime.toString(), m_dateToColorMap[dateTime] );
|
||||
bool isLogCurve = false;
|
||||
plotCurve->setSamplesFromXValuesAndYValues( xVals, yVals, isLogCurve );
|
||||
RiuQwtPlotCurve* plotCurve = createEmptyCurve( m_sweepEffPlot, dateTime.toString(), m_dateToColorMap[dateTime] );
|
||||
bool useLogarithmicScale = false;
|
||||
plotCurve->setSamplesFromXValuesAndYValues( xVals, yVals, useLogarithmicScale );
|
||||
|
||||
m_sweepEffPlot->replot();
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ RiuPlotCurve::~RiuPlotCurve()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuPlotCurve::setSamplesValues( const std::vector<double>& xValues, const std::vector<double>& yValues )
|
||||
{
|
||||
setSamplesInPlot( xValues, yValues, static_cast<int>( xValues.size() ) );
|
||||
setSamplesInPlot( xValues, yValues );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -57,9 +57,9 @@ void RiuPlotCurve::setSamplesValues( const std::vector<double>& xValues, const s
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuPlotCurve::setSamplesFromXValuesAndYValues( const std::vector<double>& xValues,
|
||||
const std::vector<double>& yValues,
|
||||
bool isLogCurve )
|
||||
bool useLogarithmicScale )
|
||||
{
|
||||
computeValidIntervalsAndSetCurveData( xValues, yValues, isLogCurve );
|
||||
computeValidIntervalsAndSetCurveData( xValues, yValues, useLogarithmicScale );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -67,11 +67,11 @@ void RiuPlotCurve::setSamplesFromXValuesAndYValues( const std::vector<double>& x
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuPlotCurve::setSamplesFromDatesAndYValues( const std::vector<QDateTime>& dateTimes,
|
||||
const std::vector<double>& yValues,
|
||||
bool isLogCurve )
|
||||
bool useLogarithmicScale )
|
||||
{
|
||||
auto xValues = RiuPlotCurve::fromQDateTime( dateTimes );
|
||||
|
||||
computeValidIntervalsAndSetCurveData( xValues, yValues, isLogCurve );
|
||||
computeValidIntervalsAndSetCurveData( xValues, yValues, useLogarithmicScale );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -79,11 +79,11 @@ void RiuPlotCurve::setSamplesFromDatesAndYValues( const std::vector<QDateTime>&
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuPlotCurve::setSamplesFromTimeTAndYValues( const std::vector<time_t>& dateTimes,
|
||||
const std::vector<double>& yValues,
|
||||
bool isLogCurve )
|
||||
bool useLogarithmicScale )
|
||||
{
|
||||
auto xValues = RiuPlotCurve::fromTime_t( dateTimes );
|
||||
|
||||
computeValidIntervalsAndSetCurveData( xValues, yValues, isLogCurve );
|
||||
computeValidIntervalsAndSetCurveData( xValues, yValues, useLogarithmicScale );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -123,9 +123,9 @@ void RiuPlotCurve::setBlackAndWhiteLegendIcon( bool blackAndWhite )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuPlotCurve::computeValidIntervalsAndSetCurveData( const std::vector<double>& xValues,
|
||||
const std::vector<double>& yValues,
|
||||
bool isLogCurve )
|
||||
bool useLogarithmicScale )
|
||||
{
|
||||
auto intervalsOfValidValues = RiaCurveDataTools::calculateIntervalsOfValidValues( yValues, isLogCurve );
|
||||
auto intervalsOfValidValues = RiaCurveDataTools::calculateIntervalsOfValidValues( yValues, useLogarithmicScale );
|
||||
|
||||
std::vector<double> validYValues;
|
||||
std::vector<double> validXValues;
|
||||
@@ -133,7 +133,7 @@ void RiuPlotCurve::computeValidIntervalsAndSetCurveData( const std::vector<doubl
|
||||
RiaCurveDataTools::getValuesByIntervals( yValues, intervalsOfValidValues, &validYValues );
|
||||
RiaCurveDataTools::getValuesByIntervals( xValues, intervalsOfValidValues, &validXValues );
|
||||
|
||||
setSamplesInPlot( validXValues, validYValues, static_cast<int>( validXValues.size() ) );
|
||||
setSamplesInPlot( validXValues, validYValues );
|
||||
|
||||
setLineSegmentStartStopIndices( RiaCurveDataTools::computePolyLineStartStopIndices( intervalsOfValidValues ) );
|
||||
}
|
||||
@@ -184,7 +184,7 @@ std::vector<double> RiuPlotCurve::fromTime_t( const std::vector<time_t>& timeSte
|
||||
void RiuPlotCurve::setSamplesFromXYErrorValues( const std::vector<double>& xValues,
|
||||
const std::vector<double>& yValues,
|
||||
const std::vector<double>& errorValues,
|
||||
bool isLogCurve,
|
||||
bool useLogarithmicScale,
|
||||
RiaCurveDataTools::ErrorAxis errorAxis )
|
||||
{
|
||||
}
|
||||
|
||||
@@ -65,21 +65,21 @@ public:
|
||||
|
||||
void setSamplesFromXValuesAndYValues( const std::vector<double>& xValues,
|
||||
const std::vector<double>& yValues,
|
||||
bool isLogCurve );
|
||||
bool useLogarithmicScale );
|
||||
|
||||
void setSamplesFromDatesAndYValues( const std::vector<QDateTime>& dateTimes,
|
||||
const std::vector<double>& yValues,
|
||||
bool isLogCurve );
|
||||
bool useLogarithmicScale );
|
||||
|
||||
void setSamplesFromTimeTAndYValues( const std::vector<time_t>& dateTimes,
|
||||
const std::vector<double>& yValues,
|
||||
bool isLogCurve );
|
||||
bool useLogarithmicScale );
|
||||
|
||||
virtual void setSamplesFromXYErrorValues(
|
||||
const std::vector<double>& xValues,
|
||||
const std::vector<double>& yValues,
|
||||
const std::vector<double>& errorValues,
|
||||
bool isLogCurve,
|
||||
bool useLogarithmicScale,
|
||||
RiaCurveDataTools::ErrorAxis errorAxis = RiaCurveDataTools::ErrorAxis::ERROR_ALONG_Y_AXIS );
|
||||
|
||||
void setLineSegmentStartStopIndices( const std::vector<std::pair<size_t, size_t>>& lineSegmentStartStopIndices );
|
||||
@@ -130,13 +130,12 @@ public:
|
||||
virtual RiuPlotCurveSymbol* createSymbol( RiuPlotCurveSymbol::PointSymbolEnum symbol ) const = 0;
|
||||
|
||||
protected:
|
||||
virtual void
|
||||
setSamplesInPlot( const std::vector<double>& xValues, const std::vector<double>& yValues, int numSamples ) = 0;
|
||||
virtual void setSamplesInPlot( const std::vector<double>& xValues, const std::vector<double>& yValues ) = 0;
|
||||
|
||||
private:
|
||||
void computeValidIntervalsAndSetCurveData( const std::vector<double>& xValues,
|
||||
const std::vector<double>& yValues,
|
||||
bool isLogCurve );
|
||||
bool useLogarithmicScale );
|
||||
|
||||
protected:
|
||||
float m_symbolSkipPixelDistance;
|
||||
|
||||
@@ -179,22 +179,18 @@ void RiuQtChartsPlotCurve::showInPlot()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuQtChartsPlotCurve::setSamplesInPlot( const std::vector<double>& xValues,
|
||||
const std::vector<double>& yValues,
|
||||
int numValues )
|
||||
void RiuQtChartsPlotCurve::setSamplesInPlot( const std::vector<double>& xValues, const std::vector<double>& yValues )
|
||||
{
|
||||
if ( !isQtChartObjectsPresent() ) return;
|
||||
|
||||
CAF_ASSERT( xValues.size() == yValues.size() );
|
||||
CAF_ASSERT( numValues <= static_cast<int>( xValues.size() ) );
|
||||
CAF_ASSERT( numValues >= 0 );
|
||||
|
||||
QtCharts::QLineSeries* line = lineSeries();
|
||||
QtCharts::QScatterSeries* scatter = scatterSeries();
|
||||
|
||||
line->clear();
|
||||
scatter->clear();
|
||||
for ( int i = 0; i < numValues; i++ )
|
||||
for ( int i = 0; i < static_cast<int>( xValues.size() ); i++ )
|
||||
{
|
||||
line->append( xValues[i], yValues[i] );
|
||||
scatter->append( xValues[i], yValues[i] );
|
||||
|
||||
@@ -78,7 +78,7 @@ public:
|
||||
RiuPlotCurveSymbol* createSymbol( RiuPlotCurveSymbol::PointSymbolEnum symbol ) const override;
|
||||
|
||||
private:
|
||||
void setSamplesInPlot( const std::vector<double>&, const std::vector<double>&, int ) override;
|
||||
void setSamplesInPlot( const std::vector<double>&, const std::vector<double>& ) override;
|
||||
|
||||
bool isQtChartObjectsPresent() const;
|
||||
QtCharts::QLineSeries* lineSeries() const;
|
||||
|
||||
@@ -337,9 +337,11 @@ void RiuQwtPlotCurve::showInPlot()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuQwtPlotCurve::setSamplesInPlot( const std::vector<double>& xValues, const std::vector<double>& yValues, int numValues )
|
||||
void RiuQwtPlotCurve::setSamplesInPlot( const std::vector<double>& xValues, const std::vector<double>& yValues )
|
||||
{
|
||||
setSamples( xValues.data(), yValues.data(), numValues );
|
||||
CAF_ASSERT( xValues.size() == yValues.size() );
|
||||
|
||||
setSamples( xValues.data(), yValues.data(), static_cast<int>( xValues.size() ) );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -415,13 +417,13 @@ std::pair<double, double> RiuQwtPlotCurve::yDataRange() const
|
||||
void RiuQwtPlotCurve::setSamplesFromXYErrorValues( const std::vector<double>& xValues,
|
||||
const std::vector<double>& yValues,
|
||||
const std::vector<double>& errorValues,
|
||||
bool isLogCurve,
|
||||
bool useLogarithmicScale,
|
||||
RiaCurveDataTools::ErrorAxis errorAxis )
|
||||
{
|
||||
CVF_ASSERT( xValues.size() == yValues.size() );
|
||||
CVF_ASSERT( xValues.size() == errorValues.size() );
|
||||
|
||||
auto intervalsOfValidValues = RiaCurveDataTools::calculateIntervalsOfValidValues( yValues, isLogCurve );
|
||||
auto intervalsOfValidValues = RiaCurveDataTools::calculateIntervalsOfValidValues( yValues, useLogarithmicScale );
|
||||
std::vector<double> filteredYValues;
|
||||
std::vector<double> filteredXValues;
|
||||
|
||||
@@ -454,7 +456,7 @@ void RiuQwtPlotCurve::setSamplesFromXYErrorValues( const std::vector<double>&
|
||||
}
|
||||
}
|
||||
|
||||
setSamplesInPlot( filteredXValues, filteredYValues, static_cast<int>( filteredXValues.size() ) );
|
||||
setSamplesInPlot( filteredXValues, filteredYValues );
|
||||
|
||||
setLineSegmentStartStopIndices( intervalsOfValidValues );
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ public:
|
||||
const std::vector<double>& xValues,
|
||||
const std::vector<double>& yValues,
|
||||
const std::vector<double>& errorValues,
|
||||
bool isLogCurve,
|
||||
bool useLogarithmicScale,
|
||||
RiaCurveDataTools::ErrorAxis errorAxis = RiaCurveDataTools::ErrorAxis::ERROR_ALONG_Y_AXIS ) override;
|
||||
|
||||
void setXAxis( RiuPlotAxis axis ) override;
|
||||
@@ -97,7 +97,7 @@ protected:
|
||||
int from,
|
||||
int to ) const override;
|
||||
|
||||
void setSamplesInPlot( const std::vector<double>&, const std::vector<double>&, int ) override;
|
||||
void setSamplesInPlot( const std::vector<double>&, const std::vector<double>& ) override;
|
||||
|
||||
QwtPlotIntervalCurve* m_qwtCurveErrorBars;
|
||||
bool m_showErrorBars;
|
||||
|
||||
Reference in New Issue
Block a user