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

@@ -117,7 +117,7 @@ void RimAsciiDataCurve::updateZoomInParentPlot()
RimSummaryPlot* plot = nullptr;
firstAncestorOrThisOfType( plot );
plot->updateZoomInQwt();
plot->updateZoomInParentPlot();
}
//--------------------------------------------------------------------------------------------------
@@ -140,7 +140,7 @@ void RimAsciiDataCurve::onLoadDataAndUpdate( bool updateParentPlot )
{
if ( plot->timeAxisProperties()->timeMode() == RimSummaryTimeAxisProperties::DATE )
{
m_qwtPlotCurve->setSamplesFromTimeTAndYValues( dateTimes, values, isLogCurve );
m_plotCurve->setSamplesFromTimeTAndYValues( dateTimes, values, isLogCurve );
}
else
{
@@ -156,17 +156,17 @@ void RimAsciiDataCurve::onLoadDataAndUpdate( bool updateParentPlot )
}
}
m_qwtPlotCurve->setSamplesFromXValuesAndYValues( times, values, isLogCurve );
m_plotCurve->setSamplesFromXValuesAndYValues( times, values, isLogCurve );
}
}
else
{
m_qwtPlotCurve->setSamplesFromTimeTAndYValues( std::vector<time_t>(), std::vector<double>(), isLogCurve );
m_plotCurve->setSamplesFromTimeTAndYValues( std::vector<time_t>(), std::vector<double>(), isLogCurve );
}
updateZoomInParentPlot();
if ( m_parentQwtPlot ) m_parentQwtPlot->replot();
if ( m_parentPlot ) m_parentPlot->replot();
}
updateQwtPlotAxis();
@@ -197,17 +197,7 @@ void RimAsciiDataCurve::defineUiOrdering( QString uiConfigName, caf::PdmUiOrderi
//--------------------------------------------------------------------------------------------------
void RimAsciiDataCurve::updateQwtPlotAxis()
{
if ( m_qwtPlotCurve )
{
if ( this->yAxis() == RiaDefines::PlotAxis::PLOT_AXIS_LEFT )
{
m_qwtPlotCurve->setYAxis( QwtPlot::yLeft );
}
else
{
m_qwtPlotCurve->setYAxis( QwtPlot::yRight );
}
}
if ( m_plotCurve ) updateAxisInPlot( this->yAxis() );
}
//--------------------------------------------------------------------------------------------------

View File

@@ -58,7 +58,7 @@ public:
void setTimeSteps( const std::vector<QDateTime>& timeSteps );
void setValues( const std::vector<double>& values );
void setTitle( const QString& title );
void setTitle( const QString& title ) override;
protected:
// RimPlotCurve overrides

View File

@@ -53,9 +53,9 @@
#include "RiuAbstractLegendFrame.h"
#include "RiuDraggableOverlayFrame.h"
#include "RiuPlotCurve.h"
#include "RiuPlotCurveSymbol.h"
#include "RiuPlotMainWindow.h"
#include "RiuQwtPlotCurve.h"
#include "RiuSummaryQwtPlot.h"
#include "RiuSummaryVectorSelectionDialog.h"
#include "RiuTextContentFrame.h"
@@ -70,23 +70,13 @@
#include "cafPdmUiTreeSelectionEditor.h"
#include "cafTitledOverlayFrame.h"
#include "cvfScalarMapper.h"
#include "qwt_plot_curve.h"
#include "qwt_symbol.h"
#include <algorithm>
//--------------------------------------------------------------------------------------------------
/// Internal constants
//--------------------------------------------------------------------------------------------------
#define DOUBLE_INF std::numeric_limits<double>::infinity()
//--------------------------------------------------------------------------------------------------
/// Internal functions
//--------------------------------------------------------------------------------------------------
RiuQwtSymbol::PointSymbolEnum statisticsCurveSymbolFromAddress( const RifEclipseSummaryAddress& address );
int statisticsCurveSymbolSize( RiuQwtSymbol::PointSymbolEnum symbol );
RiuPlotCurveSymbol::PointSymbolEnum statisticsCurveSymbolFromAddress( const RifEclipseSummaryAddress& address );
int statisticsCurveSymbolSize( RiuPlotCurveSymbol::PointSymbolEnum symbol );
CAF_PDM_SOURCE_INIT( RimEnsembleCurveSet, "RimEnsembleCurveSet" );
@@ -210,8 +200,7 @@ RimEnsembleCurveSet::RimEnsembleCurveSet()
m_summaryAddressNameTools = new RimSummaryCurveAutoName;
m_qwtPlotCurveForLegendText = new QwtPlotCurve;
m_qwtPlotCurveForLegendText->setLegendAttribute( QwtPlotCurve::LegendShowSymbol, true );
m_plotCurveForLegendText = nullptr;
m_ensembleStatCase.reset( new RimEnsembleStatisticsCase( this ) );
m_ensembleStatCase->createSummaryReaderInterface();
@@ -232,12 +221,12 @@ RimEnsembleCurveSet::~RimEnsembleCurveSet()
RimSummaryPlot* parentPlot;
firstAncestorOrThisOfType( parentPlot );
if ( parentPlot && parentPlot->viewer() )
if ( parentPlot && parentPlot->plotWidget() )
{
m_qwtPlotCurveForLegendText->detach();
if ( m_plotCurveForLegendText ) m_plotCurveForLegendText->detach();
if ( m_legendOverlayFrame )
{
parentPlot->viewer()->removeOverlayFrame( m_legendOverlayFrame );
parentPlot->plotWidget()->removeOverlayFrame( m_legendOverlayFrame );
}
}
if ( m_legendOverlayFrame )
@@ -256,7 +245,7 @@ RimEnsembleCurveSet::~RimEnsembleCurveSet()
delete m_objectiveFunctionOverlayFrame;
}
delete m_qwtPlotCurveForLegendText;
delete m_plotCurveForLegendText;
}
//--------------------------------------------------------------------------------------------------
@@ -304,44 +293,55 @@ void RimEnsembleCurveSet::loadDataAndUpdate( bool updateParentPlot )
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEnsembleCurveSet::setParentQwtPlotNoReplot( QwtPlot* plot )
void RimEnsembleCurveSet::setParentPlotNoReplot( RiuPlotWidget* plot )
{
for ( RimSummaryCurve* curve : m_curves )
{
curve->setParentQwtPlotNoReplot( plot );
// TODO: attach without replotting
curve->attach( plot );
}
if ( !m_plotCurveForLegendText )
{
m_plotCurveForLegendText = plot->createPlotCurve( nullptr, "", Qt::black );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEnsembleCurveSet::detachQwtCurves()
void RimEnsembleCurveSet::detachPlotCurves()
{
for ( RimSummaryCurve* curve : m_curves )
{
curve->detachQwtCurve();
curve->detach();
}
m_qwtPlotCurveForLegendText->detach();
if ( m_plotCurveForLegendText )
{
m_plotCurveForLegendText->detach();
delete m_plotCurveForLegendText;
m_plotCurveForLegendText = nullptr;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEnsembleCurveSet::reattachQwtCurves()
void RimEnsembleCurveSet::reattachPlotCurves()
{
for ( RimSummaryCurve* curve : m_curves )
{
curve->reattachQwtCurve();
curve->reattach();
}
m_qwtPlotCurveForLegendText->detach();
RimSummaryPlot* plot = nullptr;
firstAncestorOrThisOfType( plot );
if ( plot )
if ( m_plotCurveForLegendText )
{
m_qwtPlotCurveForLegendText->attach( plot->viewer() );
m_plotCurveForLegendText->detach();
RimSummaryPlot* plot = nullptr;
firstAncestorOrThisOfType( plot );
if ( plot && plot->plotWidget() ) m_plotCurveForLegendText->attachToPlot( plot->plotWidget() );
}
}
@@ -354,7 +354,7 @@ void RimEnsembleCurveSet::addCurve( RimSummaryCurve* curve )
{
RimSummaryPlot* plot;
firstAncestorOrThisOfType( plot );
if ( plot ) curve->setParentQwtPlotNoReplot( plot->viewer() );
if ( plot && plot->plotWidget() ) curve->setParentPlotNoReplot( plot->plotWidget() );
curve->setColor( m_color );
m_curves.push_back( curve );
@@ -619,6 +619,15 @@ void RimEnsembleCurveSet::fieldChangedByUi( const caf::PdmFieldHandle* changedFi
if ( changedField == &m_showCurves )
{
if ( !m_showCurves() )
{
// Need to detach the legend since the plot type might change from Qwt to QtCharts.
// The plot curve for legend text needs to be recreated when curves are shown next time.
m_plotCurveForLegendText->detach();
delete m_plotCurveForLegendText;
m_plotCurveForLegendText = nullptr;
}
loadDataAndUpdate( true );
updateConnectedEditors();
@@ -738,7 +747,7 @@ void RimEnsembleCurveSet::fieldChangedByUi( const caf::PdmFieldHandle* changedFi
curve->setLeftOrRightAxisY( m_plotAxis() );
}
updateQwtPlotAxis();
updatePlotAxis();
plot->updateAxes();
updateTextInPlot = true;
@@ -1315,26 +1324,26 @@ void RimEnsembleCurveSet::updateFilterLegend()
{
RimSummaryPlot* plot;
firstAncestorOrThisOfType( plot );
if ( plot && plot->viewer() )
if ( plot && plot->plotWidget() )
{
if ( m_curveFilters()->isActive() && m_curveFilters()->countActiveFilters() > 0 )
{
if ( !m_filterOverlayFrame )
{
m_filterOverlayFrame =
new RiuDraggableOverlayFrame( plot->viewer()->canvas(), plot->viewer()->overlayMargins() );
new RiuDraggableOverlayFrame( plot->plotWidget(), plot->plotWidget()->overlayMargins() );
}
m_filterOverlayFrame->setContentFrame( m_curveFilters()->makeFilterDescriptionFrame() );
plot->viewer()->addOverlayFrame( m_filterOverlayFrame );
plot->plotWidget()->addOverlayFrame( m_filterOverlayFrame );
}
else
{
if ( m_filterOverlayFrame )
{
plot->viewer()->removeOverlayFrame( m_filterOverlayFrame );
plot->plotWidget()->removeOverlayFrame( m_filterOverlayFrame );
}
}
plot->viewer()->scheduleReplot();
plot->plotWidget()->scheduleReplot();
}
}
@@ -1345,7 +1354,7 @@ void RimEnsembleCurveSet::updateObjectiveFunctionLegend()
{
RimSummaryPlot* plot;
firstAncestorOrThisOfType( plot );
if ( plot && plot->viewer() )
if ( plot && plot->plotWidget() )
{
if ( ( m_colorMode == ColorMode::BY_OBJECTIVE_FUNCTION || m_colorMode == ColorMode::BY_CUSTOM_OBJECTIVE_FUNCTION ) &&
m_showObjectiveFunctionFormula() )
@@ -1353,7 +1362,7 @@ void RimEnsembleCurveSet::updateObjectiveFunctionLegend()
if ( !m_objectiveFunctionOverlayFrame )
{
m_objectiveFunctionOverlayFrame =
new RiuDraggableOverlayFrame( plot->viewer()->canvas(), plot->viewer()->overlayMargins() );
new RiuDraggableOverlayFrame( plot->plotWidget(), plot->plotWidget()->overlayMargins() );
}
QString title;
QString description;
@@ -1385,18 +1394,18 @@ void RimEnsembleCurveSet::updateObjectiveFunctionLegend()
{
m_objectiveFunctionOverlayFrame->setContentFrame( new RiuTextContentFrame( nullptr, title, description ) );
m_objectiveFunctionOverlayFrame->setMaximumWidth( 10000 );
plot->viewer()->addOverlayFrame( m_objectiveFunctionOverlayFrame );
plot->plotWidget()->addOverlayFrame( m_objectiveFunctionOverlayFrame );
}
}
else
{
if ( m_objectiveFunctionOverlayFrame )
{
plot->viewer()->removeOverlayFrame( m_objectiveFunctionOverlayFrame );
plot->plotWidget()->removeOverlayFrame( m_objectiveFunctionOverlayFrame );
}
}
}
plot->viewer()->scheduleReplot();
plot->plotWidget()->scheduleReplot();
}
//--------------------------------------------------------------------------------------------------
@@ -1565,27 +1574,27 @@ void RimEnsembleCurveSet::updateCurveColors()
RimSummaryPlot* plot;
firstAncestorOrThisOfType( plot );
if ( plot && plot->viewer() )
if ( plot && plot->plotWidget() )
{
if ( m_yValuesSummaryCaseCollection() && isCurvesVisible() && m_colorMode != ColorMode::SINGLE_COLOR &&
m_legendConfig->showLegend() )
{
if ( !m_legendOverlayFrame )
{
m_legendOverlayFrame =
new RiuDraggableOverlayFrame( plot->viewer()->canvas(), plot->viewer()->overlayMargins() );
m_legendOverlayFrame = new RiuDraggableOverlayFrame( plot->plotWidget()->getParentForOverlay(),
plot->plotWidget()->overlayMargins() );
}
m_legendOverlayFrame->setContentFrame( m_legendConfig->makeLegendFrame() );
plot->viewer()->addOverlayFrame( m_legendOverlayFrame );
plot->plotWidget()->addOverlayFrame( m_legendOverlayFrame );
}
else
{
if ( m_legendOverlayFrame )
{
plot->viewer()->removeOverlayFrame( m_legendOverlayFrame );
plot->plotWidget()->removeOverlayFrame( m_legendOverlayFrame );
}
}
plot->viewer()->scheduleReplot();
plot->plotWidget()->scheduleReplot();
}
}
@@ -1638,11 +1647,11 @@ void RimEnsembleCurveSet::updateAddressesUiField()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEnsembleCurveSet::updateQwtPlotAxis()
void RimEnsembleCurveSet::updatePlotAxis()
{
for ( RimSummaryCurve* curve : curves() )
{
curve->updateQwtPlotAxis();
curve->updatePlotAxis();
}
}
@@ -1656,7 +1665,7 @@ void RimEnsembleCurveSet::updateEnsembleCurves( const std::vector<RimSummaryCase
CVF_ASSERT( plot );
deleteEnsembleCurves();
m_qwtPlotCurveForLegendText->detach();
if ( m_plotCurveForLegendText ) m_plotCurveForLegendText->detach();
deleteStatisticsCurves();
if ( m_statistics->hideEnsembleCurves() ) return;
@@ -1692,20 +1701,18 @@ void RimEnsembleCurveSet::updateEnsembleCurves( const std::vector<RimSummaryCase
for ( int i = 0; i < (int)newSummaryCurves.size(); ++i )
{
newSummaryCurves[i]->loadDataAndUpdate( false );
newSummaryCurves[i]->updateQwtPlotAxis();
if ( newSummaryCurves[i]->qwtPlotCurve() )
{
newSummaryCurves[i]->qwtPlotCurve()->setItemAttribute( QwtPlotItem::Legend, false );
}
newSummaryCurves[i]->updatePlotAxis();
newSummaryCurves[i]->setShowInLegend( false );
}
if ( plot->viewer() ) m_qwtPlotCurveForLegendText->attach( plot->viewer() );
if ( plot->plotWidget() && m_plotCurveForLegendText )
m_plotCurveForLegendText->attachToPlot( plot->plotWidget() );
}
if ( plot->viewer() )
if ( plot->plotWidget() )
{
if ( plot->legendsVisible() ) plot->viewer()->updateLegend();
plot->viewer()->scheduleReplot();
if ( plot->legendsVisible() ) plot->plotWidget()->updateLegend();
plot->plotWidget()->scheduleReplot();
plot->updateAxes();
plot->updatePlotInfoLabel();
}
@@ -1764,35 +1771,36 @@ void RimEnsembleCurveSet::updateStatisticsCurves( const std::vector<RimSummaryCa
}
deleteStatisticsCurves();
for ( auto address : addresses )
{
auto curve = new RimSummaryCurve();
curve->setParentQwtPlotNoReplot( plot->viewer() );
m_curves.push_back( curve );
curve->setColor( m_statistics->color() );
curve->setResampling( m_resampling() );
auto symbol = statisticsCurveSymbolFromAddress( address );
curve->setSymbol( symbol );
curve->setSymbolSize( statisticsCurveSymbolSize( symbol ) );
curve->setSymbolSkipDistance( 150 );
if ( m_statistics->showCurveLabels() )
if ( plot->plotWidget() )
{
for ( auto address : addresses )
{
curve->setSymbolLabel( QString::fromStdString( address.ensembleStatisticsQuantityName() ) );
auto curve = new RimSummaryCurve();
curve->setParentPlotNoReplot( plot->plotWidget() );
m_curves.push_back( curve );
curve->setColor( m_statistics->color() );
curve->setResampling( m_resampling() );
auto symbol = statisticsCurveSymbolFromAddress( address );
curve->setSymbol( symbol );
curve->setSymbolSize( statisticsCurveSymbolSize( symbol ) );
curve->setSymbolSkipDistance( 150 );
if ( m_statistics->showCurveLabels() )
{
curve->setSymbolLabel( QString::fromStdString( address.ensembleStatisticsQuantityName() ) );
}
curve->setLineStyle( RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_SOLID );
curve->setSummaryCaseY( m_ensembleStatCase.get() );
curve->setSummaryAddressYAndApplyInterpolation( address );
curve->setLeftOrRightAxisY( m_plotAxis() );
curve->updateCurveVisibility();
curve->loadDataAndUpdate( false );
curve->updatePlotAxis();
}
curve->setLineStyle( RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_SOLID );
curve->setSummaryCaseY( m_ensembleStatCase.get() );
curve->setSummaryAddressYAndApplyInterpolation( address );
curve->setLeftOrRightAxisY( m_plotAxis() );
curve->updateCurveVisibility();
curve->loadDataAndUpdate( false );
curve->updateQwtPlotAxis();
}
if ( plot->viewer() )
{
plot->viewer()->updateLegend();
plot->plotWidget()->updateLegend();
plot->updateAxes();
}
}
@@ -1839,7 +1847,7 @@ void RimEnsembleCurveSet::updateAllTextInPlot()
RimSummaryPlot* summaryPlot = nullptr;
this->firstAncestorOrThisOfTypeAsserted( summaryPlot );
if ( summaryPlot->viewer() )
if ( summaryPlot->plotWidget() )
{
summaryPlot->updatePlotTitle();
}
@@ -1944,16 +1952,16 @@ bool RimEnsembleCurveSet::hasMeanData() const
//--------------------------------------------------------------------------------------------------
void RimEnsembleCurveSet::updateEnsembleLegendItem()
{
m_qwtPlotCurveForLegendText->setTitle( name() );
if ( !m_plotCurveForLegendText ) return;
m_plotCurveForLegendText->setTitle( name() );
{
QwtSymbol* symbol = nullptr;
RiuPlotCurveSymbol* symbol = m_plotCurveForLegendText->createSymbol( RiuPlotCurveSymbol::SYMBOL_CROSS );
if ( m_colorMode == ColorMode::SINGLE_COLOR )
{
symbol = new QwtSymbol( QwtSymbol::HLine );
QColor curveColor( m_color.value().rByte(), m_color.value().gByte(), m_color.value().bByte() );
QColor curveColor = RiaColorTools::toQColor( m_color );
QPen curvePen( curveColor );
curvePen.setWidth( 2 );
@@ -1963,17 +1971,15 @@ void RimEnsembleCurveSet::updateEnsembleLegendItem()
else if ( m_colorMode == ColorMode::BY_ENSEMBLE_PARAM )
{
QPixmap p = QPixmap( ":/Legend.png" );
symbol = new QwtSymbol;
symbol->setPixmap( p );
symbol->setSize( 8, 8 );
}
m_qwtPlotCurveForLegendText->setSymbol( symbol );
m_plotCurveForLegendText->setSymbol( symbol );
}
bool showLegendItem = isCurvesVisible();
m_qwtPlotCurveForLegendText->setItemAttribute( QwtPlotItem::Legend, showLegendItem );
m_plotCurveForLegendText->setVisibleInLegend( showLegendItem );
}
//--------------------------------------------------------------------------------------------------
@@ -2039,23 +2045,23 @@ void RimEnsembleCurveSet::updateLegendMappingMode()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuQwtSymbol::PointSymbolEnum statisticsCurveSymbolFromAddress( const RifEclipseSummaryAddress& address )
RiuPlotCurveSymbol::PointSymbolEnum statisticsCurveSymbolFromAddress( const RifEclipseSummaryAddress& address )
{
auto qName = QString::fromStdString( address.quantityName() );
if ( qName.contains( ENSEMBLE_STAT_P10_QUANTITY_NAME ) ) return RiuQwtSymbol::SYMBOL_TRIANGLE;
if ( qName.contains( ENSEMBLE_STAT_P90_QUANTITY_NAME ) ) return RiuQwtSymbol::SYMBOL_DOWN_TRIANGLE;
if ( qName.contains( ENSEMBLE_STAT_P50_QUANTITY_NAME ) ) return RiuQwtSymbol::SYMBOL_DIAMOND;
return RiuQwtSymbol::SYMBOL_ELLIPSE;
if ( qName.contains( ENSEMBLE_STAT_P10_QUANTITY_NAME ) ) return RiuPlotCurveSymbol::SYMBOL_TRIANGLE;
if ( qName.contains( ENSEMBLE_STAT_P90_QUANTITY_NAME ) ) return RiuPlotCurveSymbol::SYMBOL_DOWN_TRIANGLE;
if ( qName.contains( ENSEMBLE_STAT_P50_QUANTITY_NAME ) ) return RiuPlotCurveSymbol::SYMBOL_DIAMOND;
return RiuPlotCurveSymbol::SYMBOL_ELLIPSE;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int statisticsCurveSymbolSize( RiuQwtSymbol::PointSymbolEnum symbol )
int statisticsCurveSymbolSize( RiuPlotCurveSymbol::PointSymbolEnum symbol )
{
if ( symbol == RiuQwtSymbol::SYMBOL_DIAMOND ) return 8;
if ( symbol == RiuQwtSymbol::SYMBOL_TRIANGLE ) return 7;
if ( symbol == RiuQwtSymbol::SYMBOL_DOWN_TRIANGLE ) return 7;
if ( symbol == RiuPlotCurveSymbol::SYMBOL_DIAMOND ) return 8;
if ( symbol == RiuPlotCurveSymbol::SYMBOL_TRIANGLE ) return 7;
if ( symbol == RiuPlotCurveSymbol::SYMBOL_DOWN_TRIANGLE ) return 7;
return 6;
}

View File

@@ -22,7 +22,7 @@
#include "RifEclipseSummaryAddressQMetaType.h"
#include "RifSummaryReaderInterface.h"
#include "RiaDefines.h"
#include "RiaPlotDefines.h"
#include "RiaQDateTimeTools.h"
#include "RimEnsembleCurveSetColorManager.h"
@@ -61,6 +61,8 @@ class RiuDraggableOverlayFrame;
class RiaSummaryCurveDefinitionAnalyser;
class RiaSummaryCurveDefinition;
class RiuSummaryVectorSelectionDialog;
class RiuPlotWidget;
class RiuPlotCurve;
class QwtPlot;
class QwtPlotCurve;
@@ -92,9 +94,9 @@ public:
void setColor( cvf::Color3f color );
void loadDataAndUpdate( bool updateParentPlot );
void setParentQwtPlotNoReplot( QwtPlot* plot );
void detachQwtCurves();
void reattachQwtCurves();
void setParentPlotNoReplot( RiuPlotWidget* plot );
void detachPlotCurves();
void reattachPlotCurves();
void addCurve( RimSummaryCurve* curve );
void deleteCurve( RimSummaryCurve* curve );
@@ -184,7 +186,7 @@ private:
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
void updateQwtPlotAxis();
void updatePlotAxis();
QString createAutoName() const;
@@ -241,7 +243,7 @@ private:
caf::PdmProxyValueField<QString> m_autoGeneratedName;
caf::PdmChildField<RimSummaryCurveAutoName*> m_summaryAddressNameTools;
QwtPlotCurve* m_qwtPlotCurveForLegendText;
RiuPlotCurve* m_plotCurveForLegendText;
QPointer<RiuDraggableOverlayFrame> m_legendOverlayFrame;
QPointer<RiuDraggableOverlayFrame> m_filterOverlayFrame;
QPointer<RiuDraggableOverlayFrame> m_objectiveFunctionOverlayFrame;

View File

@@ -29,9 +29,7 @@
#include "RimSummaryPlot.h"
#include "RimSummaryPlotSourceStepping.h"
#include "RiuQwtPlotCurve.h"
#include "qwt_plot.h"
#include "RiuPlotCurve.h"
CAF_PDM_SOURCE_INIT( RimEnsembleCurveSetCollection, "RimEnsembleCurveSetCollection" );
@@ -94,11 +92,11 @@ void RimEnsembleCurveSetCollection::loadDataAndUpdate( bool updateParentPlot )
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEnsembleCurveSetCollection::setParentQwtPlotAndReplot( QwtPlot* plot )
void RimEnsembleCurveSetCollection::setParentPlotAndReplot( RiuPlotWidget* plot )
{
for ( RimEnsembleCurveSet* curveSet : m_curveSets )
{
curveSet->setParentQwtPlotNoReplot( plot );
curveSet->setParentPlotNoReplot( plot );
}
if ( plot ) plot->replot();
@@ -107,35 +105,35 @@ void RimEnsembleCurveSetCollection::setParentQwtPlotAndReplot( QwtPlot* plot )
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEnsembleCurveSetCollection::detachQwtCurves()
void RimEnsembleCurveSetCollection::detachPlotCurves()
{
for ( const auto& curveSet : m_curveSets )
{
curveSet->detachQwtCurves();
curveSet->detachPlotCurves();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEnsembleCurveSetCollection::reattachQwtCurves()
void RimEnsembleCurveSetCollection::reattachPlotCurves()
{
for ( const auto& curveSet : m_curveSets )
{
curveSet->reattachQwtCurves();
curveSet->reattachPlotCurves();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimSummaryCurve* RimEnsembleCurveSetCollection::findRimCurveFromQwtCurve( const QwtPlotCurve* qwtCurve ) const
RimSummaryCurve* RimEnsembleCurveSetCollection::findRimCurveFromPlotCurve( const RiuPlotCurve* curve ) const
{
for ( RimEnsembleCurveSet* curveSet : m_curveSets )
{
for ( RimSummaryCurve* rimCurve : curveSet->curves() )
{
if ( rimCurve->qwtPlotCurve() == qwtCurve )
if ( rimCurve->isSameCurve( curve ) )
{
return rimCurve;
}
@@ -148,13 +146,13 @@ RimSummaryCurve* RimEnsembleCurveSetCollection::findRimCurveFromQwtCurve( const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimEnsembleCurveSet* RimEnsembleCurveSetCollection::findRimCurveSetFromQwtCurve( const QwtPlotCurve* qwtCurve ) const
RimEnsembleCurveSet* RimEnsembleCurveSetCollection::findCurveSetFromPlotCurve( const RiuPlotCurve* curve ) const
{
for ( RimEnsembleCurveSet* curveSet : m_curveSets )
{
for ( RimSummaryCurve* rimCurve : curveSet->curves() )
{
if ( rimCurve->qwtPlotCurve() == qwtCurve )
if ( rimCurve->isSameCurve( curve ) )
{
return curveSet;
}

View File

@@ -18,6 +18,7 @@
#pragma once
#include "RiuPlotWidget.h"
#include "cafPdmChildArrayField.h"
#include "cafPdmChildField.h"
#include "cafPdmField.h"
@@ -26,8 +27,7 @@
class RimEnsembleCurveSet;
class RimSummaryPlotSourceStepping;
class RimSummaryCurve;
class QwtPlot;
class QwtPlotCurve;
class RiuPlotCurve;
//==================================================================================================
///
@@ -43,12 +43,12 @@ public:
bool isCurveSetsVisible();
void loadDataAndUpdate( bool updateParentPlot );
void setParentQwtPlotAndReplot( QwtPlot* plot );
void detachQwtCurves();
void reattachQwtCurves();
void setParentPlotAndReplot( RiuPlotWidget* plot );
void detachPlotCurves();
void reattachPlotCurves();
RimSummaryCurve* findRimCurveFromQwtCurve( const QwtPlotCurve* qwtCurve ) const;
RimEnsembleCurveSet* findRimCurveSetFromQwtCurve( const QwtPlotCurve* qwtCurve ) const;
RimSummaryCurve* findRimCurveFromPlotCurve( const RiuPlotCurve* qwtCurve ) const;
RimEnsembleCurveSet* findCurveSetFromPlotCurve( const RiuPlotCurve* qwtCurve ) const;
void addCurveSet( RimEnsembleCurveSet* curveSet );
void deleteCurveSet( RimEnsembleCurveSet* curveSet );

View File

@@ -55,9 +55,6 @@
#include "cafPdmUiPushButtonEditor.h"
#include "cafPdmUiTreeOrdering.h"
#include "qwt_date.h"
#include "qwt_plot.h"
CAF_PDM_SOURCE_INIT( RimSummaryCurve, "SummaryCurve" );
//--------------------------------------------------------------------------------------------------
@@ -153,7 +150,7 @@ void RimSummaryCurve::setSummaryCaseY( RimSummaryCase* sumCase )
{
if ( m_yValuesSummaryCase != sumCase )
{
m_qwtCurveErrorBars->setSamples( nullptr );
clearErrorBars();
}
bool isEnsembleCurve = false;
@@ -215,7 +212,7 @@ void RimSummaryCurve::setSummaryAddressY( const RifEclipseSummaryAddress& addres
{
if ( m_yValuesSummaryAddress->address() != address )
{
m_qwtCurveErrorBars->setSamples( nullptr );
clearErrorBars();
}
m_yValuesSummaryAddress->setAddress( address );
@@ -392,10 +389,7 @@ double RimSummaryCurve::yValueAtTimeT( time_t time ) const
//--------------------------------------------------------------------------------------------------
void RimSummaryCurve::setOverrideCurveDataY( const std::vector<time_t>& dateTimes, const std::vector<double>& yValues )
{
if ( m_qwtPlotCurve )
{
m_qwtPlotCurve->setSamplesFromTimeTAndYValues( dateTimes, yValues, true );
}
setSamplesFromTimeTAndYValues( dateTimes, yValues, true );
}
//--------------------------------------------------------------------------------------------------
@@ -558,7 +552,7 @@ void RimSummaryCurve::updateZoomInParentPlot()
RimSummaryPlot* plot = nullptr;
firstAncestorOrThisOfTypeAsserted( plot );
plot->updateZoomInQwt();
plot->updateZoomInParentPlot();
}
//--------------------------------------------------------------------------------------------------
@@ -699,14 +693,14 @@ void RimSummaryCurve::onLoadDataAndUpdate( bool updateParentPlot )
this->setSamplesFromXYValues( std::vector<double>(), std::vector<double>(), isLogCurve );
}
if ( updateParentPlot && m_parentQwtPlot )
if ( updateParentPlot && hasParentPlot() )
{
updateZoomInParentPlot();
m_parentQwtPlot->replot();
replotParentPlot();
}
}
if ( updateParentPlot ) updateQwtPlotAxis();
if ( updateParentPlot ) updateAxisInPlot( axisY() );
}
//--------------------------------------------------------------------------------------------------
@@ -909,19 +903,9 @@ RiaDefines::PhaseType RimSummaryCurve::phaseType() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSummaryCurve::updateQwtPlotAxis()
void RimSummaryCurve::updatePlotAxis()
{
if ( m_qwtPlotCurve )
{
if ( this->axisY() == RiaDefines::PlotAxis::PLOT_AXIS_LEFT )
{
m_qwtPlotCurve->setYAxis( QwtPlot::yLeft );
}
else
{
m_qwtPlotCurve->setYAxis( QwtPlot::yRight );
}
}
updateAxisInPlot( axisY() );
}
//--------------------------------------------------------------------------------------------------
@@ -942,7 +926,7 @@ QString RimSummaryCurve::curveExportDescription( const RifEclipseSummaryAddress&
RimEnsembleCurveSetCollection* coll;
firstAncestorOrThisOfType( coll );
auto curveSet = coll ? coll->findRimCurveSetFromQwtCurve( m_qwtPlotCurve ) : nullptr;
auto curveSet = coll ? coll->findCurveSetFromPlotCurve( m_plotCurve ) : nullptr;
auto group = curveSet ? curveSet->summaryCaseCollection() : nullptr;
auto addressUiText = addr.uiText();
@@ -970,7 +954,7 @@ void RimSummaryCurve::setCurveAppearanceFromCaseType()
if ( m_yValuesSummaryCase->isObservedData() )
{
setLineStyle( RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_NONE );
setSymbol( RiuQwtSymbol::SYMBOL_XCROSS );
setSymbol( RiuPlotCurveSymbol::SYMBOL_XCROSS );
return;
}
@@ -984,7 +968,7 @@ void RimSummaryCurve::setCurveAppearanceFromCaseType()
{
setSymbolEdgeColor( m_curveAppearance->color() );
setSymbol( RiuQwtSymbol::SYMBOL_XCROSS );
setSymbol( RiuPlotCurveSymbol::SYMBOL_XCROSS );
setLineStyle( RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_NONE );
}
else if ( prefs->defaultSummaryHistoryCurveStyle() ==
@@ -992,12 +976,12 @@ void RimSummaryCurve::setCurveAppearanceFromCaseType()
{
setSymbolEdgeColor( m_curveAppearance->color() );
setSymbol( RiuQwtSymbol::SYMBOL_XCROSS );
setSymbol( RiuPlotCurveSymbol::SYMBOL_XCROSS );
setLineStyle( RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_SOLID );
}
else if ( prefs->defaultSummaryHistoryCurveStyle() == RiaPreferencesSummary::SummaryHistoryCurveStyleMode::LINES )
{
setSymbol( RiuQwtSymbol::SYMBOL_NONE );
setSymbol( RiuPlotCurveSymbol::SYMBOL_NONE );
setLineStyle( RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_SOLID );
}
@@ -1063,8 +1047,7 @@ void RimSummaryCurve::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
}
else if ( changedField == &m_plotAxis )
{
updateQwtPlotAxis();
updateAxisInPlot( axisY() );
plot->updateAxes();
dataChanged.send();
}
@@ -1075,7 +1058,7 @@ void RimSummaryCurve::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
{
// If no previous case selected and observed data, use symbols to indicate observed data curve
setLineStyle( RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_NONE );
setSymbol( RiuQwtSymbol::SYMBOL_XCROSS );
setSymbol( RiuPlotCurveSymbol::SYMBOL_XCROSS );
}
plot->updateCaseNameHasChanged();

View File

@@ -87,7 +87,7 @@ public:
bool isEnsembleCurve() const;
void setIsEnsembleCurve( bool isEnsembleCurve );
void updateQwtPlotAxis();
void updatePlotAxis();
void applyCurveAutoNameSettings( const RimSummaryCurveAutoName& autoNameSettings );
QString curveExportDescription( const RifEclipseSummaryAddress& address = RifEclipseSummaryAddress() ) const override;

View File

@@ -245,8 +245,8 @@ std::map<std::string, size_t>
}
else if ( appearance == CurveAppearanceType::SYMBOL )
{
numOptions = caf::AppEnum<RiuQwtSymbol::PointSymbolEnum>::size() - 1; // -1 since the No symbol option is not
// counted see cycledSymbol()
numOptions = caf::AppEnum<RiuPlotCurveSymbol::PointSymbolEnum>::size() - 1; // -1 since the No symbol option is
// not counted see cycledSymbol()
}
else if ( appearance == CurveAppearanceType::LINE_STYLE )
{
@@ -524,12 +524,12 @@ RiuQwtPlotCurveDefines::LineStyleEnum RimSummaryCurveAppearanceCalculator::cycle
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuQwtSymbol::PointSymbolEnum RimSummaryCurveAppearanceCalculator::cycledSymbol( int index )
RiuPlotCurveSymbol::PointSymbolEnum RimSummaryCurveAppearanceCalculator::cycledSymbol( int index )
{
if ( index < 0 ) return RiuQwtSymbol::SYMBOL_NONE;
if ( index < 0 ) return RiuPlotCurveSymbol::SYMBOL_NONE;
return caf::AppEnum<RiuQwtSymbol::PointSymbolEnum>::fromIndex(
1 + ( index % ( caf::AppEnum<RiuQwtSymbol::PointSymbolEnum>::size() - 1 ) ) );
return caf::AppEnum<RiuPlotCurveSymbol::PointSymbolEnum>::fromIndex(
1 + ( index % ( caf::AppEnum<RiuPlotCurveSymbol::PointSymbolEnum>::size() - 1 ) ) );
}
//--------------------------------------------------------------------------------------------------

View File

@@ -17,8 +17,8 @@
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "RiuPlotCurveSymbol.h"
#include "RiuQwtPlotCurveDefines.h"
#include "RiuQwtSymbol.h"
#include "cvfColor3.h"
@@ -57,13 +57,13 @@ public:
void setupCurveLook( RimSummaryCurve* curve );
static cvf::Color3f cycledPaletteColor( int colorIndex );
static cvf::Color3f cycledNoneRGBBrColor( int colorIndex );
static cvf::Color3f cycledGreenColor( int colorIndex );
static cvf::Color3f cycledBlueColor( int colorIndex );
static cvf::Color3f cycledRedColor( int colorIndex );
static cvf::Color3f cycledBrownColor( int colorIndex );
static RiuQwtSymbol::PointSymbolEnum cycledSymbol( int index );
static cvf::Color3f cycledPaletteColor( int colorIndex );
static cvf::Color3f cycledNoneRGBBrColor( int colorIndex );
static cvf::Color3f cycledGreenColor( int colorIndex );
static cvf::Color3f cycledBlueColor( int colorIndex );
static cvf::Color3f cycledRedColor( int colorIndex );
static cvf::Color3f cycledBrownColor( int colorIndex );
static RiuPlotCurveSymbol::PointSymbolEnum cycledSymbol( int index );
private:
void setOneCurveAppearance( CurveAppearanceType appeaType, size_t totalCount, int appeaIdx, RimSummaryCurve* curve );

View File

@@ -109,7 +109,7 @@ void RimSummaryCurveCollection::loadDataAndUpdate( bool updateParentPlot )
for ( RimSummaryCurve* curve : m_curves )
{
curve->loadDataAndUpdate( false );
curve->updateQwtPlotAxis();
curve->updatePlotAxis();
}
if ( updateParentPlot )
@@ -123,11 +123,11 @@ void RimSummaryCurveCollection::loadDataAndUpdate( bool updateParentPlot )
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSummaryCurveCollection::setParentQwtPlotAndReplot( QwtPlot* plot )
void RimSummaryCurveCollection::setParentPlotAndReplot( RiuPlotWidget* plot )
{
for ( RimSummaryCurve* curve : m_curves )
{
curve->setParentQwtPlotNoReplot( plot );
curve->setParentPlotNoReplot( plot );
}
if ( plot ) plot->replot();
@@ -136,33 +136,33 @@ void RimSummaryCurveCollection::setParentQwtPlotAndReplot( QwtPlot* plot )
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSummaryCurveCollection::detachQwtCurves()
void RimSummaryCurveCollection::detachPlotCurves()
{
for ( RimSummaryCurve* curve : m_curves )
{
curve->detachQwtCurve();
curve->detach();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSummaryCurveCollection::reattachQwtCurves()
void RimSummaryCurveCollection::reattachPlotCurves()
{
for ( RimSummaryCurve* curve : m_curves )
{
curve->reattachQwtCurve();
curve->reattach();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimSummaryCurve* RimSummaryCurveCollection::findRimCurveFromQwtCurve( const QwtPlotCurve* qwtCurve ) const
RimSummaryCurve* RimSummaryCurveCollection::findRimCurveFromPlotCurve( const RiuPlotCurve* curve ) const
{
for ( RimSummaryCurve* rimCurve : m_curves )
{
if ( rimCurve->qwtPlotCurve() == qwtCurve )
if ( rimCurve->isSameCurve( curve ) )
{
return rimCurve;
}
@@ -342,7 +342,7 @@ void RimSummaryCurveCollection::updateCaseNameHasChanged()
firstAncestorOrThisOfTypeAsserted( parentPlot );
parentPlot->updatePlotTitle();
if ( parentPlot->viewer() ) parentPlot->viewer()->updateLegend();
if ( parentPlot->plotWidget() ) parentPlot->plotWidget()->updateLegend();
}
//--------------------------------------------------------------------------------------------------

View File

@@ -26,12 +26,12 @@
#include "cafPdmObject.h"
#include "cafPdmPtrArrayField.h"
class QwtPlot;
class QwtPlotCurve;
class RimSummaryCase;
class RimSummaryCurve;
class RimSummaryCrossPlot;
class RimSummaryPlot;
class RiuPlotWidget;
class RiuPlotCurve;
class QKeyEvent;
//==================================================================================================
@@ -63,11 +63,11 @@ public:
void loadDataAndUpdate( bool updateParentPlot );
private:
void setParentQwtPlotAndReplot( QwtPlot* plot );
void detachQwtCurves();
void reattachQwtCurves();
void setParentPlotAndReplot( RiuPlotWidget* plot );
void detachPlotCurves();
void reattachPlotCurves();
RimSummaryCurve* findRimCurveFromQwtCurve( const QwtPlotCurve* qwtCurve ) const;
RimSummaryCurve* findRimCurveFromPlotCurve( const RiuPlotCurve* curve ) const;
void addCurve( RimSummaryCurve* curve );
void insertCurve( RimSummaryCurve* curve, size_t index );

View File

@@ -19,11 +19,14 @@
#include "RimSummaryPlot.h"
#include "RiaColorTables.h"
#include "RiaDefines.h"
#include "RiaFieldHandleTools.h"
#include "RiaPlotDefines.h"
#include "RiaSummaryAddressAnalyzer.h"
#include "RiaSummaryCurveDefinition.h"
#include "RiaSummaryTools.h"
#include "RiaTimeHistoryCurveResampler.h"
#include "RicfCommandObject.h"
#include "SummaryPlotCommands/RicSummaryPlotEditorUi.h"
@@ -35,6 +38,7 @@
#include "RimEnsembleCurveSetCollection.h"
#include "RimGridTimeHistoryCurve.h"
#include "RimMultiPlot.h"
#include "RimPlotAxisLogRangeCalculator.h"
#include "RimPlotAxisProperties.h"
#include "RimProject.h"
#include "RimSummaryCase.h"
@@ -50,6 +54,10 @@
#include "RiuSummaryQwtPlot.h"
#include "RiuTreeViewEventFilter.h"
#ifdef USE_QTCHARTS
#include "RiuSummaryQtChartsPlot.h"
#endif
#include "cvfColor3.h"
#include "cafPdmFieldScriptingCapability.h"
@@ -57,12 +65,9 @@
#include "cafPdmUiTreeOrdering.h"
#include "cafSelectionManager.h"
#include "qwt_abstract_legend.h"
#include "qwt_legend.h"
#include "qwt_plot.h"
#include "qwt_plot_curve.h"
#include "qwt_plot_renderer.h"
#include "qwt_plot_textlabel.h"
#include "qwt_scale_engine.h"
#include <QDateTime>
#include <QDebug>
@@ -203,7 +208,9 @@ RimSummaryPlot::RimSummaryPlot()
CAF_PDM_InitScriptableField( &m_useAutoPlotTitle, "IsUsingAutoName", true, "Auto Title" );
CAF_PDM_InitScriptableField( &m_description, "PlotDescription", QString( "Summary Plot" ), "Name" );
CAF_PDM_InitScriptableField( &m_normalizeCurveYValues, "normalizeCurveYValues", false, "Normalize all curves" );
#ifdef USE_QTCHARTS
CAF_PDM_InitScriptableField( &m_useQtChartsPlot, "useQtChartsPlot", false, "Use Qt Charts" );
#endif
CAF_PDM_InitFieldNoDefault( &m_summaryCurveCollection, "SummaryCurveCollection", "" );
m_summaryCurveCollection.uiCapability()->setUiTreeHidden( true );
m_summaryCurveCollection = new RimSummaryCurveCollection;
@@ -222,17 +229,17 @@ RimSummaryPlot::RimSummaryPlot()
CAF_PDM_InitFieldNoDefault( &m_leftYAxisProperties, "LeftYAxisProperties", "Left Y Axis" );
m_leftYAxisProperties.uiCapability()->setUiTreeHidden( true );
m_leftYAxisProperties = new RimPlotAxisProperties;
m_leftYAxisProperties->setNameAndAxis( "Left Y-Axis", QwtPlot::yLeft );
m_leftYAxisProperties->setNameAndAxis( "Left Y-Axis", RiaDefines::PlotAxis::PLOT_AXIS_LEFT );
CAF_PDM_InitFieldNoDefault( &m_rightYAxisProperties, "RightYAxisProperties", "Right Y Axis" );
m_rightYAxisProperties.uiCapability()->setUiTreeHidden( true );
m_rightYAxisProperties = new RimPlotAxisProperties;
m_rightYAxisProperties->setNameAndAxis( "Right Y-Axis", QwtPlot::yRight );
m_rightYAxisProperties->setNameAndAxis( "Right Y-Axis", RiaDefines::PlotAxis::PLOT_AXIS_RIGHT );
CAF_PDM_InitFieldNoDefault( &m_bottomAxisProperties, "BottomAxisProperties", "Bottom X Axis" );
m_bottomAxisProperties.uiCapability()->setUiTreeHidden( true );
m_bottomAxisProperties = new RimPlotAxisProperties;
m_bottomAxisProperties->setNameAndAxis( "Bottom X-Axis", QwtPlot::xBottom );
m_bottomAxisProperties->setNameAndAxis( "Bottom X-Axis", RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM );
connectAxisSignals( m_leftYAxisProperties() );
connectAxisSignals( m_rightYAxisProperties() );
@@ -282,13 +289,13 @@ void RimSummaryPlot::updateAxes()
updateYAxis( RiaDefines::PlotAxis::PLOT_AXIS_LEFT );
updateYAxis( RiaDefines::PlotAxis::PLOT_AXIS_RIGHT );
if ( m_timeAxisProperties() && m_plotWidget )
if ( m_timeAxisProperties() && plotWidget() )
{
m_plotWidget->updateAnnotationObjects( m_timeAxisProperties() );
m_summaryPlot->updateAnnotationObjects( m_timeAxisProperties() );
}
if ( m_leftYAxisProperties() && m_plotWidget )
if ( m_leftYAxisProperties() && plotWidget() )
{
m_plotWidget->updateAnnotationObjects( m_leftYAxisProperties() );
m_summaryPlot->updateAnnotationObjects( m_leftYAxisProperties() );
}
if ( m_isCrossPlot )
@@ -300,9 +307,9 @@ void RimSummaryPlot::updateAxes()
updateTimeAxis();
}
m_plotWidget->scheduleReplot();
plotWidget()->scheduleReplot();
updateZoomInQwt();
updateZoomInParentPlot();
}
//--------------------------------------------------------------------------------------------------
@@ -352,15 +359,17 @@ time_t RimSummaryPlot::firstTimeStepOfFirstCurve()
//--------------------------------------------------------------------------------------------------
QWidget* RimSummaryPlot::viewWidget()
{
return m_plotWidget;
return plotWidget();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuQwtPlotWidget* RimSummaryPlot::viewer()
RiuPlotWidget* RimSummaryPlot::plotWidget()
{
return m_plotWidget;
if ( !m_summaryPlot ) return nullptr;
return m_summaryPlot->plotWidget();
}
//--------------------------------------------------------------------------------------------------
@@ -421,11 +430,11 @@ QString RimSummaryPlot::asciiDataForSummaryPlotExport( RiaQDateTimeTools::DateTi
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::PdmObject* RimSummaryPlot::findPdmObjectFromQwtCurve( const QwtPlotCurve* qwtCurve ) const
caf::PdmObject* RimSummaryPlot::findPdmObjectFromPlotCurve( const RiuPlotCurve* plotCurve ) const
{
for ( RimGridTimeHistoryCurve* curve : m_gridTimeHistoryCurves )
{
if ( curve->qwtPlotCurve() == qwtCurve )
if ( curve->isSameCurve( plotCurve ) )
{
return curve;
}
@@ -433,7 +442,7 @@ caf::PdmObject* RimSummaryPlot::findPdmObjectFromQwtCurve( const QwtPlotCurve* q
for ( RimAsciiDataCurve* curve : m_asciiDataCurves )
{
if ( curve->qwtPlotCurve() == qwtCurve )
if ( curve->isSameCurve( plotCurve ) )
{
return curve;
}
@@ -441,7 +450,7 @@ caf::PdmObject* RimSummaryPlot::findPdmObjectFromQwtCurve( const QwtPlotCurve* q
if ( m_summaryCurveCollection )
{
RimSummaryCurve* foundCurve = m_summaryCurveCollection->findRimCurveFromQwtCurve( qwtCurve );
RimSummaryCurve* foundCurve = m_summaryCurveCollection->findRimCurveFromPlotCurve( plotCurve );
if ( foundCurve )
{
@@ -453,7 +462,7 @@ caf::PdmObject* RimSummaryPlot::findPdmObjectFromQwtCurve( const QwtPlotCurve* q
if ( m_ensembleCurveSetCollection )
{
RimSummaryCurve* foundCurve = m_ensembleCurveSetCollection->findRimCurveFromQwtCurve( qwtCurve );
RimSummaryCurve* foundCurve = m_ensembleCurveSetCollection->findRimCurveFromPlotCurve( plotCurve );
if ( foundCurve )
{
@@ -671,12 +680,12 @@ void RimSummaryPlot::updatePlotTitle()
updateCurveNames();
updateMdiWindowTitle();
if ( m_plotWidget )
if ( plotWidget() )
{
QString plotTitle = description();
m_plotWidget->setPlotTitle( plotTitle );
m_plotWidget->setPlotTitleEnabled( m_showPlotTitle && !isSubPlot() );
m_plotWidget->scheduleReplot();
plotWidget()->setPlotTitle( plotTitle );
plotWidget()->setPlotTitleEnabled( m_showPlotTitle && !isSubPlot() );
plotWidget()->scheduleReplot();
}
}
@@ -736,10 +745,10 @@ void RimSummaryPlot::copyAxisPropertiesFromOther( const RimSummaryPlot& sourceSu
//--------------------------------------------------------------------------------------------------
void RimSummaryPlot::updateAll()
{
if ( m_plotWidget )
if ( plotWidget() )
{
updatePlotTitle();
m_plotWidget->updateLegend();
plotWidget()->updateLegend();
updateAxes();
}
}
@@ -749,15 +758,15 @@ void RimSummaryPlot::updateAll()
//--------------------------------------------------------------------------------------------------
void RimSummaryPlot::updateLegend()
{
if ( m_plotWidget )
if ( plotWidget() )
{
m_plotWidget->setInternalLegendVisible( m_showPlotLegends && !isSubPlot() );
plotWidget()->setInternalLegendVisible( m_showPlotLegends && !isSubPlot() );
}
reattachAllCurves();
if ( m_plotWidget )
if ( plotWidget() )
{
m_plotWidget->updateLegend();
plotWidget()->updateLegend();
}
}
@@ -783,8 +792,11 @@ void RimSummaryPlot::setPlotInfoLabel( const QString& label )
//--------------------------------------------------------------------------------------------------
void RimSummaryPlot::showPlotInfoLabel( bool show )
{
RiuQwtPlotWidget* qwtPlotWidget = dynamic_cast<RiuQwtPlotWidget*>( plotWidget() );
if ( !qwtPlotWidget ) return;
if ( show )
m_plotInfoLabel->attach( m_plotWidget );
m_plotInfoLabel->attach( qwtPlotWidget->qwtPlot() );
else
m_plotInfoLabel->detach();
}
@@ -881,22 +893,12 @@ bool RimSummaryPlot::isNormalizationEnabled()
//--------------------------------------------------------------------------------------------------
void RimSummaryPlot::updateYAxis( RiaDefines::PlotAxis plotAxis )
{
if ( !m_plotWidget ) return;
QwtPlot::Axis qwtAxis = QwtPlot::yLeft;
if ( plotAxis == RiaDefines::PlotAxis::PLOT_AXIS_LEFT )
{
qwtAxis = QwtPlot::yLeft;
}
else
{
qwtAxis = QwtPlot::yRight;
}
if ( !plotWidget() ) return;
RimPlotAxisProperties* yAxisProperties = yAxisPropertiesLeftOrRight( plotAxis );
if ( yAxisProperties->isActive() && hasVisibleCurvesForAxis( plotAxis ) )
{
m_plotWidget->enableAxis( qwtAxis, true );
plotWidget()->enableAxis( plotAxis, true );
std::set<QString> timeHistoryQuantities;
@@ -910,11 +912,11 @@ void RimSummaryPlot::updateYAxis( RiaDefines::PlotAxis plotAxis )
{},
visibleAsciiDataCurvesForAxis( plotAxis ),
timeHistoryQuantities );
calc.applyAxisPropertiesToPlot( m_plotWidget );
calc.applyAxisPropertiesToPlot( plotWidget() );
}
else
{
m_plotWidget->enableAxis( qwtAxis, false );
plotWidget()->enableAxis( plotAxis, false );
}
}
@@ -929,11 +931,11 @@ void RimSummaryPlot::updateZoomForAxis( RiaDefines::PlotAxis plotAxis )
{
if ( m_bottomAxisProperties->isAutoZoom() )
{
m_plotWidget->setAxisAutoScale( QwtPlot::xBottom, true );
plotWidget()->setAxisAutoScale( RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM, true );
}
else
{
m_plotWidget->setAxisScale( QwtPlot::xBottom,
plotWidget()->setAxisScale( RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM,
m_bottomAxisProperties->visibleRangeMin(),
m_bottomAxisProperties->visibleRangeMax() );
}
@@ -942,11 +944,11 @@ void RimSummaryPlot::updateZoomForAxis( RiaDefines::PlotAxis plotAxis )
{
if ( m_timeAxisProperties->isAutoZoom() )
{
m_plotWidget->setAxisAutoScale( QwtPlot::xBottom, true );
plotWidget()->setAxisAutoScale( RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM, true );
}
else
{
m_plotWidget->setAxisScale( QwtPlot::xBottom,
plotWidget()->setAxisScale( RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM,
m_timeAxisProperties->visibleRangeMin(),
m_timeAxisProperties->visibleRangeMax() );
}
@@ -958,29 +960,29 @@ void RimSummaryPlot::updateZoomForAxis( RiaDefines::PlotAxis plotAxis )
if ( yAxisProps->isAutoZoom() )
{
m_plotWidget->setAxisIsLogarithmic( yAxisProps->qwtPlotAxisType(), yAxisProps->isLogarithmicScaleEnabled );
if ( yAxisProps->isLogarithmicScaleEnabled )
{
std::vector<const QwtPlotCurve*> plotCurves;
plotWidget()->setAxisScaleType( yAxisProps->plotAxisType(), RiuQwtPlotWidget::AxisScaleType::LOGARITHMIC );
std::vector<const RimPlotCurve*> plotCurves;
for ( RimSummaryCurve* c : visibleSummaryCurvesForAxis( plotAxis ) )
{
plotCurves.push_back( c->qwtPlotCurve() );
plotCurves.push_back( c );
}
for ( RimGridTimeHistoryCurve* c : visibleTimeHistoryCurvesForAxis( plotAxis ) )
{
plotCurves.push_back( c->qwtPlotCurve() );
plotCurves.push_back( c );
}
for ( RimAsciiDataCurve* c : visibleAsciiDataCurvesForAxis( plotAxis ) )
{
plotCurves.push_back( c->qwtPlotCurve() );
plotCurves.push_back( c );
}
double min, max;
RimPlotAxisLogRangeCalculator calc( QwtPlot::yLeft, plotCurves );
RimPlotAxisLogRangeCalculator calc( RiaDefines::PlotAxis::PLOT_AXIS_LEFT, plotCurves );
calc.computeAxisRange( &min, &max );
if ( yAxisProps->isAxisInverted() )
@@ -988,22 +990,21 @@ void RimSummaryPlot::updateZoomForAxis( RiaDefines::PlotAxis plotAxis )
std::swap( min, max );
}
m_plotWidget->setAxisScale( yAxisProps->qwtPlotAxisType(), min, max );
plotWidget()->setAxisScale( yAxisProps->plotAxisType(), min, max );
}
else
{
m_plotWidget->setAxisAutoScale( yAxisProps->qwtPlotAxisType(), true );
plotWidget()->setAxisAutoScale( yAxisProps->plotAxisType(), true );
}
}
else
{
m_plotWidget->setAxisScale( yAxisProps->qwtPlotAxisType(),
plotWidget()->setAxisScale( yAxisProps->plotAxisType(),
yAxisProps->visibleRangeMin(),
yAxisProps->visibleRangeMax() );
}
m_plotWidget->axisScaleEngine( yAxisProps->qwtPlotAxisType() )
->setAttribute( QwtScaleEngine::Inverted, yAxisProps->isAxisInverted() );
plotWidget()->setAxisInverted( yAxisProps->plotAxisType(), yAxisProps->isAxisInverted() );
}
}
@@ -1149,11 +1150,11 @@ std::vector<RimAsciiDataCurve*> RimSummaryPlot::visibleAsciiDataCurvesForAxis( R
//--------------------------------------------------------------------------------------------------
void RimSummaryPlot::updateTimeAxis()
{
if ( !m_plotWidget ) return;
if ( !plotWidget() ) return;
if ( !m_timeAxisProperties->isActive() )
{
m_plotWidget->enableAxis( QwtPlot::xBottom, false );
plotWidget()->enableAxis( RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM, false );
return;
}
@@ -1166,14 +1167,14 @@ void RimSummaryPlot::updateTimeAxis()
QString dateFormat = m_timeAxisProperties->dateFormat();
QString timeFormat = m_timeAxisProperties->timeFormat();
m_plotWidget->useDateBasedTimeAxis( dateFormat, timeFormat, dateComponents, timeComponents );
m_summaryPlot->useDateBasedTimeAxis( dateFormat, timeFormat, dateComponents, timeComponents );
}
else
{
m_plotWidget->useTimeBasedTimeAxis();
m_summaryPlot->useTimeBasedTimeAxis();
}
m_plotWidget->enableAxis( QwtPlot::xBottom, true );
plotWidget()->enableAxis( RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM, true );
{
Qt::AlignmentFlag alignment = Qt::AlignCenter;
@@ -1182,13 +1183,13 @@ void RimSummaryPlot::updateTimeAxis()
alignment = Qt::AlignRight;
}
m_plotWidget->setAxisFontsAndAlignment( QwtPlot::xBottom,
plotWidget()->setAxisFontsAndAlignment( RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM,
m_timeAxisProperties->titleFontSize(),
m_timeAxisProperties->valuesFontSize(),
true,
alignment );
m_plotWidget->setAxisTitleText( QwtPlot::xBottom, m_timeAxisProperties->title() );
m_plotWidget->setAxisTitleEnabled( QwtPlot::xBottom, m_timeAxisProperties->showTitle );
plotWidget()->setAxisTitleText( RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM, m_timeAxisProperties->title() );
plotWidget()->setAxisTitleEnabled( RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM, m_timeAxisProperties->showTitle );
{
RimSummaryTimeAxisProperties::LegendTickmarkCount tickmarkCountEnum =
@@ -1214,7 +1215,7 @@ void RimSummaryPlot::updateTimeAxis()
break;
}
m_plotWidget->setAxisMaxMajor( QwtPlot::xBottom, maxTickmarkCount );
plotWidget()->setAxisMaxMajor( RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM, maxTickmarkCount );
}
}
}
@@ -1224,15 +1225,13 @@ void RimSummaryPlot::updateTimeAxis()
//--------------------------------------------------------------------------------------------------
void RimSummaryPlot::updateBottomXAxis()
{
if ( !m_plotWidget ) return;
QwtPlot::Axis qwtAxis = QwtPlot::xBottom;
if ( !plotWidget() ) return;
RimPlotAxisProperties* bottomAxisProperties = m_bottomAxisProperties();
if ( bottomAxisProperties->isActive() )
{
m_plotWidget->enableAxis( qwtAxis, true );
plotWidget()->enableAxis( RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM, true );
std::set<QString> timeHistoryQuantities;
@@ -1241,11 +1240,11 @@ void RimSummaryPlot::updateBottomXAxis()
{},
visibleAsciiDataCurvesForAxis( RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM ),
timeHistoryQuantities );
calc.applyAxisPropertiesToPlot( m_plotWidget );
calc.applyAxisPropertiesToPlot( plotWidget() );
}
else
{
m_plotWidget->enableAxis( qwtAxis, false );
plotWidget()->enableAxis( RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM, false );
}
}
@@ -1306,7 +1305,7 @@ void RimSummaryPlot::zoomAll()
{
setAutoScaleXEnabled( true );
setAutoScaleYEnabled( true );
updateZoomInQwt();
updateZoomInParentPlot();
}
//--------------------------------------------------------------------------------------------------
@@ -1318,9 +1317,9 @@ void RimSummaryPlot::addCurveAndUpdate( RimSummaryCurve* curve )
{
m_summaryCurveCollection->addCurve( curve );
connectCurveSignals( curve );
if ( m_plotWidget )
if ( plotWidget() )
{
curve->setParentQwtPlotAndReplot( m_plotWidget );
curve->setParentPlotAndReplot( plotWidget() );
this->updateAxes();
}
}
@@ -1335,9 +1334,9 @@ void RimSummaryPlot::addCurveNoUpdate( RimSummaryCurve* curve )
{
m_summaryCurveCollection->addCurve( curve );
connectCurveSignals( curve );
if ( m_plotWidget )
if ( plotWidget() )
{
curve->setParentQwtPlotNoReplot( m_plotWidget );
curve->setParentPlotNoReplot( plotWidget() );
}
}
}
@@ -1351,9 +1350,9 @@ void RimSummaryPlot::insertCurve( RimSummaryCurve* curve, size_t insertAtPositio
{
m_summaryCurveCollection->insertCurve( curve, insertAtPosition );
connectCurveSignals( curve );
if ( m_plotWidget )
if ( plotWidget() )
{
curve->setParentQwtPlotNoReplot( m_plotWidget );
curve->setParentPlotNoReplot( plotWidget() );
}
}
}
@@ -1405,9 +1404,9 @@ void RimSummaryPlot::deleteCurves( const std::vector<RimSummaryCurve*>& curves )
if ( curveSet->curves().empty() )
{
if ( curveSet->colorMode() == RimEnsembleCurveSet::ColorMode::BY_ENSEMBLE_PARAM &&
m_plotWidget && curveSet->legendFrame() )
plotWidget() && curveSet->legendFrame() )
{
m_plotWidget->removeOverlayFrame( curveSet->legendFrame() );
plotWidget()->removeOverlayFrame( curveSet->legendFrame() );
}
m_ensembleCurveSetCollection->deleteCurveSet( curveSet );
}
@@ -1450,9 +1449,9 @@ void RimSummaryPlot::addGridTimeHistoryCurve( RimGridTimeHistoryCurve* curve )
CVF_ASSERT( curve );
m_gridTimeHistoryCurves.push_back( curve );
if ( m_plotWidget )
if ( plotWidget() )
{
curve->setParentQwtPlotAndReplot( m_plotWidget );
curve->setParentPlotAndReplot( plotWidget() );
this->updateAxes();
}
}
@@ -1465,9 +1464,9 @@ void RimSummaryPlot::addGridTimeHistoryCurveNoUpdate( RimGridTimeHistoryCurve* c
CVF_ASSERT( curve );
m_gridTimeHistoryCurves.push_back( curve );
if ( m_plotWidget )
if ( plotWidget() )
{
curve->setParentQwtPlotNoReplot( m_plotWidget );
curve->setParentPlotNoReplot( plotWidget() );
}
}
@@ -1487,10 +1486,9 @@ void RimSummaryPlot::addAsciiDataCruve( RimAsciiDataCurve* curve )
CVF_ASSERT( curve );
m_asciiDataCurves.push_back( curve );
if ( m_plotWidget )
if ( plotWidget() )
{
curve->setParentQwtPlotAndReplot( m_plotWidget );
this->updateAxes();
curve->setParentPlotAndReplot( plotWidget() );
}
}
@@ -1549,10 +1547,10 @@ void RimSummaryPlot::updateStackedCurveData()
updateStackedCurveDataForAxis( RiaDefines::PlotAxis::PLOT_AXIS_LEFT );
updateStackedCurveDataForAxis( RiaDefines::PlotAxis::PLOT_AXIS_RIGHT );
if ( m_plotWidget )
if ( plotWidget() )
{
reattachAllCurves();
m_plotWidget->scheduleReplot();
plotWidget()->scheduleReplot();
}
}
@@ -1622,9 +1620,9 @@ QImage RimSummaryPlot::snapshotWindowContent()
{
QImage image;
if ( m_plotWidget )
if ( plotWidget() )
{
QPixmap pix = m_plotWidget->grab();
QPixmap pix = plotWidget()->grab();
image = pix.toImage();
}
@@ -1696,11 +1694,11 @@ void RimSummaryPlot::onLoadDataAndUpdate()
curve->loadDataAndUpdate( false );
}
if ( m_plotWidget )
if ( plotWidget() )
{
m_plotWidget->setInternalLegendVisible( m_showPlotLegends && !isSubPlot() );
m_plotWidget->setLegendFontSize( legendFontSize() );
m_plotWidget->updateLegend();
plotWidget()->setInternalLegendVisible( m_showPlotLegends && !isSubPlot() );
plotWidget()->setLegendFontSize( legendFontSize() );
plotWidget()->updateLegend();
}
this->updateAxes();
@@ -1712,49 +1710,49 @@ void RimSummaryPlot::onLoadDataAndUpdate()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSummaryPlot::updateZoomInQwt()
void RimSummaryPlot::updateZoomInParentPlot()
{
if ( m_plotWidget )
if ( plotWidget() )
{
updateZoomForAxis( RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM );
updateZoomForAxis( RiaDefines::PlotAxis::PLOT_AXIS_LEFT );
updateZoomForAxis( RiaDefines::PlotAxis::PLOT_AXIS_RIGHT );
m_plotWidget->updateAxes();
updateZoomFromQwt();
m_plotWidget->scheduleReplot();
plotWidget()->updateAxes();
updateZoomFromParentPlot();
plotWidget()->scheduleReplot();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSummaryPlot::updateZoomFromQwt()
void RimSummaryPlot::updateZoomFromParentPlot()
{
if ( !m_plotWidget ) return;
if ( !plotWidget() ) return;
QwtInterval leftAxis = m_plotWidget->axisRange( QwtPlot::yLeft );
QwtInterval rightAxis = m_plotWidget->axisRange( QwtPlot::yRight );
QwtInterval timeAxis = m_plotWidget->axisRange( QwtPlot::xBottom );
auto [leftAxisMin, leftAxisMax] = plotWidget()->axisRange( RiaDefines::PlotAxis::PLOT_AXIS_LEFT );
auto [rightAxisMin, rightAxisMax] = plotWidget()->axisRange( RiaDefines::PlotAxis::PLOT_AXIS_RIGHT );
auto [timeAxisMin, timeAxisMax] = plotWidget()->axisRange( RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM );
m_leftYAxisProperties->visibleRangeMax = leftAxis.maxValue();
m_leftYAxisProperties->visibleRangeMin = leftAxis.minValue();
m_leftYAxisProperties->visibleRangeMax = leftAxisMax;
m_leftYAxisProperties->visibleRangeMin = leftAxisMin;
m_leftYAxisProperties->updateConnectedEditors();
m_rightYAxisProperties->visibleRangeMax = rightAxis.maxValue();
m_rightYAxisProperties->visibleRangeMin = rightAxis.minValue();
m_rightYAxisProperties->visibleRangeMax = rightAxisMax;
m_rightYAxisProperties->visibleRangeMin = rightAxisMin;
m_rightYAxisProperties->updateConnectedEditors();
if ( m_isCrossPlot )
{
m_bottomAxisProperties->visibleRangeMax = timeAxis.maxValue();
m_bottomAxisProperties->visibleRangeMin = timeAxis.minValue();
m_bottomAxisProperties->visibleRangeMax = timeAxisMax;
m_bottomAxisProperties->visibleRangeMin = timeAxisMin;
m_bottomAxisProperties->updateConnectedEditors();
}
else
{
m_timeAxisProperties->setVisibleRangeMin( timeAxis.minValue() );
m_timeAxisProperties->setVisibleRangeMax( timeAxis.maxValue() );
m_timeAxisProperties->setVisibleRangeMin( timeAxisMin );
m_timeAxisProperties->setVisibleRangeMax( timeAxisMax );
m_timeAxisProperties->updateConnectedEditors();
}
}
@@ -1772,13 +1770,19 @@ std::set<RimPlotAxisPropertiesInterface*> RimSummaryPlot::allPlotAxes() const
//--------------------------------------------------------------------------------------------------
void RimSummaryPlot::cleanupBeforeClose()
{
detachAllPlotItems();
if ( m_plotWidget )
if ( isDeletable() )
{
m_plotWidget->setParent( nullptr );
delete m_plotWidget;
m_plotWidget = nullptr;
detachAllPlotItems();
if ( plotWidget() )
{
plotWidget()->setParent( nullptr );
}
if ( m_summaryPlot )
{
m_summaryPlot.reset();
}
}
}
@@ -1827,9 +1831,9 @@ void RimSummaryPlot::curveVisibilityChanged( const caf::SignalEmitter* emitter,
//--------------------------------------------------------------------------------------------------
void RimSummaryPlot::curveAppearanceChanged( const caf::SignalEmitter* emitter )
{
if ( m_plotWidget )
if ( plotWidget() )
{
m_plotWidget->scheduleReplot();
plotWidget()->scheduleReplot();
}
}
@@ -1929,7 +1933,7 @@ void RimSummaryPlot::onPlotZoomed()
{
setAutoScaleXEnabled( false );
setAutoScaleYEnabled( false );
updateZoomFromQwt();
updateZoomFromParentPlot();
}
//--------------------------------------------------------------------------------------------------
@@ -1944,7 +1948,9 @@ void RimSummaryPlot::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering&
caf::PdmUiGroup* mainOptions = uiOrdering.addNewGroup( "General Plot Options" );
mainOptions->setCollapsedByDefault( true );
#ifdef USE_QTCHARTS
mainOptions->add( &m_useQtChartsPlot );
#endif
if ( isMdiWindow() )
{
mainOptions->add( &m_showPlotTitle );
@@ -1976,38 +1982,49 @@ void RimSummaryPlot::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering&
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuQwtPlotWidget* RimSummaryPlot::doCreatePlotViewWidget( QWidget* mainWindowParent )
RiuPlotWidget* RimSummaryPlot::doCreatePlotViewWidget( QWidget* mainWindowParent )
{
if ( !m_plotWidget )
if ( !plotWidget() )
{
m_plotWidget = new RiuSummaryQwtPlot( this, mainWindowParent );
#ifdef USE_QTCHARTS
if ( m_useQtChartsPlot )
{
m_summaryPlot = std::make_unique<RiuSummaryQtChartsPlot>( this, mainWindowParent );
}
else
{
m_summaryPlot = std::make_unique<RiuSummaryQwtPlot>( this, mainWindowParent );
}
#else
m_summaryPlot = std::make_unique<RiuSummaryQwtPlot>( this, mainWindowParent );
#endif
for ( RimGridTimeHistoryCurve* curve : m_gridTimeHistoryCurves )
{
curve->setParentQwtPlotNoReplot( m_plotWidget );
curve->setParentPlotNoReplot( plotWidget() );
}
for ( RimAsciiDataCurve* curve : m_asciiDataCurves )
{
curve->setParentQwtPlotNoReplot( m_plotWidget );
curve->setParentPlotNoReplot( plotWidget() );
}
if ( m_summaryCurveCollection )
{
m_summaryCurveCollection->setParentQwtPlotAndReplot( m_plotWidget );
m_summaryCurveCollection->setParentPlotAndReplot( plotWidget() );
}
if ( m_ensembleCurveSetCollection )
{
m_ensembleCurveSetCollection->setParentQwtPlotAndReplot( m_plotWidget );
m_ensembleCurveSetCollection->setParentPlotAndReplot( plotWidget() );
}
this->connect( m_plotWidget, SIGNAL( plotZoomed() ), SLOT( onPlotZoomed() ) );
this->connect( plotWidget(), SIGNAL( plotZoomed() ), SLOT( onPlotZoomed() ) );
updatePlotTitle();
}
return m_plotWidget;
return plotWidget();
}
//--------------------------------------------------------------------------------------------------
@@ -2102,19 +2119,22 @@ void RimSummaryPlot::detachAllPlotItems()
{
if ( m_summaryCurveCollection )
{
m_summaryCurveCollection->detachQwtCurves();
m_summaryCurveCollection->detachPlotCurves();
}
m_ensembleCurveSetCollection->detachQwtCurves();
if ( m_ensembleCurveSetCollection )
{
m_ensembleCurveSetCollection->detachPlotCurves();
}
for ( RimGridTimeHistoryCurve* curve : m_gridTimeHistoryCurves )
{
curve->detachQwtCurve();
curve->detach();
}
for ( RimAsciiDataCurve* curve : m_asciiDataCurves )
{
curve->detachQwtCurve();
curve->detach();
}
m_plotInfoLabel->detach();
@@ -2154,19 +2174,19 @@ void RimSummaryPlot::reattachAllCurves()
{
if ( m_summaryCurveCollection )
{
m_summaryCurveCollection->reattachQwtCurves();
m_summaryCurveCollection->reattachPlotCurves();
}
m_ensembleCurveSetCollection->reattachQwtCurves();
m_ensembleCurveSetCollection->reattachPlotCurves();
for ( RimGridTimeHistoryCurve* curve : m_gridTimeHistoryCurves )
{
curve->reattachQwtCurve();
curve->reattach();
}
for ( RimAsciiDataCurve* curve : m_asciiDataCurves )
{
curve->reattachQwtCurve();
curve->reattach();
}
}

View File

@@ -18,7 +18,7 @@
#pragma once
#include "RiaDefines.h"
#include "RiaPlotDefines.h"
#include "RiaQDateTimeTools.h"
#include "RifEclipseSummaryAddress.h"
@@ -26,7 +26,8 @@
#include "RimPlot.h"
#include "RimSummaryDataSourceStepping.h"
#include "qwt_plot_textlabel.h"
#include "RiuQwtPlotWidget.h"
#include "RiuSummaryPlot.h"
#include "cafPdmChildArrayField.h"
#include "cafPdmPtrArrayField.h"
@@ -59,6 +60,7 @@ class RiaSummaryCurveDefinition;
class QwtInterval;
class QwtPlotCurve;
class QwtPlotTextLabel;
class QKeyEvent;
@@ -120,8 +122,7 @@ public:
RimSummaryTimeAxisProperties* timeAxisProperties();
time_t firstTimeStepOfFirstCurve();
QWidget* viewWidget() override;
RiuQwtPlotWidget* viewer() override;
QWidget* viewWidget() override;
QString asciiDataForPlotExport() const override;
QString asciiDataForSummaryPlotExport( RiaQDateTimeTools::DateTimePeriod resamplingPeriod,
@@ -160,14 +161,14 @@ public:
virtual RimSummaryPlotSourceStepping* sourceSteppingObjectForKeyEventHandling() const;
virtual std::vector<caf::PdmFieldHandle*> fieldsToShowInToolbar();
void setAutoScaleXEnabled( bool enabled ) override;
void setAutoScaleYEnabled( bool enabled ) override;
void setAutoScaleXEnabled( bool enabled ) override;
void setAutoScaleYEnabled( bool enabled ) override;
RiuPlotWidget* plotWidget() override;
void zoomAll() override;
void updateZoomInParentPlot() override;
void updateZoomFromParentPlot() override;
void zoomAll() override;
void updateZoomInQwt() override;
void updateZoomFromQwt() override;
caf::PdmObject* findPdmObjectFromQwtCurve( const QwtPlotCurve* curve ) const override;
caf::PdmObject* findPdmObjectFromPlotCurve( const RiuPlotCurve* curve ) const override;
void onAxisSelected( int axis, bool toggle ) override;
@@ -192,7 +193,7 @@ public:
bool isDeletable() const override;
private:
RiuQwtPlotWidget* doCreatePlotViewWidget( QWidget* mainWindowParent = nullptr ) override;
RiuPlotWidget* doCreatePlotViewWidget( QWidget* mainWindowParent = nullptr ) override;
void updateNameHelperWithCurveData( RimSummaryPlotNameHelper* nameHelper ) const;
@@ -256,6 +257,9 @@ private:
void axisLogarithmicChanged( const caf::SignalEmitter* emitter, bool isLogarithmic );
private:
#ifdef USE_QTCHARTS
caf::PdmField<bool> m_useQtChartsPlot;
#endif
caf::PdmField<bool> m_normalizeCurveYValues;
caf::PdmField<bool> m_useAutoPlotTitle;
@@ -275,7 +279,7 @@ private:
caf::PdmChildField<RimSummaryPlotFilterTextCurveSetEditor*> m_textCurveSetEditor;
QPointer<RiuSummaryQwtPlot> m_plotWidget;
std::unique_ptr<RiuSummaryPlot> m_summaryPlot;
std::unique_ptr<QwtPlotTextLabel> m_plotInfoLabel;
bool m_isCrossPlot;

View File

@@ -19,6 +19,7 @@
#include "RimSummaryPlotAxisFormatter.h"
#include "RiaDefines.h"
#include "RiaNumberFormat.h"
#include "RiaSummaryCurveDefinition.h"
#include "RifSummaryReaderInterface.h"
@@ -29,13 +30,15 @@
#include "RimSummaryCaseCollection.h"
#include "RimSummaryCurve.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_scale_engine.h"
#include <cmath>
#include <set>
@@ -111,10 +114,11 @@ RimSummaryPlotAxisFormatter::RimSummaryPlotAxisFormatter( RimPlotAxisProperties*
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSummaryPlotAxisFormatter::applyAxisPropertiesToPlot( RiuQwtPlotWidget* qwtPlot )
void RimSummaryPlotAxisFormatter::applyAxisPropertiesToPlot( RiuPlotWidget* plotWidget )
{
if ( !qwtPlot ) return;
if ( !plotWidget ) return;
RiaDefines::PlotAxis axis = m_axisProperties->plotAxisType();
{
QString axisTitle = m_axisProperties->customTitle;
if ( m_axisProperties->useAutoTitle() ) axisTitle = autoAxisTitle();
@@ -124,51 +128,72 @@ void RimSummaryPlotAxisFormatter::applyAxisPropertiesToPlot( RiuQwtPlotWidget* q
{
titleAlignment = Qt::AlignRight;
}
qwtPlot->setAxisTitleText( m_axisProperties->qwtPlotAxisType(), axisTitle );
qwtPlot->setAxisFontsAndAlignment( m_axisProperties->qwtPlotAxisType(),
m_axisProperties->titleFontSize(),
m_axisProperties->valuesFontSize(),
true,
titleAlignment );
qwtPlot->setAxisTitleEnabled( m_axisProperties->qwtPlotAxisType(), true );
plotWidget->setAxisTitleText( axis, axisTitle );
plotWidget->setAxisFontsAndAlignment( axis,
m_axisProperties->titleFontSize(),
m_axisProperties->valuesFontSize(),
true,
titleAlignment );
plotWidget->setAxisTitleEnabled( axis, true );
}
auto qwtPlotWidget = dynamic_cast<RiuQwtPlotWidget*>( plotWidget );
if ( qwtPlotWidget )
{
QwtPlot::Axis qwtAxisId = RiuQwtPlotTools::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
qwtPlot->setAxisScaleDraw( m_axisProperties->qwtPlotAxisType(), new QwtScaleDraw );
qwtPlotWidget->qwtPlot()->setAxisScaleDraw( qwtAxisId, new QwtScaleDraw );
}
else
{
qwtPlot->setAxisScaleDraw( m_axisProperties->qwtPlotAxisType(),
new SummaryScaleDraw( m_axisProperties->scaleFactor(),
m_axisProperties->numberOfDecimals(),
m_axisProperties->numberFormat() ) );
qwtPlotWidget->qwtPlot()->setAxisScaleDraw( qwtAxisId,
new SummaryScaleDraw( m_axisProperties->scaleFactor(),
m_axisProperties->numberOfDecimals(),
m_axisProperties->numberFormat() ) );
}
}
#ifdef USE_QTCHARTS
auto qtChartsPlotWidget = dynamic_cast<RiuQtChartsPlotWidget*>( plotWidget );
if ( qtChartsPlotWidget )
{
auto mapToRiaNumberFormatType = []( RimPlotAxisProperties::NumberFormatType formatType ) {
if ( formatType == RimPlotAxisProperties::NumberFormatType::NUMBER_FORMAT_DECIMAL )
return RiaNumberFormat::NumberFormatType::FIXED;
if ( formatType == RimPlotAxisProperties::NumberFormatType::NUMBER_FORMAT_SCIENTIFIC )
return RiaNumberFormat::NumberFormatType::SCIENTIFIC;
return RiaNumberFormat::NumberFormatType::AUTO;
};
auto formatType = mapToRiaNumberFormatType( m_axisProperties->numberFormat() );
QString format = RiaNumberFormat::sprintfFormat( formatType, m_axisProperties->numberOfDecimals() );
qtChartsPlotWidget->setAxisFormat( axis, format );
}
#endif
{
if ( m_axisProperties->isLogarithmicScaleEnabled )
{
QwtLogScaleEngine* currentScaleEngine =
dynamic_cast<QwtLogScaleEngine*>( qwtPlot->axisScaleEngine( m_axisProperties->qwtPlotAxisType() ) );
if ( !currentScaleEngine )
bool isLogScale = plotWidget->axisScaleType( axis ) == RiuQwtPlotWidget::AxisScaleType::LOGARITHMIC;
if ( !isLogScale )
{
qwtPlot->setAxisScaleEngine( m_axisProperties->qwtPlotAxisType(), new QwtLogScaleEngine );
qwtPlot->setAxisMaxMinor( m_axisProperties->qwtPlotAxisType(), 5 );
plotWidget->setAxisScaleType( axis, RiuQwtPlotWidget::AxisScaleType::LOGARITHMIC );
plotWidget->setAxisMaxMinor( axis, 5 );
}
}
else
{
QwtLinearScaleEngine* currentScaleEngine =
dynamic_cast<QwtLinearScaleEngine*>( qwtPlot->axisScaleEngine( m_axisProperties->qwtPlotAxisType() ) );
QwtDateScaleEngine* dateScaleEngine = dynamic_cast<QwtDateScaleEngine*>( currentScaleEngine );
if ( !currentScaleEngine || dateScaleEngine )
bool isLinearScale = plotWidget->axisScaleType( axis ) == RiuQwtPlotWidget::AxisScaleType::LINEAR;
if ( !isLinearScale )
{
qwtPlot->setAxisScaleEngine( m_axisProperties->qwtPlotAxisType(), new QwtLinearScaleEngine );
qwtPlot->setAxisMaxMinor( m_axisProperties->qwtPlotAxisType(), 3 );
plotWidget->setAxisScaleType( axis, RiuQwtPlotWidget::AxisScaleType::LINEAR );
plotWidget->setAxisMaxMinor( axis, 3 );
}
}
}

View File

@@ -22,16 +22,12 @@
#include <set>
#include <vector>
#include <qwt_plot.h>
class RimAsciiDataCurve;
class RimSummaryCurve;
class RimPlotAxisProperties;
class RiaSummaryCurveDefinition;
class RiuQwtPlotWidget;
class QwtPlotCurve;
class RiuPlotWidget;
class RimSummaryPlotAxisFormatter
{
@@ -42,7 +38,7 @@ public:
const std::vector<RimAsciiDataCurve*>& asciiCurves,
const std::set<QString>& timeHistoryCurveQuantities );
void applyAxisPropertiesToPlot( RiuQwtPlotWidget* qwtPlot );
void applyAxisPropertiesToPlot( RiuPlotWidget* qwtPlot );
private:
QString autoAxisTitle() const;