Olive
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
graphview.h
Go to the documentation of this file.
1 /***
2 
3  Olive - Non-Linear Video Editor
4  Copyright (C) 2019 Olive Team
5 
6  This program is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program. If not, see <http://www.gnu.org/licenses/>.
18 
19 ***/
20 
21 #ifndef GRAPHVIEW_H
22 #define GRAPHVIEW_H
23 
24 #include <QWidget>
25 #include <QVector>
26 
27 #include "effects/effectrow.h"
28 #include "effects/effectfields.h"
29 
30 QColor get_curve_color(int index, int length);
31 
32 class GraphView : public QWidget {
33  Q_OBJECT
34 public:
35  GraphView(QWidget* parent = nullptr);
36 
37  void paintEvent(QPaintEvent *event);
38  void mousePressEvent(QMouseEvent *event);
39  void mouseMoveEvent(QMouseEvent *event);
40  void mouseReleaseEvent(QMouseEvent *event);
41  void wheelEvent(QWheelEvent *event);
42 
43  void set_row(EffectRow* r);
44 
45  void set_selected_keyframe_type(int type);
46  void set_field_visibility(int field, bool b);
47 
48  void delete_selected_keys();
49  void select_all();
50 signals:
51  void x_scroll_changed(int);
52  void y_scroll_changed(int);
53  void zoom_changed(double, double);
54  void selection_changed(bool, int);
55 private:
56  int x_scroll;
57  int y_scroll;
58  bool mousedown;
59  int start_x;
60  int start_y;
61 
62  double x_zoom;
63  double y_zoom;
64 
65  void set_scroll_x(int s);
66  void set_scroll_y(int s);
67  void set_zoom(double xz, double yz);
68 
69  int get_screen_x(double);
70  int get_screen_y(double);
71  long get_value_x(int);
72  double get_value_y(int);
73 
74  void selection_update();
75 
76  QVector<bool> field_visibility;
77 
78  QVector<int> selected_keys;
79  QVector<int> selected_keys_fields;
80  QVector<long> selected_keys_old_vals;
81  QVector<double> selected_keys_old_doubles;
82 
87 
90 
91  bool moved_keys;
92 
94 
95  void draw_lines(QPainter &p, bool vert);
96  void draw_line_text(QPainter &p, bool vert, int line_no, int line_pos, int next_line_pos);
97 
99 
106 
108 
109  bool click_add;
114 private slots:
115  void show_context_menu(const QPoint& pos);
116  void reset_view();
117  void set_view_to_selection();
118  void set_view_to_all();
119  void set_view_to_rect(int x1, double y1, int x2, double y2);
120 };
121 
122 #endif // GRAPHVIEW_H
int rect_select_offset
Definition: graphview.h:105
void show_context_menu(const QPoint &pos)
Definition: graphview.cpp:77
double get_value_y(int)
Definition: graphview.cpp:922
bool click_add
Definition: graphview.h:109
QColor get_curve_color(int index, int length)
Definition: graphview.cpp:51
void set_selected_keyframe_type(int type)
Definition: graphview.cpp:845
void set_row(EffectRow *r)
Definition: graphview.cpp:824
QVector< int > selected_keys_fields
Definition: graphview.h:79
bool click_add_proc
Definition: graphview.h:110
int rect_select_h
Definition: graphview.h:104
GraphView(QWidget *parent=nullptr)
Definition: graphview.cpp:58
EffectRow * row
Definition: graphview.h:98
long visible_in
Definition: graphview.h:107
void mouseMoveEvent(QMouseEvent *event)
Definition: graphview.cpp:470
int click_add_key
Definition: graphview.h:112
int get_screen_x(double)
Definition: graphview.cpp:903
double old_pre_handle_x
Definition: graphview.h:83
void select_all()
Definition: graphview.cpp:872
void set_view_to_all()
Definition: graphview.cpp:136
long get_value_x(int)
Definition: graphview.cpp:914
void set_scroll_y(int s)
Definition: graphview.cpp:892
QVector< int > selected_keys
Definition: graphview.h:78
bool moved_keys
Definition: graphview.h:91
void wheelEvent(QWheelEvent *event)
Definition: graphview.cpp:739
int rect_select_w
Definition: graphview.h:103
void set_zoom(double xz, double yz)
Definition: graphview.cpp:897
double y_zoom
Definition: graphview.h:63
void set_field_visibility(int field, bool b)
Definition: graphview.cpp:857
int x_scroll
Definition: graphview.h:56
void paintEvent(QPaintEvent *event)
Definition: graphview.cpp:228
void set_view_to_rect(int x1, double y1, int x2, double y2)
Definition: graphview.cpp:163
int click_add_type
Definition: graphview.h:113
int y_scroll
Definition: graphview.h:57
void y_scroll_changed(int)
int start_x
Definition: graphview.h:59
Definition: graphview.h:32
int handle_field
Definition: graphview.h:88
QVector< bool > field_visibility
Definition: graphview.h:76
void zoom_changed(double, double)
int get_screen_y(double)
Definition: graphview.cpp:910
int handle_index
Definition: graphview.h:89
bool rect_select
Definition: graphview.h:100
void mouseReleaseEvent(QMouseEvent *event)
Definition: graphview.cpp:702
double x_zoom
Definition: graphview.h:62
int start_y
Definition: graphview.h:60
void delete_selected_keys()
Definition: graphview.cpp:862
void set_view_to_selection()
Definition: graphview.cpp:115
The EffectField class.
Definition: effectfield.h:56
int rect_select_x
Definition: graphview.h:101
void selection_update()
Definition: graphview.cpp:926
EffectField * click_add_field
Definition: graphview.h:111
void x_scroll_changed(int)
QVector< long > selected_keys_old_vals
Definition: graphview.h:80
void set_scroll_x(int s)
Definition: graphview.cpp:887
bool mousedown
Definition: graphview.h:58
void reset_view()
Definition: graphview.cpp:106
int current_handle
Definition: graphview.h:93
void draw_lines(QPainter &p, bool vert)
Definition: graphview.cpp:185
QVector< double > selected_keys_old_doubles
Definition: graphview.h:81
int rect_select_y
Definition: graphview.h:102
The EffectRow class.
Definition: effectrow.h:51
void selection_changed(bool, int)
double old_pre_handle_y
Definition: graphview.h:84
void mousePressEvent(QMouseEvent *event)
Definition: graphview.cpp:363
double old_post_handle_x
Definition: graphview.h:85
void draw_line_text(QPainter &p, bool vert, int line_no, int line_pos, int next_line_pos)
Definition: graphview.cpp:175
double old_post_handle_y
Definition: graphview.h:86