author | Francesco Abbate <francesco.bbt@gmail.com> | 2012年04月22日 22:56:51 +0200 |
---|---|---|
committer | Francesco Abbate <francesco.bbt@gmail.com> | 2012年04月22日 22:56:51 +0200 |
commit | 73e77ecaf9eb7e2df3b5187b3491ac0ae491a83d (patch) | |
tree | c2f7cf541a3046c2792b70aad5570d09f85867bc | |
parent | 23dd1088cc608f470c9fdcf7e8f353e9aa96b4ce (diff) | |
download | gsl-shell-73e77ecaf9eb7e2df3b5187b3491ac0ae491a83d.tar.gz |
-rw-r--r-- | fox-gui/fx_plot_window.h | 4 | ||||
-rw-r--r-- | fox-gui/gsl_shell_app.h | 3 | ||||
-rw-r--r-- | fox-gui/lua_plot_window.cpp | 22 |
diff --git a/fox-gui/fx_plot_window.h b/fox-gui/fx_plot_window.h index f3143927..e7b11927 100644 --- a/fox-gui/fx_plot_window.h +++ b/fox-gui/fx_plot_window.h @@ -3,6 +3,7 @@ #include <fx.h> +#include "gsl_shell_app.h" #include "fx_plot_canvas.h" class fx_plot_window : public FXMainWindow { @@ -12,7 +13,8 @@ public: ~fx_plot_window(); - fx_plot_canvas& canvas() { return *m_canvas; } + fx_plot_canvas* canvas() { return m_canvas; } + gsl_shell_app* get_app() { return (gsl_shell_app*) getApp(); } int lua_id; // the following is used by Lua to keep trace of the window diff --git a/fox-gui/gsl_shell_app.h b/fox-gui/gsl_shell_app.h index 9d744167..cac10673 100644 --- a/fox-gui/gsl_shell_app.h +++ b/fox-gui/gsl_shell_app.h @@ -15,6 +15,9 @@ public: bool interrupt(); void resume(bool signal_end); + void lock() { mutex().lock(); } + void unlock() { mutex().unlock(); } + void window_create_request(FXMainWindow* win); long on_lua_interrupt(FXObject*,FXSelector,void*); diff --git a/fox-gui/lua_plot_window.cpp b/fox-gui/lua_plot_window.cpp index 89171bc0..b2473f42 100644 --- a/fox-gui/lua_plot_window.cpp +++ b/fox-gui/lua_plot_window.cpp @@ -71,7 +71,12 @@ fox_window_attach (lua_State *L) { fx_plot_window *win = object_check<fx_plot_window>(L, 1, GS_FOX_WINDOW); sg_plot* p = object_check<sg_plot>(L, 2, GS_PLOT); - win->canvas().attach(p); + gsl_shell_app* app = win->get_app(); + app->lock(); + win->canvas()->attach(p); + app->unlock(); + int slot_id = 1; + window_refs_add (L, slot_id, 1, 2); return 0; } @@ -84,20 +89,19 @@ fox_window_close (lua_State *L) int fox_window_slot_refresh (lua_State *L) { - fx_plot_window *win = object_check<fx_plot_window>(L, 1, GS_FOX_WINDOW); - fx_plot_canvas& canvas = win->canvas(); - - gsl_shell_app* app = (gsl_shell_app*) win->getApp(); + fx_plot_window* win = object_check<fx_plot_window>(L, 1, GS_FOX_WINDOW); + fx_plot_canvas* canvas = win->canvas(); + gsl_shell_app* app = win->get_app(); bool interrupted = app->interrupt(); - if (canvas.is_ready()) + if (canvas->is_ready()) { - int ww = canvas.getWidth(), hh = canvas.getHeight(); + int ww = canvas->getWidth(), hh = canvas->getHeight(); agg::trans_affine m(double(ww), 0.0, 0.0, double(hh), 0.0, 0.0); AGG_LOCK(); - opt_rect<double> rect = canvas.incremental_draw(m); + opt_rect<double> rect = canvas->incremental_draw(m); AGG_UNLOCK(); if (rect.is_defined()) @@ -105,7 +109,7 @@ fox_window_slot_refresh (lua_State *L) const int m = 4; const agg::rect_base<double>& r = rect.rect(); const agg::rect_base<int> ri(r.x1 - m, r.y1 - m, r.x2 + m, r.y2 + m); - canvas.update_region(ri); + canvas->update_region(ri); } } |