Login  Register

Re: Macro: cancel button & set scale

Posted by ben.s.carlson on Jun 13, 2014; 1:10am
URL: http://imagej.273.s1.nabble.com/Macro-cancel-button-set-scale-tp5008166p5008182.html

Both worked perfectly, thank you!!

Ben


On Thu, Jun 12, 2014 at 7:40 PM, Rasband, Wayne (NIH/NIMH) [E] [via ImageJ] <[hidden email]> wrote:
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

>
> Thank you for the help!
>
> Ben
>
>
>
>
>
>
>
> --
> View this message in context: http://imagej.1557.x6.nabble.com/Macro-cancel-button-set-scale-tp5008166.html
> Sent from the ImageJ mailing list archive at Nabble.com.
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

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



If you reply to this email, your message will be added to the discussion below:
http://imagej.1557.x6.nabble.com/Macro-cancel-button-set-scale-tp5008166p5008180.html
To unsubscribe from Macro: cancel button & set scale, click here.
NAML