Remove pure virtual from RimPlotCurve

Make it possible to use RimPlotCurve directly. Remove depnendencies on special implementation in derived classes.
This commit is contained in:
Magne Sjaastad
2024-05-13 08:34:27 +02:00
parent 2ad6c0fff2
commit b8391e6f92
13 changed files with 135 additions and 89 deletions

View File

@@ -20,10 +20,6 @@
#include "RiaSummaryDefines.h"
#include "RimProject.h"
#include "RimSummaryCalculation.h"
#include "RimSummaryCalculationCollection.h"
#include <QRegularExpression>
namespace caf

View File

@@ -25,8 +25,8 @@
#include "cafPdmPtrField.h"
#include "RiaDefines.h"
#include "RifEclipseSummaryAddressQMetaType.h"
#include "RimPlotCurve.h"
#include "cafAppEnum.h"

View File

@@ -1389,3 +1389,62 @@ void RimSummaryCurve::calculateCurveInterpolationFromAddress()
void RimSummaryCurve::updateTimeAnnotations()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSummaryCurve::updateLegendEntryVisibilityNoPlotUpdate()
{
if ( !m_plotCurve ) return;
auto ensembleCurveSet = firstAncestorOrThisOfType<RimEnsembleCurveSet>();
if ( ensembleCurveSet )
{
return;
}
bool showLegendInPlot = m_showLegend();
auto summaryPlot = firstAncestorOrThisOfType<RimSummaryPlot>();
if ( summaryPlot )
{
bool anyCalculated = false;
for ( const auto c : summaryPlot->summaryCurves() )
{
if ( c->summaryAddressY().isCalculated() )
{
// Never hide the legend for calculated curves, as the curve legend is used to
// show some essential auto generated data
anyCalculated = true;
}
}
auto isMultiPlot = ( firstAncestorOrThisOfType<RimMultiPlot>() != nullptr );
if ( !anyCalculated && isMultiPlot && summaryPlot->ensembleCurveSetCollection()->curveSets().empty() && summaryPlot->curveCount() == 1 )
{
// Disable display of legend if the summary plot has only one single curve
showLegendInPlot = false;
}
}
m_plotCurve->setVisibleInLegend( showLegendInPlot );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimSummaryCurve::canCurveBeAttached() const
{
if ( !RimPlotCurve::canCurveBeAttached() ) return false;
bool isVisibleInPossibleParent = true;
auto summaryCurveCollection = firstAncestorOrThisOfType<RimSummaryCurveCollection>();
if ( summaryCurveCollection ) isVisibleInPossibleParent = summaryCurveCollection->isCurvesVisible();
auto ensembleCurveSet = firstAncestorOrThisOfType<RimEnsembleCurveSet>();
if ( ensembleCurveSet ) isVisibleInPossibleParent = ensembleCurveSet->isCurvesVisible();
return isVisibleInPossibleParent;
}

View File

@@ -106,6 +106,7 @@ public:
RiaDefines::PhaseType phaseType() const override;
virtual bool isRegressionCurve() const;
void updateLegendEntryVisibilityNoPlotUpdate() override;
protected:
// RimPlotCurve overrides
@@ -124,6 +125,7 @@ protected:
virtual std::vector<time_t> timeStepsX() const;
virtual void updateTimeAnnotations();
bool canCurveBeAttached() const override;
// Overridden PDM methods
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;