-rw-r--r-- | agg-plot/window.cpp | 124 |
diff --git a/agg-plot/window.cpp b/agg-plot/window.cpp index 5b0e4643..4c6de7c5 100644 --- a/agg-plot/window.cpp +++ b/agg-plot/window.cpp @@ -45,8 +45,8 @@ struct dispose_buffer { ref.valid_rect = false; if (ref.layer_buf) { - delete [] ref.layer_buf; - ref.layer_buf = 0; + delete [] ref.layer_buf; + ref.layer_buf = 0; } } }; @@ -74,21 +74,21 @@ int window::ref::calculate(window::ref::node* t, const bmatrix& m, int id) direction_e dir; list<ref::node*> *ls = t->tree(dir); if (ls) - { - bmatrix lm; + { + bmatrix lm; - double* p = (dir == along_x ? &lm.tx : &lm.ty); - double* s = (dir == along_x ? &lm.sx : &lm.sy); + double* p = (dir == along_x ? &lm.tx : &lm.ty); + double* s = (dir == along_x ? &lm.sx : &lm.sy); - *s = frac; + *s = frac; - for ( ; ls; ls = ls->next(), *p += frac) - { - bmatrix sm(lm); - window::ref::compose(sm, m); - id = window::ref::calculate (ls->content(), sm, id); - } - } + for ( ; ls; ls = ls->next(), *p += frac) + { + bmatrix sm(lm); + window::ref::compose(sm, m); + id = window::ref::calculate (ls->content(), sm, id); + } + } } return id; @@ -96,8 +96,8 @@ int window::ref::calculate(window::ref::node* t, const bmatrix& m, int id) void window::ref::save_image (agg::rendering_buffer& win_buf, - agg::rect_base<int>& r, - int img_bpp, bool flip_y) + agg::rect_base<int>& r, + int img_bpp, bool flip_y) { int w = r.x2 - r.x1, h = r.y2 - r.y1; int row_len = w * (img_bpp / 8); @@ -136,14 +136,14 @@ window::ref* window::ref_lookup (ref::node *p, int slot_id) { ref *ref = window::ref_lookup(t->content(), slot_id); if (ref) - return ref; + return ref; } ref *ref = p->content(); if (ref) { if (ref->slot_id == slot_id) - return ref; + return ref; } return NULL; @@ -160,7 +160,7 @@ void window::draw_slot_by_ref(window::ref& ref, bool draw_image) if (ref.plot) { AGG_LOCK(); - ref.plot->draw(*m_canvas, mtx); + ref.plot->draw(*m_canvas, mtx); AGG_UNLOCK(); } @@ -177,10 +177,10 @@ window::draw_slot(int slot_id, bool clean_req) bool redraw = clean_req || ref->plot->need_redraw(); if (redraw) - { - draw_slot_by_ref(*ref, false); - dispose_buffer::func(*ref); - } + { + draw_slot_by_ref(*ref, false); + dispose_buffer::func(*ref); + } refresh_slot_by_ref(*ref, redraw); ref->valid_rect = true; @@ -213,17 +213,17 @@ window::restore_slot_image(int slot_id) agg::rect_base<int> r = rect_of_slot_matrix<int>(mtx); if (ref->layer_buf == 0) - { - m_canvas->clear_box(r); - draw_slot_by_ref (*ref, false); - ref->save_image(this->rbuf_window(), r, this->bpp(), this->flip_y()); - } + { + m_canvas->clear_box(r); + draw_slot_by_ref (*ref, false); + ref->save_image(this->rbuf_window(), r, this->bpp(), this->flip_y()); + } else - { - agg::rendering_buffer& img = ref->layer_img; - agg::rendering_buffer& win = this->rbuf_window(); - rendering_buffer_put_region (win, img, r, this->bpp() / 8); - } + { + agg::rendering_buffer& img = ref->layer_img; + agg::rendering_buffer& win = this->rbuf_window(); + rendering_buffer_put_region (win, img, r, this->bpp() / 8); + } } } @@ -282,7 +282,7 @@ window::cleanup_tree_rec (lua_State *L, int window_index, ref::node* n) if (ref) { if (ref->plot) - window_refs_remove (L, ref->slot_id, window_index); + window_refs_remove (L, ref->slot_id, window_index); } } @@ -290,20 +290,17 @@ bool window::split(const char *spec) { ::split<ref>::lexer lexbuf(spec); - tree::node<ref, direction_e> *new_tree = ::split<ref>::parse(lexbuf); + tree::node<ref, direction_e> *parse_tree = ::split<ref>::parse(lexbuf); + delete m_tree; - if (new_tree) - { - if (m_tree) - delete m_tree; - - m_tree = new_tree; - bmatrix m0; - ref::calculate(m_tree, m0, 0); - return true; - } + if (parse_tree) + m_tree = parse_tree; + else + m_tree = new tree::leaf<ref, direction_e>(); - return false; + bmatrix m0; + ref::calculate(m_tree, m0, 0); + return (parse_tree != NULL); } static const char * @@ -339,14 +336,14 @@ int window::attach(sg_plot* plot, const char *spec) list<ref::node*>* list = n->tree(); if (! list) - return -1; + return -1; for (int j = 1; j < k; j++) - { - list = list->next(); - if (! list) - return -1; - } + { + list = list->next(); + if (! list) + return -1; + } n = list->content(); } @@ -379,8 +376,8 @@ int window_generic_oper (lua_State *L, window_slot_method_type method) template <class param_type> int window_generic_oper_ext (lua_State *L, - void (window::*method)(int, param_type), - param_type param) + void (window::*method)(int, param_type), + param_type param) { window *win = object_check<window>(L, 1, GS_WINDOW); int slot_id = luaL_checkinteger (L, 2); @@ -408,11 +405,11 @@ void window::start (lua_State *L, gslshell::ret_status& st) inf->window_id = this->window_id; if (! this->start_new_thread (inf)) - { - window_index_remove (L, this->window_id); - this->unlock(); - st.error("error during thread initialization", "window creation"); - } + { + window_index_remove (L, this->window_id); + this->unlock(); + st.error("error during thread initialization", "window creation"); + } } else { @@ -434,7 +431,10 @@ window_new (lua_State *L) return luaL_error (L, "%s (reported during %s)", st.error_msg(), st.context()); if (spec) - win->split(spec); + { + if (!win->split(spec)) + return luaL_error(L, "invalid layout specification"); + } return 1; } @@ -485,7 +485,7 @@ window_split (lua_State *L) if (! win->split(spec)) { if (win->status == canvas_window::running) - win->do_window_update(); + win->do_window_update(); win->unlock(); return luaL_error(L, "invalid window subdivision specification"); } @@ -514,7 +514,7 @@ window_attach (lua_State *L) if (slot_id >= 0) { if (win->status == canvas_window::running) - win->draw_slot(slot_id, true); + win->draw_slot(slot_id, true); win->unlock(); window_refs_add (L, slot_id, 1, 2); } |