Posted by
Aryeh Weiss on
Jan 08, 2008; 10:29am
URL: http://imagej.273.s1.nabble.com/imageJ-front-panel-fonts-size-tp3697649p3697653.html
Michael Schmid wrote:
> Hi Aryeh,
>
> you could use the "Wait_For_User" plugin:
>
>
http://imagejdocu.tudor.lu/imagej-documentation-wiki/plugins/wait_for_user>
> Michael
> ________________________________________________________________
>
> On 7 Jan 2008, at 06:56, Aryeh Weiss wrote:
>
>> How does one interactively select an ROI in a Macro? I would like to
>> select the ROI in a loop, inside the macro. I see many ways to
>> manipulate an ROI once it exists, but I have not found a simple way to
>> specify the ROI by drawing with the mouse. It looks like I can use
>> getCursorLoc (as in GetCursorLoc Demo Tool) and then make it, but I
>> wonder if there is already a piece of a macro that does it, probably
>> better than I will.
>>
Thank you Michael. That is much better than what I cobbled together.
What you suggest is exactly right.
Here is what I did:
// adapted from Get CursorLocDemo
function Draw_Box() {
leftButton=16;
x2=-1; y2=-1; z2=-1; flags2=-1;
// wait until the left mouse button is pressed
getCursorLoc(x, y, z, flags);
while (flags&leftButton==0) {getCursorLoc(x, y, z, flags);}
// draw and update the box as long as the left mouse button is pressed
while (flags&leftButton!=0) {
getCursorLoc(x2, y2, z2, flags);
delta_x = x-x2; delta_y = y-y2;
makeRectangle(minOf(x,x2), minOf(y,y2),abs(delta_x), abs(delta_y));
wait(10);
}
// the return of delta_x is a kludge to let the macro decide if the
// rectangle is large enough
return abs(delta_x);
}
Best regards,
--aryeh
--
Aryeh Weiss
School of Engineering
Bar Ilan University
Ramat Gan 52900 Israel
Ph: 972-3-5317638
FAX: 972-3-7384050