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年10月22日 15:46:07 +0200
committerfrancesco-ST <francesco.abbate@st.com>2010年10月22日 15:46:07 +0200
commite1d06a81b148252b25fea22c47e29abc95e86ea4 (patch)
tree5ac6593477800de35c1f268fc11214ce07e59a28 /agg-plot
parent60e7238f4c48e7653c4627c6bd78b959044687e9 (diff)
downloadgsl-shell-e1d06a81b148252b25fea22c47e29abc95e86ea4.tar.gz
fixed error with bounding box calculation / code simplification
The "dispose" method was no longer needed. Now we use normal destructors.
Diffstat (limited to 'agg-plot')
-rw-r--r--agg-plot/Makefile 2
-rw-r--r--agg-plot/agg-parse-trans.cpp 2
-rw-r--r--agg-plot/drawable.cpp 39
-rw-r--r--agg-plot/drawable.h 31
-rw-r--r--agg-plot/plot-auto.h 2
-rw-r--r--agg-plot/resource-manager.h 15
-rw-r--r--agg-plot/scalable.h 16
-rw-r--r--agg-plot/text.cpp 7
-rw-r--r--agg-plot/text.h 4
9 files changed, 34 insertions, 84 deletions
diff --git a/agg-plot/Makefile b/agg-plot/Makefile
index 877098ff..0f937d12 100644
--- a/agg-plot/Makefile
+++ b/agg-plot/Makefile
@@ -44,7 +44,7 @@ endif
INCLUDES += $(AGG_INCLUDES) -I$(GSH_BASE_DIR) -I$(LUADIR)/src
-AGGPLOT_SRC_FILES = $(PLATSUP_SRC_FILES) utils.cpp units.cpp colors.cpp markers.cpp lua-draw.cpp lua-text.cpp text.cpp drawable.cpp agg-parse-trans.cpp window.cpp lua-plot.cpp canvas-window.cpp
+AGGPLOT_SRC_FILES = $(PLATSUP_SRC_FILES) utils.cpp units.cpp colors.cpp markers.cpp lua-draw.cpp lua-text.cpp text.cpp agg-parse-trans.cpp window.cpp lua-plot.cpp canvas-window.cpp
AGGPLOT_OBJ_FILES := $(AGGPLOT_SRC_FILES:%.cpp=%.o)
diff --git a/agg-plot/agg-parse-trans.cpp b/agg-plot/agg-parse-trans.cpp
index d7f11d17..f7d23786 100644
--- a/agg-plot/agg-parse-trans.cpp
+++ b/agg-plot/agg-parse-trans.cpp
@@ -324,7 +324,7 @@ parse_graph_args (lua_State *L, agg::rgba8& color)
}
else if (gs_is_userdata (L, 2, GS_DRAW_DRAWABLE))
{
- vertex_source *vs = (vertex_source *) lua_touserdata (L, 2);
+ drawable *vs = (drawable *) lua_touserdata (L, 2);
w = new boxed_drawable(vs);
}
else
diff --git a/agg-plot/drawable.cpp b/agg-plot/drawable.cpp
deleted file mode 100644
index 6be6eb85..00000000
--- a/agg-plot/drawable.cpp
+++ /dev/null
@@ -1,39 +0,0 @@
-
-#include "agg_bounding_rect.h"
-
-#include "drawable.h"
-#include "utils.h"
-
-void
-window_scalable::apply_transform(const agg::trans_affine& m, double as)
-{
- m_trans.transformer(m);
- m_source->apply_transform (m, as * m.scale());
-}
-
-void
-window_scalable::bounding_box(double *x1, double *y1,
- double *x2, double *y2)
-{
- agg::bounding_rect_single (*m_source, 0, x1, y1, x2, y2);
-}
-
-void
-window_scalable::rewind(unsigned path_id)
-{
- m_trans.rewind(path_id);
-}
-
-unsigned
-window_scalable::vertex(double* x, double* y)
-{
- return m_trans.vertex(x, y);
-}
-
-bool
-window_scalable::dispose()
-{
- if (m_source->dispose())
- delete m_source;
- return true;
-}
diff --git a/agg-plot/drawable.h b/agg-plot/drawable.h
index 56ac7ccf..c67c7714 100644
--- a/agg-plot/drawable.h
+++ b/agg-plot/drawable.h
@@ -10,16 +10,14 @@
struct drawable : public vertex_source {
virtual void bounding_box(double *x1, double *y1, double *x2, double *y2) = 0;
- virtual bool dispose() = 0;
-
virtual ~drawable() { };
};
class boxed_drawable : public drawable {
- vertex_source *m_object;
+ drawable *m_object;
public:
- boxed_drawable(vertex_source *p) : drawable(), m_object(p) {};
+ boxed_drawable(drawable *p) : drawable(), m_object(p) {};
~boxed_drawable() { };
@@ -29,11 +27,9 @@ class boxed_drawable : public drawable {
virtual void bounding_box(double *x1, double *y1, double *x2, double *y2)
{
- agg::bounding_rect_single (*m_object, 0, x1, y1, x2, y2);
+ m_object->bounding_box(x1, y1, x2, y2);
};
- virtual bool dispose() { return false; };
-
private:
boxed_drawable();
};
@@ -51,13 +47,22 @@ public:
drawable(), m_source(src), m_trans(*m_source, mtx)
{ };
- virtual void rewind(unsigned path_id);
- virtual unsigned vertex(double* x, double* y);
+ ~window_scalable() { delete m_source; };
+
+ virtual void rewind(unsigned path_id) { m_trans.rewind(path_id); };
- virtual void apply_transform(const agg::trans_affine& m, double as);
- virtual void bounding_box(double *x1, double *y1, double *x2, double *y2);
+ virtual unsigned vertex(double* x, double* y) { return m_trans.vertex(x, y); };
+
+ virtual void apply_transform(const agg::trans_affine& m, double as)
+ {
+ m_trans.transformer(m);
+ m_source->apply_transform (m, as * m.scale());
+ };
- virtual bool dispose();
+ virtual void bounding_box(double *x1, double *y1, double *x2, double *y2)
+ {
+ agg::bounding_rect_single (*m_source, 0, x1, y1, x2, y2);
+ };
};
template<class conv_type>
@@ -77,7 +82,7 @@ public:
virtual void bounding_box(double *x1, double *y1, double *x2, double *y2)
{
- agg::bounding_rect_single (*this->m_source, 0, x1, y1, x2, y2);
+ this->m_source->bounding_box(x1, y1, x2, y2);
};
};
diff --git a/agg-plot/plot-auto.h b/agg-plot/plot-auto.h
index 2424a117..7f136dae 100644
--- a/agg-plot/plot-auto.h
+++ b/agg-plot/plot-auto.h
@@ -27,7 +27,7 @@
#include "agg_array.h"
#include "agg_basics.h"
-template<class VertexSource, class resource_manager = no_management>
+template<class VertexSource, class resource_manager>
class plot_auto : public plot<VertexSource, resource_manager> {
typedef plot_item<VertexSource> item;
typedef agg::pod_bvector<item> item_list;
diff --git a/agg-plot/resource-manager.h b/agg-plot/resource-manager.h
index 5ff9d3fb..3b650926 100644
--- a/agg-plot/resource-manager.h
+++ b/agg-plot/resource-manager.h
@@ -2,26 +2,13 @@
#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 lua_management {
public:
template <class T>
static void acquire(T* p) { };
template <class T>
- static void dispose(T* p)
- {
- if (p->dispose())
- delete p;
- };
+ static void dispose(T* p) { delete p; };
};
#endif
diff --git a/agg-plot/scalable.h b/agg-plot/scalable.h
index fae4a31a..8599fd33 100644
--- a/agg-plot/scalable.h
+++ b/agg-plot/scalable.h
@@ -30,10 +30,7 @@ struct vertex_source {
virtual ~vertex_source() { };
};
-struct scalable : public vertex_source {
- virtual bool dispose() = 0;
- virtual ~scalable() { };
-};
+typedef vertex_source scalable;
template <class T, bool approx>
class vs_proxy : public vertex_source {
@@ -81,8 +78,6 @@ class boxed_scalable : public scalable {
virtual unsigned vertex(double* x, double* y) { return m_object->vertex(x, y); };
virtual void apply_transform(const agg::trans_affine& m, double as) { m_object->apply_transform(m, as); };
- virtual bool dispose() { return false; };
-
private:
boxed_scalable();
};
@@ -98,6 +93,8 @@ protected:
public:
vs_adapter(base_type* src): m_output(*src), m_source(src) { };
+
+ ~vs_adapter() { delete this->m_source; };
template <class init_type>
vs_adapter(base_type* src, init_type& val):
@@ -114,13 +111,6 @@ public:
return m_output.vertex(x, y);
};
- virtual bool dispose()
- {
- if (this->m_source->dispose())
- delete this->m_source;
- return true;
- };
-
conv_type& self() { return m_output; };
};
diff --git a/agg-plot/text.cpp b/agg-plot/text.cpp
index 04d6f137..a13e2126 100644
--- a/agg-plot/text.cpp
+++ b/agg-plot/text.cpp
@@ -29,4 +29,11 @@ namespace draw {
m_stroke.approximation_scale(as);
m_text.start_point (-m_hjustif * m_text_width, -m_vjustif * m_text_height);
}
+
+ void
+ text::bounding_box(double *x1, double *y1, double *x2, double *y2)
+ {
+ *x1 = *x2 = m_x;
+ *y1 = *y2 = m_y;
+ }
}
diff --git a/agg-plot/text.h b/agg-plot/text.h
index e5e5a6ff..7988fda7 100644
--- a/agg-plot/text.h
+++ b/agg-plot/text.h
@@ -10,7 +10,7 @@
namespace draw {
- class text : public vertex_source {
+ class text : public drawable {
typedef agg::gsv_text vs_text;
typedef agg::conv_transform<vs_text> vs_trans_text;
typedef agg::conv_stroke<vs_trans_text> vs_stroked_text;
@@ -88,8 +88,8 @@ namespace draw {
virtual void rewind(unsigned path_id);
virtual unsigned vertex(double* x, double* y);
-
virtual void apply_transform(const agg::trans_affine& m, double as);
+ virtual void bounding_box(double *x1, double *y1, double *x2, double *y2);
vs_text& self() { return m_text; };
};
generated by cgit v1.2.3 (git 2.25.1) at 2025年09月15日 16:28:17 +0000

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