gsl-shell.git - gsl-shell

index : gsl-shell.git
gsl-shell
summary refs log tree commit diff
path: root/agg-plot
diff options
context:
space:
mode:
authorfrancesco-ST <francesco.abbate@st.com>2010年12月28日 15:13:17 +0100
committerfrancesco-ST <francesco.abbate@st.com>2010年12月28日 15:13:17 +0100
commit5aee3720742fe153fe5937e0fd7981c1c95cd6cc (patch)
treedf13d14a231de74eea47727a6233a83bfe7b0b7a /agg-plot
parent45ae5dceb38d665e446960618cb8c1cda5f5afc5 (diff)
downloadgsl-shell-5aee3720742fe153fe5937e0fd7981c1c95cd6cc.tar.gz
multiple affine transforms get simplified into a single transform
Diffstat (limited to 'agg-plot')
-rw-r--r--agg-plot/agg-parse-trans.cpp 25
-rw-r--r--agg-plot/scalable.h 1
-rw-r--r--agg-plot/trans.h 6
3 files changed, 23 insertions, 9 deletions
diff --git a/agg-plot/agg-parse-trans.cpp b/agg-plot/agg-parse-trans.cpp
index 4547db24..24bfd33e 100644
--- a/agg-plot/agg-parse-trans.cpp
+++ b/agg-plot/agg-parse-trans.cpp
@@ -163,6 +163,19 @@ build_extend (lua_State *L, int specindex, typename context::base_type *obj)
return (typename context::base_type *) m;
}
+template <class context> typename context::base_type *
+affine_object_compose(typename context::base_type *obj, agg::trans_affine& m)
+{
+ typedef typename trans<context>::affine affine_type;
+
+ if (obj->affine_compose(m))
+ {
+ return obj;
+ }
+
+ return (typename context::base_type *) new affine_type(obj, m);
+}
+
template <class context> typename context::base_type*
build_translate (lua_State *L, int specindex, typename context::base_type *obj)
{
@@ -172,9 +185,7 @@ build_translate (lua_State *L, int specindex, typename context::base_type *obj)
double y = mlua_named_number (L, specindex, "y");
agg::trans_affine mtx(1.0, 0.0, 0.0, 1.0, x, y);
- affine_type *t = new affine_type(obj, mtx);
-
- return (typename context::base_type *) t;
+ return affine_object_compose<context>(obj, mtx);
}
template <class context> typename context::base_type*
@@ -191,9 +202,7 @@ build_scale (lua_State *L, int specindex, typename context::base_type *obj)
lua_pop (L, 1);
agg::trans_affine mtx(s, 0.0, 0.0, s, 0.0, 0.0);
- affine_type *t = new affine_type(obj, mtx);
-
- return (typename context::base_type *) t;
+ return affine_object_compose<context>(obj, mtx);
}
template <class context> typename context::base_type*
@@ -205,9 +214,7 @@ build_rotate (lua_State *L, int specindex, typename context::base_type *obj)
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 (typename context::base_type *) t;
+ return affine_object_compose<context>(obj, mtx);
}
template <class context>
diff --git a/agg-plot/scalable.h b/agg-plot/scalable.h
index 8599fd33..745323da 100644
--- a/agg-plot/scalable.h
+++ b/agg-plot/scalable.h
@@ -27,6 +27,7 @@ struct vertex_source {
virtual void rewind(unsigned path_id) = 0;
virtual unsigned vertex(double* x, double* y) = 0;
virtual void apply_transform(const agg::trans_affine& m, double as) = 0;
+ virtual bool affine_compose(agg::trans_affine& m) { return false; };
virtual ~vertex_source() { };
};
diff --git a/agg-plot/trans.h b/agg-plot/trans.h
index 00bd40c2..71727d12 100644
--- a/agg-plot/trans.h
+++ b/agg-plot/trans.h
@@ -86,6 +86,12 @@ struct trans {
{
this->m_source->apply_transform(m, as * m_norm);
};
+
+ virtual bool affine_compose(agg::trans_affine& m)
+ {
+ trans_affine_compose (this->m_matrix, m);
+ return true;
+ };
};
typedef agg::conv_transform<vertex_source> symbol_type;
generated by cgit v1.2.3 (git 2.25.1) at 2025年09月18日 11:34:29 +0000

AltStyle によって変換されたページ (->オリジナル) /