ColorMapSliceItem.cpp
Go to the documentation of this file.
1 #include "ColorMapSliceItem.h"
2 
3 // Qt
4 #include <QPainter>
5 
6 QIcon GetIcon(const QColor& beg, const QColor& end)
7 {
8  if(!end.isValid())
9  {
10  QPixmap pix(16, 16);
11  pix.fill(beg);
12  return QIcon(pix);
13  }
14 
15  QPixmap pix(16, 16);
16  QPainter p(&pix);
17 
18  p.fillRect(0, 0, 8, 16, beg);
19  p.fillRect(8, 0, 8, 16, end);
20 
21  return QIcon(pix);
22 }
23 
24 te::qt::widgets::ColorMapSliceItem::ColorMapSliceItem(const std::string& label, const QColor& beg, const QColor& end):
25 TreeItem("COLORMAPSLICE"),
26 m_label(label)
27 {
28  m_icon = GetIcon(beg, end);
29 }
30 
32 
34 {
35  return m_label;
36 }
37 
39 {
40  return Qt::ItemIsEnabled;
41 }
42 
44 {
45  return m_icon;
46 }
std::string m_label
Label to be presented on the Qt view.
Qt::ItemFlags flags()
Returns the flags to be used by the model.
Defines a hierarchical structure.
te::gm::Polygon * p
ColorMapSliceItem(const std::string &label, const QColor &beg, const QColor &end=QColor())
Constructor.
QIcon getIcon() const
Returns the icon to be presented in the tree.
std::string getAsString() const
Returns the label of the item to be presented in a Qt view.
A class that represents a slice of a ColorMapItem.
QIcon m_icon
Icon to be presented.
QIcon GetIcon(const QColor &beg, const QColor &end)