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 
32 class QLabel;
33 class ExprColorCurve;
34 class QHBoxLayout;
35 class ExprCSwatchFrame;
36 class Editable;
37 class StringEditable;
38 class VectorEditable;
39 class NumberEditable;
40 class AnimCurveEditable;
43 template <class TVAL>
47 class DeepWaterEditable;
48 
49 namespace animlib {
50 class AnimCurve;
51 }
52 
54 class 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 
75 signals:
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
83 slots:
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 
93 template <class T, class T2, class T3>
94 T 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?
104 class 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 
113 signals:
114  void textChanged(int id, const QString& text);
115 
116  private
117 slots:
118  void textChangedCB(const QString& text);
119 
120  private:
121  int _id;
123 };
124 
126 class 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 
146 class 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
158 slots:
159  void setValue(float value);
160 
161 signals:
162  void valueChanged(int id, float value);
163 
164  private:
165  int _id;
166  float _value;
167  QColor _col;
168 };
169 
171 class NumberControl : public ExprControl {
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
190 slots:
191  void sliderChanged(int val);
192  void editChanged(int id, const QString& text);
193 };
194 
196 class VectorControl : public ExprControl {
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
220 slots:
221  void sliderChanged(int id, float val);
222  void editChanged(int id, const QString& text);
223  void swatchChanged(QColor color);
224 };
225 
227 class StringControl : public ExprControl {
228  Q_OBJECT
229 
233  QLineEdit* _edit;
234 
235  public:
236  StringControl(int id, StringEditable* stringEditable);
237 
238  private:
239  void updateControl();
240  private
241 slots:
242  void textChanged(const QString& newText);
243  void fileBrowse();
244  void directoryBrowse();
245 };
246 
248 class CurveControl : public ExprControl {
249  Q_OBJECT
250 
255 
256  public:
257  CurveControl(int id, CurveEditable* stringEditable);
258  private
259 slots:
260  void curveChanged();
261 };
262 
264 class CCurveControl : public ExprControl {
265  Q_OBJECT
266 
271 
272  public:
273  CCurveControl(int id, ColorCurveEditable* stringEditable);
274  QColor getColor();
275  void setColor(QColor color);
276  private
277 slots:
278  void curveChanged();
279 };
280 
282 class 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
295 slots:
296  void editGraphClicked();
297 
298  private
299 slots:
300  void refreshClicked();
301 
302  private:
304 };
305 
308  Q_OBJECT
309 
314 
315  public:
316  ColorSwatchControl(int id, ColorSwatchEditable* swatchEditable);
317  private
318 slots:
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
340 slots:
341  void deepWaterChanged();
342 };
343 
344 #endif
animlib
Definition: ExprControl.h:49
CCurveControl::getColor
QColor getColor()
Interface for getting the color (used for linked color picking)
Definition: ExprControl.cpp:471
ExprColorCurve
Definition: ExprColorCurve.h:137
ExprDeepWater
Definition: ExprDeepWater.h:248
CurveControl::curveChanged
void curveChanged()
Definition: ExprControl.cpp:442
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
ExprControl::linkStateChange
void linkStateChange(int state)
Definition: ExprControl.cpp:194
AnimCurveControl::setAnimCurveCallback
static void setAnimCurveCallback(AnimCurveCallback callback)
Definition: ExprControl.cpp:669
AnimCurveEditable
Definition: Editable.h:211
ExprCurve.h
VectorEditable
Definition: Editable.h:101
DeepWaterControl::DeepWaterControl
DeepWaterControl(int id, DeepWaterEditable *stringEditable)
Definition: ExprControl.cpp:720
ExprLineEdit::ExprLineEdit
ExprLineEdit(int id, QWidget *parent)
Definition: ExprEditor.cpp:61
Editable
Definition: Editable.h:40
ExprLineEdit::textChanged
void textChanged(int id, const QString &text)
CurveControl::CurveControl
CurveControl(int id, CurveEditable *stringEditable)
Definition: ExprControl.cpp:427
ExprSlider::ExprSlider
ExprSlider(QWidget *parent=0)
Definition: ExprControl.h:129
VectorControl::setColor
void setColor(QColor color)
Interface for setting the color (used for linked color picking)
Definition: ExprControl.cpp:323
ColorCurveEditable
GenericCurveEditable< SeExpr2::Vec3d > ColorCurveEditable
Definition: ExprControl.h:44
ExprControl::_colorLinkCB
QCheckBox * _colorLinkCB
Definition: ExprControl.h:61
NumberControl::setValue
void setValue(float value)
Update the model with the value and notify the collection.
Definition: ExprControl.cpp:265
AnimCurveControl::refreshClicked
void refreshClicked()
Definition: ExprControl.cpp:626
ExprControl::_updating
bool _updating
Definition: ExprControl.h:59
ColorSwatchEditable
Definition: Editable.h:274
SeExpr2::Vec< double, 3, false >
ExprChannelSlider::paintEvent
virtual void paintEvent(QPaintEvent *e)
Definition: ExprControl.cpp:146
SeExpr2::curve
SeExpr2::CurveFuncX curve
ColorSwatchControl::_indexLabel
bool _indexLabel
Definition: ExprControl.h:325
ExprControl::linkColorEdited
void linkColorEdited(int id, QColor color)
NumberControl::updateControl
void updateControl()
Update values in slider and textbox given what the model contains.
Definition: ExprControl.cpp:257
StringControl::fileBrowse
void fileBrowse()
Definition: ExprControl.cpp:404
ExprControl::hbox
QHBoxLayout * hbox
Definition: ExprControl.h:60
ColorSwatchControl::_swatch
ExprColorSwatchWidget * _swatch
Edit box for the color swatches.
Definition: ExprControl.h:313
CurveControl::_curveEditable
CurveEditable * _curveEditable
curve model
Definition: ExprControl.h:252
ColorSwatchControl::buildSwatchWidget
void buildSwatchWidget()
Definition: ExprControl.cpp:705
StringControl::_edit
QLineEdit * _edit
Edit box for the string.
Definition: ExprControl.h:233
ExprControl::linkColorLink
void linkColorLink(int id)
ExprChannelSlider::mouseMoveEvent
virtual void mouseMoveEvent(QMouseEvent *e)
Definition: ExprControl.cpp:157
AnimCurveControl
Definition: ExprControl.h:283
clamp
T clamp(const T val, const T2 minval, const T3 maxval)
clamp val to the specified range [minval,maxval]
Definition: ExprControl.h:94
NumberControl::sliderChanged
void sliderChanged(int val)
Definition: ExprControl.cpp:243
CCurveControl::curveChanged
void curveChanged()
Definition: ExprControl.cpp:464
AnimCurveControl::_preview
ExprGraphPreview * _preview
Definition: ExprControl.h:287
NumberControl::editChanged
void editChanged(int id, const QString &text)
Definition: ExprControl.cpp:248
ExprLineEdit::_signaling
bool _signaling
Definition: ExprControl.h:122
ExprSlider::wheelEvent
virtual void wheelEvent(QWheelEvent *e)
Definition: ExprControl.h:142
ExprChannelSlider::setValue
void setValue(float value)
Definition: ExprControl.cpp:159
StringControl::textChanged
void textChanged(const QString &newText)
Definition: ExprControl.cpp:421
AnimCurveControl::callback
static AnimCurveCallback callback
Definition: ExprControl.h:303
DeepWaterControl
Control for displaying a deep water spectrum.
Definition: ExprControl.h:329
ExprChannelSlider::ExprChannelSlider
ExprChannelSlider(int id, QWidget *parent)
Definition: ExprControl.cpp:144
VectorControl::swatchChanged
void swatchChanged(QColor color)
Definition: ExprControl.cpp:310
ExprSlider::ExprSlider
ExprSlider(Qt::Orientation orientation, QWidget *parent=0)
Definition: ExprControl.h:130
AnimCurveControl::AnimCurveControl
AnimCurveControl(int id, AnimCurveEditable *curveEditable)
Definition: ExprControl.cpp:593
ExprLineEdit::setText
virtual void setText(const QString &t)
Definition: ExprControl.h:108
ExprControl::linkDisconnect
void linkDisconnect(int newId)
Definition: ExprControl.cpp:205
CurveEditable
GenericCurveEditable< double > CurveEditable
Definition: ExprControl.h:46
AnimCurveControl::editGraphClicked
void editGraphClicked()
Definition: ExprControl.cpp:637
ExprLineEdit::textChangedCB
void textChangedCB(const QString &text)
Definition: ExprEditor.cpp:65
ExprDeepWater.h
ExprSlider::mouseMoveEvent
virtual void mouseMoveEvent(QMouseEvent *e)
Definition: ExprControl.cpp:95
ExprChannelSlider::wheelEvent
virtual void wheelEvent(QWheelEvent *e)
Definition: ExprControl.h:153
ExprChannelSlider::_id
int _id
Definition: ExprControl.h:165
CCurveControl
Control for editing a color ramp curve.
Definition: ExprControl.h:264
ExprCSwatchFrame
Definition: ExprColorCurve.h:115
ExprChannelSlider::_col
QColor _col
Definition: ExprControl.h:167
DeepWaterControl::deepWaterChanged
void deepWaterChanged()
Definition: ExprControl.cpp:729
ExprChannelSlider::valueChanged
void valueChanged(int id, float value)
ExprColorSwatchWidget
Definition: ExprColorSwatch.h:54
ExprSlider::leaveEvent
virtual void leaveEvent(QEvent *event)
Definition: ExprControl.h:134
ExprControl::controlChanged
void controlChanged(int id)
NumberControl::NumberControl
NumberControl(int id, NumberEditable *number)
Definition: ExprControl.cpp:213
DeepWaterControl::_deepWaterEditable
DeepWaterEditable * _deepWaterEditable
curve model
Definition: ExprControl.h:333
CCurveControl::CCurveControl
CCurveControl(int id, ColorCurveEditable *stringEditable)
Definition: ExprControl.cpp:449
ColorSwatchControl::_swatchEditable
ColorSwatchEditable * _swatchEditable
model for the color swatches control
Definition: ExprControl.h:311
CCurveControl::setColor
void setColor(QColor color)
Interface for setting the color (used for linked color picking)
Definition: ExprControl.cpp:473
VectorControl::setValue
void setValue(int id, float value)
set the value in the model (in response to editing from controls)
Definition: ExprControl.cpp:367
ExprChannelSlider
Channel Slider (i.e. for colors)
Definition: ExprControl.h:146
AnimCurveControl::_editable
AnimCurveEditable * _editable
Definition: ExprControl.h:284
ColorSwatchControl::colorChanged
void colorChanged(int index, SeExpr2::Vec3d value)
Definition: ExprControl.cpp:681
NumberEditable
Definition: Editable.h:60
ColorSwatchControl::ColorSwatchControl
ColorSwatchControl(int id, ColorSwatchEditable *swatchEditable)
Definition: ExprControl.cpp:674
StringControl::directoryBrowse
void directoryBrowse()
Definition: ExprControl.cpp:412
ExprControl::_id
int _id
Definition: ExprControl.h:55
ExprChannelSlider::setDisplayColor
void setDisplayColor(QColor c)
Definition: ExprControl.h:155
ColorSwatchControl::colorAdded
void colorAdded(int index, SeExpr2::Vec3d value)
Definition: ExprControl.cpp:687
VectorControl::VectorControl
VectorControl(int id, VectorEditable *number)
Definition: ExprControl.cpp:273
CCurveControl::_curve
ExprColorCurve * _curve
color curve widget
Definition: ExprControl.h:270
VectorControl::_sliders
ExprChannelSlider * _sliders[3]
All three channel sliders (for each component)
Definition: ExprControl.h:204
ColorSwatchControl
A control for editing color swatches.
Definition: ExprControl.h:307
NumberControl::_edit
ExprLineEdit * _edit
Text box for the number.
Definition: ExprControl.h:179
value
For any rgb or hsl value(except for negative s values)
ExprChannelSlider::mousePressEvent
virtual void mousePressEvent(QMouseEvent *e)
Definition: ExprControl.cpp:155
ExprChannelSlider::value
float value() const
Definition: ExprControl.h:154
ExprColorCurve.h
VectorControl::sliderChanged
void sliderChanged(int id, float val)
Definition: ExprControl.cpp:329
ExprControl::setColor
virtual void setColor(QColor color)
Interface for setting the color (used for linked color picking)
Definition: ExprControl.h:73
ExprControl::_label
QLabel * _label
Definition: ExprControl.h:62
DeepWaterEditable
Definition: Editable.h:327
VectorControl::_edits
ExprLineEdit * _edits[3]
All three line edit widgets (for each component)
Definition: ExprControl.h:202
CurveControl
Control for editing a normal curve ramp.
Definition: ExprControl.h:248
ExprGraphPreview
Definition: ExprControl.cpp:475
VectorControl::_swatch
ExprCSwatchFrame * _swatch
Definition: ExprControl.h:203
VectorControl::_numberEditable
VectorEditable * _numberEditable
Number model.
Definition: ExprControl.h:200
VectorControl::editChanged
void editChanged(int id, const QString &text)
Definition: ExprControl.cpp:335
DeepWaterControl::_deepWater
ExprDeepWater * _deepWater
deep water widget
Definition: ExprControl.h:335
ExprLineEdit
Line Editor Widget(used for numbers)
Definition: ExprControl.h:104
StringControl
A control for editing strings, filenames, and directories.
Definition: ExprControl.h:227
CCurveControl::_curveEditable
ColorCurveEditable * _curveEditable
color curve model
Definition: ExprControl.h:268
AnimCurveControl::AnimCurveCallback
void(* AnimCurveCallback)(const std::string &, animlib::AnimCurve &curve)
Definition: ExprControl.h:291
StringControl::StringControl
StringControl(int id, StringEditable *stringEditable)
Definition: ExprControl.cpp:376
VectorControl::updateControl
void updateControl()
update the individual slider and eidt box controls
Definition: ExprControl.cpp:343
ExprChannelSlider::_value
float _value
Definition: ExprControl.h:166
ColorSwatchControl::colorRemoved
void colorRemoved(int index)
Definition: ExprControl.cpp:694
ExprControl::ExprControl
ExprControl(int id, Editable *editable, bool showColorLink)
Definition: ExprControl.cpp:166
ExprSlider::enterEvent
virtual void enterEvent(QEvent *event)
Definition: ExprControl.h:138
NumberControl
Number slider for either float or int data.
Definition: ExprControl.h:171
ExprLineEdit::_id
int _id
Definition: ExprControl.h:121
ExprControl::~ExprControl
virtual ~ExprControl()
Definition: ExprControl.h:68
ExprSlider::paintEvent
virtual void paintEvent(QPaintEvent *e)
Definition: ExprControl.cpp:102
ExprControl
Base class for all controls for Expressions.
Definition: ExprControl.h:54
StringEditable
Definition: Editable.h:134
ExprSlider
Generic Slider (used for int and float sliders)
Definition: ExprControl.h:126
StringControl::updateControl
void updateControl()
Definition: ExprControl.cpp:419
GenericCurveEditable
Definition: Editable.h:170
ExprCurve
Definition: ExprCurve.h:116
NumberControl::_numberEditable
NumberEditable * _numberEditable
Pointer to the number control model.
Definition: ExprControl.h:175
VectorControl::getColor
QColor getColor()
Interface for getting the color (used for linked color picking)
Definition: ExprControl.cpp:318
VectorControl
A vector or color control (named vector because it edits a SeExpr2::Vec3d literal)
Definition: ExprControl.h:196
ExprControl::_editable
Editable * _editable
Definition: ExprControl.h:64
ExprSlider::mousePressEvent
virtual void mousePressEvent(QMouseEvent *e)
Definition: ExprControl.cpp:93
ExprControl::getColor
virtual QColor getColor()
Interface for getting the color (used for linked color picking)
Definition: ExprControl.h:71
CurveControl::_curve
ExprCurve * _curve
curve edit widget
Definition: ExprControl.h:254
StringControl::_stringEditable
StringEditable * _stringEditable
model for the string control
Definition: ExprControl.h:231
NumberControl::_slider
ExprSlider * _slider
Slider for the number.
Definition: ExprControl.h:177