author | francesco-ST <francesco.abbate@st.com> | 2010年08月02日 15:34:55 +0200 |
---|---|---|
committer | francesco-ST <francesco.abbate@st.com> | 2010年08月02日 15:34:55 +0200 |
commit | 16eec33fbb475ade30821eb41ac796ec1f0a4f7d (patch) | |
tree | 0b16c9dbd21f7277e59163f0b725f6a78c1820ab | |
parent | 5a132340703270e5de65fed6499e475846a56dd5 (diff) | |
download | gsl-shell-16eec33fbb475ade30821eb41ac796ec1f0a4f7d.tar.gz |
-rw-r--r-- | agg-plot/agg-parse-trans.cpp | 51 | ||||
-rw-r--r-- | agg-plot/drawable.h | 13 | ||||
-rw-r--r-- | agg-plot/scalable.h | 15 |
diff --git a/agg-plot/agg-parse-trans.cpp b/agg-plot/agg-parse-trans.cpp index 3424c0e1..b4abc4af 100644 --- a/agg-plot/agg-parse-trans.cpp +++ b/agg-plot/agg-parse-trans.cpp @@ -24,16 +24,6 @@ struct property_reg { const char *name; }; -/* -static vertex_source * build_stroke (lua_State *L, int i, vertex_source *s); -static vertex_source * build_curve (lua_State *L, int i, vertex_source *s); -static vertex_source * build_marker (lua_State *L, int i, vertex_source *s); -static vertex_source * build_dash (lua_State *L, int i, vertex_source *s); -static vertex_source * build_extend (lua_State *L, int i, vertex_source *s); -static vertex_source * build_translate (lua_State *L, int i, vertex_source *s); -static vertex_source * build_rotate (lua_State *L, int i, vertex_source *s); -*/ - struct property_reg line_cap_properties[] = { {(int) agg::butt_cap, "butt" }, {(int) agg::square_cap, "square"}, @@ -165,30 +155,33 @@ build_extend (lua_State *L, int specindex, typename context::base_type *obj) return (typename context::base_type *) m; } -/* -vertex_source * -build_translate (lua_State *L, int specindex, vertex_source *obj) +template <class context> typename context::base_type* +build_translate (lua_State *L, int specindex, typename context::base_type *obj) { + typedef typename trans<context>::affine affine_type; + double x = mlua_named_number (L, specindex, "x"); double y = mlua_named_number (L, specindex, "y"); - trans::affine *t = new trans::affine(obj); - t->translate(x, y); + agg::trans_affine mtx(1.0, 0.0, 0.0, 1.0, x, y); + affine_type *t = new affine_type(obj, mtx); - return (vertex_source *) t; + return (typename context::base_type *) t; } -vertex_source * -build_rotate (lua_State *L, int specindex, vertex_source *obj) +template <class context> typename context::base_type* +build_rotate (lua_State *L, int specindex, typename context::base_type *obj) { + typedef typename trans<context>::affine affine_type; + double a = mlua_named_number (L, specindex, "angle"); - trans::affine *t = new trans::affine(obj); - t->rotate(a); + double c = cos(a), s = sin(a); + agg::trans_affine mtx(c, s, -s, c, 0.0, 0.0); + affine_type *t = new affine_type(obj, mtx); - return (vertex_source *) t; + return (typename context::base_type *) t; } -*/ template <class context> class builder { @@ -221,13 +214,13 @@ public: template <class context> const typename builder<context>::reg builder<context>::builder_table[] = { - {"stroke", build_stroke<context> }, - {"dash", build_dash <context> }, - {"curve", build_curve <context> }, - {"marker", build_marker<context> }, - {"extend", build_extend<context> }, - // {"translate", build_translate}, - // {"rotate", build_rotate}, + {"stroke", build_stroke <context>}, + {"dash", build_dash <context>}, + {"curve", build_curve <context>}, + {"marker", build_marker <context>}, + {"extend", build_extend <context>}, + {"translate", build_translate<context>}, + {"rotate", build_rotate <context>}, {NULL, NULL} }; diff --git a/agg-plot/drawable.h b/agg-plot/drawable.h index 66e4e5f8..d786b3a7 100644 --- a/agg-plot/drawable.h +++ b/agg-plot/drawable.h @@ -7,7 +7,7 @@ #include "agg_conv_transform.h" // Interface -class window_object { +struct window_object { public: virtual void apply_transform(const agg::trans_affine& m) = 0; virtual void bounding_box(double *x1, double *y1, double *x2, double *y2) = 0; @@ -17,16 +17,7 @@ public: virtual ~window_object() { }; }; -class drawable: public vertex_source, public window_object { -public: - virtual void apply_transform(const agg::trans_affine& m) = 0; - virtual void bounding_box(double *x1, double *y1, double *x2, double *y2) = 0; - - virtual bool dispose() = 0; - - virtual void rewind(unsigned path_id) = 0; - virtual unsigned vertex(double* x, double* y) = 0; - +struct drawable: public vertex_source, public window_object { virtual ~drawable() { }; }; diff --git a/agg-plot/scalable.h b/agg-plot/scalable.h index 2f0188ee..c27e1e35 100644 --- a/agg-plot/scalable.h +++ b/agg-plot/scalable.h @@ -1,30 +1,21 @@ #ifndef AGGPLOT_SCALABLE_H #define AGGPLOT_SCALABLE_H -class vertex_source { -public: +struct vertex_source { virtual void rewind(unsigned path_id) = 0; virtual unsigned vertex(double* x, double* y) = 0; virtual ~vertex_source() { }; }; -class scalable_object { -public: +struct scalable_object { virtual void approximation_scale(double as) = 0; virtual bool dispose() = 0; virtual ~scalable_object() { }; }; -class scalable : public vertex_source, public scalable_object { -public: - virtual void rewind(unsigned path_id) = 0; - virtual unsigned vertex(double* x, double* y) = 0; - - virtual void approximation_scale(double as) = 0; - virtual bool dispose() = 0; - +struct scalable : public vertex_source, public scalable_object { virtual ~scalable() { }; }; |