///////////////////////////////////////////////////////////////////////////////// // // 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 "RimCurveStyleRule.h" #include "RimPlotCurveAppearance.h" #include "RimSavedCurveAppearance.h" #include "cafPdmChildArrayField.h" #include "cafPdmChildField.h" #include "cafPdmField.h" #include "cafPdmObject.h" #include "cafPdmProxyValueField.h" #include "cafPdmPtrField.h" #include "cafPdmUiTreeAttributes.h" #include "cvfColor3.h" #include #include #include #include class RimColorLegend; class RimEnsembleCurveSet; class RimPlotCurve; class RimSummaryPlot; class RifEclipseSummaryAddress; //================================================================================================== /// Project-stored list of per-item style rules for the global curve appearance. //================================================================================================== class RimCurveStyleRules : public caf::PdmObject { CAF_PDM_HEADER_INIT; public: RimCurveStyleRules(); std::vector rules() const; RimCurveStyleRule* findOrCreateRule( RimCurveStyleRule::Dimension dimension, const QString& name ); // Custom rules for the dimensions selected for color or symbol, ordered so that later entries win: by dimension std::vector rulesFor( const RifEclipseSummaryAddress& address, const std::string& caseName ) const; RimCurveStyleSettings* settings() const; // Re-applies the global appearance to all plots using it void rulesChanged(); // Stores custom settings edited for the selected item, and re-applies the global appearance void ruleChanged( RimCurveStyleRule* rule ); // Whether the global appearance assigns the color or symbol of a curve with the given address and case bool controlsColor( const RifEclipseSummaryAddress& address, const std::string& caseName ) const; // Whether the curve belongs to an item checked as highlighted for the color or symbol dimension bool isHighlighted( const RifEclipseSummaryAddress& address, const std::string& caseName ) const; bool controlsSymbol( const RifEclipseSummaryAddress& address, const std::string& caseName ) const; // Index used to pick the palette color and symbol for a case or well name. Indices are kept in the project so that // existing items keep their appearance when new cases or wells are added. // Names not yet registered get the indices they would get if registered now. void registerItemNames( RimCurveStyleRule::Dimension dimension, const QStringList& names ); std::map itemIndices( RimCurveStyleRule::Dimension dimension ) const; // Color from the project color legend used for auto colors, if one is selected std::optional autoLegendColor( int index ) const; // Configures a field as a label with a link that shows the global curve appearance static void addGlobalAppearanceLink( caf::PdmUiOrdering& uiOrdering, const QString& text ); // Global appearance is selected per summary multi plot bool isGlobalColorUsed() const; bool isGlobalSymbolUsed() const; // Tags for the data source tree showing the global color and symbol assigned to an item std::vector curveStyleRuleTags( RimCurveStyleRule::Dimension dimension, const QString& name ) const; void applyGlobalAppearance( const std::vector& plots ); protected: QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; void initAfterRead() override; public: enum class AppearanceType { COLOR, SYMBOL }; private: void assignedAppearance( RimCurveStyleRule::Dimension dimension, const QString& name, int index, const std::map& plotAppearances, std::optional& color, std::optional& symbol ) const; RimCurveStyleRule* findRule( RimCurveStyleRule::Dimension dimension, const QString& name ) const; void setUpBaseStyles(); // The names of the highlighted items for the current dimension, as edited with checkboxes std::vector highlightedItems() const; void setHighlightedItems( const std::vector& names ); int symbolSize() const; void setSymbolSize( const int& size ); void connectAllPlots( bool connect ); void updateSummaryCaseTags(); // The dimension controlling the selected appearance type, as stored in the global settings caf::AppEnum currentDimension() const; void setCurrentDimension( const caf::AppEnum& dimension ); caf::PdmField>* itemOrder( RimCurveStyleRule::Dimension dimension ); const caf::PdmField>* itemOrder( RimCurveStyleRule::Dimension dimension ) const; void saveAppearance( RimSummaryPlot* plot ); void restoreAppearances( const std::vector& plots, bool applyDefaultsToUnsaved ); // The curve appearance before the global appearance was enabled, restored when disabled caf::PdmChildArrayField m_savedAppearances; caf::PdmChildField m_settings; caf::PdmChildArrayField m_rules; caf::PdmField> m_caseOrder; caf::PdmField> m_wellOrder; caf::PdmField> m_appearanceType; caf::PdmProxyValueField> m_currentType; caf::PdmPtrField m_autoColorLegend; caf::PdmField m_symbolLegend; caf::PdmProxyValueField> m_highlightedItems; caf::PdmProxyValueField m_symbolSize; // The style shared by all items controlled by color, and the symbol size shared by all items controlled by symbol caf::PdmChildField m_colorBaseStyle; caf::PdmChildField m_symbolBaseStyle; // Colors and symbols shown as tags in the data source tree, built on demand and cleared when the rules change struct TagAppearance { std::optional color; std::optional symbol; }; mutable std::map> m_tagCache; };