Mercurial > octave-dspies
diff src/DLD-FUNCTIONS/fltk_backend.cc @ 10917:888c75785221
Improvements to FLTK backend rotation
* Don't rotate past the top and bottom
* Implement __calc_dimensions__ in C++ so that it's available to graphics object ctors
* Make rotation the default mode in 3d plots
* Replace an instance of m-script __calc_dimensions__ with C++ version
author | Jordi Guti?rrez Hermoso <jordigh@gmail.com> |
---|---|
date | Fri, 27 Aug 2010 15:11:35 -0400 |
parents | f065b24f792a |
children | 2786e3b7072e |
line wrap: on
line diff
--- a/src/DLD-FUNCTIONS/fltk_backend.cc Fri Aug 27 14:04:04 2010 -0400 +++ b/src/DLD-FUNCTIONS/fltk_backend.cc Fri Aug 27 15:11:35 2010 -0400 @@ -224,7 +224,8 @@ public: plot_window (int xx, int yy, int ww, int hh, figure::properties& xfp) : Fl_Window (xx, yy, ww, hh, "octave"), window_label (), shift (0), - fp (xfp), canvas (0), autoscale (0), togglegrid (0), panzoom (0), rotate (0), help (0), status (0) + ndim (2), fp (xfp), canvas (0), autoscale (0), togglegrid (0), + panzoom (0), rotate (0), help (0), status (0) { callback (window_close, static_cast<void*> (this)); @@ -239,7 +240,9 @@ ww, status_h); bottom->box(FL_FLAT_BOX); - + + ndim = calc_dimensions (gh_manager::get_object (fp.get___myhandle__ ())); + autoscale = new Fl_Button (0, hh - status_h, @@ -266,7 +269,7 @@ "P"); panzoom->callback (button_callback, static_cast<void*> (this)); panzoom->tooltip ("Mouse Pan/Zoom"); - + rotate = new Fl_Button (3 * status_h, hh - status_h, @@ -276,6 +279,9 @@ rotate->callback (button_callback, static_cast<void*> (this)); rotate->tooltip ("Mouse Rotate"); + if (ndim == 2) + rotate->deactivate (); + help = new Fl_Button (4 * status_h, hh - status_h, @@ -317,7 +323,7 @@ set_name (); resizable (canvas); size_range (4*status_h, 2*status_h); - gui_mode = pan_zoom; + gui_mode = (ndim == 3 ? rotate_zoom : pan_zoom); } ~plot_window (void) @@ -346,6 +352,15 @@ { damage (FL_DAMAGE_ALL); canvas->damage (FL_DAMAGE_ALL); + ndim = calc_dimensions (gh_manager::get_object (fp.get___myhandle__ ())); + + if (ndim == 3) + rotate->activate (); + else + { + rotate->deactivate (); + gui_mode = pan_zoom; + } } void set_name (void) @@ -362,6 +377,9 @@ // Mod keys status int shift; + // Number of dimensions, 2 or 3. + int ndim; + // Interactive Mode enum { pan_zoom, rotate_zoom } gui_mode; @@ -396,7 +414,7 @@ if (widg == panzoom) gui_mode = pan_zoom; - if (widg == rotate) + if (widg == rotate && ndim == 3) gui_mode = rotate_zoom; if (widg == help) @@ -656,7 +674,10 @@ case 'r': case 'R': - gui_mode = rotate_zoom; + if (ndim == 3) + gui_mode = rotate_zoom; + else + gui_mode = pan_zoom; break; } }