Commit 621d2ebb authored by Robert Smith's avatar Robert Smith
Browse files

ICE now uses geometry service



ICE has been updated to make use of the GeometryVizService to create a
GeometryVizCanvas when creating a geometry editor. Also, the
viz.service.jme3 bundle has been merged into the viz.service.geometry
bundle, as neither the mesh nor reactor editor will need to share any of
thsoe classes with the geometry editor.
Signed-off-by: Robert Smith's avatarRobert Smith <SmithRW@ornl.gov>
parent e7e20d60
......@@ -360,7 +360,6 @@
<module>../tests/org.eclipse.ice.viz.service.test</module>
<module>../src/org.eclipse.ice.viz.service.geometry</module>
<module>../tests/org.eclipse.ice.viz.service.geometry.test</module>
<module>../src/org.eclipse.ice.viz.service.jme3</module>
<module>../src/org.eclipse.ice.viz.service.visit</module>
<module>../tests/org.eclipse.ice.viz.service.visit.test</module>
<module>../src/org.eclipse.ice.xolotl</module>
......
......@@ -21,7 +21,7 @@ Import-Package: com.sun.jersey.api.client,
org.eclipse.ice.iclient,
org.eclipse.ice.iclient.uiwidgets,
org.eclipse.ice.item,
org.eclipse.ice.viz.service.jme3.geometry,
org.eclipse.ice.viz.service.geometry.widgets,
org.eclipse.jface.action,
org.eclipse.jface.databinding.swt,
org.eclipse.jface.dialogs,
......
......@@ -4,8 +4,7 @@ Bundle-Name: Eclipse Widgets RCP Bundle
Bundle-SymbolicName: org.eclipse.ice.client.widgets.rcp;singleton:=true
Bundle-Version: 2.0.0
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Export-Package: org.eclipse.ice.client.widgets.geometry,
org.eclipse.ice.client.widgets.jme,
Export-Package: org.eclipse.ice.client.widgets.jme,
org.eclipse.ice.client.widgets.mesh,
org.eclipse.ice.client.widgets.mesh.properties,
org.eclipse.ice.client.widgets.reactoreditor.plant
......@@ -117,7 +116,7 @@ Import-Package: com.jme3.animation,
org.eclipse.ice.datastructures.ICEObject,
org.eclipse.ice.datastructures.form.geometry,
org.eclipse.ice.reactor.plant,
org.eclipse.ice.viz.service.jme3.shapes,
org.eclipse.ice.viz.service.geometry.shapes,
org.eclipse.jface.databinding.swt,
org.eclipse.ui.views.properties.tabbed,
org.osgi.framework,
......
/*******************************************************************************
* Copyright (c) 2012, 2014 UT-Battelle, LLC.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Initial API and implementation and/or initial documentation - Jay Jay Billings,
* Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson,
* Claire Saunders, Matthew Wang, Anna Wojtowicz
*******************************************************************************/
package org.eclipse.ice.client.widgets.geometry;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.ice.client.widgets.geometry.ShapeTreeContentProvider.BlankShape;
import org.eclipse.ice.datastructures.form.GeometryComponent;
import org.eclipse.ice.datastructures.form.geometry.ICEShape;
import org.eclipse.ice.viz.service.jme3.shapes.OperatorType;
import org.eclipse.ice.viz.service.jme3.shapes.ShapeType;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.ITreeSelection;
import org.eclipse.jface.viewers.TreePath;
import org.eclipse.ui.internal.util.BundleUtility;
import org.osgi.framework.Bundle;
import org.osgi.framework.FrameworkUtil;
/**
* <p>
* Action for adding a specific shape to the ShapeTreeView
* </p>
*
* @author Andrew P. Belt
*/
public class ActionAddShape extends Action {
/**
* <p>
* The current ShapeTreeViewer associated with the AddShape action
* </p>
*
*/
private ShapeTreeView view;
/**
* <p>
* The ShapeType used to create new PrimitiveShapes when the AddShape action
* is triggered
* </p>
* <p>
* If the value is null, the Operator is used to create ComplexShapes.
* </p>
*
*/
private ShapeType shapeType;
/**
* <p>
* The OperatorType used to create new ComplexShapes when the AddShape
* action is triggered
* </p>
* <p>
* If the value is null, the ShapeType is used to create PrimitiveShapes.
* </p>
*
*/
private OperatorType operatorType;
/**
* <p>
* The current used default shape number appended to the name of every newly
* created shape
* </p>
* <p>
* Starting from zero, this number increments every time a new shape is
* added to the tree.
* </p>
*
*/
private int currentShapeId;
/**
* The image to display as the action's icon
*/
private ImageDescriptor imageDescriptor;
/**
* <p>
* Constructor for creating new PrimitiveShapes with a given ShapeType
* </p>
*
* @param view
* <p>
* The current ShapeTreeViewer
* </p>
* @param shapeType
* <p>
* The type of PrimitiveShape to create with the action is
* triggered
* </p>
*/
public ActionAddShape(ShapeTreeView view, ShapeType shapeType) {
this.view = view;
this.shapeType = shapeType;
operatorType = null;
currentShapeId = 0;
// Set the Action's name to "Add {ShapeType}"
setText("Add " + shapeType.toString());
// Create a map which stores the filenames of the icons, relative
// to the icons/ directory
Map<ShapeType, String> shapeIcons = new HashMap<ShapeType, String>();
shapeIcons.put(ShapeType.Sphere, "sphere.gif");
shapeIcons.put(ShapeType.Cube, "cube.gif");
shapeIcons.put(ShapeType.Cylinder, "cylinder.gif");
shapeIcons.put(ShapeType.Tube, "tube.gif");
// Create the image descriptor from the file path
Bundle bundle = FrameworkUtil.getBundle(getClass());
URL imagePath = BundleUtility.find(bundle,
"icons/" + shapeIcons.get(shapeType));
imageDescriptor = ImageDescriptor.createFromURL(imagePath);
return;
}
/**
* <p>
* Constructor for creating new ComplexShapes with a given OperatorType
* </p>
*
* @param view
* <p>
* The current ShapeTreeViewer
* </p>
* @param operatorType
* <p>
* The type of ComplexShape to create with the action is
* triggered
* </p>
*/
public ActionAddShape(ShapeTreeView view, OperatorType operatorType) {
this.view = view;
this.shapeType = null;
this.operatorType = operatorType;
currentShapeId = 0;
// Set the Action's name to "Add {ShapeType}"
this.setText("Add " + operatorType.toString());
// Create a map which stores the filenames of the icons, relative
// to the icons/ directory
Map<OperatorType, String> operatorIcons = new HashMap<OperatorType, String>();
operatorIcons.put(OperatorType.Union, "union.gif");
operatorIcons.put(OperatorType.Intersection, "intersection.gif");
operatorIcons.put(OperatorType.Complement, "complement.gif");
// Create the image descriptor from the file path
Bundle bundle = FrameworkUtil.getBundle(getClass());
URL imagePath = BundleUtility.find(bundle,
"icons/" + operatorIcons.get(operatorType));
imageDescriptor = ImageDescriptor.createFromURL(imagePath);
}
/**
* <p>
* Runs this action
* </p>
* <p>
* Each action implementation must define the steps needed to carry out this
* action.
* </p>
*
*/
@Override
public void run() {
// Get the selection
ITreeSelection selection = (ITreeSelection) view.treeViewer
.getSelection();
TreePath[] paths = selection.getPaths();
// Fail silently if multiple items are selected
if (paths.length > 1) {
return;
}
// Get the GeometryComponent from the ShapeTreeView's TreeViewer
GeometryComponent geometry = (GeometryComponent) view.treeViewer
.getInput();
if (geometry == null) {
return;
}
// Get the parent shape, regardless of whether an IShape or BlankShape
// is selected
ICEShape parentComplexShape = null;
if (paths.length == 1) {
// Get the selected object from the single selection
Object selectedObject = paths[0].getLastSegment();
if (selectedObject instanceof ICEShape) {
// Get the selected shape's parent
ICEShape selectedShape = (ICEShape) selectedObject;
parentComplexShape = selectedShape.getShapeParent();
} else if (selectedObject instanceof BlankShape) {
// Get the selected blank shape's parent
BlankShape selectedBlank = (BlankShape) selectedObject;
parentComplexShape = selectedBlank.getShapeParent();
}
}
// Add a child shape to either the GeometryComponent or the parent
// ComplexShape
ICEShape childShape = createShape();
if (parentComplexShape == null) {
// Add a new shape to the root GeometryComponent
synchronized (geometry) {
geometry.getGeometry().addShape(childShape);
}
view.treeViewer.refresh();
}
else {
// Create a new shape and add it to the parentComplexShape
synchronized (geometry) {
parentComplexShape.addShape(childShape);
}
view.treeViewer.refresh(parentComplexShape);
}
// Expand the child in the tree if a ComplexShape was added
if (childShape != null && operatorType != null) {
view.treeViewer.expandToLevel(childShape, 1);
}
}
/**
* Returns the appropriate image descriptor for the action's icon
*
* @return The ImageDescriptor generated from the appropriate ShapeType or
* OperatorType
* @see org.eclipse.jface.action.Action#getImageDescriptor()
*/
@Override
public ImageDescriptor getImageDescriptor() {
return imageDescriptor;
}
/**
* <p>
* Creates a shape corresponding to this Action's ShapeType or OperatorType
* </p>
*
* @return <p>
* The newly created shape
* </p>
*/
public ICEShape createShape() {
ICEShape shape = null;
// Determine which type of shape should be created
if (shapeType != null && operatorType == null) {
// Instantiate a PrimitiveShape and set its name and ID
shape = new ICEShape(shapeType);
currentShapeId++;
shape.setName(shapeType.toString());
shape.setId(currentShapeId);
}
else if (operatorType != null && shapeType == null) {
// Instantiate a ComplexShape and set its name
shape = new ICEShape(operatorType);
currentShapeId++;
shape.setName(operatorType.toString());
shape.setId(currentShapeId);
}
// Return the shape
// If none of the conditions above passed, this will return null.
return shape;
}
}
\ No newline at end of file
/*******************************************************************************
* Copyright (c) 2012, 2014 UT-Battelle, LLC.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Initial API and implementation and/or initial documentation - Jay Jay Billings,
* Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson,
* Claire Saunders, Matthew Wang, Anna Wojtowicz
*******************************************************************************/
package org.eclipse.ice.client.widgets.geometry;
import java.net.URL;
import org.eclipse.ice.datastructures.form.GeometryComponent;
import org.eclipse.ice.datastructures.form.geometry.ICEShape;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.ITreeSelection;
import org.eclipse.jface.viewers.TreePath;
import org.eclipse.ui.internal.util.BundleUtility;
import org.osgi.framework.Bundle;
import org.osgi.framework.FrameworkUtil;
/**
* <p>
* Action for deleting the currently selected shapes from the ShapeTreeView
* </p>
*
* @author Andrew P. Belt
*/
public class ActionDeleteShape extends Action {
/**
* <p>
* The current ShapeTreeViewer associated with the DeleteShape action
* </p>
*
*/
private ShapeTreeView view;
/**
* The image descriptor associated with the delete action's icon
*/
private ImageDescriptor imageDescriptor;
/**
* <p>
* Constructor for setting the current ShapeTreeViewer
* </p>
*
* @param view
* <p>
* The current ShapeTreeView
* </p>
*/
public ActionDeleteShape(ShapeTreeView view) {
this.view = view;
this.setText("Delete Shape");
// Load the delete.gif ImageDescriptor from the bundle's
// `icons` directory
Bundle bundle = FrameworkUtil.getBundle(getClass());
URL imagePath = BundleUtility.find(bundle, "icons/delete.gif");
imageDescriptor = ImageDescriptor.createFromURL(imagePath);
}
/**
* Returns the image descriptor associated with the delete action's icon
*
* @return The ImageDescriptor with the loaded delete.gif file
* @see org.eclipse.jface.action.Action#getImageDescriptor()
*/
@Override
public ImageDescriptor getImageDescriptor() {
return imageDescriptor;
}
/**
* <p>
* Runs this action
* </p>
* <p>
* Each action implementation must define the steps needed to carry out this
* action.
* </p>
*
*/
@Override
public void run() {
// Get the tree paths of the current selection
ITreeSelection selection = (ITreeSelection) view.treeViewer
.getSelection();
TreePath[] paths = selection.getPaths();
GeometryComponent geometry = (GeometryComponent) view.treeViewer
.getInput();
// Loop through each TreePath
for (TreePath path : paths) {
Object selectedObject = path.getLastSegment();
// Check if the selected object is an IShape
if (selectedObject instanceof ICEShape) {
ICEShape selectedShape = (ICEShape) selectedObject;
ICEShape parentShape = selectedShape.getShapeParent();
if (parentShape == null) {
// The parent shape may be the root GeometryComponent,
// so try removing it from there.
synchronized (geometry) {
geometry.getGeometry().removeShape(selectedShape);
}
view.treeViewer.refresh();
}
else if (parentShape.isComplex()) {
// Remove the selected shape from the parent
synchronized (geometry) {
parentShape.removeShape(selectedShape);
}
view.treeViewer.refresh(parentShape);
}
}
}
}
}
\ No newline at end of file
/*******************************************************************************
* Copyright (c) 2012, 2014 UT-Battelle, LLC.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Initial API and implementation and/or initial documentation - Jay Jay Billings,
* Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson,
* Claire Saunders, Matthew Wang, Anna Wojtowicz
*******************************************************************************/
package org.eclipse.ice.client.widgets.geometry;
import java.net.URL;
import java.util.ArrayList;
import org.eclipse.ice.datastructures.form.GeometryComponent;
import org.eclipse.ice.datastructures.form.geometry.ICEShape;
import org.eclipse.ice.viz.service.jme3.shapes.ShapeType;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.ITreeSelection;
import org.eclipse.jface.viewers.TreePath;
import org.eclipse.jface.viewers.TreeSelection;
import org.eclipse.ui.internal.util.BundleUtility;
import org.osgi.framework.Bundle;
import org.osgi.framework.FrameworkUtil;
/**
*
* @author Andrew P. Belt
*/
public class ActionDuplicateShape extends Action {
/**
*
*/
private ShapeTreeView view;
/**
* The image descriptor associated with the duplicate action's icon
*/
private ImageDescriptor imageDescriptor;
/**
*
* @param view
*/
public ActionDuplicateShape(ShapeTreeView view) {
this.view = view;
this.setText("Duplicate Shape");
// Load duplicate.gif icon from the bundle's icons/ directory
Bundle bundle = FrameworkUtil.getBundle(getClass());
URL imagePath = BundleUtility.find(bundle, "icons/duplicate.gif");
imageDescriptor = ImageDescriptor.createFromURL(imagePath);
}
/**
* Returns the image descriptor associated with the duplicate action's icon
*
* @see org.eclipse.jface.action.Action#getImageDescriptor()
*/
@Override