From 077351cd04a18cf42ace10c0859aea092c060f95 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 9 Sep 2016 11:46:49 +0200 Subject: [PATCH] #272 Use combo box to switch between predefined and custom cell edge result --- .../ProjectDataModel/RimCellEdgeColors.cpp | 21 +++++++++++++++---- .../ProjectDataModel/RimCellEdgeColors.h | 7 +++++++ 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimCellEdgeColors.cpp b/ApplicationCode/ProjectDataModel/RimCellEdgeColors.cpp index 8c71417b2c..22ddf98b02 100644 --- a/ApplicationCode/ProjectDataModel/RimCellEdgeColors.cpp +++ b/ApplicationCode/ProjectDataModel/RimCellEdgeColors.cpp @@ -32,6 +32,17 @@ #include "cvfMath.h" +namespace caf +{ + template<> + void AppEnum< RimCellEdgeColors::ResultType >::setUp() + { + addItem(RimCellEdgeColors::PREDEFINED_RESULT, "PREDEFINED_RESULT", "Predefined"); + addItem(RimCellEdgeColors::CUSTOM_RESULT, "CUSTOM_RESULT", "Custom"); + setDefault(RimCellEdgeColors::PREDEFINED_RESULT); + } +} + CAF_PDM_SOURCE_INIT(RimCellEdgeColors, "CellEdgeResultSlot"); @@ -44,6 +55,8 @@ RimCellEdgeColors::RimCellEdgeColors() CAF_PDM_InitField(&enableCellEdgeColors, "EnableCellEdgeColors", true, "Enable cell edge results", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_resultType, "resultType", "Result mapping", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_resultVariable, "CellEdgeVariable", "Result property", "", "", ""); CAF_PDM_InitField(&useXVariable, "UseXVariable", true, "Use X values", "", "", ""); CAF_PDM_InitField(&useYVariable, "UseYVariable", true, "Use Y values", "", "", ""); @@ -235,8 +248,6 @@ QList RimCellEdgeColors::calculateValueOptions(const caf optionList.push_front(caf::PdmOptionItemInfo(RimDefines::undefinedResultName(), "")); - optionList.push_back(caf::PdmOptionItemInfo(RimCellEdgeColors::singleVarEdgeResultUiText(), RimCellEdgeColors::singleVarEdgeResultUiText())); - if (useOptionsOnly) *useOptionsOnly = true; return optionList; @@ -251,7 +262,7 @@ QList RimCellEdgeColors::calculateValueOptions(const caf //-------------------------------------------------------------------------------------------------- void RimCellEdgeColors::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) { - uiOrdering.add(&m_resultVariable); + uiOrdering.add(&m_resultType); if (isUsingSingleVariable()) { @@ -262,6 +273,8 @@ void RimCellEdgeColors::defineUiOrdering(QString uiConfigName, caf::PdmUiOrderin } else { + uiOrdering.add(&m_resultVariable); + uiOrdering.add(&useXVariable); uiOrdering.add(&useYVariable); uiOrdering.add(&useZVariable); @@ -340,7 +353,7 @@ void RimCellEdgeColors::gridScalarResultNames(std::vector* resultNames) //-------------------------------------------------------------------------------------------------- bool RimCellEdgeColors::isUsingSingleVariable() const { - return (m_resultVariable == singleVarEdgeResultUiText()); + return (m_resultType == CUSTOM_RESULT); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimCellEdgeColors.h b/ApplicationCode/ProjectDataModel/RimCellEdgeColors.h index fc53ce950d..05a690046d 100644 --- a/ApplicationCode/ProjectDataModel/RimCellEdgeColors.h +++ b/ApplicationCode/ProjectDataModel/RimCellEdgeColors.h @@ -60,6 +60,12 @@ public: Z, NEG_Z }; + enum ResultType + { + PREDEFINED_RESULT, + CUSTOM_RESULT + }; + typedef caf::AppEnum EdgeFaceEnum; void setReservoirView(RimEclipseView* ownerReservoirView); @@ -114,6 +120,7 @@ private: bool isUsingSingleVariable() const; static QString singleVarEdgeResultUiText() { return "Custom Edge Result"; } + caf::PdmField > m_resultType; caf::PdmChildField m_legendConfig; caf::PdmChildField m_singleVarEdgeResultColors;