///////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2016- Statoil ASA // // ResInsight is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY // WARRANTY; without even the implied warranty of MERCHANTABILITY or // FITNESS FOR A PARTICULAR PURPOSE. // // See the GNU General Public License at // for more details. // ///////////////////////////////////////////////////////////////////////////////// #pragma once #include "RifEclipseSummaryAddress.h" #include "RimPlotCurveAppearance.h" #include "RiaCurveDataTools.h" #include "RiaPlotDefines.h" #include "RiuPlotAxis.h" #include "RiuQwtPlotCurveDefines.h" #include "RiuQwtSymbol.h" #include "cafPdmChildField.h" #include "cafPdmField.h" #include "cafPdmFieldCvfColor.h" #include "cafPdmObject.h" #include "cafPdmPtrArrayField.h" #include #include class RiuPlotCurve; class RiuPlotWidget; //================================================================================================== /// /// //================================================================================================== class RimPlotCurve : public caf::PdmObject { CAF_PDM_HEADER_INIT; public: caf::Signal<> appearanceChanged; caf::Signal visibilityChanged; caf::Signal<> dataChanged; caf::Signal nameChanged; public: RimPlotCurve(); ~RimPlotCurve() override; void loadDataAndUpdate( bool updateParentPlot ); void setColor( const cvf::Color3f& color ); cvf::Color3f color() const; void setLineStyle( RiuQwtPlotCurveDefines::LineStyleEnum lineStyle ); void setSymbol( RiuPlotCurveSymbol::PointSymbolEnum symbolStyle ); void setInterpolation( RiuQwtPlotCurveDefines::CurveInterpolationEnum ); RiuPlotCurveSymbol::PointSymbolEnum symbol(); int symbolSize() const; cvf::Color3f symbolEdgeColor() const; void setSymbolEdgeColor( const cvf::Color3f& edgeColor ); void setSymbolSkipDistance( float distance ); void setSymbolLabel( const QString& label ); void setSymbolLabelPosition( RiuPlotCurveSymbol::LabelPosition labelPosition ); void setSymbolSize( int sizeInPixels ); void setLineThickness( int thickness ); void resetAppearance(); Qt::BrushStyle fillStyle() const; void setFillStyle( Qt::BrushStyle brushStyle ); void setFillColor( const cvf::Color3f& fillColor ); bool isCurveVisible() const; void setCurveVisibility( bool visible ); void updateCurveName(); void updateCurveNameAndUpdatePlotLegendAndTitle(); void updateCurveNameNoLegendUpdate(); void setCurveNameTemplateText( const QString& templateText ); void setNamingMethod( RiaDefines::ObjectNamingMethod namingMethod ); QString curveName() const; virtual QString curveExportDescription( const RifEclipseSummaryAddress& address = RifEclipseSummaryAddress() ) const; virtual QString createCurveNameFromTemplate( const QString& templateText ); void setCustomName( const QString& customName ); void setLegendEntryText( const QString& legendEntryText ); virtual void updateCurveVisibility(); void updateLegendEntryVisibilityAndPlotLegend(); void updateLegendEntryVisibilityNoPlotUpdate(); virtual void replotParentPlot(); bool showInLegend() const; bool errorBarsVisible() const; void setShowInLegend( bool show ); virtual void setZOrder( double z ); void setErrorBarsVisible( bool isVisible ); virtual void updateCurveAppearance(); bool isCrossPlotCurve() const; virtual void updateUiIconFromPlotSymbol(); virtual bool hasParentPlot() const; void updateCurveAppearanceForFilesOlderThan_2021_06(); virtual bool xValueRange( double* minimumValue, double* maximumValue ) const; virtual bool yValueRange( double* minimumValue, double* maximumValue ) const; virtual void setTitle( const QString& title ); int dataSize() const; std::pair sample( int index ) const; virtual double closestYValueForX( double xValue ) const; std::vector additionalDataSources() const; void setParentPlotNoReplot( RiuPlotWidget* ); void setParentPlotAndReplot( RiuPlotWidget* ); void attach( RiuPlotWidget* ); void detach( bool deletePlotCurve = false ); void reattach(); bool isSameCurve( const RiuPlotCurve* plotCurve ) const; void deletePlotCurve(); protected: virtual QString createCurveAutoName() = 0; virtual QStringList supportedCurveNameVariables() const; virtual void updateZoomInParentPlot() = 0; virtual void onLoadDataAndUpdate( bool updateParentPlot ) = 0; void initAfterRead() override; void updateCurvePresentation( bool updatePlotLegendAndTitle ); void updateFieldUiState(); void updatePlotTitle(); virtual void updateLegendsInPlot(); void setSamplesFromXYErrorValues( const std::vector& xValues, const std::vector& yValues, const std::vector& errorValues, bool useLogarithmicScale, RiaCurveDataTools::ErrorAxis errorAxis = RiaCurveDataTools::ErrorAxis::ERROR_ALONG_Y_AXIS ); void setSamplesFromXYValues( const std::vector& xValues, const std::vector& yValues, bool useLogarithmicScale ); void setSamplesFromDatesAndYValues( const std::vector& dateTimes, const std::vector& yValues, bool useLogarithmicScale ); void setSamplesFromTimeTAndYValues( const std::vector& dateTimes, const std::vector& yValues, bool useLogarithmicScale ); virtual double computeCurveZValue(); void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; caf::PdmFieldHandle* objectToggleField() override; caf::PdmFieldHandle* userDescriptionField() override; QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void appearanceUiOrdering( caf::PdmUiOrdering& uiOrdering ); void curveNameUiOrdering( caf::PdmUiOrdering& uiOrdering ); void additionalDataSourcesUiOrdering( caf::PdmUiOrdering& uiOrdering ); void onCurveAppearanceChanged( const caf::SignalEmitter* emitter ); virtual void onFillColorChanged( const caf::SignalEmitter* emitter ); bool canCurveBeAttached() const; virtual void clearErrorBars(); void checkAndApplyDefaultFillColor(); virtual void updateAxisInPlot( RiuPlotAxis plotAxis ); private: bool isCurveNameTemplateSupported() const; protected: caf::PdmField m_showCurve; caf::PdmField m_curveName; caf::PdmField m_curveNameTemplateText; caf::PdmField> m_namingMethod; caf::PdmField m_legendEntryText; caf::PdmField m_showLegend; caf::PdmField m_showErrorBars; caf::PdmChildField m_curveAppearance; caf::PdmPtrArrayField m_additionalDataSources; QPointer m_parentPlot; RiuPlotCurve* m_plotCurve; caf::PdmField m_isUsingAutoName_OBSOLETE; caf::PdmField m_symbolLabel_OBSOLETE; caf::PdmField m_symbolSize_OBSOLETE; caf::PdmField m_curveColor_OBSOLETE; caf::PdmField m_curveThickness_OBSOLETE; caf::PdmField m_symbolSkipPixelDistance_OBSOLETE; caf::PdmField m_pointSymbol_OBSOLETE; caf::PdmField m_lineStyle_OBSOLETE; caf::PdmField m_fillStyle_OBSOLETE; caf::PdmField m_fillColor_OBSOLETE; caf::PdmField m_curveInterpolation_OBSOLETE; caf::PdmField m_symbolLabelPosition_OBSOLETE; caf::PdmField m_symbolEdgeColor_OBSOLETE; };