mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#1178 Use well colors for Max Fraction Tracer
This commit is contained in:
parent
9fa772a7bc
commit
b3e845ed5e
@ -18,6 +18,7 @@
|
||||
|
||||
#include "RimFlowDiagSolution.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
#include "RiaColorTables.h"
|
||||
|
||||
#include "RigActiveCellInfo.h"
|
||||
@ -28,6 +29,7 @@
|
||||
#include "RigSingleWellResultsData.h"
|
||||
|
||||
#include "RimEclipseResultCase.h"
|
||||
#include "RimEclipseWell.h"
|
||||
#include "RimEclipseWellCollection.h"
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimFlowDiagSolution, "FlowDiagSolution");
|
||||
@ -283,15 +285,29 @@ cvf::Color3f RimFlowDiagSolution::tracerColor(QString tracerName)
|
||||
|
||||
if ( eclCase )
|
||||
{
|
||||
const cvf::Collection<RigSingleWellResultsData>& wellResults = eclCase->reservoirData()->wellResults();
|
||||
RimEclipseView* activeView = dynamic_cast<RimEclipseView*>(RiaApplication::instance()->activeReservoirView());
|
||||
|
||||
const caf::ColorTable& colorTable = RiaColorTables::wellsPaletteColors();
|
||||
|
||||
for ( size_t wIdx = 0; wIdx < wellResults.size(); ++wIdx )
|
||||
if (activeView)
|
||||
{
|
||||
if ( wellResults[wIdx]->m_wellName == tracerName )
|
||||
RimEclipseWell* well = activeView->wellCollection->findWell(tracerName);
|
||||
if (well)
|
||||
{
|
||||
return colorTable.cycledColor3f(wIdx);
|
||||
return well->wellPipeColor();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// If we do not find a well color, use index in well result data to be able to get variation of tracer colors
|
||||
// This can be the case if we do not have any views at all
|
||||
|
||||
const cvf::Collection<RigSingleWellResultsData>& wellResults = eclCase->reservoirData()->wellResults();
|
||||
|
||||
for ( size_t wIdx = 0; wIdx < wellResults.size(); ++wIdx )
|
||||
{
|
||||
if ( wellResults[wIdx]->m_wellName == tracerName )
|
||||
{
|
||||
return RiaColorTables::wellsPaletteColors().cycledColor3f(wIdx);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -281,7 +281,16 @@ void RimEclipseCellColors::updateLegendData(size_t currentTimeStep)
|
||||
|
||||
if (this->hasCategoryResult())
|
||||
{
|
||||
this->legendConfig()->setNamedCategories(this->flowDiagSolution()->tracerNames());
|
||||
std::vector<cvf::Color3ub> categoryColors;
|
||||
|
||||
std::vector<QString> tracerNames = this->flowDiagSolution()->tracerNames();
|
||||
for (const auto& tracerName : tracerNames)
|
||||
{
|
||||
categoryColors.push_back(cvf::Color3ub(this->flowDiagSolution()->tracerColor(tracerName)));
|
||||
}
|
||||
|
||||
this->legendConfig()->setNamedCategories(tracerNames);
|
||||
this->legendConfig()->setCategoryColors(categoryColors);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -308,7 +308,15 @@ void RimLegendConfig::updateLegend()
|
||||
break;
|
||||
case CATEGORY_INTEGER:
|
||||
m_categoryMapper->setCategoriesWithNames(m_categories, m_categoryNames);
|
||||
m_categoryMapper->setInterpolateColors(legendColors);
|
||||
|
||||
if (m_categoryColors.size() > 0)
|
||||
{
|
||||
m_categoryMapper->setCycleColors(m_categoryColors);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_categoryMapper->setInterpolateColors(legendColors);
|
||||
}
|
||||
m_currentScalarMapper = m_categoryMapper.p();
|
||||
break;
|
||||
default:
|
||||
@ -570,6 +578,7 @@ void RimLegendConfig::setIntegerCategories(const std::vector<int>& categories)
|
||||
{
|
||||
m_categories = categories;
|
||||
m_categoryNames.clear();
|
||||
m_categoryColors.clear();
|
||||
|
||||
updateLegend();
|
||||
}
|
||||
@ -589,6 +598,7 @@ void RimLegendConfig::setNamedCategoriesInverse(const std::vector<QString>& cate
|
||||
|
||||
m_categories = nameIndices;
|
||||
m_categoryNames = names;
|
||||
m_categoryColors.clear();
|
||||
|
||||
updateLegend();
|
||||
}
|
||||
@ -609,10 +619,23 @@ void RimLegendConfig::setNamedCategories(const std::vector<QString>& categoryNam
|
||||
|
||||
m_categories = nameIndices;
|
||||
m_categoryNames = names;
|
||||
m_categoryColors.clear();
|
||||
|
||||
updateLegend();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimLegendConfig::setCategoryColors(const std::vector<cvf::Color3ub>& categoryColors)
|
||||
{
|
||||
if (m_categoryNames.size() == categoryColors.size())
|
||||
{
|
||||
m_categoryColors = cvf::Color3ubArray(categoryColors);
|
||||
updateLegend();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -108,6 +108,7 @@ public:
|
||||
void setIntegerCategories(const std::vector<int>& categories);
|
||||
void setNamedCategoriesInverse(const std::vector<QString>& categoryNames);
|
||||
void setNamedCategories(const std::vector<QString>& categoryNames);
|
||||
void setCategoryColors(const std::vector<cvf::Color3ub>& categoryColors);
|
||||
|
||||
void setTitle(const cvf::String& title);
|
||||
|
||||
@ -156,6 +157,7 @@ private:
|
||||
|
||||
std::vector<int> m_categories;
|
||||
std::vector<cvf::String> m_categoryNames;
|
||||
cvf::Color3ubArray m_categoryColors;
|
||||
|
||||
// Fields
|
||||
caf::PdmField<int> m_numLevels;
|
||||
|
Loading…
Reference in New Issue
Block a user