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/lua-plot-cpp.h 7
-rw-r--r--agg-plot/lua-plot.cpp 55
-rw-r--r--agg-plot/window.cpp 7
-rw-r--r--agg-plot/window.h 2
4 files changed, 24 insertions, 47 deletions
diff --git a/agg-plot/lua-plot-cpp.h b/agg-plot/lua-plot-cpp.h
index 1c3f52c0..022be7e9 100644
--- a/agg-plot/lua-plot-cpp.h
+++ b/agg-plot/lua-plot-cpp.h
@@ -19,16 +19,11 @@ private:
plot_type m_plot;
public:
- lua_plot() : m_plot(), window_id(-1) { };
-
- void update_window(lua_State *L);
+ lua_plot() : m_plot() { };
plot_type& self() { return m_plot; };
static lua_plot *check(lua_State *L, int index);
-
- int window_id;
- int slot_id;
};
#endif
diff --git a/agg-plot/lua-plot.cpp b/agg-plot/lua-plot.cpp
index 0f28020b..4118843b 100644
--- a/agg-plot/lua-plot.cpp
+++ b/agg-plot/lua-plot.cpp
@@ -25,7 +25,7 @@ extern "C" {
#include "lua-plot.h"
#include "lua-plot-cpp.h"
-#include "object-index.h"
+#include "win-plot-refs.h"
#include "window.h"
#include "gs-types.h"
#include "lua-utils.h"
@@ -47,13 +47,14 @@ static int plot_add_line (lua_State *L);
static int plot_index (lua_State *L);
static int plot_newindex (lua_State *L);
static int plot_free (lua_State *L);
-// static int plot_show (lua_State *L);
+static int plot_show (lua_State *L);
static int plot_title_set (lua_State *L);
static int plot_title_get (lua_State *L);
static int plot_units_set (lua_State *L);
static int plot_units_get (lua_State *L);
-static int plot_add_gener (lua_State *L, bool as_line);
+static int plot_add_gener (lua_State *L, bool as_line);
+static void plot_update_raw (lua_State *L, int plot_index);
static const struct luaL_Reg plot_functions[] = {
{"plot", plot_new},
@@ -64,7 +65,7 @@ static const struct luaL_Reg plot_methods[] = {
{"add", plot_add },
{"addline", plot_add_line },
{"update", plot_update },
- // {"show", plot_show },
+ {"show", plot_show },
{"__index", plot_index },
{"__newindex", plot_newindex },
{"__gc", plot_free },
@@ -91,27 +92,6 @@ lua_plot::check(lua_State *L, int index)
return (lua_plot *) gs_check_userdata (L, index, GS_PLOT);
}
-void
-lua_plot::update_window(lua_State *L)
-{
- if (this->window_id <= 0)
- return;
-
- object_index_get (L, OBJECT_WINDOW, this->window_id);
-
- if (gs_is_userdata (L, lua_gettop (L), GS_WINDOW))
- {
- lua_pushcfunction (L, window_slot_update_unprotected);
- lua_insert (L, -2);
- lua_pushinteger (L, this->slot_id);
- lua_call (L, 2, 0);
- }
- else
- {
- lua_pop (L, 1);
- }
-}
-
int
plot_new (lua_State *L)
{
@@ -147,7 +127,7 @@ plot_add_gener (lua_State *L, bool as_line)
AGG_LOCK();
p->self().add(obj, color, as_line);
- p->update_window(L);
+ plot_update_raw (L, 1);
AGG_UNLOCK();
@@ -178,7 +158,7 @@ plot_title_set (lua_State *L)
AGG_LOCK();
p->self().set_title(title);
- p->update_window(L);
+ plot_update_raw (L, 1);
AGG_UNLOCK();
@@ -214,7 +194,7 @@ plot_units_set (lua_State *L)
if (current != request)
{
plt.set_units(request);
- p->update_window(L);
+ plot_update_raw (L, 1);
}
AGG_UNLOCK();
@@ -249,25 +229,32 @@ plot_newindex (lua_State *L)
return mlua_newindex_with_properties (L, plot_properties_set);
}
+void
+plot_update_raw (lua_State *L, int plot_index)
+{
+ window_plot_rev_lookup_apply (L, plot_index, window_slot_update_unprotected);
+}
+
int
plot_update (lua_State *L)
{
lua_plot *p = lua_plot::check(L, 1);
AGG_LOCK();
- p->update_window(L);
+ plot_update_raw (L, 1);
AGG_UNLOCK();
return 0;
}
-/*
int
plot_show (lua_State *L)
{
- lua_plot *p = lua_plot::check(L, 1);
- p->start_new_thread (L);
- return 1;
+ lua_pushcfunction (L, window_attach);
+ window_new (L);
+ lua_pushvalue (L, 1);
+ lua_pushstring (L, "");
+ lua_call (L, 3, 0);
+ return 0;
}
-*/
void
plot_register (lua_State *L)
diff --git a/agg-plot/window.cpp b/agg-plot/window.cpp
index 5c9a2bb6..7d10e346 100644
--- a/agg-plot/window.cpp
+++ b/agg-plot/window.cpp
@@ -17,10 +17,8 @@ extern "C" {
__BEGIN_DECLS
-static int window_new (lua_State *L);
static int window_free (lua_State *L);
static int window_split (lua_State *L);
-static int window_attach (lua_State *L);
static const struct luaL_Reg window_functions[] = {
{"window", window_new},
@@ -304,13 +302,8 @@ window_attach (lua_State *L)
if (slot_id >= 0)
{
- plot->window_id = win->id;
- plot->slot_id = slot_id;
-
win->draw_slot(slot_id, true);
-
win->unlock();
-
window_plot_ref_add (L, slot_id, 1, 2);
}
else
diff --git a/agg-plot/window.h b/agg-plot/window.h
index 1c7858de..803aa3e1 100644
--- a/agg-plot/window.h
+++ b/agg-plot/window.h
@@ -12,6 +12,8 @@ extern void window_register (lua_State *L);
extern int window_slot_update_unprotected (lua_State *L);
extern int window_update_unprotected (lua_State *L);
extern int window_update (lua_State *L);
+extern int window_new (lua_State *L);
+extern int window_attach (lua_State *L);
__END_DECLS
generated by cgit v1.2.3 (git 2.39.1) at 2025年09月27日 06:41:43 +0000

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