Commit 5ec93743 authored by Robert Smith's avatar Robert Smith
Browse files

VisItPlotViewer can now reuse Resources



The VisItPlotViewer had previously always been using the VizResource for
the last plot added, preventing it from redrawing old plots. It now
keeps track of all used resources and will switch to the resource
matching the selected VizEntry before trying to draw the plot.
Signed-off-by: Robert Smith's avatarRobert Smith <SmithRW@ornl.gov>
parent 63dbdd6e
...@@ -67,8 +67,8 @@ import gov.lbnl.visit.swt.widgets.TimeSliderWidget; ...@@ -67,8 +67,8 @@ import gov.lbnl.visit.swt.widgets.TimeSliderWidget;
* *
* @author Jay Jay Billings, Taylor Patterson, Jordan H. Deyton * @author Jay Jay Billings, Taylor Patterson, Jordan H. Deyton
*/ */
public class VisitPlotViewer extends ViewPart implements public class VisitPlotViewer extends ViewPart
IDeletePlotActionViewPart, IVizUpdateableListener, implements IDeletePlotActionViewPart, IVizUpdateableListener,
ISelectionChangedListener, IDoubleClickListener { ISelectionChangedListener, IDoubleClickListener {
/** /**
...@@ -114,6 +114,11 @@ public class VisitPlotViewer extends ViewPart implements ...@@ -114,6 +114,11 @@ public class VisitPlotViewer extends ViewPart implements
*/ */
private VizResourceComponent resourceComponent; private VizResourceComponent resourceComponent;
/**
* A list of all the resources ever used by the viewer.
*/
private Map<String, IVizResource> resourceMap;
/** /**
* The TreeViewer contained in this ViewPart used for managing resources in * The TreeViewer contained in this ViewPart used for managing resources in
* the view. * the view.
...@@ -172,14 +177,15 @@ public class VisitPlotViewer extends ViewPart implements ...@@ -172,14 +177,15 @@ public class VisitPlotViewer extends ViewPart implements
// Initialize the lists for the selected plots. // Initialize the lists for the selected plots.
plotEntries = new ArrayList<VizEntry>(); plotEntries = new ArrayList<VizEntry>();
entryResources = new ArrayList<IVizResource>(); entryResources = new ArrayList<IVizResource>();
resourceMap = new HashMap<String, IVizResource>();
// Initialize the Map of variable types to plot types // Initialize the Map of variable types to plot types
varTypePlotTypeMap = new HashMap<String, String[]>(); varTypePlotTypeMap = new HashMap<String, String[]>();
varTypePlotTypeMap.put("Materials", new String[] { "Boundary", varTypePlotTypeMap.put("Materials",
"FilledBoundary" }); new String[] { "Boundary", "FilledBoundary" });
varTypePlotTypeMap.put("Meshes", new String[] { "Mesh" }); varTypePlotTypeMap.put("Meshes", new String[] { "Mesh" });
varTypePlotTypeMap.put("Scalars", new String[] { "Pseudocolor", varTypePlotTypeMap.put("Scalars",
"Contour", "Volume" }); new String[] { "Pseudocolor", "Contour", "Volume" });
varTypePlotTypeMap.put("Vectors", new String[] { "Vector" }); varTypePlotTypeMap.put("Vectors", new String[] { "Vector" });
return; return;
...@@ -212,8 +218,8 @@ public class VisitPlotViewer extends ViewPart implements ...@@ -212,8 +218,8 @@ public class VisitPlotViewer extends ViewPart implements
// Add the Combo for selecting from the available plot types // Add the Combo for selecting from the available plot types
plotTypeCombo = new Combo(partComposite, SWT.READ_ONLY); plotTypeCombo = new Combo(partComposite, SWT.READ_ONLY);
plotTypeCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, plotTypeCombo
false)); .setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
// Add the selection listener // Add the selection listener
plotTypeCombo.addSelectionListener(new SelectionAdapter() { plotTypeCombo.addSelectionListener(new SelectionAdapter() {
@Override @Override
...@@ -231,11 +237,11 @@ public class VisitPlotViewer extends ViewPart implements ...@@ -231,11 +237,11 @@ public class VisitPlotViewer extends ViewPart implements
.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); .setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
// Initialize the TreeViewer. // Initialize the TreeViewer.
plotTreeViewer = new TreeViewer(partComposite, SWT.H_SCROLL plotTreeViewer = new TreeViewer(partComposite,
| SWT.V_SCROLL | SWT.BORDER | SWT.MULTI); SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.MULTI);
// The TreeViewer should grab all horizontal AND vertical space. // The TreeViewer should grab all horizontal AND vertical space.
plotTreeViewer.getControl().setLayoutData( plotTreeViewer.getControl()
new GridData(SWT.FILL, SWT.FILL, true, true)); .setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
plotTreeViewer.addSelectionChangedListener(this); plotTreeViewer.addSelectionChangedListener(this);
plotTreeViewer.addDoubleClickListener(this); plotTreeViewer.addDoubleClickListener(this);
...@@ -299,8 +305,7 @@ public class VisitPlotViewer extends ViewPart implements ...@@ -299,8 +305,7 @@ public class VisitPlotViewer extends ViewPart implements
@Override @Override
public void update(IVizUpdateable component) { public void update(IVizUpdateable component) {
logger.info("VisitPlotViewer Message: " logger.info("VisitPlotViewer Message: " + "Incoming resource update.");
+ "Incoming resource update.");
// Sync with the display // Sync with the display
PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
@Override @Override
...@@ -598,6 +603,12 @@ public class VisitPlotViewer extends ViewPart implements ...@@ -598,6 +603,12 @@ public class VisitPlotViewer extends ViewPart implements
} }
} }
// Set the viewer to the correct resource
IVizResource parent = resourceMap.get(entry.getDescription());
if (parent != null) {
setResource(parent);
}
if (index > -1) { if (index > -1) {
// Get the ICEResource associated with this entry. // Get the ICEResource associated with this entry.
...@@ -612,9 +623,33 @@ public class VisitPlotViewer extends ViewPart implements ...@@ -612,9 +623,33 @@ public class VisitPlotViewer extends ViewPart implements
widget.activate(); widget.activate();
widget.getViewerMethods().deleteActivePlots(); widget.getViewerMethods().deleteActivePlots();
// TODO - Add some sort of check to use the correct path here.
String dbPath = "";
// Use this for local
if (!resource.isRemote()) {
dbPath = resource.getPath().getPath();
}
// The remote file system only needs the name.
else {
dbPath = resource.getName();
}
// If this is a Windows system, reformat the path to Windows
// style by changing the file separators.
if (System.getProperty("os.name").toLowerCase()
.contains("windows")) {
if (dbPath.startsWith("/")) {
dbPath = dbPath.substring(1);
dbPath = dbPath.replace("/",
System.getProperty("file.separator"));
}
}
widget.getViewerMethods().openDatabase(dbPath);
// Add the plot to the widget. // Add the plot to the widget.
String plotType = (plotTypeCombo.getText() != "") ? plotTypeCombo String plotType = (plotTypeCombo.getText() != "")
.getText() ? plotTypeCombo.getText()
: varTypePlotTypeMap.get(entry.getParent())[0]; : varTypePlotTypeMap.get(entry.getParent())[0];
widget.getViewerMethods().addPlot(plotType, entry.getName()); widget.getViewerMethods().addPlot(plotType, entry.getName());
...@@ -721,6 +756,15 @@ public class VisitPlotViewer extends ViewPart implements ...@@ -721,6 +756,15 @@ public class VisitPlotViewer extends ViewPart implements
logger.info("VisitPlotViewer message: The selected file from " logger.info("VisitPlotViewer message: The selected file from "
+ "the VizFileViewer is \"" + resource.getName() + "\"."); + "the VizFileViewer is \"" + resource.getName() + "\".");
// Add the resource to the map if it is not null and isn't already
// present
if (inResource != null) {
String file = inResource.getDescription();
if (!resourceMap.containsKey(inResource.getDescription())) {
resourceMap.put(file, inResource);
}
}
// Enable the AddPlotAction. // Enable the AddPlotAction.
addPlotAction.setEnabled(true); addPlotAction.setEnabled(true);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment