Added copyright lines for files I've edited this year.
[synfig.git] / synfig-core / trunk / src / synfig / renddesc.h
1 /* === S Y N F I G ========================================================= */
2 /*!     \file synfig/renddesc.h
3 **      \brief Template Header
4 **
5 **      $Id$
6 **
7 **      \legal
8 **      Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
9 **      Copyright (c) 2008 Chris Moore
10 **
11 **      This package is free software; you can redistribute it and/or
12 **      modify it under the terms of the GNU General Public License as
13 **      published by the Free Software Foundation; either version 2 of
14 **      the License, or (at your option) any later version.
15 **
16 **      This package is distributed in the hope that it will be useful,
17 **      but WITHOUT ANY WARRANTY; without even the implied warranty of
18 **      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 **      General Public License for more details.
20 **      \endlegal
21 */
22 /* ========================================================================= */
23
24 /* === S T A R T =========================================================== */
25
26 #ifndef __SYNFIG_RENDERDESC_H
27 #define __SYNFIG_RENDERDESC_H
28
29 /* === H E A D E R S ======================================================= */
30
31 #include "vector.h"
32 #include "color.h"
33 #include "types.h"
34 #include <cmath>
35 #include "rect.h"
36
37 /* === M A C R O S ========================================================= */
38
39 #ifndef DPM2DPI
40 #define DPM2DPI(x)      (float(x)/39.3700787402f)
41 #define DPI2DPM(x)      (float(x)*39.3700787402f)
42 #endif
43
44 /* === T Y P E D E F S ===================================================== */
45
46 /* === C L A S S E S & S T R U C T S ======================================= */
47
48 namespace synfig {
49
50 /*!     \class RendDesc
51 **      \todo writeme
52 */
53 class RendDesc
54 {
55 public:
56         enum Lock
57         {
58                 PX_ASPECT=(1<<0),
59                 PX_AREA=(1<<1),
60                 PX_W=(1<<2),
61                 PX_H=(1<<3),
62
63                 IM_ASPECT=(1<<4),
64                 IM_SPAN=(1<<5),
65                 IM_W=(1<<6),
66                 IM_H=(1<<7),
67                 IM_ZOOMIN=(1<<8),
68                 IM_ZOOMOUT=(1<<9),
69
70                 LINK_PX_ASPECT=(1<<10),
71                 LINK_PX_AREA=(1<<11),
72                 LINK_IM_ASPECT=(1<<12),
73                 LINK_IM_SPAN=(1<<13),
74                 LINK_IM_CENTER=(1<<14)
75         };
76
77 private:
78         int w_,h_;
79         Real x_res;
80         Real y_res;
81         Point tl_, br_;
82         Point focus;
83         int a;
84         //Gamma gamma;
85         Color background;
86         int flags;
87         bool interlaced;
88         bool clamp;
89
90         float frame_rate;
91         Time time_begin, time_end;
92
93 public:
94
95         enum
96         {
97                 ANTIALIAS_UNIFORM,
98                 ANTIALIAS_MONTE_CARLO,
99                 ANTIALIAS_JITTERED,
100                 ANTIALIAS_ADAPTIVE,
101                 ANTIALIAS_QUINTCUNX
102         } AntialiasFilter;
103
104         //! Default Constructor
105         RendDesc():
106                 w_                      (480),
107                 h_                      (270),
108                 x_res           (DPI2DPM(72.0f)),
109                 y_res           (DPI2DPM(72.0f)),
110                 tl_                     (-4,2.25),
111                 br_                     (4,-2.25),
112                 focus           (0,0),
113                 a                       (2),
114                 background      (Color::gray()),
115                 flags           (0),
116                 interlaced      (false),
117                 clamp           (false),
118                 frame_rate      (24),
119                 time_begin      (0),
120                 time_end        (0)
121         { }
122
123         //! \writeme
124         RendDesc &apply(const RendDesc &x);
125
126         //! \writeme
127         const Color &get_bg_color()const;
128
129         //! \writeme
130         RendDesc &set_bg_color(const Color &bg);
131
132         //! Return the width of the composition in pixels
133         int get_w()const;
134
135         //! Set the width of the composition in pixels.
136         /*! The other parameters are adjusted according to the
137         **      constraints placed on the flags.
138         */
139         RendDesc &set_w(int x);
140
141         //! Return the height of the composition in pixels
142         int     get_h()const;
143
144         //! Set the height of the composition in pixels.
145         /*! The other parameters are adjusted according to the
146         **      constraints placed on the flags.
147         */
148         RendDesc &set_h(int y);
149
150         //!     Sets the width and height of the composition in pixels
151         RendDesc &set_wh(int x, int y);
152
153     //! Returns the horizontal resolution (in dots per meter)
154         Real get_x_res()const;
155
156         //! Sets the horizontal resolution (in dots per meter)
157         RendDesc &set_x_res(Real x);
158
159     //! Returns the vertical resolution (in dots per meter)
160         Real get_y_res()const;
161
162         //! Sets the vertical resolution (in dots per meter)
163         RendDesc &set_y_res(Real y);
164
165
166         //! Return the physical width of the composition in meters
167         Real get_physical_w()const;
168
169         //! Return the physical height of the composition in meters
170         Real get_physical_h()const;
171
172         //! Set the physical width of the composition in meters
173         RendDesc &set_physical_w(Real w);
174
175         //! Set the physical height of the composition in meters
176         RendDesc &set_physical_h(Real h);
177
178
179         //!     Return the index of the first frame
180         int get_frame_start()const;
181
182         //! Set the index of the first frame
183         RendDesc &set_frame_start(int x);
184
185         //!     Return the index of the last frame
186         int get_frame_end()const;
187
188         //! Set the index of the last frame
189         RendDesc &set_frame_end(int x);
190
191         //!     Return the starting time of the animation
192         const Time get_time_start()const;
193
194         //!     Set the time that the animation will start
195         RendDesc &set_time_start(Time x);
196
197         //! Return the end time of the animation
198         const Time get_time_end()const;
199
200         //!     Set the time that the animation will end
201         RendDesc &set_time_end(Time x);
202
203         //!     Setup for one frame at the given time
204         RendDesc &set_time(Time x);
205
206         //!     Setup for one frame
207         RendDesc &set_frame(int x);
208
209         //!     Return the frame rate (frames-per-second)
210         const float &get_frame_rate()const;
211
212         //! Set the frame rate (frames-per-second)
213         RendDesc &set_frame_rate(float x);
214
215         //! Return the status of the interlaced flag
216         const bool &get_interlaced()const;
217
218         //! Set the interlace flag
219         RendDesc &set_interlaced(bool x);
220
221         //! Return the status of the clamp flag
222         const bool &get_clamp()const;
223
224         //! Set the clamp flag
225         RendDesc &set_clamp(bool x);
226
227         //! Set constraint flags
228         RendDesc &set_flags(const int &x);
229
230         //! Clear constraint flags
231         RendDesc &clear_flags();
232
233         //! Get constraint flags
234         int get_flags()const;
235
236         //!     Return the aspect ratio of a single pixel
237         Point::value_type get_pixel_aspect()const;
238
239         //!     Return the aspect ratio of the entire image
240         Point::value_type get_image_aspect()const;
241
242         //! Return the antialias amount
243         const int &get_antialias()const;
244
245         //! Set the antialias amount
246         RendDesc &set_antialias(const int &x);
247
248         //! Return the distance from the bottom-right to the top-left
249         Real get_span()const;
250
251         //! Set the span distance
252         RendDesc& set_span(const Real &x);
253
254         //const Gamma &get_gamma()const;
255
256         //RendDesc &set_gamma(const Gamma &x);
257
258         const Point &get_focus()const;
259
260         RendDesc &set_focus(const Point &x);
261
262         const Point &get_tl()const;
263
264         RendDesc &set_tl(const Point &x);
265
266         const Point &get_br()const;
267
268         RendDesc &set_br(const Point &x);
269
270         Rect get_rect()const { return Rect(get_tl(),get_br()); }
271
272         RendDesc &set_viewport(const Point &__tl, const Point &__br);
273
274         RendDesc &set_viewport(Vector::value_type a,Vector::value_type b,Vector::value_type c,Vector::value_type d);
275
276         //! Returns the width of one pixel
277         Real get_pw()const;
278
279         //! Returns the height of one pixel
280         Real get_ph()const;
281
282         //! Sets viewport to represent the screen at the given pixel coordinates
283         RendDesc &set_subwindow(int x, int y, int w, int h);
284 };      // END of class RendDesc
285
286 //! This operator allows the combining of RendDesc::Lock flags using the '|' operator
287 /*!     \see RendDesc::Lock, RendDesc */
288 inline RendDesc::Lock operator|(RendDesc::Lock lhs, RendDesc::Lock rhs)
289 {
290         return static_cast<RendDesc::Lock>((int)lhs|(int)rhs);
291 }
292
293 //! This operator allows the masking of RendDesc::Lock flags using the '&' operator
294 /*!     \see RendDesc::Lock, RendDesc */
295 inline RendDesc::Lock operator&(RendDesc::Lock lhs, RendDesc::Lock rhs)
296 {
297         return static_cast<RendDesc::Lock>((int)lhs&(int)rhs);
298 }
299
300 //! This operator allows the inverting of RendDesc::Lock flags using the '~' operator
301 /*!     \see RendDesc::Lock, RendDesc */
302 inline RendDesc::Lock operator~(RendDesc::Lock rhs)
303 {
304         return static_cast<RendDesc::Lock>(~(int)rhs);
305 }
306
307 //! \todo This code isn't used - so how are flags checked?  Using the FLAGS macro from color.h?
308 //! This operator is for checking RendDesc::Lock flags.
309 /*! Don't think of it as "less then or equal to", but think of it
310 **      like an arrow. Is \a rhs inside of \a lhs ?
311 **      \see RendDesc::Lock, RendDesc */
312 // inline bool operator<=(RendDesc::Lock lhs, RendDesc::Lock rhs)
313 // {
314 //      return (static_cast<int>(lhs) & static_cast<int>(rhs)) == static_cast<int>(rhs);
315 // }
316
317
318 }; /* end namespace synfig */
319
320 /* === E N D =============================================================== */
321
322 #endif