Run Measure after drawing a Line

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

Run Measure after drawing a Line

JSmith-2
I'm new to writing Macros, and I'm trying to write one that will run Measure each time I draw a line.  So far I have it so that Measure is running continuously while I draw the line, then stops measuring after I stop drawing.  

Is there a way I can make Measure only run after the mouse is released?  

Thanks for any advice you can give.
Reply | Threaded
Open this post in threaded view
|

Re: Run Measure after drawing a Line

Wayne Rasband
Change the macro so it runs the Measure command when the user lets up  
the mouse button. Here is a macro tool that does this.

-wayne

  macro "Measure Line Tool -C00bL1de0L1ee1" {
         getCursorLoc(x, y, z, flags);
         xstart = x; ystart = y;
         x2=x; y2=y;
         while (true) {
             getCursorLoc(x, y, z, flags);
             if (flags&16==0) {
                  run("Measure");
                  exit;
             }
             if (x!=x2 || y!=y2)
                 makeLine(xstart, ystart, x, y);
             x2=x; y2=y;
             wait(10);
         };
     }

On Dec 7, 2007, at 3:40 PM, jsmith wrote:

> I'm new to writing Macros, and I'm trying to write one that will run  
> Measure
> each time I draw a line.  So far I have it so that Measure is running
> continuously while I draw the line, then stops measuring after I stop
> drawing.
>
> Is there a way I can make Measure only run after the mouse is released?
>
> Thanks for any advice you can give.
> --  
> View this message in context:  
> http://www.nabble.com/Run-Measure-after-drawing-a-Line- 
> tf4964297.html#a14220131
> Sent from the ImageJ mailing list archive at Nabble.com.
>
Reply | Threaded
Open this post in threaded view
|

Re: Run Measure after drawing a Line

JSmith-2
Thank you SO much!  This is exactly what I was trying to do!  :)

Sometimes the lines I'm measuring are a bit curved, is it possible to replace the line tool with the freehand line tool in this macro?  

Jen

Wayne Rasband wrote
Change the macro so it runs the Measure command when the user lets up  
the mouse button. Here is a macro tool that does this.

-wayne

  macro "Measure Line Tool -C00bL1de0L1ee1" {
         getCursorLoc(x, y, z, flags);
         xstart = x; ystart = y;
         x2=x; y2=y;
         while (true) {
             getCursorLoc(x, y, z, flags);
             if (flags&16==0) {
                  run("Measure");
                  exit;
             }
             if (x!=x2 || y!=y2)
                 makeLine(xstart, ystart, x, y);
             x2=x; y2=y;
             wait(10);
         };
     }

On Dec 7, 2007, at 3:40 PM, jsmith wrote:

> I'm new to writing Macros, and I'm trying to write one that will run  
> Measure
> each time I draw a line.  So far I have it so that Measure is running
> continuously while I draw the line, then stops measuring after I stop
> drawing.
>
> Is there a way I can make Measure only run after the mouse is released?
>
> Thanks for any advice you can give.
> --  
> View this message in context:  
> http://www.nabble.com/Run-Measure-after-drawing-a-Line- 
> tf4964297.html#a14220131
> Sent from the ImageJ mailing list archive at Nabble.com.
>