Skip to content

Commit

Permalink
2020.03.05 (1.52u33; ROI enhancements)
Browse files Browse the repository at this point in the history
  • Loading branch information
rasband committed Mar 5, 2020
1 parent c1e82a1 commit a6ce76d
Show file tree
Hide file tree
Showing 25 changed files with 795 additions and 591 deletions.
2 changes: 1 addition & 1 deletion ij/ImageJ.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public class ImageJ extends Frame implements ActionListener,

/** Plugins should call IJ.getVersion() or IJ.getFullVersion() to get the version string. */
public static final String VERSION = "1.52u";
public static final String BUILD = "29";
public static final String BUILD = "33";
public static Color backgroundColor = new Color(237,237,237);
/** SansSerif, 12-point, plain font. */
public static final Font SansSerif12 = new Font("SansSerif", Font.PLAIN, 12);
Expand Down
2 changes: 1 addition & 1 deletion ij/gui/Arrow.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public void draw(Graphics g) {
Rectangle r = ic.getSrcRect();
xbase = r.x; ybase = r.y;
}
at.setTransform(mag, 0.0, 0.0, mag, -xbase*mag, -ybase*mag);
at.setTransform(mag, 0.0, 0.0, mag, (-xbase+0.5)*mag, (-ybase+0.5)*mag); //0.5: int coordinate at pixel center
if (outline) {
float lineWidth = (float)(getOutlineWidth()*mag);
g2.setStroke(new BasicStroke(lineWidth, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND));
Expand Down
12 changes: 6 additions & 6 deletions ij/gui/EllipseRoi.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ public EllipseRoi(double x1, double y1, double x2, double y2, double aspectRatio
public EllipseRoi(int sx, int sy, ImagePlus imp) {
super(sx, sy, imp);
type = FREEROI;
xstart = ic.offScreenXD(sx);
ystart = ic.offScreenYD(sy);
xstart = offScreenXD(sx);
ystart = offScreenYD(sy);
setDrawOffset(false);
bounds = null;
}
Expand All @@ -45,8 +45,8 @@ public void draw(Graphics g) {
protected void grow(int sx, int sy) {
double x1 = xstart;
double y1 = ystart;
double x2 = ic.offScreenXD(sx);
double y2 = ic.offScreenYD(sy);
double x2 = offScreenXD(sx);
double y2 = offScreenYD(sy);
makeEllipse(x1, y1, x2, y2);
imp.draw();
}
Expand Down Expand Up @@ -149,8 +149,8 @@ protected void handleMouseUp(int screenX, int screenY) {
}

protected void moveHandle(int sx, int sy) {
double ox = ic.offScreenXD(sx);
double oy = ic.offScreenYD(sy);
double ox = offScreenXD(sx);
double oy = offScreenYD(sy);
double x1 = xpf[handle[2]]+x;
double y1 = ypf[handle[2]]+y;
double x2 = xpf[handle[0]]+x;
Expand Down
16 changes: 8 additions & 8 deletions ij/gui/FreehandRoi.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ protected void grow(int sx, int sy) {
growFloat(sx, sy);
return;
}
int ox = ic.offScreenX(sx);
int oy = ic.offScreenY(sy);
int ox = offScreenX(sx);
int oy = offScreenY(sy);
if (ox<0) ox = 0;
if (oy<0) oy = 0;
if (ox>xMax) ox = xMax;
Expand All @@ -40,8 +40,8 @@ protected void grow(int sx, int sy) {
}

private void growFloat(int sx, int sy) {
double ox = ic.offScreenXD(sx);
double oy = ic.offScreenYD(sy);
double ox = offScreenXD(sx);
double oy = offScreenYD(sy);
if (ox<0.0) ox = 0.0;
if (oy<0.0) oy = 0.0;
if (ox>xMax) ox = xMax;
Expand All @@ -61,10 +61,10 @@ private void growFloat(int sx, int sy) {
void drawLine() {
int x1, y1, x2, y2;
if (xpf!=null) {
x1 = (int)xpf[nPoints-2]+x;
y1 = (int)ypf[nPoints-2]+y;
x2 = (int)xpf[nPoints-1]+x;
y2 = (int)ypf[nPoints-1]+y;
x1 = (int)Math.round(xpf[nPoints-2]+x);
y1 = (int)Math.round(ypf[nPoints-2]+y);
x2 = (int)Math.round(xpf[nPoints-1]+x);
y2 = (int)Math.round(ypf[nPoints-1]+y);
} else {
x1 = xp[nPoints-2]+x;
y1 = yp[nPoints-2]+y;
Expand Down
14 changes: 10 additions & 4 deletions ij/gui/ImageCanvas.java
Original file line number Diff line number Diff line change
Expand Up @@ -1316,8 +1316,8 @@ protected void handleRoiMouseDown(MouseEvent e) {
boolean multiPointMode = roi!=null && (roi instanceof PointRoi) && handle==-1
&& tool==Toolbar.POINT && Toolbar.getMultiPointMode();
if (multiPointMode) {
double oxd = offScreenXD(sx);
double oyd = offScreenYD(sy);
double oxd = roi.offScreenXD(sx);
double oyd = roi.offScreenYD(sy);
if (e.isShiftDown() && !IJ.isMacro()) {
FloatPolygon points = roi.getFloatPolygon();
if (points.npoints>0) {
Expand Down Expand Up @@ -1592,7 +1592,13 @@ private boolean activateOverlayRoi(int ox, int oy) {
for (int i=o.size()-1; i>=0; i--) {
Roi roi = o.get(i);
//IJ.log(".isAltDown: "+roi.contains(ox, oy));
if (roi.contains(ox, oy) || (labels&&labelRects!=null&&labelRects[i]!=null&&labelRects[i].contains(sx,sy))) {
boolean containsMousePoint = false;
if (roi instanceof Line) { //grab line roi near its center
double grabLineWidth = 1.1 + 5./magnification;
containsMousePoint = (((Line)roi).getFloatPolygon(grabLineWidth)).contains(ox, oy);
} else
containsMousePoint = roi.contains(ox, oy);
if (containsMousePoint || (labels&&labelRects!=null&&labelRects[i]!=null&&labelRects[i].contains(sx,sy))) {
if (hyperstack && roi.getPosition()==0) {
int c = roi.getCPosition();
int z = roi.getZPosition();
Expand Down Expand Up @@ -1707,4 +1713,4 @@ public void repaintOverlay() {
repaint();
}

}
}
Loading

0 comments on commit a6ce76d

Please sign in to comment.