Issue #772 switch satellite from offscreen rendering to mosaic for a more well defined graphics API.

Change-Id: If293a65f577f13f6ba2ccae41b100dd9542d6998

Former-commit-id: 79ab850efa [formerly 009e769a180898cb62e9df4a604b40e139cf2886]
Former-commit-id: 74a69d1fb9
This commit is contained in:
Ben Steffensmeier 2012-07-10 15:43:54 -05:00
parent adcd49b090
commit 5bf019e1bb
21 changed files with 417 additions and 253 deletions

View file

@ -47,7 +47,6 @@ import com.raytheon.uf.viz.core.drawables.ImagingSupport;
import com.raytheon.uf.viz.core.drawables.PaintProperties;
import com.raytheon.uf.viz.core.drawables.ext.GraphicsExtension.IGraphicsExtensionInterface;
import com.raytheon.uf.viz.core.drawables.ext.GraphicsExtensionManager;
import com.raytheon.uf.viz.core.drawables.ext.IOffscreenRenderingExtension;
import com.raytheon.uf.viz.core.drawables.ext.colormap.IColormappedImageExtension;
import com.raytheon.uf.viz.core.exception.VizException;
@ -382,17 +381,6 @@ public abstract class AbstractGraphicsTarget implements IGraphicsTarget {
magnification);
}
@Override
public void renderOffscreen(IImage offscreenImage) throws VizException {
getExtension(IOffscreenRenderingExtension.class).renderOffscreen(
offscreenImage);
}
@Override
public void renderOnscreen() throws VizException {
getExtension(IOffscreenRenderingExtension.class).renderOnscreen();
}
@Override
public void drawString(IFont font, String text, double x, double y,
double z, TextStyle textStyle, RGB color,

View file

@ -731,20 +731,6 @@ public interface IGraphicsTarget extends IImagingExtension {
*/
public IView getView();
/**
* Use getExtension(IOffscreenRenderingExtension.class).renderOffscreen(
* offscreenImage) instead;
*/
@Deprecated
public void renderOffscreen(IImage offscreenImage) throws VizException;
/**
* Use getExtension(IOffscreenRenderingExtension.class).renderOnscreen()
* instead;
*/
@Deprecated
public void renderOnscreen() throws VizException;
/**
* Use drawStrings(DrawableString parameters)
*/

View file

@ -17,17 +17,18 @@
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.viz.radar.rsc.mosaic.ext;
package com.raytheon.uf.viz.core.drawables.ext;
import com.raytheon.uf.viz.core.DrawableImage;
import com.raytheon.uf.viz.core.IExtent;
import com.raytheon.uf.viz.core.drawables.ColorMapParameters;
import com.raytheon.uf.viz.core.drawables.IColormappedImage;
import com.raytheon.uf.viz.core.drawables.ext.IImagingExtension;
import com.raytheon.uf.viz.core.exception.VizException;
/**
* Radar mosaic image extension, creates IMosaicImages
* Mosaic image extension, creates IMosaicImages. Mosaicing should be used when
* multiple overlapping images are being drawn to the screen. The mosaic
* extension will combine these images into a single mosaic image.
*
* <pre>
*
@ -43,7 +44,7 @@ import com.raytheon.uf.viz.core.exception.VizException;
* @version 1.0
*/
public interface IRadarMosaicImageExtension extends IImagingExtension {
public interface IMosaicImageExtension extends IImagingExtension {
public static interface IMosaicImage extends IColormappedImage {

View file

@ -0,0 +1,42 @@
/**
* 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 com.raytheon.uf.viz.core.drawables.ext;
/**
* A mosaicing extension that combines images by using the largest value for
* overlapped areas of multiple iamges.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jul 10, 2012 bsteffen Initial creation
*
* </pre>
*
* @author bsteffen
* @version 1.0
*/
public interface IMosaicMaxValImageExtension extends IMosaicImageExtension {
}

View file

@ -0,0 +1,42 @@
/**
* 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 com.raytheon.uf.viz.core.drawables.ext;
/**
* A mosaicing extension that combines images by using the values from the last
* drawn image when images overalap.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jul 10, 2012 bsteffen Initial creation
*
* </pre>
*
* @author bsteffen
* @version 1.0
*/
public interface IMosaicOrderedImageExtension extends IMosaicImageExtension {
}

View file

@ -1,82 +0,0 @@
package com.raytheon.uf.viz.core.drawables.ext;
import java.nio.Buffer;
import com.raytheon.uf.viz.core.IExtent;
import com.raytheon.uf.viz.core.drawables.ColorMapParameters;
import com.raytheon.uf.viz.core.drawables.IColormappedImage;
import com.raytheon.uf.viz.core.drawables.IImage;
import com.raytheon.uf.viz.core.drawables.ext.GraphicsExtension.IGraphicsExtensionInterface;
import com.raytheon.uf.viz.core.exception.VizException;
public interface IOffscreenRenderingExtension extends
IGraphicsExtensionInterface {
/**
* All drawing between a call to renderOffscreen and the next call to
* renderOnscreen will be drawn to offscreenImage rather than to the screen.
* Will use the current screen's world as the coverage area for the
* offscreen image
*
* @param offscreenImage
* image to render to
* @throws VizException
*/
public void renderOffscreen(IImage offscreenImage) throws VizException;
/**
* All drawing between a call to renderOffscreen and the next call to
* renderOnscreen will be drawn to offscreenImage rather than to the screen.
* Will use the extent passed in as the world coverage area for the
* offscreen image
*
* @param offscreenImage
* @param offscreenExtent
* @throws VizException
*/
public void renderOffscreen(IImage offscreenImage, IExtent offscreenExtent)
throws VizException;
/**
* Reset rendering to the screen. This only needs to be called if
* renderOffscreen has been called.
*
* @throws VizException
*/
public void renderOnscreen() throws VizException;
/**
* Construct an offscreen image with the specified dimensions. This image
* will be an RGB based image
*
* @param dimensions
* @return
* @throws VizException
*/
public IImage constructOffscreenImage(int[] dimensions) throws VizException;
/**
* Construct an offscreen image for given Buffer type and size
*
* @param dataType
* @param dataBounds
* @return
* @throws VizException
*/
public IColormappedImage constructOffscreenImage(
Class<? extends Buffer> dataType, int[] dimensions)
throws VizException;
/**
* Construct an offscreen image for given Buffer type and size, applying
* ColorMapParameters to offscreen image where possible
*
* @param dataType
* @param dataBounds
* @param parameters
* @return
* @throws VizException
*/
public IColormappedImage constructOffscreenImage(
Class<? extends Buffer> dataType, int[] dimensions,
ColorMapParameters parameters) throws VizException;
}

View file

@ -6,8 +6,5 @@
<graphicsExtension
class="com.raytheon.uf.viz.radar.gl.GLRadialMeshExtension">
</graphicsExtension>
<graphicsExtension
class="com.raytheon.uf.viz.radar.gl.mosaic.GLRadarMosaicImageExtension">
</graphicsExtension>
</extension>
</plugin>

View file

@ -1,7 +1,7 @@
// this shader program sets values into a mosaic texture
// which is the same size as the screen (frame buffer)
uniform sampler2D radarData;
uniform sampler2D imageData;
uniform sampler2D mosaicTexture;
uniform int height;
uniform int width;
@ -9,10 +9,10 @@ uniform int width;
void main(void)
{
vec2 xy = gl_FragCoord.xy;
vec4 radarVal = texture2D(radarData,gl_TexCoord[0].st);
vec4 imageVal = texture2D(imageData,gl_TexCoord[0].st);
vec4 curVal = texture2D(mosaicTexture, vec2((xy.x / float(width)), (xy.y / float(height))));
if ( radarVal.r > curVal.r ) {
gl_FragColor = vec4(radarVal.r,0.0,0.0,1.0);
if ( imageVal.r > curVal.r ) {
gl_FragColor = vec4(imageVal.r,0.0,0.0,1.0);
} else {
gl_FragColor = vec4(curVal.r,0.0,0.0,1.0);
}

View file

@ -0,0 +1,20 @@
// this shader program sets values into a mosaic texture
// which is the same size as the screen (frame buffer)
uniform sampler2D imageData;
uniform sampler2D mosaicTexture;
uniform int height;
uniform int width;
void main(void)
{
vec2 xy = gl_FragCoord.xy;
vec4 imageVal = texture2D(imageData,gl_TexCoord[0].st);
vec4 curVal = texture2D(mosaicTexture, vec2((xy.x / float(width)), (xy.y / float(height))));
// assume 0 or NaN is No Data and should be replaced if another image has better values.
if ( imageVal.r != 0 && imageVal.r == imageVal.r) {
gl_FragColor = vec4(imageVal.r,0.0,0.0,1.0);
} else {
gl_FragColor = vec4(curVal.r,0.0,0.0,1.0);
}
}

View file

@ -56,5 +56,14 @@
<graphicsExtension
class="com.raytheon.viz.core.gl.internal.ext.GLMultiChannelImageExtension">
</graphicsExtension>
<graphicsExtension
class="com.raytheon.viz.core.gl.internal.ext.mosaic.GLMosaicImageExtension">
</graphicsExtension>
<graphicsExtension
class="com.raytheon.viz.core.gl.internal.ext.mosaic.GLMosaicMaxValImageExtension">
</graphicsExtension>
<graphicsExtension
class="com.raytheon.viz.core.gl.internal.ext.mosaic.GLMosaicOrderedImageExtension">
</graphicsExtension>
</extension>
</plugin>

View file

@ -1,3 +1,22 @@
/**
* 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 com.raytheon.viz.core.gl.ext;
import java.awt.Rectangle;
@ -16,7 +35,7 @@ import com.raytheon.uf.viz.core.data.IRenderedImageCallback;
import com.raytheon.uf.viz.core.drawables.ColorMapParameters;
import com.raytheon.uf.viz.core.drawables.IImage;
import com.raytheon.uf.viz.core.drawables.ext.GraphicsExtension;
import com.raytheon.uf.viz.core.drawables.ext.IOffscreenRenderingExtension;
import com.raytheon.uf.viz.core.drawables.ext.GraphicsExtension.IGraphicsExtensionInterface;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.viz.core.gl.IGLTarget;
import com.raytheon.viz.core.gl.dataformat.AbstractGLColorMapDataFormat;
@ -27,8 +46,28 @@ import com.raytheon.viz.core.gl.images.GLColormappedImage;
import com.raytheon.viz.core.gl.internal.GLView2D;
import com.raytheon.viz.core.gl.internal.ext.GLColormappedImageExtension;
/**
*
* Provides logic for creating offscreen images in GL so that data can be
* rendered and saved for better efficiency. When rendering offscreen all render
* events to the target are sent to an offscreen image, this image can later be
* rendered onscreen.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jul 10, 2012 bsteffen Initial creation
*
* </pre>
*
* @author bsteffen
* @version 1.0
*/
public class GLOffscreenRenderingExtension extends GraphicsExtension<IGLTarget>
implements IOffscreenRenderingExtension {
implements IGraphicsExtensionInterface {
private static class ViewInfo {
private IView view;
@ -53,25 +92,10 @@ public class GLOffscreenRenderingExtension extends GraphicsExtension<IGLTarget>
private ViewInfo currentInfo = null;
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.viz.core.drawables.ext.IOffscreenRenderingExtension#
* renderOffscreen(com.raytheon.uf.viz.core.drawables.IImage)
*/
@Override
public void renderOffscreen(IImage offscreenImage) throws VizException {
renderOffscreen(offscreenImage, target.getView().getExtent());
}
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.viz.core.drawables.ext.IOffscreenRenderingExtension#
* renderOffscreen(com.raytheon.uf.viz.core.drawables.IImage,
* com.raytheon.uf.viz.core.IExtent)
*/
@Override
public void renderOffscreen(IImage offscreenImage, IExtent offscreenExtent)
throws VizException {
if (!(offscreenImage instanceof AbstractGLImage)) {
@ -100,7 +124,6 @@ public class GLOffscreenRenderingExtension extends GraphicsExtension<IGLTarget>
setCurrentView(new ViewInfo(view, glImage));
}
@Override
public void renderOnscreen() throws VizException {
if (viewStack.size() > 0) {
setCurrentView(viewStack.pop());
@ -139,13 +162,6 @@ public class GLOffscreenRenderingExtension extends GraphicsExtension<IGLTarget>
return Compatibilty.TARGET_COMPATIBLE;
}
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.viz.core.drawables.ext.IOffscreenRenderingExtension#
* constructOffscreenImage(int[])
*/
@Override
public IImage constructOffscreenImage(final int[] dimensions)
throws VizException {
return target.initializeRaster(new IRenderedImageCallback() {
@ -157,26 +173,12 @@ public class GLOffscreenRenderingExtension extends GraphicsExtension<IGLTarget>
});
}
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.viz.core.drawables.ext.IOffscreenRenderingExtension#
* constructOffscreenImage(java.lang.Class, java.awt.Rectangle)
*/
@Override
public GLColormappedImage constructOffscreenImage(
Class<? extends Buffer> dataType, int[] dimensions)
throws VizException {
return constructOffscreenImage(dataType, dimensions, null);
}
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.viz.core.drawables.ext.IOffscreenRenderingExtension#
* constructOffscreenImage(java.lang.Class, java.awt.Rectangle)
*/
@Override
public GLColormappedImage constructOffscreenImage(
Class<? extends Buffer> dataType, final int[] dimensions,
ColorMapParameters parameters) throws VizException {

View file

@ -17,14 +17,15 @@
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.viz.radar.gl.mosaic;
package com.raytheon.viz.core.gl.internal.ext.mosaic;
import com.raytheon.uf.viz.core.DrawableImage;
import com.raytheon.uf.viz.core.IExtent;
import com.raytheon.uf.viz.core.drawables.ColorMapParameters;
import com.raytheon.uf.viz.core.drawables.ext.IMosaicImageExtension;
import com.raytheon.uf.viz.core.drawables.ext.IMosaicImageExtension.IMosaicImage;
import com.raytheon.viz.core.gl.images.GLColormappedImage;
import com.raytheon.viz.core.gl.images.GLDelegateImage;
import com.raytheon.viz.radar.rsc.mosaic.ext.IRadarMosaicImageExtension.IMosaicImage;
/**
* GL implementation of IMosaicImage, wraps an offscreen image and contains
@ -61,8 +62,9 @@ public class GLMosaicImage extends GLDelegateImage<GLColormappedImage>
* @param extensionClass
*/
public GLMosaicImage(GLColormappedImage image, int[] bounds,
IExtent imageExtent) {
super(image, GLRadarMosaicImageExtension.class);
IExtent imageExtent,
Class<? extends IMosaicImageExtension> extensionClass) {
super(image, extensionClass);
this.bounds = bounds;
this.extent = imageExtent;
}

View file

@ -17,7 +17,7 @@
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.viz.radar.gl.mosaic;
package com.raytheon.viz.core.gl.internal.ext.mosaic;
import java.nio.ByteBuffer;
@ -30,13 +30,12 @@ import com.raytheon.uf.viz.core.drawables.ColorMapParameters;
import com.raytheon.uf.viz.core.drawables.IImage;
import com.raytheon.uf.viz.core.drawables.ImagingSupport;
import com.raytheon.uf.viz.core.drawables.PaintProperties;
import com.raytheon.uf.viz.core.drawables.ext.IOffscreenRenderingExtension;
import com.raytheon.uf.viz.core.drawables.ext.IMosaicImageExtension;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.viz.core.gl.ext.GLOffscreenRenderingExtension;
import com.raytheon.viz.core.gl.glsl.AbstractGLSLImagingExtension;
import com.raytheon.viz.core.gl.glsl.GLShaderProgram;
import com.raytheon.viz.core.gl.images.AbstractGLImage;
import com.raytheon.viz.radar.rsc.mosaic.ext.IRadarMosaicImageExtension;
/**
* Extension used for rendering radar mosaic images
@ -55,8 +54,8 @@ import com.raytheon.viz.radar.rsc.mosaic.ext.IRadarMosaicImageExtension;
* @version 1.0
*/
public class GLRadarMosaicImageExtension extends AbstractGLSLImagingExtension
implements IRadarMosaicImageExtension {
public class GLMosaicImageExtension extends AbstractGLSLImagingExtension
implements IMosaicImageExtension {
private AbstractGLImage writeToImage;
@ -65,7 +64,7 @@ public class GLRadarMosaicImageExtension extends AbstractGLSLImagingExtension
return new GLMosaicImage(target.getExtension(
GLOffscreenRenderingExtension.class).constructOffscreenImage(
ByteBuffer.class, imageBounds, params), imageBounds,
imageExtent);
imageExtent, this.getClass());
}
/*
@ -77,7 +76,7 @@ public class GLRadarMosaicImageExtension extends AbstractGLSLImagingExtension
*/
@Override
public String getShaderProgramName() {
return "mosaicMaxVal";
return "mosaicOrdered";
}
/*
@ -95,8 +94,8 @@ public class GLRadarMosaicImageExtension extends AbstractGLSLImagingExtension
GLMosaicImage mosaicImage = (GLMosaicImage) image;
if (mosaicImage.isRepaint()) {
writeToImage = mosaicImage.getWrappedImage();
IOffscreenRenderingExtension extension = target
.getExtension(IOffscreenRenderingExtension.class);
GLOffscreenRenderingExtension extension = target
.getExtension(GLOffscreenRenderingExtension.class);
try {
extension.renderOffscreen(mosaicImage,
mosaicImage.getImageExtent());
@ -164,7 +163,7 @@ public class GLRadarMosaicImageExtension extends AbstractGLSLImagingExtension
@Override
public void loadShaderData(GLShaderProgram program, IImage image,
PaintProperties paintProps) throws VizException {
program.setUniform("radarData", 0);
program.setUniform("imageData", 0);
program.setUniform("mosaicTexture", 1);
// pass in width and height

View file

@ -0,0 +1,49 @@
/**
* 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 com.raytheon.viz.core.gl.internal.ext.mosaic;
import com.raytheon.uf.viz.core.drawables.ext.IMosaicMaxValImageExtension;
/**
* GL implementation of the max val mosaic algorithm
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jul 10, 2012 bsteffen Initial creation
*
* </pre>
*
* @author bsteffen
* @version 1.0
*/
public class GLMosaicMaxValImageExtension extends GLMosaicImageExtension
implements IMosaicMaxValImageExtension {
@Override
public String getShaderProgramName() {
return "mosaicMaxVal";
}
}

View file

@ -0,0 +1,49 @@
/**
* 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 com.raytheon.viz.core.gl.internal.ext.mosaic;
import com.raytheon.uf.viz.core.drawables.ext.IMosaicOrderedImageExtension;
/**
* GL implementation of the ordered mosaic algorithm
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jul 10, 2012 bsteffen Initial creation
*
* </pre>
*
* @author bsteffen
* @version 1.0
*/
public class GLMosaicOrderedImageExtension extends GLMosaicImageExtension
implements IMosaicOrderedImageExtension {
@Override
public String getShaderProgramName() {
return "mosaicOrdered";
}
}

View file

@ -22,6 +22,7 @@ package com.raytheon.viz.core.rsc.hdf5;
import java.awt.Point;
import java.awt.Rectangle;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@ -434,7 +435,7 @@ public abstract class AbstractTileSet implements IRenderable, IMeshCallback {
* @param isRecursiveCall
* @throws VizException
*/
protected void drawInternal(IGraphicsTarget target,
protected List<DrawableImage> drawInternal(IGraphicsTarget target,
PaintProperties paintProps, int lvl, int depth) throws VizException {
List<ImageTile> intersectedTiles = new ArrayList<ImageTile>();
@ -504,12 +505,14 @@ public abstract class AbstractTileSet implements IRenderable, IMeshCallback {
// Draw lower resolution data first
if (needDrawLower && (lvl + 1) < levels) {
drawInternal(target, paintProps, lvl + 1, depth + 1);
// put lower levels first in the list so they are drawn first.
List<DrawableImage> lowerImages = drawInternal(target, paintProps,
lvl + 1, depth + 1);
lowerImages.addAll(drawableImages);
drawableImages = lowerImages;
}
// Draw all tiles at once
target.drawRasters(paintProps, drawableImages
.toArray(new DrawableImage[drawableImages.size()]));
return drawableImages;
}
/*
@ -526,11 +529,16 @@ public abstract class AbstractTileSet implements IRenderable, IMeshCallback {
return;
}
lastPaintedTarget = target;
do2D(target, paintProps);
List<DrawableImage> drawableImages = do2D(target, paintProps);
// Draw all tiles at once
target.drawRasters(paintProps, drawableImages
.toArray(new DrawableImage[drawableImages.size()]));
}
protected void do2D(IGraphicsTarget target, PaintProperties paintProps)
throws VizException {
protected List<DrawableImage> do2D(IGraphicsTarget target,
PaintProperties paintProps) throws VizException {
double screenToWorldRatio = paintProps.getCanvasBounds().width
/ paintProps.getView().getExtent().getWidth();
@ -550,9 +558,11 @@ public abstract class AbstractTileSet implements IRenderable, IMeshCallback {
if (this.tileSet.getTileSet() != null
&& tileSet.getTileSet().size() > 0) {
drawInternal(target, paintProps, usedTileLevel, 0);
lastPaintedLevel = usedTileLevel;
return drawInternal(target, paintProps, usedTileLevel, 0);
} else {
return Collections.emptyList();
}
}

View file

@ -81,7 +81,6 @@ Export-Package: com.raytheon.viz.radar;
com.raytheon.viz.radar.rsc.graphic,
com.raytheon.viz.radar.rsc.image,
com.raytheon.viz.radar.rsc.mosaic,
com.raytheon.viz.radar.rsc.mosaic.ext,
com.raytheon.viz.radar.ui;
uses:="com.raytheon.viz.radar,
com.raytheon.viz.ui.dialogs,

View file

@ -31,6 +31,9 @@ import com.raytheon.uf.viz.core.PixelCoverage;
import com.raytheon.uf.viz.core.drawables.ColorMapParameters;
import com.raytheon.uf.viz.core.drawables.PaintProperties;
import com.raytheon.uf.viz.core.drawables.ResourcePair;
import com.raytheon.uf.viz.core.drawables.ext.IMosaicImageExtension;
import com.raytheon.uf.viz.core.drawables.ext.IMosaicImageExtension.IMosaicImage;
import com.raytheon.uf.viz.core.drawables.ext.IMosaicMaxValImageExtension;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.rsc.AbstractVizResource;
import com.raytheon.uf.viz.core.rsc.IRefreshListener;
@ -40,8 +43,6 @@ import com.raytheon.viz.core.rsc.BestResResource;
import com.raytheon.viz.radar.rsc.MosaicPaintProperties;
import com.raytheon.viz.radar.rsc.RadarImageResource;
import com.raytheon.viz.radar.rsc.mosaic.RadarMosaicRendererFactory.IRadarMosaicRenderer;
import com.raytheon.viz.radar.rsc.mosaic.ext.IRadarMosaicImageExtension;
import com.raytheon.viz.radar.rsc.mosaic.ext.IRadarMosaicImageExtension.IMosaicImage;
import com.vividsolutions.jts.geom.Coordinate;
/**
@ -177,12 +178,21 @@ public class RadarMosaicRenderer implements IRadarMosaicRenderer,
*/
private void init(IGraphicsTarget target, PaintProperties paintProps,
ColorMapParameters params) throws VizException {
IMosaicImageExtension ext = target
.getExtension(IMosaicMaxValImageExtension.class);
if (ext == null) {
// This could return about any mosaicing algorithm but it is better
// than drawing nothing
ext = target.getExtension(IMosaicImageExtension.class);
}
if (ext == null) {
}
// Construct texture for mosaicing
writeTo = target.getExtension(IRadarMosaicImageExtension.class)
.initializeRaster(
new int[] { paintProps.getCanvasBounds().width,
paintProps.getCanvasBounds().height },
paintProps.getView().getExtent(), params);
writeTo = ext.initializeRaster(
new int[] { paintProps.getCanvasBounds().width,
paintProps.getCanvasBounds().height }, paintProps
.getView().getExtent(), params);
}
@Override

View file

@ -28,14 +28,16 @@ import org.opengis.referencing.crs.CoordinateReferenceSystem;
import com.raytheon.uf.common.geospatial.ReferencedCoordinate;
import com.raytheon.uf.common.time.DataTime;
import com.raytheon.uf.viz.core.DrawableImage;
import com.raytheon.uf.viz.core.IExtent;
import com.raytheon.uf.viz.core.IGraphicsTarget;
import com.raytheon.uf.viz.core.PixelCoverage;
import com.raytheon.uf.viz.core.drawables.IImage;
import com.raytheon.uf.viz.core.drawables.ColorMapParameters;
import com.raytheon.uf.viz.core.drawables.PaintProperties;
import com.raytheon.uf.viz.core.drawables.PaintStatus;
import com.raytheon.uf.viz.core.drawables.ResourcePair;
import com.raytheon.uf.viz.core.drawables.ext.IOffscreenRenderingExtension;
import com.raytheon.uf.viz.core.drawables.ext.IMosaicImageExtension;
import com.raytheon.uf.viz.core.drawables.ext.IMosaicImageExtension.IMosaicImage;
import com.raytheon.uf.viz.core.drawables.ext.IMosaicOrderedImageExtension;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.map.MapDescriptor;
import com.raytheon.uf.viz.core.rsc.AbstractVizResource;
@ -44,6 +46,8 @@ import com.raytheon.uf.viz.core.rsc.IResourceDataChanged;
import com.raytheon.uf.viz.core.rsc.IResourceGroup;
import com.raytheon.uf.viz.core.rsc.LoadProperties;
import com.raytheon.uf.viz.core.rsc.ResourceList;
import com.raytheon.uf.viz.core.rsc.capabilities.ColorMapCapability;
import com.raytheon.uf.viz.core.rsc.capabilities.ImagingCapability;
import com.vividsolutions.jts.geom.Coordinate;
/**
@ -67,9 +71,7 @@ public class SatBlendedResource extends
AbstractVizResource<SatBlendedResourceData, MapDescriptor> implements
IResourceGroup, IRefreshListener, IResourceDataChanged {
private IImage offscreenImage = null;
private int[] imageBounds = null;
private IMosaicImage mosaicImage = null;
private IExtent lastExtent = null;
@ -149,15 +151,21 @@ public class SatBlendedResource extends
@Override
protected void paintInternal(IGraphicsTarget target,
PaintProperties paintProps) throws VizException {
if (offscreenImage == null
|| Arrays.equals(imageBounds,
new int[] { paintProps.getCanvasBounds().width,
paintProps.getCanvasBounds().height }) == false) {
ColorMapParameters params = getCapability(ColorMapCapability.class)
.getColorMapParameters();
// If first paint, initialize and wait for next paint
if (mosaicImage == null) {
initImage(target, paintProps, params);
} else if (Arrays.equals(
new int[] { mosaicImage.getWidth(), mosaicImage.getHeight() },
new int[] { paintProps.getCanvasBounds().width,
paintProps.getCanvasBounds().height }) == false) {
// If Window size changed, recreate the off screen buffer
disposeImage();
initImage(target, paintProps);
initImage(target, paintProps, params);
}
boolean newTimes = false;
List<DataTime> rscTimes = new ArrayList<DataTime>();
for (ResourcePair rp : getResourceList()) {
AbstractVizResource<?, ?> rsc = rp.getResource();
@ -165,41 +173,41 @@ public class SatBlendedResource extends
rscTimes.add(descriptor.getTimeForResource(rsc));
}
}
if (rscTimes.equals(lastTimes) == false) {
newTimes = true;
}
lastTimes = rscTimes;
IExtent extent = paintProps.getView().getExtent().clone();
if (extent.equals(lastExtent) == false
|| rscTimes.equals(lastTimes) == false) {
lastTimes = rscTimes;
lastExtent = extent;
List<DrawableImage> images = new ArrayList<DrawableImage>();
if (paintProps.getView().getExtent().equals(lastExtent) == false
|| newTimes) {
IExtent extent = lastExtent = paintProps.getView().getExtent()
.clone();
// render offscreen so alpha can be applied to combined image rather
// than to each image.
target.renderOffscreen(offscreenImage);
if (paintProps.getDataTime() != null) {
for (ResourcePair rp : getResourceList()) {
AbstractVizResource<?, ?> rsc = rp.getResource();
if (rsc != null) {
DataTime timeForRsc = paintProps.getFramesInfo()
.getTimeForResource(rsc);
PaintProperties rscProps = new PaintProperties(
paintProps);
rscProps.setDataTime(timeForRsc);
rscProps.setAlpha(1.0f);
PaintStatus paintStatus = rsc.paint(target, rscProps);
if (paintStatus != PaintStatus.PAINTED) {
updatePaintStatus(paintStatus);
for (ResourcePair rp : getResourceList()) {
AbstractVizResource<?, ?> rsc = rp.getResource();
DataTime time = paintProps.getFramesInfo().getTimeForResource(
rsc);
if (rsc != null && time != null) {
SatResource sr = (SatResource) rsc;
DataTime timeForRsc = paintProps.getFramesInfo()
.getTimeForResource(rsc);
PaintProperties rscProps = new PaintProperties(paintProps);
rscProps.setDataTime(timeForRsc);
rscProps.setAlpha(1.0f);
List<DrawableImage> rscImages = sr.getImages(target,
rscProps);
for (DrawableImage di : rscImages) {
if (di != null && di.getImage() != null
&& di.getCoverage() != null
&& di.getCoverage().getMesh() != null) {
// If image is ready to go, add
images.add(di);
}
}
}
}
target.renderOnscreen();
mosaicImage.setImagesToMosaic(images
.toArray(new DrawableImage[images.size()]));
mosaicImage.setImageExtent(extent);
Coordinate ul = new Coordinate(extent.getMinX(), extent.getMaxY());
Coordinate ur = new Coordinate(extent.getMaxX(), extent.getMaxY());
@ -209,24 +217,35 @@ public class SatBlendedResource extends
imageCoverage = new PixelCoverage(ul, ur, lr, ll);
}
target.drawRaster(offscreenImage, imageCoverage, paintProps);
mosaicImage.setContrast(getCapability(ImagingCapability.class)
.getContrast());
mosaicImage.setBrightness(getCapability(ImagingCapability.class)
.getBrightness());
target.drawRaster(mosaicImage, imageCoverage, paintProps);
}
private void initImage(IGraphicsTarget target, PaintProperties paintProps)
throws VizException {
// Construct texture for fbo
imageBounds = new int[] { paintProps.getCanvasBounds().width,
paintProps.getCanvasBounds().height };
offscreenImage = target
.getExtension(IOffscreenRenderingExtension.class)
.constructOffscreenImage(imageBounds);
private void initImage(IGraphicsTarget target, PaintProperties paintProps,
ColorMapParameters params) throws VizException {
IMosaicImageExtension ext = target
.getExtension(IMosaicOrderedImageExtension.class);
if (ext == null) {
// This could return about any mosaicing algorithm but it is better
// than drawing nothing
ext = target.getExtension(IMosaicImageExtension.class);
}
// Construct texture for mosaicing
mosaicImage = ext.initializeRaster(
new int[] { paintProps.getCanvasBounds().width,
paintProps.getCanvasBounds().height }, paintProps
.getView().getExtent(), params);
}
private void disposeImage() {
// Dispose of all data, offscreen texture
if (offscreenImage != null) {
offscreenImage.dispose();
offscreenImage = null;
if (mosaicImage != null) {
mosaicImage.dispose();
mosaicImage = null;
}
}

View file

@ -35,10 +35,12 @@ import com.raytheon.uf.common.datastorage.StorageException;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.viz.core.DrawableImage;
import com.raytheon.uf.viz.core.HDF5Util;
import com.raytheon.uf.viz.core.IGraphicsTarget;
import com.raytheon.uf.viz.core.drawables.ColorMapParameters;
import com.raytheon.uf.viz.core.drawables.IImage;
import com.raytheon.uf.viz.core.drawables.PaintProperties;
import com.raytheon.uf.viz.core.drawables.ext.colormap.IColormappedImageExtension;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.rsc.AbstractVizResource;
@ -296,4 +298,9 @@ public class SatFileBasedTileSet extends FileBasedTileSet {
public void cancelRequest(int level, int i, int j) {
}
public List<DrawableImage> getImages(IGraphicsTarget target,
PaintProperties paintProps) throws VizException {
return do2D(target, paintProps);
}
}

View file

@ -26,6 +26,7 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.measure.converter.UnitConverter;
@ -52,6 +53,7 @@ import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.common.time.BinOffset;
import com.raytheon.uf.common.time.DataTime;
import com.raytheon.uf.viz.core.DrawableImage;
import com.raytheon.uf.viz.core.IGraphicsTarget;
import com.raytheon.uf.viz.core.IMeshCallback;
import com.raytheon.uf.viz.core.drawables.ColorMapParameters;
@ -107,13 +109,13 @@ public class SatResource extends
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(SatResource.class);
protected Map<DataTime, FileBasedTileSet> tileSet;
protected Map<DataTime, SatFileBasedTileSet> tileSet;
private Map<DataTime, SatelliteRecord> recordMap = new HashMap<DataTime, SatelliteRecord>();
protected DataTime displayedDate;
protected FileBasedTileSet baseTile;
protected SatFileBasedTileSet baseTile;
protected String legend;
@ -125,7 +127,7 @@ public class SatResource extends
protected String viewType;
protected FileBasedTileSet currentTile;
protected SatFileBasedTileSet currentTile;
protected GridGeometry recordGeometry;
@ -139,7 +141,7 @@ public class SatResource extends
public SatResource(SatResourceData data, LoadProperties props) {
super(data, props);
data.addChangeListener(this);
this.tileSet = new HashMap<DataTime, FileBasedTileSet>();
this.tileSet = new HashMap<DataTime, SatFileBasedTileSet>();
this.dataTimes = new ArrayList<DataTime>();
this.legend = null;
SatelliteRecord[] records = data.getRecords();
@ -224,12 +226,11 @@ public class SatResource extends
if (sr != null && sr.getPreferences() instanceof ImagePreferences) {
sampleRange = ((ImagePreferences) sr.getPreferences())
.getSamplePrefs();
String lg = ((ImagePreferences) sr.getPreferences())
.getLegend();
// test, so legend is not over written with empty string
if (lg != null && !lg.trim().isEmpty()) {
legend = lg;
}
String lg = ((ImagePreferences) sr.getPreferences()).getLegend();
// test, so legend is not over written with empty string
if (lg != null && !lg.trim().isEmpty()) {
legend = lg;
}
}
colorMapParameters = ColorMapParameterFactory.build(null,
@ -447,7 +448,7 @@ public class SatResource extends
public void addRecord(PluginDataObject record) throws VizException {
synchronized (this) {
FileBasedTileSet tile;
SatFileBasedTileSet tile;
DataTime recordTime = null;
if (resourceData.getBinOffset() != null || resourceData.equals(0)) {
BinOffset binOffset = resourceData.getBinOffset();
@ -562,4 +563,18 @@ public class SatResource extends
issueRefresh();
}
public List<DrawableImage> getImages(IGraphicsTarget target,
PaintProperties paintProps) throws VizException {
this.target = target;
this.displayedDate = paintProps.getDataTime();
if (this.displayedDate == null)
return Collections.emptyList();
currentTile = this.tileSet.get(this.displayedDate);
if (currentTile != null) {
return currentTile.getImages(target, paintProps);
}
return Collections.emptyList();
}
}