mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#1208 Use category text instead of category index
This commit is contained in:
@@ -636,6 +636,25 @@ void RimLegendConfig::setCategoryColors(const std::vector<cvf::Color3ub>& catego
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimLegendConfig::categoryNameFromCategoryValue(size_t categoryValue) const
|
||||
{
|
||||
if (m_categoryNames.size() > 0)
|
||||
{
|
||||
for (size_t categoryIndex = 0; categoryIndex < m_categories.size(); categoryIndex++)
|
||||
{
|
||||
if (categoryValue == m_categories[categoryIndex])
|
||||
{
|
||||
return cvfqt::Utils::toQString(m_categoryNames[categoryIndex]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return QString("%1").arg(categoryValue);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -105,10 +105,12 @@ public:
|
||||
|
||||
void setAutomaticRanges(double globalMin, double globalMax, double localMin, double localMax);
|
||||
void setClosestToZeroValues(double globalPosClosestToZero, double globalNegClosestToZero, double localPosClosestToZero, double localNegClosestToZero);
|
||||
|
||||
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);
|
||||
QString categoryNameFromCategoryValue(size_t categoryValue) const;
|
||||
|
||||
void setTitle(const cvf::String& title);
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include "RimEclipseFaultColors.h"
|
||||
#include "RimEclipseView.h"
|
||||
#include "RimFormationNames.h"
|
||||
#include "RimLegendConfig.h"
|
||||
#include "RimReservoirCellResultsStorage.h"
|
||||
|
||||
#include "cafDisplayCoordTransform.h"
|
||||
@@ -706,7 +707,19 @@ QString RiuResultTextBuilder::cellResultText(RimEclipseCellColors* resultColors)
|
||||
double scalarValue = resultAccessor->cellFaceScalar(m_cellIndex, m_face);
|
||||
QString resultVar = resultColors->resultVariableUiName();
|
||||
|
||||
text = QString("%1 : %2").arg(resultVar).arg(scalarValue);
|
||||
QString resultValueText;
|
||||
if (resultColors->hasCategoryResult())
|
||||
{
|
||||
RimLegendConfig* legendConfig = resultColors->legendConfig();
|
||||
|
||||
resultValueText += legendConfig->categoryNameFromCategoryValue(scalarValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
resultValueText = QString("%1").arg(scalarValue);
|
||||
}
|
||||
|
||||
text = QString("%1 : %2").arg(resultVar).arg(resultValueText);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user