SeExpr
ExprCurve.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 ExprCurve.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 _ExprCurve_h_
23 #define _ExprCurve_h_
24 
25 
26 #include <vector>
27 
28 #include <QtCore/QObject>
29 #include <QtGui/QComboBox>
30 #include <QtGui/QGraphicsPolygonItem>
31 #include <QtGui/QGraphicsView>
32 #include <QtGui/QLineEdit>
33 
34 #include <SeExpr2/Curve.h>
35 
36 /*
37  This class overrides QGraphicsView so we can get resize events
38 */
39 class CurveGraphicsView : public QGraphicsView
40 {
41  Q_OBJECT
42 public:
44  setTransformationAnchor(QGraphicsView::NoAnchor);
45  setResizeAnchor(QGraphicsView::NoAnchor);
46  }
48 
49  virtual void resizeEvent(QResizeEvent *event);
50 
51 signals:
52  void resizeSignal(int width, int height);
53 };
54 
55 /*
56  This class overrides QGraphicsScene so we can handle mouse
57  press, drag and keyboard events
58 */
59 class CurveScene : public QGraphicsScene
60 {
61  Q_OBJECT
62 
65 public:
66  CurveScene();
67  ~CurveScene();
68 
69  void addPoint(double x, double y, const T_INTERP interp, const bool select=true);
70 
71  void removePoint(const int index);
72  void removeAll();
73 
74  virtual void keyPressEvent(QKeyEvent *event);
75 
76  virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent);
77  virtual void mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent);
78  virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent);
79  virtual void contextMenuEvent(QGraphicsSceneContextMenuEvent *event);
80  void drawRect();
81 
82  void drawPoly();
83 
84  void drawPoints();
85 
86  void emitCurveChanged();
87 
88  void rebuildCurve();
89 
90  std::vector<T_CURVE::CV> _cvs; // unsorted cvs
91 
92  friend class ExprCurve;
93 
94 private:
96 public slots:
97  void interpChanged(const int interp);
98  void selPosChanged(double pos);
99  void selValChanged(double val);
100  void resize(const int width, const int height);
101 
102 signals:
103  void cvSelected(double x, double y, T_INTERP interp);
104  void curveChanged();
105 
106 private:
107 
108  int _width;
109  int _height;
111  std::vector<QGraphicsEllipseItem *> _circleObjects;
113  QGraphicsPolygonItem *_curvePoly;
114  QGraphicsRectItem *_baseRect;
115  bool _lmb;
116 };
117 
118 class ExprCurve : public QWidget
119 {
120  Q_OBJECT
121 
124 
125 public:
126  ExprCurve(QWidget* parent = 0, QString pLabel = "", QString vLabel = "", QString iLabel = "",
127  bool expandable=true);
129 
130  // Convenience Functions
131  void addPoint(const double x, const double y, const T_INTERP interp, bool select=false);
132 
134 
135 public slots:
136  void cvSelectedSlot(double pos, double val, T_INTERP interp);
137  void selPosChanged();
138  void selValChanged();
139  void openDetail();
140 
141 signals:
142  void selPosChangedSignal(double pos);
143  void selValChangedSignal(double val);
144 
145 private:
146  QLineEdit *_selPosEdit;
147  QLineEdit *_selValEdit;
148  QComboBox *_interpComboBox;
149 };
150 #endif
void selValChangedSignal(double val)
SeExpr2::Curve< double > T_CURVE
Definition: ExprCurve.h:122
std::vector< QGraphicsEllipseItem * > _circleObjects
Definition: ExprCurve.h:111
int _selectedItem
Definition: ExprCurve.h:112
Interpolation curve class for double-&gt;double and double-&gt;Vec3D.
Definition: Curve.h:38
void cvSelectedSlot(double pos, double val, T_INTERP interp)
Definition: ExprCurve.cpp:417
T_CURVE * _curve
Definition: ExprCurve.h:95
void resize(const int width, const int height)
Definition: ExprCurve.cpp:64
void drawPoly()
Definition: ExprCurve.cpp:253
void removeAll()
Definition: ExprCurve.cpp:41
void resizeSignal(int width, int height)
QComboBox * _interpComboBox
Definition: ExprCurve.h:148
QLineEdit * _selValEdit
Definition: ExprCurve.h:147
virtual void resizeEvent(QResizeEvent *event)
Definition: ExprCurve.cpp:47
virtual void keyPressEvent(QKeyEvent *event)
Definition: ExprCurve.cpp:112
void selValChanged(double val)
Definition: ExprCurve.cpp:222
SeExpr2::Curve< double > T_CURVE
Definition: ExprCurve.h:63
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
void addPoint(const double x, const double y, const T_INTERP interp, bool select=false)
Definition: ExprCurve.cpp:491
T_CURVE::InterpType T_INTERP
Definition: ExprCurve.h:64
virtual void mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent)
Definition: ExprCurve.cpp:122
void selPosChangedSignal(double pos)
T_INTERP _interp
Definition: ExprCurve.h:110
int _height
Definition: ExprCurve.h:109
void addPoint(double x, double y, const T_INTERP interp, const bool select=true)
Definition: ExprCurve.cpp:85
void emitCurveChanged()
Definition: ExprCurve.cpp:235
</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 contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
Definition: ExprCurve.cpp:160
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent)
Definition: ExprCurve.cpp:190
void interpChanged(const int interp)
Definition: ExprCurve.cpp:197
QLineEdit * _selPosEdit
Definition: ExprCurve.h:146
void selPosChanged(double pos)
Definition: ExprCurve.cpp:209
CurveScene * _scene
Definition: ExprCurve.h:133
void cvSelected(double x, double y, T_INTERP interp)
void removePoint(const int index)
Definition: ExprCurve.cpp:101
void curveChanged()
QGraphicsRectItem * _baseRect
Definition: ExprCurve.h:114
void drawPoints()
Definition: ExprCurve.cpp:273
QGraphicsPolygonItem * _curvePoly
Definition: ExprCurve.h:113
void rebuildCurve()
Definition: ExprCurve.cpp:75
ExprCurve(QWidget *parent=0, QString pLabel="", QString vLabel="", QString iLabel="", bool expandable=true)
Definition: ExprCurve.cpp:295
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent)
Definition: ExprCurve.cpp:170
void drawRect()
Definition: ExprCurve.cpp:241
T_CURVE::InterpType T_INTERP
Definition: ExprCurve.h:123
int _width
Definition: ExprCurve.h:108
InterpType
Supported interpolation types.
Definition: Curve.h:43
void selValChanged()
Definition: ExprCurve.cpp:439
void openDetail()
Definition: ExprCurve.cpp:447
~ExprCurve()
Definition: ExprCurve.h:128
std::vector< T_CURVE::CV > _cvs
Definition: ExprCurve.h:90
void selPosChanged()
Definition: ExprCurve.cpp:430
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
bool _lmb
Definition: ExprCurve.h:115