//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)
{
}
}
}
})
...
try
{
p = pl.get(roi)
roi.setPosition(
new
Point2D.Double(p.getX()+curPos.getX(),p.getY()+curPos.getY()))
roi.setZ(13)
}
catch
(e)
{
}
...
...<code class="js plain" style="outline: 0px !important; font-size: 1em !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; bottom: auto !important; float: none !important; height: auto !important;
To view this discussion on the web visit https://groups.google.com/d/msgid/icy-software/c1c99528-f267-4f69-887e-9997e86cb43d%40googlegroups.com.--
You received this message because you are subscribed to a topic in the Google Groups "Icy imaging" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/icy-software/49OI1VVhH5A/unsubscribe.
To unsubscribe from this group and all its topics, send an email to icy-software...@googlegroups.com.
To post to this group, send email to icy-so...@googlegroups.com.
size = input0.length
for(i=0;i<size;i++)
{
p = input0[i].getPosition5D()
//set z and t here
p.setZ(1);
p.setT(-1);
input0[i].setPosition5D(p)
}
output0 = input0