From 652df8854df0166468fe051f56cd3e80e8ebfa3f Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 10 Feb 2017 08:39:25 +0100 Subject: [PATCH] #1180 Use RiaColorTables for several features (well log, summary, flow rates) --- .../RicNewSummaryCurveFeature.cpp | 6 +- .../RicAddWellLogToPlotFeature.cpp | 5 +- .../RicNewWellLogCurveExtractionFeature.cpp | 3 +- .../RicNewWellLogFileCurveFeature.cpp | 5 +- .../RicWellLogPlotCurveFeatureImpl.cpp | 29 +---- .../RicWellLogPlotCurveFeatureImpl.h | 2 +- .../Flow/RimFlowDiagSolution.cpp | 9 +- .../Flow/RimWellFlowRateCurve.cpp | 1 - .../RimEclipseWellCollection.cpp | 38 +------ .../RimEclipseWellCollection.h | 1 - .../RimSummaryCurveAppearanceCalculator.cpp | 104 ++---------------- .../Summary/RimSummaryPlot.cpp | 9 +- .../ProjectDataModel/Summary/RimSummaryPlot.h | 1 + 13 files changed, 45 insertions(+), 168 deletions(-) diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryCurveFeature.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryCurveFeature.cpp index 778129da2c..6f60b7fac3 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryCurveFeature.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryCurveFeature.cpp @@ -67,11 +67,11 @@ void RicNewSummaryCurveFeature::onActionTriggered(bool isChecked) if (plot) { RimSummaryCurve* newCurve = new RimSummaryCurve(); - plot->addCurve(newCurve); - - cvf::Color3f curveColor = RicWellLogPlotCurveFeatureImpl::curveColorFromTable(); + cvf::Color3f curveColor = RicWellLogPlotCurveFeatureImpl::curveColorFromTable(plot->curveCount()); newCurve->setColor(curveColor); + plot->addCurve(newCurve); + RimSummaryCase* defaultCase = nullptr; if (project->activeOilField()->summaryCaseCollection()->summaryCaseCount() > 0) { diff --git a/ApplicationCode/Commands/WellLogCommands/RicAddWellLogToPlotFeature.cpp b/ApplicationCode/Commands/WellLogCommands/RicAddWellLogToPlotFeature.cpp index 52ea3a84e1..45bb637df2 100644 --- a/ApplicationCode/Commands/WellLogCommands/RicAddWellLogToPlotFeature.cpp +++ b/ApplicationCode/Commands/WellLogCommands/RicAddWellLogToPlotFeature.cpp @@ -85,6 +85,9 @@ void RicAddWellLogToPlotFeature::onActionTriggered(bool isChecked) if (wellLogFile) { RimWellLogFileCurve* curve = new RimWellLogFileCurve; + cvf::Color3f curveColor = RicWellLogPlotCurveFeatureImpl::curveColorFromTable(plotTrack->curveCount()); + curve->setColor(curveColor); + plotTrack->addCurve(curve); RigWellLogFile* wellLogDataFile = wellLogFile->wellLogFile(); @@ -96,8 +99,6 @@ void RicAddWellLogToPlotFeature::onActionTriggered(bool isChecked) plot->setDepthUnit(wellLogDataFile->depthUnit()); } - cvf::Color3f curveColor = RicWellLogPlotCurveFeatureImpl::curveColorFromTable(); - curve->setColor(curveColor); curve->setWellPath(wellPath); curve->setWellLogChannelName(wellLog->name()); diff --git a/ApplicationCode/Commands/WellLogCommands/RicNewWellLogCurveExtractionFeature.cpp b/ApplicationCode/Commands/WellLogCommands/RicNewWellLogCurveExtractionFeature.cpp index 63ab440548..3e75586336 100644 --- a/ApplicationCode/Commands/WellLogCommands/RicNewWellLogCurveExtractionFeature.cpp +++ b/ApplicationCode/Commands/WellLogCommands/RicNewWellLogCurveExtractionFeature.cpp @@ -134,10 +134,11 @@ RimWellLogExtractionCurve* RicNewWellLogCurveExtractionFeature::addCurve(RimWell CVF_ASSERT(plotTrack); RimWellLogExtractionCurve* curve = new RimWellLogExtractionCurve(); - cvf::Color3f curveColor = RicWellLogPlotCurveFeatureImpl::curveColorFromTable(); + cvf::Color3f curveColor = RicWellLogPlotCurveFeatureImpl::curveColorFromTable(plotTrack->curveCount()); curve->setColor(curveColor); curve->setWellPath(wellPath); curve->setPropertiesFromView(view); + plotTrack->addCurve(curve); plotTrack->updateConnectedEditors(); diff --git a/ApplicationCode/Commands/WellLogCommands/RicNewWellLogFileCurveFeature.cpp b/ApplicationCode/Commands/WellLogCommands/RicNewWellLogFileCurveFeature.cpp index d9600de73d..25129baba4 100644 --- a/ApplicationCode/Commands/WellLogCommands/RicNewWellLogFileCurveFeature.cpp +++ b/ApplicationCode/Commands/WellLogCommands/RicNewWellLogFileCurveFeature.cpp @@ -145,11 +145,12 @@ RimWellLogFileCurve* RicNewWellLogFileCurveFeature::addCurve(RimWellLogTrack* pl CVF_ASSERT(plotTrack); RimWellLogFileCurve* curve = new RimWellLogFileCurve(); - plotTrack->addCurve(curve); - cvf::Color3f curveColor = RicWellLogPlotCurveFeatureImpl::curveColorFromTable(); + cvf::Color3f curveColor = RicWellLogPlotCurveFeatureImpl::curveColorFromTable(plotTrack->curveCount()); curve->setColor(curveColor); + plotTrack->addCurve(curve); + plotTrack->updateConnectedEditors(); RiuMainPlotWindow* plotwindow = RiaApplication::instance()->getOrCreateAndShowMainPlotWindow(); diff --git a/ApplicationCode/Commands/WellLogCommands/RicWellLogPlotCurveFeatureImpl.cpp b/ApplicationCode/Commands/WellLogCommands/RicWellLogPlotCurveFeatureImpl.cpp index f8a94b0b69..24f8438028 100644 --- a/ApplicationCode/Commands/WellLogCommands/RicWellLogPlotCurveFeatureImpl.cpp +++ b/ApplicationCode/Commands/WellLogCommands/RicWellLogPlotCurveFeatureImpl.cpp @@ -19,6 +19,8 @@ #include "RicWellLogPlotCurveFeatureImpl.h" +#include "RiaColorTables.h" + #include "RimWellAllocationPlot.h" #include "RimWellLogCurve.h" @@ -26,36 +28,13 @@ #include -static const int RI_LOGPLOT_CURVECOLORSCOUNT = 15; -static const int RI_LOGPLOT_CURVECOLORS[] = -{ - Qt::black, - Qt::darkBlue, - Qt::darkRed, - Qt::darkGreen, - Qt::darkYellow, - Qt::darkMagenta, - Qt::darkCyan, - Qt::darkGray, - Qt::blue, - Qt::red, - Qt::green, - Qt::yellow, - Qt::magenta, - Qt::cyan, - Qt::gray -}; //-------------------------------------------------------------------------------------------------- /// Pick default curve color from an index based palette //-------------------------------------------------------------------------------------------------- -cvf::Color3f RicWellLogPlotCurveFeatureImpl::curveColorFromTable() +cvf::Color3f RicWellLogPlotCurveFeatureImpl::curveColorFromTable(size_t index) { - static int colorIndex = 0; - QColor color = QColor(Qt::GlobalColor(RI_LOGPLOT_CURVECOLORS[colorIndex % RI_LOGPLOT_CURVECOLORSCOUNT])); - ++colorIndex; - cvf::Color3f cvfColor(color.redF(), color.greenF(), color.blueF()); - return cvfColor; + return RiaColorTables::wellLogPlotPaletteColors().cycledColor3f(index); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/WellLogCommands/RicWellLogPlotCurveFeatureImpl.h b/ApplicationCode/Commands/WellLogCommands/RicWellLogPlotCurveFeatureImpl.h index a30ea81e9f..4d45ddb5c9 100644 --- a/ApplicationCode/Commands/WellLogCommands/RicWellLogPlotCurveFeatureImpl.h +++ b/ApplicationCode/Commands/WellLogCommands/RicWellLogPlotCurveFeatureImpl.h @@ -30,7 +30,7 @@ class RimWellAllocationPlot; class RicWellLogPlotCurveFeatureImpl { public: - static cvf::Color3f curveColorFromTable(); + static cvf::Color3f curveColorFromTable(size_t index); static std::vector selectedWellLogCurves(); static RimWellAllocationPlot* parentWellAllocationPlot(); }; diff --git a/ApplicationCode/ProjectDataModel/Flow/RimFlowDiagSolution.cpp b/ApplicationCode/ProjectDataModel/Flow/RimFlowDiagSolution.cpp index fa2988dd04..12882e5f1f 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimFlowDiagSolution.cpp +++ b/ApplicationCode/ProjectDataModel/Flow/RimFlowDiagSolution.cpp @@ -18,7 +18,7 @@ #include "RimFlowDiagSolution.h" -#include "RimEclipseResultCase.h" +#include "RiaColorTables.h" #include "RigActiveCellInfo.h" #include "RigCaseCellResultsData.h" @@ -26,6 +26,8 @@ #include "RigFlowDiagResults.h" #include "RigMainGrid.h" #include "RigSingleWellResultsData.h" + +#include "RimEclipseResultCase.h" #include "RimEclipseWellCollection.h" CAF_PDM_SOURCE_INIT(RimFlowDiagSolution, "FlowDiagSolution"); @@ -283,12 +285,13 @@ cvf::Color3f RimFlowDiagSolution::tracerColor(QString tracerName) { const cvf::Collection& wellResults = eclCase->reservoirData()->wellResults(); + const caf::ColorTable& colorTable = RiaColorTables::wellsPaletteColors(); + for ( size_t wIdx = 0; wIdx < wellResults.size(); ++wIdx ) { if ( wellResults[wIdx]->m_wellName == tracerName ) { - - return RimEclipseWellCollection::cycledPaletteColor(wIdx); + return colorTable.cycledColor3f(wIdx); } } } diff --git a/ApplicationCode/ProjectDataModel/Flow/RimWellFlowRateCurve.cpp b/ApplicationCode/ProjectDataModel/Flow/RimWellFlowRateCurve.cpp index a11ad11ea2..c88a2882f4 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimWellFlowRateCurve.cpp +++ b/ApplicationCode/ProjectDataModel/Flow/RimWellFlowRateCurve.cpp @@ -42,7 +42,6 @@ CAF_PDM_SOURCE_INIT(RimWellFlowRateCurve, "RimWellFlowRateCurve"); RimWellFlowRateCurve::RimWellFlowRateCurve() { CAF_PDM_InitObject("Flow Rate Curve", "", "", ""); - m_curveColor = RicWellLogPlotCurveFeatureImpl::curveColorFromTable(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.cpp b/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.cpp index f5535315a5..c11c9add94 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.cpp @@ -21,6 +21,7 @@ #include "RimEclipseWellCollection.h" #include "RiaApplication.h" +#include "RiaColorTables.h" #include "RiaPreferences.h" #include "RigEclipseCaseData.h" @@ -458,12 +459,14 @@ void RimEclipseWellCollection::assignDefaultWellColors() cvf::Collection wellResults = rimEclipseCase->reservoirData()->wellResults(); + const caf::ColorTable& colorTable = RiaColorTables::wellsPaletteColors(); + for (size_t wIdx = 0; wIdx < wellResults.size(); ++wIdx) { RimEclipseWell* well = this->findWell(wellResults[wIdx]->m_wellName); if (well) { - cvf::Color3f col = cycledPaletteColor(wIdx); + cvf::Color3f col = colorTable.cycledColor3f(wIdx); well->wellPipeColor = col; well->updateConnectedEditors(); @@ -728,39 +731,6 @@ void RimEclipseWellCollection::calculateWellGeometryVisibility(size_t frameIndex } } -//-------------------------------------------------------------------------------------------------- -/// TODO: Consider creating a factory for colors, see also RimSummaryCurveAppearanceCalculator -//-------------------------------------------------------------------------------------------------- -cvf::Color3f RimEclipseWellCollection::cycledPaletteColor(size_t colorIndex) -{ - static const size_t colorCount = 15; - static const cvf::ubyte colorData[][3] = - { - { 0, 112, 136 }, // Dark Green-Blue - { 202, 0, 0 }, // Red - { 78, 204, 0 }, // Clear Green - { 236, 118, 0 }, // Orange - { 0 , 0, 0 }, // Black - { 56, 56, 255 }, // Vivid Blue - { 248, 0, 170 }, // Magenta - { 169, 2, 240 }, // Purple - { 0, 221, 221 }, // Turquoise - { 201, 168, 206 }, // Light Violet - { 0, 205, 68 }, // Bluish Green - { 236, 188, 0 }, // Mid Yellow - { 51, 204, 255 }, // Bluer Turquoise - { 164, 193, 0 }, // Mid Yellowish Green - { 0, 143, 239 }, // Dark Light Blue - }; - - size_t paletteIdx = colorIndex % colorCount; - - cvf::Color3ub ubColor(colorData[paletteIdx][0], colorData[paletteIdx][1], colorData[paletteIdx][2]); - cvf::Color3f cvfColor(ubColor); - - return cvfColor; -} - bool lessEclipseWell(const caf::PdmPointer& w1, const caf::PdmPointer& w2) { if (w1.notNull() && w2.notNull()) diff --git a/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.h b/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.h index 071127a086..8bceb970e8 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.h +++ b/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.h @@ -120,7 +120,6 @@ public: void updateStateForVisibilityCheckboxes(); - static cvf::Color3f cycledPaletteColor(size_t colorIndex); void assignDefaultWellColors(); protected: diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveAppearanceCalculator.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveAppearanceCalculator.cpp index b65ff72be7..ec37ff7d34 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveAppearanceCalculator.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveAppearanceCalculator.cpp @@ -17,7 +17,11 @@ ///////////////////////////////////////////////////////////////////////////////// #include "RimSummaryCurveAppearanceCalculator.h" + +#include "RiaColorTables.h" + #include "RimSummaryCurve.h" + #include "cvfVector3.h" #include @@ -253,31 +257,7 @@ cvf::Color3f RimSummaryCurveAppearanceCalculator::cycledPaletteColor(int colorIn { if (colorIndex < 0) return cvf::Color3f::BLACK; - static const int colorCount = 15; - static const cvf::ubyte colorData[][3] = - { - { 0, 112, 136 }, // Dark Green-Blue - { 202, 0, 0 }, // Red - { 78, 204, 0 }, // Clear Green - { 236, 118, 0 }, // Orange - { 0 , 0, 0 }, // Black - { 56, 56, 255 }, // Vivid Blue - { 248, 0, 170 }, // Magenta - { 169, 2, 240 }, // Purple - { 0, 221, 221 }, // Turquoise - { 201, 168, 206 }, // Light Violet - { 0, 205, 68 }, // Bluish Green - { 236, 188, 0 }, // Mid Yellow - { 51, 204, 255 }, // Bluer Turquoise - { 164, 193, 0 }, // Mid Yellowish Green - { 0, 143, 239 }, // Dark Light Blue - }; - - int paletteIdx = colorIndex % colorCount; - - cvf::Color3ub ubColor(colorData[paletteIdx][0], colorData[paletteIdx][1], colorData[paletteIdx][2]); - cvf::Color3f cvfColor(ubColor); - return cvfColor; + return RiaColorTables::summaryCurveDefaultPaletteColors().cycledColor3f(colorIndex); } //-------------------------------------------------------------------------------------------------- @@ -287,23 +267,7 @@ cvf::Color3f RimSummaryCurveAppearanceCalculator::cycledNoneRGBBrColor(int color { if(colorIndex < 0) return cvf::Color3f::BLACK; - static const int colorCount = 7; - static const cvf::ubyte colorData[][3] = - { - { 236, 118, 0 }, // Orange - { 0 , 0, 0 }, // Black - { 248, 0, 170 }, // Magenta - { 236, 188, 0 }, // Mid Yellow - { 169, 2, 240 }, // Purple - { 0, 221, 221 }, // Turquoise - { 201, 168, 206 }, // Light Violet - }; - - int paletteIdx = colorIndex % colorCount; - - cvf::Color3ub ubColor(colorData[paletteIdx][0], colorData[paletteIdx][1], colorData[paletteIdx][2]); - cvf::Color3f cvfColor(ubColor); - return cvfColor; + return RiaColorTables::summaryCurveNoneRedGreenBlueBrownPaletteColors().cycledColor3f(colorIndex); } //-------------------------------------------------------------------------------------------------- @@ -313,19 +277,7 @@ cvf::Color3f RimSummaryCurveAppearanceCalculator::cycledGreenColor(int colorInde { if(colorIndex < 0) return cvf::Color3f::BLACK; - static const int colorCount = 3; - static const cvf::ubyte colorData[][3] = - { - { 78, 204, 0 }, // Clear Green - { 164, 193, 0 }, // Mid Yellowish Green - { 0, 205, 68 } // Bluish Green - }; - - int paletteIdx = colorIndex % colorCount; - - cvf::Color3ub ubColor(colorData[paletteIdx][0], colorData[paletteIdx][1], colorData[paletteIdx][2]); - cvf::Color3f cvfColor(ubColor); - return cvfColor; + return RiaColorTables::summaryCurveGreenPaletteColors().cycledColor3f(colorIndex); } @@ -336,19 +288,7 @@ cvf::Color3f RimSummaryCurveAppearanceCalculator::cycledBlueColor(int colorIndex { if(colorIndex < 0) return cvf::Color3f::BLACK; - static const int colorCount = 3; - static const cvf::ubyte colorData[][3] = - { - { 56, 56, 255 }, // Vivid Blue - { 0, 143, 239 }, // Dark Light Blue - { 153, 153, 255 }, // Off Light Blue - }; - - int paletteIdx = colorIndex % colorCount; - - cvf::Color3ub ubColor(colorData[paletteIdx][0], colorData[paletteIdx][1], colorData[paletteIdx][2]); - cvf::Color3f cvfColor(ubColor); - return cvfColor; + return RiaColorTables::summaryCurveBluePaletteColors().cycledColor3f(colorIndex); } @@ -359,19 +299,7 @@ cvf::Color3f RimSummaryCurveAppearanceCalculator::cycledRedColor(int colorIndex) { if(colorIndex < 0) return cvf::Color3f::BLACK; - static const int colorCount = 3; - static const cvf::ubyte colorData[][3] = - { - { 202, 0, 0 }, // Off Red - { 255, 51, 51}, // Bright Red - { 255, 102, 102 } // Light Red - }; - - int paletteIdx = colorIndex % colorCount; - - cvf::Color3ub ubColor(colorData[paletteIdx][0], colorData[paletteIdx][1], colorData[paletteIdx][2]); - cvf::Color3f cvfColor(ubColor); - return cvfColor; + return RiaColorTables::summaryCurveRedPaletteColors().cycledColor3f(colorIndex); } @@ -382,19 +310,7 @@ cvf::Color3f RimSummaryCurveAppearanceCalculator::cycledBrownColor(int colorInde { if(colorIndex < 0) return cvf::Color3f::BLACK; - static const int colorCount = 3; - static const cvf::ubyte colorData[][3] = - { - {186, 101, 44}, - { 99, 53, 23 }, // Highway Brown - { 103, 56, 24} // Dark Brown - }; - - int paletteIdx = colorIndex % colorCount; - - cvf::Color3ub ubColor(colorData[paletteIdx][0], colorData[paletteIdx][1], colorData[paletteIdx][2]); - cvf::Color3f cvfColor(ubColor); - return cvfColor; + return RiaColorTables::summaryCurveBrownPaletteColors().cycledColor3f(colorIndex); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp index 422802aa9c..ddd00dab06 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp @@ -28,7 +28,6 @@ #include "RimSummaryYAxisProperties.h" #include "RiuMainPlotWindow.h" -#include "RiuSelectionColors.h" #include "RiuSummaryQwtPlot.h" #include "cvfBase.h" @@ -708,3 +707,11 @@ RimSummaryCurve* RimSummaryPlot::findRimCurveFromQwtCurve(const QwtPlotCurve* qw return NULL; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RimSummaryPlot::curveCount() const +{ + return m_curves.size(); +} diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.h b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.h index 94fee99742..47585d337f 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.h @@ -61,6 +61,7 @@ public: void addCurveFilter(RimSummaryCurveFilter* curveFilter); RimSummaryCurve* findRimCurveFromQwtCurve(const QwtPlotCurve* curve) const; + size_t curveCount() const; void loadDataAndUpdate();