Issue #590 Fixed gfe edit area selection issue
Change-Id: I67029301f515583a7ca3eea408513d9310e3fd35 Former-commit-id:2750c4ba08
[formerlyb8bedd1247
] [formerlyfbd269f4c7
[formerly 6588f58c80782f793c3621a2fd7ec81be2d1ead2]] Former-commit-id:fbd269f4c7
Former-commit-id:13bd18829f
This commit is contained in:
parent
af72c6411a
commit
66f39cc77b
3 changed files with 59 additions and 44 deletions
|
@ -133,6 +133,12 @@ public class DrawingToolLayer implements IRenderable {
|
||||||
*/
|
*/
|
||||||
private Geometry currentErasingLine;
|
private Geometry currentErasingLine;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The collection of geometries the {@link #currentErasingLine} is operating
|
||||||
|
* on
|
||||||
|
*/
|
||||||
|
private Collection<Geometry> currentErasingGeometries;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flag that erasing is finished and a new stack frame should be created
|
* Flag that erasing is finished and a new stack frame should be created
|
||||||
* next time {@link #processErase(IExtent, Rectangle)} is called
|
* next time {@link #processErase(IExtent, Rectangle)} is called
|
||||||
|
@ -177,20 +183,24 @@ public class DrawingToolLayer implements IRenderable {
|
||||||
processErase(paintProps.getView().getExtent(),
|
processErase(paintProps.getView().getExtent(),
|
||||||
paintProps.getCanvasBounds());
|
paintProps.getCanvasBounds());
|
||||||
|
|
||||||
if (wireframeShape == null && currentData.geometries.size() > 0) {
|
if (wireframeShape == null) {
|
||||||
|
Collection<Geometry> geoms = currentErasingGeometries != null ? currentErasingGeometries
|
||||||
|
: currentData.geometries;
|
||||||
|
if (geoms.size() > 0) {
|
||||||
// No wireframe shape and we have data, create for drawing
|
// No wireframe shape and we have data, create for drawing
|
||||||
wireframeShape = target.createWireframeShape(false,
|
wireframeShape = target.createWireframeShape(false,
|
||||||
targetGeometry);
|
targetGeometry);
|
||||||
int totalPoints = 0;
|
int totalPoints = 0;
|
||||||
for (Geometry geom : currentData.geometries) {
|
for (Geometry geom : geoms) {
|
||||||
totalPoints += geom.getNumPoints();
|
totalPoints += geom.getNumPoints();
|
||||||
}
|
}
|
||||||
wireframeShape.allocate(totalPoints * 3 * 8);
|
wireframeShape.allocate(totalPoints * 3 * 8);
|
||||||
for (Geometry geom : currentData.geometries) {
|
for (Geometry geom : geoms) {
|
||||||
handle(wireframeShape, geom);
|
handle(wireframeShape, geom);
|
||||||
}
|
}
|
||||||
wireframeShape.compile();
|
wireframeShape.compile();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (wireframeShape != null) {
|
if (wireframeShape != null) {
|
||||||
// We have data to draw, draw it
|
// We have data to draw, draw it
|
||||||
target.drawWireframeShape(wireframeShape, color, lineWidth,
|
target.drawWireframeShape(wireframeShape, color, lineWidth,
|
||||||
|
@ -221,6 +231,11 @@ public class DrawingToolLayer implements IRenderable {
|
||||||
synchronized (currentData) {
|
synchronized (currentData) {
|
||||||
if (currentErasingLine != null
|
if (currentErasingLine != null
|
||||||
&& currentErasingLine.getNumPoints() > 0) {
|
&& currentErasingLine.getNumPoints() > 0) {
|
||||||
|
if (currentErasingGeometries == null) {
|
||||||
|
currentErasingGeometries = new ArrayList<Geometry>(
|
||||||
|
currentData.geometries);
|
||||||
|
}
|
||||||
|
|
||||||
// Calculate world grid to canvas grid ratio
|
// Calculate world grid to canvas grid ratio
|
||||||
double ratio = extent.getWidth() / canvasSize.width;
|
double ratio = extent.getWidth() / canvasSize.width;
|
||||||
// Get the size to buffer the eraser line for differencing
|
// Get the size to buffer the eraser line for differencing
|
||||||
|
@ -232,16 +247,15 @@ public class DrawingToolLayer implements IRenderable {
|
||||||
flattenGeometry(currentErasingLine, eraserLines);
|
flattenGeometry(currentErasingLine, eraserLines);
|
||||||
|
|
||||||
boolean change = false;
|
boolean change = false;
|
||||||
List<Geometry> currentGeoms = new ArrayList<Geometry>(
|
|
||||||
currentData.geometries);
|
|
||||||
List<Geometry> newGeoms = new ArrayList<Geometry>(
|
List<Geometry> newGeoms = new ArrayList<Geometry>(
|
||||||
currentGeoms.size());
|
currentErasingGeometries.size());
|
||||||
|
|
||||||
// For each eraser line, run against currentData
|
// For each eraser line, run against currentData
|
||||||
for (Geometry eraserLine : eraserLines) {
|
for (Geometry eraserLine : eraserLines) {
|
||||||
eraserLine = eraserLine.buffer(bufferSize);
|
eraserLine = eraserLine.buffer(bufferSize);
|
||||||
newGeoms = new ArrayList<Geometry>(currentGeoms.size());
|
newGeoms = new ArrayList<Geometry>(
|
||||||
for (Geometry geom : currentGeoms) {
|
currentErasingGeometries.size());
|
||||||
|
for (Geometry geom : currentErasingGeometries) {
|
||||||
if (geom.intersects(eraserLine)) {
|
if (geom.intersects(eraserLine)) {
|
||||||
// Eraser line intersects, create difference
|
// Eraser line intersects, create difference
|
||||||
Geometry diff = geom.difference(eraserLine);
|
Geometry diff = geom.difference(eraserLine);
|
||||||
|
@ -262,26 +276,25 @@ public class DrawingToolLayer implements IRenderable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// These are the new "currentGeoms" for the next eraser line
|
// These are the new "currentGeoms" for the next eraser line
|
||||||
currentGeoms = newGeoms;
|
currentErasingGeometries = newGeoms;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (change) {
|
if (change && wireframeShape != null) {
|
||||||
if (addErasingEventToStack) {
|
|
||||||
// If data changed and we should add a new frame, do it
|
|
||||||
addErasingEventToStack = false;
|
|
||||||
addCurrentDataToStack(undoStack);
|
|
||||||
redoStack.clear();
|
|
||||||
} else if (wireframeShape != null) {
|
|
||||||
// In else if since addCurrentDataToStack will destroy
|
// In else if since addCurrentDataToStack will destroy
|
||||||
// wireframeShape for us
|
// wireframeShape for us
|
||||||
wireframeShape.dispose();
|
wireframeShape.dispose();
|
||||||
wireframeShape = null;
|
wireframeShape = null;
|
||||||
}
|
}
|
||||||
|
currentErasingLine = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Current data is now what is in newGeoms
|
if (addErasingEventToStack) {
|
||||||
currentData.geometries = newGeoms;
|
// If data changed and we should add a new frame, do it
|
||||||
currentErasingLine = null;
|
addErasingEventToStack = false;
|
||||||
|
addCurrentDataToStack(undoStack);
|
||||||
|
redoStack.clear();
|
||||||
|
currentData.geometries = currentErasingGeometries;
|
||||||
|
currentErasingGeometries = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
package com.raytheon.uf.viz.remote.graphics.events.points;
|
package com.raytheon.uf.viz.remote.graphics.events.points;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -80,8 +79,9 @@ public class DrawPointsEvent extends AbstractRemoteGraphicsRenderEvent {
|
||||||
public IRenderEvent createDiffObject(IRenderEvent diffEvent) {
|
public IRenderEvent createDiffObject(IRenderEvent diffEvent) {
|
||||||
DrawPointsEvent event = (DrawPointsEvent) diffEvent;
|
DrawPointsEvent event = (DrawPointsEvent) diffEvent;
|
||||||
DrawPointsEvent diffObject = new DrawPointsEvent();
|
DrawPointsEvent diffObject = new DrawPointsEvent();
|
||||||
diffObject.color = color;
|
diffObject.color = event.color;
|
||||||
diffObject.magnification = event.magnification;
|
diffObject.magnification = event.magnification;
|
||||||
|
diffObject.style = event.style;
|
||||||
|
|
||||||
Set<Point> additions = new HashSet<Point>(event.points);
|
Set<Point> additions = new HashSet<Point>(event.points);
|
||||||
additions.removeAll(points);
|
additions.removeAll(points);
|
||||||
|
@ -110,6 +110,7 @@ public class DrawPointsEvent extends AbstractRemoteGraphicsRenderEvent {
|
||||||
DrawPointsEvent event = (DrawPointsEvent) diffEvent;
|
DrawPointsEvent event = (DrawPointsEvent) diffEvent;
|
||||||
color = event.color;
|
color = event.color;
|
||||||
magnification = event.magnification;
|
magnification = event.magnification;
|
||||||
|
style = event.style;
|
||||||
|
|
||||||
synchronized (points) {
|
synchronized (points) {
|
||||||
if (event.removals != null) {
|
if (event.removals != null) {
|
||||||
|
|
|
@ -83,18 +83,10 @@ public class GFEReferenceSetResource extends
|
||||||
|
|
||||||
private byte[] fillPattern = FillPatterns.getGLPattern("SELECTED_AREA");
|
private byte[] fillPattern = FillPatterns.getGLPattern("SELECTED_AREA");
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public GFEReferenceSetResource(IReferenceSetManager refSetMgr) {
|
public GFEReferenceSetResource(IReferenceSetManager refSetMgr) {
|
||||||
super(new GFEResourceData(), new LoadProperties());
|
super(new GFEResourceData(), new LoadProperties());
|
||||||
this.refSetMgr = refSetMgr;
|
this.refSetMgr = refSetMgr;
|
||||||
|
|
||||||
this.refSetMgr.addReferenceSetChangedListener(this);
|
|
||||||
|
|
||||||
this.needsUpdate = true;
|
this.needsUpdate = true;
|
||||||
|
|
||||||
Message.registerInterest(this, RefSetAppearanceChangedMsg.class);
|
|
||||||
receiveMessage(Message
|
|
||||||
.inquireLastMessage(RefSetAppearanceChangedMsg.class));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -142,8 +134,17 @@ public class GFEReferenceSetResource extends
|
||||||
* @seecom.raytheon.viz.core.rsc.IVizResource#init(com.raytheon.viz.core.
|
* @seecom.raytheon.viz.core.rsc.IVizResource#init(com.raytheon.viz.core.
|
||||||
* IGraphicsTarget)
|
* IGraphicsTarget)
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public void initInternal(IGraphicsTarget target) {
|
public void initInternal(IGraphicsTarget target) {
|
||||||
|
this.refSetMgr.addReferenceSetChangedListener(this);
|
||||||
|
Message.registerInterest(this, RefSetAppearanceChangedMsg.class);
|
||||||
|
receiveMessage(Message
|
||||||
|
.inquireLastMessage(RefSetAppearanceChangedMsg.class));
|
||||||
|
initRefSetData(target);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initRefSetData(IGraphicsTarget target) {
|
||||||
disposeShapes();
|
disposeShapes();
|
||||||
|
|
||||||
outlineShape = target.createWireframeShape(false, this.descriptor);
|
outlineShape = target.createWireframeShape(false, this.descriptor);
|
||||||
|
@ -187,7 +188,7 @@ public class GFEReferenceSetResource extends
|
||||||
public void paintInternal(IGraphicsTarget aTarget,
|
public void paintInternal(IGraphicsTarget aTarget,
|
||||||
PaintProperties paintProps) throws VizException {
|
PaintProperties paintProps) throws VizException {
|
||||||
if (this.needsUpdate) {
|
if (this.needsUpdate) {
|
||||||
initInternal(aTarget);
|
initRefSetData(aTarget);
|
||||||
}
|
}
|
||||||
|
|
||||||
float alpha = paintProps.getAlpha();
|
float alpha = paintProps.getAlpha();
|
||||||
|
|
Loading…
Add table
Reference in a new issue