mask xy scale, mask boundary only overlay, fix 8 char mask nm bug, rework maskgui...
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / maskauto.h
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
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 2 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, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  *
20  */
21
22 #ifndef MASKAUTO_H
23 #define MASKAUTO_H
24
25
26 #include "arraylist.h"
27 #include "auto.h"
28 #include "maskauto.inc"
29 #include "maskautos.inc"
30
31 class MaskPoint
32 {
33 public:
34         MaskPoint();
35
36         int operator==(MaskPoint& ptr);
37         MaskPoint& operator=(MaskPoint& ptr);
38         void copy_from(MaskPoint &ptr);
39
40         float x, y;
41 // Incoming acceleration
42         float control_x1, control_y1;
43 // Outgoing acceleration
44         float control_x2, control_y2;
45 };
46
47 class MaskCoord { public: double x, y, z; };
48
49 class MaskEdge : public ArrayList<MaskCoord>
50 {
51 public:
52         MaskCoord &append() { return ArrayList<MaskCoord>::append(); }
53         MaskCoord &append(double x, double y, double z=0) {
54                 MaskCoord &c = append();
55                 c.x = x;  c.y = y;  c.z = z;
56                 return c;
57         }
58         void load(MaskPoints &points, float ofs);
59 };
60
61 class MaskEdges : public ArrayList<MaskEdge*> {
62 public:
63         MaskEdges() {}
64         ~MaskEdges() { remove_all_objects(); }
65 };
66
67 class MaskPoints : public ArrayList<MaskPoint *>
68 {
69 public:
70         void clear() { remove_all_objects(); }
71         MaskPoints() {}
72         ~MaskPoints() { clear(); }
73 };
74
75 class MaskPointSets : public ArrayList<MaskPoints*>
76 {
77 public:
78         void clear() { remove_all_objects(); }
79         MaskPointSets() {}
80         ~MaskPointSets() { clear(); }
81 };
82
83 #define FEATHER_MAX 100
84
85 class SubMask
86 {
87 public:
88         SubMask(MaskAuto *keyframe, int no);
89         ~SubMask();
90
91         int operator==(SubMask& ptr);
92         int equivalent(SubMask& ptr);
93         void copy_from(SubMask& ptr, int do_name=1);
94         void load(FileXML *file);
95         void copy(FileXML *file);
96         void dump(FILE *fp);
97
98         char name[BCSTRLEN];
99         float fader; // -100 - 100
100         float feather; // -100 - 100
101         MaskPoints points;
102         MaskAuto *keyframe;
103 };
104
105 class MaskAuto : public Auto
106 {
107 public:
108         MaskAuto(EDL *edl, MaskAutos *autos);
109         ~MaskAuto();
110
111         int operator==(Auto &that);
112         int operator==(MaskAuto &that);
113         bool is_maskauto() { return true; }
114         int identical(MaskAuto *src);
115         void load(FileXML *file);
116         void copy(int64_t start, int64_t end, FileXML *file, int default_auto);
117         void copy_from(Auto *src);
118         int interpolate_from(Auto *a1, Auto *a2, int64_t position, Auto *templ=0);
119         void copy_from(MaskAuto *src);
120 // Copy data but not position
121         void copy_data(MaskAuto *src);
122         void get_points(MaskPoints *points,
123                 int submask);
124         void set_points(MaskPoints *points,
125                 int submask);
126
127 // Copy parameters to this which differ between ref & src
128         void update_parameter(MaskAuto *ref, MaskAuto *src);
129
130         void dump(FILE *fp);
131 // Retrieve submask with clamping
132         SubMask* get_submask(int number);
133 // Translates all submasks
134         void translate_submasks(float translate_x, float translate_y);
135 // scale all submasks
136         void scale_submasks(int orig_scale, int new_scale);
137         int has_active_mask();
138
139         ArrayList<SubMask*> masks;
140         int apply_before_plugins;
141         int disable_opengl_masking;
142 };
143
144 // shader buffer unsized array vec only seems to work for dvec (05/2019)
145 class MaskSpot { public: double x, y; };
146
147 class MaskSpots : public ArrayList<MaskSpot>
148 {
149 public:
150         MaskSpot &append() { return ArrayList<MaskSpot>::append(); }
151         MaskSpot &append(double x, double y) {
152                 MaskSpot &s = append();
153                 s.x = x;  s.y = y;
154                 return s;
155         }
156 };
157
158 #endif