Commit d93dc65d authored by Daniel Felipe  GONZALEZ OBANDO's avatar Daniel Felipe GONZALEZ OBANDO
Browse files

Get and set position allow to use ROI center position

parent 199d07ed
......@@ -5,6 +5,7 @@ import icy.plugin.interface_.PluginBundled;
import icy.plugin.interface_.PluginLibrary;
import icy.roi.ROI;
import icy.type.point.Point5D;
import icy.type.rectangle.Rectangle5D;
import plugins.adufour.blocks.tools.roi.ROIBlock;
import plugins.adufour.blocks.util.VarList;
import plugins.adufour.vars.lang.VarDouble;
......@@ -26,6 +27,10 @@ public class GetROIPosition extends Plugin implements ROIBlock, PluginLibrary, P
protected VarDouble posT = new VarDouble("position T", 0d);
protected VarDouble posC = new VarDouble("position C", 0d);
protected VarDouble posXCenter = new VarDouble("position X(center)", 0d);
protected VarDouble posYCenter = new VarDouble("position Y(center)", 0d);
protected VarDouble posZCenter = new VarDouble("position Z(center)", 0d);
@Override
public void run()
{
......@@ -33,14 +38,18 @@ public class GetROIPosition extends Plugin implements ROIBlock, PluginLibrary, P
{
if (roi != null)
{
final Point5D pos = roi.getPosition5D();
final Rectangle5D bounds = roi.getBounds5D();
posX.setValue(Double.valueOf(bounds.getX()));
posY.setValue(Double.valueOf(bounds.getY()));
posZ.setValue(Double.valueOf(bounds.getZ()));
posT.setValue(Double.valueOf(bounds.getT()));
posC.setValue(Double.valueOf(bounds.getC()));
posXCenter.setValue(Double.valueOf(bounds.getCenterX()));
posYCenter.setValue(Double.valueOf(bounds.getCenterY()));
posZCenter.setValue(Double.valueOf(bounds.getCenterZ()));
posX.setValue(Double.valueOf(pos.getX()));
posY.setValue(Double.valueOf(pos.getY()));
posZ.setValue(Double.valueOf(pos.getZ()));
posT.setValue(Double.valueOf(pos.getT()));
posC.setValue(Double.valueOf(pos.getC()));
// stop here
break;
}
......@@ -61,6 +70,10 @@ public class GetROIPosition extends Plugin implements ROIBlock, PluginLibrary, P
outputMap.add("posZ", posZ);
outputMap.add("posT", posT);
outputMap.add("posC", posC);
outputMap.add("posXCenter", posXCenter);
outputMap.add("posYCenter", posYCenter);
outputMap.add("posZCenter", posZCenter);
}
@Override
......
......@@ -8,8 +8,11 @@ import icy.plugin.interface_.PluginBundled;
import icy.plugin.interface_.PluginLibrary;
import icy.roi.ROI;
import icy.type.point.Point5D;
import icy.type.point.Point5D.Double;
import icy.type.rectangle.Rectangle5D;
import plugins.adufour.blocks.tools.roi.ROIBlock;
import plugins.adufour.blocks.util.VarList;
import plugins.adufour.vars.lang.VarBoolean;
import plugins.adufour.vars.lang.VarDouble;
import plugins.adufour.vars.lang.VarROIArray;
import plugins.stef.roi.bloc.RoiBlocks;
......@@ -27,16 +30,33 @@ public class SetROIPosition extends Plugin implements ROIBlock, PluginLibrary, P
protected VarDouble posZ = new VarDouble("position Z", -1d);
protected VarDouble posT = new VarDouble("position T", -1d);
protected VarDouble posC = new VarDouble("position C", -1d);
protected VarBoolean useCenter = new VarBoolean("Set XYZ Center", false);
@Override
public void run()
{
final Point5D pos = new Point5D.Double(posX.getValue().doubleValue(), posY.getValue().doubleValue(), posZ
.getValue().doubleValue(), posT.getValue().doubleValue(), posC.getValue().doubleValue());
final Point5D.Double pos = new Point5D.Double(posX.getValue().doubleValue(), posY.getValue().doubleValue(),
posZ.getValue().doubleValue(), posT.getValue().doubleValue(), posC.getValue().doubleValue());
for (ROI roi : roiSet)
{
if ((roi != null) && roi.canSetPosition())
roi.setPosition5D(pos);
{
if (useCenter.getValue())
{
Rectangle5D bounds = roi.getBounds5D();
Point5D.Double newPos = (Double) pos.clone();
newPos.setX(pos.getX() - bounds.getSizeX() / 2);
newPos.setY(pos.getY() - bounds.getSizeY() / 2);
newPos.setZ(pos.getZ() - bounds.getSizeZ() / 2);
roi.setPosition5D(newPos);
}
else
{
roi.setPosition5D(pos);
}
}
}
}
@Override
......@@ -48,6 +68,7 @@ public class SetROIPosition extends Plugin implements ROIBlock, PluginLibrary, P
inputMap.add("posZ", posZ);
inputMap.add("posT", posT);
inputMap.add("posC", posC);
inputMap.add("useXYZCenter", useCenter);
}
@Override
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment