Mercurial > octave-nkf
changeset 19061:0ee9daa71273
Fix axes property "currentpoint" for FLTK, extend documentation
* plot.txi: Modify documentation for axes property currentpoint
* __init_fltk__.cc: Add implementation of currentpoint for 3D plots
and fix arrangement of x and y coordinates.
* __fltk_ginput__.m: Fix x and y index of currentpoint to reflect
bugfix in __init_fltk__.cc
author | Andreas Weber <andy.weber.aw@gmail.com> |
---|---|
date | Mon, 18 Aug 2014 21:25:39 +0200 |
parents | f27140dd13a6 |
children | c419e5487d0d |
files | doc/interpreter/plot.txi libinterp/dldfcn/__init_fltk__.cc scripts/plot/util/private/__fltk_ginput__.m |
diffstat | 3 files changed, 24 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/doc/interpreter/plot.txi Mon Aug 18 09:09:18 2014 -0700 +++ b/doc/interpreter/plot.txi Mon Aug 18 21:25:39 2014 +0200 @@ -1671,10 +1671,14 @@ @item createfcn @item currentpoint -Holds the coordinates of the point over which the mouse pointer was when -the mouse button was pressed. If a mouse callback function is defined, -@qcode{"currentpoint"} holds the coordinates of the point over which the -mouse pointer is when the function gets called. +An 2-by-3 matrix @code{[xf, yf, zf; xb, yb, zb]} which holds the +coordinates of the point over which the mouse pointer was when the +mouse button was pressed in axes data units. If a mouse callback +function is defined, @qcode{"currentpoint"} holds the pointer +coordinates at the time the mouse button was pressed. For 3D plots, +the first row of the returned matrix specifies the point nearest to +the current camera position and the second rows the furthest point. +The two points forms a line which is perpendicular to the screen. @item dataaspectratio A two-element vector specifying the relative height and width of the
--- a/libinterp/dldfcn/__init_fltk__.cc Mon Aug 18 09:09:18 2014 -0700 +++ b/libinterp/dldfcn/__init_fltk__.cc Mon Aug 18 21:25:39 2014 +0200 @@ -1148,19 +1148,25 @@ void set_axes_currentpoint (graphics_object ax, int px, int py) { - if (ax.valid_object ()) + if (ax.valid_object () && ax.isa ("axes")) { axes::properties& ap = dynamic_cast<axes::properties&> (ax.get_properties ()); - double xx, yy; - pixel2pos (ax, px, py, xx, yy); + Matrix x_zlim = ap.get_transform_zlim (); + Matrix pos (2, 3, 0.0); - Matrix pos (2,3,0); - pos(0,0) = xx; - pos(1,0) = yy; - pos(0,1) = xx; - pos(1,1) = yy; + // front point (nearest to the viewer) + ColumnVector tmp = ap.get_transform ().untransform (px, py, x_zlim(0)); + pos(0,0) = tmp(0); + pos(0,1) = tmp(1); + pos(0,2) = tmp(2); + + // back point (furthest from the viewer) + tmp = ap.get_transform ().untransform (px, py, x_zlim(1)); + pos(1,0) = tmp(0); + pos(1,1) = tmp(1); + pos(1,2) = tmp(2); ap.set_currentpoint (pos); fp.set_currentaxes (ap.get___myhandle__ ().value ());
--- a/scripts/plot/util/private/__fltk_ginput__.m Mon Aug 18 09:09:18 2014 -0700 +++ b/scripts/plot/util/private/__fltk_ginput__.m Mon Aug 18 21:25:39 2014 +0200 @@ -78,7 +78,7 @@ function ginput_buttondownfcn (src, button) point = get (src, "currentpoint"); - ginput_accumulator (1, point(1,1), point(2,1), button); + ginput_accumulator (1, point(1,1), point(1,2), button); endfunction function ginput_keypressfcn (src, evt) @@ -88,7 +88,7 @@ ## Enter key stops ginput. ginput_accumulator (2, NaN, NaN, NaN); else - ginput_accumulator (1, point(1,1), point(2,1), uint8 (key(1))); + ginput_accumulator (1, point(1,1), point(1,2), uint8 (key(1))); endif endfunction