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 #include <vector>
26
27 #include <QObject>
28 #include <QComboBox>
29 #include <QGraphicsProxyWidget>
30 #include <QGraphicsView>
31 #include <QLineEdit>
32
33 #include "../Vec.h"
34 #include "ExprCurve.h"
35
36 /*
37 This class overrides QGraphicsScene so we can handle mouse
38 press, drag and keyboard events
39 */
40 class CCurveScene : public QGraphicsScene {
41 Q_OBJECT
42
43 typedef SeExpr2::Curve<SeExpr2::Vec3d> T_CURVE;
44 typedef T_CURVE::InterpType T_INTERP;
45
46 public:
47 CCurveScene();
48 ~CCurveScene();
49
50 void addPoint(double x, const SeExpr2::Vec3d y, const T_INTERP interp, const bool select = true);
51
52 void removePoint(const int index);
53 void removeAll();
54
55 virtual void keyPressEvent(QKeyEvent *event);
56
57 virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent);
58 virtual void mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent);
59 virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent);
60 virtual void contextMenuEvent(QGraphicsSceneContextMenuEvent *event);
61 void drawRect();
62
63 void drawPoints();
64
65 QPixmap &getPixmap();
66 void emitCurveChanged();
67
68 void rebuildCurve();
69
70 std::vector<T_CURVE::CV> _cvs; // unsorted cvs
71
72 friend class ExprColorCurve;
73
74 public slots:
75 void interpChanged(const int interp);
76 void selPosChanged(double pos);
77 void selValChanged(const SeExpr2::Vec3d &val);
78 void resize(const int width, const int height);
79
80 signals:
81 void cvSelected(double x, const SeExpr2::Vec3d y, const T_INTERP interp);
82 void curveChanged();
83
84 private:
85 T_CURVE *_curve;
86
87 QByteArray getCPixmap();
88
89 int _width;
90 int _height;
91 SeExpr2::Vec3d _color;
92 T_INTERP _interp;
93 std::vector<QGraphicsEllipseItem *> _circleObjects;
94 int _selectedItem;
95 QPixmap _pixmap;
96 bool _pixmapDirty;
97 QWidget *_baseRectW;
98 QGraphicsProxyWidget *_baseRect;
99 bool _lmb;
100 };
101
102 class ExprCBoxWidget : public QWidget {
103 Q_OBJECT
104 public:
105 ExprCBoxWidget(CCurveScene *curveScene, QWidget *parent = 0) : QWidget(parent), _curveScene(curveScene) {}
106 ~ExprCBoxWidget() {}
107
108 protected:
109 virtual void paintEvent(QPaintEvent *event);
110
111 private:
112 CCurveScene *_curveScene;
113 };
114
115 class ExprCSwatchFrame : public QFrame {
116 Q_OBJECT
117 public:
118 ExprCSwatchFrame(SeExpr2::Vec3d value, QWidget *parent = 0);
119 ~ExprCSwatchFrame() {}
120
121 void setValue(const SeExpr2::Vec3d &value);
122 SeExpr2::Vec3d getValue() const;
123
124 protected:
125 virtual void paintEvent(QPaintEvent *event);
126 virtual void mousePressEvent(QMouseEvent *event);
127
128 signals:
129 void selValChangedSignal(SeExpr2::Vec3d value);
130 void swatchChanged(QColor color);
131
132 private:
133 SeExpr2::Vec3d _value;
134 QColor _color;
135 };
136
137 class ExprColorCurve : public QWidget {
138 Q_OBJECT
139
140 typedef SeExpr2::Curve<SeExpr2::Vec3d> T_CURVE;
141 typedef T_CURVE::InterpType T_INTERP;
142
143 public:
144 ExprColorCurve(QWidget *parent = 0,
145 QString pLabel = "",
146 QString vLabel = "",
147 QString iLabel = "",
148 bool expandable = true);
149 ~ExprColorCurve() {}
150
151 // Convenience Functions
152 void addPoint(const double x, const SeExpr2::Vec3d y, const T_INTERP interp, bool select = false);
153 void setSwatchColor(QColor color);
154 QColor getSwatchColor();
155
156 CCurveScene *_scene;
157
158 public slots:
159 void cvSelectedSlot(const double pos, const SeExpr2::Vec3d val, const T_INTERP interp);
160 void selPosChanged();
161 void openDetail();
162
163 signals:
164 void selPosChangedSignal(double pos);
165 void selValChangedSignal(SeExpr2::Vec3d val);
166 void swatchChanged(QColor color);
167
168 private slots:
169 void internalSwatchChanged(QColor color);
170
171 private:
172 QLineEdit *_selPosEdit;
173 ExprCSwatchFrame *_selValEdit;
174 QComboBox *_interpComboBox;
175 };
176 #endif
ExprColorCurve::cvSelectedSlot
void cvSelectedSlot(const double pos, const SeExpr2::Vec3d val, const T_INTERP interp)
Definition: ExprColorCurve.cpp:467
ExprColorCurve::_selValEdit
ExprCSwatchFrame * _selValEdit
Definition: ExprColorCurve.h:173
ExprColorCurve
Definition: ExprColorCurve.h:137
ExprColorCurve::_selPosEdit
QLineEdit * _selPosEdit
Definition: ExprColorCurve.h:172
index
The result is computed int int< br >< div style="margin-left: 40px;"> Picks values randomly between loRange and hiRange based on supplied index(which is automatically hashed). &nbsp
ExprColorCurve::ExprColorCurve
ExprColorCurve(QWidget *parent=0, QString pLabel="", QString vLabel="", QString iLabel="", bool expandable=true)
Definition: ExprColorCurve.cpp:346
CCurveScene::getCPixmap
QByteArray getCPixmap()
Definition: ExprColorCurve.cpp:227
ExprColorCurve::~ExprColorCurve
~ExprColorCurve()
Definition: ExprColorCurve.h:149
ExprCurve.h
ExprColorCurve::swatchChanged
void swatchChanged(QColor color)
CCurveScene::curveChanged
void curveChanged()
CCurveScene::_selectedItem
int _selectedItem
Definition: ExprColorCurve.h:94
CCurveScene::_lmb
bool _lmb
Definition: ExprColorCurve.h:99
SeExpr2::Vec< double, 3, false >
CCurveScene::keyPressEvent
virtual void keyPressEvent(QKeyEvent *event)
Definition: ExprColorCurve.cpp:100
CCurveScene::addPoint
void addPoint(double x, const SeExpr2::Vec3d y, const T_INTERP interp, const bool select=true)
Definition: ExprColorCurve.cpp:70
CCurveScene
Definition: ExprColorCurve.h:40
CCurveScene::T_INTERP
T_CURVE::InterpType T_INTERP
Definition: ExprColorCurve.h:44
CCurveScene::mousePressEvent
virtual void mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent)
Definition: ExprColorCurve.cpp:107
CCurveScene::rebuildCurve
void rebuildCurve()
Definition: ExprColorCurve.cpp:63
CCurveScene::selValChanged
void selValChanged(const SeExpr2::Vec3d &val)
Definition: ExprColorCurve.cpp:201
CCurveScene::_pixmap
QPixmap _pixmap
Definition: ExprColorCurve.h:95
CCurveScene::_baseRect
QGraphicsProxyWidget * _baseRect
Definition: ExprColorCurve.h:98
CCurveScene::resize
void resize(const int width, const int height)
Definition: ExprColorCurve.cpp:52
ExprCSwatchFrame::paintEvent
virtual void paintEvent(QPaintEvent *event)
Definition: ExprColorCurve.cpp:309
ExprCSwatchFrame::getValue
SeExpr2::Vec3d getValue() const
Definition: ExprColorCurve.cpp:326
CCurveScene::_cvs
std::vector< T_CURVE::CV > _cvs
Definition: ExprColorCurve.h:70
ExprCBoxWidget
Definition: ExprColorCurve.h:102
CCurveScene::_circleObjects
std::vector< QGraphicsEllipseItem * > _circleObjects
Definition: ExprColorCurve.h:93
ExprColorCurve::_scene
CCurveScene * _scene
Definition: ExprColorCurve.h:156
CCurveScene::_pixmapDirty
bool _pixmapDirty
Definition: ExprColorCurve.h:96
CCurveScene::~CCurveScene
~CCurveScene()
Definition: ExprColorCurve.cpp:50
ExprColorCurve::_interpComboBox
QComboBox * _interpComboBox
Definition: ExprColorCurve.h:174
y
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
ExprColorCurve::getSwatchColor
QColor getSwatchColor()
Definition: ExprColorCurve.cpp:495
CCurveScene::_interp
T_INTERP _interp
Definition: ExprColorCurve.h:92
ExprCSwatchFrame::ExprCSwatchFrame
ExprCSwatchFrame(SeExpr2::Vec3d value, QWidget *parent=0)
Definition: ExprColorCurve.cpp:315
ExprCSwatchFrame
Definition: ExprColorCurve.h:115
CCurveScene::_width
int _width
Definition: ExprColorCurve.h:89
ExprCSwatchFrame::_color
QColor _color
Definition: ExprColorCurve.h:134
ExprCBoxWidget::ExprCBoxWidget
ExprCBoxWidget(CCurveScene *curveScene, QWidget *parent=0)
Definition: ExprColorCurve.h:105
CCurveScene::interpChanged
void interpChanged(const int interp)
Definition: ExprColorCurve.cpp:176
CCurveScene::T_CURVE
SeExpr2::Curve< SeExpr2::Vec3d > T_CURVE
Definition: ExprColorCurve.h:43
CCurveScene::selPosChanged
void selPosChanged(double pos)
Definition: ExprColorCurve.cpp:188
ExprCBoxWidget::paintEvent
virtual void paintEvent(QPaintEvent *event)
Definition: ExprColorCurve.cpp:303
SeExpr2::Curve
Interpolation curve class for double->double and double->Vec3D.
Definition: Curve.h:38
CCurveScene::contextMenuEvent
virtual void contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
Definition: ExprColorCurve.cpp:161
CCurveScene::_curve
T_CURVE * _curve
Definition: ExprColorCurve.h:85
ExprCSwatchFrame::_value
SeExpr2::Vec3d _value
Definition: ExprColorCurve.h:133
ExprColorCurve::openDetail
void openDetail()
Definition: ExprColorCurve.cpp:502
CCurveScene::_height
int _height
Definition: ExprColorCurve.h:90
ExprCSwatchFrame::swatchChanged
void swatchChanged(QColor color)
ExprColorCurve::addPoint
void addPoint(const double x, const SeExpr2::Vec3d y, const T_INTERP interp, bool select=false)
Definition: ExprColorCurve.cpp:485
ExprCSwatchFrame::selValChangedSignal
void selValChangedSignal(SeExpr2::Vec3d value)
CCurveScene::removePoint
void removePoint(const int index)
Definition: ExprColorCurve.cpp:87
ExprColorCurve::T_INTERP
T_CURVE::InterpType T_INTERP
Definition: ExprColorCurve.h:141
CCurveScene::getPixmap
QPixmap & getPixmap()
Definition: ExprColorCurve.cpp:216
CCurveScene::mouseMoveEvent
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent)
Definition: ExprColorCurve.cpp:144
ExprCSwatchFrame::mousePressEvent
virtual void mousePressEvent(QMouseEvent *event)
Definition: ExprColorCurve.cpp:328
CCurveScene::emitCurveChanged
void emitCurveChanged()
Definition: ExprColorCurve.cpp:214
value
For any rgb or hsl value(except for negative s values)
ExprCSwatchFrame::~ExprCSwatchFrame
~ExprCSwatchFrame()
Definition: ExprColorCurve.h:119
ExprColorCurve::selPosChanged
void selPosChanged()
Definition: ExprColorCurve.cpp:479
ExprColorCurve::selPosChangedSignal
void selPosChangedSignal(double pos)
CCurveScene::_baseRectW
QWidget * _baseRectW
Definition: ExprColorCurve.h:97
CCurveScene::drawRect
void drawRect()
Definition: ExprColorCurve.cpp:263
CCurveScene::CCurveScene
CCurveScene()
Definition: ExprColorCurve.cpp:43
CCurveScene::cvSelected
void cvSelected(double x, const SeExpr2::Vec3d y, const T_INTERP interp)
ExprCBoxWidget::_curveScene
CCurveScene * _curveScene
Definition: ExprColorCurve.h:112
ExprCBoxWidget::~ExprCBoxWidget
~ExprCBoxWidget()
Definition: ExprColorCurve.h:106
CCurveScene::removeAll
void removeAll()
Definition: ExprColorCurve.cpp:98
ExprColorCurve::selValChangedSignal
void selValChangedSignal(SeExpr2::Vec3d val)
CCurveScene::mouseReleaseEvent
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent)
Definition: ExprColorCurve.cpp:170
CCurveScene::drawPoints
void drawPoints()
Definition: ExprColorCurve.cpp:276
SeExpr2::Curve::InterpType
InterpType
Supported interpolation types.
Definition: Curve.h:43
CCurveScene::_color
SeExpr2::Vec3d _color
Definition: ExprColorCurve.h:91
x
</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
ExprColorCurve::T_CURVE
SeExpr2::Curve< SeExpr2::Vec3d > T_CURVE
Definition: ExprColorCurve.h:140
ExprCSwatchFrame::setValue
void setValue(const SeExpr2::Vec3d &value)
Definition: ExprColorCurve.cpp:319
ExprColorCurve::internalSwatchChanged
void internalSwatchChanged(QColor color)
Definition: ExprColorCurve.cpp:500
ExprColorCurve::setSwatchColor
void setSwatchColor(QColor color)
Definition: ExprColorCurve.cpp:489