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

@ -21,6 +21,8 @@
#include "RiaTextStringTools.h"
#include "RifCsvUserDataParser.h"
#include "RiuQwtSymbol.h"
#include "cafPdmUiItem.h"
#include "cafPdmUiTextEditor.h"

View File

@ -17,6 +17,7 @@
/////////////////////////////////////////////////////////////////////////////////
#include "RimPlotDataFilterItem.h"
#include "RiaCurveDataTools.h"
#include "RiaResultNames.h"
#include "RifSummaryReaderInterface.h"

View File

@ -42,6 +42,7 @@
#include "RiuPlotCurve.h"
#include "RiuPlotMainWindowTools.h"
#include "RiuQwtPlotCurve.h"
#include "RiuQwtSymbol.h"
#include "RiuSummaryQwtPlot.h"
#include "RiuSummaryVectorSelectionDialog.h"

View File

@ -32,6 +32,8 @@
#include "qwt_plot.h"
#include <QPen>
#include <cmath>
//==================================================================================================

View File

@ -23,32 +23,22 @@
#include "RiaGuiApplication.h"
#include "RiaPreferences.h"
#include "RimEnsembleCurveSet.h"
#include "RimEnsembleCurveSetCollection.h"
#include "RimMultiPlot.h"
#include "RimNameConfig.h"
#include "RimPlotRectAnnotation.h"
#include "RimPlotWindow.h"
#include "RimProject.h"
#include "RimSummaryCurve.h"
#include "RimSummaryCurveCollection.h"
#include "RimSummaryPlot.h"
#include "RiuGuiTheme.h"
#include "RiuPlotCurve.h"
#include "RiuPlotCurveSymbol.h"
#include "RiuPlotMainWindowTools.h"
#include "RiuPlotWidget.h"
#include "cafAssert.h"
#include "cafPdmUiColorEditor.h"
#include "cafPdmUiComboBoxEditor.h"
#include "cafPdmUiTreeAttributes.h"
#include "cafPdmUiTreeSelectionEditor.h"
#include <QPen>
// NB! Special macro for pure virtual class
CAF_PDM_XML_ABSTRACT_SOURCE_INIT( RimPlotCurve, "PlotCurve" );
CAF_PDM_SOURCE_INIT( RimPlotCurve, "PlotCurve" );
//--------------------------------------------------------------------------------------------------
///
@ -244,6 +234,14 @@ bool RimPlotCurve::isCurveNameTemplateSupported() const
return !supportedCurveNameVariables().isEmpty();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimPlotCurve::createCurveAutoName()
{
return "Default Curve Name";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -252,6 +250,24 @@ QStringList RimPlotCurve::supportedCurveNameVariables() const
return {};
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotCurve::updateZoomInParentPlot()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotCurve::onLoadDataAndUpdate( bool updateParentPlot )
{
if ( updateParentPlot && m_parentPlot )
{
m_parentPlot->scheduleReplot();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -549,17 +565,7 @@ bool RimPlotCurve::canCurveBeAttached() const
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;
return true;
}
//--------------------------------------------------------------------------------------------------
@ -893,38 +899,7 @@ void RimPlotCurve::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 );
m_plotCurve->setVisibleInLegend( m_showLegend() );
}
//--------------------------------------------------------------------------------------------------
@ -1238,6 +1213,14 @@ void RimPlotCurve::deletePlotCurve()
m_plotCurve = nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuPlotCurve* RimPlotCurve::plotCurve() const
{
return m_plotCurve;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -1286,3 +1269,16 @@ void RimPlotCurve::onColorTagClicked( const SignalEmitter* emitter, size_t index
m_curveAppearance->setColorWithFieldChanged( newColor );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotCurve::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{
caf::PdmUiGroup* appearanceGroup = uiOrdering.addNewGroup( "Appearance" );
RimPlotCurve::appearanceUiOrdering( *appearanceGroup );
caf::PdmUiGroup* nameGroup = uiOrdering.addNewGroup( "Curve Name" );
nameGroup->add( &m_curveName );
nameGroup->add( &m_showLegend );
uiOrdering.skipRemainingFields( true );
}

View File

@ -24,7 +24,6 @@
#include "RiuPlotAxis.h"
#include "RiuQwtPlotCurveDefines.h"
#include "RiuQwtSymbol.h"
#include "cafPdmChildArrayField.h"
#include "cafPdmChildField.h"
@ -34,7 +33,6 @@
#include "cafPdmPtrArrayField.h"
#include <QPointer>
#include <Qt>
class RiuPlotCurve;
class RiuPlotWidget;
@ -104,7 +102,7 @@ public:
virtual void updateCurveVisibility();
void updateLegendEntryVisibilityAndPlotLegend();
void updateLegendEntryVisibilityNoPlotUpdate();
virtual void updateLegendEntryVisibilityNoPlotUpdate();
virtual void replotParentPlot();
bool showInLegend() const;
@ -133,21 +131,22 @@ public:
void setParentPlotNoReplot( RiuPlotWidget* );
void setParentPlotAndReplot( RiuPlotWidget* );
void attach( RiuPlotWidget* );
void detach( bool deletePlotCurve = false );
void reattach();
bool isSameCurve( const RiuPlotCurve* plotCurve ) const;
void deletePlotCurve();
void attach( RiuPlotWidget* );
void detach( bool deletePlotCurve = false );
void reattach();
bool isSameCurve( const RiuPlotCurve* plotCurve ) const;
void deletePlotCurve();
RiuPlotCurve* plotCurve() const;
std::vector<RimPlotRectAnnotation*> rectAnnotations() const;
protected:
virtual QString createCurveAutoName() = 0;
virtual QString createCurveAutoName();
virtual QStringList supportedCurveNameVariables() const;
virtual void updateZoomInParentPlot() = 0;
virtual void onLoadDataAndUpdate( bool updateParentPlot ) = 0;
virtual void updateZoomInParentPlot();
virtual void onLoadDataAndUpdate( bool updateParentPlot );
void initAfterRead() override;
void updateCurvePresentation( bool updatePlotLegendAndTitle );
@ -181,7 +180,7 @@ protected:
void onCurveAppearanceChanged( const caf::SignalEmitter* emitter );
virtual void onFillColorChanged( const caf::SignalEmitter* emitter );
bool canCurveBeAttached() const;
virtual bool canCurveBeAttached() const;
virtual void clearErrorBars();
void checkAndApplyDefaultFillColor();
@ -192,6 +191,8 @@ protected:
void onColorTagClicked( const SignalEmitter* emitter, size_t index );
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
private:
bool isCurveNameTemplateSupported() const;

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;

View File

@ -37,6 +37,7 @@
#include "RiuQwtPlotTools.h"
#include "RiuQwtPlotWheelZoomer.h"
#include "RiuQwtPlotZoomer.h"
#include "RiuQwtSymbol.h"
#include "RiuWidgetDragger.h"
#include "cafCmdFeatureMenuBuilder.h"

View File

@ -23,29 +23,20 @@
#include "RiaPlotDefines.h"
#include "RimDepthTrackPlot.h"
#include "RimFishbones.h"
#include "RimFracture.h"
#include "RimFractureTemplate.h"
#include "RimPerforationInterval.h"
#include "RimWellLogPlot.h"
#include "RimWellLogTrack.h"
#include "RimWellPath.h"
#include "RimWellPathAttribute.h"
#include "RimWellPathAttributeCollection.h"
#include "RimWellPathValve.h"
#include "RigWellPath.h"
#include "RiuPlotAxis.h"
#include "RiuQwtPlotTools.h"
#include "RiuQwtSymbol.h"
#include "qwt_plot.h"
#include "qwt_plot_marker.h"
#include "qwt_plot_shapeitem.h"
#include "qwt_text.h"
#include <QBrush>
#include <Qt>
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -21,19 +21,13 @@
#include "RiaDefines.h"
#include "RiuQwtPlotItemGroup.h"
#include "RimPlotCurve.h"
#include "RimWellLogPlot.h"
#include "RimWellPathAttribute.h"
#include "RimWellPathComponentInterface.h"
#include "cafPdmBase.h"
#include "cafPdmObject.h"
#include "cafPdmPtrField.h"
#include "RiuPlotCurveSymbol.h"
#include "cvfColor4.h"
#include "cvfObject.h"
#include <QBrush>
#include <QString>
class RigWellLogCurveData;