Commit 37ad897f authored by Robert Smith's avatar Robert Smith

Working on converting Geometry editor

Working on converting the geometry editor to the new data types.
Signed-off-by: Robert Smith's avatarRobert Smith <SmithRW@ornl.gov>
parent b61dfdf7
......@@ -5,9 +5,10 @@ Bundle-SymbolicName: org.eclipse.ice.client.widgets.test
Bundle-Version: 2.1.8.qualifier
Fragment-Host: org.eclipse.ice.client.widgets;bundle-version="2.0.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Import-Package: org.eclipse.eavp.viz.service.geometry.shapes,
Import-Package: org.eclipse.eavp.viz.modeling,
org.eclipse.eavp.viz.service.geometry.widgets,
org.eclipse.eavp.viz.modeling,
org.eclipse.eavp.viz.service.javafx.canvas,
org.eclipse.january.geometry,
org.eclipse.ui,
org.junit
Require-Bundle: org.eclipse.swtbot.eclipse.core,
......
......@@ -14,12 +14,10 @@ package org.eclipse.ice.client.widgets.test;
import static org.junit.Assert.assertTrue;
import org.eclipse.eavp.viz.modeling.base.BasicView;
import org.eclipse.eavp.viz.modeling.ShapeController;
import org.eclipse.eavp.viz.modeling.Shape;
import org.eclipse.ice.client.widgets.ICEFormEditor;
import org.eclipse.ice.client.widgets.ICEGeometryPage;
import org.eclipse.ice.datastructures.form.GeometryComponent;
import org.eclipse.january.geometry.GeometryFactory;
import org.junit.Test;
/**
......@@ -43,10 +41,10 @@ public class ICEGeometryPageTester {
// Get two GeometryComponent to check equality
GeometryComponent geometryComponent = new GeometryComponent();
GeometryComponent otherGeometryComponent = new GeometryComponent();
geometryComponent.setGeometry(
new ShapeController(new Shape(), new BasicView()));
geometryComponent.setGeometry(
new ShapeController(new Shape(), new BasicView()));
geometryComponent
.setGeometry(GeometryFactory.eINSTANCE.createGeometry());
geometryComponent
.setGeometry(GeometryFactory.eINSTANCE.createGeometry());
// Get ICEGeometryPage to check accessor
ICEFormEditor ICEFormEditor = new ICEFormEditor();
......
......@@ -18,15 +18,24 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import org.eclipse.eavp.viz.modeling.Shape;
import org.eclipse.eavp.viz.modeling.ShapeController;
import org.eclipse.eavp.viz.modeling.base.BasicView;
import org.eclipse.eavp.viz.modeling.properties.MeshProperty;
import org.eclipse.eavp.viz.modeling.ShapeController;
import org.eclipse.eavp.viz.modeling.Shape;
import org.eclipse.eavp.viz.service.geometry.shapes.GeometryMeshProperty;
import org.eclipse.eavp.viz.service.geometry.shapes.OperatorType;
import org.eclipse.eavp.viz.service.geometry.shapes.ShapeType;
import org.eclipse.eavp.viz.service.geometry.widgets.ShapeTreeContentProvider;
import org.eclipse.eavp.viz.service.javafx.canvas.FXAttachment;
import org.eclipse.eavp.viz.service.javafx.canvas.FXAttachmentManager;
import org.eclipse.ice.datastructures.form.GeometryComponent;
import org.eclipse.january.geometry.Complement;
import org.eclipse.january.geometry.Cube;
import org.eclipse.january.geometry.Geometry;
import org.eclipse.january.geometry.GeometryFactory;
import org.eclipse.january.geometry.Intersection;
import org.eclipse.january.geometry.Sphere;
import org.eclipse.january.geometry.Union;
import org.junit.Test;
/**
......@@ -48,7 +57,8 @@ public class ShapeTreeContentProviderTest {
// Create all needed objects
ShapeTreeContentProvider shapeProvider = new ShapeTreeContentProvider();
ShapeTreeContentProvider shapeProvider = new ShapeTreeContentProvider(
new FXAttachment(new FXAttachmentManager()));
// Create a shape
Shape geometryModel = new Shape();
......@@ -127,7 +137,8 @@ public class ShapeTreeContentProviderTest {
// Create all needed objects
ShapeTreeContentProvider shapeProvider = new ShapeTreeContentProvider();
ShapeTreeContentProvider shapeProvider = new ShapeTreeContentProvider(
new FXAttachment(new FXAttachmentManager()));
// Create a shape
Shape geometryModel = new Shape();
......@@ -189,7 +200,8 @@ public class ShapeTreeContentProviderTest {
// but we can still check whether it doesn't throw exceptions upon
// creation and destruction.
ShapeTreeContentProvider shapeProvider = new ShapeTreeContentProvider();
ShapeTreeContentProvider shapeProvider = new ShapeTreeContentProvider(
new FXAttachment(new FXAttachmentManager()));
shapeProvider.dispose();
......@@ -206,29 +218,27 @@ public class ShapeTreeContentProviderTest {
// Create all needed objects
ShapeTreeContentProvider shapeProvider = new ShapeTreeContentProvider();
ShapeTreeContentProvider shapeProvider = new ShapeTreeContentProvider(
new FXAttachment(new FXAttachmentManager()));
Shape geometryModel = new Shape();
geometryModel.setProperty(MeshProperty.TYPE, ShapeType.Sphere.toString());
BasicView geometryView = new BasicView();
ShapeController geometry = new ShapeController(geometryModel,
geometryView);
Geometry geometry = GeometryFactory.eINSTANCE.createGeometry();
ShapeController sphere1 = (ShapeController) geometry.clone();
ShapeController cube1 = (ShapeController) geometry.clone();
ShapeController union1 = (ShapeController) geometry.clone();
ShapeController complement1 = (ShapeController) geometry.clone();
ShapeController intersection1 = (ShapeController) geometry.clone();
Sphere sphere1 = GeometryFactory.eINSTANCE.createSphere();
Cube cube1 = GeometryFactory.eINSTANCE.createCube();
Union union1 = GeometryFactory.eINSTANCE.createUnion();
Complement complement1 = GeometryFactory.eINSTANCE.createComplement();
Intersection intersection1 = GeometryFactory.eINSTANCE
.createIntersection();
// Put them all in a GeometryComponent
GeometryComponent geometryComponent = new GeometryComponent();
geometryComponent.setGeometry(geometry);
geometryComponent.getGeometry().addEntity(sphere1);
geometryComponent.getGeometry().addEntity(cube1);
geometryComponent.getGeometry().addEntity(union1);
geometryComponent.getGeometry().addEntity(complement1);
geometryComponent.getGeometry().addEntity(sphere1);
geometryComponent.getGeometry().addNode(sphere1);
geometryComponent.getGeometry().addNode(cube1);
geometryComponent.getGeometry().addNode(union1);
geometryComponent.getGeometry().addNode(complement1);
geometryComponent.getGeometry().addNode(sphere1);
Object[] expectedElements = new Object[] { sphere1, cube1, union1,
complement1, sphere1 };
......
......@@ -11,7 +11,9 @@ Require-Bundle: org.eclipse.ice.datastructures,
org.eclipse.nebula.widgets.nattable.core;bundle-version="1.3.0",
org.eclipse.nebula.widgets.nattable.extension.glazedlists;bundle-version="1.3.0",
org.eclipse.remote.ui;bundle-version="2.0.0",
org.eclipse.swt
org.eclipse.swt,
org.eclipse.eavp.geometry.view.model;bundle-version="0.1.0",
org.eclipse.january.geometry.model;bundle-version="1.0.0"
Import-Package:
com.sun.jersey.api.client;version="1.17.0",
org.apache.commons.io,
......@@ -37,7 +39,6 @@ Import-Package:
org.eclipse.eavp.viz.modeling.properties,
org.eclipse.eavp.viz.service,
org.eclipse.eavp.viz.service.csv,
org.eclipse.eavp.viz.service.geometry.shapes,
org.eclipse.eavp.viz.service.geometry.widgets,
org.eclipse.eavp.viz.service.internal,
org.eclipse.eavp.viz.service.mesh.datastructures,
......
......@@ -64,6 +64,12 @@ public class ICEGeometryPage extends ICEFormPage
*/
private IVizService service;
/**
* The IVizCanvas responsible for drawing the composite this page will
* display.
*/
private IVizCanvas vizCanvas;
/**
* <p>
* This sets the FormEditor to be opened on, as well as the id and title
......@@ -144,6 +150,8 @@ public class ICEGeometryPage extends ICEFormPage
ShapeTreeView shapeTreeView = (ShapeTreeView) getSite()
.getWorkbenchWindow().getActivePage()
.findView(ShapeTreeView.ID);
shapeTreeView.setRenderElementHolder(
vizCanvas.getRenderElementHolder(geometryComp.getGeometry()));
shapeTreeView.setGeometry(geometryComp.getGeometry());
return;
......@@ -191,14 +199,11 @@ public class ICEGeometryPage extends ICEFormPage
// Get Geometry service from factory
IVizServiceFactory factory = editor.getVizServiceFactory();
service = factory.get("ICE Geometry Editor");
((ShapeTreeView) getSite().getWorkbenchWindow().getActivePage()
.findView(ShapeTreeView.ID)).setFactory(service.getControllerProviderFactory());
geometryComp.setService(service);
// Create and draw geometry canvas
try {
IVizCanvas vizCanvas = service
.createCanvas(geometryComp.getGeometry());
vizCanvas = service.createCanvas(geometryComp.getGeometry());
vizCanvas.draw(parent);
} catch (Exception e) {
......
......@@ -21,6 +21,7 @@ Import-Package: ca.odell.glazedlists,
org.eclipse.emf.ecore.xmi,
org.eclipse.emf.ecore.xmi.impl,
org.eclipse.emf.ecore.xmi.util,
org.eclipse.january.geometry,
org.osgi.framework;version="1.6.0",
org.osgi.util.tracker;version="1.5.0",
org.slf4j;version="1.7.2"
......
......@@ -20,17 +20,17 @@ import static org.junit.Assert.fail;
import java.util.List;
import org.eclipse.eavp.viz.service.geometry.shapes.GeometryMeshProperty;
import org.eclipse.eavp.viz.service.geometry.shapes.OperatorType;
import org.eclipse.eavp.viz.service.geometry.shapes.ShapeType;
import org.eclipse.eavp.viz.modeling.base.BasicController;
import org.eclipse.eavp.viz.modeling.base.BasicView;
import org.eclipse.eavp.viz.modeling.base.IController;
import org.eclipse.eavp.viz.modeling.properties.MeshProperty;
import org.eclipse.eavp.viz.modeling.ShapeController;
import org.eclipse.eavp.viz.modeling.Shape;
import org.eclipse.ice.datastructures.ICEObject.Component;
import org.eclipse.ice.datastructures.form.GeometryComponent;
import org.eclipse.january.geometry.Cube;
import org.eclipse.january.geometry.Cylinder;
import org.eclipse.january.geometry.Geometry;
import org.eclipse.january.geometry.GeometryFactory;
import org.eclipse.january.geometry.INode;
import org.eclipse.january.geometry.Intersection;
import org.eclipse.january.geometry.Operator;
import org.eclipse.january.geometry.Shape;
import org.eclipse.january.geometry.Sphere;
import org.junit.Test;
/**
......@@ -53,45 +53,40 @@ public class GeometryComponentTester {
public void checkAddShapes() {
// Create a shape
Shape geometryModel = new Shape();
geometryModel.setProperty(MeshProperty.TYPE,
ShapeType.Sphere.toString());
BasicView geometryView = new BasicView();
ShapeController geometryShape = new ShapeController(geometryModel,
geometryView);
Geometry geometryShape = GeometryFactory.eINSTANCE.createGeometry();
// Instantiate a GeometryComponent
GeometryComponent geometry = new GeometryComponent();
geometry.setGeometry(geometryShape);
// Add a PrimitiveShape
ShapeController sphere = (ShapeController) geometryShape.clone();
geometry.getGeometry().addEntity(sphere);
assertEquals(1, geometry.getGeometry().getEntities().size());
assertEquals(sphere, geometry.getGeometry().getEntities().get(0));
Sphere sphere = GeometryFactory.eINSTANCE.createSphere();
geometry.getGeometry().addNode(sphere);
assertEquals(1, geometry.getGeometry().getNodes().size());
assertEquals(sphere, geometry.getGeometry().getNodes().get(0));
// Add a ComplexShape
ShapeController complex = (ShapeController) geometryShape.clone();
geometry.getGeometry().addEntity(complex);
assertEquals(2, geometry.getGeometry().getEntities().size());
assertEquals(complex, geometry.getGeometry().getEntities().get(1));
Operator complex = GeometryFactory.eINSTANCE.createOperator();
geometry.getGeometry().addNode(complex);
assertEquals(2, geometry.getGeometry().getNodes().size());
assertEquals(complex, geometry.getGeometry().getNodes().get(1));
// Try adding null
geometry.getGeometry().addEntity(null);
assertEquals(2, geometry.getGeometry().getEntities().size());
geometry.getGeometry().addNode(null);
assertEquals(2, geometry.getGeometry().getNodes().size());
// Add a shape with an unknown concrete type
ShapeController unknownShape = (ShapeController) geometryShape.clone();
geometry.getGeometry().addEntity(unknownShape);
assertEquals(3, geometry.getGeometry().getEntities().size());
assertEquals(unknownShape, geometry.getGeometry().getEntities().get(2));
Shape unknownShape = GeometryFactory.eINSTANCE.createShape();
geometry.getGeometry().addNode(unknownShape);
assertEquals(3, geometry.getGeometry().getNodes().size());
assertEquals(unknownShape, geometry.getGeometry().getNodes().get(2));
// Remove the second shape
geometry.getGeometry().removeEntity(complex);
assertEquals(2, geometry.getGeometry().getEntities().size());
geometry.getGeometry().removeNode(complex);
assertEquals(2, geometry.getGeometry().getNodes().size());
// Steal the list from the GeometryComponent
List<IController> shapes = geometry.getGeometry().getEntities();
List<INode> shapes = geometry.getGeometry().getNodes();
assertEquals(2, shapes.size());
// Remove a shape from the stolen list
......@@ -147,12 +142,7 @@ public class GeometryComponentTester {
public void checkNotifications() {
// Create a shape
Shape geometryModel = new Shape();
geometryModel.setProperty(MeshProperty.TYPE,
ShapeType.Sphere.toString());
BasicView geometryView = new BasicView();
ShapeController geometryShape = new ShapeController(geometryModel,
geometryView);
Geometry geometryShape = GeometryFactory.eINSTANCE.createGeometry();
// Create a new listener and add it to a GeometryComponent
GeometryComponent geometry = new GeometryComponent();
......@@ -161,8 +151,7 @@ public class GeometryComponentTester {
geometry.register(listener);
// Modify geometryComponent's shapes list
geometry.getGeometry()
.addEntity((BasicController) geometryShape.clone());
geometry.getGeometry().addNode(GeometryFactory.eINSTANCE.createShape());
// Check that the listener was notified and reset the listener
assertTrue(listener.wasNotified());
......@@ -257,12 +246,7 @@ public class GeometryComponentTester {
@Test
public void checkEquality() {
Shape geometryModel = new Shape();
geometryModel.setProperty(MeshProperty.TYPE,
ShapeType.Sphere.toString());
BasicView geometryView = new BasicView();
ShapeController geometryShape = new ShapeController(geometryModel,
geometryView);
Geometry geometryShape = GeometryFactory.eINSTANCE.createGeometry();
// Create GeometryComponent to test
GeometryComponent component = new GeometryComponent();
......@@ -270,23 +254,20 @@ public class GeometryComponentTester {
GeometryComponent unEqualComponent = new GeometryComponent();
GeometryComponent transitiveComponent = new GeometryComponent();
component.setGeometry(geometryShape);
equalComponent.setGeometry((ShapeController) geometryShape.clone());
unEqualComponent.setGeometry((ShapeController) geometryShape.clone());
transitiveComponent
.setGeometry((ShapeController) geometryShape.clone());
equalComponent.setGeometry((Geometry) geometryShape.clone());
unEqualComponent.setGeometry((Geometry) geometryShape.clone());
transitiveComponent.setGeometry((Geometry) geometryShape.clone());
// Change values
ShapeController shape = (ShapeController) geometryShape.clone();
shape.setProperty(MeshProperty.TYPE, ShapeType.Cylinder.toString());
ShapeController weirdShape = (ShapeController) geometryShape.clone();
shape.setProperty(GeometryMeshProperty.OPERATOR,
OperatorType.Intersection.toString());
Cylinder shape = GeometryFactory.eINSTANCE.createCylinder();
Intersection weirdShape = GeometryFactory.eINSTANCE
.createIntersection();
component.getGeometry().addEntity(shape);
equalComponent.getGeometry().addEntity(shape);
transitiveComponent.getGeometry().addEntity(shape);
component.getGeometry().addNode(shape);
equalComponent.getGeometry().addNode(shape);
transitiveComponent.getGeometry().addNode(shape);
unEqualComponent.getGeometry().addEntity(weirdShape);
unEqualComponent.getGeometry().addNode(weirdShape);
// Set ICEObject data
component.setId(1);
......@@ -354,20 +335,15 @@ public class GeometryComponentTester {
public void checkCreation() {
// Create a shape
Shape geometryModel = new Shape();
geometryModel.setProperty(MeshProperty.TYPE,
ShapeType.Sphere.toString());
BasicView geometryView = new BasicView();
ShapeController geometryShape = new ShapeController(geometryModel,
geometryView);
Geometry geometryShape = GeometryFactory.eINSTANCE.createGeometry();
// Create a new GeometryComponent
GeometryComponent geometry = new GeometryComponent();
geometry.setGeometry(geometryShape);
// Check that the shapes list exists but is empty
assertNotNull(geometry.getGeometry().getEntities());
assertTrue(geometry.getGeometry().getEntities().isEmpty());
assertNotNull(geometry.getGeometry().getNodes());
assertTrue(geometry.getGeometry().getNodes().isEmpty());
}
......@@ -382,12 +358,7 @@ public class GeometryComponentTester {
public void checkCopying() {
// Create a shape
Shape geometryModel = new Shape();
geometryModel.setProperty(MeshProperty.TYPE,
ShapeType.Sphere.toString());
BasicView geometryView = new BasicView();
ShapeController geometryShape = new ShapeController(geometryModel,
geometryView);
Geometry geometryShape = GeometryFactory.eINSTANCE.createGeometry();
GeometryComponent geometry = new GeometryComponent();
GeometryComponent cloneGeometry;
......@@ -400,19 +371,12 @@ public class GeometryComponentTester {
geometry.setName("Geometry name");
// Set up GeometryComponent-specific stuff
Shape sphereModel = new Shape();
sphereModel.setProperty(MeshProperty.TYPE, ShapeType.Sphere.toString());
BasicView sphereView = new BasicView();
ShapeController sphere1 = new ShapeController(sphereModel, sphereView);
Shape cubeModel = new Shape();
cubeModel.setProperty(GeometryMeshProperty.OPERATOR,
OperatorType.Union.toString());
BasicView cubeView = new BasicView();
ShapeController cube1 = new ShapeController(cubeModel, cubeView);
geometry.getGeometry().addEntity(sphere1);
geometry.getGeometry().addEntity(cube1);
Sphere sphere1 = GeometryFactory.eINSTANCE.createSphere();
Cube cube1 = GeometryFactory.eINSTANCE.createCube();
geometry.getGeometry().addNode(sphere1);
geometry.getGeometry().addNode(cube1);
// Clone contents
cloneGeometry = (GeometryComponent) geometry.clone();
......
......@@ -25,9 +25,10 @@ Import-Package: ca.odell.glazedlists,
org.eclipse.eavp.viz.modeling.base,
org.eclipse.eavp.viz.modeling.properties,
org.eclipse.eavp.viz.service,
org.eclipse.eavp.viz.service.geometry.persistence,
org.eclipse.eavp.viz.service.mesh.datastructures,
org.eclipse.emf.common,
org.eclipse.emf.common.notify,
org.eclipse.emf.common.notify.impl,
org.eclipse.emf.common.util,
org.eclipse.emf.ecore,
org.eclipse.emf.ecore.resource,
......@@ -35,6 +36,7 @@ Import-Package: ca.odell.glazedlists,
org.eclipse.emf.ecore.xmi,
org.eclipse.emf.ecore.xmi.impl,
org.eclipse.emf.ecore.xmi.util,
org.eclipse.january.geometry,
org.eclipse.xsd,
org.osgi.framework;version="1.6.0",
org.slf4j;version="1.7.2"
......
......@@ -16,23 +16,22 @@ 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.XmlTransient;
import org.eclipse.eavp.viz.datastructures.VizObject.IManagedUpdateable;
import org.eclipse.eavp.viz.datastructures.VizObject.IManagedUpdateableListener;
import org.eclipse.eavp.viz.datastructures.VizObject.SubscriptionType;
import org.eclipse.eavp.viz.modeling.ShapeController;
import org.eclipse.eavp.viz.modeling.Shape;
import org.eclipse.eavp.viz.modeling.properties.MeshProperty;
import org.eclipse.eavp.viz.service.IVizService;
import org.eclipse.eavp.viz.service.geometry.persistence.PersistableShape;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.impl.AdapterImpl;
import org.eclipse.ice.datastructures.ICEObject.Component;
import org.eclipse.ice.datastructures.ICEObject.ICEObject;
import org.eclipse.ice.datastructures.ICEObject.IUpdateable;
import org.eclipse.ice.datastructures.ICEObject.IUpdateableListener;
import org.eclipse.ice.datastructures.componentVisitor.IComponentVisitor;
import org.eclipse.january.geometry.Geometry;
import org.eclipse.january.geometry.GeometryFactory;
/**
* <p>
......@@ -47,12 +46,6 @@ import org.eclipse.ice.datastructures.componentVisitor.IComponentVisitor;
public class GeometryComponent extends ICEObject
implements Component, IUpdateableListener, IManagedUpdateableListener {
/**
* The component's geometry in a temporary compresed form.
*/
@XmlTransient
private PersistableShape compressedGeometry;
/**
* <p>
* The set of ComponentListeners observing the GeometryComponent
......@@ -66,7 +59,7 @@ public class GeometryComponent extends ICEObject
* The Geometry managed by the GeometryComponent
*/
@XmlTransient
private ShapeController geometry;
private Geometry geometry;
/**
* The service being used to render this component.
......@@ -136,6 +129,9 @@ public class GeometryComponent extends ICEObject
// Create a new listeners list
listeners = new ArrayList<IUpdateableListener>();
// Initialize the geometry
geometry = GeometryFactory.eINSTANCE.createGeometry();
}
/**
......@@ -143,50 +139,30 @@ public class GeometryComponent extends ICEObject
*
* @return The held Geometry
*/
public ShapeController getGeometry() {
public Geometry getGeometry() {
return geometry;
}
/**
* Get the component's geometry in a persistable format. It is intended that
* this function will only be called by JAXB.
*
* @return A PersistableShape representing the component's CSG tree
*/
@XmlElement(name = "Geometry")
private PersistableShape getPersistableGeometry() {
return PersistableShape.compress((Shape) geometry.getModel());
}
/**
* Mutator method for the held geometry
*
* @param newGeometry
* the new Geometry to hold
*/
public void setGeometry(ShapeController newGeometry) {
public void setGeometry(Geometry newGeometry) {
geometry = newGeometry;
// Set the shape as being the root node for the scene
geometry.setProperty(MeshProperty.ROOT, "True");
// Register self as a listener for the geometry
geometry.register(this);
geometry.eAdapters().add(new AdapterImpl() {
// Notify listeners
@Override
public void notifyChanged(Notification notification) {
notifyListeners();
}
});
/**
* Set the compressed form of the component's geometry. It is intended that
* this function will only be called by JAXB.
*
* @param root
* The compressed root of the CSG tree to be displayed by this
* component.
*/
private void setPersistableGeometry(PersistableShape root) {
</