SeExpr
ExprColorCurve.h
Go to the documentation of this file.
1 /*
2 * Copyright Disney Enterprises, Inc. All rights reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License
6 * and the following modification to it: Section 6 Trademarks.
7 * deleted and replaced with:
8 *
9 * 6. Trademarks. This License does not grant permission to use the
10 * trade names, trademarks, service marks, or product names of the
11 * Licensor and its affiliates, except as required for reproducing
12 * the content of the NOTICE file.
13 *
14 * You may obtain a copy of the License at
15 * http://www.apache.org/licenses/LICENSE-2.0
16 *
17 * @file ExprColorCurve.h
18 * @brief Contains PyQt4 Ramp Widget to emulate Maya's ramp widget
19 * @author Arthur Shek
20 * @version ashek 05/04/09 Initial Version
21 */
22 #ifndef _ExprColorCurve_h_
23 #define _ExprColorCurve_h_
24 
25 
26 #include <vector>
27 
28 #include <QtCore/QObject>
29 #include <QtGui/QComboBox>
30 #include <QtGui/QGraphicsProxyWidget>
31 #include <QtGui/QGraphicsView>
32 #include <QtGui/QLineEdit>
33 
34 #include <SeExpr2/Vec.h>
35 
36 #include "ExprCurve.h"
37 
38 /*
39  This class overrides QGraphicsScene so we can handle mouse
40  press, drag and keyboard events
41 */
42 class CCurveScene : public QGraphicsScene
43 {
44  Q_OBJECT
45 
48 
49 public:
50  CCurveScene();
51  ~CCurveScene();
52 
53  void addPoint(double x, const SeExpr2::Vec3d y, const T_INTERP interp, const bool select=true);
54 
55  void removePoint(const int index);
56  void removeAll();
57 
58  virtual void keyPressEvent(QKeyEvent *event);
59 
60  virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent);
61  virtual void mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent);
62  virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent);
63  virtual void contextMenuEvent(QGraphicsSceneContextMenuEvent *event);
64  void drawRect();
65 
66  void drawPoints();
67 
68  QPixmap& getPixmap();
69  void emitCurveChanged();
70 
71  void rebuildCurve();
72 
73  std::vector<T_CURVE::CV> _cvs; // unsorted cvs
74 
75  friend class ExprColorCurve;
76 private:
78 public slots:
79  void interpChanged(const int interp);
80  void selPosChanged(double pos);
81  void selValChanged(const SeExpr2::Vec3d& val);
82  void resize(const int width, const int height);
83 
84 signals:
85  void cvSelected(double x, const SeExpr2::Vec3d y, const T_INTERP interp);
86  void curveChanged();
87 
88 private:
89  QByteArray getCPixmap();
90 
91  int _width;
92  int _height;
95  std::vector<QGraphicsEllipseItem *> _circleObjects;
97  QPixmap _pixmap;
99  QWidget *_baseRectW;
100  QGraphicsProxyWidget *_baseRect;
101  bool _lmb;
102 };
103 
104 
105 class ExprCBoxWidget : public QWidget
106 {
107  Q_OBJECT
108 public:
109  ExprCBoxWidget(CCurveScene* curveScene, QWidget* parent = 0) : QWidget(parent), _curveScene(curveScene) {}
111 
112 protected:
113  virtual void paintEvent(QPaintEvent* event);
114 
115 private:
117 };
118 
119 
120 class ExprCSwatchFrame : public QFrame
121 {
122  Q_OBJECT
123 public:
124  ExprCSwatchFrame(SeExpr2::Vec3d value, QWidget* parent = 0);
126 
127  void setValue(const SeExpr2::Vec3d &value);
128  SeExpr2::Vec3d getValue() const;
129 
130 protected:
131  virtual void paintEvent(QPaintEvent* event);
132  virtual void mousePressEvent(QMouseEvent* event);
133 
134 signals:
136  void swatchChanged(QColor color);
137 
138 private:
140  QColor _color;
141 };
142 
143 
144 class ExprColorCurve : public QWidget
145 {
146  Q_OBJECT
147 
150 
151 public:
152  ExprColorCurve(QWidget* parent = 0, QString pLabel = "", QString vLabel = "", QString iLabel = "",
153  bool expandable=true);
155 
156  // Convenience Functions
157  void addPoint(const double x, const SeExpr2::Vec3d y, const T_INTERP interp, bool select=false);
158  void setSwatchColor(QColor color);
159  QColor getSwatchColor();
160 
162 
163 public slots:
164  void cvSelectedSlot(const double pos, const SeExpr2::Vec3d val, const T_INTERP interp);
165  void selPosChanged();
166  void openDetail();
167 private slots:
168  void internalSwatchChanged(QColor color);
169 
170 signals:
171  void selPosChangedSignal(double pos);
173  void swatchChanged(QColor color);
174 
175 
176 private:
177  QLineEdit *_selPosEdit;
179  QComboBox *_interpComboBox;
180 };
181 #endif
182 
CCurveScene * _curveScene
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent)
void curveChanged()
virtual void mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent)
SeExpr2::Vec3d _color
ExprCSwatchFrame * _selValEdit
virtual void keyPressEvent(QKeyEvent *event)
void selValChanged(const SeExpr2::Vec3d &val)
Interpolation curve class for double-&gt;double and double-&gt;Vec3D.
Definition: Curve.h:38
T_CURVE::InterpType T_INTERP
void resize(const int width, const int height)
QComboBox * _interpComboBox
void rebuildCurve()
QLineEdit * _selPosEdit
std::vector< T_CURVE::CV > _cvs
void selValChangedSignal(SeExpr2::Vec3d value)
QPixmap _pixmap
QGraphicsProxyWidget * _baseRect
virtual void mousePressEvent(QMouseEvent *event)
void internalSwatchChanged(QColor color)
std::vector< QGraphicsEllipseItem * > _circleObjects
void addPoint(double x, const SeExpr2::Vec3d y, const T_INTERP interp, const bool select=true)
ExprCBoxWidget(CCurveScene *curveScene, QWidget *parent=0)
void selPosChangedSignal(double pos)
SeExpr2::Vec3d getValue() const
For any rgb or hsl value(except for negative s values)
void setValue(const SeExpr2::Vec3d &value)
virtual void paintEvent(QPaintEvent *event)
QPixmap & getPixmap()
The result is computed int int< br >< divstyle="margin-left:40px;"> Picks values randomly between loRange and hiRange based on supplied index(which is automatically hashed).&nbsp
ExprColorCurve(QWidget *parent=0, QString pLabel="", QString vLabel="", QString iLabel="", bool expandable=true)
SeExpr2::Curve< SeExpr2::Vec3d > T_CURVE
void removePoint(const int index)
SeExpr2::Curve< SeExpr2::Vec3d > T_CURVE
void selPosChanged(double pos)
QWidget * _baseRectW
T_INTERP _interp
CCurveScene * _scene
QColor getSwatchColor()
T_CURVE * _curve
void interpChanged(const int interp)
void cvSelectedSlot(const double pos, const SeExpr2::Vec3d val, const T_INTERP interp)
</pre >< h3 > A simple variable reference</h3 > This is not a very interesting subclass of expression until we add some additional variables Variables on some applications may be very dynamic In this we only need x
Definition: tutorial.txt:108
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent)
virtual void contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
void emitCurveChanged()
T_CURVE::InterpType T_INTERP
virtual void paintEvent(QPaintEvent *event)
void addPoint(const double x, const SeExpr2::Vec3d y, const T_INTERP interp, bool select=false)
void selValChangedSignal(SeExpr2::Vec3d val)
ExprCSwatchFrame(SeExpr2::Vec3d value, QWidget *parent=0)
void swatchChanged(QColor color)
InterpType
Supported interpolation types.
Definition: Curve.h:43
void cvSelected(double x, const SeExpr2::Vec3d y, const T_INTERP interp)
QByteArray getCPixmap()
void swatchChanged(QColor color)
This is the same as the prman cellnoise function< br ></div >< br > float< b > float y< br > float< b > float y
Definition: userdoc.txt:218
void setSwatchColor(QColor color)
SeExpr2::Vec3d _value