00001 #pragma once 00002 00003 #ifndef VIS_COLORCHOOSER 00004 #define VIS_COLORCHOOSER 00005 00006 #include <QtCore/QMap> 00007 #include <QtGui/QPixmap> 00008 #include <QtCore/QVector> 00009 #include <QtGui/QWidget> 00010 #include <QtGui/QPainter> 00011 #include <QtGui/QStylePainter> 00012 #include <QtGui/QMouseEvent> 00013 #include <QtGui/QKeyEvent> 00014 #include <vector> 00015 #include <cmath> 00016 00017 using namespace std; 00018 00022 class Vis_ColorChooser : public QWidget 00023 { 00024 00025 Q_OBJECT 00026 00027 public: 00028 00032 Vis_ColorChooser(QWidget* parent = 0); 00033 ~Vis_ColorChooser(void); 00034 00038 void setKnot (int label, QColor color); 00039 00040 protected: 00041 00042 void paintEvent(QPaintEvent * evt); 00043 void resizeEvent(QResizeEvent *evt); 00044 void mousePressEvent(QMouseEvent *evt); 00045 void mouseMoveEvent(QMouseEvent *evt); 00046 void mouseReleaseEvent(QMouseEvent *evt); 00047 void keyPressEvent(QKeyEvent *evt); 00048 00049 void paint(); 00050 void smallPaint(); 00051 00052 signals: 00053 void colorChanged(int label, QColor color); 00054 00055 private: 00056 00057 static const unsigned short borderSize = 10; 00058 static const float PI; 00059 static const float blueAxis; 00060 static const float redAxis; 00061 static const float greenAxis; 00062 00063 void updatePosAndColor (int x, int y); 00064 QColor calculateColor (int x, int y, int radius, int m_X, int m_Y); 00065 00066 bool mousePressed; 00067 QColor actColor; 00068 QPixmap pixmap; 00069 QPixmap staticMap; 00070 int label; 00071 float position[2]; 00072 }; 00073 00074 #endif 00075 00076