1 /*! ========================================================================
4 ** $Id: translate.cpp,v 1.2 2005/01/24 03:08:17 darco Exp $
6 ** Copyright (c) 2002 Robert B. Quattlebaum Jr.
8 ** This software and associated documentation
9 ** are CONFIDENTIAL and PROPRIETARY property of
10 ** the above-mentioned copyright holder.
12 ** You may not copy, print, publish, or in any
13 ** other way distribute this software without
14 ** a prior written agreement with
15 ** the copyright holder.
17 ** === N O T E S ===========================================================
19 ** ========================================================================= */
21 /* === H E A D E R S ======================================================= */
30 #include "translate.h"
31 #include <sinfg/string.h>
32 #include <sinfg/time.h>
33 #include <sinfg/context.h>
34 #include <sinfg/paramdesc.h>
35 #include <sinfg/renddesc.h>
36 #include <sinfg/surface.h>
37 #include <sinfg/value.h>
38 #include <sinfg/valuenode.h>
39 #include <sinfg/canvas.h>
40 #include <sinfg/transform.h>
44 /* === M A C R O S ========================================================= */
46 /* === G L O B A L S ======================================================= */
48 SINFG_LAYER_INIT(Translate);
49 SINFG_LAYER_SET_NAME(Translate,"translate");
50 SINFG_LAYER_SET_LOCAL_NAME(Translate,_("Translate"));
51 SINFG_LAYER_SET_CATEGORY(Translate,_("Transform"));
52 SINFG_LAYER_SET_VERSION(Translate,"0.1");
53 SINFG_LAYER_SET_CVS_ID(Translate,"$Id: translate.cpp,v 1.2 2005/01/24 03:08:17 darco Exp $");
55 /* === P R O C E D U R E S ================================================= */
57 /* === M E T H O D S ======================================================= */
59 /* === E N T R Y P O I N T ================================================= */
61 Translate::Translate():origin(0,0)
65 Translate::~Translate()
70 Translate::set_param(const String & param, const ValueBase &value)
78 Translate::get_param(const String& param)const
88 Translate::get_param_vocab()const
92 ret.push_back(ParamDesc("origin")
93 .set_local_name(_("Origin"))
94 .set_description(_("Point where you want the origin to be"))
101 Translate::hit_check(sinfg::Context context, const sinfg::Point &pos)const
103 return context.hit_check(pos-origin);
107 Translate::get_color(Context context, const Point &pos)const
109 return context.get_color(pos-origin);
112 class Translate_Trans : public Transform
114 etl::handle<const Translate> layer;
116 Translate_Trans(const Translate* x):Transform(x->get_guid()),layer(x) { }
118 sinfg::Vector perform(const sinfg::Vector& x)const
120 return x+layer->origin;
123 sinfg::Vector unperform(const sinfg::Vector& x)const
125 return x-layer->origin;
128 etl::handle<Transform>
129 Translate::get_transform()const
131 return new Translate_Trans(this);
135 Translate::accelerated_render(Context context,Surface *surface,int quality, const RendDesc &renddesc, ProgressCallback *cb)const
137 RendDesc desc(renddesc);
140 desc.set_tl(desc.get_tl()-origin);
141 desc.set_br(desc.get_br()-origin);
144 if(!context.accelerated_render(surface,quality,desc,cb))
146 if(cb)cb->error(strprintf(__FILE__"%d: Accelerated Renderer Failure",__LINE__));
154 Translate::get_full_bounding_rect(Context context)const
156 return context.get_full_bounding_rect() + origin;