(#805) Added category legend and mapper

This commit is contained in:
Magne Sjaastad
2016-08-02 10:25:55 +02:00
parent 3abd849230
commit 1101db5787
12 changed files with 1119 additions and 29 deletions

View File

@@ -21,13 +21,10 @@
#pragma once
#include "cvfBase.h"
#include "cvfObject.h"
#include "cvfVector2.h"
#include "cvfArray.h"
#include "cafPdmObject.h"
#include "cafPdmField.h"
#include "cafPdmPointer.h"
#include "cafAppEnum.h"
namespace cvf
{
@@ -38,6 +35,13 @@ namespace cvf
class ScalarMapperDiscreteLinear;
class ScalarMapperDiscreteLog;
class ScalarMapper;
class String;
}
namespace caf
{
class CategoryLegend;
class CategoryMapper;
}
class RimView;
@@ -75,7 +79,8 @@ public:
WHITE_BLACK,
BLACK_WHITE,
BLUE_WHITE_RED,
RED_WHITE_BLUE
RED_WHITE_BLUE,
CATEGORY
};
typedef caf::AppEnum<ColorRangesType> ColorRangeEnum;
@@ -85,7 +90,8 @@ public:
LINEAR_DISCRETE,
LINEAR_CONTINUOUS,
LOG10_CONTINUOUS,
LOG10_DISCRETE
LOG10_DISCRETE,
CATEGORY_INTEGER
};
enum NumberFormatType { AUTO, SCIENTIFIC, FIXED};
@@ -94,6 +100,9 @@ public:
void setColorRangeMode(ColorRangesType colorMode);
void setAutomaticRanges(double globalMin, double globalMax, double localMin, double localMax);
void setClosestToZeroValues(double globalPosClosestToZero, double globalNegClosestToZero, double localPosClosestToZero, double localNegClosestToZero);
void setCategories(const std::set<int>& globalCategories, const std::set<int>& localCategories);
void setTitle(const cvf::String& title);
cvf::ScalarMapper* scalarMapper() { return m_currentScalarMapper.p(); }
cvf::OverlayItem* legend();
@@ -103,6 +112,8 @@ protected:
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue);
virtual void initAfterRead();
virtual void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering );
virtual QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly);
private:
void updateLegend();
void updateFieldVisibility();
@@ -120,6 +131,9 @@ private:
cvf::ref<cvf::ScalarMapper> m_currentScalarMapper;
cvf::ref<cvf::OverlayScalarMapperLegend> m_scalarMapperLegend;
cvf::ref<caf::CategoryMapper> m_categoryMapper;
cvf::ref<caf::CategoryLegend> m_categoryLegend;
double m_globalAutoMax;
double m_globalAutoMin;
@@ -131,6 +145,9 @@ private:
double m_localAutoPosClosestToZero;
double m_localAutoNegClosestToZero;
cvf::IntArray m_globalCategories;
cvf::IntArray m_localCategories;
// Fields
caf::PdmField<int> m_numLevels;
caf::PdmField<int> m_precision;
@@ -140,5 +157,4 @@ private:
caf::PdmField<double> m_userDefinedMinValue;
caf::PdmField<caf::AppEnum<ColorRangesType> > m_colorRangeMode;
caf::PdmField<caf::AppEnum<MappingType> > m_mappingMode;
};