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