From 66f39cc77b18022232606070280330c107cbb5fe Mon Sep 17 00:00:00 2001 From: Max Schenkelberg Date: Wed, 6 Jun 2012 12:05:47 -0500 Subject: [PATCH] Issue #590 Fixed gfe edit area selection issue Change-Id: I67029301f515583a7ca3eea408513d9310e3fd35 Former-commit-id: 2750c4ba08b5c6917741ff070b1e79e7877cf6ad [formerly b8bedd1247da50ad8dd01a71b8058847d808c598] [formerly fbd269f4c7340413782bef36d1d354d291324d8e [formerly 6588f58c80782f793c3621a2fd7ec81be2d1ead2]] Former-commit-id: fbd269f4c7340413782bef36d1d354d291324d8e Former-commit-id: 13bd18829f4c50a6b2eb57570200838cd11d45e7 --- .../uf/viz/drawing/DrawingToolLayer.java | 79 +++++++++++-------- .../events/points/DrawPointsEvent.java | 5 +- .../viz/gfe/rsc/GFEReferenceSetResource.java | 19 ++--- 3 files changed, 59 insertions(+), 44 deletions(-) diff --git a/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/DrawingToolLayer.java b/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/DrawingToolLayer.java index 1fa1c56da7..110c94ccd0 100644 --- a/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/DrawingToolLayer.java +++ b/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/DrawingToolLayer.java @@ -133,6 +133,12 @@ public class DrawingToolLayer implements IRenderable { */ private Geometry currentErasingLine; + /** + * The collection of geometries the {@link #currentErasingLine} is operating + * on + */ + private Collection 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 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( + 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 currentGeoms = new ArrayList( - currentData.geometries); List newGeoms = new ArrayList( - currentGeoms.size()); + currentErasingGeometries.size()); // For each eraser line, run against currentData for (Geometry eraserLine : eraserLines) { eraserLine = eraserLine.buffer(bufferSize); - newGeoms = new ArrayList(currentGeoms.size()); - for (Geometry geom : currentGeoms) { + newGeoms = new ArrayList( + 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; + } } } diff --git a/cave/com.raytheon.uf.viz.remote.graphics/src/com/raytheon/uf/viz/remote/graphics/events/points/DrawPointsEvent.java b/cave/com.raytheon.uf.viz.remote.graphics/src/com/raytheon/uf/viz/remote/graphics/events/points/DrawPointsEvent.java index 923b43ef4c..fce6e799c7 100644 --- a/cave/com.raytheon.uf.viz.remote.graphics/src/com/raytheon/uf/viz/remote/graphics/events/points/DrawPointsEvent.java +++ b/cave/com.raytheon.uf.viz.remote.graphics/src/com/raytheon/uf/viz/remote/graphics/events/points/DrawPointsEvent.java @@ -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 additions = new HashSet(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) { diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/rsc/GFEReferenceSetResource.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/rsc/GFEReferenceSetResource.java index e7a5dad1da..99098993fe 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/rsc/GFEReferenceSetResource.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/rsc/GFEReferenceSetResource.java @@ -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();