Merge pull request #8387 from OPM/qtcharts-summary-plots

Closes #8228 

Major refactoring of summary plotting. Now possible to create plots both with Qwt and QtChart as plotting tool.
This commit is contained in:
Kristian Bendiksen
2022-01-17 13:14:21 +01:00
committed by GitHub
parent d9bb82de91
commit 258fbddc10
145 changed files with 7245 additions and 2932 deletions

View File

@@ -119,7 +119,7 @@ RiaDefines::PhaseType RimWellDistributionPlot::phase() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuQwtPlotWidget* RimWellDistributionPlot::viewer()
RiuPlotWidget* RimWellDistributionPlot::plotWidget()
{
return m_plotWidget;
}
@@ -170,28 +170,28 @@ void RimWellDistributionPlot::updateLegend()
if ( doShowLegend )
{
QwtLegend* legend = new QwtLegend( m_plotWidget );
m_plotWidget->insertLegend( legend, QwtPlot::BottomLegend );
m_plotWidget->qwtPlot()->insertLegend( legend, QwtPlot::BottomLegend );
}
else
{
m_plotWidget->insertLegend( nullptr );
m_plotWidget->qwtPlot()->insertLegend( nullptr );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellDistributionPlot::updateZoomInQwt()
void RimWellDistributionPlot::updateZoomInParentPlot()
{
// cvf::Trace::show("RimWellDistributionPlot::updateZoomInQwt()");
// cvf::Trace::show("RimWellDistributionPlot::updateZoomInParentPlot()");
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellDistributionPlot::updateZoomFromQwt()
void RimWellDistributionPlot::updateZoomFromParentPlot()
{
// cvf::Trace::show("RimWellDistributionPlot::updateZoomFromQwt()");
// cvf::Trace::show("RimWellDistributionPlot::updateZoomFromParentPlot()");
}
//--------------------------------------------------------------------------------------------------
@@ -222,7 +222,7 @@ void RimWellDistributionPlot::detachAllCurves()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::PdmObject* RimWellDistributionPlot::findPdmObjectFromQwtCurve( const QwtPlotCurve* /*curve*/ ) const
caf::PdmObject* RimWellDistributionPlot::findPdmObjectFromPlotCurve( const RiuPlotCurve* /*curve*/ ) const
{
// cvf::Trace::show("RimWellDistributionPlot::findPdmObjectFromQwtCurve()");
return nullptr;
@@ -282,7 +282,7 @@ void RimWellDistributionPlot::zoomAll()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuQwtPlotWidget* RimWellDistributionPlot::doCreatePlotViewWidget( QWidget* mainWindowParent )
RiuPlotWidget* RimWellDistributionPlot::doCreatePlotViewWidget( QWidget* mainWindowParent )
{
// cvf::Trace::show("RimWellDistributionPlot::createViewWidget()");
@@ -294,7 +294,7 @@ RiuQwtPlotWidget* RimWellDistributionPlot::doCreatePlotViewWidget( QWidget* main
m_plotWidget = new RiuQwtPlotWidget( this, mainWindowParent );
m_plotWidget->setAutoReplot( false );
m_plotWidget->qwtPlot()->setAutoReplot( false );
updateLegend();
onLoadDataAndUpdate();
@@ -339,7 +339,7 @@ void RimWellDistributionPlot::onLoadDataAndUpdate()
return;
}
m_plotWidget->detachItems( QwtPlotItem::Rtti_PlotCurve );
m_plotWidget->qwtPlot()->detachItems( QwtPlotItem::Rtti_PlotCurve );
updateLegend();
@@ -374,12 +374,12 @@ void RimWellDistributionPlot::onLoadDataAndUpdate()
const QString plotTitleStr =
QString( "%1 Distribution: %2, %3" ).arg( phaseString ).arg( m_wellName ).arg( timeStepName );
m_plotWidget->setTitle( plotTitleStr );
m_plotWidget->setPlotTitle( plotTitleStr );
m_plotWidget->setAxisTitleText( QwtPlot::xBottom, "TOF [years]" );
m_plotWidget->setAxisTitleText( QwtPlot::yLeft, "Reservoir Volume [m3]" );
m_plotWidget->setAxisTitleEnabled( QwtPlot::xBottom, true );
m_plotWidget->setAxisTitleEnabled( QwtPlot::yLeft, true );
m_plotWidget->setAxisTitleText( RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM, "TOF [years]" );
m_plotWidget->setAxisTitleText( RiaDefines::PlotAxis::PLOT_AXIS_LEFT, "Reservoir Volume [m3]" );
m_plotWidget->setAxisTitleEnabled( RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM, true );
m_plotWidget->setAxisTitleEnabled( RiaDefines::PlotAxis::PLOT_AXIS_LEFT, true );
m_plotWidget->scheduleReplot();
}
@@ -397,11 +397,11 @@ void RimWellDistributionPlot::populatePlotWidgetWithCurveData( const RigTofWellD
// Currently select this value so that the grid appears on top of the curves
const double baseCurveZValue = 9.5;
plotWidget->detachItems( QwtPlotItem::Rtti_PlotCurve );
plotWidget->setAxisScale( QwtPlot::xBottom, 0, 1 );
plotWidget->setAxisScale( QwtPlot::yLeft, 0, 1 );
plotWidget->setAxisAutoScale( QwtPlot::xBottom, true );
plotWidget->setAxisAutoScale( QwtPlot::yLeft, true );
plotWidget->qwtPlot()->detachItems( QwtPlotItem::Rtti_PlotCurve );
plotWidget->setAxisScale( RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM, 0, 1 );
plotWidget->setAxisScale( RiaDefines::PlotAxis::PLOT_AXIS_LEFT, 0, 1 );
plotWidget->setAxisAutoScale( RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM, true );
plotWidget->setAxisAutoScale( RiaDefines::PlotAxis::PLOT_AXIS_LEFT, true );
const std::vector<double>& tofValuesDays = calculator.sortedUniqueTofValues();
if ( tofValuesDays.size() == 0 )
@@ -449,7 +449,7 @@ void RimWellDistributionPlot::populatePlotWidgetWithCurveData( const RigTofWellD
curve->setBrush( qtClr );
curve->setZ( baseCurveZValue - i * 0.0001 );
curve->setSamples( tofValuesYears.data(), yVals.data(), static_cast<int>( tofValuesYears.size() ) );
curve->attach( plotWidget );
curve->attach( plotWidget->qwtPlot() );
}
}

View File

@@ -49,18 +49,18 @@ public:
RiaDefines::PhaseType phase() const;
// RimPlot implementations
RiuQwtPlotWidget* viewer() override;
void setAutoScaleXEnabled( bool enabled ) override;
void setAutoScaleYEnabled( bool enabled ) override;
void updateAxes() override;
void updateLegend() override;
void updateZoomInQwt() override;
void updateZoomFromQwt() override;
QString asciiDataForPlotExport() const override;
void reattachAllCurves() override;
void detachAllCurves() override;
caf::PdmObject* findPdmObjectFromQwtCurve( const QwtPlotCurve* curve ) const override;
void onAxisSelected( int axis, bool toggle ) override;
RiuPlotWidget* plotWidget() override;
void setAutoScaleXEnabled( bool enabled ) override;
void setAutoScaleYEnabled( bool enabled ) override;
void updateAxes() override;
void updateLegend() override;
void updateZoomInParentPlot() override;
void updateZoomFromParentPlot() override;
QString asciiDataForPlotExport() const override;
void reattachAllCurves() override;
void detachAllCurves() override;
caf::PdmObject* findPdmObjectFromPlotCurve( const RiuPlotCurve* curve ) const override;
void onAxisSelected( int axis, bool toggle ) override;
// RimPlotWindow implementations
QString description() const override;
@@ -76,7 +76,7 @@ private:
void onLoadDataAndUpdate() override;
private:
RiuQwtPlotWidget* doCreatePlotViewWidget( QWidget* mainWindowParent ) override;
RiuPlotWidget* doCreatePlotViewWidget( QWidget* mainWindowParent ) override;
void fixupDependentFieldsAfterCaseChange();
static void populatePlotWidgetWithCurveData( const RigTofWellDistributionCalculator& calculator,

View File

@@ -30,7 +30,9 @@
#include "RiaColorTools.h"
#include "RiuMultiPlotPage.h"
#include "RiuPlotWidget.h"
#include "RiuQwtPlotTools.h"
#include "RiuQwtPlotWidget.h"
#include "qwt_legend.h"
#include "qwt_plot.h"
@@ -217,7 +219,7 @@ void RimWellDistributionPlotCollection::addPlot( RimPlot* plot )
if ( m_viewer )
{
plot->createPlotWidget();
m_viewer->insertPlot( plot->viewer(), index );
m_viewer->insertPlot( plot->plotWidget(), index );
}
plot->setShowWindow( true );
plot->setLegendsVisible( false );
@@ -373,7 +375,7 @@ void RimWellDistributionPlotCollection::updatePlots()
for ( RimPlot* plot : m_plots() )
{
plot->loadDataAndUpdate();
plot->updateZoomInQwt();
plot->updateZoomInParentPlot();
}
}
}
@@ -407,7 +409,7 @@ void RimWellDistributionPlotCollection::recreatePlotWidgets()
for ( auto plot : m_plots() )
{
plot->createPlotWidget();
m_viewer->addPlot( plot->viewer() );
m_viewer->addPlot( plot->plotWidget() );
}
}

View File

@@ -161,7 +161,7 @@ void RimWellFlowRateCurve::onLoadDataAndUpdate( bool updateParentPlot )
{
this->RimPlotCurve::updateCurvePresentation( updateParentPlot );
m_qwtPlotCurve->setTitle( createCurveAutoName() );
m_plotCurve->setTitle( createCurveAutoName() );
if ( updateParentPlot )
{
@@ -172,7 +172,7 @@ void RimWellFlowRateCurve::onLoadDataAndUpdate( bool updateParentPlot )
updateZoomInParentPlot();
}
if ( m_parentQwtPlot ) m_parentQwtPlot->replot();
if ( hasParentPlot() ) m_parentPlot->replot();
}
//--------------------------------------------------------------------------------------------------
@@ -195,9 +195,11 @@ void RimWellFlowRateCurve::updateCurveAppearance()
}
}
if ( isUsingConnectionNumberDepthType() )
QwtPlotCurve* qwtPlotCurve = dynamic_cast<QwtPlotCurve*>( m_plotCurve );
if ( isUsingConnectionNumberDepthType() && qwtPlotCurve )
{
m_qwtPlotCurve->setStyle( QwtPlotCurve::Steps );
// Steps style only for Qwt.
qwtPlotCurve->setStyle( QwtPlotCurve::Steps );
}
if ( m_doFillCurve || isLastCurveInGroup ) // Fill the last curve in group with a transparent color to "tie" the
@@ -222,14 +224,19 @@ void RimWellFlowRateCurve::updateCurveAppearance()
gradient.setColorAt( 0.6, fillColor );
gradient.setColorAt( 0.8, fillColor.darker( 110 ) );
gradient.setColorAt( 1, fillColor );
m_qwtPlotCurve->setBrush( gradient );
m_plotCurve->setBrush( gradient );
QPen curvePen = m_qwtPlotCurve->pen();
curvePen.setColor( lineColor );
m_qwtPlotCurve->setPen( curvePen );
m_qwtPlotCurve->setOrientation( Qt::Horizontal );
m_qwtPlotCurve->setBaseline( 0.0 );
m_qwtPlotCurve->setCurveAttribute( QwtPlotCurve::Inverted, true );
if ( qwtPlotCurve )
{
// Baseline and orientation only available for Qwt.
QPen curvePen = qwtPlotCurve->pen();
curvePen.setColor( lineColor );
qwtPlotCurve->setPen( curvePen );
qwtPlotCurve->setOrientation( Qt::Horizontal );
qwtPlotCurve->setBaseline( 0.0 );
qwtPlotCurve->setCurveAttribute( QwtPlotCurve::Inverted, true );
}
}
}

View File

@@ -709,7 +709,7 @@ void RimWellPltPlot::addStackedCurve( const QString& curveName,
if ( curveGroupId == 0 )
{
curve->setDoFillCurve( true );
curve->setSymbol( RiuQwtSymbol::SYMBOL_NONE );
curve->setSymbol( RiuPlotCurveSymbol::SYMBOL_NONE );
}
else
{

View File

@@ -156,7 +156,7 @@ void RimWellRftPlot::applyCurveAppearance( RimWellLogCurve* curve )
RiaRftPltCurveDefinition curveDef = RimWellPlotTools::curveDefFromCurve( curve );
RiuQwtPlotCurveDefines::LineStyleEnum lineStyle = RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_SOLID;
RiuQwtSymbol::PointSymbolEnum currentSymbol = RiuQwtSymbol::SYMBOL_NONE;
RiuPlotCurveSymbol::PointSymbolEnum currentSymbol = RiuPlotCurveSymbol::SYMBOL_NONE;
if ( curveDef.address().sourceType() != RifDataSourceForRftPlt::ENSEMBLE_RFT )
{
currentSymbol = m_timeStepSymbols[curveDef.timeStep()];
@@ -571,8 +571,8 @@ void RimWellRftPlot::updateCurvesInPlot( const std::set<RiaRftPltCurveDefinition
curve->setZOrder(
RiuQwtPlotCurveDefines::zDepthForIndex( RiuQwtPlotCurveDefines::ZIndex::Z_ENSEMBLE_STAT_CURVE ) );
applyCurveAppearance( curve );
auto symbol = statisticsCurveSymbolFromAddress( rftAddress );
RiuQwtSymbol::LabelPosition labelPos = statisticsLabelPosFromAddress( rftAddress );
auto symbol = statisticsCurveSymbolFromAddress( rftAddress );
RiuPlotCurveSymbol::LabelPosition labelPos = statisticsLabelPosFromAddress( rftAddress );
curve->setSymbol( symbol );
curve->setSymbolLabelPosition( labelPos );
curve->setSymbolSize( curve->symbolSize() + 3 );
@@ -1159,39 +1159,39 @@ void RimWellRftPlot::assignWellPathToExtractionCurves()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuQwtSymbol::PointSymbolEnum RimWellRftPlot::statisticsCurveSymbolFromAddress( const RifEclipseRftAddress& address )
RiuPlotCurveSymbol::PointSymbolEnum RimWellRftPlot::statisticsCurveSymbolFromAddress( const RifEclipseRftAddress& address )
{
switch ( address.wellLogChannel() )
{
case RifEclipseRftAddress::PRESSURE_P10:
return RiuQwtSymbol::SYMBOL_TRIANGLE;
return RiuPlotCurveSymbol::SYMBOL_TRIANGLE;
case RifEclipseRftAddress::PRESSURE_P50:
return RiuQwtSymbol::SYMBOL_DOWN_TRIANGLE;
return RiuPlotCurveSymbol::SYMBOL_DOWN_TRIANGLE;
case RifEclipseRftAddress::PRESSURE_P90:
return RiuQwtSymbol::SYMBOL_LEFT_TRIANGLE;
return RiuPlotCurveSymbol::SYMBOL_LEFT_TRIANGLE;
case RifEclipseRftAddress::PRESSURE_MEAN:
return RiuQwtSymbol::SYMBOL_RIGHT_TRIANGLE;
return RiuPlotCurveSymbol::SYMBOL_RIGHT_TRIANGLE;
}
return RiuQwtSymbol::SYMBOL_RIGHT_TRIANGLE;
return RiuPlotCurveSymbol::SYMBOL_RIGHT_TRIANGLE;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuQwtSymbol::LabelPosition RimWellRftPlot::statisticsLabelPosFromAddress( const RifEclipseRftAddress& address )
RiuPlotCurveSymbol::LabelPosition RimWellRftPlot::statisticsLabelPosFromAddress( const RifEclipseRftAddress& address )
{
switch ( address.wellLogChannel() )
{
case RifEclipseRftAddress::PRESSURE_P10:
return RiuQwtSymbol::LabelLeftOfSymbol;
return RiuPlotCurveSymbol::LabelLeftOfSymbol;
case RifEclipseRftAddress::PRESSURE_P50:
return RiuQwtSymbol::LabelAboveSymbol;
return RiuPlotCurveSymbol::LabelAboveSymbol;
case RifEclipseRftAddress::PRESSURE_P90:
return RiuQwtSymbol::LabelRightOfSymbol;
return RiuPlotCurveSymbol::LabelRightOfSymbol;
case RifEclipseRftAddress::PRESSURE_MEAN:
return RiuQwtSymbol::LabelBelowSymbol;
return RiuPlotCurveSymbol::LabelBelowSymbol;
}
return RiuQwtSymbol::LabelAboveSymbol;
return RiuPlotCurveSymbol::LabelAboveSymbol;
}
//--------------------------------------------------------------------------------------------------
@@ -1217,10 +1217,10 @@ cvf::Color3f RimWellRftPlot::findCurveColor( RimWellLogCurve* curve )
if ( m_showStatisticsCurves )
{
if ( plotByIndex( 0 ) && plotByIndex( 0 )->viewer() )
if ( plotByIndex( 0 ) && plotByIndex( 0 )->plotWidget() )
{
cvf::Color3f backgroundColor =
RiaColorTools::fromQColorTo3f( plotByIndex( 0 )->viewer()->canvasBackground().color() );
RiaColorTools::fromQColorTo3f( plotByIndex( 0 )->plotWidget()->backgroundColor() );
curveColor = RiaColorTools::blendCvfColors( backgroundColor, curveColor, 1, 2 );
}
}
@@ -1272,7 +1272,7 @@ void RimWellRftPlot::defineCurveColorsAndSymbols( const std::set<RiaRftPltCurveD
{
if ( !m_ensembleLegendFrames[curveSet] )
{
auto m = new RiuDraggableOverlayFrame( viewer->canvas(), viewer->overlayMargins() );
auto m = new RiuDraggableOverlayFrame( viewer->getParentForOverlay(), viewer->overlayMargins() );
m->setContentFrame( curveSet->legendConfig()->makeLegendFrame() );
m_ensembleLegendFrames[curveSet] = m;
@@ -1286,12 +1286,12 @@ void RimWellRftPlot::defineCurveColorsAndSymbols( const std::set<RiaRftPltCurveD
std::vector<cvf::Color3f> colorTable;
RiaColorTables::summaryCurveDefaultPaletteColors().color3fArray().toStdVector( &colorTable );
std::vector<RiuQwtSymbol::PointSymbolEnum> symbolTable = { RiuQwtSymbol::SYMBOL_ELLIPSE,
RiuQwtSymbol::SYMBOL_RECT,
RiuQwtSymbol::SYMBOL_DIAMOND,
RiuQwtSymbol::SYMBOL_CROSS,
RiuQwtSymbol::SYMBOL_XCROSS,
RiuQwtSymbol::SYMBOL_STAR1 };
std::vector<RiuPlotCurveSymbol::PointSymbolEnum> symbolTable = { RiuPlotCurveSymbol::SYMBOL_ELLIPSE,
RiuPlotCurveSymbol::SYMBOL_RECT,
RiuPlotCurveSymbol::SYMBOL_DIAMOND,
RiuPlotCurveSymbol::SYMBOL_CROSS,
RiuPlotCurveSymbol::SYMBOL_XCROSS,
RiuPlotCurveSymbol::SYMBOL_STAR1 };
// Add new curves
for ( const RiaRftPltCurveDefinition& curveDefToAdd : allCurveDefs )

View File

@@ -24,7 +24,7 @@
#include "RimWellRftEnsembleCurveSet.h"
#include "RifDataSourceForRftPltQMetaType.h"
#include "RiuQwtSymbol.h"
#include "RiuPlotCurveSymbol.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
@@ -130,8 +130,8 @@ private:
void updateFormationsOnPlot() const;
QString associatedSimWellName() const;
static RiuQwtSymbol::PointSymbolEnum statisticsCurveSymbolFromAddress( const RifEclipseRftAddress& address );
static RiuQwtSymbol::LabelPosition statisticsLabelPosFromAddress( const RifEclipseRftAddress& address );
static RiuPlotCurveSymbol::PointSymbolEnum statisticsCurveSymbolFromAddress( const RifEclipseRftAddress& address );
static RiuPlotCurveSymbol::LabelPosition statisticsLabelPosFromAddress( const RifEclipseRftAddress& address );
cvf::Color3f findCurveColor( RimWellLogCurve* curve );
void defineCurveColorsAndSymbols( const std::set<RiaRftPltCurveDefinition>& allCurveDefs );
@@ -158,9 +158,9 @@ private:
caf::PdmChildArrayField<RimWellRftEnsembleCurveSet*> m_ensembleCurveSets;
std::map<RimWellRftEnsembleCurveSet*, QPointer<RiuDraggableOverlayFrame>> m_ensembleLegendFrames;
std::map<RifDataSourceForRftPlt, cvf::Color3f> m_dataSourceColors;
std::map<QDateTime, RiuQwtSymbol::PointSymbolEnum> m_timeStepSymbols;
bool m_isOnLoad;
std::map<RifDataSourceForRftPlt, cvf::Color3f> m_dataSourceColors;
std::map<QDateTime, RiuPlotCurveSymbol::PointSymbolEnum> m_timeStepSymbols;
bool m_isOnLoad;
caf::PdmChildField<RimWellLogPlot*> m_wellLogPlot_OBSOLETE;
};