1 /* === S Y N F I G ========================================================= */
3 ** \brief Target Class Implementation
8 ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
9 ** Copyright (c) 2007 Chris Moore
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.
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.
22 /* ========================================================================= */
24 /* === S T A R T =========================================================== */
26 #ifndef __SYNFIG_TARGET_H
27 #define __SYNFIG_TARGET_H
29 /* === H E A D E R S ======================================================= */
31 #include <sigc++/signal.h>
32 #include "string_decl.h"
38 //#include "general.h"
42 /* === M A C R O S ========================================================= */
45 #define SYNFIG_TARGET_MODULE_EXT public: static const char name__[], version__[], ext__[],cvs_id__[]; static Target *create(const char *filename);
47 //! Sets the name of the target
48 #define SYNFIG_TARGET_SET_NAME(class,x) const char class::name__[]=x
51 #define SYNFIG_TARGET_SET_EXT(class,x) const char class::ext__[]=x
53 //! Sets the version of the target
54 #define SYNFIG_TARGET_SET_VERSION(class,x) const char class::version__[]=x
56 //! Sets the CVS ID of the target
57 #define SYNFIG_TARGET_SET_CVS_ID(class,x) const char class::cvs_id__[]=x
60 #define SYNFIG_TARGET_INIT(class) synfig::Target* class::create(const char *filename) { return new class(filename); }
62 /* === T Y P E D E F S ===================================================== */
64 /* === C L A S S E S & S T R U C T S ======================================= */
71 class ProgressCallback;
74 ** \brief Render-target
77 class Target : public etl::shared_object
80 typedef etl::handle<Target> Handle;
81 typedef etl::loose_handle<Target> LooseHandle;
82 typedef etl::handle<const Target> ConstHandle;
85 -- ** -- S I G N A L S -------------------------------------------------------
90 sigc::signal<void> signal_progress_;
93 -- ** -- S I G N A L I N T E R F A C E -------------------------------------
98 sigc::signal<void>& signal_progress() { return signal_progress_; }
101 -- ** -- C O N S T R U C T O R S ---------------------------------------------
105 typedef Target* (*Factory)(const char *filename);
107 //! A type for a map of targets, indexed by the name of the Target
108 typedef std::map<String,std::pair<Factory,String> > Book;
110 typedef std::map<String,String> ExtBook;
112 //! Target Book, indexed by the target's name
115 //! Map of target names indexed by associated file extension
116 static ExtBook* ext_book_;
119 static ExtBook& ext_book();
121 static bool subsys_init();
122 static bool subsys_stop();
124 //! Adjusted Render description set by set_rend_desc()
127 etl::handle<Canvas> canvas;
134 bool avoid_time_sync_;
141 virtual ~Target() { }
143 int get_quality()const { return quality_; }
145 void set_quality(int q) { quality_=q; }
147 void set_avoid_time_sync(bool x=true) { avoid_time_sync_=x; }
149 bool get_avoid_time_sync()const { return avoid_time_sync_; }
151 bool get_remove_alpha()const { return remove_alpha; }
153 void set_remove_alpha(bool x=true) { remove_alpha=x; }
155 Gamma &gamma() { return gamma_; }
157 const Gamma &gamma()const { return gamma_; }
159 virtual void set_canvas(etl::handle<Canvas> c);
161 const etl::handle<Canvas> &get_canvas()const { return canvas; }
163 RendDesc &rend_desc() { return desc; }
164 const RendDesc &rend_desc()const { return desc; }
166 //! Renders the canvas to the target
167 virtual bool render(ProgressCallback *cb=NULL)=0;
169 //! Sets the RendDesc for the Target to \a desc.
170 /*! If there are any parts of \a desc that the render target
171 ** is not capable of doing, the render target will adjust
172 ** \a desc to fit its needs.
174 virtual bool set_rend_desc(RendDesc *d) { desc=*d; return true; }
176 virtual bool init() { return true; }
178 //! Creates a new Target described by \a type, outputting to a file described by \a filename.
179 static Handle create(const String &type, const String &filename);
180 }; // END of class Target
182 }; // END of namespace synfig
184 /* === E N D =============================================================== */