///////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2026- Equinor 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 "RimCurveStyleSettings.h" #include "RimPlotCurveAppearance.h" #include "RiuPlotCurveSymbol.h" #include "cafAppEnum.h" #include "cafIconProvider.h" #include "cafPdmField.h" #include "cafPdmFieldCvfColor.h" #include "cafPdmObject.h" #include "cvfColor3.h" #include #include #include #include class RimPlotCurve; //================================================================================================== /// Project-stored curve appearance for one specific summary case, ensemble or well. The values are /// edited in the curve appearance dock window. //================================================================================================== class RimCurveStyleRule : public caf::PdmObject { CAF_PDM_HEADER_INIT; public: using Dimension = RimCurveStyleSettings::Dimension; enum class Mode { AUTO, CUSTOM }; RimCurveStyleRule(); Dimension dimension() const; QString itemName() const; void setDimension( Dimension dimension ); void setItemName( const QString& itemName ); void setCustom( bool isCustom ); // Copies the mode and appearance, not the item the rule applies to void copySettingsFrom( const RimCurveStyleRule& other ); // Applies the rule to the curve if it is custom. Color and symbol are only applied when requested void applyToCurve( RimPlotCurve* curve, bool applyColor, bool applySymbol ) const; static QStringList availableNames( Dimension dimension ); // Caches availableNames() while in scope, as finding them can require scanning all summary addresses class AvailableNamesCache { public: AvailableNamesCache(); ~AvailableNamesCache(); AvailableNamesCache( const AvailableNamesCache& ) = delete; AvailableNamesCache& operator=( const AvailableNamesCache& ) = delete; private: bool m_isOwner; }; struct PlotAppearance { std::optional color; std::optional symbol; }; // The appearance of the first curve for each item in plots using the global appearance static std::map appearancesFromPlots( Dimension dimension ); static caf::IconProvider swatchIcon( const cvf::Color3f& color ); static caf::IconProvider paletteIcon(); static caf::IconProvider symbolIcon(); static caf::IconProvider dimensionIcon( Dimension dimension ); // Dimension icon followed by color and/or symbol swatches, when given. The symbol is drawn with the color if present. static caf::IconProvider dimensionColorIcon( Dimension dimension, const std::optional& color, const std::optional& symbol = std::nullopt ); bool isCustom() const; // The custom symbol, if the rule is custom std::optional overriddenSymbol() const; // Base rules hold the style shared by all items, they are not tied to a specific item. The color base defines line // style and thickness for items controlled by color, the symbol base the symbol size. enum class BaseKind { NONE, COLOR, SYMBOL }; void setBaseKind( BaseKind kind ); // Adds the line style and thickness fields of the color base rule void appendBaseStyleToUiOrdering( caf::PdmUiOrdering& uiOrdering ); // The symbol base rule. Setting the size also sets a matching symbol skip distance int symbolSize() const; void setSymbolSize( int size ); // Highlighted items are highlighted in the plots bool isHighlighted() const; void setHighlighted( bool highlighted ); // The custom color, if the rule is custom std::optional overriddenColor() const; protected: void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; void initAfterRead() override; private: void setUpAppearance(); void onAppearanceChanged( const caf::SignalEmitter* emitter ); private: caf::PdmField> m_dimension; caf::PdmField m_itemName; caf::PdmField> m_mode; caf::PdmField m_highlighted; // Color, symbol, line and fill settings that can be overridden caf::PdmChildField m_curveAppearance; BaseKind m_baseKind = BaseKind::NONE; };