Mercurial > hg > octave-lojdl
changeset 7839:71eb1793f0db
fltk_backend can now handle figure.position changes
author | Shai Ayal <shaiay@sourceforge.net> |
---|---|
date | Sat, 23 Feb 2008 20:53:23 +0200 |
parents | 0a2ba0053fbd |
children | 2c8f693c32fd |
files | src/graphics/ChangeLog src/graphics/fltk_backend/Makefile.in src/graphics/fltk_backend/fltk_backend.cc |
diffstat | 3 files changed, 54 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/src/graphics/ChangeLog +++ b/src/graphics/ChangeLog @@ -1,3 +1,12 @@ +2008-02-23 Shai Ayal <shaiay@users.sourceforge.net> + + * fltk_backend/fltk_backend.cc (plot_window::mark_modifed): mark + the whole window as damaged (otherwise changing figure.postion + does not have immediate effect) + (plot_window::draw): New function, checks for window size + (__fltk_maxtime__): New DEFUN to allow tweaking of fltk timeout + (__fltk_redraw__): Use fltk_maxtime as timeout + 2008-02-21 Michael Goffioul <michael.goffioul@gmail.com> * opengl/gl-render.cc (opengl_renderer::patch_tesselator::combine):
--- a/src/graphics/fltk_backend/Makefile.in +++ b/src/graphics/fltk_backend/Makefile.in @@ -68,3 +68,4 @@ fltk_backend.oct : fltk_backend.o $(DL_LD) $(DL_LDFLAGS) -o $@ $< $(OCT_LINK_DEPS) +all : fltk_backend.oct
--- a/src/graphics/fltk_backend/fltk_backend.cc +++ b/src/graphics/fltk_backend/fltk_backend.cc @@ -25,10 +25,16 @@ #include <sstream> #include <iostream> +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include "gl-render.h" + #include <FL/Fl.H> #include <FL/Fl_Window.H> #include <FL/Fl_Output.H> -#include <FL/Fl_Button.H> + #include <FL/Fl_Button.H> #include <FL/Fl_Gl_Window.H> #include <FL/fl_ask.H> #include <FL/fl_draw.H> @@ -37,13 +43,6 @@ #include "parse.h" #include "graphics.h" -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include "gl-render.h" - - const char* help_text = "\ Keyboard Shortcuts\n\ a - autoscale\n\ @@ -191,7 +190,7 @@ double number () { return _number;}; - void mark_modified () { canvas->damage (FL_DAMAGE_ALL); } + void mark_modified () { damage (FL_DAMAGE_ALL); } private: // figure number @@ -299,6 +298,15 @@ args(2) = pos; feval("set",args); } + + void draw (void) + { + figure::properties& fp = get_figure_props (); + Matrix pos = fp.get_position ().matrix_value (); + Fl_Window::resize (pos(0), pos(1) , pos(2), pos(3)); + + return Fl_Window::draw (); + } int handle (int event) { static double x0,y0; @@ -491,7 +499,7 @@ } }; -bool backend_registered = false; +static bool backend_registered = false; // call this to init the fltk backend DEFUN_DLD (__init_fltk__, args, nargout,"") { @@ -510,14 +518,34 @@ backend_registered = false; - // give FLTK no more than 0.01 sec to do it's stuff - Fl::wait(1e-2); + // give FLTK 10 seconds to wrap it up + Fl::wait(10); octave_value retval; return retval; } +// give FLTK no more than 0.01 sec to do it's stuff +static double fltk_maxtime = 1e-2; + +// call this to delete the fltk backend +DEFUN_DLD (__fltk_maxtime__, args, nargout,"") +{ + octave_value retval=fltk_maxtime; + + if (args.length () == 1 ) + { + if (args(0).is_real_scalar ()) + fltk_maxtime = args(0).double_value (); + else + error("argument must be a real scalar"); + } + + return retval; +} + // call this from the idle_callback to refresh windows -DEFUN_DLD (__fltk_redraw__, args, nargout,"internal function for the fltk backend") +DEFUN_DLD (__fltk_redraw__, args, nargout,\ + "internal function for the fltk backend") { octave_value retval; @@ -560,8 +588,7 @@ } } - // give FLTK no more than 0.01 sec to do it's stuff - Fl::wait(1e-2); + Fl::wait(fltk_maxtime); return retval; } @@ -570,9 +597,11 @@ autoload("__init_fltk__",[pwd(),"/fltk_backend.oct"]) autoload("__remove_fltk__",[pwd(),"/fltk_backend.oct"]) autoload("__fltk_redraw__",[pwd(),"/fltk_backend.oct"]) +autoload("__fltk_maxtime__",[pwd(),"/fltk_backend.oct"]) input_event_hook ("__fltk_redraw__"); __init_fltk__ (); set(gcf(),"__backend__","fltk") +plot(randn(1e3,1)); */