1 /* === S Y N F I G ========================================================= */
2 /*! \file synfig/renddesc.h
3 ** \brief Class that defines the parameters needed by the Renderer to
4 * render a context to a surface.
9 ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
10 ** Copyright (c) 2008 Chris Moore
12 ** This package is free software; you can redistribute it and/or
13 ** modify it under the terms of the GNU General Public License as
14 ** published by the Free Software Foundation; either version 2 of
15 ** the License, or (at your option) any later version.
17 ** This package is distributed in the hope that it will be useful,
18 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 ** General Public License for more details.
23 /* ========================================================================= */
25 /* === S T A R T =========================================================== */
27 #ifndef __SYNFIG_RENDERDESC_H
28 #define __SYNFIG_RENDERDESC_H
30 /* === H E A D E R S ======================================================= */
38 /* === M A C R O S ========================================================= */
41 #define DPM2DPI(x) (float(x)/39.3700787402f)
42 #define DPI2DPM(x) (float(x)*39.3700787402f)
45 /* === T Y P E D E F S ===================================================== */
47 /* === C L A S S E S & S T R U C T S ======================================= */
59 PX_ASPECT=(1<<0), // "Pixel Aspect" in Locks and Links
60 PX_AREA=(1<<1), // not used
61 PX_W=(1<<2), // "Pixel Width" in Locks and Links - not used
62 PX_H=(1<<3), // "Pixel Height" in Locks and Links - not used
64 IM_ASPECT=(1<<4), // "Image Aspect" in Locks and Links
65 IM_SPAN=(1<<5), // "Image Span" in Locks and Links
66 IM_W=(1<<6), // "Image Width" in Locks and Links
67 IM_H=(1<<7), // "Image Height" in Locks and Links
68 IM_ZOOMIN=(1<<8), // not used
69 IM_ZOOMOUT=(1<<9), // not used
71 LINK_PX_ASPECT=(1<<10), // not used
72 LINK_PX_AREA=(1<<11), // not used
73 LINK_IM_ASPECT=(1<<12), // not used
74 LINK_IM_SPAN=(1<<13), // not used
75 LINK_IM_CENTER=(1<<14) // not used
79 //! Width and height of the compostion in pixels
81 //! Horizontal resolution of the composition in pixels per meter
83 //! Vertical resolution of the composition in pixels per meter
85 //! The Top Left and the Bottom Right Points of the composition
87 //! The Focus Point of the compostion. Used when zooming in
91 //! The background color used when alpha is not supported or avoided
93 //! The result of the flags combination.
96 //! Interlaced flag for targets that suports it
98 //! Clamp flag to decide if color must be clamped or not
100 //! Frame rate of the composition to be rendered
102 //! Begin time and end time of the Composition to render
103 Time time_begin, time_end;
106 //! Anti alias filers types. Seems never implemented
110 ANTIALIAS_MONTE_CARLO,
116 //! Default Constructor
120 x_res (DPI2DPM(72.0f)),
121 y_res (DPI2DPM(72.0f)),
126 background (Color::gray()),
135 //! Applies the given Render Description \x to the current one
136 RendDesc &apply(const RendDesc &x);
138 //! Gets the background color
139 const Color &get_bg_color()const;
141 //! Sets the background color
142 RendDesc &set_bg_color(const Color &bg);
144 //! Return the width of the composition in pixels
147 //! Set the width of the composition in pixels.
148 /*! The other parameters are adjusted according to the
149 ** constraints placed on the flags.
150 * Seems to be incomplete and doesn't use all the possible
152 * \todo write the needed code to keep the flags usage
154 RendDesc &set_w(int x);
156 //! Return the height of the composition in pixels
159 //! Set the height of the composition in pixels.
160 /*! The other parameters are adjusted according to the
161 ** constraints placed on the flags.
162 * Seems to be incomplete and doesn't use all the possible
164 * \todo write the needed code to keep the flags usage
166 RendDesc &set_h(int y);
168 //! Sets the width and height of the composition in pixels
169 RendDesc &set_wh(int x, int y);
171 //! Returns the horizontal resolution (in dots per meter)
172 Real get_x_res()const;
174 //! Sets the horizontal resolution (in dots per meter)
175 RendDesc &set_x_res(Real x);
177 //! Returns the vertical resolution (in dots per meter)
178 Real get_y_res()const;
180 //! Sets the vertical resolution (in dots per meter)
181 RendDesc &set_y_res(Real y);
184 //! Return the physical width of the composition in meters
185 Real get_physical_w()const;
187 //! Return the physical height of the composition in meters
188 Real get_physical_h()const;
190 //! Set the physical width of the composition in meters
191 RendDesc &set_physical_w(Real w);
193 //! Set the physical height of the composition in meters
194 RendDesc &set_physical_h(Real h);
197 //! Return the index of the first frame
198 int get_frame_start()const;
200 //! Set the index of the first frame
201 RendDesc &set_frame_start(int x);
203 //! Return the index of the last frame
204 int get_frame_end()const;
206 //! Set the index of the last frame
207 RendDesc &set_frame_end(int x);
209 //! Return the starting time of the animation
210 const Time get_time_start()const;
212 //! Set the time that the animation will start
213 RendDesc &set_time_start(Time x);
215 //! Return the end time of the animation
216 const Time get_time_end()const;
218 //! Set the time that the animation will end
219 RendDesc &set_time_end(Time x);
221 //! Setup for one frame at the given time
222 RendDesc &set_time(Time x);
224 //! Setup for one frame
225 RendDesc &set_frame(int x);
227 //! Return the frame rate (frames-per-second)
228 const float &get_frame_rate()const;
230 //! Set the frame rate (frames-per-second)
231 RendDesc &set_frame_rate(float x);
233 //! Return the status of the interlaced flag
234 const bool &get_interlaced()const;
236 //! Set the interlace flag
237 RendDesc &set_interlaced(bool x);
239 //! Return the status of the clamp flag
240 const bool &get_clamp()const;
242 //! Set the clamp flag
243 RendDesc &set_clamp(bool x);
245 //! Set constraint flags
246 RendDesc &set_flags(const int &x);
248 //! Clear constraint flags
249 RendDesc &clear_flags();
251 //! Get constraint flags
252 int get_flags()const;
254 //! Return the aspect ratio of a single pixel
255 Point::value_type get_pixel_aspect()const;
257 //! Return the aspect ratio of the entire image
258 Point::value_type get_image_aspect()const;
260 //! Return the antialias amount
261 const int &get_antialias()const;
263 //! Set the antialias amount
264 RendDesc &set_antialias(const int &x);
266 //! Return the distance from the bottom-right to the top-left
267 Real get_span()const;
269 //! Set the span distance
270 RendDesc& set_span(const Real &x);
272 //! Gets the focus Point
273 const Point &get_focus()const;
274 //! Sets the focus Point
275 RendDesc &set_focus(const Point &x);
276 //! Gets the top left point of the compostion
277 const Point &get_tl()const;
278 //! Sets the top left point of the compostion
279 RendDesc &set_tl(const Point &x);
280 //! Gets the bottom right point of the compostion
281 const Point &get_br()const;
282 //! Sets the bottom right point of the compostion
283 RendDesc &set_br(const Point &x);
284 //! Returns the rectangle of the composition
285 Rect get_rect()const { return Rect(get_tl(),get_br()); }
286 //! Sets the view port by the top left and right bottom corners
287 RendDesc &set_viewport(const Point &__tl, const Point &__br);
288 //! Sets the view port by the four corners values
289 RendDesc &set_viewport(Vector::value_type a,Vector::value_type b,Vector::value_type c,Vector::value_type d);
290 //! Returns the width of one pixel
292 //! Returns the height of one pixel
294 //! Sets viewport to represent the screen at the given pixel coordinates
295 RendDesc &set_subwindow(int x, int y, int w, int h);
296 }; // END of class RendDesc
298 //! This operator allows the combining of RendDesc::Lock flags using the '|' operator
299 /*! \see RendDesc::Lock, RendDesc */
300 inline RendDesc::Lock operator|(RendDesc::Lock lhs, RendDesc::Lock rhs)
302 return static_cast<RendDesc::Lock>((int)lhs|(int)rhs);
305 //! This operator allows the masking of RendDesc::Lock flags using the '&' operator
306 /*! \see RendDesc::Lock, RendDesc */
307 inline RendDesc::Lock operator&(RendDesc::Lock lhs, RendDesc::Lock rhs)
309 return static_cast<RendDesc::Lock>((int)lhs&(int)rhs);
312 //! This operator allows the inverting of RendDesc::Lock flags using the '~' operator
313 /*! \see RendDesc::Lock, RendDesc */
314 inline RendDesc::Lock operator~(RendDesc::Lock rhs)
316 return static_cast<RendDesc::Lock>(~(int)rhs);
319 }; /* end namespace synfig */
321 /* === E N D =============================================================== */