Merge "Issue #628 added PgenResourceGhost to track the gl ghost draw objects." into development

Former-commit-id: 4a389da950 [formerly cfc56f670a] [formerly ab86141e2f [formerly 00dfc8449b6d12b0a3ed52c3f60cc016eaa13af3]]
Former-commit-id: ab86141e2f
Former-commit-id: 5ada671511
This commit is contained in:
Nate Jensen 2012-06-26 13:21:49 -05:00 committed by Gerrit Code Review
commit f90897dc5d
12 changed files with 189 additions and 48 deletions

View file

@ -1930,7 +1930,7 @@ public class GLTarget implements IGLTarget {
@Override
public BufferedImage screenshot() {
makeContextCurrent();
boolean needsRelease = makeContextCurrent();
if (theCanvas != null) {
theCanvas.swapBuffers();
}
@ -1941,7 +1941,9 @@ public class GLTarget implements IGLTarget {
theCanvas.swapBuffers();
}
if (needsRelease) {
releaseContext();
}
return bi;
}

View file

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry exported="true" kind="lib" path="jaxen-1.1-beta-7.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry exported="true" kind="lib" path="dom4j-1.6.1.jar" sourcepath="org.dom4jsrc.zip"/>

View file

@ -4,6 +4,7 @@ Bundle-Name: Dom4j Plug-in
Bundle-SymbolicName: org.dom4j
Bundle-Version: 1.0.0.qualifier
Bundle-ClassPath: dom4j-1.6.1.jar,
jaxen-1.1-beta-7.jar,
.
Export-Package: org.dom4j,
org.dom4j.bean,

View file

@ -1,3 +1,4 @@
bin.includes = META-INF/,\
.,\
dom4j-1.6.1.jar
dom4j-1.6.1.jar,\
jaxen-1.1-beta-7.jar

Binary file not shown.

View file

@ -509,8 +509,8 @@
name="NMAP Views"/>
<view
category="gov.noaa.nws.ncep.viz.ui.nmap"
allowMultiple="false"
restorable="true"
allowMultiple="true"
restorable="false"
class="gov.noaa.nws.ncep.ui.pgen.palette.PgenPaletteWindow"
id="gov.noaa.nws.ncep.ui.PGEN"
name="PGEN"/>

View file

@ -88,6 +88,17 @@ public abstract class AbstractElementContainer {
public abstract void draw(IGraphicsTarget target, PaintProperties paintProps,
DisplayProperties dprops);
/**
* Draws to the given graphics target. Recreates the IDisplayable objects, if
* necessary.
* @param target
* @param paintProps
* @param dprops PGEN Layer properties
* @param needsCreate
*/
public abstract void draw(IGraphicsTarget target, PaintProperties paintProps,
DisplayProperties dprops, boolean needsCreate);
/**
* Uses a DisplayElementFactory to create IDisplayable objects from the Drawable Element
* @param paintProps
@ -95,7 +106,7 @@ public abstract class AbstractElementContainer {
protected void createDisplayables(PaintProperties paintProps) {
//Cleanup first
if ( (displayEls!=null) && !displayEls.isEmpty() ) dispose();
if ( (displayEls!=null) && !displayEls.isEmpty() ) reset();
if ( element instanceof IAvnText ) {
displayEls = def.createDisplayElements( (IAvnText) element, paintProps );
}
@ -145,6 +156,10 @@ public abstract class AbstractElementContainer {
}
}
private void reset() {
def.reset();
}
/**
* Releases the resources held by any of the IDisplayables
*/
@ -158,5 +173,9 @@ public abstract class AbstractElementContainer {
displayEls.clear();
}
public void setElement(DrawableElement el) {
this.element = el;
}
}

View file

@ -44,8 +44,17 @@ public class DefaultElementContainer extends AbstractElementContainer {
@Override
public void draw(IGraphicsTarget target, PaintProperties paintProps,
DisplayProperties dprops) {
draw(target, paintProps, dprops, false);
}
boolean needsCreate = false;
/*
* Draws to the given graphics target. Recreates the IDisplayable objects if zooming or
* if the Layer properties change.
* @see gov.noaa.nws.ncep.ui.pgen.display.AbstractTBNL#draw(com.raytheon.uf.viz.core.IGraphicsTarget, com.raytheon.uf.viz.core.drawables.PaintProperties, boolean)
*/
@Override
public void draw(IGraphicsTarget target, PaintProperties paintProps,
DisplayProperties dprops, boolean needsCreate) {
if ( (displayEls == null) || paintProps.isZooming() ) needsCreate = true;

View file

@ -4632,4 +4632,20 @@ public class DisplayElementFactory {
return new Line(null, new Color[]{color},1.5f,.5,false,
false, pts, 0, null,"Lines","LINE_SOLID");
}
public void reset() {
if (ss != null) {
ss.reset();
}
if (sym != null) {
sym.reset();
}
if (wfs != null) {
for (IWireframeShape shape : wfs) {
if (shape != null) {
shape.reset();
}
}
}
}
}

View file

@ -43,8 +43,17 @@ public class RasterElementContainer extends AbstractElementContainer {
@Override
public void draw(IGraphicsTarget target, PaintProperties paintProps,
DisplayProperties dprops) {
draw(target, paintProps, dprops, false);
}
boolean needsCreate = false;
/*
* Draws to the given graphics target. Recreates the IDisplayable objects
* if the Layer properties change.
* @see gov.noaa.nws.ncep.ui.pgen.display.AbstractTBNL#draw(com.raytheon.uf.viz.core.IGraphicsTarget, com.raytheon.uf.viz.core.drawables.PaintProperties, boolean)
*/
@Override
public void draw(IGraphicsTarget target, PaintProperties paintProps,
DisplayProperties dprops, boolean needsCreate) {
if ( displayEls == null ) needsCreate = true;

View file

@ -142,7 +142,8 @@ public class PgenResource extends AbstractVizResource<PgenResourceData,MapDescri
/**
* Ghost line for multi-point element.
*/
private AbstractDrawableComponent ghost = null;
// private AbstractDrawableComponent ghost = null;
PgenResourceGhost ghost = null;
/*
* List of elements that should be displayed in "selected" mode
@ -311,7 +312,7 @@ public class PgenResource extends AbstractVizResource<PgenResourceData,MapDescri
drawProduct( target, paintProps );
if ( elSelected != null ) drawSelected( target, paintProps);
if ( ghost != null ) drawGhost( target, paintProps, df);
if ( ghost != null ) ghost.draw(target, paintProps, df, descriptor);
// Save current graphics target for possible future reminder
if ( saveOnNextPaint ) {
@ -450,7 +451,11 @@ public class PgenResource extends AbstractVizResource<PgenResourceData,MapDescri
*/
public void setGhostLine(AbstractDrawableComponent ghost) {
this.ghost = ghost;
if (this.ghost == null) {
this.ghost = new PgenResourceGhost();
}
// this.ghost = ghost;
this.ghost.setGhostLine(ghost);
}
@ -463,25 +468,6 @@ public class PgenResource extends AbstractVizResource<PgenResourceData,MapDescri
}
/**
* Creates displayables for an element using an ElementContainer and call the
* displayables' draw() method to draw the element.
* @param target Graphic target
* @param paintProps Paint properties
* @param df Display element factory
* @param el Input drawable element
*/
private void drawElement( IGraphicsTarget target, PaintProperties paintProps,
DisplayElementFactory df, DrawableElement el ){
AbstractElementContainer dispEl = null;
dispEl = new DefaultElementContainer(el, descriptor, target);
dispEl.draw(target, paintProps, null);
dispEl.dispose();
}
/**
* Finds the nearest element in the products to the input point.
* @param point
@ -712,23 +698,6 @@ public class PgenResource extends AbstractVizResource<PgenResourceData,MapDescri
}
*/
/**
* Draw the ghost
* @param target
* @param paintProps
* @param df
*/
private void drawGhost( IGraphicsTarget target, PaintProperties paintProps,
DisplayElementFactory df ){
df.setLayerDisplayAttr( false, null, false );
Iterator<DrawableElement> iterator = ghost.createDEIterator();
while ( iterator.hasNext()){
drawElement( target, paintProps, df, iterator.next() );
}
}
/**
* Sets the selected element to the input element.
* @param element

View file

@ -0,0 +1,114 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package gov.noaa.nws.ncep.ui.pgen.rsc;
import gov.noaa.nws.ncep.ui.pgen.display.AbstractElementContainer;
import gov.noaa.nws.ncep.ui.pgen.display.DefaultElementContainer;
import gov.noaa.nws.ncep.ui.pgen.display.DisplayElementFactory;
import gov.noaa.nws.ncep.ui.pgen.elements.AbstractDrawableComponent;
import gov.noaa.nws.ncep.ui.pgen.elements.DECollection;
import gov.noaa.nws.ncep.ui.pgen.elements.DrawableElement;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import com.raytheon.uf.viz.core.IGraphicsTarget;
import com.raytheon.uf.viz.core.drawables.PaintProperties;
import com.raytheon.uf.viz.core.map.IMapDescriptor;
/**
* Ghost drawing for the pgen resource.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jun 15, 2012 bgonzale Initial creation
*
* </pre>
*
* @author bgonzale
* @version 1.0
*/
public class PgenResourceGhost {
public AbstractDrawableComponent component;
Map<Object, AbstractElementContainer> componentMap = new HashMap<Object, AbstractElementContainer>();
/**
* Draw the ghost
* @param target
* @param paintProps
* @param df
* @param descriptor
*/
public void draw( IGraphicsTarget target, PaintProperties paintProps,
DisplayElementFactory df, IMapDescriptor descriptor){
df.setLayerDisplayAttr( false, null, false );
if (component != null) {
Iterator<DrawableElement> iterator = component
.createDEIterator();
int count = 0;
while (iterator.hasNext()) {
DrawableElement element = iterator.next();
drawElement(target, paintProps, df, element, descriptor);
++count;
}
}
}
/**
* Creates displayables for an element using an ElementContainer and call the
* displayables' draw() method to draw the element.
* @param target Graphic target
* @param paintProps Paint properties
* @param df Display element factory
* @param el Input drawable element
* @praram descriptor
*/
private void drawElement( IGraphicsTarget target, PaintProperties paintProps,
DisplayElementFactory df, DrawableElement el, IMapDescriptor descriptor){
Object key = createKey(el);
AbstractElementContainer graphic = componentMap.get(key);
if (graphic == null) {
graphic = new DefaultElementContainer(el, descriptor, target);
componentMap.put(key, graphic);
} else {
graphic.setElement(el);
}
graphic.draw(target, paintProps, null, true);
}
private Object createKey(DrawableElement el) {
return el.getPgenCategory()+ ":"+el.getPgenType();
}
/**
* Sets the ghost line for the PGEN drawing layer.
* @param ghost
*/
public void setGhostLine(AbstractDrawableComponent ghost) {
this.component = ghost;
}
}