mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#829 Ordered the legend for formation names in the natural top to bottom order
This commit is contained in:
@@ -948,20 +948,12 @@ void RimEclipseView::updateLegends()
|
||||
{
|
||||
if(cellEdgeResult()->singleVarEdgeResultColors()->resultType() != RimDefines::FORMATION_NAMES)
|
||||
{
|
||||
cellEdgeResult()->legendConfig()->setCategories(results->uniqueCellScalarValues(cellEdgeResult()->singleVarEdgeResultColors()->scalarResultIndex()));
|
||||
cellEdgeResult()->legendConfig()->setIntegerCategories(results->uniqueCellScalarValues(cellEdgeResult()->singleVarEdgeResultColors()->scalarResultIndex()));
|
||||
}
|
||||
else
|
||||
{
|
||||
const std::vector<QString>& fnVector = eclipseCase->activeFormationNames()->formationNames();
|
||||
std::vector<int> nameIndices;
|
||||
std::vector<cvf::String> names;
|
||||
for (int i = 0; i < fnVector.size(); ++i)
|
||||
{
|
||||
nameIndices.push_back(i);
|
||||
names.push_back(cvfqt::Utils::toString(fnVector[i]));
|
||||
}
|
||||
|
||||
cellEdgeResult()->legendConfig()->setCategoriesWithNames(nameIndices, names);
|
||||
cellEdgeResult()->legendConfig()->setNamedCategoriesInverse(fnVector);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1012,20 +1004,12 @@ void RimEclipseView::updateMinMaxValuesAndAddLegendToView(QString legendLabel, R
|
||||
{
|
||||
if(resultColors->resultType() != RimDefines::FORMATION_NAMES)
|
||||
{
|
||||
resultColors->legendConfig()->setCategories(cellResultsData->uniqueCellScalarValues(resultColors->scalarResultIndex()));
|
||||
resultColors->legendConfig()->setIntegerCategories(cellResultsData->uniqueCellScalarValues(resultColors->scalarResultIndex()));
|
||||
}
|
||||
else
|
||||
{
|
||||
const std::vector<QString>& fnVector = eclipseCase()->reservoirData()->activeFormationNames()->formationNames();
|
||||
std::vector<int> nameIndices;
|
||||
std::vector<cvf::String> names;
|
||||
for (int i = 0; i < fnVector.size(); ++i)
|
||||
{
|
||||
nameIndices.push_back(i);
|
||||
names.push_back(cvfqt::Utils::toString(fnVector[i]));
|
||||
}
|
||||
|
||||
resultColors->legendConfig()->setCategoriesWithNames(nameIndices, names);
|
||||
resultColors->legendConfig()->setNamedCategoriesInverse(fnVector);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -423,15 +423,7 @@ void RimGeoMechView::updateLegends()
|
||||
if (cellResult()->hasCategoryResult())
|
||||
{
|
||||
const std::vector<QString>& fnVector = gmCase->femPartResults()->activeFormationNames()->formationNames();
|
||||
std::vector<int> nameIndices;
|
||||
std::vector<cvf::String> names;
|
||||
for (int i = 0; i < fnVector.size(); ++i)
|
||||
{
|
||||
nameIndices.push_back(i);
|
||||
names.push_back(cvfqt::Utils::toString(fnVector[i]));
|
||||
}
|
||||
|
||||
cellResult()->legendConfig->setCategoriesWithNames(nameIndices, names);
|
||||
cellResult()->legendConfig->setNamedCategoriesInverse(fnVector);
|
||||
}
|
||||
|
||||
m_viewer->addColorLegendToBottomLeftCorner(cellResult()->legendConfig->legend());
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
#include "cvfScalarMapperContinuousLog.h"
|
||||
#include "cvfScalarMapperDiscreteLinear.h"
|
||||
#include "cvfScalarMapperDiscreteLog.h"
|
||||
#include "cvfqtUtils.h"
|
||||
|
||||
#include <cmath>
|
||||
#include "RimGeoMechCellColors.h"
|
||||
@@ -690,7 +691,7 @@ void RimLegendConfig::setClosestToZeroValues(double globalPosClosestToZero, doub
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimLegendConfig::setCategories(const std::vector<int>& categories)
|
||||
void RimLegendConfig::setIntegerCategories(const std::vector<int>& categories)
|
||||
{
|
||||
m_categories = categories;
|
||||
m_categoryNames.clear();
|
||||
@@ -701,10 +702,18 @@ void RimLegendConfig::setCategories(const std::vector<int>& categories)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimLegendConfig::setCategoriesWithNames(const std::vector<int>& categories, const std::vector<cvf::String>& categoryNames)
|
||||
void RimLegendConfig::setNamedCategoriesInverse(const std::vector<QString>& categoryNames)
|
||||
{
|
||||
m_categories = categories;
|
||||
m_categoryNames = categoryNames;
|
||||
std::vector<int> nameIndices;
|
||||
std::vector<cvf::String> names;
|
||||
for(int i = static_cast<int>(categoryNames.size()) - 1; i >= 0; --i)
|
||||
{
|
||||
nameIndices.push_back(i);
|
||||
names.push_back(cvfqt::Utils::toString(categoryNames[i]));
|
||||
}
|
||||
|
||||
m_categories = nameIndices;
|
||||
m_categoryNames = names;
|
||||
|
||||
updateLegend();
|
||||
}
|
||||
|
||||
@@ -105,8 +105,8 @@ public:
|
||||
|
||||
void setAutomaticRanges(double globalMin, double globalMax, double localMin, double localMax);
|
||||
void setClosestToZeroValues(double globalPosClosestToZero, double globalNegClosestToZero, double localPosClosestToZero, double localNegClosestToZero);
|
||||
void setCategories(const std::vector<int>& categories);
|
||||
void setCategoriesWithNames(const std::vector<int>& categories, const std::vector<cvf::String>& categoryNames);
|
||||
void setIntegerCategories(const std::vector<int>& categories);
|
||||
void setNamedCategoriesInverse(const std::vector<QString>& categoryNames);
|
||||
|
||||
void setTitle(const cvf::String& title);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user