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:
Diffstat (limited to 'agg-plot')
-rw-r--r--agg-plot/window-cpp.h 28
-rw-r--r--agg-plot/window.cpp 58
2 files changed, 37 insertions, 49 deletions
diff --git a/agg-plot/window-cpp.h b/agg-plot/window-cpp.h
index 564a4160..32d294c4 100644
--- a/agg-plot/window-cpp.h
+++ b/agg-plot/window-cpp.h
@@ -45,6 +45,16 @@ public:
if (layer_buf) delete layer_buf;
};
+ void dispose_buffer()
+ {
+ valid_rect = false;
+ if (layer_buf)
+ {
+ delete [] layer_buf;
+ layer_buf = 0;
+ }
+ }
+
void save_image (agg::rendering_buffer& winbuf, agg::rect_base<int>& r,
int bpp, bool flip_y);
@@ -55,7 +65,6 @@ public:
private:
void draw_slot_by_ref(ref& ref, bool dirty);
void refresh_slot_by_ref(ref& ref, bool draw_all);
- void draw_rec(ref::node *n);
void cleanup_tree_rec (lua_State *L, int window_index, ref::node* n);
static ref *ref_lookup (ref::node *p, int slot_id);
@@ -87,13 +96,20 @@ public:
void save_slot_image(int slot_id);
void restore_slot_image(int slot_id);
- void cleanup_refs(lua_State *L, int window_index)
- {
- cleanup_tree_rec (L, window_index, m_tree);
- };
-
void draw_slot(int slot_id);
virtual void on_draw();
virtual void on_resize(int sx, int sy);
+
+private:
+ struct slot_draw_function
+ {
+ slot_draw_function(window* w): win(w) { }
+ void call(window::ref* ref) { win->draw_slot_by_ref(*ref, false); }
+ window* win;
+ };
+
+ struct dispose_buffer_function {
+ void call(window::ref* ref) { ref->dispose_buffer(); }
+ };
};
diff --git a/agg-plot/window.cpp b/agg-plot/window.cpp
index 78f43dfb..3868de85 100644
--- a/agg-plot/window.cpp
+++ b/agg-plot/window.cpp
@@ -42,18 +42,6 @@ static const struct luaL_Reg window_methods[] = {
__END_DECLS
-struct dispose_buffer {
- static void func (window::ref& ref)
- {
- ref.valid_rect = false;
- if (ref.layer_buf)
- {
- delete [] ref.layer_buf;
- ref.layer_buf = 0;
- }
- }
-};
-
void window::ref::compose(bmatrix& a, const bmatrix& b)
{
trans_affine_compose (a, b);
@@ -118,20 +106,6 @@ window::ref::save_image (agg::rendering_buffer& win_buf,
}
}
-void
-window::draw_rec(ref::node *n)
-{
- list<ref::node*> *ls;
- for (ls = n->tree(); ls != NULL; ls = ls->next())
- draw_rec(ls->content());
-
- ref *ref = n->content();
- if (ref)
- {
- draw_slot_by_ref (*ref, false);
- }
-}
-
window::ref* window::ref_lookup (ref::node *p, int slot_id)
{
list<ref::node*> *t = p->tree();
@@ -182,7 +156,7 @@ window::draw_slot(int slot_id, bool clean_req)
if (redraw)
{
draw_slot_by_ref(*ref, false);
- dispose_buffer::func(*ref);
+ ref->dispose_buffer();
}
refresh_slot_by_ref(*ref, redraw);
@@ -262,7 +236,10 @@ void
window::on_draw()
{
if (m_canvas)
- draw_rec(m_tree);
+ {
+ slot_draw_function draw_func(this);
+ this->plot_apply(draw_func);
+ }
}
void
@@ -271,23 +248,17 @@ window::on_resize(int sx, int sy)
this->canvas_window::on_resize(sx, sy);
if (m_tree)
{
- tree::walk_rec<window::ref, direction_e, dispose_buffer>(m_tree);
+ dispose_buffer_function dispose;
+ this->plot_apply(dispose);
}
}
-void
-window::cleanup_tree_rec (lua_State *L, int window_index, ref::node* n)
-{
- for (list<ref::node*> *ls = n->tree(); ls != NULL; ls = ls->next())
- cleanup_tree_rec(L, window_index, ls->content());
-
- ref *ref = n->content();
- if (ref)
- {
- if (ref->plot)
- window_refs_remove (L, ref->slot_id, window_index);
- }
-}
+struct refs_remove_function {
+ refs_remove_function(lua_State *_L, int k): L(_L), window_index(k) {}
+ void call(window::ref* ref) { if (ref->plot) window_refs_remove(L, ref->slot_id, window_index); }
+ lua_State* L;
+ int window_index;
+};
bool
window::split(const char *spec)
@@ -497,7 +468,8 @@ window_split (lua_State *L)
win->lock();
- win->cleanup_refs(L, 1);
+ refs_remove_function refs_remove_func(L, 1);
+ win->plot_apply(refs_remove_func);
if (! win->split(spec))
{
generated by cgit v1.2.3 (git 2.25.1) at 2025年09月18日 08:57:12 +0000

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