///////////////////////////////////////////////////////////////////////////////// // // 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 "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; 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 ); // The global appearance applies to all summary plots in the project bool useGlobalAppearance() const; void setUseGlobalAppearance( bool enable ); 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; public: enum class AppearanceType { COLOR, SYMBOL }; private: void assignedAppearance( 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; QString currentItemName() const; bool updateSelectedItem(); // 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 applyGlobalAppearanceMode(); void saveAppearance( RimSummaryPlot* plot ); void restoreAppearances(); // The curve appearance before the global appearance was enabled, restored when disabled caf::PdmChildArrayField m_savedAppearances; caf::PdmField m_useGlobalAppearance; 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::PdmField m_currentItemIndex; // Edited in the dock window for the selected item. Not stored, custom settings are copied to a rule in m_rules. caf::PdmChildField m_selectedItem; };