bugGNU Octave - Bugs: bug #44834, [FLTK] ginput doesn't return...

 
 

bug #44834: [FLTK] ginput doesn't return proper (X,Y) coordinates for key press

Submitter:  Philip Nienhuis <philipnienhuis>
Submitted:  Tue 14 Apr 2015 12:49:33 PM UTC
   
 
Category:  Plotting with OpenGL Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  None
Originator Name:  Philip Nienhuis Open/Closed:  * Closed
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Thu 23 Apr 2015 03:41:37 PM UTC, comment #12: 

Thanks for testing.  They are doing what I expected.  I checked in a fix for FLTK here (http://hg.savannah.gnu.org/hgweb/octave/rev/144498565de9).  Closing report.

Rik <rik5>
Group administrator
Thu 23 Apr 2015 12:03:03 PM UTC, comment #11: 

BTW, ginput does move currentpoint.
Clicking lower left:

>> get (gca, 'currentpoint')
ans =
    1.2385    1.2763    1.0000
    1.2385    1.2763   -1.0000


and then, moving mouse cursor to upper right and...:

>> [a, b, c] = ginput (1)
% tapping some key
a =
    9.8859
b =
    9.8026
c =
    97
>> get (gca, 'currentpoint')
ans =
    9.8859    9.8026    1.0000
    9.8859    9.8026   -1.0000


Is this enough info?

Philip Nienhuis <philipnienhuis>
Group Member
Thu 23 Apr 2015 10:26:30 AM UTC, comment #10: 

(added comment)
I can see that the focus is on the graphics window when I type the key because I have "focus follows mouse" set in one of those UI tweak utilities for Windows and the graphics title bar indicates focus.

Philip Nienhuis <philipnienhuis>
Group Member
Thu 23 Apr 2015 10:24:23 AM UTC, comment #9: 

Rik,
The secondaction (type "a") gives me an error message in the terminal:

>> a
Undefined function or variable 'a'.


Apparently Matlab transfers the focus to the terminal for key presses even if the mouse cursor is in the graphics windows.

The currentpoint for the entire action sequence remains to be the same and it is two rather than one for reasons unknown to me:

>> plot (1:10)
% mouse click lower left
>> get (gca, 'currentpoint')

ans =

    1.1970    1.1974    1.0000
    1.1970    1.1974   -1.0000

% mouse cursor upper right, tapping 'a' key
>> a
Undefined function or variable 'a'.

>> get (gca, 'currentpoint')

ans =

    1.1970    1.1974    1.0000
    1.1970    1.1974   -1.0000
>>


Philip Nienhuis <philipnienhuis>
Group Member
Tue 21 Apr 2015 08:53:59 PM UTC, comment #8: 

I think I need another test run.  I know that Matlab updates the currentpoint property when ginput is run.  Does it update the currentpoint property for every keypress regardless of whether ginput is running?

Sample code:


plot (1:10);
%% Move mouse to plot window and click near point (1,1)
%% Move mouse near point (10,10) and type 'a'
%% Move mouse and focus back to command window
get (gca, 'currentpoint')


Is the answer (1,1) or (10,10)?

Rik <rik5>
Group administrator
Tue 21 Apr 2015 07:38:50 PM UTC, comment #7: 

Thank you very much for the fix!
I'll try later tonight, or tomorrow.

Philip Nienhuis <philipnienhuis>
Group Member
Tue 21 Apr 2015 03:52:13 AM UTC, comment #6: 

I fixed the return coordinates for Qt in this cset (http://hg.savannah.gnu.org/hgweb/octave/rev/248f2f2e7d48).  It was more difficult than I had hoped.

I'm re-titling to reflect that FLTK has not been updated

Rik <rik5>
Group administrator
Sun 19 Apr 2015 03:29:07 AM UTC, comment #5: 

Thanks Guillaume.  I now have enough information to code a solution.

Rik <rik5>
Group administrator
Sat 18 Apr 2015 11:30:58 PM UTC, comment #4: 

Here is what MATLAB returns:


get (gca, 'currentpoint')

x =

    2.0058
    4.9919


y =

    2.0102
    5.0015


b =

     1
    97


ans =

    4.9919    5.0015    1.0000
    4.9919    5.0015   -1.0000


Guillaume <gyom>
Sat 18 Apr 2015 10:43:17 PM UTC, comment #3: 

@Philip: Could you test whether Matlab is updating the CurrentPoint property when a key is pressed?

Sample code:


plot (1:10);
[x,y,b] = ginput (2)
%% Now move the cursor to some point like (2,2) and left-click mouse
%% Now move cursor to a new point like (5,5) and press 'a'
get (gca, 'currentpoint')


You said that the value returned in (x,y) was correct for a keypress.  Was the value of the CurrentPoint property the same as that returned in (x,y) which is something like (5,5)?

Rik <rik5>
Group administrator
Tue 14 Apr 2015 07:44:27 PM UTC, comment #2: 

I just tested on Linux -> same issue -> OS set to Any

Philip Nienhuis <philipnienhuis>
Group Member
Tue 14 Apr 2015 07:18:12 PM UTC, comment #1: 

Confirmed.  Although what it appears to do is simply return the coordinates of the last mouse button press (maybe initialized to 0,0 if there has bee no mouse button yet).

This will have to be fixed separatel for the FLTK toolkit and for the Qt toolkit.

For the FLTK toolkit the file is libinterp/dldfcn/__init_fltk__.cc.  The function is handle() and the case statement block is FL_KEYDOWN.  Probably need to borrow the code from FL_PUSH (single mouse click) and set the currentpoint property of the axis. 

This is what the callback for a keypress in ginput.m relies on to get the positioning.


function ginput_keypressfcn (src, evt)
  point = get (gca (), "currentpoint");
  key = evt.Key;
  if (key == "return")
    ## Enter key stops ginput.
    ginput_accumulator (2, NaN, NaN, NaN);
  else
    ginput_accumulator (1, point(1,1), point(1,2), uint8 (key(1)));
  endif
endfunction


Of course, this might not be exactly Matlab compatible as my reading of the documentation suggests that only a true mouse click should set the currentpoint property.  But, maybe this small Matlab incompatibity isn't as bad as not returning X,Y coordinates.

For Qt, the file to change is libgui/graphics/Canvas.cc.  The function is Canvas::canvasKeyPressEvent.  Very likely the same solution in that updateCurrentPoint (figObj, obj, event) needs to be called when a key is pressed, not just for a mouse event.

Rik <rik5>
Group administrator
Tue 14 Apr 2015 12:49:33 PM UTC, original submission:  

With the OpenGL toolkits, ginput returns (0, 0) for the XY coordinates when a key is pressed. This has been the case since 3.8.2

In gnuplot has been working fine since at least 3.8.2. Matlab's ginput also returns proper plot coordinates for key presses

Philip Nienhuis <philipnienhuis>
Group Member

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by gyom (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by philipnienhuis (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2015-04-23 rik5 StatusConfirmed Fixed
        Open/ClosedOpen Closed
    2015-04-21 rik5 Summary[OpenGL] ginput doesn\'t return proper (X,Y) coordinates for key press [FLTK] ginput doesn't return proper (X,Y) coordinates for key press
    2015-04-14 philipnienhuis Operating SystemMicrosoft Windows Any
    2015-04-14 rik5 StatusNone Confirmed

    Back to the top

    Powered by Savane 3.13-4b48.
    Corresponding source code