mask fade/feather rounding problem, mask mode sense err, add mask
[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 #define FEATHER_MAX 100
48
49 class SubMask
50 {
51 public:
52         SubMask(MaskAuto *keyframe, int no);
53         ~SubMask();
54
55         int operator==(SubMask& ptr);
56         int equivalent(SubMask& ptr);
57         void copy_from(SubMask& ptr);
58         void load(FileXML *file);
59         void copy(FileXML *file);
60         void dump(FILE *fp);
61
62         char name[BCSTRLEN];
63         float fader; // 0 - 100
64         float feather; // 0 - 100
65         ArrayList<MaskPoint*> points;
66         MaskAuto *keyframe;
67 };
68
69 class MaskAuto : public Auto
70 {
71 public:
72         MaskAuto(EDL *edl, MaskAutos *autos);
73         ~MaskAuto();
74
75         int operator==(Auto &that);
76         int operator==(MaskAuto &that);
77         bool is_maskauto() { return true; }
78         int identical(MaskAuto *src);
79         void load(FileXML *file);
80         void copy(int64_t start, int64_t end, FileXML *file, int default_auto);
81         void copy_from(Auto *src);
82         int interpolate_from(Auto *a1, Auto *a2, int64_t position, Auto *templ=0);
83         void copy_from(MaskAuto *src);
84 // Copy data but not position
85         void copy_data(MaskAuto *src);
86         void get_points(ArrayList<MaskPoint*> *points,
87                 int submask);
88         void set_points(ArrayList<MaskPoint*> *points,
89                 int submask);
90
91 // Copy parameters to this which differ between ref & src
92         void update_parameter(MaskAuto *ref, MaskAuto *src);
93
94         void dump(FILE *fp);
95 // Retrieve submask with clamping
96         SubMask* get_submask(int number);
97 // Translates all submasks
98         void translate_submasks(float translate_x, float translate_y);
99 // scale all submasks
100         void scale_submasks(int orig_scale, int new_scale);
101
102         ArrayList<SubMask*> masks;
103         int apply_before_plugins;
104         int disable_opengl_masking;
105 };
106
107 class MaskCoord { public: double x, y, z; };
108
109 class MaskEdge : public ArrayList<MaskCoord>
110 {
111 public:
112         MaskCoord &append() { return ArrayList<MaskCoord>::append(); }
113         MaskCoord &append(double x, double y, double z=0) {
114                 MaskCoord &c = append();
115                 c.x = x;  c.y = y;  c.z = z;
116                 return c;
117         }
118 };
119
120 // shader buffer unsized array vec only seems to work for dvec (05/2019)
121 class MaskSpot { public: double x, y; };
122
123 class MaskSpots : public ArrayList<MaskSpot>
124 {
125 public:
126         MaskSpot &append() { return ArrayList<MaskSpot>::append(); }
127         MaskSpot &append(double x, double y) {
128                 MaskSpot &s = append();
129                 s.x = x;  s.y = y;
130                 return s;
131         }
132 };
133
134 class MaskEdges : public ArrayList<MaskEdge*> {
135 public:
136         MaskEdges() {}
137         ~MaskEdges() { remove_all_objects(); }
138 };
139
140 class MaskPointSet : public ArrayList<MaskPoint*>
141 {
142 public:
143         void clear() { remove_all_objects(); }
144         MaskPointSet() {}
145         ~MaskPointSet() { clear(); }
146 };
147 class MaskPointSets : public ArrayList<MaskPointSet*>
148 {
149 public:
150         void clear() { remove_all_objects(); }
151         MaskPointSets() {}
152         ~MaskPointSets() { clear(); }
153 };
154
155 #endif