00001 00007 #ifndef PALETTE_H 00008 #define PALETTE_H 00009 00010 #include <QtGui/qwidget.h> 00011 00012 enum COLOR_TABLE {BW=0, COLOR, NB_PAL}; 00013 00014 class QMenu; 00015 class QColor; 00016 00020 class Palette : public QWidget 00021 { 00022 Q_OBJECT 00023 00024 public: 00028 Palette(QWidget *parent=0); 00029 00030 virtual ~Palette(); 00031 00032 protected: 00033 00035 int m_idxPal; 00036 00038 int m_vMin; 00039 00041 int m_vMax; 00042 00044 float m_fact; 00045 00047 int m_dataMin; 00048 00050 int m_dataMax; 00051 00053 QMenu *m_menuPalette; 00054 00056 QMenu *m_menuColors; 00057 00059 QMenu *m_menuLinLog; 00060 00062 bool m_isLogScale; 00063 00064 signals: 00067 void PaletteModified(); 00068 00069 public slots: 00070 00073 void SelectBW(); 00074 00077 void SelectColor(); 00078 00081 void SelectLinear(); 00082 00085 void SelectLogarithmic(); 00086 00089 void AdjustScale(); 00090 00093 void AdjustAutoScale(); 00094 00095 protected: 00096 00099 void paintEvent(QPaintEvent *); 00100 00103 void paintPalette(QPainter *p); 00104 00107 void CreatePaletteMenu(); 00108 00111 void mousePressEvent(QMouseEvent *e); 00112 00115 void AdjustScaleFactor(); 00116 00120 void ChangePalette(int iPal); 00121 00124 void ChangeLinLog(bool); 00125 00129 int GetPalIndex(int i) const; 00130 00131 public: 00132 00136 QColor GetColor(int i) const ; 00137 00140 int GetPal() const ; 00141 00144 int GetMin() const ; 00145 00148 int GetMax() const ; 00149 00152 bool IsLogScale() const ; 00153 00156 QMenu* GetMenu() const ; 00157 00162 void ChangeDataMinMax(int min, int max); 00163 00168 void ChangeExtrema(int vMin, int vMax); 00169 00174 int DataToIndex(int val); 00175 }; 00176 00177 #endif //