Short Description

Move all selected ROIs together

Documentation

Move all selected roi together

Usage

  • Select all ROIs you want to move together
  • run this script, and you will found a red point ROI on the left-top corner of current sequence
  • drag the red point

Versions

  • Version 1 • Released on: 2014-07-29 15:56:23
    Download
    Description:

    initial version

    //Move all selected roi together
    //Usage
    //Select all ROIs you want to move together
    //run this script, and you will found a red point ROI on the left-top corner of current sequence
    //drag the red point
    
    
    //Author Will Ouyang
    
    
    importClass(Packages.icy.type.collection.array.Array1DUtil)
    importClass(Packages.icy.roi.ROIListener)
    importClass(Packages.icy.roi.ROI2DPoint)
    importClass(Packages.java.awt.geom.Point2D)
    importClass(Packages.java.awt.Color)
    importClass(Packages.java.util.HashMap)
    seq = getSequence()
    if (seq == null) throw "Please open a sequence first"
     
    rois = seq.getROI2Ds()
    if (rois.isEmpty()) throw "No ROI on the sequence"
    roi = rois.get(0)
    
    anchor = new ROI2DPoint(0,0)
    anchor.setColor(Color.red)
    seq.addROI(anchor, true)
    lastPos = anchor.getPosition2D()
    var pl = new HashMap()
    size = rois.size()
    for(i = 0;i< size ;i++ )
    {
    	roi = rois.get(i)
    	if(roi.isSelected())
    	if(roi != anchor)
    	{
    		pl.put(roi,roi.getPosition2D())
    	}
    }
    anchor.setSelected(true)
    anchor.addListener(new ROIListener(){
    	roiChanged: function(ev) {
    		anchor = ev.getSource()
    		curPos =  anchor.getPosition2D()
    		for(i = 0;i< size ;i++ )
    		{
    			roi = rois.get(i)
    			if(roi == anchor)
    				continue
    			try
    			{
    				p = pl.get(roi)
    				roi.setPosition(new Point2D.Double(p.getX()+curPos.getX(),p.getY()+curPos.getY()))
    			}
    			catch(e)
    			{
    			}
    		}
        	}
    })
    
    
    
    
    

Leave a Review