00001 #pragma once 00002 00003 #include "common.h" 00004 #include "HoverPoints.h" 00005 #include <QtGui/QWidget> 00006 00007 class ShadeWidget : public QWidget 00008 { 00009 Q_OBJECT 00010 public: 00011 enum ShadeType { 00012 RedShade, 00013 GreenShade, 00014 BlueShade, 00015 ARGBShade 00016 }; 00017 00018 ShadeWidget(ShadeType type, QWidget *parent, std::string name); 00019 00020 void setGradientStops(const QGradientStops &stops); 00021 QGradientStops getGradientStops() const {return m_alpha_gradient.stops(); } 00022 00023 void paintEvent(QPaintEvent *e); 00024 00025 QSize sizeHint() const { return QSize(150, 40); } 00026 00027 void setPoints(QPolygonF pts); 00028 QPolygonF points() const; 00029 00030 void setHistogram(const int*); 00031 void clearHistogram(); 00032 00033 std::string getName() const; 00034 00035 HoverPoints *hoverPoints() const { return m_hoverPoints; } 00036 00037 uint colorAt(int x); 00038 00039 signals: 00040 void colorsChanged(); 00041 00042 private: 00043 void generateShade(); 00044 00045 ShadeType m_shade_type; 00046 QImage m_shade; 00047 HoverPoints *m_hoverPoints; 00048 QLinearGradient m_alpha_gradient; 00049 std::string m_shadeName; 00050 00051 // Histogram dependent 00052 int densityArray[ DENSITY_COUNT ]; 00053 int maxDensityIndex; 00054 int* m_density; 00055 bool histogramVisible; 00056 00057 QPixmap* m_nohist; 00058 QPixmap* m_hist; 00059 };