Issue #590 Fixed gfe edit area selection issue

Change-Id: I67029301f515583a7ca3eea408513d9310e3fd35

Former-commit-id: 6588f58c80782f793c3621a2fd7ec81be2d1ead2
This commit is contained in:
Max Schenkelberg 2012-06-06 12:05:47 -05:00
parent 8b87b6a0a1
commit fbd269f4c7
3 changed files with 59 additions and 44 deletions

View file

@ -133,6 +133,12 @@ public class DrawingToolLayer implements IRenderable {
*/
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
* next time {@link #processErase(IExtent, Rectangle)} is called
@ -177,19 +183,23 @@ public class DrawingToolLayer implements IRenderable {
processErase(paintProps.getView().getExtent(),
paintProps.getCanvasBounds());
if (wireframeShape == null && currentData.geometries.size() > 0) {
// No wireframe shape and we have data, create for drawing
wireframeShape = target.createWireframeShape(false,
targetGeometry);
int totalPoints = 0;
for (Geometry geom : currentData.geometries) {
totalPoints += geom.getNumPoints();
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
wireframeShape = target.createWireframeShape(false,
targetGeometry);
int totalPoints = 0;
for (Geometry geom : geoms) {
totalPoints += geom.getNumPoints();
}
wireframeShape.allocate(totalPoints * 3 * 8);
for (Geometry geom : geoms) {
handle(wireframeShape, geom);
}
wireframeShape.compile();
}
wireframeShape.allocate(totalPoints * 3 * 8);
for (Geometry geom : currentData.geometries) {
handle(wireframeShape, geom);
}
wireframeShape.compile();
}
if (wireframeShape != null) {
// We have data to draw, draw it
@ -221,6 +231,11 @@ public class DrawingToolLayer implements IRenderable {
synchronized (currentData) {
if (currentErasingLine != null
&& currentErasingLine.getNumPoints() > 0) {
if (currentErasingGeometries == null) {
currentErasingGeometries = new ArrayList<Geometry>(
currentData.geometries);
}
// Calculate world grid to canvas grid ratio
double ratio = extent.getWidth() / canvasSize.width;
// Get the size to buffer the eraser line for differencing
@ -232,16 +247,15 @@ public class DrawingToolLayer implements IRenderable {
flattenGeometry(currentErasingLine, eraserLines);
boolean change = false;
List<Geometry> currentGeoms = new ArrayList<Geometry>(
currentData.geometries);
List<Geometry> newGeoms = new ArrayList<Geometry>(
currentGeoms.size());
currentErasingGeometries.size());
// For each eraser line, run against currentData
for (Geometry eraserLine : eraserLines) {
eraserLine = eraserLine.buffer(bufferSize);
newGeoms = new ArrayList<Geometry>(currentGeoms.size());
for (Geometry geom : currentGeoms) {
newGeoms = new ArrayList<Geometry>(
currentErasingGeometries.size());
for (Geometry geom : currentErasingGeometries) {
if (geom.intersects(eraserLine)) {
// Eraser line intersects, create difference
Geometry diff = geom.difference(eraserLine);
@ -262,27 +276,26 @@ public class DrawingToolLayer implements IRenderable {
}
}
// These are the new "currentGeoms" for the next eraser line
currentGeoms = newGeoms;
currentErasingGeometries = newGeoms;
}
if (change) {
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
// wireframeShape for us
wireframeShape.dispose();
wireframeShape = null;
}
if (change && wireframeShape != null) {
// In else if since addCurrentDataToStack will destroy
// wireframeShape for us
wireframeShape.dispose();
wireframeShape = null;
}
// Current data is now what is in newGeoms
currentData.geometries = newGeoms;
currentErasingLine = null;
}
if (addErasingEventToStack) {
// If data changed and we should add a new frame, do it
addErasingEventToStack = false;
addCurrentDataToStack(undoStack);
redoStack.clear();
currentData.geometries = currentErasingGeometries;
currentErasingGeometries = null;
}
}
}

View file

@ -20,7 +20,6 @@
package com.raytheon.uf.viz.remote.graphics.events.points;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
@ -80,8 +79,9 @@ public class DrawPointsEvent extends AbstractRemoteGraphicsRenderEvent {
public IRenderEvent createDiffObject(IRenderEvent diffEvent) {
DrawPointsEvent event = (DrawPointsEvent) diffEvent;
DrawPointsEvent diffObject = new DrawPointsEvent();
diffObject.color = color;
diffObject.color = event.color;
diffObject.magnification = event.magnification;
diffObject.style = event.style;
Set<Point> additions = new HashSet<Point>(event.points);
additions.removeAll(points);
@ -110,6 +110,7 @@ public class DrawPointsEvent extends AbstractRemoteGraphicsRenderEvent {
DrawPointsEvent event = (DrawPointsEvent) diffEvent;
color = event.color;
magnification = event.magnification;
style = event.style;
synchronized (points) {
if (event.removals != null) {

View file

@ -83,18 +83,10 @@ public class GFEReferenceSetResource extends
private byte[] fillPattern = FillPatterns.getGLPattern("SELECTED_AREA");
@SuppressWarnings("unchecked")
public GFEReferenceSetResource(IReferenceSetManager refSetMgr) {
super(new GFEResourceData(), new LoadProperties());
this.refSetMgr = refSetMgr;
this.refSetMgr.addReferenceSetChangedListener(this);
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.
* IGraphicsTarget)
*/
@SuppressWarnings("unchecked")
@Override
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();
outlineShape = target.createWireframeShape(false, this.descriptor);
@ -187,7 +188,7 @@ public class GFEReferenceSetResource extends
public void paintInternal(IGraphicsTarget aTarget,
PaintProperties paintProps) throws VizException {
if (this.needsUpdate) {
initInternal(aTarget);
initRefSetData(aTarget);
}
float alpha = paintProps.getAlpha();