mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Upgraded visualization libraries
Major refactoring of color legend framework Added discrete log color legend p4#: 18989
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
#include "cafFactory.h"
|
||||
#include "cafPdmUiLineEditor.h"
|
||||
#include "cafPdmUiComboBoxEditor.h"
|
||||
#include "cvfScalarMapperDiscreteLog.h"
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimLegendConfig, "Legend");
|
||||
|
||||
@@ -58,6 +59,7 @@ namespace caf {
|
||||
addItem(RimLegendConfig::LINEAR_DISCRETE, "LinearDiscrete", "Discrete Linear");
|
||||
addItem(RimLegendConfig::LINEAR_CONTINUOUS, "LinearContinuous", "Continuous Linear");
|
||||
addItem(RimLegendConfig::LOG10_CONTINUOUS, "Log10Continuous", "Continuous Logarithmic");
|
||||
addItem(RimLegendConfig::LOG10_DISCRETE, "Log10Discrete", "Discrete Logarithmic");
|
||||
setDefault(RimLegendConfig::LINEAR_CONTINUOUS);
|
||||
}
|
||||
}
|
||||
@@ -83,17 +85,16 @@ RimLegendConfig::RimLegendConfig()
|
||||
CAF_PDM_InitField(&resultVariableName, "ResultVariableUsage", QString(""), "", "", "", "");
|
||||
resultVariableName.setUiHidden(true);
|
||||
|
||||
m_linDiscreteScalarMapper = new cvf::ScalarMapperUniformLevels;
|
||||
m_linDiscreteScalarMapper->setTextureSize(1024);
|
||||
|
||||
m_logSmoothScalarMapper = new cvf::ScalarMapperContinuousLog;
|
||||
m_linDiscreteScalarMapper = new cvf::ScalarMapperDiscreteLinear;
|
||||
m_logDiscreteScalarMapper = new cvf::ScalarMapperDiscreteLog;
|
||||
m_linSmoothScalarMapper = new cvf::ScalarMapperContinuousLinear;
|
||||
m_logSmoothScalarMapper = new cvf::ScalarMapperContinuousLog;
|
||||
|
||||
m_currentScalarMapper = m_linDiscreteScalarMapper;
|
||||
|
||||
|
||||
cvf::FixedAtlasFont* font = new cvf::FixedAtlasFont(cvf::FixedAtlasFont::STANDARD);
|
||||
m_legend = new cvf::OverlayColorLegend(font);
|
||||
m_legend = new cvf::OverlayScalarMapperLegend(font);
|
||||
m_position = cvf::Vec2ui(20, 50);
|
||||
|
||||
updateFieldVisibility();
|
||||
@@ -164,7 +165,9 @@ void RimLegendConfig::updateLegend()
|
||||
adjustedMax = adjust(m_userDefinedMaxValue, m_precision);
|
||||
}
|
||||
|
||||
|
||||
m_linDiscreteScalarMapper->setRange(adjustedMin, adjustedMax);
|
||||
m_logDiscreteScalarMapper->setRange(adjustedMin, adjustedMax);
|
||||
m_logSmoothScalarMapper->setRange(adjustedMin, adjustedMax);
|
||||
m_linSmoothScalarMapper->setRange(adjustedMin, adjustedMax);
|
||||
|
||||
@@ -173,26 +176,26 @@ void RimLegendConfig::updateLegend()
|
||||
{
|
||||
case NORMAL:
|
||||
{
|
||||
legendColors.reserve(5);
|
||||
legendColors.reserve(7);
|
||||
legendColors.add(cvf::Color3ub( 0, 0, 255));
|
||||
legendColors.add(cvf::Color3ub( 0, 127, 255));
|
||||
legendColors.add(cvf::Color3ub( 0, 255, 255));
|
||||
legendColors.add(cvf::Color3ub( 0, 255, 0));
|
||||
legendColors.add(cvf::Color3ub(255, 255, 0));
|
||||
legendColors.add(cvf::Color3ub(255, 127, 0));
|
||||
legendColors.add(cvf::Color3ub(255, 0, 0));
|
||||
|
||||
m_linDiscreteScalarMapper->setColors(cvf::ScalarMapper::NORMAL, m_numLevels);
|
||||
}
|
||||
break;
|
||||
case OPPOSITE_NORMAL:
|
||||
{
|
||||
legendColors.reserve(5);
|
||||
legendColors.reserve(7);
|
||||
legendColors.add(cvf::Color3ub(255, 0, 0));
|
||||
legendColors.add(cvf::Color3ub(255, 127, 0));
|
||||
legendColors.add(cvf::Color3ub(255, 255, 0));
|
||||
legendColors.add(cvf::Color3ub( 0, 255, 0));
|
||||
legendColors.add(cvf::Color3ub( 0, 255, 255));
|
||||
legendColors.add(cvf::Color3ub( 0, 127, 255));
|
||||
legendColors.add(cvf::Color3ub( 0, 0, 255));
|
||||
|
||||
m_linDiscreteScalarMapper->setColors(legendColors); // Todo: Change legend type to new
|
||||
}
|
||||
break; case BLACK_WHITE:
|
||||
case WHITE_BLACK:
|
||||
@@ -208,8 +211,6 @@ void RimLegendConfig::updateLegend()
|
||||
legendColors.add(cvf::Color3ub::WHITE);
|
||||
legendColors.add(cvf::Color3ub::BLACK);
|
||||
}
|
||||
cvf::ref<cvf::Color3ubArray> interpolated = interpolateColorArray(legendColors, m_numLevels);
|
||||
m_linDiscreteScalarMapper->setColors(*(interpolated.p()));
|
||||
}
|
||||
break;
|
||||
case PINK_WHITE:
|
||||
@@ -226,17 +227,19 @@ void RimLegendConfig::updateLegend()
|
||||
legendColors.add(cvf::Color3ub::WHITE);
|
||||
legendColors.add(cvf::Color3ub::DEEP_PINK);
|
||||
}
|
||||
cvf::ref<cvf::Color3ubArray> interpolated = interpolateColorArray(legendColors, m_numLevels);
|
||||
m_linDiscreteScalarMapper->setColors(*(interpolated.p()));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
m_linDiscreteScalarMapper->setColors(legendColors);
|
||||
m_logDiscreteScalarMapper->setColors(legendColors);
|
||||
m_logSmoothScalarMapper->setColors(legendColors);
|
||||
m_linSmoothScalarMapper->setColors(legendColors);
|
||||
|
||||
m_logSmoothScalarMapper->setMajorLevelCount(m_numLevels, true);
|
||||
m_linSmoothScalarMapper->setMajorLevelCount(m_numLevels, true);
|
||||
m_linDiscreteScalarMapper->setLevelCount(m_numLevels, true);
|
||||
m_logDiscreteScalarMapper->setLevelCount(m_numLevels, true);
|
||||
m_logSmoothScalarMapper->setLevelCount(m_numLevels, true);
|
||||
m_linSmoothScalarMapper->setLevelCount(m_numLevels, true);
|
||||
|
||||
switch(m_mappingMode())
|
||||
{
|
||||
@@ -249,9 +252,13 @@ void RimLegendConfig::updateLegend()
|
||||
case LOG10_CONTINUOUS:
|
||||
m_currentScalarMapper = m_logSmoothScalarMapper.p();
|
||||
break;
|
||||
case LOG10_DISCRETE:
|
||||
m_currentScalarMapper = m_logDiscreteScalarMapper.p();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
m_legend->setScalarMapper(m_currentScalarMapper.p());
|
||||
|
||||
|
||||
@@ -322,6 +329,7 @@ void RimLegendConfig::setColorRangeMode(ColorRangesType colorMode)
|
||||
updateLegend();
|
||||
}
|
||||
|
||||
/*
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -367,7 +375,7 @@ cvf::ref<cvf::Color3ubArray> RimLegendConfig::interpolateColorArray(const cvf::C
|
||||
|
||||
return colors;
|
||||
}
|
||||
|
||||
*/
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -387,7 +395,7 @@ void RimLegendConfig::recreateLegend()
|
||||
// the legend disappeared because of this, so workaround: recreate the legend when needed:
|
||||
|
||||
cvf::FixedAtlasFont* font = new cvf::FixedAtlasFont(cvf::FixedAtlasFont::STANDARD);
|
||||
m_legend = new cvf::OverlayColorLegend(font);
|
||||
m_legend = new cvf::OverlayScalarMapperLegend(font);
|
||||
|
||||
updateLegend();
|
||||
}
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
#include "cafAppEnum.h"
|
||||
#include "cvfScalarMapperContinuousLog.h"
|
||||
#include "cvfScalarMapperContinuousLinear.h"
|
||||
#include "cvfOverlayColorLegend.h"
|
||||
#include "cvfScalarMapperUniformLevels.h"
|
||||
#include "cvfOverlayScalarMapperLegend.h"
|
||||
#include "cvfScalarMapperDiscreteLinear.h"
|
||||
|
||||
class RimReservoirView;
|
||||
//==================================================================================================
|
||||
@@ -66,7 +66,8 @@ public:
|
||||
{
|
||||
LINEAR_DISCRETE,
|
||||
LINEAR_CONTINUOUS,
|
||||
LOG10_CONTINUOUS
|
||||
LOG10_CONTINUOUS,
|
||||
LOG10_DISCRETE
|
||||
};
|
||||
|
||||
typedef caf::AppEnum<MappingType> MappingEnum;
|
||||
@@ -76,7 +77,7 @@ public:
|
||||
void setPosition(cvf::Vec2ui position);
|
||||
|
||||
cvf::ScalarMapper* scalarMapper() { return m_currentScalarMapper.p(); }
|
||||
cvf::OverlayColorLegend* legend() { return m_legend.p(); }
|
||||
cvf::OverlayScalarMapperLegend* legend() { return m_legend.p(); }
|
||||
void updateLegend();
|
||||
|
||||
protected:
|
||||
@@ -90,12 +91,13 @@ private:
|
||||
private:
|
||||
caf::PdmPointer<RimReservoirView> m_reservoirView;
|
||||
|
||||
cvf::ref<cvf::ScalarMapperUniformLevels> m_linDiscreteScalarMapper;
|
||||
cvf::ref<cvf::ScalarMapperDiscreteLinear> m_linDiscreteScalarMapper;
|
||||
cvf::ref<cvf::ScalarMapperDiscreteLinear> m_logDiscreteScalarMapper;
|
||||
cvf::ref<cvf::ScalarMapperContinuousLog> m_logSmoothScalarMapper;
|
||||
cvf::ref<cvf::ScalarMapperContinuousLinear> m_linSmoothScalarMapper;
|
||||
cvf::ref<cvf::LegendScalarMapper> m_currentScalarMapper;
|
||||
cvf::ref<cvf::ScalarMapper> m_currentScalarMapper;
|
||||
|
||||
cvf::ref<cvf::OverlayColorLegend> m_legend;
|
||||
cvf::ref<cvf::OverlayScalarMapperLegend> m_legend;
|
||||
|
||||
double m_globalAutoMax;
|
||||
double m_globalAutoMin;
|
||||
|
||||
Reference in New Issue
Block a user