-
Notifications
You must be signed in to change notification settings - Fork 0
/
ChannelViewer.h
104 lines (89 loc) · 2.74 KB
/
ChannelViewer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#ifndef ANIMATIONVIEWER_H
#define ANIMATIONVIEWER_H
#include <QGraphicsView>
#include <QHash>
#include "Channel.h"
#include "Keyframe.h"
namespace Ui {
class MainWindow;
}
class ChannelViewer : public QGraphicsView
{
Q_OBJECT
public:
ChannelViewer(QWidget *parent = 0);
virtual ~ChannelViewer();
void setChannel(Channel* channel);
void initUi(Ui::MainWindow* ui);
protected:
virtual void mouseMoveEvent(QMouseEvent* event);
virtual void mousePressEvent(QMouseEvent* event);
virtual void mouseReleaseEvent(QMouseEvent* event);
virtual void keyReleaseEvent(QKeyEvent *event);
private slots:
void onSelectionChanged();
void onTangentTypeChanged(QString newType);
void onTangentValueChanged(double newValue);
void onKeyChanged(double newValue);
void onChannelChanged(QString newType);
private:
struct KeyframeInfo {
KeyframeInfo();
void reset();
QGraphicsItemGroup* _group;
QGraphicsRectItem* _rect;
QGraphicsLineItem* _tangentIn;
QGraphicsLineItem* _tangentOut;
Keyframe* _keyframe;
};
struct World {
float startTime;
float endTime;
float duration;
int numCyle;
float worldWidth;
float worldRight;
float worldLeft;
float worldHeight;
float worldTop;
float worldBottom;
float heightOffset;
float min;
float max;
float xSW;
float ySW;
float xWS;
float yWS;
float keySize;
float keyWidth;
float keyHeight;
float tangentLength;
};
void _clear();
void _createScene();
void _changeSelection(QGraphicsItem* newSelection);
void _setKeyUi();
void _updateKeys();
void _updateCurve();
void _addKey(QPointF const& pos);
void _createKey(Keyframe* key, bool addToScene = true);
Ui::MainWindow* _ui;
Channel* _channel;
QGraphicsScene* _scene;
QGraphicsPathItem* _innerCurve;
QGraphicsPathItem* _outerCurve;
QGraphicsPathItem* _mainGrid;
QGraphicsPathItem* _grid;
QHash<QGraphicsItem*, KeyframeInfo> _keys;
QRectF _world;
QPoint _originMousePos;
KeyframeInfo _selected;
QGraphicsRectItem* _selectionRect;
bool _isDragging;
World _info;
static QHash<QString, Channel::ExtrapolateType> _extrapolationNameType;
static QHash<Channel::ExtrapolateType, QString> _extrapolationTypeName;
static QHash<QString, Keyframe::TangentType> _tangentNameType;
static QHash<Keyframe::TangentType, QString> _tangentTypeName;
};
#endif // ANIMATIONVIEWER_H