27 #include "../../../../color/ColorBar.h"
28 #include "../../../../maptools/Utils.h"
29 #include "../../../../se/Categorize.h"
30 #include "../../../../se/ColorMap.h"
31 #include "../../../../se/Interpolate.h"
32 #include "../../../../se/InterpolationPoint.h"
37 #include <QtGui/QMenu>
38 #include <QtGui/QWidget>
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(
"Classification 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;
bool setData(int column, const QVariant &value, int role=Qt::EditRole)
They are used to define a graph of points.
TEMAPEXPORT double GetDouble(const te::se::ParameterValue *param)
Gets the parameter value as double.
int getGreen() const
It returns the green component color value (a value from 0 to 255).
te::map::AbstractLayerPtr getLayer() const
A ColorMap defines either the colors of a pallette-type raster source or the mapping of numeric pixel...
ColorMapItem(te::se::ColorMap *cm, QObject *parent=0)
void setColor(const std::string &hexColor)
It sets the color using a two hexadecimal RGB-encoded color.
void setCheckable(bool checkable)
A helper class for 32-bit RGBA (Red-Green-Blue-Alpha channel) color.
A class that represents a grouping item of a color map in a LayerTreeModel.
A class that represents a color map of rastersymbolizer of a layer in a LayerTreeModel.
TEMAPEXPORT std::string GetString(const te::se::ParameterValue *param)
Gets the parameter value as string.
The class that represents an item in a LayerTreeModel.
ParameterValue * getValue() const
QMenu * getMenu(QWidget *parent=0) const
Qt::ItemFlags flags() const
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
const std::string getItemType() const
It returns the item type: "COLORMAP_ITEM".
bool canFetchMore() const
int getBlue() const
It returns the blue component color value (a value from 0 to 255).
QVariant data(int column, int role) const
int getRed() const
It returns the red component color value (a value from 0 to 255).