00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef _SeExprEdColorCurve_h_
00016 #define _SeExprEdColorCurve_h_
00017
00018
00019 #include <vector>
00020
00021 #include <QtCore/QObject>
00022 #include <QtGui/QComboBox>
00023 #include <QtGui/QGraphicsProxyWidget>
00024 #include <QtGui/QGraphicsView>
00025 #include <QtGui/QLineEdit>
00026
00027 #include <SeVec3d.h>
00028
00029 #include "SeExprEdCurve.h"
00030
00031
00032
00033
00034
00035 class CCurveScene : public QGraphicsScene
00036 {
00037 Q_OBJECT
00038
00039 typedef SeExpr::SeCurve<SeVec3d> T_CURVE;
00040 typedef T_CURVE::InterpType T_INTERP ;
00041
00042 public:
00043 CCurveScene();
00044 ~CCurveScene();
00045
00046 void addPoint(double x, const SeVec3d y, const T_INTERP interp, const bool select=true);
00047
00048 void removePoint(const int index);
00049 void removeAll();
00050
00051 virtual void keyPressEvent(QKeyEvent *event);
00052
00053 virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent);
00054 virtual void mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent);
00055 virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent);
00056
00057 void drawRect();
00058
00059 void drawPoints();
00060
00061 QPixmap& getPixmap();
00062 void emitCurveChanged();
00063
00064 void rebuildCurve();
00065
00066 std::vector<T_CURVE::CV> _cvs;
00067
00068 friend class SeExprEdColorCurve;
00069 private:
00070 T_CURVE* _curve;
00071 public slots:
00072 void interpChanged(const int interp);
00073 void selPosChanged(double pos);
00074 void selValChanged(const SeVec3d& val);
00075 void resize(const int width, const int height);
00076
00077 signals:
00078 void cvSelected(double x, const SeVec3d y, const T_INTERP interp);
00079 void curveChanged();
00080
00081 private:
00082 QByteArray getCPixmap();
00083
00084 int _width;
00085 int _height;
00086 SeVec3d _color;
00087 T_INTERP _interp;
00088 std::vector<QGraphicsEllipseItem *> _circleObjects;
00089 int _selectedItem;
00090 QPixmap _pixmap;
00091 bool _pixmapDirty;
00092 QWidget *_baseRectW;
00093 QGraphicsProxyWidget *_baseRect;
00094 bool _lmb;
00095 };
00096
00097
00098 class SeExprEdCBoxWidget : public QWidget
00099 {
00100 Q_OBJECT
00101 public:
00102 SeExprEdCBoxWidget(CCurveScene* curveScene, QWidget* parent = 0) : QWidget(parent), _curveScene(curveScene) {}
00103 ~SeExprEdCBoxWidget() {}
00104
00105 protected:
00106 virtual void paintEvent(QPaintEvent* event);
00107
00108 private:
00109 CCurveScene* _curveScene;
00110 };
00111
00112
00113 class SeExprEdCSwatchFrame : public QFrame
00114 {
00115 Q_OBJECT
00116 public:
00117 SeExprEdCSwatchFrame(SeVec3d value, QWidget* parent = 0);
00118 ~SeExprEdCSwatchFrame() {}
00119
00120 void setValue(const SeVec3d &value);
00121 SeVec3d getValue() const;
00122
00123 protected:
00124 virtual void paintEvent(QPaintEvent* event);
00125 virtual void mousePressEvent(QMouseEvent* event);
00126
00127 signals:
00128 void selValChangedSignal(SeVec3d value);
00129 void swatchChanged(QColor color);
00130
00131 private:
00132 SeVec3d _value;
00133 QColor _color;
00134 };
00135
00136
00137 class SeExprEdColorCurve : public QWidget
00138 {
00139 Q_OBJECT
00140
00141 typedef SeExpr::SeCurve<SeVec3d> T_CURVE;
00142 typedef T_CURVE::InterpType T_INTERP ;
00143
00144 public:
00145 SeExprEdColorCurve(QWidget* parent = 0, QString pLabel = "", QString vLabel = "", QString iLabel = "",
00146 bool expandable=true);
00147 ~SeExprEdColorCurve() {}
00148
00149
00150 void addPoint(const double x, const SeVec3d y, const T_INTERP interp, bool select=false);
00151 void setSwatchColor(QColor color);
00152 QColor getSwatchColor();
00153
00154 CCurveScene *_scene;
00155
00156 public slots:
00157 void cvSelectedSlot(const double pos, const SeVec3d val, const T_INTERP interp);
00158 void selPosChanged();
00159 void openDetail();
00160 private slots:
00161 void internalSwatchChanged(QColor color);
00162
00163 signals:
00164 void selPosChangedSignal(double pos);
00165 void selValChangedSignal(SeVec3d val);
00166 void swatchChanged(QColor color);
00167
00168
00169 private:
00170 QLineEdit *_selPosEdit;
00171 SeExprEdCSwatchFrame *_selValEdit;
00172 QComboBox *_interpComboBox;
00173 };
00174 #endif
00175