Merge "Issue #2281 Fix shear click distance calculations. Change-Id: I67980264723512a4167cf90cfc3adac2c9ba1d08" into development
Former-commit-id:6da211df08
[formerly9750770e95
] [formerly9e885902f2
] [formerly6da211df08
[formerly9750770e95
] [formerly9e885902f2
] [formerly80c5359b2f
[formerly9e885902f2
[formerly c89594a00326e3e2fe89575db8c54920ac4f94fe]]]] Former-commit-id:80c5359b2f
Former-commit-id:345623b6f1
[formerlyc275483a82
] [formerly b303bd199a493df962b1e1e3c8875da4abbde4aa [formerlye81d8579c6
]] Former-commit-id: 53ca136668c55e8489b99198a3531f4e596e3fb1 [formerlye58772a81f
] Former-commit-id:f6fe063540
This commit is contained in:
commit
0440927789
4 changed files with 52 additions and 90 deletions
|
@ -37,6 +37,7 @@ import com.vividsolutions.jts.geom.GeometryFactory;
|
|||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Aug 29, 2013 2281 bsteffen Rename ToolsUiUitil.
|
||||
*
|
||||
*
|
||||
* </pre>
|
||||
|
@ -45,7 +46,7 @@ import com.vividsolutions.jts.geom.GeometryFactory;
|
|||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class ToolsUiUitil {
|
||||
public class ToolsUiUtil {
|
||||
|
||||
private static final GeometryFactory gf = new GeometryFactory();
|
||||
|
|
@ -39,7 +39,8 @@ import com.vividsolutions.jts.geom.Coordinate;
|
|||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 01/11/2010 mnash
|
||||
* Jan 11, 2010 mnash
|
||||
* Aug 29, 2013 2281 bsteffen Fix click distance calculations.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -102,11 +103,10 @@ public abstract class ShearAction extends AbstractGenericToolAction<ShearLayer>
|
|||
lastMouseY = y;
|
||||
|
||||
if (shearLayer.isEditable()) {
|
||||
Coordinate c = editor.translateClick(x, y);
|
||||
|
||||
if (mouseButton == 1) {
|
||||
lineToMove = -1;
|
||||
coordinateFound = shearLayer.isInsideEndpoint(c);
|
||||
coordinateFound = shearLayer.isInsideEndpoint(editor, x, y);
|
||||
|
||||
if (coordinateFound != null) {
|
||||
this.mode = Mode.MOVE_POINT;
|
||||
|
@ -114,7 +114,7 @@ public abstract class ShearAction extends AbstractGenericToolAction<ShearLayer>
|
|||
return true;
|
||||
}
|
||||
|
||||
if ((lineToMove = shearLayer.isInsideLine(c)) != -1) {
|
||||
if ((lineToMove = shearLayer.isInsideLine(editor, x, y)) != -1) {
|
||||
this.mode = Mode.MOVE_LINE;
|
||||
return true;
|
||||
}
|
||||
|
@ -201,15 +201,14 @@ public abstract class ShearAction extends AbstractGenericToolAction<ShearLayer>
|
|||
*/
|
||||
public boolean handleMouseMove(int x, int y) {
|
||||
if (shearLayer.isEditable()) {
|
||||
Coordinate c = editor.translateClick(x, y);
|
||||
|
||||
if (shearLayer.isInsideEndpoint(c) != null) {
|
||||
if (shearLayer.isInsideEndpoint(editor, x, y) != null) {
|
||||
// Change the cursor to a hand.
|
||||
this.setCursorHand();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (shearLayer.isInsideLine(c) != -1) {
|
||||
if (shearLayer.isInsideLine(editor, x, y) != -1) {
|
||||
// Change the cursor to crosshairs.
|
||||
this.setCursorCross();
|
||||
return true;
|
||||
|
|
|
@ -33,7 +33,7 @@ import com.raytheon.uf.viz.core.IDisplayPaneContainer;
|
|||
import com.raytheon.uf.viz.core.drawables.IDescriptor;
|
||||
import com.raytheon.uf.viz.core.drawables.IRenderableDisplay;
|
||||
import com.raytheon.viz.awipstools.ToolsDataManager;
|
||||
import com.raytheon.viz.awipstools.common.ToolsUiUitil;
|
||||
import com.raytheon.viz.awipstools.common.ToolsUiUtil;
|
||||
import com.raytheon.viz.awipstools.ui.layer.InteractiveBaselinesLayer.Baseline;
|
||||
import com.raytheon.viz.ui.cmenu.IContextMenuContributor;
|
||||
import com.raytheon.viz.ui.cmenu.IContextMenuProvider;
|
||||
|
@ -53,6 +53,7 @@ import com.vividsolutions.jts.geom.LineString;
|
|||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Aug 29, 2013 2281 bsteffen Rename ToolsUiUitil.
|
||||
*
|
||||
*
|
||||
* </pre>
|
||||
|
@ -160,7 +161,7 @@ public class InteractiveBaselineUIManager extends InputAdapter implements
|
|||
Baseline[] lines = baselinesLayer.getCurrentBaselines();
|
||||
int mouse = SWT.CURSOR_ARROW;
|
||||
for (Baseline line : lines) {
|
||||
int idx = ToolsUiUitil.closeToCoordinate(container,
|
||||
int idx = ToolsUiUtil.closeToCoordinate(container,
|
||||
line.line.getCoordinates(), x, y, CLICK_RADIUS_PIX);
|
||||
if (idx >= 0) {
|
||||
// We are close to a point in this line
|
||||
|
@ -170,7 +171,7 @@ public class InteractiveBaselineUIManager extends InputAdapter implements
|
|||
hoverCoords = new Coordinate[] { hoverLine.line
|
||||
.getCoordinateN(idx) };
|
||||
break;
|
||||
} else if (ToolsUiUitil.closeToLine(container,
|
||||
} else if (ToolsUiUtil.closeToLine(container,
|
||||
line.line.getCoordinates(), x, y, CLICK_RADIUS_PIX)) {
|
||||
// We are close this this line
|
||||
mouse = SWT.CURSOR_SIZEALL;
|
||||
|
@ -434,7 +435,7 @@ public class InteractiveBaselineUIManager extends InputAdapter implements
|
|||
double[] screenLoc = container.translateInverseClick(c);
|
||||
screenLoc[0] += changeX;
|
||||
screenLoc[1] += changeY;
|
||||
Coordinate translated = ToolsUiUitil.translateClick(container,
|
||||
Coordinate translated = ToolsUiUtil.translateClick(container,
|
||||
baselinesLayer.getDescriptor(), screenLoc[0], screenLoc[1]);
|
||||
c.x = translated.x;
|
||||
c.y = translated.y;
|
||||
|
@ -486,7 +487,7 @@ public class InteractiveBaselineUIManager extends InputAdapter implements
|
|||
// First time we've moved our new line, change to two points
|
||||
firstSelection = false;
|
||||
coords = new Coordinate[] { coords[0],
|
||||
ToolsUiUitil.translateClick(container, descriptor, x, y) };
|
||||
ToolsUiUtil.translateClick(container, descriptor, x, y) };
|
||||
} else {
|
||||
double[] d1 = container
|
||||
.translateInverseClick(coords[coords.length - 1]);
|
||||
|
@ -497,7 +498,7 @@ public class InteractiveBaselineUIManager extends InputAdapter implements
|
|||
Coordinate c = new Coordinate(x, y);
|
||||
if (Angle.angleBetween(c2, c1, c) > (Math.PI / 2)) {
|
||||
coords = Arrays.copyOf(coords, coords.length + 1);
|
||||
coords[coords.length - 1] = ToolsUiUitil.translateClick(
|
||||
coords[coords.length - 1] = ToolsUiUtil.translateClick(
|
||||
container, descriptor, c.x, c.y);
|
||||
} else {
|
||||
selectionQueue.add(currentlySelecting);
|
||||
|
@ -550,13 +551,13 @@ public class InteractiveBaselineUIManager extends InputAdapter implements
|
|||
Coordinate[] newLine = new Coordinate[hoverCoords.length + 1];
|
||||
for (int i = 0; i < newLine.length; i++) {
|
||||
if (i < insertionPoint) {
|
||||
newLine[i] = ToolsUiUitil.translateClick(container, descriptor,
|
||||
newLine[i] = ToolsUiUtil.translateClick(container, descriptor,
|
||||
screenLocs[i].x, screenLocs[i].y);
|
||||
} else if (i > insertionPoint) {
|
||||
newLine[i] = ToolsUiUitil.translateClick(container, descriptor,
|
||||
newLine[i] = ToolsUiUtil.translateClick(container, descriptor,
|
||||
screenLocs[i - 1].x, screenLocs[i - 1].y);
|
||||
} else {
|
||||
newLine[i] = ToolsUiUitil.translateClick(container, descriptor,
|
||||
newLine[i] = ToolsUiUtil.translateClick(container, descriptor,
|
||||
screenRefPoint.x, screenRefPoint.y);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,24 +49,23 @@ import com.raytheon.uf.viz.core.rsc.capabilities.EditableCapability;
|
|||
import com.raytheon.uf.viz.core.rsc.capabilities.MagnificationCapability;
|
||||
import com.raytheon.uf.viz.core.rsc.tools.GenericToolsResourceData;
|
||||
import com.raytheon.uf.viz.points.PointsDataManager;
|
||||
import com.raytheon.viz.awipstools.common.ToolsUiUtil;
|
||||
import com.raytheon.viz.ui.input.EditableManager;
|
||||
import com.vividsolutions.jts.geom.Coordinate;
|
||||
import com.vividsolutions.jts.geom.Geometry;
|
||||
import com.vividsolutions.jts.geom.GeometryFactory;
|
||||
import com.vividsolutions.jts.geom.LineString;
|
||||
import com.vividsolutions.jts.geom.LinearRing;
|
||||
import com.vividsolutions.jts.operation.buffer.BufferOp;
|
||||
|
||||
/**
|
||||
* TODO Add Description
|
||||
* Interactive resource for rendering the Shear data.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 15Mar2013 15693 mgamazaychikov Added magnification capability.
|
||||
* 05/02/2013 DR 14587 D. Friedman Use base velocity.
|
||||
* Mar 15, 2013 15693 mgamazaychikov Added magnification capability.
|
||||
* May 02, 2013 14587 D. Friedman Use base velocity.
|
||||
* Aug 29, 2013 2281 bsteffen Fix click distance calculations.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -218,24 +217,6 @@ public class ShearLayer extends
|
|||
}
|
||||
}
|
||||
|
||||
public LinearRing getCircle(Coordinate coor, double radius) {
|
||||
|
||||
Coordinate circleCoordinates[] = new Coordinate[361];
|
||||
Coordinate firstCoor = null;
|
||||
|
||||
for (int i = 0; i < 360; i++) {
|
||||
circleCoordinates[i] = getCoordinateOnCircle(coor, radius, i);
|
||||
if (i == 0) {
|
||||
// save the first coordinate, to add to end, so completes the
|
||||
// ring.
|
||||
firstCoor = circleCoordinates[0];
|
||||
}
|
||||
}
|
||||
circleCoordinates[360] = firstCoor;
|
||||
|
||||
return gf.createLinearRing(circleCoordinates);
|
||||
}
|
||||
|
||||
public Coordinate getCoordinateOnCircle(Coordinate coor, double radius,
|
||||
int angle) {
|
||||
|
||||
|
@ -298,18 +279,6 @@ public class ShearLayer extends
|
|||
return getCapability(EditableCapability.class).isEditable();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks and returns the coordinate of the endpoint that clicked in.
|
||||
*
|
||||
* @param c
|
||||
* Coordinate of the click.
|
||||
* @return Coordinate of the endpoint, null if not found.
|
||||
*/
|
||||
public Coordinate isInsideEndpoint(Coordinate c) {
|
||||
|
||||
return getEndpointClickedIn(c);
|
||||
}
|
||||
|
||||
public void moveBaseline(Coordinate delta, int index) {
|
||||
|
||||
for (Coordinate point : baseline.getCoordinates()) {
|
||||
|
@ -340,54 +309,46 @@ public class ShearLayer extends
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the endpoint the user clicked in, or null if they didn't click in
|
||||
* an endpoint.
|
||||
* Get the closest endpoint to the provided screen location.
|
||||
*
|
||||
* @param coor
|
||||
* Coordinate of the click point.
|
||||
* @return The coordinate of the endpoint they hit on.
|
||||
* @param container
|
||||
* display container to use
|
||||
* @param refX
|
||||
* x location in screen pixels
|
||||
* @param refY
|
||||
* y location in screen pixels
|
||||
* @return T Coordinate of the endpoint, null if not found.
|
||||
*/
|
||||
public Coordinate getEndpointClickedIn(Coordinate coor) {
|
||||
|
||||
Coordinate c1 = getBaseline().getCoordinates()[0];
|
||||
Coordinate c2 = getBaseline().getCoordinates()[1];
|
||||
|
||||
if (gf.createPolygon(getCircle(c1, this.endCircleRadius), null)
|
||||
.contains(gf.createPoint(coor))) {
|
||||
return c1;
|
||||
} else if (gf.createPolygon(getCircle(c2, this.endCircleRadius), null)
|
||||
.contains(gf.createPoint(coor))) {
|
||||
return c2;
|
||||
public Coordinate isInsideEndpoint(IDisplayPaneContainer container, int x,
|
||||
int y) {
|
||||
Coordinate[] coords = getBaseline().getCoordinates();
|
||||
int idx = ToolsUiUtil.closeToCoordinate(container, coords, x, y, 9);
|
||||
if (idx < 0) {
|
||||
return null;
|
||||
} else {
|
||||
return coords[idx];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the index of the linestring the user clicked in (for move for
|
||||
* instance).
|
||||
*
|
||||
* @param coor
|
||||
* @param container
|
||||
* display container to use
|
||||
* @param refX
|
||||
* x location of reference point in screen pixels
|
||||
* @param refY
|
||||
* y location of reference point in screen pixels
|
||||
* @return int Index of line they matched on.
|
||||
*/
|
||||
public int isInsideLine(Coordinate coor) {
|
||||
|
||||
int index = -1;
|
||||
for (int i = 0; i < getBuffer().length; i++) {
|
||||
if (getBuffer()[i].contains(gf.createPoint(coor))) {
|
||||
index = i;
|
||||
}
|
||||
public int isInsideLine(IDisplayPaneContainer container, int x, int y) {
|
||||
Coordinate[] coords = getBaseline().getCoordinates();
|
||||
if (ToolsUiUtil.closeToLine(container, coords, x, y, 15)) {
|
||||
return 0;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
public Geometry[] getBuffer() {
|
||||
|
||||
Geometry[] buffer = new Geometry[1];
|
||||
|
||||
buffer[0] = BufferOp.bufferOp(getBaseline(), 0.001);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue