27 #include "../../../../color/ColorBar.h"
28 #include "../../../../se/Categorize.h"
29 #include "../../../../se/ColorMap.h"
30 #include "../../../../se/Interpolate.h"
31 #include "../../../../se/InterpolationPoint.h"
32 #include "../../../../se/Utils.h"
59 if(role == Qt::DecorationRole)
60 return QVariant(QIcon::fromTheme(
"grouping"));
62 if(role == Qt::DisplayRole)
66 if(m_colorMap->getCategorize())
68 type = tr(
"Categorization");
70 else if(m_colorMap->getInterpolate())
72 type = tr(
"Interpolation");
75 QString text = tr(
"Legend by") +
" " + type;
76 return QVariant(text);
79 if(role == Qt::CheckStateRole && m_isCheckable)
80 return QVariant(m_isChecked ? Qt::Checked : Qt::Unchecked);
92 return (m_colorMap->getCategorize() || m_colorMap->getInterpolate()) && children().isEmpty();
97 return (m_isCheckable ? (Qt::ItemIsEnabled | Qt::ItemIsUserCheckable) : Qt::ItemIsEnabled);
102 if(!children().isEmpty())
105 if(m_colorMap->getCategorize())
107 std::vector<te::se::ParameterValue*> t = m_colorMap->getCategorize()->getThresholds();
108 std::vector<te::se::ParameterValue*> tV = m_colorMap->getCategorize()->getThresholdValues();
110 for(std::size_t i = 1; i < tV.size() - 1; ++i)
112 double lowerLimit, upperLimit;
116 lowerLimit = std::numeric_limits<double>::min();
119 else if(i == tV.size() - 1)
122 upperLimit = std::numeric_limits<double>::max();
137 else if(m_colorMap->getInterpolate())
139 std::vector<te::se::InterpolationPoint*> ip = m_colorMap->getInterpolate()->getInterpolationPoints();
141 for(std::size_t i = 0; i < ip.size() - 1; ++i)
147 colorInit.setColor(colorInit.getRed(), colorInit.getGreen(), colorInit.getBlue());
148 double lowerLimit = ipItemInit->
getData();
154 colorEnd.setColor(colorEnd.getRed(), colorEnd.getGreen(), colorEnd.getBlue());
155 double upperLimit = ipItemEnd->
getData();
164 if(m_colorMap->getCategorize())
166 return !m_colorMap->getCategorize()->getThresholdValues().empty();
169 if(m_colorMap->getInterpolate())
171 return !m_colorMap->getInterpolate()->getInterpolationPoints().empty();
179 if(role == Qt::CheckStateRole && m_isCheckable)
182 Qt::CheckState checkState =
static_cast<Qt::CheckState
>(value.toInt(&ok));
187 m_isChecked = (checkState == Qt::Checked ?
true :
false);
202 return "COLORMAP_ITEM";
207 m_isCheckable =
false;
ParameterValue * getValue() const
void setColor(const std::string &hexColor)
It sets the color using a two hexadecimal RGB-encoded color.
int getRed() const
It returns the red component color value (a value from 0 to 255).
int getBlue() const
It returns the blue component color value (a value from 0 to 255).
int getGreen() const
It returns the green component color value (a value from 0 to 255).
TESEEXPORT double GetDouble(const te::se::ParameterValue *param)
It gets the parameter value as a double.
They are used to define a graph of points.
A helper class for 32-bit RGBA (Red-Green-Blue-Alpha channel) color.
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
A class that represents a grouping item of a color map in a LayerTreeModel.
TESEEXPORT std::string GetString(const te::se::ParameterValue *param)
It gets the parameter value as a string.
A ColorMap defines either the colors of a pallette-type raster source or the mapping of numeric pixel...
A class that represents a color map of rastersymbolizer of a layer in a LayerTreeModel.