Merge branch 'core_exp' into ss_sync (Graphics Improvements for NPP/Collaboration)
used git cherry-pick -m 1 879a2e0 Initial reconciliation of Graphics Improvements for NPP/Collaboration with 12.3.1 baseline Conflicts: cave/com.raytheon.uf.viz.derivparam/src/com/raytheon/uf/viz/derivparam/tree/DerivedLevelNode.java* cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/AbstractGLMesh.java cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/GLCanvasCache.java cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/GLFactoryAdapter.java cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/GLGeometryPainter.java cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/IGLTarget.java cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/images/AbstractGLImage.java cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/images/GLCMTextureData.java cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/images/GLColormappedImage.java cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/images/GLImage.java cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/internal/GLTarget.java cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/internal/GLWireframeShape2D.java cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/objects/GLVertexBufferObject.java cave/com.raytheon.viz.grid/src/com/raytheon/viz/grid/util/GribDataCubeAdapter.java cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/drawables/GeneralPointImageExtension.java cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/drawables/IPointImageExtension.java cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/rsc/PlotResource2.java* cave/com.raytheon.viz.radar/src/com/raytheon/viz/radar/rsc/mosaic/ext/IRadarMosaicImageExtension.java edexOsgi/com.raytheon.uf.common.time/src/com/raytheon/uf/common/time/msgs/GetServerTimeRequest.java Conflicts: ncep/gov.noaa.nws.ncep.viz.rsc.mosaic/src/gov/noaa/nws/ncep/viz/rsc/mosaic/rsc/RadarRadialResource.java ncep/gov.noaa.nws.ncep.viz.rsc.ncradar/src/gov/noaa/nws/ncep/viz/rsc/ncradar/rsc/RadarImageResource.java Former-commit-id: 05d9729acfe9e0f4af4a6ec030052ab26b0a5eb9
This commit is contained in:
parent
8485b90ff8
commit
7b75b781ad
159 changed files with 5137 additions and 5298 deletions
|
@ -407,12 +407,6 @@ public class CoopPrecipDataCubeAdapter implements IDataCubeAdapter {
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String recordKeyGenerator(PluginDataObject pdo) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initInventory() {
|
||||
// TODO Auto-generated method stub
|
||||
|
|
|
@ -87,6 +87,7 @@ public abstract class AbstractDbMapResource<T extends AbstractDbMapResourceData,
|
|||
|
||||
if (font != null) {
|
||||
font.dispose();
|
||||
font = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -540,7 +540,7 @@ public class DbMapResource extends
|
|||
if (shadedShape != null) {
|
||||
shadedShape.dispose();
|
||||
}
|
||||
|
||||
lastExtent = null;
|
||||
super.disposeInternal();
|
||||
}
|
||||
|
||||
|
|
|
@ -133,11 +133,4 @@ public abstract class AbstractGraphicsFactoryAdapter {
|
|||
public abstract Canvas constrcutCanvas(Composite canvasComp)
|
||||
throws VizException;
|
||||
|
||||
/**
|
||||
* Dispose of the canvas, it can be assumed the canvas is the same type
|
||||
* created from constructCanvas
|
||||
*
|
||||
* @param canvas
|
||||
*/
|
||||
public abstract void disposeCanvas(Canvas canvas);
|
||||
}
|
||||
|
|
|
@ -45,11 +45,16 @@ public class DrawableImage {
|
|||
|
||||
private PixelCoverage coverage;
|
||||
|
||||
private RasterMode mode = RasterMode.SYNCHRONOUS;
|
||||
private RasterMode mode;
|
||||
|
||||
public DrawableImage(IImage image, PixelCoverage coverage) {
|
||||
this(image, coverage, RasterMode.SYNCHRONOUS);
|
||||
}
|
||||
|
||||
public DrawableImage(IImage image, PixelCoverage coverage, RasterMode mode) {
|
||||
this.image = image;
|
||||
this.coverage = coverage;
|
||||
this.mode = mode;
|
||||
}
|
||||
|
||||
public IImage getImage() {
|
||||
|
|
|
@ -39,6 +39,8 @@ import com.raytheon.uf.viz.core.drawables.IRenderableDisplay;
|
|||
import com.raytheon.uf.viz.core.drawables.IShadedShape;
|
||||
import com.raytheon.uf.viz.core.drawables.IWireframeShape;
|
||||
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.IImagingExtension;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
import com.raytheon.uf.viz.core.geom.PixelCoordinate;
|
||||
import com.vividsolutions.jts.geom.LinearRing;
|
||||
|
@ -64,7 +66,7 @@ import com.vividsolutions.jts.geom.LinearRing;
|
|||
* @author chammack
|
||||
* @version 1
|
||||
*/
|
||||
public interface IGraphicsTarget {
|
||||
public interface IGraphicsTarget extends IImagingExtension {
|
||||
|
||||
/** Defines alignment characteristics */
|
||||
public static enum HorizontalAlignment {
|
||||
|
@ -189,24 +191,6 @@ public interface IGraphicsTarget {
|
|||
public abstract boolean drawRaster(IImage image, PixelCoverage extent,
|
||||
PaintProperties paintProps) throws VizException;
|
||||
|
||||
/**
|
||||
* Draw a raster to a target, given an extent and an alpha (transparency)
|
||||
* value. Assumes synchronous operation.
|
||||
*
|
||||
* This operation will block on unavailable data.
|
||||
*
|
||||
* @param image
|
||||
* the image reference object to draw
|
||||
* @param extent
|
||||
* the extent of the drawable area
|
||||
* @param paintProps
|
||||
* the paint properties
|
||||
* @return status whether the raster was able to be drawn
|
||||
* @throws VizException
|
||||
*/
|
||||
public abstract boolean drawRasters(PaintProperties paintProps,
|
||||
DrawableImage... images) throws VizException;
|
||||
|
||||
/**
|
||||
* Draw a raster to a target, given an extent and an alpha (transparency)
|
||||
* value
|
||||
|
@ -662,15 +646,6 @@ public interface IGraphicsTarget {
|
|||
*/
|
||||
public abstract boolean isNeedsRefresh();
|
||||
|
||||
/**
|
||||
* Stage an image
|
||||
*
|
||||
* @param image
|
||||
* the image to stage
|
||||
* @throws VizException
|
||||
*/
|
||||
public abstract void stage(final IImage image) throws VizException;
|
||||
|
||||
/**
|
||||
* Sets the background color of the panes.
|
||||
*
|
||||
|
@ -680,6 +655,10 @@ public interface IGraphicsTarget {
|
|||
public abstract void setBackgroundColor(RGB backgroundColor);
|
||||
|
||||
/**
|
||||
* DEPRECATED: This method has no effect. IGraphicsTargets are not
|
||||
* responsible to drawing a colorbar. Use method drawColorRamp to draw a
|
||||
* color ramp
|
||||
*
|
||||
* Sets whether to display a builtin colorbar when displaying colormapped
|
||||
* images (Defaults to true)
|
||||
*
|
||||
|
@ -687,6 +666,7 @@ public interface IGraphicsTarget {
|
|||
* boolean flag indicating whether to display the built in
|
||||
* colorbar
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract void setUseBuiltinColorbar(boolean isColorbarDisplayed);
|
||||
|
||||
/**
|
||||
|
@ -1044,6 +1024,7 @@ public interface IGraphicsTarget {
|
|||
* @param extensionClass
|
||||
* @return
|
||||
*/
|
||||
public abstract <T> T getExtension(Class<T> extensionClass)
|
||||
throws VizException;
|
||||
public abstract <T extends IGraphicsExtensionInterface> T getExtension(
|
||||
Class<T> extensionClass) throws VizException;
|
||||
|
||||
}
|
||||
|
|
|
@ -19,14 +19,13 @@
|
|||
**/
|
||||
package com.raytheon.uf.viz.core;
|
||||
|
||||
import org.geotools.coverage.grid.GridGeometry2D;
|
||||
import org.opengis.referencing.operation.MathTransform;
|
||||
import org.geotools.coverage.grid.GeneralGridGeometry;
|
||||
|
||||
import com.raytheon.uf.viz.core.drawables.IRenderable;
|
||||
import com.raytheon.uf.viz.core.rsc.hdf5.ImageTile;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
|
||||
/**
|
||||
* Base for any mesh 2D/3D, Quad/Triangle -- etc
|
||||
* Base for any mesh 2D/3D, Quad/Triangle -- etc. See {@link PixelCoverage} /
|
||||
* {@link DrawableImage}
|
||||
*
|
||||
* <pre>
|
||||
* SOFTWARE HISTORY
|
||||
|
@ -40,27 +39,7 @@ import com.raytheon.uf.viz.core.rsc.hdf5.ImageTile;
|
|||
* @version 1.0
|
||||
*/
|
||||
|
||||
public interface IMesh extends IRenderable {
|
||||
|
||||
/**
|
||||
* Calculate all the mesh vertices and texture coordinates
|
||||
*
|
||||
* @param pc
|
||||
* @param tile
|
||||
* @param toLatLon
|
||||
* translate the tile coordinates to lat/lon coords if the tile
|
||||
* envelope is not already
|
||||
*/
|
||||
public abstract void calculateMesh(PixelCoverage pc, ImageTile tile,
|
||||
MathTransform toLatLon);
|
||||
|
||||
/**
|
||||
* Calculate all the mesh vertices and texture coordinates
|
||||
*
|
||||
* @param pc
|
||||
* @param gg
|
||||
*/
|
||||
public void calculateMesh(PixelCoverage pc, GridGeometry2D gg);
|
||||
public interface IMesh {
|
||||
|
||||
/**
|
||||
* Dispose of the mesh data
|
||||
|
@ -73,4 +52,12 @@ public interface IMesh extends IRenderable {
|
|||
* @param extent
|
||||
*/
|
||||
public boolean intersects(IExtent extent);
|
||||
|
||||
/**
|
||||
* Reprojects the mesh into the new target geometry
|
||||
*
|
||||
* @param targetGeometry
|
||||
*/
|
||||
public void reproject(GeneralGridGeometry targetGeometry)
|
||||
throws VizException;
|
||||
}
|
||||
|
|
|
@ -77,8 +77,6 @@ public class Colormapper {
|
|||
boolean log = parameters.isLogarithmic();
|
||||
double logFactor = parameters.getLogFactor();
|
||||
boolean mirror = parameters.isMirror();
|
||||
double naturalMin = parameters.getDataMin();
|
||||
double naturalMax = parameters.getDataMax();
|
||||
double cmapMin = parameters.getColorMapMin();
|
||||
double cmapMax = parameters.getColorMapMax();
|
||||
int colorMapSz = parameters.getColorMap().getSize();
|
||||
|
|
|
@ -34,7 +34,6 @@ import com.raytheon.uf.common.dataplugin.PluginDataObject;
|
|||
import com.raytheon.uf.common.dataquery.requests.RequestConstraint;
|
||||
import com.raytheon.uf.common.dataquery.requests.RequestConstraint.ConstraintType;
|
||||
import com.raytheon.uf.common.dataquery.requests.TimeQueryRequest;
|
||||
import com.raytheon.uf.common.dataquery.requests.TimeQueryRequestSet;
|
||||
import com.raytheon.uf.common.datastorage.Request;
|
||||
import com.raytheon.uf.common.datastorage.StorageException;
|
||||
import com.raytheon.uf.common.datastorage.records.IDataRecord;
|
||||
|
@ -42,10 +41,7 @@ import com.raytheon.uf.common.pointdata.PointDataContainer;
|
|||
import com.raytheon.uf.common.time.BinOffset;
|
||||
import com.raytheon.uf.common.time.DataTime;
|
||||
import com.raytheon.uf.viz.core.catalog.LayerProperty;
|
||||
import com.raytheon.uf.viz.core.catalog.ScriptCreator;
|
||||
import com.raytheon.uf.viz.core.comm.Loader;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
import com.raytheon.uf.viz.core.requests.ThriftClient;
|
||||
|
||||
/**
|
||||
* The DataCubeContainer is responsible for handling requests for data times,
|
||||
|
@ -101,7 +97,7 @@ public class DataCubeContainer {
|
|||
if (container.adapter != null) {
|
||||
synchronized (container.adapter) {
|
||||
Boolean initialized = initializedMap.get(container.adapter);
|
||||
if (!initialized) {
|
||||
if (initialized == null || !initialized) {
|
||||
container.adapter.initInventory();
|
||||
initializedMap.put(container.adapter, true);
|
||||
}
|
||||
|
@ -121,21 +117,9 @@ public class DataCubeContainer {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private IDataRecord[] getDataRecordInternal(PluginDataObject obj)
|
||||
throws VizDataCubeException {
|
||||
if (adapter != null) {
|
||||
return adapter.getRecord(obj);
|
||||
} else {
|
||||
IDataRecord record = null;
|
||||
try {
|
||||
record = CubeUtil.retrieveData(obj, pluginName);
|
||||
} catch (VizException e) {
|
||||
throw new VizDataCubeException(
|
||||
"Error retrieving 2D grid record.", e);
|
||||
}
|
||||
return new IDataRecord[] { record };
|
||||
if (adapter == null) {
|
||||
// Construct default adapter for plugin if none found
|
||||
adapter = new DefaultDataCubeAdapter(plugin);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -153,23 +137,7 @@ public class DataCubeContainer {
|
|||
*/
|
||||
public static IDataRecord[] getDataRecord(PluginDataObject obj)
|
||||
throws VizDataCubeException {
|
||||
return getInstance(obj.getPluginName()).getDataRecordInternal(obj);
|
||||
}
|
||||
|
||||
private IDataRecord[] getDataRecordInternal(PluginDataObject obj,
|
||||
Request req, String dataset) throws VizDataCubeException {
|
||||
if (adapter != null) {
|
||||
return adapter.getRecord(obj, req, dataset);
|
||||
} else {
|
||||
IDataRecord record = null;
|
||||
try {
|
||||
record = CubeUtil.retrieveData(obj, pluginName, req, dataset);
|
||||
} catch (VizException e) {
|
||||
throw new VizDataCubeException(
|
||||
"Error retrieving 2D grid record.", e);
|
||||
}
|
||||
return new IDataRecord[] { record };
|
||||
}
|
||||
return getInstance(obj.getPluginName()).adapter.getRecord(obj);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -188,29 +156,10 @@ public class DataCubeContainer {
|
|||
*/
|
||||
public static IDataRecord[] getDataRecord(PluginDataObject obj,
|
||||
Request req, String dataset) throws VizDataCubeException {
|
||||
return getInstance(obj.getPluginName()).getDataRecordInternal(obj, req,
|
||||
return getInstance(obj.getPluginName()).adapter.getRecord(obj, req,
|
||||
dataset);
|
||||
}
|
||||
|
||||
private void getDataRecordsInternal(List<PluginDataObject> objs,
|
||||
Request req, String dataset) throws VizDataCubeException {
|
||||
if (adapter != null) {
|
||||
adapter.getRecords(objs, req, dataset);
|
||||
} else {
|
||||
for (PluginDataObject obj : objs) {
|
||||
IDataRecord record = null;
|
||||
try {
|
||||
record = CubeUtil.retrieveData(obj, pluginName, req,
|
||||
dataset);
|
||||
} catch (VizException e) {
|
||||
throw new VizDataCubeException(
|
||||
"Error retrieving 2D grid record.", e);
|
||||
}
|
||||
obj.setMessageData(record);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* For each PluginDataObject requests the DataRecords specified by Request
|
||||
* and dataSet and stores those DataRecords in the PluginDataObject message
|
||||
|
@ -238,41 +187,25 @@ public class DataCubeContainer {
|
|||
"All PluginDataObjects must be for the same plugin");
|
||||
}
|
||||
}
|
||||
getInstance(pluginName).getDataRecordsInternal(objs, req, dataset);
|
||||
}
|
||||
|
||||
private PointDataContainer getPointDataInternal(String[] params,
|
||||
Map<String, RequestConstraint> map) throws VizException {
|
||||
if (adapter != null) {
|
||||
return adapter.getPoints(pluginName, params, map);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
getInstance(pluginName).adapter.getRecords(objs, req, dataset);
|
||||
}
|
||||
|
||||
public static PointDataContainer getPointData(String plugin,
|
||||
String[] params, Map<String, RequestConstraint> map)
|
||||
throws VizException {
|
||||
return getInstance(plugin).getPointDataInternal(params, map);
|
||||
}
|
||||
|
||||
private PointDataContainer getPointDataInternal(String[] params,
|
||||
String levelKey, Map<String, RequestConstraint> map)
|
||||
throws VizException {
|
||||
if (levelKey == null) {
|
||||
return getPointData(pluginName, params, map);
|
||||
}
|
||||
if (adapter != null) {
|
||||
return adapter.getPoints(pluginName, params, levelKey, map);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
DataCubeContainer container = getInstance(plugin);
|
||||
return container.adapter.getPoints(container.pluginName, params, map);
|
||||
}
|
||||
|
||||
public static PointDataContainer getPointData(String plugin,
|
||||
String[] params, String levelKey, Map<String, RequestConstraint> map)
|
||||
throws VizException {
|
||||
return getInstance(plugin).getPointDataInternal(params, levelKey, map);
|
||||
DataCubeContainer container = getInstance(plugin);
|
||||
if (levelKey == null) {
|
||||
return getPointData(container.pluginName, params, map);
|
||||
}
|
||||
return container.adapter.getPoints(container.pluginName, params,
|
||||
levelKey, map);
|
||||
}
|
||||
|
||||
public static DataTime[] performTimeQuery(
|
||||
|
@ -308,20 +241,6 @@ public class DataCubeContainer {
|
|||
new DataTime[0]);
|
||||
}
|
||||
|
||||
public List<List<DataTime>> performTimeQueriesInternal(
|
||||
List<TimeQueryRequest> requests) throws VizException {
|
||||
if (adapter == null) {
|
||||
TimeQueryRequestSet set = new TimeQueryRequestSet();
|
||||
set.setRequests(requests.toArray(new TimeQueryRequest[0]));
|
||||
@SuppressWarnings("unchecked")
|
||||
List<List<DataTime>> result = (List<List<DataTime>>) ThriftClient
|
||||
.sendRequest(set);
|
||||
return result;
|
||||
} else {
|
||||
return adapter.timeQuery(requests);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform a bulk time query request when all requests have the same plugin
|
||||
* type.
|
||||
|
@ -334,7 +253,7 @@ public class DataCubeContainer {
|
|||
if (requests.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return getInstance(pluginName).performTimeQueriesInternal(requests);
|
||||
return getInstance(pluginName).adapter.timeQuery(requests);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -346,8 +265,8 @@ public class DataCubeContainer {
|
|||
*/
|
||||
public static List<List<DataTime>> performTimeQueries(String pluginName,
|
||||
TimeQueryRequest... requests) throws VizException {
|
||||
return getInstance(pluginName).performTimeQueriesInternal(
|
||||
Arrays.asList(requests));
|
||||
return getInstance(pluginName).adapter.timeQuery(Arrays
|
||||
.asList(requests));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -403,17 +322,6 @@ public class DataCubeContainer {
|
|||
return result;
|
||||
}
|
||||
|
||||
private synchronized List<Object> getDataInternal(LayerProperty property,
|
||||
int timeOut) throws VizException {
|
||||
if (adapter == null) {
|
||||
String scriptToExecute = ScriptCreator.createScript(property);
|
||||
return Loader
|
||||
.loadScripts(new String[] { scriptToExecute }, timeOut);
|
||||
} else {
|
||||
return adapter.getData(property, timeOut);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of responses for the requested layer property. If a
|
||||
* derived parameter, this will piece together the base parameteters.
|
||||
|
@ -432,31 +340,11 @@ public class DataCubeContainer {
|
|||
.getEntryQueryParameters(false);
|
||||
String pluginName = originalQuery.get("pluginName")
|
||||
.getConstraintValue();
|
||||
return getInstance(pluginName).getDataInternal(property, timeOut);
|
||||
}
|
||||
|
||||
private Object getInventoryInternal() {
|
||||
if (adapter != null) {
|
||||
return adapter.getInventory();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
return getInstance(pluginName).adapter.getData(property, timeOut);
|
||||
}
|
||||
|
||||
public static Object getInventory(String plugin) {
|
||||
return getInstance(plugin).getInventoryInternal();
|
||||
}
|
||||
|
||||
private List<Map<String, RequestConstraint>> getBaseUpdateConstraintsInternal(
|
||||
Map<String, RequestConstraint> constraints) {
|
||||
if (adapter != null) {
|
||||
return adapter.getBaseUpdateConstraints(constraints);
|
||||
} else {
|
||||
List<Map<String, RequestConstraint>> result = new ArrayList<Map<String, RequestConstraint>>(
|
||||
1);
|
||||
result.add(constraints);
|
||||
return result;
|
||||
}
|
||||
return getInstance(plugin).adapter.getInventory();
|
||||
}
|
||||
|
||||
public static List<Map<String, RequestConstraint>> getBaseUpdateConstraints(
|
||||
|
@ -467,8 +355,8 @@ public class DataCubeContainer {
|
|||
&& pluginRC.getConstraintType() == ConstraintType.EQUALS) {
|
||||
plugin = pluginRC.getConstraintValue();
|
||||
}
|
||||
return getInstance(plugin)
|
||||
.getBaseUpdateConstraintsInternal(constraints);
|
||||
return getInstance(plugin).adapter
|
||||
.getBaseUpdateConstraints(constraints);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,239 @@
|
|||
/**
|
||||
* 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.datastructure;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.raytheon.uf.common.dataplugin.PluginDataObject;
|
||||
import com.raytheon.uf.common.dataquery.requests.RequestConstraint;
|
||||
import com.raytheon.uf.common.dataquery.requests.TimeQueryRequest;
|
||||
import com.raytheon.uf.common.dataquery.requests.TimeQueryRequestSet;
|
||||
import com.raytheon.uf.common.datastorage.Request;
|
||||
import com.raytheon.uf.common.datastorage.records.IDataRecord;
|
||||
import com.raytheon.uf.common.pointdata.PointDataContainer;
|
||||
import com.raytheon.uf.common.time.DataTime;
|
||||
import com.raytheon.uf.viz.core.catalog.LayerProperty;
|
||||
import com.raytheon.uf.viz.core.catalog.ScriptCreator;
|
||||
import com.raytheon.uf.viz.core.comm.Loader;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
import com.raytheon.uf.viz.core.requests.ThriftClient;
|
||||
|
||||
/**
|
||||
* Default implementation of IDataCubeAdapter, function implementations were
|
||||
* moved from DataCubeContainer into here
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Dec 7, 2011 mschenke Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author mschenke
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class DefaultDataCubeAdapter implements IDataCubeAdapter {
|
||||
|
||||
private String pluginName;
|
||||
|
||||
public DefaultDataCubeAdapter(String pluginName) {
|
||||
this.pluginName = pluginName;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.viz.core.datastructure.IDataCubeAdapter#getSupportedPlugins
|
||||
* ()
|
||||
*/
|
||||
@Override
|
||||
public String[] getSupportedPlugins() {
|
||||
return new String[] { pluginName };
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.viz.core.datastructure.IDataCubeAdapter#timeQuery(java
|
||||
* .util.List)
|
||||
*/
|
||||
@Override
|
||||
public List<List<DataTime>> timeQuery(List<TimeQueryRequest> requests)
|
||||
throws VizException {
|
||||
TimeQueryRequestSet set = new TimeQueryRequestSet();
|
||||
set.setRequests(requests.toArray(new TimeQueryRequest[0]));
|
||||
@SuppressWarnings("unchecked")
|
||||
List<List<DataTime>> result = (List<List<DataTime>>) ThriftClient
|
||||
.sendRequest(set);
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.viz.core.datastructure.IDataCubeAdapter#getPoints(java
|
||||
* .lang.String, java.lang.String[], java.util.Map)
|
||||
*/
|
||||
@Override
|
||||
public PointDataContainer getPoints(String plugin, String[] parameters,
|
||||
Map<String, RequestConstraint> queryParams) throws VizException {
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.viz.core.datastructure.IDataCubeAdapter#getPoints(java
|
||||
* .lang.String, java.lang.String[], java.lang.String, java.util.Map)
|
||||
*/
|
||||
@Override
|
||||
public PointDataContainer getPoints(String plugin, String[] parameters,
|
||||
String levelKey, Map<String, RequestConstraint> queryParams)
|
||||
throws VizException {
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.viz.core.datastructure.IDataCubeAdapter#getRecord(com
|
||||
* .raytheon.uf.common.dataplugin.PluginDataObject)
|
||||
*/
|
||||
@Override
|
||||
public IDataRecord[] getRecord(PluginDataObject obj)
|
||||
throws VizDataCubeException {
|
||||
IDataRecord record = null;
|
||||
try {
|
||||
record = CubeUtil.retrieveData(obj, pluginName);
|
||||
} catch (VizException e) {
|
||||
throw new VizDataCubeException("Error retrieving 2D data record.",
|
||||
e);
|
||||
}
|
||||
return new IDataRecord[] { record };
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.viz.core.datastructure.IDataCubeAdapter#getRecord(com
|
||||
* .raytheon.uf.common.dataplugin.PluginDataObject,
|
||||
* com.raytheon.uf.common.datastorage.Request, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public IDataRecord[] getRecord(PluginDataObject obj, Request req,
|
||||
String dataset) throws VizDataCubeException {
|
||||
IDataRecord record = null;
|
||||
try {
|
||||
record = CubeUtil.retrieveData(obj, pluginName, req, dataset);
|
||||
} catch (VizException e) {
|
||||
throw new VizDataCubeException("Error retrieving 2D data record.",
|
||||
e);
|
||||
}
|
||||
return new IDataRecord[] { record };
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.viz.core.datastructure.IDataCubeAdapter#getRecords(java
|
||||
* .util.List, com.raytheon.uf.common.datastorage.Request, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void getRecords(List<PluginDataObject> objs, Request req,
|
||||
String dataset) throws VizDataCubeException {
|
||||
for (PluginDataObject obj : objs) {
|
||||
IDataRecord record = null;
|
||||
try {
|
||||
record = CubeUtil.retrieveData(obj, pluginName, req, dataset);
|
||||
} catch (VizException e) {
|
||||
throw new VizDataCubeException(
|
||||
"Error retrieving 2D grid record.", e);
|
||||
}
|
||||
obj.setMessageData(record);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.viz.core.datastructure.IDataCubeAdapter#getData(com.raytheon
|
||||
* .uf.viz.core.catalog.LayerProperty, int)
|
||||
*/
|
||||
@Override
|
||||
public List<Object> getData(LayerProperty property, int timeOut)
|
||||
throws VizException {
|
||||
String scriptToExecute = ScriptCreator.createScript(property);
|
||||
return Loader.loadScripts(new String[] { scriptToExecute }, timeOut);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.viz.core.datastructure.IDataCubeAdapter#initInventory()
|
||||
*/
|
||||
@Override
|
||||
public void initInventory() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.viz.core.datastructure.IDataCubeAdapter#getInventory()
|
||||
*/
|
||||
@Override
|
||||
public Object getInventory() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.uf.viz.core.datastructure.IDataCubeAdapter#
|
||||
* getBaseUpdateConstraints(java.util.Map)
|
||||
*/
|
||||
@Override
|
||||
public List<Map<String, RequestConstraint>> getBaseUpdateConstraints(
|
||||
Map<String, RequestConstraint> constraints) {
|
||||
List<Map<String, RequestConstraint>> result = new ArrayList<Map<String, RequestConstraint>>(
|
||||
1);
|
||||
result.add(constraints);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
|
@ -145,16 +145,6 @@ public interface IDataCubeAdapter {
|
|||
public List<Object> getData(LayerProperty property, int timeOut)
|
||||
throws VizException;
|
||||
|
||||
/**
|
||||
* A simple method that will create a unique string based on the information
|
||||
* in the PluginDataObject passed in.
|
||||
*
|
||||
* @param pdo
|
||||
* The PDO to generate a unique name from
|
||||
* @return A string unique to that PDO
|
||||
*/
|
||||
public String recordKeyGenerator(PluginDataObject pdo);
|
||||
|
||||
/**
|
||||
* If the inventory for a particular data type is large (for example, Grib),
|
||||
* a call to this method should get a copy of that data type's inventory
|
||||
|
|
|
@ -31,7 +31,22 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
|
||||
|
||||
import org.geotools.coverage.grid.GeneralGridEnvelope;
|
||||
import org.geotools.coverage.grid.GeneralGridGeometry;
|
||||
import org.geotools.coverage.grid.GridGeometry2D;
|
||||
import org.geotools.geometry.GeneralEnvelope;
|
||||
import org.geotools.referencing.CRS;
|
||||
import org.geotools.referencing.operation.DefaultMathTransformFactory;
|
||||
import org.opengis.referencing.FactoryException;
|
||||
import org.opengis.referencing.crs.CoordinateReferenceSystem;
|
||||
import org.opengis.referencing.crs.GeneralDerivedCRS;
|
||||
import org.opengis.referencing.datum.PixelInCell;
|
||||
import org.opengis.referencing.operation.MathTransform;
|
||||
import org.opengis.referencing.operation.TransformException;
|
||||
|
||||
import com.raytheon.uf.common.serialization.adapters.GridGeometryAdapter;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
|
@ -39,6 +54,7 @@ import com.raytheon.uf.common.time.DataTime;
|
|||
import com.raytheon.uf.viz.core.AbstractTimeMatcher;
|
||||
import com.raytheon.uf.viz.core.IDisplayPane;
|
||||
import com.raytheon.uf.viz.core.IDisplayPaneContainer;
|
||||
import com.raytheon.uf.viz.core.IExtent;
|
||||
import com.raytheon.uf.viz.core.VizConstants;
|
||||
import com.raytheon.uf.viz.core.datastructure.LoopProperties;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
|
@ -111,6 +127,19 @@ public abstract class AbstractDescriptor extends ResourceGroup implements
|
|||
/** The frame coordination object */
|
||||
protected IFrameCoordinator frameCoordinator;
|
||||
|
||||
private MathTransform worldToPixel;
|
||||
|
||||
private MathTransform pixelToWorld;
|
||||
|
||||
/** The spatial grid for the descriptor */
|
||||
private GeneralGridGeometry gridGeometry;
|
||||
|
||||
public AbstractDescriptor(GeneralGridGeometry gridGeometry) {
|
||||
this();
|
||||
this.gridGeometry = gridGeometry;
|
||||
init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
|
@ -196,7 +225,8 @@ public abstract class AbstractDescriptor extends ResourceGroup implements
|
|||
protected void preAddListener(ResourcePair rp)
|
||||
throws WrongProjectionException {
|
||||
|
||||
AbstractVizResource resource = rp.getResource();
|
||||
AbstractVizResource<?, AbstractDescriptor> resource = (AbstractVizResource<?, AbstractDescriptor>) rp
|
||||
.getResource();
|
||||
|
||||
resource.setDescriptor(this);
|
||||
|
||||
|
@ -654,6 +684,119 @@ public abstract class AbstractDescriptor extends ResourceGroup implements
|
|||
return frameCoordinator;
|
||||
}
|
||||
|
||||
private void init() {
|
||||
GeneralGridGeometry gridGeometry = getGridGeometry();
|
||||
MathTransform worldToCRS = getWorldToCRSTransform(gridGeometry);
|
||||
if (worldToCRS != null) {
|
||||
try {
|
||||
MathTransform crsToPixel = gridGeometry.getGridToCRS(
|
||||
PixelInCell.CELL_CENTER).inverse();
|
||||
worldToPixel = new DefaultMathTransformFactory()
|
||||
.createConcatenatedTransform(worldToCRS, crsToPixel);
|
||||
pixelToWorld = worldToPixel.inverse();
|
||||
} catch (Exception e) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Error setting up Math Transforms,"
|
||||
+ " this descriptor may not work properly", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.uf.viz.core.drawables.IDescriptor#getCRS()
|
||||
*/
|
||||
@Override
|
||||
public final CoordinateReferenceSystem getCRS() {
|
||||
if (gridGeometry != null && gridGeometry.getEnvelope() != null) {
|
||||
return gridGeometry.getEnvelope().getCoordinateReferenceSystem();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.uf.viz.core.drawables.IDescriptor#getGridGeometry()
|
||||
*/
|
||||
@Override
|
||||
@XmlElement
|
||||
@XmlJavaTypeAdapter(value = GridGeometryAdapter.class)
|
||||
public final GeneralGridGeometry getGridGeometry() {
|
||||
return gridGeometry;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the grid geometry
|
||||
*
|
||||
* @param gridGeometry
|
||||
* the gridGeometry to set
|
||||
* @throws VizException
|
||||
*/
|
||||
public void setGridGeometry(GeneralGridGeometry gridGeometry)
|
||||
throws VizException {
|
||||
this.gridGeometry = gridGeometry;
|
||||
init();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.viz.core.drawables.IDescriptor#pixelToWorld(double[])
|
||||
*/
|
||||
@Override
|
||||
public final double[] pixelToWorld(double[] pixel) {
|
||||
double[] output = new double[3];
|
||||
double[] wpixel = pixel;
|
||||
|
||||
if (pixel.length == 2) {
|
||||
wpixel = new double[] { pixel[0], pixel[1], 0 };
|
||||
}
|
||||
|
||||
if (pixelToWorld != null) {
|
||||
try {
|
||||
pixelToWorld.transform(wpixel, 0, output, 0, 1);
|
||||
} catch (TransformException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
System.arraycopy(wpixel, 0, output, 0, wpixel.length);
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.viz.core.drawables.IDescriptor#worldToPixel(double[])
|
||||
*/
|
||||
@Override
|
||||
public final double[] worldToPixel(double[] world) {
|
||||
double[] output = new double[3];
|
||||
double[] input = world;
|
||||
if (world.length == 2) {
|
||||
input = new double[] { world[0], world[1], 0 };
|
||||
}
|
||||
|
||||
if (worldToPixel != null) {
|
||||
try {
|
||||
worldToPixel.transform(input, 0, output, 0, 1);
|
||||
} catch (TransformException e) {
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
System.arraycopy(input, 0, output, 0, input.length);
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
|
@ -683,4 +826,40 @@ public abstract class AbstractDescriptor extends ResourceGroup implements
|
|||
getFrameCoordinator().changeFrame(loopProperties);
|
||||
}
|
||||
|
||||
protected static GeneralGridGeometry createGridGeometry(IExtent extent,
|
||||
CoordinateReferenceSystem crs) {
|
||||
GeneralEnvelope envelope = new GeneralEnvelope(2);
|
||||
envelope.setRange(0, extent.getMinX(), extent.getMaxX());
|
||||
envelope.setRange(1, extent.getMinY(), extent.getMaxY());
|
||||
envelope.setCoordinateReferenceSystem(crs);
|
||||
return new GridGeometry2D(
|
||||
new GeneralGridEnvelope(new int[] { 0, 0 }, new int[] {
|
||||
(int) extent.getWidth(), (int) extent.getHeight() },
|
||||
false), envelope);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the world to CRS transform used for {@link #worldToPixel(double[])}
|
||||
* and {@link #pixelToWorld(double[])}
|
||||
*
|
||||
* @param gridGeometry
|
||||
* @return The world to gridGeometry CRS transform or null if there is none
|
||||
*/
|
||||
public static MathTransform getWorldToCRSTransform(
|
||||
GeneralGridGeometry gridGeometry) {
|
||||
CoordinateReferenceSystem crs = gridGeometry.getEnvelope()
|
||||
.getCoordinateReferenceSystem();
|
||||
if (crs instanceof GeneralDerivedCRS) {
|
||||
GeneralDerivedCRS projCRS = (GeneralDerivedCRS) crs;
|
||||
CoordinateReferenceSystem worldCRS = projCRS.getBaseCRS();
|
||||
try {
|
||||
return CRS.findMathTransform(worldCRS, crs);
|
||||
} catch (FactoryException e) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Error setting up Math Transforms,"
|
||||
+ " this descriptor may not work properly", e);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -206,8 +206,8 @@ public class ColorMapLoader {
|
|||
ColorMap cm = (ColorMap) SerializationUtil
|
||||
.jaxbUnmarshalFromXmlFile(colorMapFile.getFile()
|
||||
.getAbsolutePath());
|
||||
|
||||
cm.setName(name);
|
||||
cm.setChanged(false);
|
||||
return cm;
|
||||
} else {
|
||||
return null;
|
||||
|
|
|
@ -22,6 +22,8 @@ package com.raytheon.uf.viz.core.drawables;
|
|||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.measure.converter.UnitConverter;
|
||||
import javax.measure.unit.Unit;
|
||||
|
@ -116,7 +118,7 @@ public class ColorMapParameters implements Cloneable, ISerializableObject {
|
|||
|
||||
}
|
||||
|
||||
protected IColorMapParametersListener listener;
|
||||
protected Set<IColorMapParametersListener> listeners = new HashSet<IColorMapParametersListener>();
|
||||
|
||||
/** Units of the colormap parameters (min/max) */
|
||||
protected Unit<?> displayUnit;
|
||||
|
@ -714,13 +716,19 @@ public class ColorMapParameters implements Cloneable, ISerializableObject {
|
|||
}
|
||||
|
||||
private void notifyListener() {
|
||||
if (listener != null) {
|
||||
for (IColorMapParametersListener listener : listeners) {
|
||||
listener.colorMapChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public void setListener(IColorMapParametersListener listener) {
|
||||
this.listener = listener;
|
||||
public void addListener(IColorMapParametersListener listener) {
|
||||
if (listener != null) {
|
||||
listeners.add(listener);
|
||||
}
|
||||
}
|
||||
|
||||
public void removeListener(IColorMapParametersListener listener) {
|
||||
listeners.remove(listener);
|
||||
}
|
||||
|
||||
public void setAlphaMask(byte[] alphaMask) {
|
||||
|
@ -741,8 +749,8 @@ public class ColorMapParameters implements Cloneable, ISerializableObject {
|
|||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
if (listener != null) {
|
||||
return listener.hashCode();
|
||||
if (listeners.size() > 0) {
|
||||
return listeners.hashCode();
|
||||
} else if (colorMap != null) {
|
||||
return colorMap.hashCode();
|
||||
} else {
|
||||
|
|
|
@ -20,6 +20,9 @@
|
|||
|
||||
package com.raytheon.uf.viz.core.drawables;
|
||||
|
||||
import com.raytheon.uf.viz.core.drawables.ext.IImagingExtension;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
|
||||
/**
|
||||
* Describes a generic Image resource. The IImage resource is an interface
|
||||
* handle to an image. The image resource manages the lifecycle of the
|
||||
|
@ -63,6 +66,11 @@ public interface IImage {
|
|||
UNLOADED, STAGED, LOADED, LOADING, FAILED, INVALID
|
||||
};
|
||||
|
||||
/**
|
||||
* Stages any data required for the image to load/draw
|
||||
*/
|
||||
public abstract void stage() throws VizException;
|
||||
|
||||
/**
|
||||
* @return the status
|
||||
*/
|
||||
|
@ -106,4 +114,10 @@ public interface IImage {
|
|||
*/
|
||||
public abstract void setContrast(float contrast);
|
||||
|
||||
/**
|
||||
* Gets the extension class for this image
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public abstract Class<? extends IImagingExtension> getExtensionClass();
|
||||
}
|
|
@ -0,0 +1,143 @@
|
|||
/**
|
||||
* 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;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.raytheon.uf.viz.core.DrawableImage;
|
||||
import com.raytheon.uf.viz.core.IGraphicsTarget;
|
||||
import com.raytheon.uf.viz.core.IGraphicsTarget.RasterMode;
|
||||
import com.raytheon.uf.viz.core.drawables.IImage.Status;
|
||||
import com.raytheon.uf.viz.core.drawables.ext.IImagingExtension;
|
||||
import com.raytheon.uf.viz.core.drawables.ext.TextureLoader;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
|
||||
/**
|
||||
* Support class for rendering images to a target
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Mar 13, 2012 mschenke Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author mschenke
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class ImagingSupport {
|
||||
|
||||
protected static final TextureLoader textureLoader = TextureLoader
|
||||
.getInstance();
|
||||
|
||||
/**
|
||||
* Prepares images for painting by staging and/or targeting the image
|
||||
*
|
||||
* @param target
|
||||
* @param images
|
||||
* @throws VizException
|
||||
*/
|
||||
public static void prepareImages(IGraphicsTarget target,
|
||||
DrawableImage... images) throws VizException {
|
||||
for (DrawableImage di : images) {
|
||||
IImage image = di.getImage();
|
||||
RasterMode mode = di.getMode();
|
||||
|
||||
if (image.getStatus() != Status.LOADED
|
||||
&& image.getStatus() != Status.STAGED) {
|
||||
if (mode == RasterMode.ASYNCHRONOUS) {
|
||||
textureLoader.requestLoad(image);
|
||||
target.setNeedsRefresh(true);
|
||||
} else if (mode == RasterMode.SYNCHRONOUS) {
|
||||
image.stage();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Routes the images to be rendered by their proper extensions, expects
|
||||
* images have already been "prepared" (Status=STAGED)
|
||||
*
|
||||
* @param target
|
||||
* @param paintProps
|
||||
* @param images
|
||||
* @return
|
||||
* @throws VizException
|
||||
*/
|
||||
public static boolean routeImages(IGraphicsTarget target,
|
||||
PaintProperties paintProps, DrawableImage[] images)
|
||||
throws VizException {
|
||||
boolean rval = true;
|
||||
boolean skipped = false;
|
||||
List<DrawableImage> bulk = new ArrayList<DrawableImage>();
|
||||
Class<? extends IImagingExtension> lastExt = null;
|
||||
for (DrawableImage di : images) {
|
||||
IImage image = di.getImage();
|
||||
IImage.Status imageSts = image.getStatus();
|
||||
if (imageSts == IImage.Status.LOADED
|
||||
|| imageSts == IImage.Status.STAGED) {
|
||||
Class<? extends IImagingExtension> imageExt = image
|
||||
.getExtensionClass();
|
||||
if (imageExt.equals(lastExt) == false && bulk.size() > 0) {
|
||||
DrawableImage[] extImages = bulk
|
||||
.toArray(new DrawableImage[bulk.size()]);
|
||||
// Render what we have
|
||||
IImagingExtension impl = target.getExtension(lastExt);
|
||||
rval &= impl.drawRasters(paintProps, extImages);
|
||||
bulk.clear();
|
||||
}
|
||||
|
||||
bulk.add(di);
|
||||
lastExt = imageExt;
|
||||
} else {
|
||||
skipped = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (bulk.size() > 0) {
|
||||
// Render what is left
|
||||
IImagingExtension impl = target.getExtension(lastExt);
|
||||
rval &= impl.drawRasters(paintProps,
|
||||
bulk.toArray(new DrawableImage[bulk.size()]));
|
||||
}
|
||||
|
||||
return rval & skipped;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares the images, then routes them for rendering
|
||||
*
|
||||
* @param paintProps
|
||||
* @param images
|
||||
* @return
|
||||
*/
|
||||
public static boolean drawRasters(IGraphicsTarget target,
|
||||
PaintProperties paintProps, DrawableImage[] images)
|
||||
throws VizException {
|
||||
prepareImages(target, images);
|
||||
return routeImages(target, paintProps, images);
|
||||
}
|
||||
}
|
|
@ -1,66 +0,0 @@
|
|||
package com.raytheon.uf.viz.core.drawables;
|
||||
|
||||
import org.eclipse.swt.graphics.RGB;
|
||||
|
||||
public class SingleColorImage implements IImage {
|
||||
|
||||
private IImage image = null;
|
||||
|
||||
private RGB color = null;
|
||||
|
||||
public IImage getWrappedImage() {
|
||||
return image;
|
||||
}
|
||||
|
||||
public void setWrappedImage(IImage image) {
|
||||
this.image = image;
|
||||
}
|
||||
|
||||
public void setColor(RGB color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public RGB getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public SingleColorImage(IImage image) {
|
||||
this.image = image;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Status getStatus() {
|
||||
return image.getStatus();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInterpolated(boolean isInterpolated) {
|
||||
image.setInterpolated(isInterpolated);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
image.dispose();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth() {
|
||||
return image.getWidth();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return image.getHeight();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBrightness(float brightness) {
|
||||
image.setBrightness(brightness);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setContrast(float contrast) {
|
||||
image.setContrast(contrast);
|
||||
}
|
||||
|
||||
}
|
|
@ -40,15 +40,22 @@ import com.raytheon.uf.viz.core.IGraphicsTarget;
|
|||
*/
|
||||
public abstract class GraphicsExtension<T extends IGraphicsTarget> {
|
||||
|
||||
public static enum Compatibilty {
|
||||
INCOMPATIBLE(-1), GENERIC(0), TARGET_COMPATIBLE(1000), ENHANCED_TARGET_COMPATIBLE(
|
||||
2000);
|
||||
/**
|
||||
* Interface that other interfaces should extend if they want to be used as
|
||||
* a graphics extension
|
||||
*/
|
||||
public static interface IGraphicsExtensionInterface {
|
||||
|
||||
public int value;
|
||||
}
|
||||
|
||||
private Compatibilty(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
public static class Compatibilty {
|
||||
public static final int INCOMPATIBLE = -1;
|
||||
|
||||
public static final int GENERIC = 0;
|
||||
|
||||
public static final int TARGET_COMPATIBLE = 1000;
|
||||
|
||||
public static final int ENHANCED_TARGET_COMPATIBLE = 2000;
|
||||
}
|
||||
|
||||
protected T target;
|
||||
|
@ -69,12 +76,19 @@ public abstract class GraphicsExtension<T extends IGraphicsTarget> {
|
|||
public final int setTarget(IGraphicsTarget target) {
|
||||
try {
|
||||
this.target = (T) target;
|
||||
return getCompatibilityValue(this.target);
|
||||
} catch (ClassCastException e) {
|
||||
return Compatibilty.INCOMPATIBLE.value;
|
||||
this.target = null;
|
||||
return Compatibilty.INCOMPATIBLE;
|
||||
}
|
||||
return getCompatibilityValue(this.target);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the target compability value.
|
||||
*
|
||||
* @param target
|
||||
* @return
|
||||
*/
|
||||
public abstract int getCompatibilityValue(T target);
|
||||
|
||||
/**
|
||||
|
|
|
@ -15,6 +15,7 @@ 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.IGraphicsTarget;
|
||||
import com.raytheon.uf.viz.core.drawables.ext.GraphicsExtension.IGraphicsExtensionInterface;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
|
||||
public class GraphicsExtensionManager {
|
||||
|
@ -67,8 +68,8 @@ public class GraphicsExtensionManager {
|
|||
* @return
|
||||
* @throws VizException
|
||||
*/
|
||||
public synchronized <T> T getExtension(Class<T> extensionClass)
|
||||
throws VizException {
|
||||
public synchronized <T extends IGraphicsExtensionInterface> T getExtension(
|
||||
Class<T> extensionClass) throws VizException {
|
||||
if (cached.containsKey(extensionClass)) {
|
||||
return extensionClass.cast(cached.get(extensionClass));
|
||||
}
|
||||
|
@ -76,10 +77,14 @@ public class GraphicsExtensionManager {
|
|||
int bestVal = -1;
|
||||
for (Class<?> eClass : extensions) {
|
||||
if (extensionClass.isAssignableFrom(eClass)) {
|
||||
GraphicsExtension<?> graphicsExt;
|
||||
try {
|
||||
graphicsExt = GraphicsExtension.class.cast(eClass
|
||||
GraphicsExtension<?> graphicsExt = GraphicsExtension.class.cast(eClass
|
||||
.newInstance());
|
||||
int val = graphicsExt.setTarget(target);
|
||||
if (val > bestVal) {
|
||||
bestVal = val;
|
||||
bestExt = extensionClass.cast(graphicsExt);
|
||||
}
|
||||
} catch (InstantiationException e) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
e.getLocalizedMessage(), e);
|
||||
|
@ -89,11 +94,6 @@ public class GraphicsExtensionManager {
|
|||
e.getLocalizedMessage(), e);
|
||||
continue;
|
||||
}
|
||||
int val = graphicsExt.setTarget(target);
|
||||
if (val > bestVal) {
|
||||
bestVal = val;
|
||||
bestExt = extensionClass.cast(graphicsExt);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (bestExt != null) {
|
||||
|
|
|
@ -17,24 +17,23 @@
|
|||
* 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.uf.viz.core.drawables.ext;
|
||||
|
||||
import com.raytheon.uf.viz.core.drawables.IImage;
|
||||
import com.raytheon.uf.viz.core.DrawableImage;
|
||||
import com.raytheon.uf.viz.core.drawables.PaintProperties;
|
||||
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.glsl.AbstractShaderLoader;
|
||||
import com.raytheon.viz.core.gl.glsl.GLShaderProgram;
|
||||
|
||||
/**
|
||||
* TODO Add Description
|
||||
* Interface extensions that return IImage objects should implement
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Sep 20, 2010 mschenke Initial creation
|
||||
* Dec 15, 2011 mschenke Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -42,22 +41,17 @@ import com.raytheon.viz.core.gl.glsl.GLShaderProgram;
|
|||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class CompReflShaderLoader extends AbstractShaderLoader {
|
||||
public interface IImagingExtension extends IGraphicsExtensionInterface {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
/**
|
||||
* Draw the images passed in
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.viz.core.gl.glsl.IShaderLoader#loadData(com.raytheon.viz
|
||||
* .core.gl.IGLTarget, com.raytheon.viz.core.gl.glsl.GLShaderProgram,
|
||||
* com.raytheon.uf.viz.core.drawables.IImage,
|
||||
* com.raytheon.uf.viz.core.drawables.PaintProperties)
|
||||
* @param paintProps
|
||||
* @param images
|
||||
* @return whether all images were drawn or not
|
||||
* @throws VizException
|
||||
*/
|
||||
@Override
|
||||
public void loadData(IGLTarget target, GLShaderProgram program,
|
||||
IImage image, PaintProperties paintProps) throws VizException {
|
||||
// load radar data to GL_TEXTURE0 (bound in drawRaster)
|
||||
program.setUniform("radarData", 0);
|
||||
}
|
||||
public boolean drawRasters(PaintProperties paintProps,
|
||||
DrawableImage... images) throws VizException;
|
||||
|
||||
}
|
|
@ -4,9 +4,11 @@ import java.nio.Buffer;
|
|||
|
||||
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.IGraphicsExtensionInterface;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
|
||||
public interface IOffscreenRenderingExtension {
|
||||
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.
|
||||
|
|
|
@ -17,52 +17,49 @@
|
|||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package com.raytheon.uf.viz.core.drawables.ext;
|
||||
|
||||
package com.raytheon.viz.core.gl.glsl;
|
||||
import java.awt.image.RenderedImage;
|
||||
|
||||
import org.eclipse.swt.graphics.RGB;
|
||||
|
||||
import com.raytheon.uf.viz.core.drawables.IImage;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
|
||||
/**
|
||||
* Define common interface for vertex and fragement shaders.
|
||||
* Extension for creating images that should be mapped to a single color
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
*
|
||||
* Dec 15, 2011 mschenke Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author estrabal
|
||||
* @author mschenke
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
import com.raytheon.uf.viz.core.drawables.IImage;
|
||||
import com.raytheon.uf.viz.core.drawables.PaintProperties;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
import com.raytheon.viz.core.gl.IGLTarget;
|
||||
public interface ISingleColorImageExtension extends IImagingExtension {
|
||||
|
||||
public interface IShaderLoader {
|
||||
public static interface ISingleColorImage extends IImage {
|
||||
|
||||
public void setColor(RGB color);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct an ISingleColorImage image that maps the image passed into to
|
||||
* the single color value
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public abstract String getName();
|
||||
|
||||
/**
|
||||
*
|
||||
* @param name
|
||||
*/
|
||||
public abstract void setName(String name);
|
||||
|
||||
/**
|
||||
* load shader variables using IImage and PaintProperties
|
||||
*
|
||||
* @param target
|
||||
* @param program
|
||||
* @param image
|
||||
* @param paintProps
|
||||
* @param color
|
||||
* @return
|
||||
* @throws VizException
|
||||
*/
|
||||
public abstract void loadData(IGLTarget target, GLShaderProgram program,
|
||||
IImage image, PaintProperties paintProps) throws VizException;
|
||||
public ISingleColorImage constructImage(RenderedImage image, RGB color);
|
||||
|
||||
}
|
|
@ -0,0 +1,129 @@
|
|||
/**
|
||||
* 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;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.ui.services.IDisposable;
|
||||
|
||||
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.Activator;
|
||||
import com.raytheon.uf.viz.core.drawables.IImage;
|
||||
import com.raytheon.uf.viz.core.jobs.JobPool;
|
||||
|
||||
/**
|
||||
* Class that loads data for AbstractGLImages asynchronously
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 7/1/06 chammack Initial Creation.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author chammack
|
||||
*
|
||||
*/
|
||||
public class TextureLoader {
|
||||
|
||||
private static final IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(TextureLoader.class);
|
||||
|
||||
/** The instance */
|
||||
private static TextureLoader instance;
|
||||
|
||||
private JobPool loaderPool;
|
||||
|
||||
private List<IImage> texturesToLoad;
|
||||
|
||||
/**
|
||||
* Get the currently running instance of the texture loader
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static synchronized TextureLoader getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new TextureLoader();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use getInstance() instead of constructor
|
||||
*
|
||||
*/
|
||||
private TextureLoader() {
|
||||
this.texturesToLoad = new ArrayList<IImage>();
|
||||
this.loaderPool = new JobPool("Texture Loader", Runtime.getRuntime()
|
||||
.availableProcessors(), true);
|
||||
// Make sure we get shutdown properly
|
||||
Activator.getDefault().registerDisposable(new IDisposable() {
|
||||
@Override
|
||||
public void dispose() {
|
||||
shutdown();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Request an image to be loaded
|
||||
*
|
||||
* @param img
|
||||
* the image
|
||||
*/
|
||||
public void requestLoad(final IImage img) {
|
||||
if (!texturesToLoad.contains(img)) {
|
||||
texturesToLoad.add(img);
|
||||
loaderPool.schedule(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
try {
|
||||
img.stage();
|
||||
} catch (Throwable t) {
|
||||
statusHandler.handle(
|
||||
Priority.PROBLEM,
|
||||
"Error staging texture: "
|
||||
+ t.getLocalizedMessage(), t);
|
||||
}
|
||||
} finally {
|
||||
texturesToLoad.remove(img);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Request the job to be shut down
|
||||
*
|
||||
*/
|
||||
public void shutdown() {
|
||||
loaderPool.cancel();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,240 @@
|
|||
/**
|
||||
* 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.colormap;
|
||||
|
||||
import java.awt.image.RenderedImage;
|
||||
|
||||
import com.raytheon.uf.viz.core.IGraphicsTarget;
|
||||
import com.raytheon.uf.viz.core.data.IColorMapDataRetrievalCallback;
|
||||
import com.raytheon.uf.viz.core.data.IColorMapDataRetrievalCallback.ColorMapData;
|
||||
import com.raytheon.uf.viz.core.data.IRenderedImageCallback;
|
||||
import com.raytheon.uf.viz.core.data.prep.Colormapper;
|
||||
import com.raytheon.uf.viz.core.drawables.ColorMapParameters;
|
||||
import com.raytheon.uf.viz.core.drawables.IColorMapParametersListener;
|
||||
import com.raytheon.uf.viz.core.drawables.IColormappedImage;
|
||||
import com.raytheon.uf.viz.core.drawables.IImage;
|
||||
import com.raytheon.uf.viz.core.drawables.ext.IImagingExtension;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
|
||||
/**
|
||||
* General colormapped image, regenerates image if parameters change
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Dec 16, 2011 mschenke Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author mschenke
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class ColormappedImage implements IColormappedImage,
|
||||
IRenderedImageCallback, IColorMapParametersListener {
|
||||
|
||||
private IImage image;
|
||||
|
||||
private IColorMapDataRetrievalCallback callback;
|
||||
|
||||
private ColorMapParameters parameters;
|
||||
|
||||
public ColormappedImage(IGraphicsTarget target,
|
||||
IColorMapDataRetrievalCallback callback,
|
||||
ColorMapParameters parameters) {
|
||||
this.callback = callback;
|
||||
setColorMapParameters(parameters);
|
||||
image = target.initializeRaster(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the wrapped image for the colormapped image
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public IImage getWrappedImage() {
|
||||
return image;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.uf.viz.core.drawables.IImage#getStatus()
|
||||
*/
|
||||
@Override
|
||||
public Status getStatus() {
|
||||
return image.getStatus();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.uf.viz.core.drawables.IImage#setInterpolated(boolean)
|
||||
*/
|
||||
@Override
|
||||
public void setInterpolated(boolean isInterpolated) {
|
||||
image.setInterpolated(isInterpolated);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.uf.viz.core.drawables.IImage#dispose()
|
||||
*/
|
||||
@Override
|
||||
public void dispose() {
|
||||
if (image != null) {
|
||||
image.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.uf.viz.core.drawables.IImage#getWidth()
|
||||
*/
|
||||
@Override
|
||||
public int getWidth() {
|
||||
return image.getWidth();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.uf.viz.core.drawables.IImage#getHeight()
|
||||
*/
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return image.getHeight();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.uf.viz.core.drawables.IImage#setBrightness(float)
|
||||
*/
|
||||
@Override
|
||||
public void setBrightness(float brightness) {
|
||||
image.setBrightness(brightness);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.uf.viz.core.drawables.IImage#setContrast(float)
|
||||
*/
|
||||
@Override
|
||||
public void setContrast(float contrast) {
|
||||
image.setContrast(contrast);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.uf.viz.core.drawables.IImage#getExtensionClass()
|
||||
*/
|
||||
@Override
|
||||
public Class<? extends IImagingExtension> getExtensionClass() {
|
||||
return GeneralColormappedImageExtension.class;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.viz.core.drawables.IColormappedImage#getColorMapParameters
|
||||
* ()
|
||||
*/
|
||||
@Override
|
||||
public ColorMapParameters getColorMapParameters() {
|
||||
return parameters;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.viz.core.drawables.IColormappedImage#setColorMapParameters
|
||||
* (com.raytheon.uf.viz.core.drawables.ColorMapParameters)
|
||||
*/
|
||||
@Override
|
||||
public void setColorMapParameters(ColorMapParameters params) {
|
||||
if (params != this.parameters) {
|
||||
if (this.parameters != null) {
|
||||
this.parameters.removeListener(this);
|
||||
}
|
||||
this.parameters = params;
|
||||
if (this.parameters != null) {
|
||||
this.parameters.addListener(this);
|
||||
}
|
||||
dispose();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.uf.viz.core.drawables.IColormappedImage#getValue(int,
|
||||
* int)
|
||||
*/
|
||||
@Override
|
||||
public double getValue(int x, int y) {
|
||||
return Double.NaN;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.uf.viz.core.data.IRenderedImageCallback#getImage()
|
||||
*/
|
||||
@Override
|
||||
public RenderedImage getImage() throws VizException {
|
||||
if (parameters == null || parameters.getColorMap() == null) {
|
||||
return null;
|
||||
}
|
||||
ColorMapData colorMapData = callback.getColorMapData();
|
||||
return Colormapper.colorMap(colorMapData, parameters);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.uf.viz.core.drawables.IColorMapParametersListener#
|
||||
* colorMapChanged()
|
||||
*/
|
||||
@Override
|
||||
public void colorMapChanged() {
|
||||
dispose();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.uf.viz.core.drawables.IImage#stage()
|
||||
*/
|
||||
@Override
|
||||
public void stage() throws VizException {
|
||||
image.stage();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,81 +0,0 @@
|
|||
/**
|
||||
* 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.colormap;
|
||||
|
||||
import java.awt.image.RenderedImage;
|
||||
|
||||
import com.raytheon.uf.viz.core.data.IColorMapDataRetrievalCallback;
|
||||
import com.raytheon.uf.viz.core.data.IColorMapDataRetrievalCallback.ColorMapData;
|
||||
import com.raytheon.uf.viz.core.data.IRenderedImageCallback;
|
||||
import com.raytheon.uf.viz.core.data.prep.Colormapper;
|
||||
import com.raytheon.uf.viz.core.drawables.ColorMapParameters;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
|
||||
/**
|
||||
* General {@link IRenderedImageCallback} that takes a
|
||||
* {@link IColorMapDataRetrievalCallback} and {@link ColorMapParameters} and
|
||||
* will colormap the data returned from the callback into a
|
||||
* {@link RenderedImage}
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Nov 22, 2011 mschenke Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author mschenke
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class ColormappedRenderedImageCallback implements IRenderedImageCallback {
|
||||
|
||||
private IColorMapDataRetrievalCallback callback;
|
||||
|
||||
private ColorMapParameters parameters;
|
||||
|
||||
/**
|
||||
* Construct a ColormappedRenderedImageCallback for the colormap data
|
||||
* callback and parameters
|
||||
*
|
||||
* @param dataCallback
|
||||
* @param parameters
|
||||
*/
|
||||
public ColormappedRenderedImageCallback(
|
||||
IColorMapDataRetrievalCallback dataCallback,
|
||||
ColorMapParameters parameters) {
|
||||
this.callback = dataCallback;
|
||||
this.parameters = parameters;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.uf.viz.core.data.IRenderedImageCallback#getImage()
|
||||
*/
|
||||
@Override
|
||||
public RenderedImage getImage() throws VizException {
|
||||
ColorMapData colorMapData = callback.getColorMapData();
|
||||
return Colormapper.colorMap(colorMapData, parameters);
|
||||
}
|
||||
}
|
|
@ -19,11 +19,17 @@
|
|||
**/
|
||||
package com.raytheon.uf.viz.core.drawables.ext.colormap;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.raytheon.uf.viz.core.DrawableImage;
|
||||
import com.raytheon.uf.viz.core.IGraphicsTarget;
|
||||
import com.raytheon.uf.viz.core.data.IColorMapDataRetrievalCallback;
|
||||
import com.raytheon.uf.viz.core.drawables.ColorMapParameters;
|
||||
import com.raytheon.uf.viz.core.drawables.IImage;
|
||||
import com.raytheon.uf.viz.core.drawables.IColormappedImage;
|
||||
import com.raytheon.uf.viz.core.drawables.PaintProperties;
|
||||
import com.raytheon.uf.viz.core.drawables.ext.GraphicsExtension;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
|
||||
/**
|
||||
* General colormapped image extension. Uses
|
||||
|
@ -56,10 +62,10 @@ public class GeneralColormappedImageExtension extends
|
|||
* com.raytheon.uf.viz.core.drawables.ColorMapParameters)
|
||||
*/
|
||||
@Override
|
||||
public IImage initializeRaster(IColorMapDataRetrievalCallback dataCallback,
|
||||
public IColormappedImage initializeRaster(
|
||||
IColorMapDataRetrievalCallback dataCallback,
|
||||
ColorMapParameters colorMapParameters) {
|
||||
return target.initializeRaster(new ColormappedRenderedImageCallback(
|
||||
dataCallback, colorMapParameters));
|
||||
return new ColormappedImage(target, dataCallback, colorMapParameters);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -70,7 +76,29 @@ public class GeneralColormappedImageExtension extends
|
|||
*/
|
||||
@Override
|
||||
public int getCompatibilityValue(IGraphicsTarget target) {
|
||||
return Compatibilty.GENERIC.value;
|
||||
return Compatibilty.GENERIC;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.viz.core.drawables.ext.IImagingExtension#drawRasters(
|
||||
* com.raytheon.uf.viz.core.drawables.PaintProperties,
|
||||
* com.raytheon.uf.viz.core.DrawableImage[])
|
||||
*/
|
||||
@Override
|
||||
public boolean drawRasters(PaintProperties paintProps,
|
||||
DrawableImage... images) throws VizException {
|
||||
List<DrawableImage> renderables = new ArrayList<DrawableImage>();
|
||||
for (DrawableImage di : images) {
|
||||
if (di.getImage() instanceof ColormappedImage) {
|
||||
renderables.add(new DrawableImage(((ColormappedImage) di
|
||||
.getImage()).getWrappedImage(), di.getCoverage()));
|
||||
}
|
||||
}
|
||||
return target.drawRasters(paintProps,
|
||||
renderables.toArray(new DrawableImage[renderables.size()]));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.eclipse.swt.graphics.RGB;
|
|||
|
||||
import com.raytheon.uf.viz.core.drawables.IDescriptor;
|
||||
import com.raytheon.uf.viz.core.drawables.IShadedShape;
|
||||
import com.raytheon.uf.viz.core.drawables.ext.GraphicsExtension.IGraphicsExtensionInterface;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
import com.vividsolutions.jts.geom.Geometry;
|
||||
import com.vividsolutions.jts.geom.LineString;
|
||||
|
@ -53,7 +54,8 @@ import com.vividsolutions.jts.geom.LineString;
|
|||
* @author bsteffen
|
||||
* @version 1.0
|
||||
*/
|
||||
public interface IColormapShadedShapeExtension {
|
||||
public interface IColormapShadedShapeExtension extends
|
||||
IGraphicsExtensionInterface {
|
||||
|
||||
public interface IColormapShadedShape {
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ package com.raytheon.uf.viz.core.drawables.ext.colormap;
|
|||
import com.raytheon.uf.viz.core.data.IColorMapDataRetrievalCallback;
|
||||
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.IImagingExtension;
|
||||
|
||||
/**
|
||||
* Extension for creating {@link IColormappedImage} objects
|
||||
|
@ -41,7 +41,7 @@ import com.raytheon.uf.viz.core.drawables.IImage;
|
|||
* @version 1.0
|
||||
*/
|
||||
|
||||
public interface IColormappedImageExtension {
|
||||
public interface IColormappedImageExtension extends IImagingExtension {
|
||||
|
||||
/**
|
||||
* Initializes an IColormappedImage given the dataCallback and colormap
|
||||
|
@ -51,6 +51,7 @@ public interface IColormappedImageExtension {
|
|||
* @param colorMapParameters
|
||||
* @return
|
||||
*/
|
||||
public IImage initializeRaster(IColorMapDataRetrievalCallback dataCallback,
|
||||
public IColormappedImage initializeRaster(
|
||||
IColorMapDataRetrievalCallback dataCallback,
|
||||
ColorMapParameters colorMapParameters);
|
||||
}
|
||||
|
|
|
@ -19,7 +19,12 @@
|
|||
**/
|
||||
package com.raytheon.uf.viz.core.map;
|
||||
|
||||
import org.geotools.coverage.grid.GeneralGridGeometry;
|
||||
import org.geotools.coverage.grid.GridGeometry2D;
|
||||
|
||||
import com.raytheon.uf.viz.core.IMesh;
|
||||
import com.raytheon.uf.viz.core.drawables.IDescriptor;
|
||||
import com.raytheon.uf.viz.core.drawables.ext.GraphicsExtension.IGraphicsExtensionInterface;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
|
||||
/**
|
||||
|
@ -39,17 +44,31 @@ import com.raytheon.uf.viz.core.exception.VizException;
|
|||
* @version 1.0
|
||||
*/
|
||||
|
||||
public interface IMapMeshExtension {
|
||||
public interface IMapMeshExtension extends IGraphicsExtensionInterface {
|
||||
|
||||
/**
|
||||
* Create a mesh
|
||||
*
|
||||
* @param descriptor
|
||||
* Constructs a mesh for mapping the imageGeometry onto the targetGeometry
|
||||
*
|
||||
* @param imageGeometry
|
||||
* @param targetGeometry
|
||||
* @return
|
||||
* @throws VizException
|
||||
*/
|
||||
public abstract IMesh constructMesh(IMapDescriptor descriptor)
|
||||
throws VizException;
|
||||
public abstract IMesh constructMesh(GridGeometry2D imageGeometry,
|
||||
GeneralGridGeometry targetGeometry) throws VizException;
|
||||
|
||||
/**
|
||||
* Convenient method for constructing a mesh for mapping the imageGeometry
|
||||
* onto the targetDescriptor. Same as calling
|
||||
* {@link #constructMesh(GridGeometry2D, GeneralGridGeometry)} passing in
|
||||
* target.getGridGeometry()
|
||||
*
|
||||
* @param imageGeometry
|
||||
* @param targetDescriptor
|
||||
* @return
|
||||
* @throws VizException
|
||||
*/
|
||||
public abstract IMesh constructMesh(GridGeometry2D imageGeometry,
|
||||
IDescriptor targetDescriptor) throws VizException;
|
||||
|
||||
}
|
||||
|
|
|
@ -26,9 +26,7 @@ import java.util.ArrayList;
|
|||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
|
||||
|
||||
import org.eclipse.swt.graphics.RGB;
|
||||
import org.geotools.coverage.grid.GeneralGridEnvelope;
|
||||
|
@ -36,23 +34,16 @@ import org.geotools.coverage.grid.GeneralGridGeometry;
|
|||
import org.geotools.coverage.grid.GridGeometry2D;
|
||||
import org.geotools.geometry.DirectPosition2D;
|
||||
import org.geotools.geometry.GeneralEnvelope;
|
||||
import org.geotools.referencing.CRS;
|
||||
import org.geotools.referencing.GeodeticCalculator;
|
||||
import org.geotools.referencing.crs.DefaultGeocentricCRS;
|
||||
import org.geotools.referencing.crs.DefaultGeographicCRS;
|
||||
import org.geotools.referencing.operation.DefaultMathTransformFactory;
|
||||
import org.opengis.geometry.DirectPosition;
|
||||
import org.opengis.referencing.FactoryException;
|
||||
import org.opengis.referencing.crs.CoordinateReferenceSystem;
|
||||
import org.opengis.referencing.datum.PixelInCell;
|
||||
import org.opengis.referencing.operation.MathTransform;
|
||||
import org.opengis.referencing.operation.MathTransformFactory;
|
||||
import org.opengis.referencing.operation.TransformException;
|
||||
|
||||
import com.raytheon.uf.common.geospatial.CRSCache;
|
||||
import com.raytheon.uf.common.geospatial.MapUtil;
|
||||
import com.raytheon.uf.common.serialization.ISerializableObject;
|
||||
import com.raytheon.uf.common.serialization.adapters.GridGeometryAdapter;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
|
@ -196,24 +187,12 @@ public class MapDescriptor extends AbstractDescriptor implements
|
|||
return gridGeom;
|
||||
}
|
||||
|
||||
/** The transform from lat/lon to the current CRS */
|
||||
protected MathTransform coordinateTransform;
|
||||
|
||||
/** The transform from the current CRS to lat/lon */
|
||||
protected MathTransform inverseCoordinateTransform;
|
||||
|
||||
/** The mapping from grid to coordinate */
|
||||
protected MathTransform mapToCoordinateTransform;
|
||||
|
||||
/** The mapping from coordinate to grid */
|
||||
protected MathTransform coordinateToMapTransform;
|
||||
|
||||
/** The mapping from wgs84 to grid */
|
||||
protected MathTransform wgsToGridTransform;
|
||||
|
||||
/** The mapping from grid to wgs84 */
|
||||
protected MathTransform gridToWGSTransform;
|
||||
|
||||
/** The time in ms that the last blink state was used */
|
||||
protected long timeLastBlink;
|
||||
|
||||
|
@ -229,9 +208,6 @@ public class MapDescriptor extends AbstractDescriptor implements
|
|||
*/
|
||||
protected int mapWidth;
|
||||
|
||||
/** The geospatial descriptor for the grid */
|
||||
protected GeneralGridGeometry gridGeometry;
|
||||
|
||||
/** elevation exaggeration */
|
||||
protected double elevationExageration = 0;
|
||||
|
||||
|
@ -242,8 +218,6 @@ public class MapDescriptor extends AbstractDescriptor implements
|
|||
LAT_LON_FORMATTER.setMaximumFractionDigits(2);
|
||||
}
|
||||
|
||||
private String cloudSourceName;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
|
@ -274,49 +248,26 @@ public class MapDescriptor extends AbstractDescriptor implements
|
|||
*
|
||||
*/
|
||||
public MapDescriptor(GeneralGridGeometry gridGeometry) throws VizException {
|
||||
super();
|
||||
|
||||
this.gridGeometry = gridGeometry;
|
||||
super(gridGeometry);
|
||||
init();
|
||||
}
|
||||
|
||||
protected void init() throws VizException {
|
||||
MathTransformFactory mtf = new DefaultMathTransformFactory();
|
||||
|
||||
try {
|
||||
|
||||
mapToCoordinateTransform = this.gridGeometry
|
||||
GeneralGridGeometry gridGeometry = getGridGeometry();
|
||||
mapToCoordinateTransform = gridGeometry
|
||||
.getGridToCRS(PixelInCell.CELL_CENTER);
|
||||
coordinateToMapTransform = mapToCoordinateTransform.inverse();
|
||||
CoordinateReferenceSystem descriptorCRS = this.gridGeometry
|
||||
.getCoordinateReferenceSystem();
|
||||
if (descriptorCRS.toWKT().equals(
|
||||
DefaultGeocentricCRS.CARTESIAN.toWKT())) {
|
||||
inverseCoordinateTransform = CRS.findMathTransform(
|
||||
descriptorCRS, DefaultGeographicCRS.WGS84_3D);
|
||||
|
||||
coordinateTransform = inverseCoordinateTransform.inverse();
|
||||
|
||||
} else {
|
||||
inverseCoordinateTransform = CRSCache.getInstance()
|
||||
.getTransformToLatLon(descriptorCRS);
|
||||
coordinateTransform = inverseCoordinateTransform.inverse();
|
||||
}
|
||||
|
||||
wgsToGridTransform = mtf.createConcatenatedTransform(
|
||||
coordinateTransform, coordinateToMapTransform);
|
||||
gridToWGSTransform = mtf.createConcatenatedTransform(
|
||||
mapToCoordinateTransform, inverseCoordinateTransform);
|
||||
|
||||
CoordinateReferenceSystem crs = this.gridGeometry
|
||||
CoordinateReferenceSystem crs = gridGeometry
|
||||
.getCoordinateReferenceSystem();
|
||||
|
||||
DirectPosition s1, d1, s2, d2;
|
||||
if (crs.getCoordinateSystem().getDimension() == 2) {
|
||||
double centerX = (this.gridGeometry.getGridRange().getLow(0) + this.gridGeometry
|
||||
double centerX = (gridGeometry.getGridRange().getLow(0) + gridGeometry
|
||||
.getGridRange().getHigh(0)) / 2;
|
||||
|
||||
double centerY = (this.gridGeometry.getGridRange().getLow(1) + this.gridGeometry
|
||||
double centerY = (gridGeometry.getGridRange().getLow(1) + gridGeometry
|
||||
.getGridRange().getHigh(1)) / 2;
|
||||
|
||||
s1 = new DirectPosition2D(centerX, centerY);
|
||||
|
@ -367,43 +318,6 @@ public class MapDescriptor extends AbstractDescriptor implements
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.viz.core.drawables.IDescriptor#pixelToWorld(double[])
|
||||
*/
|
||||
@Override
|
||||
public double[] pixelToWorld(final double[] pixel) {
|
||||
// if (pixel[0] < 1.0)
|
||||
// pixel[0] = 1;
|
||||
//
|
||||
// if (pixel[0] > theWorldWidth - 1.0)
|
||||
// pixel[0] = theWorldWidth - 1.0;
|
||||
//
|
||||
// if (pixel[1] < 1.0)
|
||||
// pixel[1] = 1;
|
||||
//
|
||||
// if (pixel[1] > theWorldHeight - 1.0)
|
||||
// pixel[1] = theWorldHeight;
|
||||
|
||||
double[] output = new double[3];
|
||||
double[] wpixel = pixel;
|
||||
|
||||
if (pixel.length == 2) {
|
||||
wpixel = new double[] { pixel[0], pixel[1], 0 };
|
||||
}
|
||||
|
||||
try {
|
||||
gridToWGSTransform.transform(wpixel, 0, output, 0, 1);
|
||||
} catch (TransformException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
|
@ -417,7 +331,7 @@ public class MapDescriptor extends AbstractDescriptor implements
|
|||
if (crs == MapUtil.LATLON_PROJECTION) {
|
||||
return pixelToWorld(pixel);
|
||||
} else if (!crs.getName().equals(
|
||||
this.gridGeometry.getCoordinateReferenceSystem().getName())) {
|
||||
getGridGeometry().getCoordinateReferenceSystem().getName())) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -431,33 +345,6 @@ public class MapDescriptor extends AbstractDescriptor implements
|
|||
return output2;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.viz.core.drawables.IDescriptor#worldToPixel(double[])
|
||||
*/
|
||||
@Override
|
||||
public double[] worldToPixel(double[] world) {
|
||||
|
||||
double[] output = new double[3];
|
||||
|
||||
double[] input = null;
|
||||
if (world.length == 2) {
|
||||
input = new double[] { world[0], world[1], 0 };
|
||||
} else {
|
||||
input = world;
|
||||
}
|
||||
|
||||
try {
|
||||
wgsToGridTransform.transform(input, 0, output, 0, 1);
|
||||
} catch (TransformException e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
|
@ -466,11 +353,10 @@ public class MapDescriptor extends AbstractDescriptor implements
|
|||
*/
|
||||
@Override
|
||||
public double[] worldToPixel(double[] pixel, CoordinateReferenceSystem crs) {
|
||||
|
||||
if (crs == MapUtil.LATLON_PROJECTION) {
|
||||
return worldToPixel(pixel);
|
||||
} else if (!crs.getName().equals(
|
||||
this.gridGeometry.getCoordinateReferenceSystem().getName())) {
|
||||
getGridGeometry().getCoordinateReferenceSystem().getName())) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -618,18 +504,6 @@ public class MapDescriptor extends AbstractDescriptor implements
|
|||
return pc;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.uf.viz.core.map.IMapDescriptor#getMapData()
|
||||
*/
|
||||
@Override
|
||||
@XmlElement
|
||||
@XmlJavaTypeAdapter(value = GridGeometryAdapter.class)
|
||||
public GeneralGridGeometry getGridGeometry() {
|
||||
return this.gridGeometry;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
|
@ -656,29 +530,10 @@ public class MapDescriptor extends AbstractDescriptor implements
|
|||
@Override
|
||||
public void setGridGeometry(GeneralGridGeometry gridGeometry)
|
||||
throws VizException {
|
||||
this.gridGeometry = gridGeometry;
|
||||
|
||||
super.setGridGeometry(gridGeometry);
|
||||
init();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.uf.viz.core.map.IMapDescriptor#getCRS()
|
||||
*/
|
||||
@Override
|
||||
public CoordinateReferenceSystem getCRS() {
|
||||
if (this.gridGeometry != null) {
|
||||
return this.gridGeometry.getCoordinateReferenceSystem();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public MathTransform getToGridTransform() {
|
||||
return this.wgsToGridTransform;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current display width
|
||||
*
|
||||
|
|
|
@ -0,0 +1,340 @@
|
|||
/**
|
||||
* 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.rsc;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.opengis.referencing.crs.CoordinateReferenceSystem;
|
||||
|
||||
import com.raytheon.uf.common.dataplugin.PluginDataObject;
|
||||
import com.raytheon.uf.common.time.DataTime;
|
||||
import com.raytheon.uf.viz.core.IGraphicsTarget;
|
||||
import com.raytheon.uf.viz.core.VizApp;
|
||||
import com.raytheon.uf.viz.core.drawables.IDescriptor;
|
||||
import com.raytheon.uf.viz.core.drawables.IRenderable;
|
||||
import com.raytheon.uf.viz.core.drawables.PaintProperties;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
import com.raytheon.uf.viz.core.rsc.capabilities.AbstractCapability;
|
||||
|
||||
/**
|
||||
* Abstract resource class that manages frames with renderable objects
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Dec 21, 2011 mschenke Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author mschenke
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public abstract class AbstractPluginDataObjectResource<T extends AbstractResourceData, D extends IDescriptor>
|
||||
extends AbstractVizResource<T, D> {
|
||||
|
||||
private static class Frame {
|
||||
List<PluginDataObject> records = new ArrayList<PluginDataObject>();
|
||||
|
||||
IRenderable renderable;
|
||||
}
|
||||
|
||||
private Map<DataTime, Frame> frames = new HashMap<DataTime, Frame>();
|
||||
|
||||
private Object lock = new Object();
|
||||
|
||||
/**
|
||||
* @param resourceData
|
||||
* @param loadProperties
|
||||
*/
|
||||
protected AbstractPluginDataObjectResource(T resourceData,
|
||||
LoadProperties loadProperties) {
|
||||
super(resourceData, loadProperties);
|
||||
dataTimes = new ArrayList<DataTime>();
|
||||
resourceData.addChangeListener(new IResourceDataChanged() {
|
||||
@Override
|
||||
public void resourceChanged(ChangeType type, Object object) {
|
||||
if (type == ChangeType.DATA_UPDATE) {
|
||||
if (object instanceof PluginDataObject) {
|
||||
addDataObject((PluginDataObject) object);
|
||||
} else if (object instanceof PluginDataObject[]) {
|
||||
for (PluginDataObject pdo : (PluginDataObject[]) object) {
|
||||
addDataObject((PluginDataObject) pdo);
|
||||
}
|
||||
} else if (object instanceof Object[]) {
|
||||
for (Object obj : (Object[]) object) {
|
||||
if (obj instanceof PluginDataObject) {
|
||||
addDataObject((PluginDataObject) obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (type == ChangeType.CAPABILITY) {
|
||||
if (object instanceof AbstractCapability) {
|
||||
AbstractCapability capability = (AbstractCapability) object;
|
||||
for (Frame frame : frames.values()) {
|
||||
if (frame.renderable != null) {
|
||||
capabilityChanged(frame.renderable, capability);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the pdo to the appropriate time and removes any renderable or data
|
||||
* cached for that time.
|
||||
*
|
||||
* @param pdo
|
||||
*/
|
||||
protected final void addDataObject(PluginDataObject pdo) {
|
||||
synchronized (lock) {
|
||||
if (frames == null) {
|
||||
// Check for null in case we were waiting for lock from
|
||||
// disposeInternal in which case we shouldn't process add
|
||||
return;
|
||||
}
|
||||
DataTime time = getDataObjectTime(pdo);
|
||||
Frame frame = frames.get(time);
|
||||
if (frame == null) {
|
||||
frame = new Frame();
|
||||
frames.put(time, frame);
|
||||
}
|
||||
if (frame.records.contains(pdo)) {
|
||||
frame.records.remove(pdo);
|
||||
}
|
||||
frame.records.add(pdo);
|
||||
if (frame.renderable != null) {
|
||||
if (updateRenderable(frame.renderable, pdo) == false) {
|
||||
dispose(frame.renderable);
|
||||
}
|
||||
}
|
||||
if (!dataTimes.contains(dataTimes)) {
|
||||
dataTimes.add(time);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the DataTime to be associated with this record. Default returns
|
||||
* PluginDataObject.getDataTime()
|
||||
*
|
||||
* @param pdo
|
||||
* @return
|
||||
*/
|
||||
protected DataTime getDataObjectTime(PluginDataObject pdo) {
|
||||
return pdo.getDataTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the records for the given time. Empty list will be returned if no
|
||||
* frame for time
|
||||
*
|
||||
* @param time
|
||||
* @return
|
||||
*/
|
||||
protected List<PluginDataObject> getPluginDataObjects(DataTime time) {
|
||||
Frame frame = frames.get(time);
|
||||
if (frame != null) {
|
||||
return frame.records;
|
||||
}
|
||||
return new ArrayList<PluginDataObject>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current time for the resource, default calls
|
||||
* descriptor.getTimeForResoruce(this)
|
||||
*
|
||||
* @return the current time
|
||||
*/
|
||||
protected DataTime getTimeForResource() {
|
||||
return descriptor.getTimeForResource(this);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.viz.core.rsc.AbstractVizResource#remove(com.raytheon.
|
||||
* uf.common.time.DataTime)
|
||||
*/
|
||||
@Override
|
||||
public final void remove(DataTime dataTime) {
|
||||
synchronized (lock) {
|
||||
super.remove(dataTime);
|
||||
Frame frame = frames.remove(dataTime);
|
||||
if (frame != null && frame.renderable != null) {
|
||||
IRenderable dispose = frame.renderable;
|
||||
frame.renderable = null;
|
||||
dispose(dispose);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispose of a renderable.
|
||||
*
|
||||
* @param renderable
|
||||
*/
|
||||
private void dispose(final IRenderable renderable) {
|
||||
VizApp.runAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
disposeRenderable(renderable);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void project(CoordinateReferenceSystem crs)
|
||||
throws VizException {
|
||||
Iterator<Frame> iter = frames.values().iterator();
|
||||
while (iter.hasNext()) {
|
||||
Frame frame = iter.next();
|
||||
IRenderable renderable = frame.renderable;
|
||||
if (renderable != null) {
|
||||
if (!projectRenderable(renderable, crs)) {
|
||||
frame.renderable = null;
|
||||
dispose(renderable);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.viz.core.rsc.AbstractVizResource#paintInternal(com.raytheon
|
||||
* .uf.viz.core.IGraphicsTarget,
|
||||
* com.raytheon.uf.viz.core.drawables.PaintProperties)
|
||||
*/
|
||||
@Override
|
||||
protected final void paintInternal(IGraphicsTarget target,
|
||||
PaintProperties paintProps) throws VizException {
|
||||
DataTime time = paintProps.getDataTime();
|
||||
if (time == null) {
|
||||
time = getTimeForResource();
|
||||
}
|
||||
Frame currFrame = frames.get(time);
|
||||
if (currFrame != null) {
|
||||
IRenderable renderable = currFrame.renderable;
|
||||
if (renderable == null) {
|
||||
currFrame.renderable = renderable = constructRenderable(currFrame.records);
|
||||
}
|
||||
|
||||
if (renderable != null) {
|
||||
renderable.paint(target, paintProps);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.uf.viz.core.rsc.AbstractVizResource#disposeInternal()
|
||||
*/
|
||||
@Override
|
||||
protected final void disposeInternal() {
|
||||
synchronized (lock) {
|
||||
for (Frame frame : frames.values()) {
|
||||
if (frame.renderable != null) {
|
||||
disposeRenderable(frame.renderable);
|
||||
}
|
||||
}
|
||||
frames.clear();
|
||||
frames = null;
|
||||
}
|
||||
disposeResource();
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispose method for the resource to dispose any data not tied to a
|
||||
* renderable. Called after all renderables have been disposed. Default impl
|
||||
* does nothing
|
||||
*/
|
||||
protected void disposeResource() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Notification that a capability has changed and the renderable should be
|
||||
* updated
|
||||
*
|
||||
* @param renderable
|
||||
* @param capability
|
||||
*/
|
||||
protected abstract void capabilityChanged(IRenderable renderable,
|
||||
AbstractCapability capability);
|
||||
|
||||
/**
|
||||
* Dispose the renderable object
|
||||
*
|
||||
* @param renderable
|
||||
*/
|
||||
protected abstract void disposeRenderable(IRenderable renderable);
|
||||
|
||||
/**
|
||||
* Attempt to reproject the renderable object into this specified
|
||||
* projection. If unable to reproject, return false and renderable will be
|
||||
* recreated next paint
|
||||
*
|
||||
* @param renderable
|
||||
* @param crs
|
||||
* @return
|
||||
*/
|
||||
protected abstract boolean projectRenderable(IRenderable renderable,
|
||||
CoordinateReferenceSystem crs) throws VizException;
|
||||
|
||||
/**
|
||||
* Construct a renderable object for the given records. This method is
|
||||
* called from paintInternal. Null can be returned and this method will be
|
||||
* called next paintInternal. That can be used if requesting data that is
|
||||
* required for the renderable asynchronously.
|
||||
*
|
||||
* NOTE: The size of the pdo list will only grow so it can be used to
|
||||
* determine if new data has arrived since last call
|
||||
*
|
||||
* @param records
|
||||
* @return
|
||||
*/
|
||||
protected abstract IRenderable constructRenderable(
|
||||
List<PluginDataObject> records) throws VizException;
|
||||
|
||||
/**
|
||||
* Update the renderable with the new pdo, if the renderable is updatable,
|
||||
* return true. If the renderable needs to be recreated from scratch, return
|
||||
* false
|
||||
*
|
||||
* @param renderable
|
||||
* @param pdo
|
||||
* @return
|
||||
*/
|
||||
protected abstract boolean updateRenderable(IRenderable renderable,
|
||||
PluginDataObject pdo);
|
||||
}
|
|
@ -21,6 +21,7 @@ package com.raytheon.uf.viz.core.rsc;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
@ -385,11 +386,6 @@ public abstract class AbstractRequestableResourceData extends
|
|||
|
||||
Set<DataTime> currentSet = new HashSet<DataTime>(Arrays.asList(current));
|
||||
|
||||
boolean initialLoad = false;
|
||||
if (currentSet.size() == 0) {
|
||||
initialLoad = true;
|
||||
}
|
||||
|
||||
Set<DataTime> loadSet = new HashSet<DataTime>();
|
||||
for (DataTime t : desiredSet) {
|
||||
boolean found = false;
|
||||
|
@ -409,6 +405,21 @@ public abstract class AbstractRequestableResourceData extends
|
|||
return new PluginDataObject[0];
|
||||
}
|
||||
|
||||
return requestPluginDataObjects(loadSet);
|
||||
}
|
||||
|
||||
/**
|
||||
* Request plugin data objects for the passed in times. This method is
|
||||
* called from getLatestPluginDataObjects(DataTime[],DataTime[]) after time
|
||||
* filter from desired and current has been done. The times passed in is a
|
||||
* collection of new times needed
|
||||
*
|
||||
* @param loadSet
|
||||
* @return
|
||||
* @throws VizException
|
||||
*/
|
||||
protected PluginDataObject[] requestPluginDataObjects(
|
||||
Collection<DataTime> loadSet) throws VizException {
|
||||
LayerProperty property = new LayerProperty();
|
||||
// TODO fix?
|
||||
property.setDesiredProduct(ResourceType.PLAN_VIEW);
|
||||
|
@ -476,7 +487,7 @@ public abstract class AbstractRequestableResourceData extends
|
|||
/**
|
||||
* Comparator for response array.
|
||||
*/
|
||||
private static Comparator<PluginDataObject> layerComparator = new Comparator<PluginDataObject>() {
|
||||
protected static Comparator<PluginDataObject> layerComparator = new Comparator<PluginDataObject>() {
|
||||
|
||||
@Override
|
||||
public int compare(PluginDataObject arg0, PluginDataObject arg1) {
|
||||
|
|
|
@ -20,10 +20,10 @@
|
|||
package com.raytheon.uf.viz.core.rsc;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CopyOnWriteArraySet;
|
||||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
|
@ -152,11 +152,11 @@ public abstract class AbstractVizResource<T extends AbstractResourceData, D exte
|
|||
protected AbstractVizResource(T resourceData, LoadProperties loadProperties) {
|
||||
this.resourceData = resourceData;
|
||||
this.loadProperties = loadProperties;
|
||||
refreshListeners = new HashSet<IRefreshListener>();
|
||||
initListeners = new HashSet<IInitListener>();
|
||||
paintListeners = new HashSet<IPaintListener>();
|
||||
paintStatusListeners = new HashSet<IPaintStatusChangedListener>();
|
||||
disposeListeners = new HashSet<IDisposeListener>();
|
||||
refreshListeners = new CopyOnWriteArraySet<IRefreshListener>();
|
||||
initListeners = new CopyOnWriteArraySet<IInitListener>();
|
||||
paintListeners = new CopyOnWriteArraySet<IPaintListener>();
|
||||
paintStatusListeners = new CopyOnWriteArraySet<IPaintStatusChangedListener>();
|
||||
disposeListeners = new CopyOnWriteArraySet<IDisposeListener>();
|
||||
|
||||
if (resourceData != null) {
|
||||
resourceData.addChangeListener(new IResourceDataChanged() {
|
||||
|
@ -717,7 +717,7 @@ public abstract class AbstractVizResource<T extends AbstractResourceData, D exte
|
|||
*/
|
||||
public final void recycle() {
|
||||
if (status == ResourceStatus.INITIALIZED) {
|
||||
dispose();
|
||||
disposeInternal();
|
||||
}
|
||||
status = ResourceStatus.NEW;
|
||||
initJob = null;
|
||||
|
|
|
@ -73,6 +73,9 @@ public class ColorMapCapability extends AbstractCapability implements
|
|||
public void setColorMapParameters(ColorMapParameters colorMapParameters,
|
||||
boolean notify) {
|
||||
if (this.colorMapParameters != colorMapParameters) {
|
||||
if (this.colorMapParameters != null) {
|
||||
this.colorMapParameters.removeListener(this);
|
||||
}
|
||||
this.colorMapParameters = colorMapParameters;
|
||||
if (notify) {
|
||||
capabilityChanged();
|
||||
|
@ -80,7 +83,7 @@ public class ColorMapCapability extends AbstractCapability implements
|
|||
}
|
||||
|
||||
if (this.colorMapParameters != null) {
|
||||
this.colorMapParameters.setListener(this);
|
||||
this.colorMapParameters.addListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -21,23 +21,115 @@ package com.raytheon.uf.viz.core.rsc.hdf5;
|
|||
|
||||
import java.awt.Rectangle;
|
||||
|
||||
import com.raytheon.uf.viz.core.PixelCoverage;
|
||||
import org.geotools.coverage.grid.GeneralGridEnvelope;
|
||||
import org.geotools.coverage.grid.GridGeometry2D;
|
||||
import org.geotools.geometry.GeneralEnvelope;
|
||||
import org.geotools.geometry.jts.ReferencedEnvelope;
|
||||
import org.opengis.coverage.grid.GridEnvelope;
|
||||
import org.opengis.geometry.Envelope;
|
||||
|
||||
import com.raytheon.uf.viz.core.PixelCoverage;
|
||||
import com.vividsolutions.jts.geom.Coordinate;
|
||||
|
||||
/**
|
||||
* ImageTile is an object that represents an image (or part of an image)
|
||||
* geospatially, it contains a grid geometry that represents the projection and
|
||||
* size of the image and a PixelCoverage which contains the screen projected
|
||||
* data for the image. Because a single ImageTile can represent multiple images,
|
||||
* this class does not contain the actual image it represents so the tile can be
|
||||
* shared between images
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Mar 13, 2012 mschenke Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author mschenke
|
||||
* @version 1.0
|
||||
*/
|
||||
public class ImageTile {
|
||||
|
||||
public com.vividsolutions.jts.geom.Envelope envelope;
|
||||
|
||||
public double elevation;
|
||||
public GridGeometry2D imageGeometry;
|
||||
|
||||
public PixelCoverage coverage;
|
||||
|
||||
public Rectangle rect;
|
||||
/**
|
||||
* Checks to see if the x/y coordinate is contained by the ImageTile's CRS
|
||||
* Envelope
|
||||
*
|
||||
* @param x
|
||||
* @param y
|
||||
* @return
|
||||
*/
|
||||
public boolean contains(double x, double y) {
|
||||
Envelope env = imageGeometry.getEnvelope();
|
||||
return env.getMinimum(0) <= x && env.getMaximum(0) >= x
|
||||
&& env.getMinimum(1) <= y && env.getMaximum(1) >= y;
|
||||
}
|
||||
|
||||
// TODO clean up occlusionQueries move to GLImage?
|
||||
public int query = -1;
|
||||
/**
|
||||
* Checks to see if the Coordinate is contained by the ImageTile's CRS
|
||||
* Envelope
|
||||
*
|
||||
* @param c
|
||||
* @return
|
||||
*/
|
||||
public boolean contains(Coordinate c) {
|
||||
return contains(c.x, c.y);
|
||||
}
|
||||
|
||||
public boolean occlude = false;
|
||||
/**
|
||||
* Set the grid geometry of the tile given the image rectangle and the
|
||||
* referenced envelope
|
||||
*
|
||||
* @param rect
|
||||
* @param env
|
||||
*/
|
||||
public void setGridGeometry(Rectangle rect, ReferencedEnvelope env) {
|
||||
GeneralGridEnvelope gge = new GeneralGridEnvelope(rect);
|
||||
GeneralEnvelope ge = new GeneralEnvelope(env);
|
||||
imageGeometry = new GridGeometry2D(gge, ge);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the image geometry
|
||||
*
|
||||
* @param imageGeometry
|
||||
*/
|
||||
public void setGridGeometry(GridGeometry2D imageGeometry) {
|
||||
this.imageGeometry = imageGeometry;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the image rectangle. This could be a subsection of a larger image so
|
||||
* x and y may not be 0,0
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Rectangle getRectangle() {
|
||||
GridEnvelope env = imageGeometry.getGridRange();
|
||||
return new Rectangle(env.getLow(0), env.getLow(1), env.getSpan(0),
|
||||
env.getSpan(1));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the spatially referenced envelope of the image tile
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public ReferencedEnvelope getEnvelope() {
|
||||
return new ReferencedEnvelope(imageGeometry.getEnvelope());
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispose the image tile, disposes of the coverage object associated with
|
||||
* it
|
||||
*/
|
||||
public void dispose() {
|
||||
if (coverage != null) {
|
||||
coverage.dispose();
|
||||
|
|
|
@ -1,163 +0,0 @@
|
|||
/**
|
||||
* 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.rsc.hdf5;
|
||||
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.core.runtime.jobs.Job;
|
||||
import org.opengis.referencing.operation.MathTransform;
|
||||
|
||||
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.IMesh;
|
||||
import com.raytheon.uf.viz.core.IMeshCallback;
|
||||
import com.raytheon.uf.viz.core.PixelCoverage;
|
||||
import com.raytheon.uf.viz.core.rsc.RenderingOrderFactory;
|
||||
|
||||
/**
|
||||
* Persistent job used to calculate mesh tiles outside of the rendering thread
|
||||
*
|
||||
* <pre>
|
||||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Mar 1, 2007 chammack Initial Creation.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author cnh
|
||||
* @version 1
|
||||
*/
|
||||
public class MeshCalculatorJob extends Job {
|
||||
private static final transient IUFStatusHandler statusHandler = UFStatus.getHandler(MeshCalculatorJob.class);
|
||||
|
||||
private static MeshCalculatorJob instance;
|
||||
|
||||
private ConcurrentLinkedQueue<PixelCoverage> requests;
|
||||
|
||||
private ConcurrentHashMap<PixelCoverage, MeshParameters> map;
|
||||
|
||||
private MeshCalculatorJob() {
|
||||
super("Mesh Calculator");
|
||||
requests = new ConcurrentLinkedQueue<PixelCoverage>();
|
||||
map = new ConcurrentHashMap<PixelCoverage, MeshParameters>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Request to have the mesh be calculated in the mesh thread
|
||||
*
|
||||
* @param mesh
|
||||
* @param tile
|
||||
* @param preTransform
|
||||
*/
|
||||
public synchronized void requestLoad(IMesh mesh, ImageTile tile,
|
||||
MathTransform preTransform) {
|
||||
if (!requests.contains(tile.coverage)) {
|
||||
MeshParameters params = new MeshParameters();
|
||||
params.tile = tile;
|
||||
params.mesh = mesh;
|
||||
params.preTransform = preTransform;
|
||||
|
||||
map.put(tile.coverage, params);
|
||||
requests.add(tile.coverage);
|
||||
}
|
||||
instance.schedule();
|
||||
}
|
||||
|
||||
/**
|
||||
* Request to have the mesh be calculated in the mesh thread, with the
|
||||
* callback being notified after the mesh has been calculated
|
||||
*
|
||||
* @param callback
|
||||
* @param mesh
|
||||
* @param tile
|
||||
* @param preTransform
|
||||
*/
|
||||
public synchronized void requestLoad(IMeshCallback callback, IMesh mesh,
|
||||
ImageTile tile, MathTransform preTransform) {
|
||||
if (!requests.contains(tile.coverage)) {
|
||||
MeshParameters params = new MeshParameters();
|
||||
params.tile = tile;
|
||||
params.mesh = mesh;
|
||||
params.preTransform = preTransform;
|
||||
params.callback = callback;
|
||||
|
||||
map.put(tile.coverage, params);
|
||||
requests.add(tile.coverage);
|
||||
}
|
||||
instance.schedule();
|
||||
}
|
||||
|
||||
public static synchronized MeshCalculatorJob getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new MeshCalculatorJob();
|
||||
instance.setSystem(true);
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @seeorg.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.
|
||||
* IProgressMonitor)
|
||||
*/
|
||||
@Override
|
||||
protected IStatus run(IProgressMonitor monitor) {
|
||||
|
||||
while (requests.size() > 0) {
|
||||
PixelCoverage coverage = requests.peek();
|
||||
try {
|
||||
MeshParameters p = map.get(coverage);
|
||||
|
||||
coverage.setMesh(null);
|
||||
p.mesh.calculateMesh(coverage, p.tile, p.preTransform);
|
||||
coverage.setMesh(p.mesh);
|
||||
|
||||
if (p.callback != null) {
|
||||
p.callback.meshCalculated(p.tile);
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
statusHandler.handle(Priority.PROBLEM, "An error occured during mesh calculations, some images may not be properly reprojected.", t);
|
||||
}
|
||||
map.remove(coverage);
|
||||
requests.remove();
|
||||
}
|
||||
return Status.OK_STATUS;
|
||||
}
|
||||
|
||||
private class MeshParameters {
|
||||
// public MapDescriptor mapDescriptor;
|
||||
|
||||
public IMesh mesh;
|
||||
|
||||
public ImageTile tile;
|
||||
|
||||
public MathTransform preTransform;
|
||||
|
||||
public IMeshCallback callback;
|
||||
}
|
||||
|
||||
}
|
|
@ -7,7 +7,10 @@ Bundle-Activator: com.raytheon.uf.viz.derivparam.Activator
|
|||
Bundle-Vendor: RAYTHEON
|
||||
Require-Bundle: org.eclipse.core.runtime,
|
||||
javax.measure,
|
||||
com.raytheon.uf.common.dataquery
|
||||
com.raytheon.uf.common.dataquery,
|
||||
com.raytheon.uf.viz.core;bundle-version="1.12.1174",
|
||||
com.raytheon.uf.common.datastorage;bundle-version="1.12.1174",
|
||||
com.raytheon.uf.common.pointdata;bundle-version="1.12.1174"
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Eclipse-RegisterBuddy: com.raytheon.uf.common.serialization
|
||||
|
@ -17,21 +20,13 @@ Import-Package: com.raytheon.edex.meteoLib,
|
|||
com.raytheon.uf.common.dataplugin,
|
||||
com.raytheon.uf.common.dataplugin.level,
|
||||
com.raytheon.uf.common.dataplugin.persist,
|
||||
com.raytheon.uf.common.datastorage.records,
|
||||
com.raytheon.uf.common.derivparam.tree,
|
||||
com.raytheon.uf.common.localization,
|
||||
com.raytheon.uf.common.message.response,
|
||||
com.raytheon.uf.common.serialization,
|
||||
com.raytheon.uf.common.serialization.adapters,
|
||||
com.raytheon.uf.common.status,
|
||||
com.raytheon.uf.common.time,
|
||||
com.raytheon.uf.viz.core,
|
||||
com.raytheon.uf.viz.core.catalog,
|
||||
com.raytheon.uf.viz.core.comm,
|
||||
com.raytheon.uf.viz.core.exception,
|
||||
com.raytheon.uf.viz.core.level,
|
||||
com.raytheon.uf.viz.core.localization,
|
||||
com.raytheon.uf.viz.core.status
|
||||
com.raytheon.uf.common.time
|
||||
Export-Package: com.raytheon.uf.viz.derivparam,
|
||||
com.raytheon.uf.viz.derivparam.data,
|
||||
com.raytheon.uf.viz.derivparam.inv,
|
||||
|
|
|
@ -0,0 +1,394 @@
|
|||
/**
|
||||
* 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.derivparam.data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import com.raytheon.uf.common.dataplugin.PluginDataObject;
|
||||
import com.raytheon.uf.common.dataquery.requests.DbQueryRequest;
|
||||
import com.raytheon.uf.common.dataquery.requests.DbQueryRequestSet;
|
||||
import com.raytheon.uf.common.dataquery.requests.RequestConstraint;
|
||||
import com.raytheon.uf.common.dataquery.requests.RequestConstraint.ConstraintType;
|
||||
import com.raytheon.uf.common.dataquery.requests.TimeQueryRequest;
|
||||
import com.raytheon.uf.common.dataquery.requests.TimeQueryRequestSet;
|
||||
import com.raytheon.uf.common.dataquery.responses.DbQueryResponse;
|
||||
import com.raytheon.uf.common.dataquery.responses.DbQueryResponseSet;
|
||||
import com.raytheon.uf.common.datastorage.Request;
|
||||
import com.raytheon.uf.common.datastorage.records.IDataRecord;
|
||||
import com.raytheon.uf.common.pointdata.PointDataContainer;
|
||||
import com.raytheon.uf.common.time.DataTime;
|
||||
import com.raytheon.uf.viz.core.catalog.LayerProperty;
|
||||
import com.raytheon.uf.viz.core.datastructure.IDataCubeAdapter;
|
||||
import com.raytheon.uf.viz.core.datastructure.VizDataCubeException;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
import com.raytheon.uf.viz.core.requests.ThriftClient;
|
||||
import com.raytheon.uf.viz.derivparam.tree.AbstractRequestableLevelNode;
|
||||
import com.raytheon.uf.viz.derivparam.tree.AbstractRequestableLevelNode.Dependency;
|
||||
|
||||
/**
|
||||
* Abstract data cube adapter for standard data type that uses derived
|
||||
* parameters
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jan 30, 2012 mschenke Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author mschenke
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public abstract class AbstractDataCubeAdapter implements IDataCubeAdapter {
|
||||
|
||||
private String[] supportedPlugins;
|
||||
|
||||
protected AbstractDataCubeAdapter(String[] supportedPlugins) {
|
||||
this.supportedPlugins = supportedPlugins;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.viz.core.datastructure.IDataCubeAdapter#getSupportedPlugins
|
||||
* ()
|
||||
*/
|
||||
@Override
|
||||
public String[] getSupportedPlugins() {
|
||||
return supportedPlugins;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.viz.core.datastructure.IDataCubeAdapter#timeQuery(java
|
||||
* .util.List)
|
||||
*/
|
||||
@Override
|
||||
public List<List<DataTime>> timeQuery(List<TimeQueryRequest> requests)
|
||||
throws VizException {
|
||||
int mapSize = (int) (requests.size() * 1) + 1;
|
||||
Map<AbstractRequestableLevelNode, Set<DataTime>> cache = new HashMap<AbstractRequestableLevelNode, Set<DataTime>>(
|
||||
mapSize);
|
||||
LinkedHashMap<AbstractRequestableLevelNode, TimeQueryRequest> queries = new LinkedHashMap<AbstractRequestableLevelNode, TimeQueryRequest>(
|
||||
mapSize);
|
||||
|
||||
for (TimeQueryRequest request : requests) {
|
||||
List<AbstractRequestableLevelNode> requestNodes = evaluateRequestConstraints(request
|
||||
.getQueryTerms());
|
||||
// pull out time queries and bulk submit
|
||||
for (AbstractRequestableLevelNode requestNode : requestNodes) {
|
||||
getTimeQuery(request, requestNode, false, queries, cache, null);
|
||||
}
|
||||
}
|
||||
|
||||
// set the results back into the cache's
|
||||
TimeQueryRequestSet reqSet = new TimeQueryRequestSet();
|
||||
reqSet.setRequests(queries.values().toArray(
|
||||
new TimeQueryRequest[queries.size()]));
|
||||
@SuppressWarnings("unchecked")
|
||||
List<List<DataTime>> qResponses = (List<List<DataTime>>) ThriftClient
|
||||
.sendRequest(reqSet);
|
||||
int index = 0;
|
||||
for (AbstractRequestableLevelNode node : queries.keySet()) {
|
||||
// put results into cache
|
||||
node.setTimeQueryResults(false, qResponses.get(index++), cache,
|
||||
null);
|
||||
}
|
||||
List<List<DataTime>> finalResponse = new ArrayList<List<DataTime>>(
|
||||
requests.size());
|
||||
for (TimeQueryRequest request : requests) {
|
||||
List<AbstractRequestableLevelNode> requestNodes = evaluateRequestConstraints(request
|
||||
.getQueryTerms());
|
||||
// pull the actual results from the cache
|
||||
Set<DataTime> results = new HashSet<DataTime>(64);
|
||||
for (AbstractRequestableLevelNode requestNode : requestNodes) {
|
||||
Set<DataTime> times = requestNode.timeQuery(request, false,
|
||||
cache, null);
|
||||
if (times == AbstractRequestableLevelNode.TIME_AGNOSTIC) {
|
||||
// TODO: include time agnostic query in main bulk query as
|
||||
// each pressure level will cause a separate query
|
||||
List<DataTime> temp = timeAgnosticQuery(request
|
||||
.getQueryTerms());
|
||||
if (temp != null) {
|
||||
results.addAll(temp);
|
||||
}
|
||||
break;
|
||||
} else {
|
||||
results.addAll(times);
|
||||
}
|
||||
}
|
||||
if (!request.isMaxQuery() || results.isEmpty()) {
|
||||
finalResponse.add(new ArrayList<DataTime>(results));
|
||||
} else {
|
||||
ArrayList<DataTime> response = new ArrayList<DataTime>(results);
|
||||
Collections.sort(response);
|
||||
finalResponse
|
||||
.add(Arrays.asList(response.get(response.size() - 1)));
|
||||
}
|
||||
}
|
||||
return finalResponse;
|
||||
}
|
||||
|
||||
protected void getTimeQuery(
|
||||
TimeQueryRequest originalRequest,
|
||||
AbstractRequestableLevelNode req,
|
||||
boolean latestOnly,
|
||||
LinkedHashMap<AbstractRequestableLevelNode, TimeQueryRequest> queries,
|
||||
Map<AbstractRequestableLevelNode, Set<DataTime>> cache,
|
||||
Map<AbstractRequestableLevelNode, Set<DataTime>> latestOnlyCache)
|
||||
throws VizException {
|
||||
List<Dependency> depends = req.getDependencies();
|
||||
if (depends.isEmpty()) {
|
||||
// is source node
|
||||
TimeQueryRequest myQ = req.getTimeQuery(originalRequest,
|
||||
latestOnly, cache, latestOnlyCache);
|
||||
if (myQ != null) {
|
||||
// no need to merge timeQueries
|
||||
queries.put(req, myQ);
|
||||
}
|
||||
} else {
|
||||
for (Dependency dep : depends) {
|
||||
// TODO: Optimize dTime/fTime to use bulk query mechanism,
|
||||
// small case that is a not easy to get right with a bulk
|
||||
// query
|
||||
if (dep.timeOffset == 0 || !latestOnly) {
|
||||
getTimeQuery(originalRequest, dep.node, latestOnly,
|
||||
queries, cache, latestOnlyCache);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.viz.core.datastructure.IDataCubeAdapter#getPoints(java
|
||||
* .lang.String, java.lang.String[], java.util.Map)
|
||||
*/
|
||||
@Override
|
||||
public PointDataContainer getPoints(String plugin, String[] parameters,
|
||||
Map<String, RequestConstraint> queryParams) throws VizException {
|
||||
// TODO Someday we should put objective analysis code
|
||||
// into this area
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.viz.core.datastructure.IDataCubeAdapter#getPoints(java
|
||||
* .lang.String, java.lang.String[], java.lang.String, java.util.Map)
|
||||
*/
|
||||
@Override
|
||||
public PointDataContainer getPoints(String plugin, String[] parameters,
|
||||
String levelKey, Map<String, RequestConstraint> queryParams)
|
||||
throws VizException {
|
||||
// TODO Someday we should put objective analysis code
|
||||
// into this area
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.viz.core.datastructure.IDataCubeAdapter#getData(com.raytheon
|
||||
* .uf.viz.core.catalog.LayerProperty, int)
|
||||
*/
|
||||
@Override
|
||||
public List<Object> getData(LayerProperty property, int timeOut)
|
||||
throws VizException {
|
||||
List<AbstractRequestableLevelNode> requests = evaluateRequestConstraints(property
|
||||
.getEntryQueryParameters(false));
|
||||
int mapSize = (int) (requests.size() * 1.25) + 1;
|
||||
Map<AbstractRequestableLevelNode, List<AbstractRequestableData>> cache = new HashMap<AbstractRequestableLevelNode, List<AbstractRequestableData>>(
|
||||
mapSize);
|
||||
LinkedHashMap<AbstractRequestableLevelNode, DbQueryRequest> queries = new LinkedHashMap<AbstractRequestableLevelNode, DbQueryRequest>(
|
||||
mapSize);
|
||||
for (AbstractRequestableLevelNode req : requests) {
|
||||
getDataQuery(req, property, timeOut, queries, cache);
|
||||
}
|
||||
DbQueryRequestSet reqSet = new DbQueryRequestSet();
|
||||
reqSet.setQueries(queries.values().toArray(
|
||||
new DbQueryRequest[queries.size()]));
|
||||
DbQueryResponseSet qSetResponse = (DbQueryResponseSet) ThriftClient
|
||||
.sendRequest(reqSet);
|
||||
DbQueryResponse[] qResponses = qSetResponse.getResults();
|
||||
int index = 0;
|
||||
for (AbstractRequestableLevelNode node : queries.keySet()) {
|
||||
// put results into cache
|
||||
node.setDataQueryResults(qResponses[index++], cache);
|
||||
}
|
||||
|
||||
// pull the actual results from the cache
|
||||
List<AbstractRequestableData> requesters = new ArrayList<AbstractRequestableData>(
|
||||
requests.size());
|
||||
for (AbstractRequestableLevelNode request : requests) {
|
||||
requesters.addAll(request.getData(property, timeOut, cache));
|
||||
}
|
||||
|
||||
return getData(property, requesters);
|
||||
}
|
||||
|
||||
protected void getDataQuery(
|
||||
AbstractRequestableLevelNode req,
|
||||
LayerProperty property,
|
||||
int timeOut,
|
||||
LinkedHashMap<AbstractRequestableLevelNode, DbQueryRequest> queries,
|
||||
Map<AbstractRequestableLevelNode, List<AbstractRequestableData>> cache)
|
||||
throws VizException {
|
||||
List<Dependency> depends = req.getDependencies();
|
||||
if (depends.isEmpty()) {
|
||||
// is source node
|
||||
DbQueryRequest myQ = req.getDataQuery(property, timeOut, cache);
|
||||
if (myQ != null) {
|
||||
addDataQuery(req, myQ, queries);
|
||||
}
|
||||
} else {
|
||||
for (Dependency dep : depends) {
|
||||
// TODO: Optimize dTime/fTime to use bulk query mechanism,
|
||||
// small case that is a not easy to get right with a bulk
|
||||
// query
|
||||
if (dep.timeOffset == 0) {
|
||||
getDataQuery(dep.node, property, timeOut, queries, cache);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void addDataQuery(AbstractRequestableLevelNode req,
|
||||
DbQueryRequest query,
|
||||
LinkedHashMap<AbstractRequestableLevelNode, DbQueryRequest> queries) {
|
||||
DbQueryRequest curQuery = queries.get(req);
|
||||
if (curQuery == null) {
|
||||
queries.put(req, query);
|
||||
} else {
|
||||
// merge
|
||||
// assume same DB, fields, etc, should only be different
|
||||
// time constraints since its the same node
|
||||
RequestConstraint curDTs = curQuery.getConstraints()
|
||||
.get("dataTime");
|
||||
RequestConstraint myDTs = query.getConstraints().get("dataTime");
|
||||
if (curDTs != null && myDTs != null) {
|
||||
// only merge if both require dataTimes, otherwise one
|
||||
// would be constrained when it needs everything, also
|
||||
// assuming both to be in lists and needing to be merged
|
||||
curDTs.setConstraintType(ConstraintType.IN);
|
||||
Pattern split = Pattern.compile(",");
|
||||
|
||||
String[] curVals = split.split(curDTs.getConstraintValue());
|
||||
String[] myVals = split.split(myDTs.getConstraintValue());
|
||||
HashSet<String> dups = new HashSet<String>(curVals.length
|
||||
+ myVals.length);
|
||||
dups.addAll(Arrays.asList(curVals));
|
||||
dups.addAll(Arrays.asList(myVals));
|
||||
curDTs.setConstraintValueList(dups.toArray(new String[dups
|
||||
.size()]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.uf.viz.core.datastructure.IDataCubeAdapter#
|
||||
* getBaseUpdateConstraints(java.util.Map)
|
||||
*/
|
||||
@Override
|
||||
public List<Map<String, RequestConstraint>> getBaseUpdateConstraints(
|
||||
Map<String, RequestConstraint> constraints) {
|
||||
List<Map<String, RequestConstraint>> result = new ArrayList<Map<String, RequestConstraint>>(
|
||||
1);
|
||||
result.add(constraints);
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.viz.core.datastructure.IDataCubeAdapter#getRecord(com
|
||||
* .raytheon.uf.common.dataplugin.PluginDataObject)
|
||||
*/
|
||||
@Override
|
||||
public IDataRecord[] getRecord(PluginDataObject obj)
|
||||
throws VizDataCubeException {
|
||||
return getRecord(obj, Request.ALL, null);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.viz.core.datastructure.IDataCubeAdapter#getRecord(com
|
||||
* .raytheon.uf.common.dataplugin.PluginDataObject,
|
||||
* com.raytheon.uf.common.datastorage.Request, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public IDataRecord[] getRecord(PluginDataObject obj, Request req,
|
||||
String dataset) throws VizDataCubeException {
|
||||
getRecords(Arrays.asList(obj), req, dataset);
|
||||
IDataRecord[] result = (IDataRecord[]) obj.getMessageData();
|
||||
obj.setMessageData(null);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scan the inventory for AbstractRequestableLevelNodes that match the
|
||||
* request constraints
|
||||
*
|
||||
* @param constraints
|
||||
* @return
|
||||
*/
|
||||
protected abstract List<AbstractRequestableLevelNode> evaluateRequestConstraints(
|
||||
Map<String, RequestConstraint> constraints);
|
||||
|
||||
/**
|
||||
* @param queryTerms
|
||||
* @return
|
||||
*/
|
||||
protected abstract List<DataTime> timeAgnosticQuery(
|
||||
Map<String, RequestConstraint> queryTerms) throws VizException;
|
||||
|
||||
/**
|
||||
* @param requesters
|
||||
* @return
|
||||
*/
|
||||
protected abstract List<Object> getData(LayerProperty property,
|
||||
List<AbstractRequestableData> requesters) throws VizException;
|
||||
}
|
|
@ -581,7 +581,7 @@ public abstract class AbstractInventory implements DerivParamUpdateListener {
|
|||
|| levelsToProcess == null || sourcesToProcess.isEmpty()
|
||||
|| paramsToProcess.isEmpty() || levelsToProcess.isEmpty()
|
||||
|| derParLibrary == null) {
|
||||
return null;
|
||||
return Collections.emptyList();
|
||||
}
|
||||
if (clazz != null) {
|
||||
// when clazz == null we need to link the aliases to the source
|
||||
|
|
|
@ -26,6 +26,7 @@ import java.util.Set;
|
|||
|
||||
import com.raytheon.uf.common.dataplugin.level.Level;
|
||||
import com.raytheon.uf.common.dataquery.requests.RequestConstraint;
|
||||
import com.raytheon.uf.common.dataquery.requests.TimeQueryRequest;
|
||||
import com.raytheon.uf.common.time.DataTime;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
import com.raytheon.uf.viz.derivparam.library.DerivParamDesc;
|
||||
|
@ -67,11 +68,13 @@ public abstract class AbstractAliasLevelNode extends AbstractDerivedLevelNode {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Set<DataTime> timeQueryInternal(boolean latestOnly,
|
||||
public Set<DataTime> timeQueryInternal(TimeQueryRequest originalRequest,
|
||||
boolean latestOnly,
|
||||
Map<AbstractRequestableLevelNode, Set<DataTime>> cache,
|
||||
Map<AbstractRequestableLevelNode, Set<DataTime>> latestOnlyCache)
|
||||
throws VizException {
|
||||
return sourceNode.timeQuery(latestOnly, cache, latestOnlyCache);
|
||||
return sourceNode.timeQuery(originalRequest, latestOnly, cache,
|
||||
latestOnlyCache);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -31,6 +31,7 @@ import java.util.Set;
|
|||
|
||||
import com.raytheon.uf.common.dataplugin.level.Level;
|
||||
import com.raytheon.uf.common.dataquery.requests.RequestConstraint;
|
||||
import com.raytheon.uf.common.dataquery.requests.TimeQueryRequest;
|
||||
import com.raytheon.uf.common.time.DataTime;
|
||||
import com.raytheon.uf.viz.core.catalog.CatalogQuery;
|
||||
import com.raytheon.uf.viz.core.catalog.LayerProperty;
|
||||
|
@ -270,7 +271,8 @@ public abstract class AbstractCubeLevelNode extends AbstractDerivedLevelNode {
|
|||
Map<String, RequestConstraint> requestContraintsToFilter);
|
||||
|
||||
@Override
|
||||
public Set<DataTime> timeQueryInternal(boolean latestOnly,
|
||||
public Set<DataTime> timeQueryInternal(TimeQueryRequest originalRequest,
|
||||
boolean latestOnly,
|
||||
Map<AbstractRequestableLevelNode, Set<DataTime>> cache,
|
||||
Map<AbstractRequestableLevelNode, Set<DataTime>> latestOnlyCache)
|
||||
throws VizException {
|
||||
|
@ -299,8 +301,8 @@ public abstract class AbstractCubeLevelNode extends AbstractDerivedLevelNode {
|
|||
|
||||
results.addAll(mergedTimeQuery(merge(requests), latestOnly));
|
||||
for (AbstractRequestableLevelNode request : requests) {
|
||||
results.addAll(request
|
||||
.timeQuery(latestOnly, cache, latestOnlyCache));
|
||||
results.addAll(request.timeQuery(originalRequest, latestOnly,
|
||||
cache, latestOnlyCache));
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
|
|
@ -243,7 +243,8 @@ public abstract class AbstractDerivedLevelNode extends
|
|||
}
|
||||
|
||||
@Override
|
||||
protected TimeQueryRequest getTimeQueryInternal(boolean latestOnly,
|
||||
protected TimeQueryRequest getTimeQueryInternal(
|
||||
TimeQueryRequest originalRequest, boolean latestOnly,
|
||||
Map<AbstractRequestableLevelNode, Set<DataTime>> cache)
|
||||
throws VizException {
|
||||
throw new UnsupportedOperationException(
|
||||
|
|
|
@ -205,7 +205,8 @@ public abstract class AbstractRequestableLevelNode extends LevelNode {
|
|||
protected abstract List<AbstractRequestableData> processDataQueryResults(
|
||||
DbQueryResponse queryResponse) throws VizException;
|
||||
|
||||
public Set<DataTime> timeQuery(boolean latestOnly,
|
||||
public Set<DataTime> timeQuery(TimeQueryRequest originalRequest,
|
||||
boolean latestOnly,
|
||||
Map<AbstractRequestableLevelNode, Set<DataTime>> cache,
|
||||
Map<AbstractRequestableLevelNode, Set<DataTime>> latestOnlyCache)
|
||||
throws VizException {
|
||||
|
@ -215,15 +216,16 @@ public abstract class AbstractRequestableLevelNode extends LevelNode {
|
|||
return latestOnlyCache.get(this);
|
||||
}
|
||||
|
||||
Set<DataTime> results = timeQueryInternal(latestOnly, cache,
|
||||
latestOnlyCache);
|
||||
Set<DataTime> results = timeQueryInternal(originalRequest, latestOnly,
|
||||
cache, latestOnlyCache);
|
||||
if (cache != null && !latestOnly) {
|
||||
cache.put(this, results);
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
public TimeQueryRequest getTimeQuery(boolean latestOnly,
|
||||
public TimeQueryRequest getTimeQuery(TimeQueryRequest originalRequest,
|
||||
boolean latestOnly,
|
||||
Map<AbstractRequestableLevelNode, Set<DataTime>> cache,
|
||||
Map<AbstractRequestableLevelNode, Set<DataTime>> latestOnlyCache)
|
||||
throws VizException {
|
||||
|
@ -233,7 +235,7 @@ public abstract class AbstractRequestableLevelNode extends LevelNode {
|
|||
return null;
|
||||
}
|
||||
|
||||
return getTimeQueryInternal(latestOnly, cache);
|
||||
return getTimeQueryInternal(originalRequest, latestOnly, cache);
|
||||
}
|
||||
|
||||
public void setTimeQueryResults(boolean latestOnly,
|
||||
|
@ -386,13 +388,14 @@ public abstract class AbstractRequestableLevelNode extends LevelNode {
|
|||
return rval;
|
||||
}
|
||||
|
||||
protected abstract Set<DataTime> timeQueryInternal(boolean latestOnly,
|
||||
protected abstract Set<DataTime> timeQueryInternal(
|
||||
TimeQueryRequest originalRequest, boolean latestOnly,
|
||||
Map<AbstractRequestableLevelNode, Set<DataTime>> cache,
|
||||
Map<AbstractRequestableLevelNode, Set<DataTime>> latestOnlyCache)
|
||||
throws VizException;
|
||||
|
||||
protected abstract TimeQueryRequest getTimeQueryInternal(
|
||||
boolean latestOnly,
|
||||
TimeQueryRequest originalRequest, boolean latestOnly,
|
||||
Map<AbstractRequestableLevelNode, Set<DataTime>> cache)
|
||||
throws VizException;
|
||||
|
||||
|
@ -408,8 +411,9 @@ public abstract class AbstractRequestableLevelNode extends LevelNode {
|
|||
Map<AbstractRequestableLevelNode, List<AbstractRequestableData>> cache)
|
||||
throws VizException;
|
||||
|
||||
protected Set<DataTime> timeQuery(boolean latestOnly) throws VizException {
|
||||
return timeQuery(latestOnly,
|
||||
protected Set<DataTime> timeQuery(TimeQueryRequest originalRequest,
|
||||
boolean latestOnly) throws VizException {
|
||||
return timeQuery(originalRequest, latestOnly,
|
||||
new HashMap<AbstractRequestableLevelNode, Set<DataTime>>(),
|
||||
new HashMap<AbstractRequestableLevelNode, Set<DataTime>>());
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ import java.util.Map;
|
|||
import java.util.Set;
|
||||
|
||||
import com.raytheon.uf.common.dataplugin.level.Level;
|
||||
import com.raytheon.uf.common.dataquery.requests.TimeQueryRequest;
|
||||
import com.raytheon.uf.common.time.DataTime;
|
||||
import com.raytheon.uf.viz.core.catalog.LayerProperty;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
|
@ -102,7 +103,8 @@ public class CompositeAverageLevelNode extends UnionLevelNode {
|
|||
* boolean, java.util.Map)
|
||||
*/
|
||||
@Override
|
||||
public Set<DataTime> timeQueryInternal(boolean latestOnly,
|
||||
public Set<DataTime> timeQueryInternal(TimeQueryRequest originalRequest,
|
||||
boolean latestOnly,
|
||||
Map<AbstractRequestableLevelNode, Set<DataTime>> cache,
|
||||
Map<AbstractRequestableLevelNode, Set<DataTime>> latestOnlyCache)
|
||||
throws VizException {
|
||||
|
@ -114,8 +116,8 @@ public class CompositeAverageLevelNode extends UnionLevelNode {
|
|||
for (AbstractRequestableLevelNode request : requests) {
|
||||
// Do not request just latest only because if two nodes have
|
||||
// different latests than this will return no times
|
||||
Set<DataTime> times = request.timeQuery(false, cache,
|
||||
latestOnlyCache);
|
||||
Set<DataTime> times = request.timeQuery(originalRequest, false,
|
||||
cache, latestOnlyCache);
|
||||
if (times == TIME_AGNOSTIC) {
|
||||
continue;
|
||||
} else if (results == TIME_AGNOSTIC) {
|
||||
|
|
|
@ -32,6 +32,7 @@ import java.util.Map.Entry;
|
|||
import java.util.Set;
|
||||
|
||||
import com.raytheon.uf.common.dataplugin.level.Level;
|
||||
import com.raytheon.uf.common.dataquery.requests.TimeQueryRequest;
|
||||
import com.raytheon.uf.common.time.DataTime;
|
||||
import com.raytheon.uf.common.time.DataTime.FLAG;
|
||||
import com.raytheon.uf.viz.core.catalog.LayerProperty;
|
||||
|
@ -152,7 +153,8 @@ public class DerivedLevelNode extends AbstractDerivedLevelNode {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Set<DataTime> timeQueryInternal(boolean latestOnly,
|
||||
public Set<DataTime> timeQueryInternal(TimeQueryRequest originalRequest,
|
||||
boolean latestOnly,
|
||||
Map<AbstractRequestableLevelNode, Set<DataTime>> cache,
|
||||
Map<AbstractRequestableLevelNode, Set<DataTime>> latestOnlyCache)
|
||||
throws VizException {
|
||||
|
@ -179,8 +181,8 @@ public class DerivedLevelNode extends AbstractDerivedLevelNode {
|
|||
}
|
||||
for (DerivParamField field : fieldsKeys) {
|
||||
AbstractRequestableLevelNode node = fields.get(field);
|
||||
Set<DataTime> queryDataTimes = node.timeQuery(false, cache,
|
||||
latestOnlyCache);
|
||||
Set<DataTime> queryDataTimes = node.timeQuery(originalRequest,
|
||||
false, cache, latestOnlyCache);
|
||||
timeCache.put(field, queryDataTimes);
|
||||
if (queryDataTimes == TIME_AGNOSTIC) {
|
||||
if (availableDataTimes == null) {
|
||||
|
@ -288,7 +290,7 @@ public class DerivedLevelNode extends AbstractDerivedLevelNode {
|
|||
if (this.timeCache == null
|
||||
|| this.lastTimeQuery + TIME_QUERY_CACHE_TIME < System
|
||||
.currentTimeMillis()) {
|
||||
this.timeQuery(false);
|
||||
this.timeQuery(null, false);
|
||||
}
|
||||
|
||||
// keep a reference for scope of method
|
||||
|
|
|
@ -24,8 +24,8 @@ import java.util.HashMap;
|
|||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import com.raytheon.uf.common.dataplugin.level.Level;
|
||||
import com.raytheon.uf.common.time.DataTime;
|
||||
|
@ -70,7 +70,7 @@ public class ModelRunLevelNode extends AbstractAliasLevelNode {
|
|||
int timeOut,
|
||||
Map<AbstractRequestableLevelNode, List<AbstractRequestableData>> cache)
|
||||
throws VizException {
|
||||
Set<DataTime> allTimes = this.timeQuery(false);
|
||||
Set<DataTime> allTimes = this.timeQuery(null, false);
|
||||
Set<DataTime> neededTimes = null;
|
||||
DataTime[] requestedTimes = property.getSelectedEntryTime();
|
||||
if (requestedTimes == null) {
|
||||
|
|
|
@ -28,6 +28,7 @@ import java.util.Set;
|
|||
|
||||
import com.raytheon.uf.common.dataplugin.level.Level;
|
||||
import com.raytheon.uf.common.dataquery.requests.RequestConstraint;
|
||||
import com.raytheon.uf.common.dataquery.requests.TimeQueryRequest;
|
||||
import com.raytheon.uf.common.time.DataTime;
|
||||
import com.raytheon.uf.viz.core.catalog.LayerProperty;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
|
@ -116,7 +117,7 @@ public class OrLevelNode extends AbstractDerivedLevelNode {
|
|||
Set<DataTime> requestedTimes = null;
|
||||
DataTime[] requestedTimesArr = property.getSelectedEntryTime();
|
||||
if (requestedTimesArr == null) {
|
||||
requestedTimes = this.timeQuery(false);
|
||||
requestedTimes = this.timeQuery(null, false);
|
||||
} else {
|
||||
requestedTimes = new HashSet<DataTime>(
|
||||
Arrays.asList(requestedTimesArr));
|
||||
|
@ -144,14 +145,15 @@ public class OrLevelNode extends AbstractDerivedLevelNode {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected Set<DataTime> timeQueryInternal(boolean latestOnly,
|
||||
protected Set<DataTime> timeQueryInternal(TimeQueryRequest originalRequest,
|
||||
boolean latestOnly,
|
||||
Map<AbstractRequestableLevelNode, Set<DataTime>> cache,
|
||||
Map<AbstractRequestableLevelNode, Set<DataTime>> latestOnlyCache)
|
||||
throws VizException {
|
||||
Set<DataTime> results = new HashSet<DataTime>();
|
||||
for (AbstractRequestableLevelNode node : nodes) {
|
||||
Set<DataTime> times = node.timeQuery(latestOnly, cache,
|
||||
latestOnlyCache);
|
||||
Set<DataTime> times = node.timeQuery(originalRequest, latestOnly,
|
||||
cache, latestOnlyCache);
|
||||
if (times == AbstractRequestableLevelNode.TIME_AGNOSTIC) {
|
||||
return times;
|
||||
} else {
|
||||
|
|
|
@ -99,7 +99,8 @@ public class StaticDataLevelNode extends AbstractDerivedLevelNode {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Set<DataTime> timeQueryInternal(boolean latestOnly,
|
||||
public Set<DataTime> timeQueryInternal(TimeQueryRequest originalRequest,
|
||||
boolean latestOnly,
|
||||
Map<AbstractRequestableLevelNode, Set<DataTime>> cache,
|
||||
Map<AbstractRequestableLevelNode, Set<DataTime>> latestOnlyCache)
|
||||
throws VizException {
|
||||
|
@ -107,7 +108,8 @@ public class StaticDataLevelNode extends AbstractDerivedLevelNode {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected TimeQueryRequest getTimeQueryInternal(boolean latestOnly,
|
||||
protected TimeQueryRequest getTimeQueryInternal(
|
||||
TimeQueryRequest originalRequest, boolean latestOnly,
|
||||
Map<AbstractRequestableLevelNode, Set<DataTime>> cache)
|
||||
throws VizException {
|
||||
return null;
|
||||
|
|
|
@ -28,6 +28,7 @@ import java.util.Map.Entry;
|
|||
import java.util.Set;
|
||||
|
||||
import com.raytheon.uf.common.dataplugin.level.Level;
|
||||
import com.raytheon.uf.common.dataquery.requests.TimeQueryRequest;
|
||||
import com.raytheon.uf.common.time.DataTime;
|
||||
import com.raytheon.uf.viz.core.catalog.LayerProperty;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
|
@ -82,7 +83,7 @@ public class TimeRangeLevelNode extends AbstractAliasLevelNode {
|
|||
int timeOut,
|
||||
Map<AbstractRequestableLevelNode, List<AbstractRequestableData>> cache)
|
||||
throws VizException {
|
||||
Set<DataTime> allTime = sourceNode.timeQuery(false);
|
||||
Set<DataTime> allTime = sourceNode.timeQuery(null, false);
|
||||
Map<DataTime, List<DataTime>> goodTimes = new HashMap<DataTime, List<DataTime>>();
|
||||
Set<DataTime> timesToRequest = new HashSet<DataTime>();
|
||||
for (DataTime time : allTime) {
|
||||
|
@ -126,12 +127,13 @@ public class TimeRangeLevelNode extends AbstractAliasLevelNode {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Set<DataTime> timeQueryInternal(boolean latestOnly,
|
||||
public Set<DataTime> timeQueryInternal(TimeQueryRequest originalRequest,
|
||||
boolean latestOnly,
|
||||
Map<AbstractRequestableLevelNode, Set<DataTime>> cache,
|
||||
Map<AbstractRequestableLevelNode, Set<DataTime>> latestOnlyCache)
|
||||
throws VizException {
|
||||
Set<DataTime> allTime = sourceNode.timeQuery(false, cache,
|
||||
latestOnlyCache);
|
||||
Set<DataTime> allTime = sourceNode.timeQuery(originalRequest, false,
|
||||
cache, latestOnlyCache);
|
||||
Set<DataTime> goodTimes = new HashSet<DataTime>();
|
||||
for (DataTime time : allTime) {
|
||||
if (allTime.containsAll(calculateNeededTimes(time))) {
|
||||
|
|
|
@ -30,6 +30,7 @@ import java.util.Map.Entry;
|
|||
import java.util.Set;
|
||||
|
||||
import com.raytheon.uf.common.dataplugin.level.Level;
|
||||
import com.raytheon.uf.common.dataquery.requests.TimeQueryRequest;
|
||||
import com.raytheon.uf.common.time.DataTime;
|
||||
import com.raytheon.uf.viz.core.catalog.LayerProperty;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
|
@ -142,7 +143,8 @@ public class UnionLevelNode extends AbstractDerivedLevelNode {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Set<DataTime> timeQueryInternal(boolean latestOnly,
|
||||
public Set<DataTime> timeQueryInternal(TimeQueryRequest originalRequest,
|
||||
boolean latestOnly,
|
||||
Map<AbstractRequestableLevelNode, Set<DataTime>> cache,
|
||||
Map<AbstractRequestableLevelNode, Set<DataTime>> latestOnlyCache)
|
||||
throws VizException {
|
||||
|
@ -153,8 +155,8 @@ public class UnionLevelNode extends AbstractDerivedLevelNode {
|
|||
List<AbstractRequestableLevelNode> requests = new ArrayList<AbstractRequestableLevelNode>(
|
||||
nodes);
|
||||
for (AbstractRequestableLevelNode request : requests) {
|
||||
Set<DataTime> times = request.timeQuery(latestOnly, cache,
|
||||
latestOnlyCache);
|
||||
Set<DataTime> times = request.timeQuery(originalRequest,
|
||||
latestOnly, cache, latestOnlyCache);
|
||||
if (times == TIME_AGNOSTIC) {
|
||||
continue;
|
||||
} else if (results == TIME_AGNOSTIC) {
|
||||
|
|
|
@ -46,8 +46,6 @@ 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.IGraphicsTarget.RasterMode;
|
||||
import com.raytheon.uf.viz.core.IMesh;
|
||||
import com.raytheon.uf.viz.core.PixelCoverage;
|
||||
import com.raytheon.uf.viz.core.drawables.ColorMapLoader;
|
||||
import com.raytheon.uf.viz.core.drawables.ColorMapParameters;
|
||||
import com.raytheon.uf.viz.core.drawables.IImage;
|
||||
|
@ -55,15 +53,12 @@ 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.map.IMapDescriptor;
|
||||
import com.raytheon.uf.viz.core.map.IMapMeshExtension;
|
||||
import com.raytheon.uf.viz.core.rsc.AbstractVizResource;
|
||||
import com.raytheon.uf.viz.core.rsc.IResourceDataChanged;
|
||||
import com.raytheon.uf.viz.core.rsc.LoadProperties;
|
||||
import com.raytheon.uf.viz.core.rsc.capabilities.ColorMapCapability;
|
||||
import com.raytheon.uf.viz.core.rsc.capabilities.ImagingCapability;
|
||||
import com.raytheon.uf.viz.core.rsc.hdf5.ImageTile;
|
||||
import com.vividsolutions.jts.geom.Coordinate;
|
||||
import com.vividsolutions.jts.geom.Envelope;
|
||||
|
||||
/**
|
||||
* NPP VIIRS resource. Responsible for drawing a single color band
|
||||
|
@ -194,8 +189,8 @@ public class VIIRSResource extends
|
|||
data.projectionData = new float[][] { lonFloats, latFloats };
|
||||
|
||||
data.tile = new ImageTile();
|
||||
data.tile.rect = new Rectangle(0, 0, width, height);
|
||||
data.tile.envelope = new Envelope(0, width, 0, height);
|
||||
// data.tile.rect = new Rectangle(0, 0, width, height);
|
||||
// data.tile.envelope = new Envelope(0, width, 0, height);
|
||||
|
||||
calculateMesh(data, target);
|
||||
|
||||
|
@ -384,20 +379,21 @@ public class VIIRSResource extends
|
|||
*/
|
||||
private void calculateMesh(VIIRSData frame, IGraphicsTarget target)
|
||||
throws VizException {
|
||||
Rectangle tile = frame.tile.rect;
|
||||
frame.tile.coverage = new PixelCoverage(new Coordinate(tile.getMinX(),
|
||||
tile.getMinY()),
|
||||
new Coordinate(tile.getMaxX(), tile.getMinY()), new Coordinate(
|
||||
tile.getMaxX(), tile.getMaxY()), new Coordinate(
|
||||
tile.getMinX(), tile.getMaxY()));
|
||||
IMesh mesh = target.getExtension(IMapMeshExtension.class)
|
||||
.constructMesh(descriptor);
|
||||
mesh.calculateMesh(frame.tile.coverage, frame.tile,
|
||||
new VIIRSDataMathTransform(frame.projectionData,
|
||||
frame.tile.rect.width, frame.tile.rect.height));
|
||||
frame.projectionData = null;
|
||||
frame.tile.coverage.setMesh(mesh);
|
||||
frame.projectionData = null;
|
||||
// Rectangle tile = frame.tile.rect;
|
||||
// frame.tile.coverage = new PixelCoverage(new
|
||||
// Coordinate(tile.getMinX(),
|
||||
// tile.getMinY()),
|
||||
// new Coordinate(tile.getMaxX(), tile.getMinY()), new Coordinate(
|
||||
// tile.getMaxX(), tile.getMaxY()), new Coordinate(
|
||||
// tile.getMinX(), tile.getMaxY()));
|
||||
// IMesh mesh = target.getExtension(IMapMeshExtension.class)
|
||||
// .constructMesh(descriptor);
|
||||
// mesh.calculateMesh(frame.tile.coverage, frame.tile,
|
||||
// new VIIRSDataMathTransform(frame.projectionData,
|
||||
// frame.tile.rect.width, frame.tile.rect.height));
|
||||
// frame.projectionData = null;
|
||||
// frame.tile.coverage.setMesh(mesh);
|
||||
// frame.projectionData = null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
// this shader program sets values into a mosaic texture
|
||||
// which is the same size as the screen (frame buffer)
|
||||
// Use depth buffer texture
|
||||
|
||||
uniform sampler2D radarData;
|
||||
uniform sampler2D mosaicTexture;
|
||||
uniform sampler2D depthTexture;
|
||||
uniform int height;
|
||||
uniform int width;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
// TODO: Mimic mosaicMax except use depthTexture to look up current
|
||||
// depth buffer info (which will actually store the current distance
|
||||
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
// this shader program sets values into a mosaic texture
|
||||
// which is the same size as the screen (frame buffer)
|
||||
|
||||
uniform sampler2D radarData;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec4 radarVal = texture2D(radarData,gl_TexCoord[0].st);
|
||||
gl_FragColor = vec4(radarVal.r,0.0,0.0,1.0);
|
||||
}
|
|
@ -1,24 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?eclipse version="3.2"?>
|
||||
<plugin>
|
||||
<extension
|
||||
point="com.raytheon.viz.core.gl.shader">
|
||||
<shader
|
||||
loaderClass="com.raytheon.uf.viz.radar.gl.mosaic.MosaicShaderLoader"
|
||||
programName="mosaicMaxVal">
|
||||
</shader>
|
||||
<shader
|
||||
loaderClass="com.raytheon.uf.viz.radar.gl.mosaic.MosaicShaderLoader"
|
||||
programName="mosaicMinDist">
|
||||
</shader>
|
||||
</extension>
|
||||
<extension
|
||||
point="com.raytheon.uf.viz.core.graphicsExtension">
|
||||
<graphicsExtension
|
||||
class="com.raytheon.uf.viz.radar.gl.GLRadialMeshExtension">
|
||||
</graphicsExtension>
|
||||
<graphicsExtension
|
||||
class="com.raytheon.uf.viz.radar.gl.mosaic.GLRadarMosaicRendererFactory">
|
||||
class="com.raytheon.uf.viz.radar.gl.mosaic.GLRadarMosaicImageExtension">
|
||||
</graphicsExtension>
|
||||
</extension>
|
||||
</plugin>
|
||||
|
|
|
@ -59,7 +59,7 @@ public class GLRadialMeshExtension extends GraphicsExtension<IGLTarget>
|
|||
throws VizException {
|
||||
String format = radarData.getFormat();
|
||||
if ("Radial".equals(format)) {
|
||||
return RadarRadialMeshCache.getMesh(radarData, descriptor);
|
||||
return RadarRadialMesh.getMesh(radarData, descriptor);
|
||||
} else {
|
||||
throw new VizException(
|
||||
"Cannot construct radial meshes for non radial RadarRecords");
|
||||
|
@ -74,6 +74,6 @@ public class GLRadialMeshExtension extends GraphicsExtension<IGLTarget>
|
|||
*/
|
||||
@Override
|
||||
public int getCompatibilityValue(IGLTarget target) {
|
||||
return Compatibilty.TARGET_COMPATIBLE.value;
|
||||
return Compatibilty.TARGET_COMPATIBLE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,559 +0,0 @@
|
|||
/**
|
||||
* 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.radar.gl;
|
||||
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.eclipse.swt.graphics.RGB;
|
||||
import org.geotools.coverage.grid.GeneralGridGeometry;
|
||||
|
||||
import com.raytheon.uf.common.colormap.IColorMap;
|
||||
import com.raytheon.uf.viz.core.DrawableCircle;
|
||||
import com.raytheon.uf.viz.core.DrawableColorMap;
|
||||
import com.raytheon.uf.viz.core.DrawableImage;
|
||||
import com.raytheon.uf.viz.core.DrawableLine;
|
||||
import com.raytheon.uf.viz.core.DrawableString;
|
||||
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.data.IDataPreparer;
|
||||
import com.raytheon.uf.viz.core.data.IRenderedImageCallback;
|
||||
import com.raytheon.uf.viz.core.drawables.ColorMapParameters;
|
||||
import com.raytheon.uf.viz.core.drawables.IDescriptor;
|
||||
import com.raytheon.uf.viz.core.drawables.IFont;
|
||||
import com.raytheon.uf.viz.core.drawables.IFont.Style;
|
||||
import com.raytheon.uf.viz.core.drawables.IImage;
|
||||
import com.raytheon.uf.viz.core.drawables.IRenderableDisplay;
|
||||
import com.raytheon.uf.viz.core.drawables.IShadedShape;
|
||||
import com.raytheon.uf.viz.core.drawables.IWireframeShape;
|
||||
import com.raytheon.uf.viz.core.drawables.PaintProperties;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
import com.raytheon.uf.viz.core.geom.PixelCoordinate;
|
||||
import com.raytheon.viz.core.gl.IGLTarget;
|
||||
import com.vividsolutions.jts.geom.LinearRing;
|
||||
|
||||
/**
|
||||
* IGraphicsTarget for mosaicing radar data, delegates all calls to an IGLTarget
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jun 22, 2010 mschenke Initial creation
|
||||
* Jul 19, 2010 #5952 bkowal Defined the 'updateExtent' method.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author mschenke
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class MosaicGLTarget implements IGraphicsTarget {
|
||||
|
||||
private IGLTarget delegate;
|
||||
|
||||
public MosaicGLTarget(IGLTarget delegateTarget) {
|
||||
this.delegate = delegateTarget;
|
||||
}
|
||||
|
||||
/* Important functions!!! */
|
||||
public boolean drawRaster(IImage image, PixelCoverage extent,
|
||||
PaintProperties paintProps, RasterMode mode) throws VizException {
|
||||
return delegate.drawRaster(image, extent, paintProps, mode,
|
||||
"mosaicMaxVal");
|
||||
}
|
||||
|
||||
public boolean drawRaster(IImage image, PixelCoverage extent,
|
||||
PaintProperties paintProps) throws VizException {
|
||||
return delegate.drawRaster(image, extent, paintProps, "mosaicMaxVal");
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.viz.core.IGraphicsTarget#drawRasters(com.raytheon.uf.
|
||||
* viz.core.drawables.PaintProperties,
|
||||
* com.raytheon.uf.viz.core.DrawableImage[])
|
||||
*/
|
||||
@Override
|
||||
public boolean drawRasters(PaintProperties paintProps,
|
||||
DrawableImage... images) throws VizException {
|
||||
return delegate.drawRasters("mosaicMaxVal", paintProps, images);
|
||||
}
|
||||
|
||||
/* Standard delegate functions */
|
||||
public void beginFrame(IRenderableDisplay display, boolean isClearBackground) {
|
||||
delegate.beginFrame(display, isClearBackground);
|
||||
}
|
||||
|
||||
public IColorMap buildColorMap(String name) throws VizException {
|
||||
return delegate.buildColorMap(name);
|
||||
}
|
||||
|
||||
public void clearClippingPlane() {
|
||||
delegate.clearClippingPlane();
|
||||
}
|
||||
|
||||
public IShadedShape createShadedShape(boolean mutable,
|
||||
IDescriptor descriptor, boolean tesselate) {
|
||||
return delegate.createShadedShape(mutable, descriptor, tesselate);
|
||||
}
|
||||
|
||||
public IWireframeShape createWireframeShape(boolean mutable,
|
||||
GeneralGridGeometry geom, float simplificationLevel,
|
||||
boolean spatialChopFlag, IExtent extent) {
|
||||
return delegate.createWireframeShape(mutable, geom,
|
||||
simplificationLevel, spatialChopFlag, extent);
|
||||
}
|
||||
|
||||
public IWireframeShape createWireframeShape(boolean mutableFlag,
|
||||
GeneralGridGeometry geom) {
|
||||
return delegate.createWireframeShape(mutableFlag, geom);
|
||||
}
|
||||
|
||||
public IWireframeShape createWireframeShape(boolean mutable,
|
||||
IDescriptor descriptor, float simplificationLevel,
|
||||
boolean spatialChopFlag, IExtent extent) {
|
||||
return delegate.createWireframeShape(mutable, descriptor,
|
||||
simplificationLevel, spatialChopFlag, extent);
|
||||
}
|
||||
|
||||
public IWireframeShape createWireframeShape(boolean mutable,
|
||||
IDescriptor descriptor, float simplificationLevel) {
|
||||
return delegate.createWireframeShape(mutable, descriptor,
|
||||
simplificationLevel);
|
||||
}
|
||||
|
||||
public IWireframeShape createWireframeShape(boolean mutable,
|
||||
IDescriptor descriptor) {
|
||||
return delegate.createWireframeShape(mutable, descriptor);
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
delegate.dispose();
|
||||
}
|
||||
|
||||
public void drawArc(double x1, double y1, double z1, double radius,
|
||||
RGB color, float width, int startAzimuth, int arcWidth,
|
||||
LineStyle lineStyle, boolean includeSides) throws VizException {
|
||||
delegate.drawArc(x1, y1, z1, radius, color, width, startAzimuth,
|
||||
arcWidth, lineStyle, includeSides);
|
||||
}
|
||||
|
||||
public void drawCircle(double x1, double y1, double z1, double radius,
|
||||
RGB color, float width) throws VizException {
|
||||
delegate.drawCircle(x1, y1, z1, radius, color, width);
|
||||
}
|
||||
|
||||
public void drawColorRamp(IColorMap colorMap, IExtent pixelExtent,
|
||||
float blendAlpha) throws VizException {
|
||||
delegate.drawColorRamp(colorMap, pixelExtent, blendAlpha);
|
||||
}
|
||||
|
||||
public void drawCylinder(PixelCoordinate coord, RGB color, float alpha,
|
||||
double height, double baseRadius, double topRadius, int sideCount,
|
||||
int sliceCount, double rotation, double lean) {
|
||||
delegate.drawCylinder(coord, color, alpha, height, baseRadius,
|
||||
topRadius, sideCount, sliceCount, rotation, lean);
|
||||
}
|
||||
|
||||
public void drawFilledCircle(double x, double y, double z, double radius,
|
||||
RGB color) throws VizException {
|
||||
delegate.drawFilledCircle(x, y, z, radius, color);
|
||||
}
|
||||
|
||||
public void drawLine(double x1, double y1, double z1, double x2, double y2,
|
||||
double z2, RGB color, float width, LineStyle lineStyle)
|
||||
throws VizException {
|
||||
delegate.drawLine(x1, y1, z1, x2, y2, z2, color, width, lineStyle);
|
||||
}
|
||||
|
||||
public void drawLine(double x1, double y1, double z1, double x2, double y2,
|
||||
double z2, RGB color, float width) throws VizException {
|
||||
delegate.drawLine(x1, y1, z1, x2, y2, z2, color, width);
|
||||
}
|
||||
|
||||
public void drawPoint(double x, double y, double z, RGB color,
|
||||
PointStyle pointStyle) throws VizException {
|
||||
delegate.drawPoint(x, y, z, color, pointStyle);
|
||||
}
|
||||
|
||||
public void drawRect(IExtent pe, RGB color, float lineWidth, double alpha)
|
||||
throws VizException {
|
||||
delegate.drawRect(pe, color, lineWidth, alpha);
|
||||
}
|
||||
|
||||
public void drawShadedPolygon(LinearRing poly, RGB color, double alpha,
|
||||
byte[] pattern) throws VizException {
|
||||
delegate.drawShadedPolygon(poly, color, alpha, pattern);
|
||||
}
|
||||
|
||||
public void drawShadedRect(IExtent pe, RGB color, double alpha,
|
||||
byte[] pattern) throws VizException {
|
||||
delegate.drawShadedRect(pe, color, alpha, pattern);
|
||||
}
|
||||
|
||||
public void drawShadedShape(IShadedShape shape, float alpha)
|
||||
throws VizException {
|
||||
delegate.drawShadedShape(shape, alpha);
|
||||
}
|
||||
|
||||
public void drawString(IFont font, String text, double x, double y,
|
||||
double z, TextStyle textStyle, RGB color,
|
||||
HorizontalAlignment horizontalAlignment, Double rotation)
|
||||
throws VizException {
|
||||
delegate.drawString(font, text, x, y, z, textStyle, color,
|
||||
horizontalAlignment, rotation);
|
||||
}
|
||||
|
||||
public void drawString(IFont font, String text, double x, double y,
|
||||
double z, TextStyle textStyle, RGB color,
|
||||
HorizontalAlignment horizontalAlignment,
|
||||
VerticalAlignment verticalAlignment, Double rotation)
|
||||
throws VizException {
|
||||
delegate.drawString(font, text, x, y, z, textStyle, color,
|
||||
horizontalAlignment, verticalAlignment, rotation);
|
||||
}
|
||||
|
||||
public void drawStrings(IFont font, String[] text, double x, double y,
|
||||
double z, TextStyle textStyle, RGB[] colors,
|
||||
HorizontalAlignment horizontalAlignment,
|
||||
VerticalAlignment verticalAlignment) throws VizException {
|
||||
delegate.drawStrings(font, text, x, y, z, textStyle, colors,
|
||||
horizontalAlignment, verticalAlignment);
|
||||
}
|
||||
|
||||
public void drawString(IFont font, String string, double xPos, double yPos,
|
||||
double zPos, TextStyle textStyle, RGB color,
|
||||
HorizontalAlignment horizontalAlignment,
|
||||
VerticalAlignment verticalAlignment, Double rotation, float alpha,
|
||||
double magnification) throws VizException {
|
||||
// not implemented
|
||||
}
|
||||
|
||||
public void drawWireframeShape(IWireframeShape shape, RGB color,
|
||||
float lineWidth, LineStyle lineStyle, IFont font)
|
||||
throws VizException {
|
||||
delegate.drawWireframeShape(shape, color, lineWidth, lineStyle, font);
|
||||
}
|
||||
|
||||
public void drawWireframeShape(IWireframeShape shape, RGB color,
|
||||
float lineWidth, LineStyle lineStyle, IFont font, float alpha)
|
||||
throws VizException {
|
||||
delegate.drawWireframeShape(shape, color, lineWidth, lineStyle, font,
|
||||
alpha);
|
||||
}
|
||||
|
||||
public void drawWireframeShape(IWireframeShape shape, RGB color,
|
||||
float lineWidth, LineStyle lineStyle) throws VizException {
|
||||
delegate.drawWireframeShape(shape, color, lineWidth, lineStyle);
|
||||
}
|
||||
|
||||
public void drawWireframeShape(IWireframeShape shape, RGB color,
|
||||
float lineWidth, LineStyle lineStyle, float alpha)
|
||||
throws VizException {
|
||||
delegate.drawWireframeShape(shape, color, lineWidth, lineStyle, alpha);
|
||||
}
|
||||
|
||||
public void drawWireframeShape(IWireframeShape shape, RGB color,
|
||||
float lineWidth) throws VizException {
|
||||
delegate.drawWireframeShape(shape, color, lineWidth);
|
||||
}
|
||||
|
||||
public void endFrame() {
|
||||
delegate.endFrame();
|
||||
}
|
||||
|
||||
public IFont getDefaultFont() {
|
||||
return delegate.getDefaultFont();
|
||||
}
|
||||
|
||||
public double[] getPointOnCircle(double x1, double y1, double z1,
|
||||
double radius, double angle) throws VizException {
|
||||
return delegate.getPointOnCircle(x1, y1, z1, radius, angle);
|
||||
}
|
||||
|
||||
public Rectangle2D getStringBounds(IFont font, String text) {
|
||||
return delegate.getStringBounds(font, text);
|
||||
}
|
||||
|
||||
public String getViewType() {
|
||||
return delegate.getViewType();
|
||||
}
|
||||
|
||||
public void init() {
|
||||
delegate.init();
|
||||
}
|
||||
|
||||
public IFont initializeFont(File fontFile, float size, Style[] styles) {
|
||||
return delegate.initializeFont(fontFile, size, styles);
|
||||
}
|
||||
|
||||
public IFont initializeFont(String fontName, float size, Style[] styles) {
|
||||
return delegate.initializeFont(fontName, size, styles);
|
||||
}
|
||||
|
||||
public IFont initializeFont(String font) {
|
||||
return delegate.initializeFont(font);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public IImage initializeRaster(IDataPreparer preparer,
|
||||
ColorMapParameters optionalParams) {
|
||||
return delegate.initializeRaster(preparer, optionalParams);
|
||||
}
|
||||
|
||||
public IImage initializeRaster(IRenderedImageCallback imageCallback) {
|
||||
return delegate.initializeRaster(imageCallback);
|
||||
}
|
||||
|
||||
public boolean isNeedsRefresh() {
|
||||
return delegate.isNeedsRefresh();
|
||||
}
|
||||
|
||||
public void resize() {
|
||||
delegate.resize();
|
||||
}
|
||||
|
||||
public BufferedImage screenshot() {
|
||||
return delegate.screenshot();
|
||||
}
|
||||
|
||||
public void setBackgroundColor(RGB backgroundColor) {
|
||||
delegate.setBackgroundColor(backgroundColor);
|
||||
}
|
||||
|
||||
public void setNeedsRefresh(boolean needsRefresh) {
|
||||
delegate.setNeedsRefresh(needsRefresh);
|
||||
}
|
||||
|
||||
public void setupClippingPlane(IExtent extent) {
|
||||
delegate.setupClippingPlane(extent);
|
||||
}
|
||||
|
||||
public void setUseBuiltinColorbar(boolean isColorbarDisplayed) {
|
||||
delegate.setUseBuiltinColorbar(isColorbarDisplayed);
|
||||
}
|
||||
|
||||
public void stage(IImage image) throws VizException {
|
||||
delegate.stage(image);
|
||||
}
|
||||
|
||||
public void updateExtent(IExtent updatedExtent) {
|
||||
/* Do Nothing */
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.viz.core.IGraphicsTarget#getStringBounds(com.raytheon
|
||||
* .uf.viz.core.drawables.IFont, java.lang.String[],
|
||||
* com.raytheon.uf.viz.core.IGraphicsTarget.TextStyle)
|
||||
*/
|
||||
@Override
|
||||
public Rectangle2D getStringBounds(IFont font, String[] text,
|
||||
TextStyle style) {
|
||||
return delegate.getStringBounds(font, text, style);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.viz.core.IGraphicsTarget#drawColorRamp(com.raytheon.uf
|
||||
* .common.colormap.IColorMap, com.raytheon.uf.viz.core.IExtent, float,
|
||||
* float, float)
|
||||
*/
|
||||
@Override
|
||||
public void drawColorRamp(IColorMap colorMap, IExtent pixelExtent,
|
||||
float blendAlpha, float brightness, float contrast)
|
||||
throws VizException {
|
||||
delegate.drawColorRamp(colorMap, pixelExtent, blendAlpha, brightness,
|
||||
contrast);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.viz.core.IGraphicsTarget#drawShadedShape(com.raytheon
|
||||
* .uf.viz.core.drawables.IShadedShape, float, float)
|
||||
*/
|
||||
@Override
|
||||
public void drawShadedShape(IShadedShape shape, float alpha,
|
||||
float brightness) throws VizException {
|
||||
delegate.drawShadedShape(shape, alpha, brightness);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.viz.core.IGraphicsTarget#drawColorRamp(com.raytheon.uf
|
||||
* .viz.core.drawables.ColorMapParameters, com.raytheon.uf.viz.core.IExtent,
|
||||
* float)
|
||||
*/
|
||||
@Override
|
||||
public void drawColorRamp(ColorMapParameters colorMapParams,
|
||||
IExtent pixelExtent, float blendAlpha) throws VizException {
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.viz.core.IGraphicsTarget#drawColorRamp(com.raytheon.uf
|
||||
* .viz.core.drawables.ColorMapParameters, com.raytheon.uf.viz.core.IExtent,
|
||||
* float, float, float)
|
||||
*/
|
||||
@Override
|
||||
public void drawColorRamp(ColorMapParameters colorMapParams,
|
||||
IExtent pixelExtent, float blendAlpha, float brightness,
|
||||
float contrast) throws VizException {
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.uf.viz.core.IGraphicsTarget#drawPoint(double, double,
|
||||
* double, org.eclipse.swt.graphics.RGB,
|
||||
* com.raytheon.uf.viz.core.IGraphicsTarget.PointStyle, float)
|
||||
*/
|
||||
@Override
|
||||
public void drawPoint(double x, double y, double z, RGB color,
|
||||
PointStyle pointStyle, float magnification) throws VizException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderOffscreen(IImage offscreenImage) throws VizException {
|
||||
delegate.renderOffscreen(offscreenImage);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderOnscreen() throws VizException {
|
||||
delegate.renderOnscreen();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.viz.core.IGraphicsTarget#getStringsBounds(com.raytheon
|
||||
* .uf.viz.core.DrawStringsParameters)
|
||||
*/
|
||||
@Override
|
||||
public Rectangle2D getStringsBounds(DrawableString parameters) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.viz.core.IGraphicsTarget#getStringsBounds(com.raytheon
|
||||
* .uf.viz.core.DrawStringsParameters, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public Rectangle2D getStringsBounds(DrawableString parameters, String string) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.viz.core.IGraphicsTarget#drawStrings(com.raytheon.uf.
|
||||
* viz.core.DrawStringsParameters)
|
||||
*/
|
||||
@Override
|
||||
public void drawStrings(DrawableString... parameters) throws VizException {
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.viz.core.IGraphicsTarget#drawColorRamp(com.raytheon.uf
|
||||
* .viz.core.DrawableColorMap)
|
||||
*/
|
||||
@Override
|
||||
public void drawColorRamp(DrawableColorMap colorMap) throws VizException {
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.viz.core.IGraphicsTarget#drawCircle(com.raytheon.uf.viz
|
||||
* .core.DrawableCircle)
|
||||
*/
|
||||
@Override
|
||||
public void drawCircle(DrawableCircle... circle) throws VizException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawStrings(Collection<DrawableString> parameters)
|
||||
throws VizException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawPoints(Collection<double[]> locations, RGB color,
|
||||
PointStyle pointStyle, float magnification) throws VizException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawShadedShapes(float alpha, float brightness,
|
||||
IShadedShape... shapes) throws VizException {
|
||||
delegate.drawShadedShapes(alpha, brightness, shapes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getExtension(Class<T> extensionClass) throws VizException {
|
||||
return delegate.getExtension(extensionClass);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.viz.core.IGraphicsTarget#drawLine(com.raytheon.uf.viz
|
||||
* .core.DrawableLine[])
|
||||
*/
|
||||
@Override
|
||||
public void drawLine(DrawableLine... lines) throws VizException {
|
||||
delegate.drawLine(lines);
|
||||
}
|
||||
|
||||
}
|
|
@ -19,20 +19,25 @@
|
|||
**/
|
||||
package com.raytheon.uf.viz.radar.gl;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.media.opengl.GL;
|
||||
|
||||
import org.geotools.coverage.grid.GeneralGridGeometry;
|
||||
import org.geotools.coverage.grid.GridGeometry2D;
|
||||
import org.opengis.referencing.operation.MathTransform;
|
||||
import org.opengis.referencing.operation.TransformException;
|
||||
|
||||
import com.raytheon.uf.common.dataplugin.radar.RadarRecord;
|
||||
import com.raytheon.uf.common.dataplugin.radar.util.RadarUtil;
|
||||
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.map.IMapDescriptor;
|
||||
import com.raytheon.uf.viz.core.rsc.hdf5.ImageTile;
|
||||
import com.raytheon.uf.viz.core.drawables.IDescriptor;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
import com.raytheon.viz.core.gl.AbstractGLMesh;
|
||||
import com.raytheon.viz.core.gl.GLGeometryObject2D;
|
||||
import com.raytheon.viz.core.gl.GLGeometryObject2D.GLGeometryObjectData;
|
||||
import com.raytheon.viz.core.gl.SharedCoordMap.SharedCoordinateKey;
|
||||
|
||||
/**
|
||||
|
@ -55,30 +60,133 @@ public class RadarRadialMesh extends AbstractGLMesh {
|
|||
private static final transient IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(RadarRadialMesh.class);
|
||||
|
||||
private static class CacheKey {
|
||||
private final float latitude;
|
||||
|
||||
private final float longitude;
|
||||
|
||||
private final int hashCode;
|
||||
|
||||
private final int numBins;
|
||||
|
||||
private final int numRadials;
|
||||
|
||||
private final int gateResolution;
|
||||
|
||||
private final float trueElevationAngle;
|
||||
|
||||
private final int jStart;
|
||||
|
||||
private final float[] angleData;
|
||||
|
||||
private final GeneralGridGeometry gridGeometry;
|
||||
|
||||
public CacheKey(float latitude, float longitude, int numBins,
|
||||
int numRadials, int gateResolution, float trueElevationAngle,
|
||||
int jStart, float[] angleData, GeneralGridGeometry gridGeometry) {
|
||||
this.latitude = latitude;
|
||||
this.longitude = longitude;
|
||||
this.numBins = numBins;
|
||||
this.numRadials = numRadials;
|
||||
this.gateResolution = gateResolution;
|
||||
this.trueElevationAngle = trueElevationAngle;
|
||||
this.jStart = jStart;
|
||||
this.angleData = angleData;
|
||||
this.gridGeometry = gridGeometry;
|
||||
final int prime = 31;
|
||||
int hashCode = 1;
|
||||
hashCode = prime * hashCode + Arrays.hashCode(angleData);
|
||||
hashCode = prime * hashCode + gateResolution;
|
||||
hashCode = prime * hashCode + jStart;
|
||||
hashCode = prime * hashCode + Float.floatToIntBits(latitude);
|
||||
hashCode = prime * hashCode + Float.floatToIntBits(longitude);
|
||||
hashCode = prime * hashCode + numBins;
|
||||
hashCode = prime * hashCode + numRadials;
|
||||
hashCode = prime * hashCode
|
||||
+ Float.floatToIntBits(trueElevationAngle);
|
||||
hashCode = prime * hashCode + gridGeometry.hashCode();
|
||||
this.hashCode = hashCode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return hashCode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
CacheKey other = (CacheKey) obj;
|
||||
if (hashCode != other.hashCode)
|
||||
return false;
|
||||
if (gateResolution != other.gateResolution)
|
||||
return false;
|
||||
if (jStart != other.jStart)
|
||||
return false;
|
||||
if (latitude != other.latitude)
|
||||
return false;
|
||||
if (longitude != other.longitude)
|
||||
return false;
|
||||
if (numBins != other.numBins)
|
||||
return false;
|
||||
if (numRadials != other.numRadials)
|
||||
return false;
|
||||
if (Float.floatToIntBits(trueElevationAngle) != Float
|
||||
.floatToIntBits(other.trueElevationAngle))
|
||||
return false;
|
||||
if (!Arrays.equals(angleData, other.angleData))
|
||||
return false;
|
||||
if (gridGeometry != null && other.gridGeometry == null) {
|
||||
return false;
|
||||
}
|
||||
if (gridGeometry == null && other.gridGeometry != null) {
|
||||
return false;
|
||||
}
|
||||
if (gridGeometry != null
|
||||
&& !gridGeometry.equals(other.gridGeometry)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private static Map<CacheKey, RadarRadialMesh> cache = new HashMap<CacheKey, RadarRadialMesh>();
|
||||
|
||||
/** The record to build the mesh for */
|
||||
private RadarRecord record;
|
||||
|
||||
private IMapDescriptor descriptor;
|
||||
private CacheKey cacheKey;
|
||||
|
||||
public RadarRadialMesh(IMapDescriptor descriptor, RadarRecord record) {
|
||||
super(GL.GL_TRIANGLE_STRIP, descriptor);
|
||||
private int refCount;
|
||||
|
||||
public RadarRadialMesh(RadarRecord record,
|
||||
GeneralGridGeometry targetGeometry, CacheKey cacheKey)
|
||||
throws VizException {
|
||||
super(GL.GL_TRIANGLE_STRIP);
|
||||
this.record = record;
|
||||
this.descriptor = descriptor;
|
||||
this.cacheKey = cacheKey;
|
||||
initialize(
|
||||
RadarUtil.constructGridGeometry(record.getCRS(),
|
||||
RadarUtil.calculateExtent(record),
|
||||
Math.max(record.getNumBins(), record.getNumRadials())),
|
||||
targetGeometry);
|
||||
refCount = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected double[][][] generateWorldCoords(ImageTile tile, MathTransform mt)
|
||||
throws TransformException {
|
||||
protected double[][][] generateWorldCoords(GridGeometry2D imageGeometry,
|
||||
MathTransform mt) throws TransformException {
|
||||
|
||||
int horizontalDivisions = key.horizontalDivisions;
|
||||
int verticalDivisions = key.verticalDivisions;
|
||||
int verticalDivisions = key.verticalDivisions + 1;
|
||||
|
||||
// get dx and dy for texture points
|
||||
float dX = (1.0f / (horizontalDivisions));
|
||||
|
||||
vertexCoords = new GLGeometryObject2D(new GLGeometryObjectData(
|
||||
GL.GL_TRIANGLE_STRIP, GL.GL_VERTEX_ARRAY));
|
||||
vertexCoords.allocate(2 * verticalDivisions * horizontalDivisions);
|
||||
float dX = (1.0f / (key.horizontalDivisions));
|
||||
|
||||
// set up our angle data for the radials
|
||||
float[] angles = record.getAngleData();
|
||||
|
@ -166,9 +274,10 @@ public class RadarRadialMesh extends AbstractGLMesh {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected SharedCoordinateKey generateKey(ImageTile tile, MathTransform mt) {
|
||||
protected SharedCoordinateKey generateKey(GridGeometry2D imageGeometry,
|
||||
MathTransform mt) {
|
||||
try {
|
||||
return new SharedCoordinateKey(record.getNumRadials() + 1,
|
||||
return new SharedCoordinateKey(record.getNumRadials(),
|
||||
getNumVerticalDivisions(mt, record));
|
||||
} catch (Exception e) {
|
||||
statusHandler
|
||||
|
@ -202,7 +311,7 @@ public class RadarRadialMesh extends AbstractGLMesh {
|
|||
in[1] = 0;
|
||||
toLatLon.transform(in, 0, out, 0, 1);
|
||||
|
||||
double[] start = descriptor.worldToPixel(out);
|
||||
double[] start = worldToPixel(out);
|
||||
|
||||
for (int i = 0; i < angles.length; ++i) {
|
||||
// grab end
|
||||
|
@ -215,7 +324,7 @@ public class RadarRadialMesh extends AbstractGLMesh {
|
|||
in[0] = range * sinAz;
|
||||
in[1] = range * cosAz;
|
||||
toLatLon.transform(in, 0, out, 0, 1);
|
||||
out = descriptor.worldToPixel(out);
|
||||
out = worldToPixel(out);
|
||||
|
||||
int[] curPow2 = new int[] { (int) Math.floor(Math.log(numBins)
|
||||
/ Math.log(2)) };
|
||||
|
@ -256,7 +365,7 @@ public class RadarRadialMesh extends AbstractGLMesh {
|
|||
double[] in = new double[] { rangeToTry * sinAz, rangeToTry * cosAz };
|
||||
double[] actual = new double[3];
|
||||
toLatLon.transform(in, 0, actual, 0, 1);
|
||||
actual = descriptor.worldToPixel(actual);
|
||||
actual = worldToPixel(actual);
|
||||
|
||||
// Get linear interpolated point
|
||||
double[] interp = new double[] { (endLoc[0] + startLoc[0]) / 2,
|
||||
|
@ -276,4 +385,54 @@ public class RadarRadialMesh extends AbstractGLMesh {
|
|||
}
|
||||
}
|
||||
|
||||
private void use() {
|
||||
refCount += 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.core.gl.AbstractGLMesh#dispose()
|
||||
*/
|
||||
@Override
|
||||
public synchronized void dispose() {
|
||||
refCount -= 1;
|
||||
synchronized (cache) {
|
||||
if (refCount == 0) {
|
||||
super.dispose();
|
||||
cache.remove(cacheKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static RadarRadialMesh getMesh(RadarRecord radarData,
|
||||
IDescriptor descriptor) throws VizException {
|
||||
float latitude = radarData.getLatitude();
|
||||
float longitude = radarData.getLongitude();
|
||||
int numBins = radarData.getNumBins();
|
||||
int numRadials = radarData.getNumRadials();
|
||||
int gateResolution = radarData.getGateResolution();
|
||||
float trueElevationAngle = radarData.getTrueElevationAngle();
|
||||
Integer jStart = radarData.getJstart();
|
||||
if (jStart == null) {
|
||||
jStart = 0;
|
||||
}
|
||||
float[] angleData = radarData.getAngleData();
|
||||
CacheKey key = new CacheKey(latitude, longitude, numBins, numRadials,
|
||||
gateResolution, trueElevationAngle, jStart, angleData,
|
||||
descriptor.getGridGeometry());
|
||||
synchronized (cache) {
|
||||
RadarRadialMesh mesh = cache.get(key);
|
||||
if (mesh == null) {
|
||||
// System.out.println("Mesh Cache miss");
|
||||
mesh = new RadarRadialMesh(radarData,
|
||||
descriptor.getGridGeometry(), key);
|
||||
cache.put(key, mesh);
|
||||
} else {
|
||||
// System.out.println("Mesh Cache hit");
|
||||
}
|
||||
mesh.use();
|
||||
return mesh;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,252 +0,0 @@
|
|||
/**
|
||||
* 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.radar.gl;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.geotools.coverage.grid.GeneralGridGeometry;
|
||||
import org.geotools.coverage.grid.GridGeometry2D;
|
||||
import org.opengis.referencing.operation.MathTransform;
|
||||
|
||||
import com.raytheon.uf.common.dataplugin.radar.RadarRecord;
|
||||
import com.raytheon.uf.viz.core.IExtent;
|
||||
import com.raytheon.uf.viz.core.IGraphicsTarget;
|
||||
import com.raytheon.uf.viz.core.IMesh;
|
||||
import com.raytheon.uf.viz.core.PixelCoverage;
|
||||
import com.raytheon.uf.viz.core.drawables.IDescriptor;
|
||||
import com.raytheon.uf.viz.core.drawables.PaintProperties;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
import com.raytheon.uf.viz.core.map.IMapDescriptor;
|
||||
import com.raytheon.uf.viz.core.rsc.hdf5.ImageTile;
|
||||
|
||||
/**
|
||||
*
|
||||
* TODO Add Description
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jul 28, 2011 bsteffen Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bsteffen
|
||||
* @version 1.0
|
||||
*/
|
||||
public class RadarRadialMeshCache {
|
||||
|
||||
private static class CacheKey {
|
||||
|
||||
private final float latitude;
|
||||
|
||||
private final float longitude;
|
||||
|
||||
private final int hashCode;
|
||||
|
||||
private final int numBins;
|
||||
|
||||
private final int numRadials;
|
||||
|
||||
private final int gateResolution;
|
||||
|
||||
private final float trueElevationAngle;
|
||||
|
||||
private final int jStart;
|
||||
|
||||
private final float[] angleData;
|
||||
|
||||
private final GeneralGridGeometry gridGeometry;
|
||||
|
||||
public CacheKey(float latitude, float longitude, int numBins,
|
||||
int numRadials, int gateResolution, float trueElevationAngle,
|
||||
int jStart, float[] angleData, GeneralGridGeometry gridGeometry) {
|
||||
this.latitude = latitude;
|
||||
this.longitude = longitude;
|
||||
this.numBins = numBins;
|
||||
this.numRadials = numRadials;
|
||||
this.gateResolution = gateResolution;
|
||||
this.trueElevationAngle = trueElevationAngle;
|
||||
this.jStart = jStart;
|
||||
this.angleData = angleData;
|
||||
this.gridGeometry = gridGeometry;
|
||||
final int prime = 31;
|
||||
int hashCode = 1;
|
||||
hashCode = prime * hashCode + Arrays.hashCode(angleData);
|
||||
hashCode = prime * hashCode + gateResolution;
|
||||
hashCode = prime * hashCode + jStart;
|
||||
hashCode = prime * hashCode + Float.floatToIntBits(latitude);
|
||||
hashCode = prime * hashCode + Float.floatToIntBits(longitude);
|
||||
hashCode = prime * hashCode + numBins;
|
||||
hashCode = prime * hashCode + numRadials;
|
||||
hashCode = prime * hashCode
|
||||
+ Float.floatToIntBits(trueElevationAngle);
|
||||
hashCode = prime * hashCode + gridGeometry.hashCode();
|
||||
this.hashCode = hashCode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return hashCode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
CacheKey other = (CacheKey) obj;
|
||||
if (hashCode != other.hashCode)
|
||||
return false;
|
||||
if (gateResolution != other.gateResolution)
|
||||
return false;
|
||||
if (jStart != other.jStart)
|
||||
return false;
|
||||
if (latitude != other.latitude)
|
||||
return false;
|
||||
if (longitude != other.longitude)
|
||||
return false;
|
||||
if (numBins != other.numBins)
|
||||
return false;
|
||||
if (numRadials != other.numRadials)
|
||||
return false;
|
||||
if (Float.floatToIntBits(trueElevationAngle) != Float
|
||||
.floatToIntBits(other.trueElevationAngle))
|
||||
return false;
|
||||
if (!Arrays.equals(angleData, other.angleData))
|
||||
return false;
|
||||
if (gridGeometry != null && other.gridGeometry == null) {
|
||||
return false;
|
||||
}
|
||||
if (gridGeometry == null && other.gridGeometry != null) {
|
||||
return false;
|
||||
}
|
||||
if (gridGeometry != null
|
||||
&& !gridGeometry.equals(other.gridGeometry)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static class RadarSharedMesh implements IMesh {
|
||||
|
||||
private final CacheKey key;
|
||||
|
||||
private final IMesh mesh;
|
||||
|
||||
private int refCount = 0;
|
||||
|
||||
private boolean calculated = false;
|
||||
|
||||
private RadarSharedMesh(IMesh mesh, CacheKey key) {
|
||||
this.mesh = mesh;
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paint(IGraphicsTarget target, PaintProperties paintProps)
|
||||
throws VizException {
|
||||
mesh.paint(target, paintProps);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void calculateMesh(PixelCoverage pc,
|
||||
ImageTile tile, MathTransform toLatLon) {
|
||||
if (!calculated) {
|
||||
mesh.calculateMesh(pc, tile, toLatLon);
|
||||
calculated = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void calculateMesh(PixelCoverage pc,
|
||||
GridGeometry2D gg) {
|
||||
if (!calculated) {
|
||||
mesh.calculateMesh(pc, gg);
|
||||
calculated = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
refCount -= 1;
|
||||
synchronized (cache) {
|
||||
if (refCount == 0) {
|
||||
mesh.dispose();
|
||||
cache.remove(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void use() {
|
||||
refCount += 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean intersects(IExtent extent) {
|
||||
return mesh.intersects(extent);
|
||||
}
|
||||
}
|
||||
|
||||
private static Map<CacheKey, RadarSharedMesh> cache = new HashMap<CacheKey, RadarSharedMesh>();
|
||||
|
||||
public static RadarSharedMesh getMesh(RadarRecord radarData,
|
||||
IDescriptor descriptor) throws VizException {
|
||||
float latitude = radarData.getLatitude();
|
||||
float longitude = radarData.getLongitude();
|
||||
int numBins = radarData.getNumBins();
|
||||
int numRadials = radarData.getNumRadials();
|
||||
int gateResolution = radarData.getGateResolution();
|
||||
float trueElevationAngle = radarData.getTrueElevationAngle();
|
||||
Integer jStart = radarData.getJstart();
|
||||
if (jStart == null) {
|
||||
jStart = 0;
|
||||
}
|
||||
float[] angleData = radarData.getAngleData();
|
||||
CacheKey key = new CacheKey(latitude, longitude, numBins, numRadials,
|
||||
gateResolution, trueElevationAngle, jStart, angleData,
|
||||
descriptor.getGridGeometry());
|
||||
synchronized (cache) {
|
||||
RadarSharedMesh mesh = cache.get(key);
|
||||
if (mesh == null) {
|
||||
// System.out.println("Mesh Cache miss");
|
||||
IMesh baseMesh = new RadarRadialMesh(
|
||||
(IMapDescriptor) descriptor, radarData);
|
||||
mesh = new RadarSharedMesh(baseMesh, key);
|
||||
cache.put(key, mesh);
|
||||
} else {
|
||||
// System.out.println("Mesh Cache hit");
|
||||
}
|
||||
mesh.use();
|
||||
return mesh;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,107 @@
|
|||
/**
|
||||
* 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.radar.gl.mosaic;
|
||||
|
||||
import com.raytheon.uf.viz.core.DrawableImage;
|
||||
import com.raytheon.viz.core.gl.images.AbstractGLImage;
|
||||
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
|
||||
* other DrawableImages to mosaic
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Dec 16, 2011 mschenke Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author mschenke
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class GLMosaicImage extends GLDelegateImage<AbstractGLImage> implements
|
||||
IMosaicImage {
|
||||
|
||||
private DrawableImage[] images;
|
||||
|
||||
private boolean repaint;
|
||||
|
||||
private int[] bounds;
|
||||
|
||||
/**
|
||||
* @param target
|
||||
* @param image
|
||||
* @param extensionClass
|
||||
*/
|
||||
public GLMosaicImage(AbstractGLImage image, int[] bounds) {
|
||||
super(image, GLRadarMosaicImageExtension.class);
|
||||
this.bounds = bounds;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.core.gl.images.GLDelegateImage#getWidth()
|
||||
*/
|
||||
@Override
|
||||
public int getWidth() {
|
||||
return bounds[0];
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.core.gl.images.GLDelegateImage#getHeight()
|
||||
*/
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return bounds[1];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the repaint
|
||||
*/
|
||||
public boolean isRepaint() {
|
||||
return repaint;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param repaint
|
||||
* @return
|
||||
*/
|
||||
public void setRepaint(boolean repaint) {
|
||||
this.repaint = repaint;
|
||||
}
|
||||
|
||||
public DrawableImage[] getImagesToMosaic() {
|
||||
return images;
|
||||
}
|
||||
|
||||
public void setImagesToMosaic(DrawableImage... images) {
|
||||
this.images = images;
|
||||
repaint = true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,164 @@
|
|||
/**
|
||||
* 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.radar.gl.mosaic;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import javax.media.opengl.GL;
|
||||
|
||||
import com.raytheon.uf.viz.core.DrawableImage;
|
||||
import com.raytheon.uf.viz.core.PixelCoverage;
|
||||
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.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
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Dec 16, 2011 mschenke Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author mschenke
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class GLRadarMosaicImageExtension extends AbstractGLSLImagingExtension
|
||||
implements IRadarMosaicImageExtension {
|
||||
|
||||
private AbstractGLImage writeToImage;
|
||||
|
||||
public GLMosaicImage initializeRaster(int[] imageBounds,
|
||||
ColorMapParameters params) throws VizException {
|
||||
return new GLMosaicImage(target.getExtension(
|
||||
GLOffscreenRenderingExtension.class).constructOffscreenImage(
|
||||
ByteBuffer.class, imageBounds, params), imageBounds);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.viz.core.gl.ext.AbstractGLImagingExtension#getShaderProgramName
|
||||
* ()
|
||||
*/
|
||||
@Override
|
||||
public String getShaderProgramName() {
|
||||
return "mosaicMaxVal";
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.viz.core.gl.ext.AbstractGLImagingExtension#preImageRender
|
||||
* (com.raytheon.uf.viz.core.drawables.PaintProperties,
|
||||
* com.raytheon.viz.core.gl.images.AbstractGLImage)
|
||||
*/
|
||||
@Override
|
||||
public synchronized Object preImageRender(PaintProperties paintProps,
|
||||
AbstractGLImage image, PixelCoverage coverage) throws VizException {
|
||||
if (image instanceof GLMosaicImage) {
|
||||
GLMosaicImage mosaicImage = (GLMosaicImage) image;
|
||||
if (mosaicImage.isRepaint()) {
|
||||
writeToImage = mosaicImage.getWrappedImage();
|
||||
IOffscreenRenderingExtension extension = target
|
||||
.getExtension(IOffscreenRenderingExtension.class);
|
||||
try {
|
||||
extension.renderOffscreen(mosaicImage);
|
||||
DrawableImage[] imagesToMosaic = mosaicImage
|
||||
.getImagesToMosaic();
|
||||
// Make sure images are staged before we mosaic them
|
||||
ImagingSupport.prepareImages(target, imagesToMosaic);
|
||||
// Need to set repaint based on if drawing completed
|
||||
mosaicImage.setRepaint(drawRasters(paintProps,
|
||||
imagesToMosaic) == false);
|
||||
} finally {
|
||||
extension.renderOnscreen();
|
||||
}
|
||||
writeToImage = null;
|
||||
}
|
||||
|
||||
target.drawRasters(paintProps,
|
||||
new DrawableImage(mosaicImage.getWrappedImage(), coverage));
|
||||
// Don't actually render this image now since we just did it
|
||||
return null;
|
||||
} else {
|
||||
GL gl = target.getGl();
|
||||
// activate on texture2 as 0 is radar image and 1 is colormap
|
||||
gl.glActiveTexture(GL.GL_TEXTURE2);
|
||||
gl.glBindTexture(writeToImage.getTextureStorageType(),
|
||||
writeToImage.getTextureid());
|
||||
return image;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.viz.core.gl.ext.AbstractGLImagingExtension#postImageRender
|
||||
* (com.raytheon.uf.viz.core.drawables.PaintProperties,
|
||||
* com.raytheon.viz.core.gl.images.AbstractGLImage, java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public void postImageRender(PaintProperties paintProps,
|
||||
AbstractGLImage image, Object data) throws VizException {
|
||||
GL gl = target.getGl();
|
||||
// activate on texture2 as 0 is radar image and 1 is colormap
|
||||
gl.glActiveTexture(GL.GL_TEXTURE2);
|
||||
gl.glBindTexture(writeToImage.getTextureStorageType(), 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.viz.core.gl.ext.AbstractGLImagingExtension#loadShaderData
|
||||
* (com.raytheon.viz.core.gl.glsl.GLShaderProgram,
|
||||
* com.raytheon.uf.viz.core.drawables.IImage,
|
||||
* com.raytheon.uf.viz.core.drawables.PaintProperties)
|
||||
*/
|
||||
@Override
|
||||
public void loadShaderData(GLShaderProgram program, IImage image,
|
||||
PaintProperties paintProps) throws VizException {
|
||||
program.setUniform("radarData", 0);
|
||||
program.setUniform("mosaicTexture", 2);
|
||||
|
||||
// pass in width and height
|
||||
program.setUniform("height", (paintProps.getCanvasBounds().height));
|
||||
program.setUniform("width", (paintProps.getCanvasBounds().width));
|
||||
}
|
||||
|
||||
}
|
|
@ -579,14 +579,14 @@ public class VarHeightResource extends
|
|||
XYWindImageData windData = (XYWindImageData) data;
|
||||
double dir = windData.getWindDir();
|
||||
double speed = windData.getWindSpd();
|
||||
double[] screen = hodoDescriptor.worldToPixel(new double[] {
|
||||
double[] screen = hodoDescriptor.polarToPixel(new double[] {
|
||||
speed, dir });
|
||||
line.addPoint(screen[0], screen[1]);
|
||||
}
|
||||
}
|
||||
if (!line.points.isEmpty()) {
|
||||
double[] screen = hodoDescriptor
|
||||
.worldToPixel(new double[] { 0, 0 });
|
||||
.polarToPixel(new double[] { 0, 0 });
|
||||
line.addPoint(screen[0], screen[1]);
|
||||
|
||||
target.drawLine(line);
|
||||
|
|
|
@ -23,18 +23,10 @@ import java.util.List;
|
|||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
|
||||
|
||||
import org.geotools.coverage.grid.GeneralGridEnvelope;
|
||||
import org.geotools.coverage.grid.GeneralGridGeometry;
|
||||
import org.geotools.coverage.grid.GridGeometry2D;
|
||||
import org.geotools.geometry.GeneralEnvelope;
|
||||
import org.geotools.referencing.crs.DefaultEngineeringCRS;
|
||||
import org.opengis.referencing.crs.CoordinateReferenceSystem;
|
||||
|
||||
import com.raytheon.uf.common.serialization.ISerializableObject;
|
||||
import com.raytheon.uf.common.serialization.adapters.GridGeometryAdapter;
|
||||
import com.raytheon.uf.viz.core.PixelExtent;
|
||||
import com.raytheon.uf.viz.core.drawables.AbstractDescriptor;
|
||||
import com.raytheon.uf.viz.core.drawables.ResourcePair;
|
||||
|
@ -68,24 +60,12 @@ public class XyGraphDescriptor extends AbstractDescriptor implements
|
|||
|
||||
protected double zoomLevel = 1.0f;
|
||||
|
||||
@XmlElement
|
||||
@XmlJavaTypeAdapter(value = GridGeometryAdapter.class)
|
||||
protected GeneralGridGeometry geometry;
|
||||
|
||||
public XyGraphDescriptor() {
|
||||
this(new PixelExtent(0, 1000, 0, 1000));
|
||||
}
|
||||
|
||||
public XyGraphDescriptor(PixelExtent anExtent) {
|
||||
super();
|
||||
GeneralEnvelope envelope = new GeneralEnvelope(2);
|
||||
envelope.setRange(0, anExtent.getMinX(), anExtent.getMaxX());
|
||||
envelope.setRange(1, anExtent.getMinY(), anExtent.getMaxY());
|
||||
envelope.setCoordinateReferenceSystem(DefaultEngineeringCRS.CARTESIAN_2D);
|
||||
geometry = new GridGeometry2D(new GeneralGridEnvelope(
|
||||
new int[] { 0, 0 }, new int[] { (int) anExtent.getWidth(),
|
||||
(int) anExtent.getHeight() }, false), envelope);
|
||||
getResourceList().addPreRemoveListener(this);
|
||||
super(createGridGeometry(anExtent, DefaultEngineeringCRS.CARTESIAN_2D));
|
||||
}
|
||||
|
||||
public IGraph getGraph(IGraphableResource<?, ?> rsc) {
|
||||
|
@ -96,42 +76,6 @@ public class XyGraphDescriptor extends AbstractDescriptor implements
|
|||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.uf.viz.core.drawables.IDescriptor#getCRS()
|
||||
*/
|
||||
@Override
|
||||
public CoordinateReferenceSystem getCRS() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GeneralGridGeometry getGridGeometry() {
|
||||
return geometry;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.core.drawables.IDescriptor#pixelToWorld(double[])
|
||||
*/
|
||||
@Override
|
||||
public double[] pixelToWorld(double[] pixel) {
|
||||
return pixel;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.core.drawables.IDescriptor#worldToPixel(double[])
|
||||
*/
|
||||
@Override
|
||||
public double[] worldToPixel(double[] worldPixel) {
|
||||
return worldPixel;
|
||||
}
|
||||
|
||||
public GraphResource getGraphResource() {
|
||||
List<GraphResource> rscs = resourceList
|
||||
.getResourcesByTypeAsType(GraphResource.class);
|
||||
|
|
|
@ -112,9 +112,9 @@ public class HodographBackgroundResource extends
|
|||
label.horizontalAlignment = HorizontalAlignment.CENTER;
|
||||
label.textStyle = TextStyle.BLANKED;
|
||||
double[] center = descriptor
|
||||
.worldToPixel(new double[] { 20, direction });
|
||||
.polarToPixel(new double[] { 20, direction });
|
||||
double[] point = descriptor
|
||||
.worldToPixel(new double[] { 400, direction });
|
||||
.polarToPixel(new double[] { 400, direction });
|
||||
LineSegment line = new LineSegment(center[0], center[1], point[0],
|
||||
point[1]);
|
||||
LineSegment bottom = new LineSegment(extent.getMinX(),
|
||||
|
@ -161,14 +161,14 @@ public class HodographBackgroundResource extends
|
|||
DrawableLine circle = new DrawableLine();
|
||||
circle.basics.color = GREY;
|
||||
for (int dir = 0; dir <= 36; dir += 1) {
|
||||
double[] screen = descriptor.worldToPixel(new double[] {
|
||||
double[] screen = descriptor.polarToPixel(new double[] {
|
||||
mag, dir * 10 });
|
||||
circle.addPoint(screen[0], screen[1]);
|
||||
}
|
||||
lineList.add(circle);
|
||||
DrawableString label = new DrawableString(String.valueOf(mag),
|
||||
GREY);
|
||||
double[] screen = descriptor.worldToPixel(new double[] { mag,
|
||||
double[] screen = descriptor.polarToPixel(new double[] { mag,
|
||||
225 });
|
||||
label.setCoordinates(screen[0], screen[1]);
|
||||
label.textStyle = TextStyle.BLANKED;
|
||||
|
@ -176,9 +176,9 @@ public class HodographBackgroundResource extends
|
|||
}
|
||||
// Add the lines
|
||||
for (int dir = 0; dir <= 8; dir += 1) {
|
||||
double[] screen1 = descriptor.worldToPixel(new double[] { 0,
|
||||
double[] screen1 = descriptor.polarToPixel(new double[] { 0,
|
||||
dir * 45 });
|
||||
double[] screen2 = descriptor.worldToPixel(new double[] { 500,
|
||||
double[] screen2 = descriptor.polarToPixel(new double[] { 500,
|
||||
dir * 45 });
|
||||
DrawableLine line = new DrawableLine();
|
||||
line.basics.color = GREY;
|
||||
|
|
|
@ -19,17 +19,9 @@
|
|||
**/
|
||||
package com.raytheon.uf.viz.xy.hodo;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
|
||||
|
||||
import org.geotools.coverage.grid.GeneralGridEnvelope;
|
||||
import org.geotools.coverage.grid.GeneralGridGeometry;
|
||||
import org.geotools.coverage.grid.GridGeometry2D;
|
||||
import org.geotools.geometry.GeneralEnvelope;
|
||||
import org.geotools.referencing.crs.DefaultEngineeringCRS;
|
||||
import org.opengis.referencing.crs.CoordinateReferenceSystem;
|
||||
|
||||
import com.raytheon.uf.common.serialization.adapters.GridGeometryAdapter;
|
||||
import com.raytheon.uf.viz.core.IExtent;
|
||||
import com.raytheon.uf.viz.core.drawables.AbstractDescriptor;
|
||||
|
||||
|
@ -55,33 +47,14 @@ public class HodographDescriptor extends AbstractDescriptor {
|
|||
// The max distance of the hodograph
|
||||
private static final double MAX_RANGE = 140.0;
|
||||
|
||||
@XmlElement
|
||||
@XmlJavaTypeAdapter(value = GridGeometryAdapter.class)
|
||||
protected GeneralGridGeometry geometry;
|
||||
|
||||
public HodographDescriptor(IExtent anExtent) {
|
||||
super();
|
||||
GeneralEnvelope envelope = new GeneralEnvelope(2);
|
||||
envelope.setRange(0, anExtent.getMinX(), anExtent.getMaxX());
|
||||
envelope.setRange(1, anExtent.getMinY(), anExtent.getMaxY());
|
||||
envelope.setCoordinateReferenceSystem(DefaultEngineeringCRS.CARTESIAN_2D);
|
||||
geometry = new GridGeometry2D(new GeneralGridEnvelope(
|
||||
new int[] { 0, 0 }, new int[] { (int) anExtent.getWidth(),
|
||||
(int) anExtent.getHeight() }, false), envelope);
|
||||
super(createGridGeometry(anExtent, DefaultEngineeringCRS.CARTESIAN_2D));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CoordinateReferenceSystem getCRS() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GeneralGridGeometry getGridGeometry() {
|
||||
return geometry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double[] pixelToWorld(double[] pixel) {
|
||||
// Separate functions for polar transformations until we can get it working
|
||||
// in geotools framework
|
||||
public double[] pixelToPolar(double[] pixel) {
|
||||
GeneralGridGeometry geometry = getGridGeometry();
|
||||
double x = pixel[0];
|
||||
double y = pixel[1];
|
||||
int xRange = geometry.getGridRange().getSpan(0);
|
||||
|
@ -95,8 +68,8 @@ public class HodographDescriptor extends AbstractDescriptor {
|
|||
return new double[] { r, a, 0 };
|
||||
}
|
||||
|
||||
@Override
|
||||
public double[] worldToPixel(double[] world) {
|
||||
public double[] polarToPixel(double[] world) {
|
||||
GeneralGridGeometry geometry = getGridGeometry();
|
||||
double r = world[0];
|
||||
double a = world[1];
|
||||
int xRange = geometry.getGridRange().getSpan(0);
|
||||
|
|
|
@ -46,6 +46,7 @@ import com.raytheon.uf.common.datastorage.records.FloatDataRecord;
|
|||
import com.raytheon.uf.common.datastorage.records.IDataRecord;
|
||||
import com.raytheon.uf.common.geospatial.CRSCache;
|
||||
import com.raytheon.uf.common.geospatial.MapUtil;
|
||||
import com.raytheon.uf.common.geospatial.util.WorldWrapChecker;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
|
@ -60,7 +61,6 @@ import com.raytheon.uf.viz.core.drawables.IFont;
|
|||
import com.raytheon.uf.viz.core.drawables.IWireframeShape;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
import com.raytheon.uf.viz.core.map.IMapDescriptor;
|
||||
import com.raytheon.uf.viz.core.map.WorldWrapChecker;
|
||||
import com.raytheon.uf.viz.core.style.LabelingPreferences;
|
||||
import com.raytheon.viz.core.contours.cache.SubGridCacheKey;
|
||||
import com.raytheon.viz.core.contours.util.ContourContainer;
|
||||
|
@ -1337,7 +1337,8 @@ public class ContourSupport {
|
|||
throws TransformException {
|
||||
long tZ0 = System.currentTimeMillis();
|
||||
|
||||
WorldWrapChecker wwc = new WorldWrapChecker(descriptor);
|
||||
WorldWrapChecker wwc = new WorldWrapChecker(
|
||||
descriptor.getGridGeometry());
|
||||
|
||||
List<float[]> splitLines = new ArrayList<float[]>();
|
||||
List<Float> dupValues = new ArrayList<Float>();
|
||||
|
|
|
@ -21,6 +21,7 @@ Require-Bundle: org.eclipse.ui,
|
|||
Bundle-ActivationPolicy: lazy
|
||||
Export-Package: com.raytheon.viz.core.gl,
|
||||
com.raytheon.viz.core.gl.dataformat,
|
||||
com.raytheon.viz.core.gl.ext,
|
||||
com.raytheon.viz.core.gl.glsl,
|
||||
com.raytheon.viz.core.gl.images
|
||||
Import-Package: com.raytheon.uf.common.status,
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
// Simple shader program for applying alpha,brightness, and contrast to the
|
||||
// colormap in the same way they are applied to data
|
||||
|
||||
#include <colorUtil>
|
||||
#include <indexing>
|
||||
|
||||
uniform float brightness;
|
||||
uniform float contrast;
|
||||
uniform float alphaVal;
|
||||
|
@ -15,25 +18,15 @@ uniform sampler2D alphaMask;
|
|||
uniform int applyMask;
|
||||
uniform float logFactor;
|
||||
|
||||
vec3 AvgLuminance = vec3(0.5, 0.5, 0.5);
|
||||
|
||||
// Given an index(0-1) find the color in the colormap
|
||||
vec4 findColor(float index){
|
||||
if (logFactor > 0.0){
|
||||
float minLog = log(logFactor);
|
||||
float maxLog = log(logFactor + 1.0);
|
||||
|
||||
float lg = log(logFactor + index);
|
||||
|
||||
index = (lg - minLog) / (maxLog - minLog);
|
||||
if (index < 0.0){
|
||||
index = 0.0;
|
||||
}
|
||||
else if (index > 1.0){
|
||||
index = 1.0;
|
||||
}
|
||||
void main(void){
|
||||
// Lookup color in colorMap for index
|
||||
float index = gl_TexCoord[0].s;
|
||||
if ( logFactor > 0.0 ) {
|
||||
index = getLogFactorIndex(index, logFactor);
|
||||
}
|
||||
vec4 color = texture1D(colorMap, index).rgba;
|
||||
vec4 color = texture1D(colorMap, index).rgba;
|
||||
|
||||
// Apply alpha mask if set
|
||||
float alpha = color.a;
|
||||
if ( applyMask == 1 ) {
|
||||
if ( texture2D(alphaMask , vec2(index,index) ).r != 0.0 ) {
|
||||
|
@ -48,18 +41,6 @@ vec4 findColor(float index){
|
|||
color.b*color.a + bkgrndBlue*(1.0 - color.a),
|
||||
alpha);
|
||||
}
|
||||
return vec4(color.rgb, alpha);
|
||||
}
|
||||
|
||||
// Apply the preferences for contrast, alpha, and brightness
|
||||
vec4 applyContrastAlphaBrightness(vec4 color){
|
||||
vec3 textureColor3 = vec3(color);
|
||||
vec3 adjustedColor = mix(AvgLuminance, textureColor3, contrast);
|
||||
float curAlpha = min(color.a, alphaVal);
|
||||
return vec4(adjustedColor.r * brightness, adjustedColor.g * brightness, adjustedColor.b * brightness, curAlpha);
|
||||
}
|
||||
|
||||
void main(void){
|
||||
vec4 textureColor = findColor(gl_TexCoord[0].s);
|
||||
gl_FragColor = applyContrastAlphaBrightness(textureColor);
|
||||
gl_FragColor = applyContrastAlphaBrightness(color, alphaVal, brightness, contrast);
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
#include <colorUtil>
|
||||
#include <indexing>
|
||||
|
||||
uniform float alpha;
|
||||
uniform float brightness;
|
||||
uniform float contrast;
|
||||
uniform int applyMask;
|
||||
uniform float naturalMin;
|
||||
uniform float naturalMax;
|
||||
uniform float cmapMin;
|
||||
uniform float cmapMax;
|
||||
uniform sampler1D colorMap;
|
||||
uniform sampler2D alphaMask;
|
||||
uniform sampler2D rawTex;
|
||||
uniform float colorMapSz;
|
||||
uniform int isFloat;
|
||||
uniform int logarithmic;
|
||||
uniform int mirror;
|
||||
uniform float logFactor;
|
||||
|
||||
void main(void) {
|
||||
vec4 textureColor = texture2D(rawTex, gl_TexCoord[0].st);
|
||||
float index = 0.0;
|
||||
float rawValue = textureColor.r;
|
||||
if ( isFloat == 1 ) {
|
||||
if ( logarithmic == 1 ) {
|
||||
index = findFloatIndexLog(rawValue, cmapMin, cmapMax, mirror);
|
||||
} else {
|
||||
index = findFloatIndex(rawValue, cmapMin, cmapMax);
|
||||
}
|
||||
|
||||
// Special float handling, -1.0 is NaN
|
||||
if (index == -1.0){
|
||||
gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
float naturalValue = ((rawValue * (naturalMax - naturalMin)) + naturalMin);
|
||||
index = findIndex(naturalValue, cmapMin, cmapMax);
|
||||
}
|
||||
|
||||
// Lookup color in colorMap for index
|
||||
if ( logFactor > 0.0 ) {
|
||||
index = getLogFactorIndex(index, logFactor);
|
||||
}
|
||||
textureColor = texture1D(colorMap, index).rgba;
|
||||
|
||||
// Apply alpha mask
|
||||
if ( applyMask == 1 ) {
|
||||
if ( texture2D(alphaMask , vec2(index,index) ).r != 0.0 ) {
|
||||
textureColor = vec4(textureColor.rgb, 0.0);
|
||||
}
|
||||
}
|
||||
|
||||
gl_FragColor = applyContrastAlphaBrightness(textureColor, alpha, brightness, contrast);
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
|
||||
vec3 AvgLuminance = vec3(0.5, 0.5, 0.5);
|
||||
|
||||
/**
|
||||
* This function applies the specified alpha, brightness, and contrast values
|
||||
* to the color passed in
|
||||
*/
|
||||
vec4 applyContrastAlphaBrightness(vec4 color, float alpha, float brightness, float contrast){
|
||||
vec3 textureColor3 = vec3(color);
|
||||
vec3 adjustedColor = mix(AvgLuminance, textureColor3, contrast);
|
||||
float curAlpha = min(color.a, alpha);
|
||||
return vec4(adjustedColor.r * brightness, adjustedColor.g * brightness, adjustedColor.b * brightness, curAlpha);
|
||||
}
|
||||
|
||||
/**
|
||||
* This function calculates a new index to use based on the logFactor
|
||||
*/
|
||||
float getLogFactorIndex(float index, float logFactor) {
|
||||
if (logFactor > 0.0){
|
||||
float minLog = log(logFactor);
|
||||
float maxLog = log(logFactor + 1.0);
|
||||
|
||||
float lg = log(logFactor + index);
|
||||
|
||||
index = (lg - minLog) / (maxLog - minLog);
|
||||
if (index < 0.0){
|
||||
index = 0.0;
|
||||
}
|
||||
else if (index > 1.0){
|
||||
index = 1.0;
|
||||
}
|
||||
}
|
||||
return index;
|
||||
}
|
|
@ -0,0 +1,104 @@
|
|||
|
||||
float HALF_FLOAT_NaN = 65504.0;
|
||||
|
||||
/**
|
||||
* This function takes an index number and caps it to the range 0-1
|
||||
*/
|
||||
float capIndex(float index) {
|
||||
if ( index < 0.0 ) {
|
||||
index = 0.0;
|
||||
} else if ( index > 1.0 ) {
|
||||
index = 1.0;
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function linearly finds the index for the rawValue into cmapMin/cmapMax.
|
||||
* 65504.0 is treated as NaN for half floats and -1 is returned as special case
|
||||
*/
|
||||
float findFloatIndex(float rawValue, float cmapMin, float cmapMax) {
|
||||
if ( rawValue == HALF_FLOAT_NaN ) {
|
||||
return -1.0;
|
||||
}
|
||||
float index = ((rawValue - cmapMin) / abs(cmapMax-cmapMin));
|
||||
return capIndex(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* This function logarithmically finds the index for the rawValue into cmapMin/cmapMax.
|
||||
* 65504.0 is treated as NaN for half floats and -1 is returned as special case
|
||||
*/
|
||||
float findFloatIndexLog(float rawValue, float cmapMin, float cmapMax, int mirror) {
|
||||
if ( rawValue == HALF_FLOAT_NaN ) {
|
||||
return -1.0;
|
||||
}
|
||||
|
||||
float index = 0.0;
|
||||
// is this strictly negative, strictly positive or neg to pos scaling?
|
||||
if ( cmapMin >= 0.0 && cmapMax >= 0.0 && mirror!=1) {
|
||||
if(rawValue < cmapMin){
|
||||
index = 0.0;
|
||||
}else{
|
||||
// simple calculation
|
||||
index = ((log(rawValue) - log(cmapMin)) / abs(log(cmapMax)-log(cmapMin)));
|
||||
}
|
||||
} else if (cmapMin <= 0.0 && cmapMax <= 0.0 && mirror!=1) {
|
||||
index = ((log(rawValue) - log(cmapMax)) / abs(log(cmapMin)-log(cmapMax)));
|
||||
} else {
|
||||
// special case, neg to pos:
|
||||
float colorMapMin = cmapMin;
|
||||
float colorMapMax = cmapMax;
|
||||
float zeroVal = max(colorMapMax, abs(colorMapMin)) * 0.0001;
|
||||
if (mirror==1 && (colorMapMin > 0.0 || colorMapMax < 0.0)) {
|
||||
if (colorMapMax < 0.0) {
|
||||
colorMapMax = -cmapMax;
|
||||
rawValue = -rawValue;
|
||||
zeroVal = -colorMapMin;
|
||||
} else {
|
||||
zeroVal = cmapMin;
|
||||
}
|
||||
colorMapMin = -cmapMax;
|
||||
}
|
||||
float leftZero = 0.0;
|
||||
float rightZero = 0.0;
|
||||
float absLogZeroVal = abs(log(zeroVal));
|
||||
|
||||
rightZero = absLogZeroVal + log(colorMapMax);
|
||||
|
||||
float cmapMax2 = abs(colorMapMin);
|
||||
|
||||
leftZero = absLogZeroVal + log(cmapMax2);
|
||||
|
||||
float zeroIndex = leftZero / (leftZero + rightZero);
|
||||
|
||||
// figure out index for texture val
|
||||
float absTextureColor = abs(rawValue);
|
||||
if (absTextureColor <= zeroVal) {
|
||||
index = zeroIndex;
|
||||
} else if (rawValue > 0.0) {
|
||||
// positive texture color value, find index from 0 to
|
||||
// cmapMax:
|
||||
float logTexColor = absLogZeroVal + log(rawValue);
|
||||
|
||||
float texIndex = logTexColor / rightZero;
|
||||
index = (zeroIndex + ((1.0 - zeroIndex) * texIndex));
|
||||
} else {
|
||||
// negative texture color value, find index from 0 to
|
||||
// cmapMax:
|
||||
float logTexColor = absLogZeroVal + log(absTextureColor);
|
||||
|
||||
float texIndex = logTexColor / leftZero;
|
||||
index = (zeroIndex - (zeroIndex * texIndex));
|
||||
}
|
||||
}
|
||||
return capIndex(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a raw data value linearly determine the index(0-1) into cmapMin/cmapMax
|
||||
*/
|
||||
float findIndex(float rawValue, float cmapMin, float cmapMax) {
|
||||
float index = ((rawValue - cmapMin) / abs(cmapMax-cmapMin));
|
||||
return capIndex(index);
|
||||
}
|
|
@ -1,172 +1,11 @@
|
|||
// NOTE: 65504.0 is the maximum half precision float value
|
||||
// it is used to do masking of GFE grids since NaNs are not supported
|
||||
// in NVIDIA cards prior to the 8000 series
|
||||
// The check for textureColor.r == 65504.0 can be replaced by
|
||||
// isnan(textureColor.r) if support for cards prior to the 8000 series
|
||||
// is not required.
|
||||
|
||||
// NOTE: there is a corresponding conversion from NaN to 65504.0 in
|
||||
// FloatDataPreparer that will also need to be changed
|
||||
#include <colorUtil>
|
||||
|
||||
uniform float brightness;
|
||||
uniform float contrast;
|
||||
uniform int doColorMap;
|
||||
uniform int applyMask;
|
||||
uniform float naturalMin;
|
||||
uniform float naturalMax;
|
||||
uniform float cmapMin;
|
||||
uniform float cmapMax;
|
||||
uniform sampler1D colorMap;
|
||||
uniform float alpha;
|
||||
uniform sampler2D rawTex;
|
||||
uniform sampler2D alphaMask;
|
||||
uniform float alphaVal;
|
||||
uniform float colorMapSz;
|
||||
uniform int isFloat;
|
||||
uniform int logarithmic;
|
||||
uniform int mirror;
|
||||
uniform float logFactor;
|
||||
uniform int doSingleColor;
|
||||
uniform vec3 singleColor;
|
||||
|
||||
vec3 AvgLuminance = vec3(0.5, 0.5, 0.5);
|
||||
|
||||
// Given a raw data value determine the index(0-1) into the colormap using log scaling
|
||||
float findIndexLog(float rawValue){
|
||||
float index = 0.0;
|
||||
// is this strictly negative, strictly positive or neg to pos scaling?
|
||||
if ( cmapMin >= 0.0 && cmapMax >= 0.0 && mirror!=1) {
|
||||
if(rawValue < cmapMin){
|
||||
index = 0.0;
|
||||
}else{
|
||||
// simple calculation
|
||||
index = ((log(rawValue) - log(cmapMin)) / abs(log(cmapMax)-log(cmapMin)));
|
||||
}
|
||||
} else if (cmapMin <= 0.0 && cmapMax <= 0.0 && mirror!=1) {
|
||||
index = ((log(rawValue) - log(cmapMax)) / abs(log(cmapMin)-log(cmapMax)));
|
||||
} else {
|
||||
// special case, neg to pos:
|
||||
float colorMapMin = cmapMin;
|
||||
float colorMapMax = cmapMax;
|
||||
float zeroVal = max(colorMapMax, abs(colorMapMin)) * 0.0001;
|
||||
if (mirror==1 && (colorMapMin > 0.0 || colorMapMax < 0.0)) {
|
||||
if (colorMapMax < 0.0) {
|
||||
colorMapMax = -cmapMax;
|
||||
rawValue = -rawValue;
|
||||
zeroVal = -colorMapMin;
|
||||
} else {
|
||||
zeroVal = cmapMin;
|
||||
}
|
||||
colorMapMin = -cmapMax;
|
||||
}
|
||||
float leftZero = 0.0;
|
||||
float rightZero = 0.0;
|
||||
float absLogZeroVal = abs(log(zeroVal));
|
||||
|
||||
rightZero = absLogZeroVal + log(colorMapMax);
|
||||
|
||||
float cmapMax2 = abs(colorMapMin);
|
||||
|
||||
leftZero = absLogZeroVal + log(cmapMax2);
|
||||
|
||||
float zeroIndex = leftZero / (leftZero + rightZero);
|
||||
|
||||
// figure out index for texture val
|
||||
float absTextureColor = abs(rawValue);
|
||||
if (absTextureColor <= zeroVal) {
|
||||
index = zeroIndex;
|
||||
} else if (rawValue > 0.0) {
|
||||
// positive texture color value, find index from 0 to
|
||||
// cmapMax:
|
||||
float logTexColor = absLogZeroVal + log(rawValue);
|
||||
|
||||
float texIndex = logTexColor / rightZero;
|
||||
index = (zeroIndex + ((1.0 - zeroIndex) * texIndex));
|
||||
} else {
|
||||
// negative texture color value, find index from 0 to
|
||||
// cmapMax:
|
||||
float logTexColor = absLogZeroVal + log(absTextureColor);
|
||||
|
||||
float texIndex = logTexColor / leftZero;
|
||||
index = (zeroIndex - (zeroIndex * texIndex));
|
||||
}
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
// Given a raw data value determine the index(0-1) into the colormap
|
||||
float findIndex(float rawValue)
|
||||
{
|
||||
float index = 0.0;
|
||||
if (isFloat == 1) {
|
||||
if (rawValue == 65504.0) {
|
||||
return -1.0;
|
||||
}
|
||||
if (logarithmic == 1){
|
||||
index = findIndexLog(rawValue);
|
||||
}else{
|
||||
index = ((rawValue - cmapMin) / abs(cmapMax-cmapMin));
|
||||
}
|
||||
} else {
|
||||
float naturalValue = ((rawValue * (naturalMax - naturalMin)) + naturalMin);
|
||||
index = ((naturalValue - cmapMin) / abs(cmapMax-cmapMin));
|
||||
}
|
||||
if(index < 0.0) {
|
||||
index = 0.0;
|
||||
} else if(index > 1.0) {
|
||||
index = 1.0;
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
// Given an index(0-1) find the color in the colormap
|
||||
vec4 findColor(float index){
|
||||
if (logFactor > 0.0){
|
||||
float minLog = log(logFactor);
|
||||
float maxLog = log(logFactor + 1.0);
|
||||
|
||||
float lg = log(logFactor + index);
|
||||
|
||||
index = (lg - minLog) / (maxLog - minLog);
|
||||
if (index < 0.0){
|
||||
index = 0.0;
|
||||
}
|
||||
else if (index > 1.0){
|
||||
index = 1.0;
|
||||
}
|
||||
}
|
||||
vec4 color = texture1D(colorMap, index).rgba;
|
||||
float alpha = color.a;
|
||||
if ( applyMask == 1 ) {
|
||||
if ( texture2D(alphaMask , vec2(index,index) ).r != 0.0 ) {
|
||||
alpha = 0.0;
|
||||
}
|
||||
}
|
||||
return vec4(color.rgb, alpha);
|
||||
}
|
||||
|
||||
// Apply the preferences for contrast, alpha, and brightness
|
||||
vec4 applyContrastAlphaBrightness(vec4 color){
|
||||
vec3 textureColor3 = vec3(color);
|
||||
vec3 adjustedColor = mix(AvgLuminance, textureColor3, contrast);
|
||||
float curAlpha = min(color.a, alphaVal);
|
||||
return vec4(adjustedColor.r * brightness, adjustedColor.g * brightness, adjustedColor.b * brightness, curAlpha);
|
||||
}
|
||||
|
||||
void main(void)
|
||||
{
|
||||
void main(void) {
|
||||
vec4 textureColor = texture2D(rawTex, gl_TexCoord[0].st);
|
||||
float alpha = textureColor.a;
|
||||
if(doColorMap == 1) {
|
||||
float index = findIndex(textureColor.r);
|
||||
if (index == -1.0){
|
||||
gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
return;
|
||||
}
|
||||
textureColor = findColor(index);
|
||||
}
|
||||
|
||||
if ( doSingleColor == 1 ) {
|
||||
textureColor.rgb = singleColor;
|
||||
}
|
||||
gl_FragColor = applyContrastAlphaBrightness(textureColor);
|
||||
gl_FragColor = applyContrastAlphaBrightness(textureColor, alpha, brightness, contrast);
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
#include <colorUtil>
|
||||
|
||||
uniform float brightness;
|
||||
uniform float contrast;
|
||||
uniform float alpha;
|
||||
uniform sampler2D rawTex;
|
||||
uniform vec3 color;
|
||||
|
||||
void main(void) {
|
||||
vec4 textureColor = texture2D(rawTex, gl_TexCoord[0].st);
|
||||
textureColor.rgb = color;
|
||||
gl_FragColor = applyContrastAlphaBrightness(textureColor, alpha, brightness, contrast);
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
uniform float brightness;
|
||||
uniform float contrast;
|
||||
uniform sampler1D colorMap;
|
||||
uniform int textureType;
|
||||
uniform sampler2D cloudTexture2D;
|
||||
uniform sampler3D cloudTexture3D;
|
||||
uniform float glaze;
|
||||
uniform float rime;
|
||||
uniform float alphaVal;
|
||||
uniform int clwSize;
|
||||
uniform float clwRange[8];
|
||||
uniform float naturalValues[2];
|
||||
uniform float cmap[];
|
||||
|
||||
vec3 AvgLuminance = vec3(0.5, 0.5, 0.5);
|
||||
|
||||
float getValue(sampler2D s2D, sampler3D s3D, float max, float min) {
|
||||
|
||||
float value;
|
||||
if(textureType == 3) {
|
||||
value = texture3D(s3D, vec3(gl_TexCoord[0])).r;
|
||||
}else {
|
||||
value = texture2D(s2D, vec2(gl_TexCoord[0])).r;
|
||||
}
|
||||
|
||||
// scale the value
|
||||
value = (value *(max-min)) + min;
|
||||
return value;
|
||||
|
||||
}
|
||||
|
||||
void main(void)
|
||||
{
|
||||
gl_FragColor = vec4(1.0, 1.0, 0.0, 1.0 );
|
||||
|
||||
float temp = getValue(cloudTexture2D, cloudTexture3D, naturalValues[1], naturalValues[0] );
|
||||
|
||||
float index = ((temp - cmap[0]) / (cmap[1]-cmap[0]));
|
||||
if(index < 0.0) {
|
||||
index = 0.0;
|
||||
} else if(index > 1.0) {
|
||||
index = 1.0;
|
||||
}
|
||||
|
||||
vec4 color = texture1D(colorMap, index).rgba;
|
||||
|
||||
float alpha = color.a;
|
||||
vec4 textureColor = vec4(color.rgb, 1.0);
|
||||
|
||||
vec3 adjustedColor = mix(AvgLuminance, color.rgb, contrast);
|
||||
float curAlpha = min(alpha, alphaVal);
|
||||
|
||||
//// if(curAlpha > 0.0) {
|
||||
gl_FragColor = vec4(adjustedColor.r * brightness, adjustedColor.g * brightness, adjustedColor.b * brightness, curAlpha);
|
||||
// } else {
|
||||
// discard;
|
||||
// }
|
||||
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
uniform sampler2D tex;
|
||||
uniform float brightness;
|
||||
uniform float contrast;
|
||||
uniform int doColorMap;
|
||||
uniform float naturalMin;
|
||||
uniform float naturalMax;
|
||||
uniform float cmapMin;
|
||||
uniform float cmapMax;
|
||||
uniform sampler1D colorMap;
|
||||
uniform sampler2D rawTex;
|
||||
uniform float alphaVal;
|
||||
uniform float colorMapSz;
|
||||
vec3 AvgLuminance = vec3(0.5, 0.5, 0.5);
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec4 textureColor = texture2D(rawTex, gl_TexCoord[0].st);
|
||||
float alpha = textureColor.a;
|
||||
if(doColorMap == 1) {
|
||||
// + " float naturalValue = ((textureColor.r * (20000)) - 10000);
|
||||
float naturalValue = ((textureColor.r * (naturalMax - naturalMin)) + naturalMin);
|
||||
float index = ((naturalValue - cmapMin) / abs(cmapMax-cmapMin));
|
||||
if(index < 0.0) {
|
||||
index = 0.0;
|
||||
} else if(index > 1.0) {
|
||||
index = 1.0;
|
||||
}
|
||||
vec4 color = texture1D(colorMap, index).rgba;
|
||||
alpha = color.a;
|
||||
textureColor = vec4(color.rgb, 1.0);
|
||||
}
|
||||
vec3 textureColor3 = vec3(textureColor);
|
||||
vec3 adjustedColor = mix(AvgLuminance, textureColor3, contrast);
|
||||
float curAlpha = min(alpha, alphaVal);
|
||||
gl_FragColor = vec4(adjustedColor.r * brightness, adjustedColor.g * brightness, adjustedColor.b * brightness, curAlpha);
|
||||
|
||||
}
|
|
@ -1,98 +0,0 @@
|
|||
uniform sampler3D tex;
|
||||
uniform float brightness;
|
||||
uniform float contrast;
|
||||
uniform int doColorMap;
|
||||
uniform float naturalMin;
|
||||
uniform float naturalMax;
|
||||
uniform float cmapMin;
|
||||
uniform float cmapMax;
|
||||
uniform sampler1D colorMap;
|
||||
uniform sampler3D rawTex;
|
||||
uniform float alphaVal;
|
||||
uniform float colorMapSz;
|
||||
uniform sampler2D grids[8];
|
||||
uniform int enabledImpacts[8];
|
||||
uniform int numberEnabled;
|
||||
|
||||
//// actuall pressure levels
|
||||
//uniform float pressures[20];
|
||||
//uniform int layers;
|
||||
//
|
||||
//
|
||||
//uniform float texturePres[30];
|
||||
|
||||
vec3 AvgLuminance = vec3(0.5, 0.5, 0.5);
|
||||
|
||||
//float interp1(float y1, float y3, float x1, float x2, float x3) {
|
||||
// if(x3 == x1) {
|
||||
// x1 += 0.01;
|
||||
// }
|
||||
//
|
||||
// return y1+((y3-y1) *((x2-x1)/(x3-x1)));
|
||||
//
|
||||
//}
|
||||
//
|
||||
//// based on metolib pvalue.f
|
||||
//float pvalue() {
|
||||
//
|
||||
// float z = vec3(gl_TexCoord[0].xyz).z;
|
||||
// int j = int(z *float(layers-1));
|
||||
// vec3 lower = gl_TexCoord[0].xyz;
|
||||
// vec3 upper = gl_TexCoord[0].xyz;
|
||||
//
|
||||
//
|
||||
// float lowerVal = texture3D(rawTex, lower).r;
|
||||
// float uperVal = texture3D(rawTex, upper).r;
|
||||
//
|
||||
// for(int i = 0; i < layers; ++i) {
|
||||
//
|
||||
// if(pressures[i] < texturePres[j]) {
|
||||
//
|
||||
// // assuming texture coordinates are 0-1
|
||||
// lower.z += 1/(layers-1);
|
||||
// upper.z -= 1/(layers-1);
|
||||
//
|
||||
// float lowerVal = texture3D(rawTex, lower).r;
|
||||
// float upperVal = texture3D(rawTex, upper).r;
|
||||
//
|
||||
// float p1 = log(pressures[i-1]);
|
||||
// float p2 = log(texturePres[j]);
|
||||
// float p3 = log(pressures[i]);
|
||||
//
|
||||
// return interp1(lowerVal, upperVal, p1, p2, p3 );
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//}
|
||||
|
||||
|
||||
void main(void)
|
||||
{
|
||||
float textureValue = texture3D(rawTex, gl_TexCoord[0].xyz).r;
|
||||
|
||||
float naturalValue = ((textureValue * (naturalMax - naturalMin)) + naturalMin);
|
||||
float index = ((naturalValue - cmapMin) / (cmapMax-cmapMin));
|
||||
if(index < 0.0) {
|
||||
index = 0.0;
|
||||
} else if(index > 1.0) {
|
||||
index = 1.0;
|
||||
}
|
||||
vec4 color = texture1D(colorMap, index).rgba;
|
||||
float alpha = color.a;
|
||||
vec4 textureColor = vec4(color.rgb, 1.0);
|
||||
|
||||
|
||||
vec3 textureColor3 = vec3(textureColor);
|
||||
vec3 adjustedColor = mix(AvgLuminance, textureColor3, contrast);
|
||||
//
|
||||
float curAlpha = min(alpha, alphaVal);
|
||||
|
||||
if(curAlpha > 0.0){
|
||||
gl_FragColor = vec4(adjustedColor.r * brightness, adjustedColor.g * brightness, adjustedColor.b * brightness, curAlpha);
|
||||
}
|
||||
else {
|
||||
discard;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,56 +0,0 @@
|
|||
uniform sampler2D temp2D;
|
||||
uniform sampler3D temp3D;
|
||||
uniform sampler2D rh2D;
|
||||
uniform sampler3D rh3D;
|
||||
uniform int textureType;
|
||||
uniform float naturalMin[2];
|
||||
uniform float naturalMax[2];
|
||||
uniform float severeThreshold;
|
||||
uniform float moderateThreshold;
|
||||
|
||||
float getValue(sampler2D s2D, sampler3D s3D, float max, float min) {
|
||||
|
||||
float value;
|
||||
if(textureType == 3) {
|
||||
value = texture3D(s3D, vec3(gl_TexCoord[0])).r;
|
||||
}else {
|
||||
value = texture2D(s2D, vec2(gl_TexCoord[0])).r;
|
||||
}
|
||||
|
||||
// scale the value
|
||||
value = (value *(max-min)) + min;
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
void main(void)
|
||||
{
|
||||
|
||||
|
||||
float kelvin = getValue(temp2D, temp3D, naturalMax[0], naturalMin[0]);
|
||||
|
||||
float t = (((kelvin - 273.15) * 1.8) + 32.0);
|
||||
|
||||
float rh = getValue(rh2D, rh3D, naturalMax[1], naturalMin[1]);
|
||||
|
||||
|
||||
float hi = t;
|
||||
if(t >= 57.0) {
|
||||
hi = -42.379 + (2.04901523*t) + (10.14333127*rh) - (0.22475541*t*rh) - (0.00683783*t*t) - (0.05481717*rh*rh) + (0.00122874*t*t*rh)+ (0.00085282*t*rh*rh) - (0.00000199*((t*rh)*(t*rh)));
|
||||
}
|
||||
|
||||
gl_FragColor =vec4(1.0, 0.0, 1.0, 1.0);
|
||||
// convert threshold values to fahenheit
|
||||
if(hi > (severeThreshold *9.0/5.0 -459.67)) {
|
||||
gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
|
||||
|
||||
} else if(hi > (moderateThreshold *9.0/5.0 -459.67)) {
|
||||
gl_FragColor = vec4(1.0, 1.0, 0.0, 1.0);
|
||||
}
|
||||
else {
|
||||
discard;
|
||||
// gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,125 +0,0 @@
|
|||
uniform float brightness;
|
||||
uniform float contrast;
|
||||
uniform sampler1D colorMap;
|
||||
uniform sampler3D tempTex3D;
|
||||
uniform sampler3D clwTex3D;
|
||||
uniform sampler2D tempTex2D;
|
||||
uniform sampler2D clwTex2D;
|
||||
uniform sampler2D tempTex;
|
||||
uniform sampler2D clwTex;
|
||||
uniform float glaze;
|
||||
uniform float rime;
|
||||
uniform float alphaVal;
|
||||
uniform int clwSize;
|
||||
uniform float clwRange[4];
|
||||
uniform float naturalMin[2];
|
||||
uniform float naturalMax[2];
|
||||
uniform int textureType;
|
||||
vec3 AvgLuminance = vec3(0.5, 0.5, 0.5);
|
||||
|
||||
// shader based on icing algorithm found at
|
||||
// http://aoaws.caa.gov.tw/htdocs/projects/aoaws/model/icing/algorithm
|
||||
//
|
||||
|
||||
|
||||
// get the scaled value from either the 2D or 3D texture
|
||||
float getValue(sampler2D s2D, sampler3D s3D, float max, float min) {
|
||||
|
||||
float value;
|
||||
if(textureType == 3) {
|
||||
value = texture3D(s3D, vec3(gl_TexCoord[0])).r;
|
||||
}else {
|
||||
value = texture2D(s2D, vec2(gl_TexCoord[0])).r;
|
||||
}
|
||||
|
||||
// scale the value
|
||||
value = (value *(max-min)) + min;
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
float getIcing()
|
||||
{
|
||||
|
||||
float value = 0.0;
|
||||
|
||||
float temp = getValue(tempTex2D, tempTex3D, naturalMax[0], naturalMin[0]);
|
||||
|
||||
// clw - cloud liquid water
|
||||
float clw = getValue(clwTex2D, clwTex3D, naturalMax[1], naturalMin[1]);
|
||||
|
||||
if(temp > glaze || clw < clwRange[0]) {
|
||||
// no icing
|
||||
value = 0.0;
|
||||
}
|
||||
else {
|
||||
|
||||
if(temp < rime){
|
||||
value = 1.0;
|
||||
}
|
||||
else {
|
||||
value = 2.0;
|
||||
}
|
||||
|
||||
float x = 0.0;
|
||||
for(int i = 0; i < 4; i++) {
|
||||
if(clw > clwRange[i] ){
|
||||
x += 1.0 ;
|
||||
|
||||
}
|
||||
}
|
||||
value += x;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
void main(void)
|
||||
{
|
||||
gl_FragColor = vec4(1.0, 1.0, 0.0, 1.0 );
|
||||
|
||||
// vec4 textureColor = texture2D(tempTex, gl_TexCoord[0].st);
|
||||
// float alpha = textureColor.a;
|
||||
|
||||
float index1 = getIcing();
|
||||
|
||||
// if(index1 == 900.0 ) {
|
||||
// gl_FragColor = vec4(1.0, 0.0, 1.0, 1.0 );
|
||||
//
|
||||
// }
|
||||
// else if(index1 == 10000.0) {
|
||||
// gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0 );
|
||||
//
|
||||
// } else if(index1 == 999.0) {
|
||||
// gl_FragColor = vec4(0.0, 0.0, 1.0, 1.0 );
|
||||
//
|
||||
// }
|
||||
// else {
|
||||
|
||||
float index = (index1 / 5.0);
|
||||
if(index < 0.0) {
|
||||
index = 0.0;
|
||||
} else if(index > 1.0) {
|
||||
index = 1.0;
|
||||
}
|
||||
|
||||
vec4 color = texture1D(colorMap, index).rgba;
|
||||
|
||||
float alpha = color.a;
|
||||
vec4 textureColor = vec4(color.rgb, 1.0);
|
||||
|
||||
vec3 textureColor3 = vec3(textureColor);
|
||||
|
||||
vec3 adjustedColor = mix(AvgLuminance, textureColor3, contrast);
|
||||
float curAlpha = min(alpha, alphaVal);
|
||||
|
||||
if(alpha > 0.0) {
|
||||
gl_FragColor = vec4(adjustedColor.r * brightness, adjustedColor.g * brightness, adjustedColor.b * brightness, alpha);
|
||||
}
|
||||
else {
|
||||
discard;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,157 +0,0 @@
|
|||
uniform sampler2D tex;
|
||||
uniform float brightness;
|
||||
uniform float contrast;
|
||||
uniform int doColorMap;
|
||||
uniform float naturalMin;
|
||||
uniform float naturalMax;
|
||||
uniform float cmapMin;
|
||||
uniform float cmapMax;
|
||||
uniform sampler1D colorMap;
|
||||
uniform sampler2D rawTex;
|
||||
uniform float alphaVal;
|
||||
uniform float colorMapSz;
|
||||
uniform int doImpact;
|
||||
uniform int upperThreshold;
|
||||
uniform int numberGrids;
|
||||
uniform float severeThreshold[8];
|
||||
uniform float moderateThreshold[8];
|
||||
uniform float naturalMins[8];
|
||||
uniform float naturalMaxes[8];
|
||||
uniform sampler2D grids[8];
|
||||
uniform int enabledImpacts[8];
|
||||
uniform int numberEnabled;
|
||||
vec3 AvgLuminance = vec3(0.5, 0.5, 0.5);
|
||||
|
||||
float impactAnd()
|
||||
{
|
||||
float impactVal = 3.0;
|
||||
for(int x=0; x < 8; x++)
|
||||
{
|
||||
if(x >= numberGrids)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if(enabledImpacts[x] == 1)
|
||||
{
|
||||
vec4 textureColor = texture2D(grids[x], gl_TexCoord[0].st);
|
||||
float naturalValue = ((textureColor.r * (naturalMaxes[x] - naturalMins[x])) + naturalMins[x]);
|
||||
if(upperThreshold == 1)
|
||||
{
|
||||
if(naturalValue < moderateThreshold[x])
|
||||
{
|
||||
impactVal = 0.0;
|
||||
}
|
||||
else if(naturalValue < severeThreshold[x])
|
||||
{
|
||||
if(impactVal == 3.0)
|
||||
{
|
||||
impactVal = 2.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(naturalValue > moderateThreshold[x])
|
||||
{
|
||||
impactVal = 0.0;
|
||||
}
|
||||
else if(naturalValue > severeThreshold[x])
|
||||
{
|
||||
if(impactVal == 3.0)
|
||||
{
|
||||
impactVal = 2.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return impactVal;
|
||||
}
|
||||
|
||||
float impactOr()
|
||||
{
|
||||
float impactVal = 0.0;
|
||||
for(int x=0; x < 8; x++)
|
||||
{
|
||||
if(x >= numberGrids)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if(enabledImpacts[x] == 1)
|
||||
{
|
||||
vec4 textureColor = texture2D(grids[x], gl_TexCoord[0].st);
|
||||
float naturalValue = ((textureColor.r * (naturalMaxes[x] - naturalMins[x])) + naturalMins[x]);
|
||||
if(upperThreshold == 1)
|
||||
{
|
||||
if(naturalValue > severeThreshold[x])
|
||||
{
|
||||
impactVal = 3.0;
|
||||
}
|
||||
else if(naturalValue > moderateThreshold[x])
|
||||
{
|
||||
impactVal = 2.0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(naturalValue < severeThreshold[x])
|
||||
{
|
||||
impactVal = 3.0;
|
||||
}
|
||||
else if(naturalValue < moderateThreshold[x])
|
||||
{
|
||||
impactVal = 2.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return impactVal;
|
||||
}
|
||||
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec4 textureColor = texture2D(rawTex, gl_TexCoord[0].st);
|
||||
float alpha = textureColor.a;
|
||||
if(doImpact == 1)
|
||||
{
|
||||
float impactVal = 0.0;
|
||||
if(numberEnabled > 0)
|
||||
{
|
||||
impactVal = impactAnd();
|
||||
}
|
||||
else
|
||||
{
|
||||
impactVal = 0.0;
|
||||
}
|
||||
|
||||
float index = (impactVal / 3.0);
|
||||
if(index < 0.0) {
|
||||
index = 0.0;
|
||||
} else if(index > 1.0) {
|
||||
index = 1.0;
|
||||
}
|
||||
vec4 color = texture1D(colorMap, index).rgba;
|
||||
alpha = color.a;
|
||||
textureColor = vec4(color.rgb, 1.0);
|
||||
}
|
||||
else if(doColorMap == 1) {
|
||||
float naturalValue = ((textureColor.r * (naturalMax - naturalMin)) + naturalMin);
|
||||
float index = ((naturalValue - cmapMin) / (cmapMax-cmapMin));
|
||||
if(index < 0.0) {
|
||||
index = 0.0;
|
||||
} else if(index > 1.0) {
|
||||
index = 1.0;
|
||||
}
|
||||
vec4 color = texture1D(colorMap, index).rgba;
|
||||
alpha = color.a;
|
||||
textureColor = vec4(color.rgb, 1.0);
|
||||
}
|
||||
vec3 textureColor3 = vec3(textureColor);
|
||||
vec3 adjustedColor = mix(AvgLuminance, textureColor3, contrast);
|
||||
float curAlpha = min(alpha, alphaVal);
|
||||
gl_FragColor = vec4(adjustedColor.r * brightness, adjustedColor.g * brightness, adjustedColor.b * brightness, curAlpha);
|
||||
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
uniform sampler2D terrainMap;
|
||||
uniform float exaggeration;
|
||||
uniform int layer;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec4 newVertexPos;
|
||||
float df;
|
||||
|
||||
gl_TexCoord[0].xy = gl_MultiTexCoord0.xy;
|
||||
vec3 normal = normalize(gl_Normal);
|
||||
df = texture2D( terrainMap, gl_TexCoord[0].xy ).r;
|
||||
if(layer > 0){
|
||||
exaggeration *= layer;
|
||||
}
|
||||
newVertexPos = vec4(normal *df* exaggeration , 0.0) + gl_Vertex;
|
||||
|
||||
gl_Position = gl_ModelViewProjectionMatrix * newVertexPos;
|
||||
}
|
|
@ -20,13 +20,8 @@
|
|||
-->
|
||||
<?eclipse version="3.2"?>
|
||||
<plugin>
|
||||
<extension-point id ="shader" name="shader" schema="schema/shader.exsd"/>
|
||||
|
||||
<extension point="com.raytheon.uf.viz.core.graphicsFactory">
|
||||
<graphicsFactory id="default" type="2D" factoryClass="com.raytheon.viz.core.gl.GLFactoryAdapter"/>
|
||||
</extension>
|
||||
<extension point="com.raytheon.viz.core.gl.shader">
|
||||
<shader programName="raster" loaderClass="com.raytheon.viz.core.gl.glsl.GLSLRasterProgramLoader"/>
|
||||
</extension>
|
||||
<extension
|
||||
point="com.raytheon.uf.viz.localization.localizationpath">
|
||||
|
@ -44,7 +39,7 @@
|
|||
class="com.raytheon.viz.core.gl.internal.ext.GLColormapShadedShapeExtension">
|
||||
</graphicsExtension>
|
||||
<graphicsExtension
|
||||
class="com.raytheon.viz.core.gl.internal.ext.GLOffscreenRenderingExtension">
|
||||
class="com.raytheon.viz.core.gl.ext.GLOffscreenRenderingExtension">
|
||||
</graphicsExtension>
|
||||
<graphicsExtension
|
||||
class="com.raytheon.viz.core.gl.internal.ext.GLMapMeshExtension">
|
||||
|
@ -52,5 +47,11 @@
|
|||
<graphicsExtension
|
||||
class="com.raytheon.viz.core.gl.internal.ext.GLColormappedImageExtension">
|
||||
</graphicsExtension>
|
||||
<graphicsExtension
|
||||
class="com.raytheon.viz.core.gl.internal.ext.GLSingleColorImageExtension">
|
||||
</graphicsExtension>
|
||||
<graphicsExtension
|
||||
class="com.raytheon.viz.core.gl.internal.ext.GLDefaultImagingExtension">
|
||||
</graphicsExtension>
|
||||
</extension>
|
||||
</plugin>
|
||||
|
|
|
@ -1,85 +0,0 @@
|
|||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<!-- Schema file written by PDE -->
|
||||
<schema targetNamespace="com.raytheon.viz.core.gl" xmlns="http://www.w3.org/2001/XMLSchema">
|
||||
<annotation>
|
||||
<appinfo>
|
||||
<meta.schema plugin="com.raytheon.viz.core.gl" id="shader" name="shader"/>
|
||||
</appinfo>
|
||||
<documentation>
|
||||
This extension point is used to identify shader programs
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
<element name="extension">
|
||||
<annotation>
|
||||
<appinfo>
|
||||
<meta.element />
|
||||
</appinfo>
|
||||
</annotation>
|
||||
<complexType>
|
||||
<sequence>
|
||||
<element ref="shader" minOccurs="1" maxOccurs="unbounded"/>
|
||||
</sequence>
|
||||
<attribute name="point" type="string" use="required">
|
||||
<annotation>
|
||||
<documentation>
|
||||
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="id" type="string">
|
||||
<annotation>
|
||||
<documentation>
|
||||
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="name" type="string">
|
||||
<annotation>
|
||||
<documentation>
|
||||
|
||||
</documentation>
|
||||
<appinfo>
|
||||
<meta.attribute translatable="true"/>
|
||||
</appinfo>
|
||||
</annotation>
|
||||
</attribute>
|
||||
</complexType>
|
||||
</element>
|
||||
|
||||
<element name="shader">
|
||||
<complexType>
|
||||
<attribute name="loaderClass" type="string" use="required">
|
||||
<annotation>
|
||||
<documentation>
|
||||
|
||||
</documentation>
|
||||
<appinfo>
|
||||
<meta.attribute kind="java" basedOn=":com.raytheon.viz.core.gl.glsl.IShaderLoader"/>
|
||||
</appinfo>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="programName" type="string" use="required">
|
||||
<annotation>
|
||||
<documentation>
|
||||
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
</complexType>
|
||||
</element>
|
||||
|
||||
<annotation>
|
||||
<appinfo>
|
||||
<meta.section type="since"/>
|
||||
</appinfo>
|
||||
<documentation>
|
||||
0.1
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</schema>
|
|
@ -19,31 +19,31 @@
|
|||
**/
|
||||
package com.raytheon.viz.core.gl;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.media.opengl.GL;
|
||||
|
||||
import org.geotools.coverage.grid.GeneralGridGeometry;
|
||||
import org.geotools.coverage.grid.GridGeometry2D;
|
||||
import org.geotools.referencing.CRS;
|
||||
import org.geotools.referencing.crs.DefaultGeographicCRS;
|
||||
import org.geotools.referencing.operation.DefaultMathTransformFactory;
|
||||
import org.opengis.referencing.datum.PixelInCell;
|
||||
import org.opengis.referencing.operation.MathTransform;
|
||||
import org.opengis.referencing.operation.TransformException;
|
||||
|
||||
import com.raytheon.uf.common.geospatial.MapUtil;
|
||||
import com.raytheon.uf.common.geospatial.util.WorldWrapChecker;
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
import com.raytheon.uf.viz.core.IExtent;
|
||||
import com.raytheon.uf.viz.core.IGraphicsTarget;
|
||||
import com.raytheon.uf.viz.core.IMesh;
|
||||
import com.raytheon.uf.viz.core.PixelCoverage;
|
||||
import com.raytheon.uf.viz.core.drawables.PaintProperties;
|
||||
import com.raytheon.uf.viz.core.drawables.PaintStatus;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
import com.raytheon.uf.viz.core.map.IMapDescriptor;
|
||||
import com.raytheon.uf.viz.core.map.WorldWrapChecker;
|
||||
import com.raytheon.uf.viz.core.rsc.hdf5.ImageTile;
|
||||
import com.raytheon.uf.viz.core.jobs.JobPool;
|
||||
import com.raytheon.viz.core.gl.GLGeometryObject2D.GLGeometryObjectData;
|
||||
import com.raytheon.viz.core.gl.SharedCoordMap.SharedCoordinateKey;
|
||||
import com.raytheon.viz.core.gl.SharedCoordMap.SharedCoordinates;
|
||||
import com.vividsolutions.jts.geom.Envelope;
|
||||
|
||||
/**
|
||||
* Abstract GLMesh
|
||||
|
@ -63,35 +63,76 @@ import com.vividsolutions.jts.geom.Envelope;
|
|||
|
||||
public abstract class AbstractGLMesh implements IMesh {
|
||||
|
||||
protected boolean shouldDraw = true;
|
||||
private static final JobPool calculator = new JobPool("Mesh Calculator", 2,
|
||||
false);
|
||||
|
||||
private boolean compiled = false;
|
||||
protected static enum State {
|
||||
NEW, CALCULATING, CALCULATED, COMPILED, INVALID;
|
||||
}
|
||||
|
||||
protected GLGeometryObject2D vertexCoords;
|
||||
private State internalState = State.NEW;
|
||||
|
||||
protected SharedCoordinateKey key;
|
||||
private GLGeometryObject2D vertexCoords;
|
||||
|
||||
private SharedCoordinates sharedTextureCoords;
|
||||
|
||||
protected IMapDescriptor descriptor;
|
||||
protected SharedCoordinateKey key;
|
||||
|
||||
public AbstractGLMesh(int geometryType, IMapDescriptor descriptor) {
|
||||
vertexCoords = new GLGeometryObject2D(new GLGeometryObjectData(
|
||||
geometryType, GL.GL_VERTEX_ARRAY));
|
||||
this.descriptor = descriptor;
|
||||
private Runnable calculate = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
synchronized (calculate) {
|
||||
if (internalState == State.CALCULATING) {
|
||||
// If we aren't in CALCULATING state, we were disposed while
|
||||
// waiting to run and shouldn't run now
|
||||
if (calculateMesh()) {
|
||||
internalState = State.CALCULATED;
|
||||
} else {
|
||||
internalState = State.INVALID;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private int geometryType;
|
||||
|
||||
private MathTransform imageCRSToLatLon;
|
||||
|
||||
private MathTransform latLonToTargetGrid;
|
||||
|
||||
private GeneralGridGeometry targetGeometry;
|
||||
|
||||
private GridGeometry2D imageGeometry;
|
||||
|
||||
protected AbstractGLMesh(int geometryType) {
|
||||
this.geometryType = geometryType;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.viz.core.IMesh#paint(com.raytheon.viz.core.IGraphicsTarget)
|
||||
*/
|
||||
@Override
|
||||
public synchronized void paint(IGraphicsTarget target,
|
||||
protected final void initialize(GridGeometry2D imageGeometry,
|
||||
GeneralGridGeometry targetGeometry) throws VizException {
|
||||
this.imageGeometry = imageGeometry;
|
||||
if (imageGeometry != null) {
|
||||
try {
|
||||
imageCRSToLatLon = MapUtil.getTransformToLatLon(imageGeometry
|
||||
.getCoordinateReferenceSystem());
|
||||
} catch (Throwable t) {
|
||||
throw new VizException(
|
||||
"Error construcing image to lat/lon transform", t);
|
||||
}
|
||||
}
|
||||
reproject(targetGeometry);
|
||||
}
|
||||
|
||||
public final synchronized PaintStatus paint(IGraphicsTarget target,
|
||||
PaintProperties paintProps) throws VizException {
|
||||
if (!shouldDraw) {
|
||||
return;
|
||||
State internalState = this.internalState;
|
||||
if (internalState == State.NEW) {
|
||||
throw new VizException(
|
||||
"Class did not properly call initialize on construction");
|
||||
} else if (internalState == State.INVALID) {
|
||||
// Don't paint if invalid to avoid crashes
|
||||
return PaintStatus.ERROR;
|
||||
}
|
||||
|
||||
IGLTarget glTarget;
|
||||
|
@ -101,65 +142,91 @@ public abstract class AbstractGLMesh implements IMesh {
|
|||
|
||||
glTarget = (IGLTarget) target;
|
||||
|
||||
if (sharedTextureCoords == null) {
|
||||
sharedTextureCoords = SharedCoordMap.get(key, glTarget);
|
||||
}
|
||||
try {
|
||||
if (internalState == State.CALCULATED) {
|
||||
// We finished calculating the mesh, compile it
|
||||
sharedTextureCoords = SharedCoordMap.get(key, glTarget);
|
||||
vertexCoords.compile(glTarget.getGl());
|
||||
this.internalState = internalState = State.COMPILED;
|
||||
}
|
||||
|
||||
if (!compiled) {
|
||||
vertexCoords.compile(glTarget.getGl());
|
||||
compiled = true;
|
||||
if (internalState == State.COMPILED) {
|
||||
GLGeometryPainter.paintGeometries(glTarget.getGl(),
|
||||
vertexCoords, sharedTextureCoords.getTextureCoords());
|
||||
return PaintStatus.PAINTED;
|
||||
} else if (internalState == State.CALCULATING) {
|
||||
target.setNeedsRefresh(true);
|
||||
return PaintStatus.REPAINT;
|
||||
} else {
|
||||
return PaintStatus.ERROR;
|
||||
}
|
||||
} catch (VizException e) {
|
||||
this.internalState = State.INVALID;
|
||||
throw e;
|
||||
}
|
||||
|
||||
GLGeometryPainter.paintGeometries(glTarget.getGl(), vertexCoords,
|
||||
sharedTextureCoords.getTextureCoords());
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void dispose() {
|
||||
vertexCoords.dispose();
|
||||
if (sharedTextureCoords != null) {
|
||||
SharedCoordMap.remove(key);
|
||||
sharedTextureCoords = null;
|
||||
// Synchronize on calculate so we don't dispose while running
|
||||
synchronized (calculate) {
|
||||
// Cancel calculation job from running
|
||||
calculator.cancel(calculate);
|
||||
// dispose and reset vertexCoords
|
||||
if (vertexCoords != null) {
|
||||
vertexCoords.dispose();
|
||||
vertexCoords = null;
|
||||
}
|
||||
if (sharedTextureCoords != null) {
|
||||
SharedCoordMap.remove(key);
|
||||
sharedTextureCoords = null;
|
||||
}
|
||||
internalState = State.INVALID;
|
||||
}
|
||||
shouldDraw = false;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.viz.core.IMesh#calculateMesh(com.raytheon.viz.core.PixelCoverage
|
||||
* , org.opengis.coverage.grid.GridGeometry)
|
||||
* @see com.raytheon.uf.viz.core.IMesh#reproject(org.geotools.coverage.grid.
|
||||
* GeneralGridGeometry)
|
||||
*/
|
||||
public void calculateMesh(PixelCoverage pc, GridGeometry2D gg) {
|
||||
MathTransform toLL = null;
|
||||
ImageTile tile = null;
|
||||
try {
|
||||
toLL = CRS.findMathTransform(gg.getCoordinateReferenceSystem(),
|
||||
DefaultGeographicCRS.WGS84);
|
||||
tile = new ImageTile();
|
||||
tile.coverage = pc;
|
||||
tile.rect = new Rectangle(gg.getGridRange().getLow(0), gg
|
||||
.getGridRange().getLow(1), gg.getGridRange().getHigh(0), gg
|
||||
.getGridRange().getHigh(1));
|
||||
tile.envelope = new Envelope(gg.getEnvelope().getMinimum(0), gg
|
||||
.getEnvelope().getMaximum(0), gg.getEnvelope()
|
||||
.getMinimum(1), gg.getEnvelope().getMaximum(1));
|
||||
} catch (Exception e) {
|
||||
@Override
|
||||
public final void reproject(GeneralGridGeometry targetGeometry)
|
||||
throws VizException {
|
||||
if (targetGeometry.equals(this.targetGeometry) == false) {
|
||||
dispose();
|
||||
this.targetGeometry = targetGeometry;
|
||||
|
||||
// Set up convenience transforms
|
||||
try {
|
||||
DefaultMathTransformFactory factory = new DefaultMathTransformFactory();
|
||||
latLonToTargetGrid = factory.createConcatenatedTransform(
|
||||
MapUtil.getTransformFromLatLon(targetGeometry
|
||||
.getCoordinateReferenceSystem()),
|
||||
targetGeometry.getGridToCRS(PixelInCell.CELL_CENTER)
|
||||
.inverse());
|
||||
} catch (Throwable t) {
|
||||
internalState = State.INVALID;
|
||||
throw new VizException("Error projecting mesh", t);
|
||||
}
|
||||
|
||||
internalState = State.CALCULATING;
|
||||
calculator.schedule(calculate);
|
||||
}
|
||||
calculateMesh(pc, tile, toLL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calculateMesh(PixelCoverage pc, ImageTile tile, MathTransform mt) {
|
||||
shouldDraw = false;
|
||||
key = generateKey(tile, mt);
|
||||
private boolean calculateMesh() {
|
||||
key = generateKey(imageGeometry, imageCRSToLatLon);
|
||||
try {
|
||||
double[][][] worldCoordinates = generateWorldCoords(tile, mt);
|
||||
double[][][] worldCoordinates = generateWorldCoords(imageGeometry,
|
||||
imageCRSToLatLon);
|
||||
vertexCoords = new GLGeometryObject2D(new GLGeometryObjectData(
|
||||
geometryType, GL.GL_VERTEX_ARRAY));
|
||||
vertexCoords.allocate(worldCoordinates.length
|
||||
* worldCoordinates[0].length);
|
||||
// Check for world wrapping
|
||||
WorldWrapChecker wwc = new WorldWrapChecker(descriptor);
|
||||
WorldWrapChecker wwc = new WorldWrapChecker(targetGeometry);
|
||||
|
||||
for (int i = 0; i < worldCoordinates.length; ++i) {
|
||||
double[][] strip = worldCoordinates[i];
|
||||
|
@ -176,7 +243,7 @@ public abstract class AbstractGLMesh implements IMesh {
|
|||
prev1 = null;
|
||||
prev2 = null;
|
||||
}
|
||||
vSegment.add(descriptor.worldToPixel(next));
|
||||
vSegment.add(worldToPixel(next));
|
||||
|
||||
prev2 = prev1;
|
||||
prev1 = next;
|
||||
|
@ -185,14 +252,28 @@ public abstract class AbstractGLMesh implements IMesh {
|
|||
vertexCoords.addSegment(vSegment.toArray(new double[vSegment
|
||||
.size()][]));
|
||||
}
|
||||
|
||||
shouldDraw = true;
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
shouldDraw = false;
|
||||
Activator.statusHandler.handle(Priority.PROBLEM,
|
||||
"Error calculating mesh", e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
pc.setMesh(this);
|
||||
protected final double[] worldToPixel(double[] world) {
|
||||
double[] in = null;
|
||||
if (world.length == 2) {
|
||||
in = new double[] { world[0], world[1], 0.0 };
|
||||
} else {
|
||||
in = world;
|
||||
}
|
||||
double[] out = new double[in.length];
|
||||
try {
|
||||
latLonToTargetGrid.transform(in, 0, out, 0, 1);
|
||||
} catch (TransformException e) {
|
||||
return null;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -207,10 +288,11 @@ public abstract class AbstractGLMesh implements IMesh {
|
|||
return false;
|
||||
}
|
||||
|
||||
protected abstract SharedCoordinateKey generateKey(ImageTile tile,
|
||||
MathTransform mt);
|
||||
protected abstract SharedCoordinateKey generateKey(
|
||||
GridGeometry2D imageGeometry, MathTransform mt);
|
||||
|
||||
protected abstract double[][][] generateWorldCoords(ImageTile tile,
|
||||
MathTransform mt) throws TransformException;
|
||||
protected abstract double[][][] generateWorldCoords(
|
||||
GridGeometry2D imageGeometry, MathTransform mt)
|
||||
throws TransformException;
|
||||
|
||||
}
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
**/
|
||||
package com.raytheon.viz.core.gl;
|
||||
|
||||
import org.eclipse.core.runtime.jobs.Job;
|
||||
import org.eclipse.jface.preference.IPersistentPreferenceStore;
|
||||
import org.eclipse.ui.plugin.AbstractUIPlugin;
|
||||
import org.osgi.framework.BundleContext;
|
||||
|
@ -34,7 +33,8 @@ import com.raytheon.uf.viz.core.localization.HierarchicalPreferenceStore;
|
|||
* The activator class controls the plug-in life cycle
|
||||
*/
|
||||
public class Activator extends AbstractUIPlugin {
|
||||
private static final transient IUFStatusHandler statusHandler = UFStatus
|
||||
|
||||
public static final transient IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(Activator.class);
|
||||
|
||||
// The plug-in ID
|
||||
|
@ -62,12 +62,6 @@ public class Activator extends AbstractUIPlugin {
|
|||
*/
|
||||
public void start(BundleContext context) throws Exception {
|
||||
super.start(context);
|
||||
// Start the texture loader job
|
||||
TextureLoaderJob textureLoader = TextureLoaderJob.getInstance();
|
||||
if (textureLoader.getState() != Job.RUNNING) {
|
||||
textureLoader.setSystem(true);
|
||||
textureLoader.schedule();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -80,11 +74,6 @@ public class Activator extends AbstractUIPlugin {
|
|||
public void stop(BundleContext context) throws Exception {
|
||||
plugin = null;
|
||||
super.stop(context);
|
||||
// Start the texture loader job
|
||||
TextureLoaderJob textureLoader = TextureLoaderJob.getInstance();
|
||||
if (textureLoader.getState() == Job.RUNNING) {
|
||||
textureLoader.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -151,17 +151,4 @@ public class GLFactoryAdapter extends AbstractGraphicsFactoryAdapter {
|
|||
return canvas;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.viz.core.AbstractGraphicsFactoryAdapter#disposeCanvas
|
||||
* (org.eclipse.swt.widgets.Canvas)
|
||||
*/
|
||||
@Override
|
||||
public void disposeCanvas(Canvas canvas) {
|
||||
if (!canvas.isDisposed()) {
|
||||
canvas.getParent().dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,8 +48,6 @@ import com.raytheon.viz.core.gl.GLGeometryObject2D.State;
|
|||
|
||||
public class GLGeometryPainter {
|
||||
|
||||
private static int maxVertices = -1;
|
||||
|
||||
public static void paintGeometries(GL gl, GLGeometryObject2D... geoms)
|
||||
throws VizException {
|
||||
State state = State.INVALID;
|
||||
|
|
|
@ -24,14 +24,9 @@ import javax.media.opengl.glu.GLU;
|
|||
|
||||
import org.eclipse.swt.graphics.Rectangle;
|
||||
|
||||
import com.raytheon.uf.viz.core.DrawableImage;
|
||||
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.IRenderableDisplay;
|
||||
import com.raytheon.uf.viz.core.drawables.PaintProperties;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
import com.raytheon.viz.core.gl.images.GLColormappedImage;
|
||||
import com.raytheon.uf.viz.core.drawables.ColorMapParameters;
|
||||
import com.raytheon.viz.core.gl.objects.GLTextureObject;
|
||||
|
||||
public interface IGLTarget extends IGraphicsTarget {
|
||||
|
||||
|
@ -39,13 +34,9 @@ public interface IGLTarget extends IGraphicsTarget {
|
|||
|
||||
public abstract GLU getGlu();
|
||||
|
||||
/**
|
||||
* Active texture unit and bind a texture
|
||||
*
|
||||
* @param textureUnit
|
||||
* @param GLImage
|
||||
*/
|
||||
public abstract void bindTexture(int textureUnit, GLColormappedImage image);
|
||||
public abstract void pushGLState();
|
||||
|
||||
public abstract void popGLState();
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -59,6 +50,12 @@ public interface IGLTarget extends IGraphicsTarget {
|
|||
*/
|
||||
public abstract void releaseContext();
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public abstract void releaseContext();
|
||||
|
||||
/**
|
||||
* Get the modle view matrix settings
|
||||
*
|
||||
|
@ -107,70 +104,13 @@ public interface IGLTarget extends IGraphicsTarget {
|
|||
public abstract Rectangle getBounds();
|
||||
|
||||
/**
|
||||
* Dispose a vbo
|
||||
* Get a colormap texture id for the specified parameters
|
||||
*
|
||||
* @param id
|
||||
* the vbo id
|
||||
*/
|
||||
public abstract void disposeVBO(int id);
|
||||
|
||||
/**
|
||||
* Dispose the occlusion query
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
public abstract void disposeOcclusionQueries(int[] id);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param display
|
||||
* @throws VizException
|
||||
*/
|
||||
public void beginOcclusionTest(IRenderableDisplay display)
|
||||
throws VizException;
|
||||
|
||||
/**
|
||||
* End the occlusion test. Commands will update the framebuffer
|
||||
*
|
||||
* @throws VizException
|
||||
*/
|
||||
public void endOcclusionTest() throws VizException;
|
||||
|
||||
/**
|
||||
* call drawRaster using a specified shader program
|
||||
*
|
||||
* @param image
|
||||
* @param extent
|
||||
* @param paintProps
|
||||
* @param shaderProgram
|
||||
* @param cmapParams
|
||||
* @return
|
||||
* @throws VizException
|
||||
*/
|
||||
public abstract boolean drawRaster(IImage image, PixelCoverage extent,
|
||||
PaintProperties paintProps, String shaderProgram)
|
||||
throws VizException;
|
||||
|
||||
/**
|
||||
* call drawRaster with a specified shader program
|
||||
*
|
||||
* @param image
|
||||
* the image reference object to draw
|
||||
* @param extent
|
||||
* the extent of the drawable area
|
||||
* @param paintProps
|
||||
* the paint properties
|
||||
* @param mode
|
||||
* the drawing mode (synchronous, asynchronous)
|
||||
* @return status whether the raster was able to be drawn
|
||||
* @throws VizException
|
||||
*/
|
||||
public abstract boolean drawRaster(IImage image, PixelCoverage extent,
|
||||
PaintProperties paintProps, RasterMode mode, String shaderProgram)
|
||||
throws VizException;
|
||||
|
||||
public abstract boolean drawRasters(String shader,
|
||||
PaintProperties paintProps, DrawableImage... images)
|
||||
throws VizException;
|
||||
public abstract GLTextureObject getColorMapTexture(
|
||||
ColorMapParameters cmapParams);
|
||||
|
||||
/**
|
||||
* Checks the glError state and does a UFStatus message
|
||||
|
|
|
@ -153,14 +153,13 @@ public class SharedCoordMap {
|
|||
*/
|
||||
private static void populateTextureGeom(SharedCoordinateKey key,
|
||||
GLGeometryObject2D geom) {
|
||||
geom.allocate(key.verticalDivisions * key.horizontalDivisions * 2);
|
||||
|
||||
int height = 2 * key.verticalDivisions;
|
||||
int height = 2 * (key.verticalDivisions + 1);
|
||||
int width = key.horizontalDivisions;
|
||||
geom.allocate(width * height * 2);
|
||||
|
||||
// get dx and dy for texture points
|
||||
float dX = (1.0f / (key.horizontalDivisions));
|
||||
float dY = (1.0f / (key.verticalDivisions - 1));
|
||||
float dY = (1.0f / (key.verticalDivisions));
|
||||
|
||||
float xLow, xHigh = 0;
|
||||
|
||||
|
|
|
@ -1,210 +0,0 @@
|
|||
/**
|
||||
* 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;
|
||||
|
||||
import java.util.Queue;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
|
||||
import javax.media.opengl.GLContext;
|
||||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.core.runtime.jobs.Job;
|
||||
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
import com.raytheon.viz.core.gl.images.AbstractGLImage;
|
||||
|
||||
/**
|
||||
* Job that demand-loads textures into GL.
|
||||
* <P>
|
||||
*
|
||||
* If a multiple ImageIO.reads are incurred simultaneously, the performance is
|
||||
* horrible. By having only one texture load occur at a time in a different
|
||||
* (non-blocking) thread, with adequate pause between texture loads, this
|
||||
* problem is alleviated.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 7/1/06 chammack Initial Creation.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author chammack
|
||||
*
|
||||
*/
|
||||
public class TextureLoaderJob extends Job {
|
||||
|
||||
/** Number of things to keep on the queue before starting to remove some */
|
||||
private static final int MAX_QUEUE_SIZE = 256;
|
||||
|
||||
/** The instance */
|
||||
private static TextureLoaderJob instance;
|
||||
|
||||
/** Time (in ms) for the texture job to sleep (NEVER SET TO ZERO) */
|
||||
private static final int TEXTURE_JOB_SLEEP_TIME = 2;
|
||||
|
||||
/** A flag to indicate whether the job should continue running */
|
||||
private boolean isRunning = true;
|
||||
|
||||
/** A queue of images to load */
|
||||
private final Queue<AbstractGLImage> texturesToLoad;
|
||||
|
||||
/** A thread safe list of images to load */
|
||||
private final ConcurrentLinkedQueue<Request> texturesToLoadToGPU;
|
||||
|
||||
/**
|
||||
* Internal datastructure: used to populate the queues
|
||||
*/
|
||||
private class Request {
|
||||
public AbstractGLImage image;
|
||||
|
||||
public GLContext ctx;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the currently running instance of the texture loader
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static TextureLoaderJob getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new TextureLoaderJob();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use getInstance() instead of constructor
|
||||
*
|
||||
*/
|
||||
private TextureLoaderJob() {
|
||||
super("Texture Loader");
|
||||
this.texturesToLoad = new LinkedBlockingQueue<AbstractGLImage>();
|
||||
this.texturesToLoadToGPU = new ConcurrentLinkedQueue<Request>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Request an image to be loaded
|
||||
*
|
||||
* @param img
|
||||
* the image
|
||||
*/
|
||||
public void requestLoad(AbstractGLImage img) {
|
||||
if (!this.texturesToLoad.contains(img))
|
||||
this.texturesToLoad.add(img);
|
||||
}
|
||||
|
||||
public void requestLoadIntoTexture(AbstractGLImage img, GLContext ctx) {
|
||||
Request req = new Request();
|
||||
req.image = img;
|
||||
req.ctx = ctx;
|
||||
|
||||
this.texturesToLoadToGPU.add(req);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @seeorg.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.
|
||||
* IProgressMonitor)
|
||||
*/
|
||||
@Override
|
||||
protected IStatus run(IProgressMonitor monitor) {
|
||||
|
||||
while (this.isRunning) {
|
||||
while (this.texturesToLoad.size() > MAX_QUEUE_SIZE) {
|
||||
this.texturesToLoad.poll();
|
||||
}
|
||||
|
||||
while (this.texturesToLoad.size() > 0) {
|
||||
AbstractGLImage image = this.texturesToLoad.remove();
|
||||
if (image.getStatus() == com.raytheon.uf.viz.core.drawables.IImage.Status.STAGED
|
||||
|| image.getStatus() == com.raytheon.uf.viz.core.drawables.IImage.Status.LOADED) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
image.stageTexture();
|
||||
} catch (VizException e) {
|
||||
Activator
|
||||
.getDefault()
|
||||
.getLog()
|
||||
.log(new Status(IStatus.ERROR, Activator.PLUGIN_ID,
|
||||
"Staging texture failed", e));
|
||||
}
|
||||
}
|
||||
try {
|
||||
Thread.sleep(TEXTURE_JOB_SLEEP_TIME);
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
|
||||
// while (this.texturesToLoadToGPU.size() > MAX_QUEUE_SIZE) {
|
||||
// this.texturesToLoadToGPU.remove();
|
||||
// }
|
||||
//
|
||||
// while (this.texturesToLoadToGPU.size() > 0) {
|
||||
// final Request request = this.texturesToLoadToGPU.remove();
|
||||
//
|
||||
// if (request.image.getStatus() == IImage.Status.LOADED
|
||||
// || request.image.getStatus() == IImage.Status.FAILED) {
|
||||
// continue;
|
||||
// }
|
||||
// VizApp.runSync(new Runnable() {
|
||||
//
|
||||
// public void run() {
|
||||
// try {
|
||||
// request.image.loadTexture(request.ctx);
|
||||
// } catch (VizException e) {
|
||||
// // Set an exception that the drawing subsystem will
|
||||
// // pick
|
||||
// // up and log properly/display to user
|
||||
// request.image.setStatus(IImage.Status.FAILED);
|
||||
// request.image.setFailedMessage(e);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// });
|
||||
//
|
||||
// }
|
||||
// try {
|
||||
// Thread.sleep(TEXTURE_JOB_SLEEP_TIME);
|
||||
// } catch (InterruptedException e) {
|
||||
// }
|
||||
|
||||
}
|
||||
return Status.OK_STATUS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Request the job to be shut down
|
||||
*
|
||||
*/
|
||||
public void shutdown() {
|
||||
this.isRunning = false;
|
||||
}
|
||||
|
||||
}
|
|
@ -83,7 +83,7 @@ public class GLShortDataFormat extends AbstractGLColorMapDataFormat {
|
|||
* (int, int, com.raytheon.viz.core.gl.dataprep.GLColorMapData)
|
||||
*/
|
||||
@Override
|
||||
public Short getValue(int x, int y, GLColorMapData data) {
|
||||
public Number getValue(int x, int y, GLColorMapData data) {
|
||||
if (!(data.getData() instanceof ShortBuffer)) {
|
||||
throw new IllegalArgumentException(
|
||||
"Expecting data to contain a ShortBuffer but instead it is a "
|
||||
|
|
|
@ -60,7 +60,7 @@ public class GLUnsignedShortDataFormat extends GLShortDataFormat {
|
|||
* int, com.raytheon.viz.core.gl.dataformat.GLColorMapData)
|
||||
*/
|
||||
@Override
|
||||
public Short getValue(int x, int y, GLColorMapData data) {
|
||||
public Number getValue(int x, int y, GLColorMapData data) {
|
||||
if (!(data.getData() instanceof ShortBuffer)) {
|
||||
throw new IllegalArgumentException(
|
||||
"Expecting data to contain a ShortBuffer but instead it is a "
|
||||
|
@ -69,7 +69,7 @@ public class GLUnsignedShortDataFormat extends GLShortDataFormat {
|
|||
int width = getAlignedWidth(data.getDimensionSize(0));
|
||||
int index = y * width + x;
|
||||
ShortBuffer buffer = (ShortBuffer) data.getData();
|
||||
return buffer.get(index);
|
||||
return (buffer.get(index) & 0xFFFF);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,373 @@
|
|||
/**
|
||||
* 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.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.FloatBuffer;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.media.opengl.GL;
|
||||
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.viz.core.DrawableImage;
|
||||
import com.raytheon.uf.viz.core.IMesh;
|
||||
import com.raytheon.uf.viz.core.PixelCoverage;
|
||||
import com.raytheon.uf.viz.core.drawables.IImage;
|
||||
import com.raytheon.uf.viz.core.drawables.IImage.Status;
|
||||
import com.raytheon.uf.viz.core.drawables.PaintProperties;
|
||||
import com.raytheon.uf.viz.core.drawables.PaintStatus;
|
||||
import com.raytheon.uf.viz.core.drawables.ext.GraphicsExtension;
|
||||
import com.raytheon.uf.viz.core.drawables.ext.IImagingExtension;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
import com.raytheon.viz.core.gl.AbstractGLMesh;
|
||||
import com.raytheon.viz.core.gl.GLCapabilities;
|
||||
import com.raytheon.viz.core.gl.IGLTarget;
|
||||
import com.raytheon.viz.core.gl.glsl.GLSLFactory;
|
||||
import com.raytheon.viz.core.gl.glsl.GLShaderProgram;
|
||||
import com.raytheon.viz.core.gl.images.AbstractGLImage;
|
||||
import com.sun.opengl.util.texture.TextureCoords;
|
||||
import com.vividsolutions.jts.geom.Coordinate;
|
||||
|
||||
/**
|
||||
* Abstract GL Imaging extension class
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Dec 15, 2011 mschenke Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author mschenke
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public abstract class AbstractGLImagingExtension extends
|
||||
GraphicsExtension<IGLTarget> implements IImagingExtension {
|
||||
|
||||
protected static final IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(AbstractGLImagingExtension.class);
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.viz.core.drawables.ext.IImagingExtension#drawRasters(
|
||||
* com.raytheon.uf.viz.core.drawables.PaintProperties,
|
||||
* com.raytheon.uf.viz.core.DrawableImage[])
|
||||
*/
|
||||
@Override
|
||||
public final boolean drawRasters(PaintProperties paintProps,
|
||||
DrawableImage... images) throws VizException {
|
||||
GL gl = target.getGl();
|
||||
boolean rval = true;
|
||||
gl.glGetError();
|
||||
|
||||
target.pushGLState();
|
||||
try {
|
||||
gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_FILL);
|
||||
rval = drawRastersInternal(paintProps, images);
|
||||
gl.glPolygonMode(GL.GL_BACK, GL.GL_LINE);
|
||||
gl.glDisable(GL.GL_BLEND);
|
||||
} finally {
|
||||
target.popGLState();
|
||||
}
|
||||
|
||||
target.handleError(gl.glGetError());
|
||||
return rval;
|
||||
}
|
||||
|
||||
protected boolean drawRastersInternal(PaintProperties paintProps,
|
||||
DrawableImage... images) throws VizException {
|
||||
GL gl = target.getGl();
|
||||
GLCapabilities capabilities = GLCapabilities.getInstance(gl);
|
||||
// Get shader program extension uses
|
||||
String shaderProgram = getShaderProgramName();
|
||||
|
||||
int repaints = 0;
|
||||
Set<String> errorMsgs = new HashSet<String>();
|
||||
|
||||
GLShaderProgram program = null;
|
||||
boolean attemptedToLoadShader = false;
|
||||
int lastTextureType = -1;
|
||||
|
||||
for (DrawableImage di : images) {
|
||||
AbstractGLImage glImage = (AbstractGLImage) di.getImage();
|
||||
PixelCoverage extent = di.getCoverage();
|
||||
|
||||
synchronized (glImage) {
|
||||
if (glImage.getStatus() == Status.STAGED) {
|
||||
glImage.target(target);
|
||||
}
|
||||
|
||||
if (glImage.getStatus() != Status.LOADED) {
|
||||
++repaints;
|
||||
continue;
|
||||
}
|
||||
|
||||
int textureType = glImage.getTextureStorageType();
|
||||
|
||||
if (lastTextureType != textureType) {
|
||||
if (lastTextureType != -1) {
|
||||
gl.glDisable(lastTextureType);
|
||||
}
|
||||
gl.glEnable(textureType);
|
||||
lastTextureType = textureType;
|
||||
}
|
||||
|
||||
Object dataObj = null;
|
||||
|
||||
if (glImage.bind(gl)) {
|
||||
// Notify extension image is about to be rendered
|
||||
dataObj = preImageRender(paintProps, glImage, extent);
|
||||
|
||||
if (dataObj == null) {
|
||||
// Skip image if preImageRender returned null
|
||||
continue;
|
||||
}
|
||||
|
||||
if (shaderProgram != null
|
||||
&& capabilities.cardSupportsShaders) {
|
||||
if (program == null && !attemptedToLoadShader) {
|
||||
attemptedToLoadShader = true;
|
||||
program = GLSLFactory.getInstance()
|
||||
.getShaderProgram(target, null,
|
||||
shaderProgram);
|
||||
if (program != null) {
|
||||
program.startShader();
|
||||
}
|
||||
|
||||
gl.glTexEnvi(GL.GL_TEXTURE_ENV,
|
||||
GL.GL_TEXTURE_ENV_MODE, GL.GL_ADD);
|
||||
gl.glEnable(GL.GL_BLEND);
|
||||
gl.glTexEnvi(GL.GL_TEXTURE_ENV,
|
||||
GL.GL_TEXTURE_ENV_MODE, GL.GL_BLEND);
|
||||
gl.glBlendFunc(GL.GL_SRC_ALPHA,
|
||||
GL.GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
gl.glColor4f(0.0f, 0.0f, 0.0f,
|
||||
paintProps.getAlpha());
|
||||
}
|
||||
|
||||
if (program != null) {
|
||||
loadShaderData(program, glImage, paintProps);
|
||||
}
|
||||
} else {
|
||||
gl.glEnable(GL.GL_BLEND);
|
||||
gl.glBlendFunc(GL.GL_SRC_ALPHA,
|
||||
GL.GL_ONE_MINUS_SRC_ALPHA);
|
||||
gl.glColor4f(1.0f, 1.0f, 1.0f, paintProps.getAlpha());
|
||||
}
|
||||
|
||||
if (drawCoverage(paintProps, extent,
|
||||
glImage.getTextureCoords(), 0) == PaintStatus.REPAINT) {
|
||||
// Coverage not ready, needs repaint
|
||||
++repaints;
|
||||
}
|
||||
|
||||
gl.glActiveTexture(GL.GL_TEXTURE0);
|
||||
gl.glBindTexture(textureType, 0);
|
||||
|
||||
// Notify extension image has been rendered
|
||||
postImageRender(paintProps, glImage, dataObj);
|
||||
|
||||
// Enable if you want to see mesh drawn
|
||||
if (false) {
|
||||
if (program != null) {
|
||||
program.endShader();
|
||||
}
|
||||
gl.glDisable(GL.GL_BLEND);
|
||||
gl.glColor3f(0.0f, 1.0f, 0.0f);
|
||||
gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_LINE);
|
||||
drawCoverage(paintProps, extent,
|
||||
glImage.getTextureCoords(), 0);
|
||||
gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_FILL);
|
||||
gl.glEnable(GL.GL_BLEND);
|
||||
if (program != null) {
|
||||
program.startShader();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
errorMsgs.add("Texture did not bind");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (lastTextureType != -1) {
|
||||
gl.glDisable(lastTextureType);
|
||||
}
|
||||
|
||||
if (program != null) {
|
||||
program.endShader();
|
||||
}
|
||||
|
||||
if (errorMsgs.size() > 0) {
|
||||
throw new VizException("Error rendering " + errorMsgs.size()
|
||||
+ " images: " + errorMsgs);
|
||||
}
|
||||
|
||||
boolean needsRepaint = repaints > 0;
|
||||
if (needsRepaint) {
|
||||
target.setNeedsRefresh(true);
|
||||
}
|
||||
|
||||
return needsRepaint == false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw an image coverage object
|
||||
*
|
||||
* @param paintProps
|
||||
* @param pc
|
||||
* @param coords
|
||||
* @param corrFactor
|
||||
* @throws VizException
|
||||
*/
|
||||
protected PaintStatus drawCoverage(PaintProperties paintProps,
|
||||
PixelCoverage pc, TextureCoords coords, float corrFactor)
|
||||
throws VizException {
|
||||
GL gl = target.getGl();
|
||||
if (pc == null) {
|
||||
return PaintStatus.ERROR;
|
||||
}
|
||||
// gl.glPolygonMode(GL.GL_BACK, GL.GL_FILL);
|
||||
// gl.glColor3d(1.0, 0.0, 0.0);
|
||||
// }
|
||||
|
||||
// boolean useNormals = false;
|
||||
IMesh mesh = pc.getMesh();
|
||||
|
||||
// if mesh exists, use it
|
||||
if (mesh != null) {
|
||||
if (mesh instanceof AbstractGLMesh) {
|
||||
return ((AbstractGLMesh) mesh).paint(target, paintProps);
|
||||
}
|
||||
} else if (coords != null) {
|
||||
FloatBuffer fb = ByteBuffer.allocateDirect(4 * 5 * 4)
|
||||
.order(ByteOrder.nativeOrder()).asFloatBuffer();
|
||||
|
||||
Coordinate ul = pc.getUl();
|
||||
Coordinate ur = pc.getUr();
|
||||
Coordinate lr = pc.getLr();
|
||||
Coordinate ll = pc.getLl();
|
||||
|
||||
fb.put(new float[] { coords.left() + corrFactor,
|
||||
coords.bottom() + corrFactor });
|
||||
fb.put(new float[] { (float) ll.x, (float) ll.y, (float) ll.z });
|
||||
|
||||
fb.put(new float[] { coords.right() - corrFactor,
|
||||
coords.bottom() + corrFactor });
|
||||
fb.put(new float[] { (float) lr.x, (float) lr.y, (float) lr.z });
|
||||
|
||||
fb.put(new float[] { coords.left() + corrFactor,
|
||||
coords.top() - corrFactor });
|
||||
fb.put(new float[] { (float) ul.x, (float) ul.y, (float) ul.z });
|
||||
|
||||
fb.put(new float[] { coords.right() - corrFactor,
|
||||
coords.top() - corrFactor });
|
||||
fb.put(new float[] { (float) ur.x, (float) ur.y, (float) ur.z });
|
||||
|
||||
// Clear error bit
|
||||
gl.glGetError();
|
||||
|
||||
gl.glEnableClientState(GL.GL_VERTEX_ARRAY);
|
||||
gl.glEnableClientState(GL.GL_TEXTURE_COORD_ARRAY);
|
||||
|
||||
gl.glInterleavedArrays(GL.GL_T2F_V3F, 0, fb.rewind());
|
||||
int error = gl.glGetError();
|
||||
if (error == GL.GL_NO_ERROR) {
|
||||
gl.glDrawArrays(GL.GL_TRIANGLE_STRIP, 0, 4);
|
||||
} else {
|
||||
target.handleError(error);
|
||||
}
|
||||
|
||||
gl.glDisableClientState(GL.GL_VERTEX_ARRAY);
|
||||
gl.glDisableClientState(GL.GL_TEXTURE_COORD_ARRAY);
|
||||
return PaintStatus.PAINTED;
|
||||
}
|
||||
return PaintStatus.ERROR;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup anything that is required pre image rendering. Object returned is a
|
||||
* state object and will be passed in to postImageRender. If the image
|
||||
* should not be drawn, return null
|
||||
*
|
||||
* @param paintProps
|
||||
* @param image
|
||||
* @return
|
||||
* @throws VizException
|
||||
*/
|
||||
public Object preImageRender(PaintProperties paintProps,
|
||||
AbstractGLImage image, PixelCoverage imageCoverage)
|
||||
throws VizException {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Post image rendering method, can be used to change any state required.
|
||||
* Return object from preImageRender is passed in as data argument
|
||||
*
|
||||
* @param paintProps
|
||||
* @param image
|
||||
* @param data
|
||||
* @throws VizException
|
||||
*/
|
||||
public void postImageRender(PaintProperties paintProps,
|
||||
AbstractGLImage image, Object data) throws VizException {
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.uf.viz.core.drawables.ext.GraphicsExtension#
|
||||
* getCompatibilityValue(com.raytheon.uf.viz.core.IGraphicsTarget)
|
||||
*/
|
||||
@Override
|
||||
public int getCompatibilityValue(IGLTarget target) {
|
||||
return Compatibilty.TARGET_COMPATIBLE;
|
||||
}
|
||||
|
||||
/**
|
||||
* The shader program name to execute for this extension
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public abstract String getShaderProgramName();
|
||||
|
||||
/**
|
||||
* Populate the shader program with data required for execution
|
||||
*
|
||||
* @param program
|
||||
* @param image
|
||||
* @param paintProps
|
||||
* @throws VizException
|
||||
*/
|
||||
public abstract void loadShaderData(GLShaderProgram program, IImage image,
|
||||
PaintProperties paintProps) throws VizException;
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package com.raytheon.viz.core.gl.internal.ext;
|
||||
package com.raytheon.viz.core.gl.ext;
|
||||
|
||||
import java.nio.Buffer;
|
||||
import java.nio.ByteBuffer;
|
||||
|
@ -12,13 +12,13 @@ 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.colormap.IColormappedImageExtension;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
import com.raytheon.viz.core.gl.IGLTarget;
|
||||
import com.raytheon.viz.core.gl.dataformat.AbstractGLColorMapDataFormat;
|
||||
import com.raytheon.viz.core.gl.dataformat.GLByteDataFormat;
|
||||
import com.raytheon.viz.core.gl.dataformat.IGLColorMapDataFormatProvider;
|
||||
import com.raytheon.viz.core.gl.images.AbstractGLImage;
|
||||
import com.raytheon.viz.core.gl.internal.ext.GLColormappedImageExtension;
|
||||
|
||||
public class GLOffscreenRenderingExtension extends GraphicsExtension<IGLTarget>
|
||||
implements IOffscreenRenderingExtension {
|
||||
|
@ -37,7 +37,7 @@ public class GLOffscreenRenderingExtension extends GraphicsExtension<IGLTarget>
|
|||
if (glImage.getStatus() == IImage.Status.UNLOADED
|
||||
|| glImage.getStatus() == IImage.Status.LOADING) {
|
||||
glImage.setStatus(IImage.Status.LOADING);
|
||||
glImage.stageTexture();
|
||||
glImage.stage();
|
||||
}
|
||||
|
||||
if (glImage.getStatus() == IImage.Status.STAGED) {
|
||||
|
@ -63,7 +63,7 @@ public class GLOffscreenRenderingExtension extends GraphicsExtension<IGLTarget>
|
|||
*/
|
||||
@Override
|
||||
public int getCompatibilityValue(IGLTarget target) {
|
||||
return Compatibilty.TARGET_COMPATIBLE.value;
|
||||
return Compatibilty.TARGET_COMPATIBLE;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -73,8 +73,9 @@ public class GLOffscreenRenderingExtension extends GraphicsExtension<IGLTarget>
|
|||
* constructOffscreenImage(java.lang.Class, java.awt.Rectangle)
|
||||
*/
|
||||
@Override
|
||||
public IImage constructOffscreenImage(Class<? extends Buffer> dataType,
|
||||
int[] dimensions) throws VizException {
|
||||
public AbstractGLImage constructOffscreenImage(
|
||||
Class<? extends Buffer> dataType, int[] dimensions)
|
||||
throws VizException {
|
||||
return constructOffscreenImage(dataType, dimensions, null);
|
||||
}
|
||||
|
||||
|
@ -85,9 +86,9 @@ public class GLOffscreenRenderingExtension extends GraphicsExtension<IGLTarget>
|
|||
* constructOffscreenImage(java.lang.Class, java.awt.Rectangle)
|
||||
*/
|
||||
@Override
|
||||
public IImage constructOffscreenImage(Class<? extends Buffer> dataType,
|
||||
final int[] dimensions, ColorMapParameters parameters)
|
||||
throws VizException {
|
||||
public AbstractGLImage constructOffscreenImage(
|
||||
Class<? extends Buffer> dataType, final int[] dimensions,
|
||||
ColorMapParameters parameters) throws VizException {
|
||||
int width = dimensions[0];
|
||||
int height = dimensions[1];
|
||||
// Need to add support for multiple buffer types
|
||||
|
@ -102,10 +103,10 @@ public class GLOffscreenRenderingExtension extends GraphicsExtension<IGLTarget>
|
|||
}
|
||||
|
||||
if (imageBuffer != null) {
|
||||
IImage image = null;
|
||||
AbstractGLImage image = null;
|
||||
final Buffer buffer = imageBuffer;
|
||||
IColormappedImageExtension cmapExt = target
|
||||
.getExtension(IColormappedImageExtension.class);
|
||||
GLColormappedImageExtension cmapExt = target
|
||||
.getExtension(GLColormappedImageExtension.class);
|
||||
if (supportsLuminance) {
|
||||
image = cmapExt.initializeRaster(
|
||||
new IColorMapDataRetrievalCallback() {
|
|
@ -17,16 +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.glsl;
|
||||
|
||||
import com.raytheon.uf.viz.core.drawables.ext.GraphicsExtension;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
import com.raytheon.viz.core.gl.GLCapabilities;
|
||||
import com.raytheon.viz.core.gl.IGLTarget;
|
||||
import com.raytheon.viz.radar.rsc.mosaic.MergeRasterRadarMosaicRenderer;
|
||||
import com.raytheon.viz.radar.rsc.mosaic.ext.IRadarMosaicRendererFactoryExtension;
|
||||
import com.raytheon.viz.core.gl.ext.AbstractGLImagingExtension;
|
||||
import com.raytheon.viz.core.gl.internal.GLTarget;
|
||||
|
||||
/**
|
||||
* Radar mosaic renderer factory for IGLTarget
|
||||
* Abstract GL Extension that requires shader to work properly
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
|
@ -34,7 +33,7 @@ import com.raytheon.viz.radar.rsc.mosaic.ext.IRadarMosaicRendererFactoryExtensio
|
|||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Nov 22, 2011 mschenke Initial creation
|
||||
* Dec 15, 2011 mschenke Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -42,28 +41,8 @@ import com.raytheon.viz.radar.rsc.mosaic.ext.IRadarMosaicRendererFactoryExtensio
|
|||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class GLRadarMosaicRendererFactory extends GraphicsExtension<IGLTarget>
|
||||
implements IRadarMosaicRendererFactoryExtension {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.viz.radar.rsc.mosaic.ext.IRadarMosaicRendererFactoryExtension
|
||||
* #createNewRenderer()
|
||||
*/
|
||||
@Override
|
||||
public IRadarMosaicRenderer createNewRenderer(MosaicType mosaicType)
|
||||
throws VizException {
|
||||
switch (mosaicType) {
|
||||
case MergeRaster:
|
||||
return new MergeRasterRadarMosaicRenderer();
|
||||
case MaxValue:
|
||||
return new RadarMosaicRenderer();
|
||||
}
|
||||
throw new VizException("Could not find mosaic renderer for type = "
|
||||
+ mosaicType);
|
||||
}
|
||||
public abstract class AbstractGLSLImagingExtension extends
|
||||
AbstractGLImagingExtension {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
|
@ -73,7 +52,12 @@ public class GLRadarMosaicRendererFactory extends GraphicsExtension<IGLTarget>
|
|||
*/
|
||||
@Override
|
||||
public int getCompatibilityValue(IGLTarget target) {
|
||||
return Compatibilty.TARGET_COMPATIBLE.value;
|
||||
if (GLCapabilities.getInstance(target.getGl()).cardSupportsShaders
|
||||
&& GLTarget.FORCE_NO_SHADER == false) {
|
||||
return Compatibilty.ENHANCED_TARGET_COMPATIBLE;
|
||||
} else {
|
||||
return Compatibilty.INCOMPATIBLE;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -22,15 +22,6 @@ package com.raytheon.viz.core.gl.glsl;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IConfigurationElement;
|
||||
import org.eclipse.core.runtime.IExtension;
|
||||
import org.eclipse.core.runtime.IExtensionPoint;
|
||||
import org.eclipse.core.runtime.IExtensionRegistry;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
|
||||
import com.raytheon.uf.viz.core.drawables.IImage;
|
||||
import com.raytheon.uf.viz.core.drawables.PaintProperties;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
import com.raytheon.viz.core.gl.IGLTarget;
|
||||
import com.raytheon.viz.core.gl.glsl.internal.GLProgramManager;
|
||||
|
@ -58,45 +49,7 @@ public class GLSLFactory {
|
|||
|
||||
private final Map<String, GLShaderProgram> shadersPrograms = new HashMap<String, GLShaderProgram>();
|
||||
|
||||
private static final Map<String, Object> shaderProgramMap = new HashMap<String, Object>();
|
||||
|
||||
static {
|
||||
// Construct the resource mapping from Eclipse plugins
|
||||
IExtensionRegistry registry = Platform.getExtensionRegistry();
|
||||
IExtensionPoint point = registry
|
||||
.getExtensionPoint("com.raytheon.viz.core.gl.shader");
|
||||
if (point != null) {
|
||||
IExtension[] extensions = point.getExtensions();
|
||||
|
||||
for (int i = 0; i < extensions.length; ++i) {
|
||||
IConfigurationElement[] config = extensions[i]
|
||||
.getConfigurationElements();
|
||||
|
||||
for (int j = 0; j < config.length; j++) {
|
||||
String name = config[j].getAttribute("programName");
|
||||
shaderProgramMap.put(name, config[j]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static void registerProgramLoader(String name, IShaderLoader loader) {
|
||||
shaderProgramMap.put(name, loader);
|
||||
}
|
||||
|
||||
private GLSLFactory() {
|
||||
// Register vetex.glsl as the default vertex program loader
|
||||
IShaderLoader loader = new AbstractShaderLoader() {
|
||||
@Override
|
||||
public void loadData(IGLTarget target, GLShaderProgram program,
|
||||
IImage image, PaintProperties paintProps)
|
||||
throws VizException {
|
||||
// does nothing
|
||||
}
|
||||
};
|
||||
loader.setName(DEFAULT_VERTEX);
|
||||
registerProgramLoader(loader.getName(), loader);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -133,68 +86,17 @@ public class GLSLFactory {
|
|||
String shaderName = new String(vertexName + "_" + fragName);
|
||||
GLShaderProgram shader = shadersPrograms.get(shaderName);
|
||||
if (shader == null
|
||||
|| GLProgramManager.getInstance().hasBeenModified(fragName,
|
||||
false)
|
||||
|| GLProgramManager.getInstance().hasBeenModified(vertexName,
|
||||
false)) {
|
||||
|| GLProgramManager.getInstance().hasBeenModified(fragName)
|
||||
|| GLProgramManager.getInstance().hasBeenModified(vertexName)) {
|
||||
if (shader != null) {
|
||||
shader.dispose();
|
||||
}
|
||||
// program object not cached, construct
|
||||
IShaderLoader vertexShader = null;
|
||||
if (vertexName != null) {
|
||||
vertexShader = getShaderLoaderInstance(shaderProgramMap
|
||||
.get(vertexName));
|
||||
}
|
||||
IShaderLoader fragmentShader = null;
|
||||
if (fragName != null) {
|
||||
fragmentShader = getShaderLoaderInstance(shaderProgramMap
|
||||
.get(fragName));
|
||||
fragmentShader.setName(fragName);
|
||||
}
|
||||
|
||||
shader = new GLShaderProgram(target, shaderName, vertexShader,
|
||||
fragmentShader);
|
||||
shader = new GLShaderProgram(target, shaderName, vertexName,
|
||||
fragName);
|
||||
shadersPrograms.put(shaderName, shader);
|
||||
}
|
||||
|
||||
if (shader != null) {
|
||||
Object fshader = shaderProgramMap.get(fragName);
|
||||
Object vshader = shaderProgramMap.get(vertexName);
|
||||
if (fshader != null && fshader instanceof IShaderLoader
|
||||
&& shader.getFragmentShader() != fshader) {
|
||||
shader.updateFragmentShader((IShaderLoader) fshader);
|
||||
}
|
||||
if (vshader != null && vshader instanceof IShaderLoader
|
||||
&& shader.getVertexShader() != vshader) {
|
||||
shader.updateVertexShader((IShaderLoader) vshader);
|
||||
}
|
||||
}
|
||||
|
||||
return shader;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct an instance of the shader loader class
|
||||
*
|
||||
* @param className
|
||||
* @return
|
||||
*/
|
||||
private IShaderLoader getShaderLoaderInstance(Object object)
|
||||
throws VizException {
|
||||
if (object instanceof IConfigurationElement) {
|
||||
IConfigurationElement configElement = (IConfigurationElement) object;
|
||||
try {
|
||||
return (IShaderLoader) configElement
|
||||
.createExecutableExtension("loaderClass");
|
||||
} catch (CoreException e) {
|
||||
throw new VizException(
|
||||
"Error constructing instance of loader class: "
|
||||
+ configElement.getAttribute("loaderClass"), e);
|
||||
}
|
||||
} else if (object instanceof IShaderLoader) {
|
||||
return (IShaderLoader) object;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,133 +0,0 @@
|
|||
/**
|
||||
* 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.glsl;
|
||||
|
||||
import javax.media.opengl.GL;
|
||||
|
||||
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.SingleColorImage;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
import com.raytheon.viz.core.gl.IGLTarget;
|
||||
import com.raytheon.viz.core.gl.images.AbstractGLImage;
|
||||
import com.raytheon.viz.core.gl.images.GLColormappedImage;
|
||||
|
||||
/**
|
||||
* Shader loader for rasters
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* May 25, 2010 mschenke Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author mschenke
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class GLSLRasterProgramLoader extends AbstractShaderLoader {
|
||||
|
||||
/*
|
||||
* (non-Javadoc
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.viz.core.gl.glsl.IShaderLoader#loadData(com.raytheon.viz
|
||||
* .core.gl.IGLTarget, com.raytheon.viz.core.gl.glsl.GLShaderProgram,
|
||||
* com.raytheon.uf.viz.core.drawables.IImage,
|
||||
* com.raytheon.uf.viz.core.drawables.PaintProperties)
|
||||
*/
|
||||
@Override
|
||||
public void loadData(IGLTarget target, GLShaderProgram program,
|
||||
IImage iimage, PaintProperties paintProps) throws VizException {
|
||||
// Check for single color image
|
||||
if (iimage instanceof SingleColorImage) {
|
||||
program.setUniform("doSingleColor", 1);
|
||||
program.setUniform("singleColor",
|
||||
((SingleColorImage) iimage).getColor());
|
||||
iimage = ((SingleColorImage) iimage).getWrappedImage();
|
||||
} else {
|
||||
program.setUniform("doSingleColor", 0);
|
||||
}
|
||||
|
||||
// Get image as AbstractGLImage
|
||||
AbstractGLImage image = null;
|
||||
if (iimage instanceof AbstractGLImage == false) {
|
||||
throw new VizException(
|
||||
"Cannot apply glsl raster shader to non gl image");
|
||||
}
|
||||
image = (AbstractGLImage) iimage;
|
||||
|
||||
program.setUniform("brightness", image.getBrightness());
|
||||
program.setUniform("contrast", image.getContrast());
|
||||
|
||||
int texId = image instanceof GLColormappedImage ? ((GLColormappedImage) image)
|
||||
.getTextureid() : -1;
|
||||
if (texId > -1) {
|
||||
program.setUniform("doColorMap", 1);
|
||||
} else {
|
||||
program.setUniform("doColorMap", 0);
|
||||
}
|
||||
|
||||
float naturalMin = 0;
|
||||
float naturalMax = 0;
|
||||
|
||||
float cmapMin = 0;
|
||||
float cmapMax = 0;
|
||||
|
||||
if (texId > 0) {
|
||||
GLColormappedImage colormappedImg = (GLColormappedImage) image;
|
||||
ColorMapParameters colorMapParameters = colormappedImg
|
||||
.getColorMapParameters();
|
||||
|
||||
naturalMin = colorMapParameters.getDataMin();
|
||||
naturalMax = colorMapParameters.getDataMax();
|
||||
cmapMin = colorMapParameters.getColorMapMin();
|
||||
cmapMax = colorMapParameters.getColorMapMax();
|
||||
|
||||
program.setUniform("colorMapSz", colorMapParameters.getColorMap()
|
||||
.getSize());
|
||||
int textureType = ((GLColormappedImage) image).getTextureType();
|
||||
program.setUniform("isFloat", textureType == GL.GL_FLOAT
|
||||
|| textureType == GL.GL_HALF_FLOAT_ARB ? 1 : 0);
|
||||
program.setUniform("logarithmic",
|
||||
colorMapParameters.isLogarithmic() ? 1 : 0);
|
||||
program.setUniform("logFactor", colorMapParameters.getLogFactor());
|
||||
program.setUniform("mirror", colorMapParameters.isMirror() ? 1 : 0);
|
||||
|
||||
program.setUniform("applyMask", colorMapParameters.isUseMask() ? 1
|
||||
: 0);
|
||||
}
|
||||
|
||||
program.setUniform("naturalMin", naturalMin);
|
||||
program.setUniform("naturalMax", naturalMax);
|
||||
program.setUniform("cmapMin", cmapMin);
|
||||
program.setUniform("cmapMax", cmapMax);
|
||||
|
||||
program.setUniform("alphaMask", 2);
|
||||
program.setUniform("colorMap", 1);
|
||||
program.setUniform("rawText", 0);
|
||||
|
||||
program.setUniform("alphaVal", paintProps.getAlpha());
|
||||
}
|
||||
}
|
|
@ -21,7 +21,9 @@ package com.raytheon.viz.core.gl.glsl;
|
|||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.IntBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.media.opengl.GL;
|
||||
|
@ -31,8 +33,6 @@ import org.eclipse.swt.graphics.RGB;
|
|||
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.drawables.IImage;
|
||||
import com.raytheon.uf.viz.core.drawables.PaintProperties;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
import com.raytheon.viz.core.gl.IGLTarget;
|
||||
import com.raytheon.viz.core.gl.glsl.internal.GLProgramManager;
|
||||
|
@ -68,14 +68,6 @@ public class GLShaderProgram {
|
|||
|
||||
private int glslContext = -1;
|
||||
|
||||
private int vertexShaderId = -1;
|
||||
|
||||
private int fragmentShaderId = -1;
|
||||
|
||||
private IShaderLoader vertexShader;
|
||||
|
||||
private IShaderLoader fragmentShader;
|
||||
|
||||
private State state = State.INVALID;
|
||||
|
||||
// Declaring and using variables in GLSL is similar to using variables in C.
|
||||
|
@ -111,28 +103,36 @@ public class GLShaderProgram {
|
|||
* @param fragmentShader
|
||||
* - can be null (but not if vertexShader == null)
|
||||
*/
|
||||
GLShaderProgram(IGLTarget target, String name, IShaderLoader vertexShader,
|
||||
IShaderLoader fragmentShader) throws VizException {
|
||||
GLShaderProgram(IGLTarget target, String name, String vertexShader,
|
||||
String fragmentShader) throws VizException {
|
||||
gl = target.getGl();
|
||||
glslContext = gl.glCreateProgramObjectARB();
|
||||
glslContext = gl.glCreateProgram();
|
||||
if (glslContext < 1) {
|
||||
throw new VizException(
|
||||
"Error creating glsl program, could not create program object");
|
||||
}
|
||||
|
||||
vertexShaderId = -1;
|
||||
fragmentShaderId = -1;
|
||||
|
||||
List<Integer> shaderIds = new ArrayList<Integer>(2);
|
||||
if (vertexShader != null) {
|
||||
this.setVertexShader(vertexShader);
|
||||
shaderIds.add(addShader(vertexShader, GL.GL_VERTEX_SHADER));
|
||||
}
|
||||
|
||||
if (fragmentShader != null) {
|
||||
this.setFragmentShader(fragmentShader);
|
||||
shaderIds.add(addShader(fragmentShader, GL.GL_FRAGMENT_SHADER));
|
||||
}
|
||||
gl.glLinkProgramARB(glslContext);
|
||||
|
||||
for (Integer shaderId : shaderIds) {
|
||||
gl.glAttachShader(glslContext, shaderId);
|
||||
}
|
||||
gl.glLinkProgram(glslContext);
|
||||
if (!checkForLinkingErrors(gl)) {
|
||||
state = State.INITIALIZED;
|
||||
for (Integer shaderId : shaderIds) {
|
||||
gl.glDeleteShader(shaderId);
|
||||
}
|
||||
} else {
|
||||
throw new VizException(
|
||||
"Error creating glsl shader program, could not link");
|
||||
}
|
||||
this.name = name;
|
||||
}
|
||||
|
@ -142,7 +142,7 @@ public class GLShaderProgram {
|
|||
*/
|
||||
public void startShader() {
|
||||
if (state == State.INITIALIZED) {
|
||||
gl.glUseProgramObjectARB(glslContext);
|
||||
gl.glUseProgram(glslContext);
|
||||
state = State.IN_USE;
|
||||
}
|
||||
loadedUniforms.clear();
|
||||
|
@ -153,7 +153,7 @@ public class GLShaderProgram {
|
|||
*/
|
||||
public void endShader() {
|
||||
if (state == State.IN_USE) {
|
||||
gl.glUseProgramObjectARB(0);
|
||||
gl.glUseProgram(0);
|
||||
state = State.INITIALIZED;
|
||||
}
|
||||
loadedUniforms.clear();
|
||||
|
@ -168,53 +168,18 @@ public class GLShaderProgram {
|
|||
}
|
||||
|
||||
/**
|
||||
* Load data into the shader program
|
||||
* Load, and compile the shader program
|
||||
*
|
||||
* @param target
|
||||
* @param image
|
||||
* @param paintProps
|
||||
* @throws VizException
|
||||
* @param shader
|
||||
*/
|
||||
public void loadData(IGLTarget target, IImage image,
|
||||
PaintProperties paintProps) throws VizException {
|
||||
if (state == State.IN_USE) {
|
||||
if (vertexShader != null) {
|
||||
vertexShader.loadData(target, this, image, paintProps);
|
||||
}
|
||||
if (fragmentShader != null) {
|
||||
fragmentShader.loadData(target, this, image, paintProps);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set, load, and compile the vertex shader program
|
||||
*
|
||||
* @param vshader
|
||||
*/
|
||||
private void setVertexShader(IShaderLoader vshader) throws VizException {
|
||||
this.vertexShader = vshader;
|
||||
vertexShaderId = loadShaderProgram(GLProgramManager.getInstance()
|
||||
.getProgramCode(vshader.getName()), GL.GL_VERTEX_SHADER);
|
||||
if (vertexShaderId < 0) {
|
||||
private int addShader(String shaderName, int shaderType)
|
||||
throws VizException {
|
||||
int shaderId = loadShaderProgram(shaderName, shaderType);
|
||||
if (shaderId < 1) {
|
||||
throw new VizException(
|
||||
"Error creating vertex shader, object not allocated");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set, load, and compile the fragment shader program
|
||||
*
|
||||
* @param fshader
|
||||
*/
|
||||
private void setFragmentShader(IShaderLoader fshader) throws VizException {
|
||||
this.fragmentShader = fshader;
|
||||
fragmentShaderId = loadShaderProgram(GLProgramManager.getInstance()
|
||||
.getProgramCode(fshader.getName()), GL.GL_FRAGMENT_SHADER);
|
||||
if (fragmentShaderId < 0) {
|
||||
throw new VizException(
|
||||
"Error creating fragment shader, object not allocated");
|
||||
"Error creating shader, object not allocated");
|
||||
}
|
||||
return shaderId;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -224,54 +189,20 @@ public class GLShaderProgram {
|
|||
* @param glShaderId
|
||||
* @return the shader program id
|
||||
*/
|
||||
private int loadShaderProgram(String program, int glShaderId) {
|
||||
int shaderId = gl.glCreateShaderObjectARB(glShaderId);
|
||||
private int loadShaderProgram(String programName, int glShaderId)
|
||||
throws VizException {
|
||||
String program = GLProgramManager.getInstance().getProgramCode(
|
||||
programName);
|
||||
int shaderId = gl.glCreateShader(glShaderId);
|
||||
if (shaderId >= 0) {
|
||||
gl.glShaderSourceARB(shaderId, 1, new String[] { program },
|
||||
gl.glShaderSource(shaderId, 1, new String[] { program },
|
||||
(int[]) null, 0);
|
||||
gl.glCompileShaderARB(shaderId);
|
||||
checkForCompileErrors(gl, shaderId, glShaderId);
|
||||
gl.glAttachObjectARB(glslContext, shaderId);
|
||||
gl.glCompileShader(shaderId);
|
||||
checkForCompileErrors(gl, shaderId, glShaderId, programName);
|
||||
}
|
||||
return shaderId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the fragment shader's loader object
|
||||
*
|
||||
* @param fshader
|
||||
*/
|
||||
public void updateFragmentShader(IShaderLoader fshader) {
|
||||
this.fragmentShader = fshader;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the vertex shader loader
|
||||
*
|
||||
* @param vshader
|
||||
*/
|
||||
public void updateVertexShader(IShaderLoader vshader) {
|
||||
this.vertexShader = vshader;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the shader loader
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
IShaderLoader getVertexShader() {
|
||||
return vertexShader;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the fragment loader
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
IShaderLoader getFragmentShader() {
|
||||
return fragmentShader;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the uniform variable for the shader program
|
||||
*
|
||||
|
@ -283,6 +214,9 @@ public class GLShaderProgram {
|
|||
gl.glUniform1f(getUniformLocation(uniformName), (Float) value);
|
||||
} else if (value instanceof Integer) {
|
||||
gl.glUniform1i(getUniformLocation(uniformName), (Integer) value);
|
||||
} else if (value instanceof Boolean) {
|
||||
gl.glUniform1i(getUniformLocation(uniformName),
|
||||
((Boolean) value) == true ? 1 : 0);
|
||||
} else if (value instanceof int[]) {
|
||||
gl.glUniform1iv(getUniformLocation(uniformName), MAX_MULTIGRIDS,
|
||||
(int[]) value, 0);
|
||||
|
@ -306,7 +240,7 @@ public class GLShaderProgram {
|
|||
* @param value
|
||||
*/
|
||||
public void setUniform(String key, Object value) {
|
||||
if (value != null) {
|
||||
if (value != null && state == State.IN_USE) {
|
||||
if (loadedUniforms.containsKey(key) == false
|
||||
|| value.equals(loadedUniforms.get(key)) == false) {
|
||||
// we haven't loaded this uniform yet or it is different
|
||||
|
@ -324,7 +258,7 @@ public class GLShaderProgram {
|
|||
* @return
|
||||
*/
|
||||
private int getUniformLocation(String name) {
|
||||
return (gl.glGetUniformLocationARB(glslContext, name));
|
||||
return (gl.glGetUniformLocation(glslContext, name));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -334,23 +268,22 @@ public class GLShaderProgram {
|
|||
* @param shader
|
||||
* @return
|
||||
*/
|
||||
private boolean checkForCompileErrors(GL gl, int shader, int glId) {
|
||||
private boolean checkForCompileErrors(GL gl, int shader, int glId,
|
||||
String name) {
|
||||
String type = "unknown";
|
||||
String fileName = "unkown";
|
||||
if (glId == GL.GL_FRAGMENT_SHADER) {
|
||||
type = "fragment";
|
||||
fileName = fragmentShader.getName();
|
||||
} else if (glId == GL.GL_VERTEX_SHADER) {
|
||||
type = "vertex";
|
||||
fileName = vertexShader.getName();
|
||||
}
|
||||
|
||||
boolean rval = false;
|
||||
int[] compilecheck = new int[1];
|
||||
gl.glGetObjectParameterivARB(shader, GL.GL_OBJECT_COMPILE_STATUS_ARB,
|
||||
compilecheck, 0);
|
||||
if (compilecheck[0] == GL.GL_FALSE) {
|
||||
System.err.println("A compilation error occured in the " + type
|
||||
+ " shader source file (" + fileName + ".glsl)");
|
||||
+ " shader source file (" + name + ")");
|
||||
|
||||
IntBuffer iVal = BufferUtil.newIntBuffer(1);
|
||||
gl.glGetObjectParameterivARB(shader,
|
||||
|
@ -367,8 +300,8 @@ public class GLShaderProgram {
|
|||
byte[] infoBytes = new byte[length - 1];
|
||||
infoLog.get(infoBytes);
|
||||
statusHandler.handle(Priority.CRITICAL, "Problem occured during "
|
||||
+ type + " shader initialization of file " + fileName
|
||||
+ ".glsl: " + new String(infoBytes));
|
||||
+ type + " shader initialization of " + name + ": "
|
||||
+ new String(infoBytes));
|
||||
System.err.println(new String(infoBytes));
|
||||
rval = true;
|
||||
}
|
||||
|
@ -417,18 +350,6 @@ public class GLShaderProgram {
|
|||
endShader();
|
||||
}
|
||||
if (state == State.INITIALIZED) {
|
||||
if (fragmentShader != null) {
|
||||
gl.glDetachShader(glslContext, fragmentShaderId);
|
||||
gl.glDeleteShader(fragmentShaderId);
|
||||
fragmentShaderId = -1;
|
||||
}
|
||||
|
||||
if (vertexShader != null) {
|
||||
gl.glDetachShader(glslContext, vertexShaderId);
|
||||
gl.glDeleteShader(vertexShaderId);
|
||||
vertexShaderId = -1;
|
||||
}
|
||||
|
||||
gl.glDeleteProgram(glslContext);
|
||||
glslContext = -1;
|
||||
}
|
||||
|
|
|
@ -23,11 +23,18 @@ import java.io.BufferedReader;
|
|||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import com.raytheon.uf.common.localization.IPathManager;
|
||||
import com.raytheon.uf.common.localization.LocalizationFile;
|
||||
import com.raytheon.uf.common.localization.PathManagerFactory;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
|
||||
/**
|
||||
|
@ -43,16 +50,44 @@ import com.raytheon.uf.viz.core.exception.VizException;
|
|||
*/
|
||||
public class GLProgramManager {
|
||||
|
||||
private static final String GLSL_FOLDER = "glsl";
|
||||
|
||||
private static final String GLSL_INCLUDE_FOLDER = GLSL_FOLDER
|
||||
+ IPathManager.SEPARATOR + "include";
|
||||
|
||||
private static final String GLSL_EXTENSION = ".glsl";
|
||||
|
||||
private static final String GLSL_HEADER_EXTENSION = ".glh";
|
||||
|
||||
private static final Pattern INCLUDE_PATTERN = Pattern
|
||||
.compile("^#include\\s*<([a-zA-z0-9_]*)>.*");
|
||||
|
||||
private static GLProgramManager instance;
|
||||
|
||||
private final Map<String, String> includeCode = new HashMap<String, String>();
|
||||
|
||||
private final Map<String, String> programsCode = new HashMap<String, String>();
|
||||
|
||||
private Map<String, File> fileMap = new HashMap<String, File>();
|
||||
private final Map<String, File> headerFiles = new HashMap<String, File>();
|
||||
|
||||
private Map<File, Long> modificationMap = new HashMap<File, Long>();
|
||||
private final Map<String, File> includeFiles = new HashMap<String, File>();
|
||||
|
||||
private final Map<String, File> programFiles = new HashMap<String, File>();
|
||||
|
||||
private final IPathManager pm;
|
||||
|
||||
private GLProgramManager() {
|
||||
pm = PathManagerFactory.getPathManager();
|
||||
|
||||
// Lookup available main programs (will be in glsl directory)
|
||||
LocalizationFile[] files = pm.listStaticFiles(GLSL_FOLDER,
|
||||
new String[] { GLSL_EXTENSION }, false, true);
|
||||
for (LocalizationFile file : files) {
|
||||
File fileObj = file.getFile();
|
||||
String name = fileObj.getName();
|
||||
programFiles.put(name, fileObj);
|
||||
programsCode.put(name, readProgramContents(fileObj));
|
||||
}
|
||||
}
|
||||
|
||||
public static GLProgramManager getInstance() {
|
||||
|
@ -63,67 +98,151 @@ public class GLProgramManager {
|
|||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get program code for the program name specified, these files live in glsl
|
||||
* directory in localization.
|
||||
*
|
||||
* @param aProgramName
|
||||
* @return
|
||||
* @throws VizException
|
||||
*/
|
||||
public String getProgramCode(String aProgramName) throws VizException {
|
||||
String program = programsCode.get(aProgramName);
|
||||
String searchPath = "glsl" + File.separator + aProgramName + ".glsl";
|
||||
if (hasBeenModified(searchPath, true) || program == null) {
|
||||
File file = fileMap.get(searchPath);
|
||||
modificationMap.put(file, file.lastModified());
|
||||
try {
|
||||
program = readFile(file);
|
||||
programsCode.put(aProgramName, program);
|
||||
} catch (IOException e) {
|
||||
throw new VizException("Error loading program code for: "
|
||||
+ aProgramName, e);
|
||||
}
|
||||
}
|
||||
|
||||
return program;
|
||||
String fileName = aProgramName + GLSL_EXTENSION;
|
||||
hasBeenModified(aProgramName);
|
||||
return programsCode.get(fileName);
|
||||
}
|
||||
|
||||
public boolean hasBeenModified(String searchPath, boolean path) {
|
||||
if (searchPath == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!path) {
|
||||
searchPath = "glsl" + File.separator + searchPath + ".glsl";
|
||||
}
|
||||
|
||||
File file = fileMap.get(searchPath);
|
||||
if (file == null) {
|
||||
IPathManager pm = PathManagerFactory.getPathManager();
|
||||
file = pm.getStaticFile(searchPath);
|
||||
fileMap.put(searchPath, file);
|
||||
}
|
||||
|
||||
if (file.exists() == false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Long lastMod = modificationMap.get(file);
|
||||
if (lastMod == null || file.lastModified() > lastMod) {
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* Checks if program has been modified
|
||||
*
|
||||
* @param programName
|
||||
* @return
|
||||
*/
|
||||
public boolean hasBeenModified(String programName) {
|
||||
// TODO: Check file modification time and reload contents. Should also
|
||||
// check modification times of files depends on and reload if any
|
||||
// changes
|
||||
return false;
|
||||
}
|
||||
|
||||
private String readFile(File aFile) throws IOException {
|
||||
/**
|
||||
* Reads program contends for file, will recursively load all #includes as
|
||||
* well
|
||||
*
|
||||
* @param aFile
|
||||
* @return
|
||||
*/
|
||||
private String readProgramContents(File aFile) {
|
||||
try {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
|
||||
List<String> toInclude = new ArrayList<String>();
|
||||
getIncludes(aFile, toInclude);
|
||||
|
||||
for (String include : toInclude) {
|
||||
// look for header file first
|
||||
File header = getIncludeFile(include, true);
|
||||
if (header != null) {
|
||||
String name = header.getName();
|
||||
String contents = includeCode.get(name);
|
||||
if (contents == null) {
|
||||
contents = readFileContents(header);
|
||||
includeCode.put(name, contents);
|
||||
}
|
||||
buffer.append(contents);
|
||||
}
|
||||
}
|
||||
|
||||
for (String include : toInclude) {
|
||||
// look for glsl files next
|
||||
File header = getIncludeFile(include, false);
|
||||
if (header != null) {
|
||||
String name = header.getName();
|
||||
String contents = includeCode.get(name);
|
||||
if (contents == null) {
|
||||
contents = readFileContents(header);
|
||||
includeCode.put(name, contents);
|
||||
}
|
||||
buffer.append(contents);
|
||||
}
|
||||
}
|
||||
|
||||
// Read program file contents
|
||||
buffer.append(readFileContents(aFile));
|
||||
return buffer.toString();
|
||||
} catch (IOException e) {
|
||||
UFStatus.getHandler().handle(Priority.PROBLEM,
|
||||
"Error reading glsl program code from file system", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read file contents off file system
|
||||
*
|
||||
* @param file
|
||||
* @param includeCode
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
private String readFileContents(File file) throws IOException {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
FileReader fr = new FileReader(aFile);
|
||||
BufferedReader reader = new BufferedReader(fr);
|
||||
String line = "";
|
||||
while (line != null) {
|
||||
buffer.append(line);
|
||||
buffer.append("\n");
|
||||
line = reader.readLine();
|
||||
BufferedReader reader = new BufferedReader(new FileReader(file));
|
||||
|
||||
String line = null;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
Matcher match = INCLUDE_PATTERN.matcher(line);
|
||||
if (match.find() == false) {
|
||||
buffer.append(line).append("\n");
|
||||
}
|
||||
}
|
||||
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
private void getIncludes(File file, List<String> toInclude)
|
||||
throws IOException {
|
||||
List<String> newIncludes = new ArrayList<String>();
|
||||
BufferedReader reader = new BufferedReader(new FileReader(file));
|
||||
String line = null;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
Matcher match = INCLUDE_PATTERN.matcher(line);
|
||||
if (match.find()) {
|
||||
String include = match.group(1);
|
||||
if (toInclude.contains(include) == false
|
||||
&& newIncludes.contains(include) == false) {
|
||||
newIncludes.add(include);
|
||||
toInclude.add(include);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
reader.close();
|
||||
fr.close();
|
||||
|
||||
String text = buffer.toString();
|
||||
return text;
|
||||
// Recursively get all include files
|
||||
for (String newInclude : newIncludes) {
|
||||
getIncludes(getIncludeFile(newInclude, false), toInclude);
|
||||
}
|
||||
}
|
||||
|
||||
private File getIncludeFile(String name, boolean header) {
|
||||
String fileName = name
|
||||
+ (header ? GLSL_HEADER_EXTENSION : GLSL_EXTENSION);
|
||||
|
||||
Map<String, File> toUse = null;
|
||||
if (header) {
|
||||
toUse = headerFiles;
|
||||
} else {
|
||||
toUse = includeFiles;
|
||||
}
|
||||
|
||||
File file = toUse.get(name);
|
||||
if (file == null) {
|
||||
file = pm.getStaticFile(GLSL_INCLUDE_FOLDER
|
||||
+ IPathManager.SEPARATOR + fileName);
|
||||
toUse.put(name, file);
|
||||
}
|
||||
|
||||
return file;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,10 +24,12 @@ import javax.media.opengl.glu.GLU;
|
|||
|
||||
import com.raytheon.uf.viz.core.IGraphicsTarget;
|
||||
import com.raytheon.uf.viz.core.drawables.IImage;
|
||||
import com.raytheon.uf.viz.core.drawables.ext.IImagingExtension;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
import com.raytheon.viz.core.gl.GLContextBridge;
|
||||
import com.raytheon.viz.core.gl.objects.GLFrameBufferObject;
|
||||
import com.raytheon.viz.core.gl.objects.GLRenderBuffer;
|
||||
import com.sun.opengl.util.texture.TextureCoords;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -69,7 +71,10 @@ public abstract class AbstractGLImage implements IImage {
|
|||
// Used for offscreen rendering
|
||||
private GLRenderBuffer rbuf;
|
||||
|
||||
protected AbstractGLImage() {
|
||||
private Class<? extends IImagingExtension> extensionClass;
|
||||
|
||||
protected AbstractGLImage(Class<? extends IImagingExtension> extensionClass) {
|
||||
this.extensionClass = extensionClass;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -214,14 +219,75 @@ public abstract class AbstractGLImage implements IImage {
|
|||
rbuf = null;
|
||||
}
|
||||
throw new VizException(errorMessage);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.uf.viz.core.drawables.IImage#getExtensionClass()
|
||||
*/
|
||||
@Override
|
||||
public Class<? extends IImagingExtension> getExtensionClass() {
|
||||
return extensionClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* Binds the texture. Default implementation takes the textureId and binds
|
||||
* to GL_TEXTURE0. Use bind(int) for more control
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean bind(GL gl) {
|
||||
return bind(gl, GL.GL_TEXTURE0);
|
||||
}
|
||||
|
||||
public boolean bind(GL gl, int texture) {
|
||||
int texId = getTextureid();
|
||||
if (texId > 0) {
|
||||
int textureType = getTextureStorageType();
|
||||
gl.glActiveTexture(texture);
|
||||
gl.glBindTexture(textureType, texId);
|
||||
|
||||
// Apply interpolation
|
||||
if (isInterpolated()) {
|
||||
gl.glTexParameteri(textureType, GL.GL_TEXTURE_MIN_FILTER,
|
||||
GL.GL_LINEAR);
|
||||
gl.glTexParameteri(textureType, GL.GL_TEXTURE_MAG_FILTER,
|
||||
GL.GL_LINEAR);
|
||||
} else {
|
||||
gl.glTexParameteri(textureType, GL.GL_TEXTURE_MIN_FILTER,
|
||||
GL.GL_NEAREST);
|
||||
gl.glTexParameteri(textureType, GL.GL_TEXTURE_MAG_FILTER,
|
||||
GL.GL_NEAREST);
|
||||
}
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.uf.viz.core.drawables.IImage#stage()
|
||||
*/
|
||||
@Override
|
||||
public final void stage() throws VizException {
|
||||
Status status = getStatus();
|
||||
if (status != Status.LOADED && status != Status.STAGED) {
|
||||
setStatus(Status.LOADING);
|
||||
if (stageTexture()) {
|
||||
setStatus(Status.STAGED);
|
||||
} else {
|
||||
setStatus(Status.FAILED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public abstract TextureCoords getTextureCoords();
|
||||
|
||||
public abstract int getTextureid();
|
||||
|
||||
public abstract int getTextureStorageType();
|
||||
|
||||
public abstract void stageTexture() throws VizException;
|
||||
public abstract boolean stageTexture() throws VizException;
|
||||
|
||||
public abstract void loadTexture(GL gl) throws VizException;
|
||||
|
||||
|
|
|
@ -200,7 +200,7 @@ public class GLCMTextureData implements IImageCacheable {
|
|||
return GL.GL_TEXTURE_2D;
|
||||
}
|
||||
|
||||
public double getValue(int x, int y, float dataMin, float dataMax) {
|
||||
public double getValue(int x, int y) {
|
||||
if (!isStaged() && isLoaded()) {
|
||||
GL gl = GLU.getCurrentGL();
|
||||
if (gl == null || data == null) {
|
||||
|
|
|
@ -24,8 +24,9 @@ import javax.media.opengl.GL;
|
|||
import com.raytheon.uf.viz.core.data.IColorMapDataRetrievalCallback;
|
||||
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;
|
||||
import com.raytheon.viz.core.gl.IGLTarget;
|
||||
import com.sun.opengl.util.texture.TextureCoords;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -51,24 +52,30 @@ public class GLColormappedImage extends AbstractGLImage implements
|
|||
protected GLCMTextureData data;
|
||||
|
||||
public GLColormappedImage(IColorMapDataRetrievalCallback dataCallback,
|
||||
ColorMapParameters params, IGLTarget target) {
|
||||
super();
|
||||
ColorMapParameters params,
|
||||
Class<? extends IImagingExtension> extensionClass) {
|
||||
super(extensionClass);
|
||||
this.data = GLCMTextureData.getGlTextureId(dataCallback);
|
||||
this.colorMapParameters = params;
|
||||
if (data.isLoaded()) {
|
||||
setStatus(Status.LOADED);
|
||||
} else if (data.isStaged()) {
|
||||
setStatus(Status.STAGED);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.core.gl.GLImage#stageTexture()
|
||||
* @see com.raytheon.viz.core.gl.images.AbstractGLImage#stageTexture()
|
||||
*/
|
||||
@Override
|
||||
public void stageTexture() throws VizException {
|
||||
if (data.stageTexture()) {
|
||||
setStatus(Status.STAGED);
|
||||
} else {
|
||||
setStatus(Status.FAILED);
|
||||
public boolean stageTexture() throws VizException {
|
||||
if (data == null) {
|
||||
throw new VizException(
|
||||
"Cannot stage texture, image has been disposed");
|
||||
}
|
||||
return data.stageTexture();
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -169,8 +176,10 @@ public class GLColormappedImage extends AbstractGLImage implements
|
|||
|
||||
@Override
|
||||
public double getValue(int x, int y) {
|
||||
double val = data.getValue(x, y, colorMapParameters.getDataMin(),
|
||||
colorMapParameters.getDataMax());
|
||||
double val = Double.NaN;
|
||||
if (data != null) {
|
||||
val = data.getValue(x, y);
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
|
@ -222,7 +231,11 @@ public class GLColormappedImage extends AbstractGLImage implements
|
|||
@Override
|
||||
public Status getStatus() {
|
||||
Status status = super.getStatus();
|
||||
if (data.isLoaded()) {
|
||||
if (data == null) {
|
||||
if (status != Status.UNLOADED) {
|
||||
setStatus(Status.UNLOADED);
|
||||
}
|
||||
} else if (data.isLoaded()) {
|
||||
if (status != Status.LOADED) {
|
||||
setStatus(Status.LOADED);
|
||||
}
|
||||
|
@ -242,4 +255,14 @@ public class GLColormappedImage extends AbstractGLImage implements
|
|||
return super.getStatus();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.core.gl.images.AbstractGLImage#getTextureCoords()
|
||||
*/
|
||||
@Override
|
||||
public TextureCoords getTextureCoords() {
|
||||
return new TextureCoords(0, 1, 1, 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue