Login  Register

Re: Create pre-defined ROI on mouse click and add to ROI manager

Posted by Straub, Volko A. (Dr.) on Jun 19, 2014; 5:41am
URL: http://imagej.273.s1.nabble.com/Create-pre-defined-ROI-on-mouse-click-and-add-to-ROI-manager-tp5008292p5008305.html

I encountered similar problems in the past when I tried to do something
like this. The only way I could get around the problem was by inserting
a wait() command after the getCursorLoc() command (try wait(100), but
depends on your mouse clicking habit).
Hope this helps,
Volko


On 18/06/2014 17:31, JBImageJ wrote:

> macro CircleOn_MouseClick{
>          getPixelSize(unit, pixelWidth, pixelHeight);
>          setTool("rectangle");
>          leftButton=16;
>          rightButton=4;
>          radius = 100;
>          Dialog.create("Settings");
>          Dialog.addNumber("Set radius of circle", radius);
>          Dialog.show();
>          radius = Dialog.getNumber();
>          height = 2*pixelHeight*radius;
>          width = 2*pixelWidth*radius;
>          x2=-1; y2=-1; z2=-1; flags2=-1;
>          getCursorLoc(x, y, z, flags);
>          while (flags&rightButton==0){
>                  getCursorLoc(x, y, z, flags);
>                  if (flags&leftButton!=0) {
>                                  if (x!=x2 || y!=y2 || z!=z2 ||
> flags!=flags2) {
>                                  x = x - width/2;
>                                  y = y - height/2;
>                                  makeOval(x, y, width, height);
>                                  roiManager("Add");
>                                  
>                          }
>
>                 }
>        }
> }

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