#1180 Use RiaColorTables for several features (well log, summary, flow rates)

This commit is contained in:
Magne Sjaastad 2017-02-10 08:39:25 +01:00
parent 3d5781a601
commit 652df8854d
13 changed files with 45 additions and 168 deletions

View File

@ -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)
{

View File

@ -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());

View File

@ -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();

View File

@ -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();

View File

@ -19,6 +19,8 @@
#include "RicWellLogPlotCurveFeatureImpl.h"
#include "RiaColorTables.h"
#include "RimWellAllocationPlot.h"
#include "RimWellLogCurve.h"
@ -26,36 +28,13 @@
#include <QColor>
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);
}
//--------------------------------------------------------------------------------------------------

View File

@ -30,7 +30,7 @@ class RimWellAllocationPlot;
class RicWellLogPlotCurveFeatureImpl
{
public:
static cvf::Color3f curveColorFromTable();
static cvf::Color3f curveColorFromTable(size_t index);
static std::vector<RimWellLogCurve*> selectedWellLogCurves();
static RimWellAllocationPlot* parentWellAllocationPlot();
};

View File

@ -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<RigSingleWellResultsData>& 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);
}
}
}

View File

@ -42,7 +42,6 @@ CAF_PDM_SOURCE_INIT(RimWellFlowRateCurve, "RimWellFlowRateCurve");
RimWellFlowRateCurve::RimWellFlowRateCurve()
{
CAF_PDM_InitObject("Flow Rate Curve", "", "", "");
m_curveColor = RicWellLogPlotCurveFeatureImpl::curveColorFromTable();
}
//--------------------------------------------------------------------------------------------------

View File

@ -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<RigSingleWellResultsData> 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<RimEclipseWell>& w1, const caf::PdmPointer<RimEclipseWell>& w2)
{
if (w1.notNull() && w2.notNull())

View File

@ -120,7 +120,6 @@ public:
void updateStateForVisibilityCheckboxes();
static cvf::Color3f cycledPaletteColor(size_t colorIndex);
void assignDefaultWellColors();
protected:

View File

@ -17,7 +17,11 @@
/////////////////////////////////////////////////////////////////////////////////
#include "RimSummaryCurveAppearanceCalculator.h"
#include "RiaColorTables.h"
#include "RimSummaryCurve.h"
#include "cvfVector3.h"
#include <cmath>
@ -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);
}
//--------------------------------------------------------------------------------------------------

View File

@ -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();
}

View File

@ -61,6 +61,7 @@ public:
void addCurveFilter(RimSummaryCurveFilter* curveFilter);
RimSummaryCurve* findRimCurveFromQwtCurve(const QwtPlotCurve* curve) const;
size_t curveCount() const;
void loadDataAndUpdate();