Posted by
Rasband, Wayne (NIH/NIMH) [E] on
Jun 12, 2014; 11:38pm
URL: http://imagej.273.s1.nabble.com/Macro-cancel-button-set-scale-tp5008166p5008180.html
On Jun 12, 2014, at 10:58 AM, ben.s.carlson wrote:
> Hello,
>
> I have two questions regarding the macro language. After some searching and
> experimentation, I can't find the answer so I'm wondering if anybody can
> provide assistance.
>
> I have a somewhat interactive macro in which there are several waitForUser
> prompts that request that the user takes some action.
>
> 1) I'm wondering if there is some way to add a Cancel button to the
> waitForUser prompt. I'd like to do this because if the user makes a mistake
> and has to start over, there is no way for them to do so. Instead, they
> just have to click "OK" on the many prompts that appear until the macro
> finishes.
>
> Here is a small snippet. Can I add Cancel buttons to these prompts?
>
> waitForUser( "Pause","Focus on the ruler");
> setTool("line");
> waitForUser( "Pause","Draw a line and set scale");
You can cancel a waitForUser dialog and abort the macro by pressing the esc key.
> 2) The second is related to the request to "set the scale" above. Is it
> possible to automate this so that the user is not required to click Analyze
> -> Set Scale? The "Distance in Pixels" value is always the length of the
> line the user just drew, "Known distance" is 1.0, and "Unit of length" is
> cm. This seems like it is something that can be automated.
This should do it:
getLine(x1, y1, x2, y2, lineWidth);
if (x1==-1)
exit("Stright line selection required");
dx=x2-x1; dy=y2-y1;
length = sqrt(dx*dx+dy*dy);
setVoxelSize(1/length, 1/length, 1, "cm");
-wayne
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html