gsl-shell.git - gsl-shell

index : gsl-shell.git
gsl-shell
summary refs log tree commit diff
diff options
context:
space:
mode:
Diffstat
-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
3 files changed, 19 insertions, 10 deletions
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);
}
}
generated by cgit v1.2.3 (git 2.39.1) at 2025年09月16日 15:07:28 +0000

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