author | francesco-ST <francesco.abbate@st.com> | 2011年04月29日 12:04:09 +0200 |
---|---|---|
committer | francesco-ST <francesco.abbate@st.com> | 2011年05月02日 08:49:15 +0200 |
commit | a7096dd693d4042b27e33e616576f4f79f34ad39 (patch) | |
tree | 5206c62801f87b2961a9497005b50ed5c2be09a5 /agg-plot | |
parent | 5d6ade3d7faffa14aae1079d18490cc6015aca42 (diff) | |
download | gsl-shell-a7096dd693d4042b27e33e616576f4f79f34ad39.tar.gz |
-rw-r--r-- | agg-plot/lua-plot.cpp | 24 | ||||
-rw-r--r-- | agg-plot/plot.h | 20 |
diff --git a/agg-plot/lua-plot.cpp b/agg-plot/lua-plot.cpp index 826204b6..d953ac50 100644 --- a/agg-plot/lua-plot.cpp +++ b/agg-plot/lua-plot.cpp @@ -63,6 +63,8 @@ static int plot_sync_mode_get (lua_State *L); static int plot_sync_mode_set (lua_State *L); static int plot_pad_mode_get (lua_State *L); static int plot_pad_mode_set (lua_State *L); +static int plot_clip_mode_get (lua_State *L); +static int plot_clip_mode_set (lua_State *L); static int canvas_new (lua_State *L); @@ -101,6 +103,7 @@ static const struct luaL_Reg plot_properties_get[] = { {"units", plot_units_get }, {"sync", plot_sync_mode_get }, {"pad", plot_pad_mode_get }, + {"clip", plot_clip_mode_get }, {NULL, NULL} }; @@ -109,6 +112,7 @@ static const struct luaL_Reg plot_properties_set[] = { {"units", plot_units_set }, {"sync", plot_sync_mode_set }, {"pad", plot_pad_mode_set }, + {"clip", plot_clip_mode_set }, {NULL, NULL} }; @@ -437,6 +441,26 @@ static int plot_pad_mode_get (lua_State *L) return 1; } +static int plot_clip_mode_set (lua_State *L) +{ + lua_plot *p = object_check<lua_plot>(L, 1, GS_PLOT); + bool request = (bool) lua_toboolean (L, 2); + AGG_LOCK(); + p->set_clip_mode(request); + AGG_UNLOCK(); + plot_update_raw (L, p, 1); + return 0; +} + +static int plot_clip_mode_get (lua_State *L) +{ + lua_plot *p = object_check<lua_plot>(L, 1, GS_PLOT); + AGG_LOCK(); + lua_pushboolean (L, p->clip_is_active()); + AGG_UNLOCK(); + return 1; +} + int plot_sync_mode_get (lua_State *L) { diff --git a/agg-plot/plot.h b/agg-plot/plot.h index 6550de74..1ef8bd0e 100644 --- a/agg-plot/plot.h +++ b/agg-plot/plot.h @@ -70,7 +70,7 @@ public: plot(bool use_units = true) : m_root_layer(), m_layers(), m_current_layer(&m_root_layer), - m_drawing_queue(0), + m_drawing_queue(0), m_clip_flag(true), m_need_redraw(true), m_rect(), m_use_units(use_units), m_pad_units(false), m_title_buf(), m_sync_mode(true) @@ -115,6 +115,9 @@ public: void clear_current_layer(); int current_layer_index(); + bool clip_is_active() const { return m_clip_flag; }; + void set_clip_mode(bool flag) { m_clip_flag = flag; }; + bool need_redraw() const { return m_need_redraw; }; void commit_pending_draw(); @@ -162,6 +165,8 @@ protected: agg::trans_affine m_trans; pod_list<item> *m_drawing_queue; + bool m_clip_flag; + bool m_need_redraw; opt_rect<double> m_rect; @@ -306,11 +311,14 @@ agg::trans_affine plot<VS,RM>::get_scaled_matrix(agg::trans_affine& canvas_mtx) template<class VS, class RM> void plot<VS,RM>::clip_plot_area(canvas &canvas, agg::trans_affine& canvas_mtx) { - agg::trans_affine mvp; - viewport_scale(mvp); - trans_affine_compose (mvp, canvas_mtx); - agg::rect_base<int> clip = rect_of_slot_matrix<int>(mvp); - canvas.clip_box(clip); + if (this->clip_is_active()) + { + agg::trans_affine mvp; + viewport_scale(mvp); + trans_affine_compose (mvp, canvas_mtx); + agg::rect_base<int> clip = rect_of_slot_matrix<int>(mvp); + canvas.clip_box(clip); + } } template<class VS, class RM> |