SeExpr
ExprControl.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#ifndef _ExprControl_h_
18#define _ExprControl_h_
19#include <QTextBrowser>
20#include <QPlainTextEdit>
21#include <QDialog>
22#include <QTimer>
23#include <QRegExp>
24#include <QLineEdit>
25#include <QCheckBox>
26#include <QSlider>
27
28#include "ExprCurve.h"
29#include "ExprColorCurve.h"
30#include "ExprDeepWater.h"
31
32class QLabel;
33class ExprColorCurve;
34class QHBoxLayout;
36class Editable;
37class StringEditable;
38class VectorEditable;
39class NumberEditable;
43template <class TVAL>
48
49namespace animlib {
50class AnimCurve;
51}
52
54class ExprControl : public QWidget {
55 Q_OBJECT;
56
57 protected:
58 int _id;
59 bool _updating; // whether to send events (i.e. masked when self editing)
60 QHBoxLayout* hbox;
61 QCheckBox* _colorLinkCB;
62 QLabel* _label;
63
65
66 public:
67 ExprControl(int id, Editable* editable, bool showColorLink);
68 virtual ~ExprControl() {}
69
71 virtual QColor getColor() { return QColor(); }
73 virtual void setColor(QColor color) {Q_UNUSED(color)};
74
75signals:
76 // sends that the control has been changed to the control collection
77 void controlChanged(int id);
78 // sends the new color to the control collection
79 void linkColorEdited(int id, QColor color);
80 // sends that a color link is desired to the control collection
81 void linkColorLink(int id);
82 public
83slots:
84 // receives that the link should be changed to the given state (0=off,1=on)
85 void linkStateChange(int state);
86
87 public:
88 // notifies this that the link should be disconnected
89 void linkDisconnect(int newId);
90};
91
93template <class T, class T2, class T3>
94T clamp(const T val, const T2 minval, const T3 maxval) {
95 if (val < minval)
96 return minval;
97 else if (val > maxval)
98 return maxval;
99 return val;
100}
101
103// TODO: can this now be removed?
104class ExprLineEdit : public QLineEdit {
105 Q_OBJECT
106 public:
107 ExprLineEdit(int id, QWidget* parent);
108 virtual void setText(const QString& t) {
109 if (_signaling) return;
110 QLineEdit::setText(t);
111 }
112
113signals:
114 void textChanged(int id, const QString& text);
115
116 private
117slots:
118 void textChangedCB(const QString& text);
119
120 private:
121 int _id;
123};
124
126class ExprSlider : public QSlider {
127 Q_OBJECT
128 public:
129 ExprSlider(QWidget* parent = 0) : QSlider(parent) {}
130 ExprSlider(Qt::Orientation orientation, QWidget* parent = 0) : QSlider(orientation, parent) {}
131 virtual void mousePressEvent(QMouseEvent* e);
132 virtual void mouseMoveEvent(QMouseEvent* e);
133 virtual void paintEvent(QPaintEvent* e);
134 virtual void leaveEvent(QEvent* event) {
135 Q_UNUSED(event);
136 update();
137 }
138 virtual void enterEvent(QEvent* event) {
139 Q_UNUSED(event);
140 update();
141 }
142 virtual void wheelEvent(QWheelEvent* e) { e->ignore(); }
143};
144
146class ExprChannelSlider : public QWidget {
147 Q_OBJECT
148 public:
149 ExprChannelSlider(int id, QWidget* parent);
150 virtual void paintEvent(QPaintEvent* e);
151 virtual void mousePressEvent(QMouseEvent* e);
152 virtual void mouseMoveEvent(QMouseEvent* e);
153 virtual void wheelEvent(QWheelEvent* e) { e->ignore(); }
154 float value() const { return _value; }
155 void setDisplayColor(QColor c) { _col = c; }
156
157 public
158slots:
159 void setValue(float value);
160
161signals:
162 void valueChanged(int id, float value);
163
164 private:
165 int _id;
166 float _value;
167 QColor _col;
168};
169
172 Q_OBJECT
173
180
181 public:
182 NumberControl(int id, NumberEditable* number);
183
184 private:
186 void setValue(float value);
188 void updateControl();
189 private
190slots:
191 void sliderChanged(int val);
192 void editChanged(int id, const QString& text);
193};
194
197 Q_OBJECT
198
204 ;
207
208 public:
209 VectorControl(int id, VectorEditable* number);
210
211 QColor getColor();
212 void setColor(QColor color);
213
214 private:
216 void setValue(int id, float value);
218 void updateControl();
219 private
220slots:
221 void sliderChanged(int id, float val);
222 void editChanged(int id, const QString& text);
223 void swatchChanged(QColor color);
224};
225
228 Q_OBJECT
229
233 QLineEdit* _edit;
234
235 public:
236 StringControl(int id, StringEditable* stringEditable);
237
238 private:
239 void updateControl();
240 private
241slots:
242 void textChanged(const QString& newText);
243 void fileBrowse();
244 void directoryBrowse();
245};
246
248class CurveControl : public ExprControl {
249 Q_OBJECT
250
255
256 public:
257 CurveControl(int id, CurveEditable* stringEditable);
258 private
259slots:
260 void curveChanged();
261};
262
265 Q_OBJECT
266
271
272 public:
273 CCurveControl(int id, ColorCurveEditable* stringEditable);
274 QColor getColor();
275 void setColor(QColor color);
276 private
277slots:
278 void curveChanged();
279};
280
282class ExprGraphPreview;
284 Q_OBJECT;
285
288
289 public:
290 AnimCurveControl(int id, AnimCurveEditable* curveEditable);
291 typedef void (*AnimCurveCallback)(const std::string&, animlib::AnimCurve& curve);
293
294 public
295slots:
296 void editGraphClicked();
297
298 private
299slots:
300 void refreshClicked();
301
302 private:
304};
305
308 Q_OBJECT
309
314
315 public:
316 ColorSwatchControl(int id, ColorSwatchEditable* swatchEditable);
317 private
318slots:
319 void buildSwatchWidget();
322 void colorRemoved(int index);
323
324 private:
326};
327
330 Q_OBJECT
331
336
337 public:
338 DeepWaterControl(int id, DeepWaterEditable* stringEditable);
339 private
340slots:
341 void deepWaterChanged();
342};
343
344#endif
GenericCurveEditable< SeExpr2::Vec3d > ColorCurveEditable
Definition ExprControl.h:45
GenericCurveEditable< double > CurveEditable
Definition ExprControl.h:46
T clamp(const T val, const T2 minval, const T3 maxval)
clamp val to the specified range [minval,maxval]
Definition ExprControl.h:94
static AnimCurveCallback callback
AnimCurveEditable * _editable
static void setAnimCurveCallback(AnimCurveCallback callback)
void(*) AnimCurveCallback(const std::string &, animlib::AnimCurve &curve)
AnimCurveControl(int id, AnimCurveEditable *curveEditable)
ExprGraphPreview * _preview
Control for editing a color ramp curve.
CCurveControl(int id, ColorCurveEditable *stringEditable)
void setColor(QColor color)
Interface for setting the color (used for linked color picking)
QColor getColor()
Interface for getting the color (used for linked color picking)
ColorCurveEditable * _curveEditable
color curve model
ExprColorCurve * _curve
color curve widget
A control for editing color swatches.
void colorRemoved(int index)
ColorSwatchEditable * _swatchEditable
model for the color swatches control
ExprColorSwatchWidget * _swatch
Edit box for the color swatches.
void colorAdded(int index, SeExpr2::Vec3d value)
void colorChanged(int index, SeExpr2::Vec3d value)
ColorSwatchControl(int id, ColorSwatchEditable *swatchEditable)
Control for editing a normal curve ramp.
void curveChanged()
CurveControl(int id, CurveEditable *stringEditable)
ExprCurve * _curve
curve edit widget
CurveEditable * _curveEditable
curve model
Control for displaying a deep water spectrum.
DeepWaterControl(int id, DeepWaterEditable *stringEditable)
ExprDeepWater * _deepWater
deep water widget
DeepWaterEditable * _deepWaterEditable
curve model
Channel Slider (i.e. for colors)
virtual void wheelEvent(QWheelEvent *e)
void valueChanged(int id, float value)
void setValue(float value)
float value() const
ExprChannelSlider(int id, QWidget *parent)
virtual void mousePressEvent(QMouseEvent *e)
void setDisplayColor(QColor c)
virtual void paintEvent(QPaintEvent *e)
virtual void mouseMoveEvent(QMouseEvent *e)
Base class for all controls for Expressions.
Definition ExprControl.h:54
QCheckBox * _colorLinkCB
Definition ExprControl.h:61
Editable * _editable
Definition ExprControl.h:64
QHBoxLayout * hbox
Definition ExprControl.h:60
virtual QColor getColor()
Interface for getting the color (used for linked color picking)
Definition ExprControl.h:71
void linkStateChange(int state)
void linkDisconnect(int newId)
virtual ~ExprControl()
Definition ExprControl.h:68
QLabel * _label
Definition ExprControl.h:62
void controlChanged(int id)
void linkColorLink(int id)
void linkColorEdited(int id, QColor color)
ExprControl(int id, Editable *editable, bool showColorLink)
virtual void setColor(QColor color)
Interface for setting the color (used for linked color picking)
Definition ExprControl.h:73
Line Editor Widget(used for numbers)
virtual void setText(const QString &t)
void textChanged(int id, const QString &text)
void textChangedCB(const QString &text)
ExprLineEdit(int id, QWidget *parent)
Generic Slider (used for int and float sliders)
virtual void leaveEvent(QEvent *event)
virtual void enterEvent(QEvent *event)
virtual void paintEvent(QPaintEvent *e)
virtual void wheelEvent(QWheelEvent *e)
ExprSlider(QWidget *parent=0)
virtual void mouseMoveEvent(QMouseEvent *e)
ExprSlider(Qt::Orientation orientation, QWidget *parent=0)
virtual void mousePressEvent(QMouseEvent *e)
Number slider for either float or int data.
NumberEditable * _numberEditable
Pointer to the number control model.
void editChanged(int id, const QString &text)
void updateControl()
Update values in slider and textbox given what the model contains.
ExprLineEdit * _edit
Text box for the number.
void sliderChanged(int val)
ExprSlider * _slider
Slider for the number.
NumberControl(int id, NumberEditable *number)
void setValue(float value)
Update the model with the value and notify the collection.
A control for editing strings, filenames, and directories.
void directoryBrowse()
StringEditable * _stringEditable
model for the string control
void textChanged(const QString &newText)
StringControl(int id, StringEditable *stringEditable)
QLineEdit * _edit
Edit box for the string.
A vector or color control (named vector because it edits a SeExpr2::Vec3d literal)
ExprLineEdit * _edits[3]
All three line edit widgets (for each component)
QColor getColor()
Interface for getting the color (used for linked color picking)
void updateControl()
update the individual slider and eidt box controls
void editChanged(int id, const QString &text)
void setColor(QColor color)
Interface for setting the color (used for linked color picking)
void sliderChanged(int id, float val)
void setValue(int id, float value)
set the value in the model (in response to editing from controls)
void swatchChanged(QColor color)
ExprChannelSlider * _sliders[3]
All three channel sliders (for each component)
VectorEditable * _numberEditable
Number model.
VectorControl(int id, VectorEditable *number)
ExprCSwatchFrame * _swatch
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
For any rgb or hsl value(except for negative s values)