00001 #ifndef WDGCOLORBAR_H
00002 #define WDGCOLORBAR_H
00003
00004 #include <QWidget>
00005 #include <QLabel>
00006 #include <QPainter>
00007 #include <QPixmap>
00008
00009 #include <Qt>
00010 #include <QtGui>
00011 #include <QtCore>
00012
00013 #include "PSQt/QGUtils.h"
00014 #include "ndarray/ndarray.h"
00015
00016 namespace PSQt {
00017
00018
00019
00020
00021
00022 enum ORIENT {HR=0, HL, VU, VD};
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056 class WdgColorBar : public QLabel
00057 {
00058 Q_OBJECT
00059
00060 public:
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071 WdgColorBar( QWidget *parent=0,
00072 const float& h1=260,
00073 const float& h2=-60,
00074 const unsigned& colors=1024,
00075 const ORIENT& orient=HR,
00076 const float& aspect=0.03);
00077
00078 virtual ~WdgColorBar();
00079
00080 void setStyle() ;
00081 void showTips() ;
00082
00083 void closeEvent (QCloseEvent *event = 0) ;
00084 void moveEvent (QMoveEvent *event = 0) ;
00085
00086 void setColorBar( const float& h1=0,
00087 const float& h2=360,
00088 const unsigned& colors=1024,
00089 const ORIENT& orient=HR,
00090 const float& aspect=0.03
00091 );
00092
00093 protected :
00094 void mousePressEvent (QMouseEvent *event = 0) ;
00095 void mouseReleaseEvent (QMouseEvent *event = 0) ;
00096 void mouseMoveEvent (QMouseEvent *event = 0) ;
00097 void resizeEvent (QResizeEvent *event = 0) ;
00098
00099 signals :
00100
00101
00102
00103
00104
00105 void pressColorBar(QMouseEvent*, const float&) ;
00106 void releaseColorBar(QMouseEvent*, const float&) ;
00107 void moveOnColorBar(QMouseEvent*, const float&) ;
00108
00109 public slots:
00110 void onHueAnglesUpdated(const float&, const float&) ;
00111 void testPressColorBar(QMouseEvent*, const float&) ;
00112 void testReleaseColorBar(QMouseEvent*, const float&) ;
00113 void testMoveOnColorBar(QMouseEvent*, const float&) ;
00114
00115 private:
00116 float m_h1;
00117 float m_h2;
00118 unsigned m_colors;
00119 ORIENT m_orient;
00120 float m_aspect;
00121
00122 QLabel* m_lab_cbar;
00123 QPixmap* m_pixmap_cbar;
00124
00125 inline const char* _name_(){return "WdgColorBar";}
00126 float fractionOfColorBar(QMouseEvent *e);
00127 void connectForTest();
00128 void message(QMouseEvent* e, const float& frac, const char* comment);
00129 };
00130
00131 }
00132
00133 #endif // WDGCOLORBAR_H