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 <QtGui/QTextBrowser>
20 #include <QtGui/QPlainTextEdit>
21 #include <QtGui/QDialog>
22 #include <QtCore/QTimer>
23 #include <QtCore/QRegExp>
24 #include <QtGui/QLineEdit>
25 #include <QtGui/QCheckBox>
26 #include <QtGui/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> struct GenericCurveEditable;
46 class DeepWaterEditable;
47 
48 namespace animlib{
49 class AnimCurve;
50 }
51 
53 class ExprControl:public QWidget
54 {
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 slots:
83  // receives that the link should be changed to the given state (0=off,1=on)
84  void linkStateChange(int state);
85 public:
86  // notifies this that the link should be disconnected
87  void linkDisconnect(int newId);
88 };
89 
90 
92 template<class T,class T2,class T3> T clamp(const T val,const T2 minval,const T3 maxval)
93 {
94  if(val<minval) return minval;
95  else if(val>maxval) return maxval;
96  return val;
97 }
98 
100 // TODO: can this now be removed?
101 class ExprLineEdit : public QLineEdit
102 {
103  Q_OBJECT
104  public:
105  ExprLineEdit(int id, QWidget* parent);
106  virtual void setText(const QString& t)
107  {
108  if (_signaling) return;
109  QLineEdit::setText(t);
110  }
111 
112  signals:
113  void textChanged(int id, const QString& text);
114 
115  private slots:
116  void textChangedCB(const QString& text);
117 
118  private:
119  int _id;
121 };
122 
124 class ExprSlider : public QSlider
125 {
126  Q_OBJECT
127  public:
128  ExprSlider(QWidget* parent = 0) : QSlider(parent) {}
129  ExprSlider(Qt::Orientation orientation, QWidget* parent = 0)
130  : 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 ) { Q_UNUSED(event); update(); }
135  virtual void enterEvent(QEvent* event ) { Q_UNUSED(event); update(); }
136  virtual void wheelEvent(QWheelEvent* e) { e->ignore(); }
137 };
138 
140 class ExprChannelSlider : public QWidget
141 {
142  Q_OBJECT
143  public:
144  ExprChannelSlider(int id, QWidget* parent);
145  virtual void paintEvent(QPaintEvent* e);
146  virtual void mousePressEvent(QMouseEvent* e);
147  virtual void mouseMoveEvent(QMouseEvent* e);
148  virtual void wheelEvent(QWheelEvent* e) { e->ignore(); }
149  float value() const { return _value; }
150  void setDisplayColor( QColor c ) { _col = c; }
151 
152  public slots:
153  void setValue(float value);
154 
155  signals:
156  void valueChanged(int id, float value);
157  private:
158  int _id;
159  float _value;
160  QColor _col;
161 };
162 
165 {
166  Q_OBJECT
167 
174 public:
175  NumberControl(int id,NumberEditable* number);
176 private:
178  void setValue(float value);
180  void updateControl();
181 private slots:
182  void sliderChanged(int val);
183  void editChanged(int id,const QString& text);
184 };
185 
188 {
189  Q_OBJECT
190 
198 public:
199  VectorControl(int id,VectorEditable* number);
200 
201  QColor getColor();
202  void setColor(QColor color);
203 private:
205  void setValue(int id,float value);
207  void updateControl();
208 private slots:
209  void sliderChanged(int id,float val);
210  void editChanged(int id,const QString& text);
211  void swatchChanged(QColor color);
212 };
213 
216 {
217  Q_OBJECT
218 
222  QLineEdit* _edit;
223 public:
224  StringControl(int id,StringEditable* stringEditable);
225 private:
226  void updateControl();
227 private slots:
228  void textChanged(const QString& newText);
229  void fileBrowse();
230  void directoryBrowse();
231 };
232 
235 {
236  Q_OBJECT
237 
242 public:
243  CurveControl(int id,CurveEditable* stringEditable);
244 private slots:
245  void curveChanged();
246 };
247 
250 {
251  Q_OBJECT
252 
257 public:
258  CCurveControl(int id,ColorCurveEditable* stringEditable);
259  QColor getColor();
260  void setColor(QColor color);
261 private slots:
262  void curveChanged();
263 };
264 
266 class ExprGraphPreview;
268 {
269  Q_OBJECT;
270 
273 public:
274  AnimCurveControl(int id,AnimCurveEditable* curveEditable);
275  typedef void (*AnimCurveCallback)(const std::string&,animlib::AnimCurve& curve);
277 
278 public slots:
279  void editGraphClicked();
280 
281 private slots:
282  void refreshClicked();
283 
284 private:
286 };
287 
290 {
291  Q_OBJECT
292 
297 public:
298  ColorSwatchControl(int id,ColorSwatchEditable* swatchEditable);
299 private slots:
300  void buildSwatchWidget();
303  void colorRemoved(int index);
304 private:
306 };
307 
310 {
311  Q_OBJECT
312 
317 public:
318  DeepWaterControl(int id,DeepWaterEditable* stringEditable);
319 private slots:
320  void deepWaterChanged();
321 };
322 
323 #endif
Editable * _editable
Definition: ExprControl.h:64
void editChanged(int id, const QString &text)
void linkColorEdited(int id, QColor color)
void colorChanged(int index, SeExpr2::Vec3d value)
Control for editing a normal curve ramp.
Definition: ExprControl.h:234
virtual void mouseMoveEvent(QMouseEvent *e)
void linkColorLink(int id)
SeExpr2::CurveFuncX curve
DeepWaterControl(int id, DeepWaterEditable *stringEditable)
void colorAdded(int index, SeExpr2::Vec3d value)
Generic Slider (used for int and float sliders)
Definition: ExprControl.h:124
virtual void paintEvent(QPaintEvent *e)
void editChanged(int id, const QString &text)
StringControl(int id, StringEditable *stringEditable)
void curveChanged()
A control for editing color swatches.
Definition: ExprControl.h:289
void linkStateChange(int state)
ExprLineEdit * _edits[3]
All three line edit widgets (for each component)
Definition: ExprControl.h:194
void swatchChanged(QColor color)
DeepWaterEditable * _deepWaterEditable
curve model
Definition: ExprControl.h:314
virtual QColor getColor()
Interface for getting the color (used for linked color picking)
Definition: ExprControl.h:71
ExprCurve * _curve
curve edit widget
Definition: ExprControl.h:241
void curveChanged()
Control for displaying a deep water spectrum.
Definition: ExprControl.h:309
QLineEdit * _edit
Edit box for the string.
Definition: ExprControl.h:222
QCheckBox * _colorLinkCB
Definition: ExprControl.h:61
ExprChannelSlider(int id, QWidget *parent)
A vector or color control (named vector because it edits a SeExpr2::Vec3d literal) ...
Definition: ExprControl.h:187
GenericCurveEditable< double > CurveEditable
Definition: Editable.h:235
void updateControl()
Update values in slider and textbox given what the model contains.
ExprCSwatchFrame * _swatch
Definition: ExprControl.h:195
void updateControl()
update the individual slider and eidt box controls
virtual void paintEvent(QPaintEvent *e)
void colorRemoved(int index)
void(* AnimCurveCallback)(const std::string &, animlib::AnimCurve &curve)
Definition: ExprControl.h:275
ExprColorSwatchWidget * _swatch
Edit box for the color swatches.
Definition: ExprControl.h:296
ExprSlider(Qt::Orientation orientation, QWidget *parent=0)
Definition: ExprControl.h:129
float value() const
Definition: ExprControl.h:149
QHBoxLayout * hbox
Definition: ExprControl.h:60
void setValue(int id, float value)
set the value in the model (in response to editing from controls)
A control for editing strings, filenames, and directories.
Definition: ExprControl.h:215
void valueChanged(int id, float value)
void controlChanged(int id)
virtual void leaveEvent(QEvent *event)
Definition: ExprControl.h:134
For any rgb or hsl value(except for negative s values)
ColorSwatchEditable * _swatchEditable
model for the color swatches control
Definition: ExprControl.h:294
ExprSlider * _slider
Slider for the number.
Definition: ExprControl.h:171
void setValue(float value)
ColorSwatchControl(int id, ColorSwatchEditable *swatchEditable)
virtual void wheelEvent(QWheelEvent *e)
Definition: ExprControl.h:148
ColorCurveEditable * _curveEditable
color curve model
Definition: ExprControl.h:254
void sliderChanged(int id, float val)
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
static void setAnimCurveCallback(AnimCurveCallback callback)
void linkDisconnect(int newId)
CurveControl(int id, CurveEditable *stringEditable)
QColor getColor()
Interface for getting the color (used for linked color picking)
virtual void wheelEvent(QWheelEvent *e)
Definition: ExprControl.h:136
virtual void mouseMoveEvent(QMouseEvent *e)
ExprSlider(QWidget *parent=0)
Definition: ExprControl.h:128
void setColor(QColor color)
Interface for setting the color (used for linked color picking)
Line Editor Widget(used for numbers)
Definition: ExprControl.h:101
ExprControl(int id, Editable *editable, bool showColorLink)
void setDisplayColor(QColor c)
Definition: ExprControl.h:150
ExprLineEdit(int id, QWidget *parent)
Definition: ExprEditor.cpp:61
CurveEditable * _curveEditable
curve model
Definition: ExprControl.h:239
NumberEditable * _numberEditable
Pointer to the number control model.
Definition: ExprControl.h:169
void setValue(float value)
Update the model with the value and notify the collection.
ExprDeepWater * _deepWater
deep water widget
Definition: ExprControl.h:316
ExprLineEdit * _edit
Text box for the number.
Definition: ExprControl.h:173
virtual void mousePressEvent(QMouseEvent *e)
ExprGraphPreview * _preview
Definition: ExprControl.h:272
QLabel * _label
Definition: ExprControl.h:62
Base class for all controls for Expressions.
Definition: ExprControl.h:53
StringEditable * _stringEditable
model for the string control
Definition: ExprControl.h:220
NumberControl(int id, NumberEditable *number)
QColor getColor()
Interface for getting the color (used for linked color picking)
double clamp(double x, double lo, double hi)
Definition: ExprBuiltins.h:40
CCurveControl(int id, ColorCurveEditable *stringEditable)
ExprColorCurve * _curve
color curve widget
Definition: ExprControl.h:256
void textChanged(const QString &newText)
virtual void setColor(QColor color)
Interface for setting the color (used for linked color picking)
Definition: ExprControl.h:73
AnimCurveControl(int id, AnimCurveEditable *curveEditable)
void directoryBrowse()
virtual void enterEvent(QEvent *event)
Definition: ExprControl.h:135
Channel Slider (i.e. for colors)
Definition: ExprControl.h:140
static AnimCurveCallback callback
Definition: ExprControl.h:285
void textChangedCB(const QString &text)
Definition: ExprEditor.cpp:68
void textChanged(int id, const QString &text)
VectorControl(int id, VectorEditable *number)
GenericCurveEditable< SeExpr2::Vec3d > ColorCurveEditable
Definition: Editable.h:234
Number slider for either float or int data.
Definition: ExprControl.h:164
virtual void mousePressEvent(QMouseEvent *e)
virtual void setText(const QString &t)
Definition: ExprControl.h:106
VectorEditable * _numberEditable
Number model.
Definition: ExprControl.h:192
void sliderChanged(int val)
ExprChannelSlider * _sliders[3]
All three channel sliders (for each component)
Definition: ExprControl.h:195
bool _updating
Definition: ExprControl.h:59
Control for editing a color ramp curve.
Definition: ExprControl.h:249
void setColor(QColor color)
Interface for setting the color (used for linked color picking)
AnimCurveEditable * _editable
Definition: ExprControl.h:269
virtual ~ExprControl()
Definition: ExprControl.h:68
void updateControl()