From 1e9e6d8541385a1e678d2b21f13d65fe49c62a8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Mon, 8 Aug 2016 15:33:20 +0200 Subject: [PATCH] #780 Cleanup and alignment --- .../RimCurveAppearanceCalculator.cpp | 79 ++++++---- .../RimCurveAppearanceCalculator.h | 142 +++++------------- 2 files changed, 85 insertions(+), 136 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimCurveAppearanceCalculator.cpp b/ApplicationCode/ProjectDataModel/RimCurveAppearanceCalculator.cpp index be86e37ac9..56474ef154 100644 --- a/ApplicationCode/ProjectDataModel/RimCurveAppearanceCalculator.cpp +++ b/ApplicationCode/ProjectDataModel/RimCurveAppearanceCalculator.cpp @@ -58,6 +58,22 @@ RimCurveLookCalculator::RimCurveLookCalculator(const std::setsummaryAddress().wellGroupName()]; int regAppearanceIdx = m_regToAppearanceIdxMap[curve->summaryAddress().regionNumber()]; - setOneCurveAppearance(m_caseAppearanceType, m_caseCount, caseAppearanceIdx, curve); - setOneCurveAppearance(m_varAppearanceType, m_variableCount, varAppearanceIdx, curve); - setOneCurveAppearance(m_wellAppearanceType, m_wellCount, welAppearanceIdx, curve); - setOneCurveAppearance(m_groupAppearanceType, m_groupCount, grpAppearanceIdx, curve); - setOneCurveAppearance(m_regionAppearanceType, m_regionCount, regAppearanceIdx, curve); + setOneCurveAppearance(m_caseAppearanceType, m_caseCount, caseAppearanceIdx, curve); + setOneCurveAppearance(m_varAppearanceType, m_variableCount, varAppearanceIdx, curve); + setOneCurveAppearance(m_wellAppearanceType, m_wellCount, welAppearanceIdx, curve); + setOneCurveAppearance(m_groupAppearanceType, m_groupCount, grpAppearanceIdx, curve); + setOneCurveAppearance(m_regionAppearanceType, m_regionCount, regAppearanceIdx, curve); curve->setColor(gradeColor(m_currentCurveBaseColor, m_currentCurveGradient)); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimCurveLookCalculator::setOneCurveAppearance(CurveAppearanceType appeaType, size_t totalCount, int appeaIdx, RimSummaryCurve* curve) +{ + switch(appeaType) + { + case NONE: + break; + case COLOR: + m_currentCurveBaseColor = cycledPaletteColor(appeaIdx); + break; + case GRADIENT: + m_currentCurveGradient = gradient(totalCount, appeaIdx); + break; + case LINE_STYLE: + curve->setLineStyle(cycledLineStyle(appeaIdx)); + break; + case SYMBOL: + curve->setSymbol(cycledSymbol(appeaIdx)); + break; + case LINE_THICKNESS: + curve->setLineThickness(cycledLineThickness(appeaIdx)); + break; + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -150,32 +193,6 @@ float RimCurveLookCalculator::gradient(size_t totalCount, int index) return darkLimit + (index * step); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimCurveLookCalculator::setOneCurveAppearance(CurveAppearanceType appeaType, size_t totalCount, int appeaIdx, RimSummaryCurve* curve) -{ - switch(appeaType) - { - case NONE: - break; - case COLOR: - m_currentCurveBaseColor = cycledPaletteColor(appeaIdx); - break; - case GRADIENT: - m_currentCurveGradient = gradient(totalCount, appeaIdx); - break; - case LINE_STYLE: - curve->setLineStyle(cycledLineStyle(appeaIdx)); - break; - case SYMBOL: - curve->setSymbol(cycledSymbol(appeaIdx)); - break; - case LINE_THICKNESS: - curve->setLineThickness(cycledLineThickness(appeaIdx)); - break; - } -} //-------------------------------------------------------------------------------------------------- /// diff --git a/ApplicationCode/ProjectDataModel/RimCurveAppearanceCalculator.h b/ApplicationCode/ProjectDataModel/RimCurveAppearanceCalculator.h index 60dc38d9d1..6c81064d33 100644 --- a/ApplicationCode/ProjectDataModel/RimCurveAppearanceCalculator.h +++ b/ApplicationCode/ProjectDataModel/RimCurveAppearanceCalculator.h @@ -27,127 +27,59 @@ class RimSummaryCase; class RimCurveLookCalculator { public: -#if 0 - RimCurveLookCalculator(const std::set >& curveDefinitions) - { - - std::set casSet; - std::set varSet; - std::set welSet; - std::set grpSet; - std::set regSet; - - for (const std::pair& curveDef : curveDefinitions) - { - if (curveDef.first) casSet.insert(curveDef.first); - if (!curveDef.second.quantityName().empty()) varSet.insert(curveDef.second.quantityName()); - if (!curveDef.second.wellName().empty()) welSet.insert(curveDef.second.wellName()); - if (!curveDef.second.wellGroupName().empty()) grpSet.insert(curveDef.second.wellGroupName()); - if (!(curveDef.second.regionNumber() == -1)) regSet.insert(curveDef.second.regionNumber()); - } - - m_caseCount = casSet.size(); - m_variableCount = varSet.size(); - m_wellCount = welSet.size(); - m_groupCount = grpSet.size(); - m_regionCount = regSet.size(); - - prevCase = nullptr; - colorIndex = 0; - lineStyleIdx = -1; - } -#endif - RimCurveLookCalculator(const std::set >& curveDefinitions); - - #if 0 - void setupCurveLook2(RimSummaryCurve* curve) - { - RimPlotCurve::LineStyleEnum lineStyle = RimPlotCurve::STYLE_SOLID; - - if(curve->summaryCase() != prevCase) - { - prevCase = curve->summaryCase(); - lineStyleIdx++; - } - - lineStyle = caf::AppEnum::fromIndex(lineStyleIdx%caf::AppEnum::size()); - if(lineStyle == RimPlotCurve::STYLE_NONE) - { - lineStyle = RimPlotCurve::STYLE_SOLID; - lineStyleIdx++; - } - - cvf::Color3f curveColor = cycledPaletteColor(colorIndex); - colorIndex++; - - curve->setColor(curveColor); - curve->setLineStyle(lineStyle); - } - #endif - - void setupCurveLook(RimSummaryCurve* curve); - - //-------------------------------------------------------------------------------------------------- - /// Pick default curve color from an index based palette - //-------------------------------------------------------------------------------------------------- - cvf::Color3f cycledPaletteColor(int colorIndex); - - RimPlotCurve::LineStyleEnum cycledLineStyle(int index); - - RimPlotCurve::PointSymbolEnum cycledSymbol(int index); - - int cycledLineThickness(int index); - - float gradient(size_t totalCount, int index); - -private: - int colorIndex; - RimSummaryCase* prevCase; - int lineStyleIdx; - enum CurveAppearanceType { NONE, - COLOR, + COLOR, GRADIENT, LINE_STYLE, SYMBOL, LINE_THICKNESS }; - void setOneCurveAppearance(CurveAppearanceType appeaType, size_t totalCount, int appeaIdx, RimSummaryCurve* curve); + void assignDimensions(CurveAppearanceType caseAppearance, + CurveAppearanceType variAppearance, + CurveAppearanceType wellAppearance, + CurveAppearanceType gropAppearance, + CurveAppearanceType regiAppearance); + + void setupCurveLook(RimSummaryCurve* curve); + +private: + + + void setOneCurveAppearance(CurveAppearanceType appeaType, size_t totalCount, int appeaIdx, RimSummaryCurve* curve); + + cvf::Color3f cycledPaletteColor(int colorIndex); + RimPlotCurve::LineStyleEnum cycledLineStyle(int index); + RimPlotCurve::PointSymbolEnum cycledSymbol(int index); + int cycledLineThickness(int index); + float gradient(size_t totalCount, int index); - cvf::Color3f gradeColor(const cvf::Color3f& color , float factor); + cvf::Color3f gradeColor(const cvf::Color3f& color , float factor); - cvf::Color3f m_currentCurveBaseColor; - float m_currentCurveGradient; + cvf::Color3f m_currentCurveBaseColor; + float m_currentCurveGradient; - size_t m_caseCount; - size_t m_variableCount; - size_t m_wellCount; - size_t m_groupCount; - size_t m_regionCount; + size_t m_caseCount; + size_t m_variableCount; + size_t m_wellCount; + size_t m_groupCount; + size_t m_regionCount; - CurveAppearanceType m_caseAppearanceType; - CurveAppearanceType m_varAppearanceType; - CurveAppearanceType m_wellAppearanceType; - CurveAppearanceType m_groupAppearanceType; - CurveAppearanceType m_regionAppearanceType; + CurveAppearanceType m_caseAppearanceType; + CurveAppearanceType m_varAppearanceType; + CurveAppearanceType m_wellAppearanceType; + CurveAppearanceType m_groupAppearanceType; + CurveAppearanceType m_regionAppearanceType; - std::map m_caseToAppearanceIdxMap; - std::map m_varToAppearanceIdxMap; - std::map m_welToAppearanceIdxMap; - std::map m_grpToAppearanceIdxMap; - std::map m_regToAppearanceIdxMap; + std::map m_caseToAppearanceIdxMap; + std::map m_varToAppearanceIdxMap; + std::map m_welToAppearanceIdxMap; + std::map m_grpToAppearanceIdxMap; + std::map m_regToAppearanceIdxMap; - #if 0 - std::vector m_colorsPrCurveDimension; - std::vector m_gradientPrCurveDimension; - std::vector m_lineStylePrCurveDimension; - std::vector m_symbolPrCurveDimension; - std::vector m_lineThicknessPrCurveDimension; - #endif };