#1174 Use well ordering when creating category legend colors max tracer

This commit is contained in:
Magne Sjaastad
2017-02-15 15:21:13 +01:00
parent 9a7f187765
commit 037c7c1f73
3 changed files with 37 additions and 31 deletions

View File

@@ -29,6 +29,8 @@
#include "RimEclipseCase.h"
#include "RimEclipseFaultColors.h"
#include "RimEclipseView.h"
#include "RimEclipseWell.h"
#include "RimEclipseWellCollection.h"
#include "RimLegendConfig.h"
#include "RimTernaryLegendConfig.h"
#include "RimViewController.h"
@@ -281,16 +283,32 @@ void RimEclipseCellColors::updateLegendData(size_t currentTimeStep)
if (this->hasCategoryResult())
{
std::vector<cvf::Color3ub> categoryColors;
std::vector<std::tuple<QString, int, cvf::Color3ub>> categories;
std::vector<QString> tracerNames = this->flowDiagSolution()->tracerNames();
for (const auto& tracerName : tracerNames)
// Loop through the wells to get same ordering as the wells in tree view
for (size_t i = 0; i < m_reservoirView->wellCollection()->wells().size(); i++)
{
categoryColors.push_back(cvf::Color3ub(this->flowDiagSolution()->tracerColor(tracerName)));
size_t reverseIndex = m_reservoirView->wellCollection()->wells().size() - i - 1;
RimEclipseWell* well = m_reservoirView->wellCollection()->wells()[reverseIndex];
QString wellName = well->name();
auto tracer = std::find(begin(tracerNames), end(tracerNames), wellName);
if (tracer != end(tracerNames))
{
// The category value is defined as the index of the tracer name in the tracer name vector
size_t categoryValue = std::distance(begin(tracerNames), tracer);
cvf::Color3ub color(cvf::Color3::SEA_GREEN);
color = cvf::Color3ub(well->wellPipeColor());
categories.push_back(std::make_tuple(wellName, static_cast<int>(categoryValue), color));
}
}
this->legendConfig()->setNamedCategories(tracerNames);
this->legendConfig()->setCategoryColors(categoryColors);
this->legendConfig()->setCategoryItems(categories);
}
}
else