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 //! Type that represents a pointer to a Target's constructor.
106 /*! As a pointer to the constructor, it represents a "factory" of targets.
107 ** Receives the output filename (including path).
109 typedef Target* (*Factory)(const char *filename);
114 String filename; ///< Output filename including path
117 //! Book of types of targets indexed by the name of the Target.
118 typedef std::map<String,BookEntry> Book;
120 typedef std::map<String,String> ExtBook;
122 //! Target Book, indexed by the target's name
125 //! Map of target names indexed by associated file extension
126 static ExtBook* ext_book_;
129 static ExtBook& ext_book();
131 static bool subsys_init();
132 static bool subsys_stop();
134 //! Adjusted Render description set by set_rend_desc()
137 etl::handle<Canvas> canvas;
144 bool avoid_time_sync_;
151 virtual ~Target() { }
153 int get_quality()const { return quality_; }
155 void set_quality(int q) { quality_=q; }
157 void set_avoid_time_sync(bool x=true) { avoid_time_sync_=x; }
159 bool get_avoid_time_sync()const { return avoid_time_sync_; }
161 bool get_remove_alpha()const { return remove_alpha; }
163 void set_remove_alpha(bool x=true) { remove_alpha=x; }
165 Gamma &gamma() { return gamma_; }
167 const Gamma &gamma()const { return gamma_; }
169 virtual void set_canvas(etl::handle<Canvas> c);
171 const etl::handle<Canvas> &get_canvas()const { return canvas; }
173 RendDesc &rend_desc() { return desc; }
174 const RendDesc &rend_desc()const { return desc; }
176 //! Renders the canvas to the target
177 virtual bool render(ProgressCallback *cb=NULL)=0;
179 //! Sets the RendDesc for the Target to \a desc.
180 /*! If there are any parts of \a desc that the render target
181 ** is not capable of doing, the render target will adjust
182 ** \a desc to fit its needs.
184 virtual bool set_rend_desc(RendDesc *d) { desc=*d; return true; }
186 virtual bool init() { return true; }
188 //! Creates a new Target described by \a type, outputting to a file described by \a filename.
189 static Handle create(const String &type, const String &filename);
190 }; // END of class Target
192 }; // END of namespace synfig
194 /* === E N D =============================================================== */