getCursorLoc function

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

getCursorLoc function

Straub, Volko A. (Dr.)
Hi Everybody,

I am using the getCursorLoc(x, y, z, modifiers) function in a macro.
Using it with most selection tools, the value returned by the variable
when clicking the left mouse button is 16. However, I noticed that when
using it with thepointselection tool it can be 16, 32 or 48, which
appears to depend on the cursor movement as illustrated by the code
below. It looks like it has something to do with the cursor movement
(i.e. when cursor is moving at start and end of mouse click, it appears
to be 16, if it is stationary at start of mouse click it seems to be
initially 48 followed by 32 until cursor is moved), but I couldn't find
any comments about this in the macro command documentation. Could
anybody provide some more detail/explanation?

Thanks,
Volko


setOption("DisablePopupMenu", true);
setTool(7);
modifiers=0;
while (modifiers!=4) {
     getCursorLoc(x,y,z,modifiers);
     print(toolID+" "+modifiers);
     wait(100);
};
setOption("DisablePopupMenu", false);*
**
*

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: getCursorLoc function

Michael Schmid
Hi Volko,

if the cursor is inside the selection, you get the insideROI = 32 flag (cursor inside selection) as long as the cursor position selection is inside the selection.

For a PointRoi, the insideROI flag is set if the coordinates are exactly equal to those of a point of the selection. At high magnification, you will see this more often; then it is easier to hit a point exactly with the cursor. At low magnification, it is a matter of luck whether the cursor exactly hits the location of a point.

Typically, for the flags one has to do a bitwise 'and' operation with some mask, e.g.
  shift=1;
  ctrl=2;
  if (flags & (shift+ctrl) != 0) print("position with shift or ctrl down");

For the flags, see
  http://imagej.nih.gov/ij/macros//GetCursorLocDemo.txt

Michael
________________________________________________________________
On May 31, 2015, at 08:07, Volko Straub wrote:

> Hi Everybody,
>
> I am using the getCursorLoc(x, y, z, modifiers) function in a macro. Using it with most selection tools, the value returned by the variable when clicking the left mouse button is 16. However, I noticed that when using it with thepointselection tool it can be 16, 32 or 48, which appears to depend on the cursor movement as illustrated by the code below. It looks like it has something to do with the cursor movement (i.e. when cursor is moving at start and end of mouse click, it appears to be 16, if it is stationary at start of mouse click it seems to be initially 48 followed by 32 until cursor is moved), but I couldn't find any comments about this in the macro command documentation. Could anybody provide some more detail/explanation?
>
> Thanks,
> Volko
>
>
> setOption("DisablePopupMenu", true);
> setTool(7);
> modifiers=0;
> while (modifiers!=4) {
>    getCursorLoc(x,y,z,modifiers);
>    print(toolID+" "+modifiers);
>    wait(100);
> };
> setOption("DisablePopupMenu", false);*
> **
> *
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: getCursorLoc function

Straub, Volko A. (Dr.)
Hi Michael,
Thanks for the explanation and pointing me to the sample macro - I had missed the list of the different flag values. Any idea what the flag value 48 indicates? Appears to be a more recent addition as it is not listed in the sample macro.
Thanks,
Volko

On June 1, 2015 5:49:14 PM GMT+01:00, Michael Schmid <[hidden email]> wrote:

>Hi Volko,
>
>if the cursor is inside the selection, you get the insideROI = 32 flag
>(cursor inside selection) as long as the cursor position selection is
>inside the selection.
>
>For a PointRoi, the insideROI flag is set if the coordinates are
>exactly equal to those of a point of the selection. At high
>magnification, you will see this more often; then it is easier to hit a
>point exactly with the cursor. At low magnification, it is a matter of
>luck whether the cursor exactly hits the location of a point.
>
>Typically, for the flags one has to do a bitwise 'and' operation with
>some mask, e.g.
>  shift=1;
>  ctrl=2;
>if (flags & (shift+ctrl) != 0) print("position with shift or ctrl
>down");
>
>For the flags, see
>  http://imagej.nih.gov/ij/macros//GetCursorLocDemo.txt
>
>Michael
>________________________________________________________________
>On May 31, 2015, at 08:07, Volko Straub wrote:
>
>> Hi Everybody,
>>
>> I am using the getCursorLoc(x, y, z, modifiers) function in a macro.
>Using it with most selection tools, the value returned by the variable
>when clicking the left mouse button is 16. However, I noticed that when
>using it with thepointselection tool it can be 16, 32 or 48, which
>appears to depend on the cursor movement as illustrated by the code
>below. It looks like it has something to do with the cursor movement
>(i.e. when cursor is moving at start and end of mouse click, it appears
>to be 16, if it is stationary at start of mouse click it seems to be
>initially 48 followed by 32 until cursor is moved), but I couldn't find
>any comments about this in the macro command documentation. Could
>anybody provide some more detail/explanation?
>>
>> Thanks,
>> Volko
>>
>>
>> setOption("DisablePopupMenu", true);
>> setTool(7);
>> modifiers=0;
>> while (modifiers!=4) {
>>    getCursorLoc(x,y,z,modifiers);
>>    print(toolID+" "+modifiers);
>>    wait(100);
>> };
>> setOption("DisablePopupMenu", false);*
>> **
>> *
>>
>> --
>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>
>--
>ImageJ mailing list: http://imagej.nih.gov/ij/list.html

--
Sent from my Android device with K-9 Mail. Please excuse my brevity.

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: getCursorLoc function

Michael Schmid
Hi Volko,

the flags are additive, so e.g.
  48 = 16+32 = leftButton + insideROI
   3 =  1+ 2 = shift+ctrl
  33 =  1+32 = shift+insideROI
etc.

All the flags are a power of 2. Thus, each flag has exactly one bit set
when written as a binary number. So one can disentangle them by bitwise
'and' operations.
  http://en.wikipedia.org/wiki/Mask_%28computing%29

Michael
__________________________________________________________


On Mon, June 1, 2015 20:03, vs64 wrote:

> Hi Michael,
> Thanks for the explanation and pointing me to the sample macro - I had
> missed the list of the different flag values. Any idea what the flag value
> 48 indicates? Appears to be a more recent addition as it is not listed in
> the sample macro.
> Thanks,
> Volko
>
> On June 1, 2015 5:49:14 PM GMT+01:00, Michael Schmid
> <[hidden email]> wrote:
>>Hi Volko,
>>
>>if the cursor is inside the selection, you get the insideROI = 32 flag
>>(cursor inside selection) as long as the cursor position selection is
>>inside the selection.
>>
>>For a PointRoi, the insideROI flag is set if the coordinates are
>>exactly equal to those of a point of the selection. At high
>>magnification, you will see this more often; then it is easier to hit a
>>point exactly with the cursor. At low magnification, it is a matter of
>>luck whether the cursor exactly hits the location of a point.
>>
>>Typically, for the flags one has to do a bitwise 'and' operation with
>>some mask, e.g.
>>  shift=1;
>>  ctrl=2;
>>if (flags & (shift+ctrl) != 0) print("position with shift or ctrl
>>down");
>>
>>For the flags, see
>>  http://imagej.nih.gov/ij/macros//GetCursorLocDemo.txt
>>
>>Michael
>>________________________________________________________________
>>On May 31, 2015, at 08:07, Volko Straub wrote:
>>
>>> Hi Everybody,
>>>
>>> I am using the getCursorLoc(x, y, z, modifiers) function in a macro.
>>Using it with most selection tools, the value returned by the variable
>>when clicking the left mouse button is 16. However, I noticed that when
>>using it with thepointselection tool it can be 16, 32 or 48, which
>>appears to depend on the cursor movement as illustrated by the code
>>below. It looks like it has something to do with the cursor movement
>>(i.e. when cursor is moving at start and end of mouse click, it appears
>>to be 16, if it is stationary at start of mouse click it seems to be
>>initially 48 followed by 32 until cursor is moved), but I couldn't find
>>any comments about this in the macro command documentation. Could
>>anybody provide some more detail/explanation?
>>>
>>> Thanks,
>>> Volko
>>>
>>>
>>> setOption("DisablePopupMenu", true);
>>> setTool(7);
>>> modifiers=0;
>>> while (modifiers!=4) {
>>>    getCursorLoc(x,y,z,modifiers);
>>>    print(toolID+" "+modifiers);
>>>    wait(100);
>>> };
>>> setOption("DisablePopupMenu", false);*
>>> **
>>> *
>>>
>>> --
>>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>
>>--
>>ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>
> --
> Sent from my Android device with K-9 Mail. Please excuse my brevity.
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html