From db384ea75410c03354672a50440e1dc3569cb1af Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Wed, 6 May 2020 22:30:51 +0200 Subject: [PATCH] Add getters for RimColorLegend++. --- .../ProjectDataModel/RimColorLegend.cpp | 8 +++++++ .../ProjectDataModel/RimColorLegend.h | 2 ++ .../RimColorLegendCollection.cpp | 8 +++++++ .../RimColorLegendCollection.h | 3 ++- .../ProjectDataModel/RimColorLegendItem.cpp | 24 +++++++++++++++++++ .../ProjectDataModel/RimColorLegendItem.h | 5 +++- 6 files changed, 48 insertions(+), 2 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimColorLegend.cpp b/ApplicationCode/ProjectDataModel/RimColorLegend.cpp index 519b39a948..ac6bb9379b 100644 --- a/ApplicationCode/ProjectDataModel/RimColorLegend.cpp +++ b/ApplicationCode/ProjectDataModel/RimColorLegend.cpp @@ -65,6 +65,14 @@ void RimColorLegend::appendColorLegendItem( RimColorLegendItem* colorLegendItem m_colorLegendItems.push_back( colorLegendItem ); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimColorLegend::colorLegendItems() const +{ + return m_colorLegendItems.childObjects(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimColorLegend.h b/ApplicationCode/ProjectDataModel/RimColorLegend.h index 97407b0e4d..bc33849ce9 100644 --- a/ApplicationCode/ProjectDataModel/RimColorLegend.h +++ b/ApplicationCode/ProjectDataModel/RimColorLegend.h @@ -45,6 +45,8 @@ public: void setColorLegendName( const QString& colorLegendName ); void appendColorLegendItem( RimColorLegendItem* colorLegendItem ); + std::vector colorLegendItems() const; + public: caf::PdmFieldHandle* userDescriptionField() override; diff --git a/ApplicationCode/ProjectDataModel/RimColorLegendCollection.cpp b/ApplicationCode/ProjectDataModel/RimColorLegendCollection.cpp index 0f4412ee07..d0bcb0915d 100644 --- a/ApplicationCode/ProjectDataModel/RimColorLegendCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimColorLegendCollection.cpp @@ -47,6 +47,14 @@ void RimColorLegendCollection::appendColorLegend( RimColorLegend* colorLegend ) m_colorLegends.push_back( colorLegend ); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimColorLegendCollection::colorLegends() const +{ + return m_colorLegends.childObjects(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimColorLegendCollection.h b/ApplicationCode/ProjectDataModel/RimColorLegendCollection.h index 694a1f92ec..62d33c46b3 100644 --- a/ApplicationCode/ProjectDataModel/RimColorLegendCollection.h +++ b/ApplicationCode/ProjectDataModel/RimColorLegendCollection.h @@ -41,9 +41,10 @@ public: RimColorLegendCollection(); ~RimColorLegendCollection() override; -public: void appendColorLegend( RimColorLegend* colorLegend ); + std::vector colorLegends() const; + void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; private: diff --git a/ApplicationCode/ProjectDataModel/RimColorLegendItem.cpp b/ApplicationCode/ProjectDataModel/RimColorLegendItem.cpp index 149b3494b0..a10cc0cd93 100644 --- a/ApplicationCode/ProjectDataModel/RimColorLegendItem.cpp +++ b/ApplicationCode/ProjectDataModel/RimColorLegendItem.cpp @@ -60,6 +60,30 @@ void RimColorLegendItem::setValues( const QString& categoryName, int categoryVal m_color = color; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const cvf::Color3f& RimColorLegendItem::color() const +{ + return m_color(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const QString& RimColorLegendItem::categoryName() const +{ + return m_categoryName(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int RimColorLegendItem::categoryValue() const +{ + return m_categoryValue(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimColorLegendItem.h b/ApplicationCode/ProjectDataModel/RimColorLegendItem.h index 806f285498..a2f145c4fa 100644 --- a/ApplicationCode/ProjectDataModel/RimColorLegendItem.h +++ b/ApplicationCode/ProjectDataModel/RimColorLegendItem.h @@ -41,7 +41,10 @@ public: RimColorLegendItem(); ~RimColorLegendItem() override; - void setValues( const QString& categoryName, int categoryValue, const cvf::Color3f& color ); + void setValues( const QString& categoryName, int categoryValue, const cvf::Color3f& color ); + const cvf::Color3f& color() const; + const QString& categoryName() const; + int categoryValue() const; public: void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;