From da8a5a42eaaf07adf5be57ea8c6e4b6652b52740 Mon Sep 17 00:00:00 2001 From: AWIPS User Date: Sun, 24 May 2015 21:01:45 -0500 Subject: [PATCH] Clear data menu command change to wipe loaded products. Also Tileset buffer added for Mcidas native projections. Former-commit-id: cf580ae837da6fcb30fcf0718137e8be4058a483 --- cave/com.raytheon.uf.viz.d2d.ui/plugin.xml | 8 ++- .../viz/d2d/ui/map/actions/ClearAction.java | 52 ++++++++++------- .../viz/satellite/rsc/SatResource.java | 1 + .../dataplugin/satellite/SatMapCoverage.java | 57 +++++++++---------- 4 files changed, 66 insertions(+), 52 deletions(-) diff --git a/cave/com.raytheon.uf.viz.d2d.ui/plugin.xml b/cave/com.raytheon.uf.viz.d2d.ui/plugin.xml index b815dbc73b..177d40a9dd 100644 --- a/cave/com.raytheon.uf.viz.d2d.ui/plugin.xml +++ b/cave/com.raytheon.uf.viz.d2d.ui/plugin.xml @@ -130,14 +130,14 @@ id="view" label="View" sibling_order="<menu label="label"> </menu>"> - + + label="Clear Data"> - + diff --git a/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/map/actions/ClearAction.java b/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/map/actions/ClearAction.java index 4341948c17..b7500d66c9 100644 --- a/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/map/actions/ClearAction.java +++ b/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/map/actions/ClearAction.java @@ -20,6 +20,10 @@ package com.raytheon.uf.viz.d2d.ui.map.actions; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + import org.eclipse.core.commands.AbstractHandler; import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionException; @@ -30,19 +34,20 @@ import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; import com.raytheon.uf.viz.core.IDisplayPane; import com.raytheon.uf.viz.core.IDisplayPaneContainer; +import com.raytheon.uf.viz.core.drawables.IDescriptor; +import com.raytheon.uf.viz.core.drawables.ResourcePair; import com.raytheon.uf.viz.core.exception.VizException; import com.raytheon.uf.viz.core.globals.VizGlobalsManager; import com.raytheon.uf.viz.core.maps.actions.NewMapEditor; import com.raytheon.uf.viz.core.maps.display.VizMapEditor; -import com.raytheon.uf.viz.core.status.StatusConstants; -import com.raytheon.uf.viz.d2d.ui.Activator; +import com.raytheon.uf.viz.core.rsc.AbstractVizResource; +import com.raytheon.uf.viz.core.rsc.ResourceList; import com.raytheon.viz.ui.EditorUtil; -import com.raytheon.viz.ui.HistoryList; import com.raytheon.viz.ui.editor.AbstractEditor; -import com.raytheon.viz.ui.editor.IMultiPaneEditor; /** - * Action to reset a map to its initial state + * Action to reset a map to its initial state. What this *should* + * do is remove all non-map resources.... * *
  * 
@@ -56,6 +61,7 @@ import com.raytheon.viz.ui.editor.IMultiPaneEditor;
  *  Jul 10, 2008             chammack    Properly clear the resource list on the old 
  *                                       descriptor to facilitate better cleanup
  * Oct 21, 2008   #1450      randerso    Fixed to support multipane editors
+ * May 24, 2015              mjames@ucar Moved UnloadAllProductsAction here to replace map reload
  * 
  * 
* @@ -68,22 +74,30 @@ public class ClearAction extends AbstractHandler { @Override public Object execute(ExecutionEvent arg0) throws ExecutionException { - IEditorPart part = EditorUtil.getActiveEditor(); - if (part == null) { - new NewMapEditor().execute(null); - return null; - } - try { - if (part instanceof IDisplayPaneContainer) { - HistoryList.getInstance().refreshLatestBundle(); - clear(part); - HistoryList.getInstance().addBundle(); - } else { - clear(part); + IDisplayPaneContainer cont = EditorUtil.getActiveVizContainer(); + + IDisplayPane[] panes = cont.getDisplayPanes(); + + for (IDisplayPane displayPane : panes) { + IDescriptor desc = displayPane.getDescriptor(); + ResourceList rl = desc.getResourceList(); + + Iterator iterator = rl.iterator(); + List> rscsToRemove = new ArrayList>(); + + while (iterator.hasNext()) { + ResourcePair rp = iterator.next(); + if (!rp.getProperties().isMapLayer() + && !rp.getProperties().isSystemResource()) { + rscsToRemove.add(rp.getResource()); + } + } + + for (AbstractVizResource rsc : rscsToRemove) { + rl.removeRsc(rsc); } - } catch (VizException e) { - throw new ExecutionException("Error during clear", e); } + cont.refresh(); return null; } diff --git a/cave/com.raytheon.viz.satellite/src/com/raytheon/viz/satellite/rsc/SatResource.java b/cave/com.raytheon.viz.satellite/src/com/raytheon/viz/satellite/rsc/SatResource.java index dc910d6452..e7cce92de0 100644 --- a/cave/com.raytheon.viz.satellite/src/com/raytheon/viz/satellite/rsc/SatResource.java +++ b/cave/com.raytheon.viz.satellite/src/com/raytheon/viz/satellite/rsc/SatResource.java @@ -243,6 +243,7 @@ public class SatResource extends } if (tileSet == null) { tileSet = new SatTileSetRenderable(SatResource.this, record); + // this is where getGridGeometry is called from D2D SAT tileSet.project(descriptor.getGridGeometry()); tileMap.put(record.getCoverage(), tileSet); } diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.satellite/src/com/raytheon/uf/common/dataplugin/satellite/SatMapCoverage.java b/edexOsgi/com.raytheon.uf.common.dataplugin.satellite/src/com/raytheon/uf/common/dataplugin/satellite/SatMapCoverage.java index a4ae4cf038..4d750e4330 100644 --- a/edexOsgi/com.raytheon.uf.common.dataplugin.satellite/src/com/raytheon/uf/common/dataplugin/satellite/SatMapCoverage.java +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.satellite/src/com/raytheon/uf/common/dataplugin/satellite/SatMapCoverage.java @@ -21,6 +21,7 @@ package com.raytheon.uf.common.dataplugin.satellite; import gov.noaa.nws.ncep.common.dataplugin.mcidas.McidasMapCoverage; +import gov.noaa.nws.ncep.common.dataplugin.mcidas.McidasRecord; import gov.noaa.nws.ncep.common.dataplugin.mcidas.McidasSpatialFactory; import gov.noaa.nws.ncep.common.tools.IDecoderConstantsN; @@ -41,9 +42,11 @@ import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import org.apache.commons.lang.builder.HashCodeBuilder; +import org.geotools.coverage.grid.GeneralGridEnvelope; import org.geotools.coverage.grid.GridEnvelope2D; import org.geotools.coverage.grid.GridGeometry2D; import org.geotools.geometry.Envelope2D; +import org.geotools.geometry.GeneralEnvelope; import org.geotools.referencing.crs.DefaultGeographicCRS; import org.hibernate.annotations.Type; import org.opengis.coverage.grid.GridEnvelope; @@ -86,6 +89,7 @@ import com.vividsolutions.jts.geom.Polygon; * Nov 05, 2014 3788 bsteffen Make gid a sequence instead of a hash. * May 19, 2015 mjames@ucar Added decoding of GVAR native projection products, * increased crsWKT to 5120 for GVAR the_geom + * May 21, 2015 mjames@ucar Added display capability for GVAR projection products * */ @Entity @@ -495,37 +499,30 @@ public class SatMapCoverage extends PersistableDataObject implements @Override public GridGeometry2D getGridGeometry() { - /* - GridEnvelope gridRange; - Envelope crsRange; - - gridRange = new GridEnvelope2D(0, 0, getNx(), getNy()); - crsRange = new Envelope2D(getCrs(), new Rectangle2D.Double( - minX, minY, getNx() * getDx(), getNy() * getDy())); - */ - GridEnvelope gridRange; - Envelope crsRange; - if (projection == PROJ_GVAR) { // for native projection - minX = getUpperLeftElement(); - int maxX = getUpperLeftElement() + (getNx() * getElementRes()); - minY = getUpperLeftLine() + (getNy() * getLineRes()); - minY = -minY; - int maxY = -1 * getUpperLeftLine(); - - gridRange = new GridEnvelope2D(0, 0, nx, ny); - Rectangle2D rect = new Rectangle2D.Double(minX, - minY, maxX, maxY); - crsRange = new Envelope2D(getCrs(), rect ); - }else { - int nx = getNx(); - int ny = getNy(); - - gridRange = new GridEnvelope2D(0, 0, nx, ny); - crsRange = new Envelope2D(getCrs(), new Rectangle2D.Double(minX, - minY, nx * getDx(), ny * getDy())); + /* + * Native projections + */ + if (projection == PROJ_GVAR) { + GridEnvelope gridRange = new GeneralGridEnvelope(new int[] { + 0, 0 }, new int[] { getNx(),getNy() }, false); + GeneralEnvelope crsRange = new GeneralEnvelope(2); + crsRange.setCoordinateReferenceSystem( getCrs() ); + + int minX = getUpperLeftElement(); + int maxX = getUpperLeftElement() + ( getNx() * getElementRes() ); + int minY = getUpperLeftLine() + ( getNy() * getLineRes() ); + minY = -minY; + int maxY = -1 * getUpperLeftLine(); + crsRange.setRange(0, minX, maxX); + crsRange.setRange(1, minY, maxY); + return new GridGeometry2D(gridRange, crsRange); + } else { + GridEnvelope gridRange = new GridEnvelope2D(0, 0, getNx(), getNy()); + Envelope crsRange = new Envelope2D(getCrs(), new Rectangle2D.Double( + minX, minY, getNx() * getDx(), getNy() * getDy())); + return new GridGeometry2D(gridRange, crsRange); } - GridGeometry2D tmpGrid = new GridGeometry2D(gridRange, crsRange); - return new GridGeometry2D(gridRange, crsRange); + } @Override