Add support for multiple curve sets in one VFP plot

- support selection of multiple values for multiple producer variables
- use one color for curves in a curve set representing a VFP curve collection
- use symbols to indicate individual family values for curves
- show all required values to identify curves as curve legend text and curve mouse hover text
- make sure all available settings of axis property object is applied to the plot axis
- support display of all curve data using "Show Plot Data"
This commit is contained in:
Magne Sjaastad
2024-06-12 07:52:37 +02:00
parent 13532b0fe4
commit fe63231db9
12 changed files with 725 additions and 264 deletions

View File

@@ -29,73 +29,16 @@
#include "RimSummaryCase.h"
#include "RimSummaryCaseCollection.h"
#include "RimSummaryCurve.h"
#include "Tools/RimPlotAxisTools.h"
#include "RiuQtChartsPlotWidget.h"
#include "RiuQwtPlotTools.h"
#include "RiuSummaryQuantityNameInfoProvider.h"
#include "RiuSummaryQwtPlot.h"
#include "qwt_date_scale_engine.h"
#include "qwt_plot.h"
#include "qwt_plot_curve.h"
#include "qwt_scale_draw.h"
#include "qwt_text.h"
#include <cmath>
#include <set>
#include <string>
//--------------------------------------------------------------------------------------------------
// e format as [-]9.9e[+|-]999
// E format as[-]9.9E[+| -]999
// f format as[-]9.9
// g use e or f format, whichever is the most concise
// G use E or f format, whichever is the most concise
//--------------------------------------------------------------------------------------------------
class SummaryScaleDraw : public QwtScaleDraw
{
public:
SummaryScaleDraw( double scaleFactor,
int numberOfDecimals,
RimPlotAxisProperties::NumberFormatType numberFormat = RimPlotAxisProperties::NUMBER_FORMAT_AUTO )
{
m_scaleFactor = scaleFactor;
m_numberOfDecimals = numberOfDecimals;
m_numberFormat = numberFormat;
}
QwtText label( double value ) const override
{
if ( qFuzzyCompare( scaledValue( value ) + 1.0, 1.0 ) ) value = 0.0;
return QString::number( scaledValue( value ), numberFormat(), m_numberOfDecimals );
}
private:
char numberFormat() const
{
switch ( m_numberFormat )
{
case RimPlotAxisProperties::NUMBER_FORMAT_AUTO:
return 'g';
case RimPlotAxisProperties::NUMBER_FORMAT_DECIMAL:
return 'f';
case RimPlotAxisProperties::NUMBER_FORMAT_SCIENTIFIC:
return 'e';
default:
return 'g';
}
}
double scaledValue( double value ) const { return value / m_scaleFactor; }
private:
double m_scaleFactor;
int m_numberOfDecimals;
RimPlotAxisProperties::NumberFormatType m_numberFormat;
};
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -139,24 +82,7 @@ void RimSummaryPlotAxisFormatter::applyAxisPropertiesToPlot( RiuPlotWidget* plot
plotWidget->setAxisTitleEnabled( axis, true );
}
auto qwtPlotWidget = dynamic_cast<RiuQwtPlotWidget*>( plotWidget );
if ( qwtPlotWidget )
{
auto qwtAxisId = qwtPlotWidget->toQwtPlotAxis( axis );
if ( m_axisProperties->numberFormat() == RimPlotAxisProperties::NUMBER_FORMAT_AUTO && m_axisProperties->scaleFactor() == 1.0 )
{
// Default to Qwt's own scale draw to avoid changing too much for default values
qwtPlotWidget->qwtPlot()->setAxisScaleDraw( qwtAxisId, new QwtScaleDraw );
}
else
{
qwtPlotWidget->qwtPlot()->setAxisScaleDraw( qwtAxisId,
new SummaryScaleDraw( m_axisProperties->scaleFactor(),
m_axisProperties->decimalCount(),
m_axisProperties->numberFormat() ) );
}
}
RimPlotAxisTools::applyAxisScaleDraw( plotWidget, axis, m_axisProperties );
#ifdef USE_QTCHARTS
auto qtChartsPlotWidget = dynamic_cast<RiuQtChartsPlotWidget*>( plotWidget );
@@ -307,13 +233,7 @@ QString RimSummaryPlotAxisFormatter::autoAxisTitle() const
}
QString assembledYAxisText;
QString scaleFactorText = "";
if ( m_axisProperties->scaleFactor() != 1.0 )
{
int exponent = std::log10( m_axisProperties->scaleFactor() );
scaleFactorText = QString( " x 10<sup>%1</sup> " ).arg( QString::number( exponent ) );
}
QString scaleFactorText = RimPlotAxisTools::scaleFactorText( m_axisProperties );
for ( const auto& unitIt : unitToQuantityNameMap )
{