author | francesco-ST <francesco.abbate@st.com> | 2010年07月07日 10:41:43 +0200 |
---|---|---|
committer | francesco-ST <francesco.abbate@st.com> | 2010年07月07日 10:41:43 +0200 |
commit | 395c1cfb10a9f51990993d509d96f8c2f9ed47ab (patch) | |
tree | 2d21fdbacc5493480b2f7be89df466d656a2871a /agg-plot | |
parent | e0f29ca732d23d0dbfec5399d4740ed67c1232a9 (diff) | |
download | gsl-shell-395c1cfb10a9f51990993d509d96f8c2f9ed47ab.tar.gz |
-rw-r--r-- | agg-plot/Makefile | 182 | ||||
-rw-r--r-- | agg-plot/colors.cpp | 104 | ||||
-rw-r--r-- | agg-plot/colors.h | 28 | ||||
-rw-r--r-- | agg-plot/lua-cpp-utils.cpp | 4 | ||||
-rw-r--r-- | agg-plot/lua-cpp-utils.h | 40 | ||||
-rw-r--r-- | agg-plot/lua-draw.h | 96 | ||||
-rw-r--r-- | agg-plot/lua-plot.h | 74 | ||||
-rw-r--r-- | agg-plot/resource-manager.h | 60 | ||||
-rw-r--r-- | agg-plot/trans.h | 342 |
diff --git a/agg-plot/Makefile b/agg-plot/Makefile index 7f5c9b0c..e1945ae2 100644 --- a/agg-plot/Makefile +++ b/agg-plot/Makefile @@ -1,91 +1,91 @@ -
-# Makefile
-#
-# Copyright (C) 2009 Francesco Abbate
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3 of the License, or (at
-# your option) any later version.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-
-GSH_BASE_DIR = ..
-
-include $(GSH_BASE_DIR)/makeconfig
-include $(GSH_BASE_DIR)/makeflags
-include $(GSH_BASE_DIR)/make-packages
-
-LUADIR = $(GSH_BASE_DIR)/lua
-AR= ar rcu
-RANLIB= ranlib
-
-ifeq ($(PLATFORM), none)
-nono:
- @echo "You haven't edited 'makeconfig' yet. Set your settings there, then run 'make' again"
-endif
-
-ifeq ($(strip $(PLATFORM)), mingw)
-# Option for Windows Platform
- DEFS += -DWIN32
- INCLUDES += -I/usr/include -I/usr/pthreads-w32/include
- PLATSUP_SRC_FILES = agg_platform_support_win32.cpp agg_win32_bmp.cpp
-else
- PLATSUP_SRC_FILES = agg_platform_support_x11.cpp
-endif
-
-INCLUDES += $(AGG_INCLUDES) -I$(GSH_BASE_DIR) -I$(LUADIR)/src
-
-AGGPLOT_SRC_FILES = $(PLATSUP_SRC_FILES) utils.cpp units.cpp colors.cpp lua-draw.cpp lua-plot.cpp xwin-show.cpp
-
-AGGPLOT_OBJ_FILES := $(AGGPLOT_SRC_FILES:%.cpp=%.o)
-
-DEP_FILES := $(AGGPLOT_SRC_FILES:%.cpp=.deps/%.P)
-
-DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :)
-
-CXXCOMPILE = $(CXX) $(CXXFLAGS) $(DEFS) $(INCLUDES)
-
-TARGETS = libaggplot.a
-
-all: $(TARGETS)
-
-#test.exe: $(AGGPLOT_OBJ_FILES)
-# gcc -o test.exe $(AGGPLOT_OBJ_FILES) $(AGG_LIBS)
-
-libaggplot.a: $(AGGPLOT_OBJ_FILES)
- $(AR) $@ $?
- $(RANLIB) $@
-
-%.o: %.cpp
- @echo $(CXXCOMPILE) -c $<
- @$(CXXCOMPILE) -Wp,-MMD,.deps/$(*F).pp -c $<
- @-cp .deps/$(*F).pp .deps/$(*F).P; \
- tr ' ' '012円' < .deps/$(*F).pp \
- | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
- >> .deps/$(*F).P; \
- rm .deps/$(*F).pp
-
-%.o: %.c
- @echo $(COMPILE) -c $<
- @$(COMPILE) -Wp,-MMD,.deps/$(*F).pp -c $<
- @-cp .deps/$(*F).pp .deps/$(*F).P; \
- tr ' ' '012円' < .deps/$(*F).pp \
- | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
- >> .deps/$(*F).P; \
- rm .deps/$(*F).pp
-
-.PHONY: clean all
-
-clean:
- $(RM) *.o *.lo *.la *.so *.dll $(TARGETS)
-
--include $(DEP_FILES)
+ +# Makefile +# +# Copyright (C) 2009 Francesco Abbate +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# + +GSH_BASE_DIR = .. + +include $(GSH_BASE_DIR)/makeconfig +include $(GSH_BASE_DIR)/makeflags +include $(GSH_BASE_DIR)/make-packages + +LUADIR = $(GSH_BASE_DIR)/lua +AR= ar rcu +RANLIB= ranlib + +ifeq ($(PLATFORM), none) +nono: + @echo "You haven't edited 'makeconfig' yet. Set your settings there, then run 'make' again" +endif + +ifeq ($(strip $(PLATFORM)), mingw) +# Option for Windows Platform + DEFS += -DWIN32 + INCLUDES += -I/usr/include -I/usr/pthreads-w32/include + PLATSUP_SRC_FILES = agg_platform_support_win32.cpp agg_win32_bmp.cpp +else + PLATSUP_SRC_FILES = agg_platform_support_x11.cpp +endif + +INCLUDES += $(AGG_INCLUDES) -I$(GSH_BASE_DIR) -I$(LUADIR)/src + +AGGPLOT_SRC_FILES = $(PLATSUP_SRC_FILES) utils.cpp units.cpp colors.cpp lua-draw.cpp lua-plot.cpp xwin-show.cpp + +AGGPLOT_OBJ_FILES := $(AGGPLOT_SRC_FILES:%.cpp=%.o) + +DEP_FILES := $(AGGPLOT_SRC_FILES:%.cpp=.deps/%.P) + +DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :) + +CXXCOMPILE = $(CXX) $(CXXFLAGS) $(DEFS) $(INCLUDES) + +TARGETS = libaggplot.a + +all: $(TARGETS) + +#test.exe: $(AGGPLOT_OBJ_FILES) +# gcc -o test.exe $(AGGPLOT_OBJ_FILES) $(AGG_LIBS) + +libaggplot.a: $(AGGPLOT_OBJ_FILES) + $(AR) $@ $? + $(RANLIB) $@ + +%.o: %.cpp + @echo $(CXXCOMPILE) -c $< + @$(CXXCOMPILE) -Wp,-MMD,.deps/$(*F).pp -c $< + @-cp .deps/$(*F).pp .deps/$(*F).P; \ + tr ' ' '012円' < .deps/$(*F).pp \ + | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \ + >> .deps/$(*F).P; \ + rm .deps/$(*F).pp + +%.o: %.c + @echo $(COMPILE) -c $< + @$(COMPILE) -Wp,-MMD,.deps/$(*F).pp -c $< + @-cp .deps/$(*F).pp .deps/$(*F).P; \ + tr ' ' '012円' < .deps/$(*F).pp \ + | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \ + >> .deps/$(*F).P; \ + rm .deps/$(*F).pp + +.PHONY: clean all + +clean: + $(RM) *.o *.lo *.la *.so *.dll $(TARGETS) + +-include $(DEP_FILES) diff --git a/agg-plot/colors.cpp b/agg-plot/colors.cpp index c1ea0ea6..e4ea0807 100644 --- a/agg-plot/colors.cpp +++ b/agg-plot/colors.cpp @@ -1,52 +1,52 @@ -
-#include <string.h>
-
-#include "lua-cpp-utils.h"
-#include "colors.h"
-
-agg::rgba8 *
-rgba8_push_default (lua_State *L)
-{
- return new(L, GS_RGBA_COLOR) agg::rgba8(180, 0, 0, 255);
-}
-
-agg::rgba8 *
-rgba8_push_lookup (lua_State *L, const char *color_str)
-{
- const char *p = color_str;
- const int a = 255;
-
- if (strcmp (p, "white") == 0)
- return new(L, GS_RGBA_COLOR) agg::rgba8(255, 255, 255, a);
-
- int val = 180;
- int r = 0, g = 0, b = 0;
-
- if (strncmp (p, "light", 5) == 0)
- {
- val = 255;
- p += 5;
- }
- else if (strncmp (p, "dark", 4) == 0)
- {
- val = 120;
- p += 4;
- }
-
- if (strcmp (p, "red") == 0)
- r = val;
- else if (strcmp (p, "green") == 0)
- g = val;
- else if (strcmp (p, "blue") == 0)
- b = val;
- else if (strcmp (p, "cyan") == 0)
- g = b = val;
- else if (strcmp (p, "magenta") == 0)
- r = b = val;
- else if (strcmp (p, "yellow") == 0)
- r = g = val;
- else if (strcmp (p, "gray") == 0)
- r = g = b = val;
-
- return new(L, GS_RGBA_COLOR) agg::rgba8(r, g, b, a);
-}
+ +#include <string.h> + +#include "lua-cpp-utils.h" +#include "colors.h" + +agg::rgba8 * +rgba8_push_default (lua_State *L) +{ + return new(L, GS_RGBA_COLOR) agg::rgba8(180, 0, 0, 255); +} + +agg::rgba8 * +rgba8_push_lookup (lua_State *L, const char *color_str) +{ + const char *p = color_str; + const int a = 255; + + if (strcmp (p, "white") == 0) + return new(L, GS_RGBA_COLOR) agg::rgba8(255, 255, 255, a); + + int val = 180; + int r = 0, g = 0, b = 0; + + if (strncmp (p, "light", 5) == 0) + { + val = 255; + p += 5; + } + else if (strncmp (p, "dark", 4) == 0) + { + val = 120; + p += 4; + } + + if (strcmp (p, "red") == 0) + r = val; + else if (strcmp (p, "green") == 0) + g = val; + else if (strcmp (p, "blue") == 0) + b = val; + else if (strcmp (p, "cyan") == 0) + g = b = val; + else if (strcmp (p, "magenta") == 0) + r = b = val; + else if (strcmp (p, "yellow") == 0) + r = g = val; + else if (strcmp (p, "gray") == 0) + r = g = b = val; + + return new(L, GS_RGBA_COLOR) agg::rgba8(r, g, b, a); +} diff --git a/agg-plot/colors.h b/agg-plot/colors.h index 560b6a5c..6add76f2 100644 --- a/agg-plot/colors.h +++ b/agg-plot/colors.h @@ -1,14 +1,14 @@ -#ifndef AGGPLOT_COLORS_H
-#define AGGPLOT_COLORS_H
-
-extern "C" {
-#include "lua.h"
-}
-
-#include "defs.h"
-#include "agg_color_rgba.h"
-
-extern agg::rgba8 * rgba8_push_lookup(lua_State *L, const char *color_str);
-extern agg::rgba8 * rgba8_push_default(lua_State *L);
-
-#endif
+#ifndef AGGPLOT_COLORS_H +#define AGGPLOT_COLORS_H + +extern "C" { +#include "lua.h" +} + +#include "defs.h" +#include "agg_color_rgba.h" + +extern agg::rgba8 * rgba8_push_lookup(lua_State *L, const char *color_str); +extern agg::rgba8 * rgba8_push_default(lua_State *L); + +#endif diff --git a/agg-plot/lua-cpp-utils.cpp b/agg-plot/lua-cpp-utils.cpp index 2fce32bc..90f0716e 100644 --- a/agg-plot/lua-cpp-utils.cpp +++ b/agg-plot/lua-cpp-utils.cpp @@ -1,2 +1,2 @@ -
-#include "lua-cpp-utils.h"
+ +#include "lua-cpp-utils.h" diff --git a/agg-plot/lua-cpp-utils.h b/agg-plot/lua-cpp-utils.h index df0c97bd..9ded6bb0 100644 --- a/agg-plot/lua-cpp-utils.h +++ b/agg-plot/lua-cpp-utils.h @@ -1,20 +1,20 @@ -#ifndef LUA_CPP_UTILS_H
-#define LUA_CPP_UTILS_H
-
-#include <new>
-
-#include "defs.h"
-__BEGIN_DECLS
-#include "lua.h"
-__END_DECLS
-
-#include "gs-types.h"
-
-inline void* operator new(size_t nbytes, lua_State *L, enum gs_type_e tp)
-{
- void* p = lua_newuserdata(L, nbytes);
- gs_set_metatable (L, tp);
- return p;
-}
-
-#endif
+#ifndef LUA_CPP_UTILS_H +#define LUA_CPP_UTILS_H + +#include <new> + +#include "defs.h" +__BEGIN_DECLS +#include "lua.h" +__END_DECLS + +#include "gs-types.h" + +inline void* operator new(size_t nbytes, lua_State *L, enum gs_type_e tp) +{ + void* p = lua_newuserdata(L, nbytes); + gs_set_metatable (L, tp); + return p; +} + +#endif diff --git a/agg-plot/lua-draw.h b/agg-plot/lua-draw.h index d7f94550..3df6fc9d 100644 --- a/agg-plot/lua-draw.h +++ b/agg-plot/lua-draw.h @@ -1,48 +1,48 @@ -#ifndef LUA_DRAW_H
-#define LUA_DRAW_H
-
-
-#include "defs.h"
-
-#include <pthread.h>
-
-__BEGIN_DECLS
-#include "lua.h"
-__END_DECLS
-
-#ifdef __cplusplus
-
-#include "vertex-source.h"
-#include "drawables.h"
-#include "trans.h"
-
-extern int agg_text_new (lua_State *L);
-extern int agg_path_new (lua_State *L);
-extern int agg_rgb_new (lua_State *L);
-extern int agg_rgba_new (lua_State *L);
-
-extern vertex_source* check_agg_obj (lua_State *L, int index);
-extern my::path* check_agg_path (lua_State *L, int index);
-extern my::text* check_agg_text (lua_State *L, int index);
-extern agg::rgba8* check_agg_rgba8 (lua_State *L, int index);
-
-#endif
-
-__BEGIN_DECLS
-
-extern pthread_mutex_t agg_mutex[1];
-
-#define AGG_LOCK() pthread_mutex_lock (agg_mutex);
-#define AGG_UNLOCK() pthread_mutex_unlock (agg_mutex);
-
-#define AGG_PROTECT(op) { \
- pthread_mutex_lock (agg_mutex); \
- op; \
- pthread_mutex_unlock (agg_mutex); \
- }
-
-extern void draw_register (lua_State *L);
-
-__END_DECLS
-
-#endif
+#ifndef LUA_DRAW_H +#define LUA_DRAW_H + + +#include "defs.h" + +#include <pthread.h> + +__BEGIN_DECLS +#include "lua.h" +__END_DECLS + +#ifdef __cplusplus + +#include "vertex-source.h" +#include "drawables.h" +#include "trans.h" + +extern int agg_text_new (lua_State *L); +extern int agg_path_new (lua_State *L); +extern int agg_rgb_new (lua_State *L); +extern int agg_rgba_new (lua_State *L); + +extern vertex_source* check_agg_obj (lua_State *L, int index); +extern my::path* check_agg_path (lua_State *L, int index); +extern my::text* check_agg_text (lua_State *L, int index); +extern agg::rgba8* check_agg_rgba8 (lua_State *L, int index); + +#endif + +__BEGIN_DECLS + +extern pthread_mutex_t agg_mutex[1]; + +#define AGG_LOCK() pthread_mutex_lock (agg_mutex); +#define AGG_UNLOCK() pthread_mutex_unlock (agg_mutex); + +#define AGG_PROTECT(op) { \ + pthread_mutex_lock (agg_mutex); \ + op; \ + pthread_mutex_unlock (agg_mutex); \ + } + +extern void draw_register (lua_State *L); + +__END_DECLS + +#endif diff --git a/agg-plot/lua-plot.h b/agg-plot/lua-plot.h index ffc06393..98cd2a07 100644 --- a/agg-plot/lua-plot.h +++ b/agg-plot/lua-plot.h @@ -1,37 +1,37 @@ -#ifndef LUA_CPLOT_H
-#define LUA_CPLOT_H
-
-#include "defs.h"
-
-__BEGIN_DECLS
-#include "lua.h"
-__END_DECLS
-
-#ifdef __cplusplus
-
-#include "plot.h"
-#include "resource-manager.h"
-
-typedef plot<vertex_source, no_management> plot_type;
-
-struct agg_plot : public plot_type {
- bool is_shown;
- void *window;
- int id;
-
- agg_plot() : plot_type(), is_shown(false), window(NULL), id(0) {};
-
- void wait_update();
-
- static agg_plot* arg_check(lua_State *L, int index);
-};
-
-#endif
-
-__BEGIN_DECLS
-
-extern void plot_register (lua_State *L);
-
-__END_DECLS
-
-#endif
+#ifndef LUA_CPLOT_H +#define LUA_CPLOT_H + +#include "defs.h" + +__BEGIN_DECLS +#include "lua.h" +__END_DECLS + +#ifdef __cplusplus + +#include "plot.h" +#include "resource-manager.h" + +typedef plot<vertex_source, no_management> plot_type; + +struct agg_plot : public plot_type { + bool is_shown; + void *window; + int id; + + agg_plot() : plot_type(), is_shown(false), window(NULL), id(0) {}; + + void wait_update(); + + static agg_plot* arg_check(lua_State *L, int index); +}; + +#endif + +__BEGIN_DECLS + +extern void plot_register (lua_State *L); + +__END_DECLS + +#endif diff --git a/agg-plot/resource-manager.h b/agg-plot/resource-manager.h index c965a49c..2a794d63 100644 --- a/agg-plot/resource-manager.h +++ b/agg-plot/resource-manager.h @@ -1,30 +1,30 @@ -#ifndef AGGPLOT_RESOURCE_MANAGER_H
-#define AGGPLOT_RESOURCE_MANAGER_H
-
-
-class no_management {
- public:
- template <class T>
- static void acquire(T* p) {};
-
- template <class T>
- static void dispose(T* p) {};
-};
-
-/*
-class ref_manager {
-public:
- template <class T>
- static void acquire(T* p) { p->ref(); };
-
- template <class T>
- static void dispose(T* p)
- {
- unsigned rc = p->unref();
- if (rc == 0)
- delete p;
- };
-};
-*/
-
-#endif
+#ifndef AGGPLOT_RESOURCE_MANAGER_H +#define AGGPLOT_RESOURCE_MANAGER_H + + +class no_management { + public: + template <class T> + static void acquire(T* p) {}; + + template <class T> + static void dispose(T* p) {}; +}; + +/* +class ref_manager { +public: + template <class T> + static void acquire(T* p) { p->ref(); }; + + template <class T> + static void dispose(T* p) + { + unsigned rc = p->unref(); + if (rc == 0) + delete p; + }; +}; +*/ + +#endif diff --git a/agg-plot/trans.h b/agg-plot/trans.h index 0cdacee2..93a94405 100644 --- a/agg-plot/trans.h +++ b/agg-plot/trans.h @@ -1,171 +1,171 @@ -#ifndef AGGPLOT_TRANS_H
-#define AGGPLOT_TRANS_H
-
-#include "agg_trans_affine.h"
-#include "agg_conv_stroke.h"
-#include "agg_conv_curve.h"
-#include "agg_conv_dash.h"
-#include "agg_conv_transform.h"
-#include "agg_vcgen_markers_term.h"
-#include "agg_arrowhead.h"
-#include "agg_bounding_rect.h"
-#include "agg_ellipse.h"
-
-#include "my_conv_simple_marker.h"
-
-#include "utils.h"
-#include "vertex-source.h"
-
-template<class T>
-class vs_trans_proxy : public vertex_source {
-protected:
- T m_output;
- vertex_source* m_source;
-
-public:
- vs_trans_proxy(vertex_source* src): m_output(*src), m_source(src)
- {
- };
-
- template <class init_type>
- vs_trans_proxy(vertex_source* src, init_type& val):
- m_output(*src, val), m_source(src)
- {};
-
- virtual void rewind(unsigned path_id) { m_output.rewind(path_id); };
- virtual unsigned vertex(double* x, double* y) { return m_output.vertex(x, y); };
-
- /*
- virtual void ref() { m_source->ref(); };
- virtual unsigned unref()
- {
- unsigned rc = m_source->unref();
- if (rc == 0)
- delete m_source;
- return 0;
- };
- */
-
- virtual void apply_transform(agg::trans_affine& m, double as)
- {
- m_source->apply_transform(m, as);
- };
-
- virtual void bounding_box(double *x1, double *y1, double *x2, double *y2)
- {
- m_source->bounding_box(x1, y1, x2, y2);
- };
-
- T& self() { return m_output; };
-};
-
-typedef vs_trans_proxy<agg::conv_stroke<vertex_source> > vs_stroke;
-typedef vs_trans_proxy<agg::conv_curve<vertex_source> > vs_curve;
-typedef vs_trans_proxy<agg::conv_dash<vertex_source> > vs_dash;
-typedef vs_trans_proxy<agg::conv_transform<vertex_source> > vs_transform;
-
-namespace trans {
-
- class stroke : public vs_stroke {
- public:
- typedef agg::conv_stroke<vertex_source> base_type;
-
- stroke(vertex_source* src, double width = 1.0): vs_stroke(src)
- {
- base_type& v = self();
- v.width(width);
- };
-
- virtual void apply_transform(agg::trans_affine& m, double as)
- {
- m_output.approximation_scale(as);
- m_source->apply_transform(m, as);
- };
-
- void line_cap(agg::line_cap_e cap)
- {
- m_output.line_cap(cap);
- };
-
- void line_join(agg::line_join_e join)
- {
- m_output.line_join(join);
- };
- };
-
- class curve : public vs_curve {
- public:
- curve(vertex_source* src): vs_curve(src) {};
-
- virtual void apply_transform(agg::trans_affine& m, double as)
- {
- m_output.approximation_scale(as);
- m_source->apply_transform(m, as);
- };
- };
-
- class dash : public vs_dash {
- public:
- dash(vertex_source* src): vs_dash(src) {};
-
- void add_dash(double dash_len, double gap_len)
- {
- m_output.add_dash(dash_len, gap_len);
- }
- };
-
- typedef vs_trans_proxy<my::conv_simple_marker<vertex_source, agg::ellipse> > vs_marker_ellipse;
-
- class marker : public vs_marker_ellipse {
- agg::ellipse m_ellipse;
-
- public:
- marker(vertex_source* src, double size): vs_marker_ellipse(src, m_ellipse)
- {
- m_ellipse.init(0.0, 0.0, size/2, size/2);
- };
-
- virtual void apply_transform(agg::trans_affine& m, double as)
- {
- m_ellipse.approximation_scale(as);
- m_source->apply_transform(m, as);
- };
- };
-
- class resize : public vs_transform {
- agg::trans_affine m_matrix;
-
- public:
- resize(vertex_source* src): vs_transform(src, m_matrix), m_matrix() {};
-
- virtual void apply_transform(agg::trans_affine& m, double as)
- {
- m_matrix = m;
- as *= trans_affine_max_norm(m);
- m_source->apply_transform(m, as);
- };
-
- virtual void bounding_box(double *x1, double *y1, double *x2, double *y2)
- {
- agg::bounding_rect_single(*m_source, 0, x1, y1, x2, y2);
- };
- };
-
-
- class affine : public vs_transform {
- agg::trans_affine m_matrix;
-
- public:
- affine(vertex_source* src): vs_transform(src, m_matrix), m_matrix() {};
-
- virtual void bounding_box(double *x1, double *y1, double *x2, double *y2)
- {
- agg::bounding_rect_single(m_output, 0, x1, y1, x2, y2);
- };
-
- const trans_affine& rotate(double a) { return m_matrix.rotate(a); };
- const trans_affine& translate(double x, double y) { return m_matrix.translate(x, y); };
- };
-}
-
-#endif
+#ifndef AGGPLOT_TRANS_H +#define AGGPLOT_TRANS_H + +#include "agg_trans_affine.h" +#include "agg_conv_stroke.h" +#include "agg_conv_curve.h" +#include "agg_conv_dash.h" +#include "agg_conv_transform.h" +#include "agg_vcgen_markers_term.h" +#include "agg_arrowhead.h" +#include "agg_bounding_rect.h" +#include "agg_ellipse.h" + +#include "my_conv_simple_marker.h" + +#include "utils.h" +#include "vertex-source.h" + +template<class T> +class vs_trans_proxy : public vertex_source { +protected: + T m_output; + vertex_source* m_source; + +public: + vs_trans_proxy(vertex_source* src): m_output(*src), m_source(src) + { + }; + + template <class init_type> + vs_trans_proxy(vertex_source* src, init_type& val): + m_output(*src, val), m_source(src) + {}; + + virtual void rewind(unsigned path_id) { m_output.rewind(path_id); }; + virtual unsigned vertex(double* x, double* y) { return m_output.vertex(x, y); }; + + /* + virtual void ref() { m_source->ref(); }; + virtual unsigned unref() + { + unsigned rc = m_source->unref(); + if (rc == 0) + delete m_source; + return 0; + }; + */ + + virtual void apply_transform(agg::trans_affine& m, double as) + { + m_source->apply_transform(m, as); + }; + + virtual void bounding_box(double *x1, double *y1, double *x2, double *y2) + { + m_source->bounding_box(x1, y1, x2, y2); + }; + + T& self() { return m_output; }; +}; + +typedef vs_trans_proxy<agg::conv_stroke<vertex_source> > vs_stroke; +typedef vs_trans_proxy<agg::conv_curve<vertex_source> > vs_curve; +typedef vs_trans_proxy<agg::conv_dash<vertex_source> > vs_dash; +typedef vs_trans_proxy<agg::conv_transform<vertex_source> > vs_transform; + +namespace trans { + + class stroke : public vs_stroke { + public: + typedef agg::conv_stroke<vertex_source> base_type; + + stroke(vertex_source* src, double width = 1.0): vs_stroke(src) + { + base_type& v = self(); + v.width(width); + }; + + virtual void apply_transform(agg::trans_affine& m, double as) + { + m_output.approximation_scale(as); + m_source->apply_transform(m, as); + }; + + void line_cap(agg::line_cap_e cap) + { + m_output.line_cap(cap); + }; + + void line_join(agg::line_join_e join) + { + m_output.line_join(join); + }; + }; + + class curve : public vs_curve { + public: + curve(vertex_source* src): vs_curve(src) {}; + + virtual void apply_transform(agg::trans_affine& m, double as) + { + m_output.approximation_scale(as); + m_source->apply_transform(m, as); + }; + }; + + class dash : public vs_dash { + public: + dash(vertex_source* src): vs_dash(src) {}; + + void add_dash(double dash_len, double gap_len) + { + m_output.add_dash(dash_len, gap_len); + } + }; + + typedef vs_trans_proxy<my::conv_simple_marker<vertex_source, agg::ellipse> > vs_marker_ellipse; + + class marker : public vs_marker_ellipse { + agg::ellipse m_ellipse; + + public: + marker(vertex_source* src, double size): vs_marker_ellipse(src, m_ellipse) + { + m_ellipse.init(0.0, 0.0, size/2, size/2); + }; + + virtual void apply_transform(agg::trans_affine& m, double as) + { + m_ellipse.approximation_scale(as); + m_source->apply_transform(m, as); + }; + }; + + class resize : public vs_transform { + agg::trans_affine m_matrix; + + public: + resize(vertex_source* src): vs_transform(src, m_matrix), m_matrix() {}; + + virtual void apply_transform(agg::trans_affine& m, double as) + { + m_matrix = m; + as *= trans_affine_max_norm(m); + m_source->apply_transform(m, as); + }; + + virtual void bounding_box(double *x1, double *y1, double *x2, double *y2) + { + agg::bounding_rect_single(*m_source, 0, x1, y1, x2, y2); + }; + }; + + + class affine : public vs_transform { + agg::trans_affine m_matrix; + + public: + affine(vertex_source* src): vs_transform(src, m_matrix), m_matrix() {}; + + virtual void bounding_box(double *x1, double *y1, double *x2, double *y2) + { + agg::bounding_rect_single(m_output, 0, x1, y1, x2, y2); + }; + + const trans_affine& rotate(double a) { return m_matrix.rotate(a); }; + const trans_affine& translate(double x, double y) { return m_matrix.translate(x, y); }; + }; +} + +#endif |