Commit 9abed7db authored by Robert Smith's avatar Robert Smith
Browse files

Fixed test failures and renamed data structures



Got all tests working with the new mesh and geometry editors. Also
renamed most of the data structures involved in the unified MVC data
structures. 
Signed-off-by: Robert Smith's avatarRobert Smith <SmithRW@ornl.gov>
parent 86eac012
......@@ -18,8 +18,8 @@ import org.eclipse.ice.client.widgets.ICEFormEditor;
import org.eclipse.ice.client.widgets.ICEGeometryPage;
import org.eclipse.ice.datastructures.form.GeometryComponent;
import org.eclipse.ice.viz.service.modeling.AbstractView;
import org.eclipse.ice.viz.service.modeling.Shape;
import org.eclipse.ice.viz.service.modeling.ShapeComponent;
import org.eclipse.ice.viz.service.modeling.ShapeController;
import org.eclipse.ice.viz.service.modeling.ShapeMesh;
import org.junit.Test;
/**
......@@ -44,9 +44,9 @@ public class ICEGeometryPageTester {
GeometryComponent geometryComponent = new GeometryComponent();
GeometryComponent otherGeometryComponent = new GeometryComponent();
geometryComponent.setGeometry(
new Shape(new ShapeComponent(), new AbstractView()));
new ShapeController(new ShapeMesh(), new AbstractView()));
geometryComponent.setGeometry(
new Shape(new ShapeComponent(), new AbstractView()));
new ShapeController(new ShapeMesh(), new AbstractView()));
// Get ICEGeometryPage to check accessor
ICEFormEditor ICEFormEditor = new ICEFormEditor();
......
......@@ -23,8 +23,8 @@ import org.eclipse.ice.viz.service.geometry.shapes.OperatorType;
import org.eclipse.ice.viz.service.geometry.shapes.ShapeType;
import org.eclipse.ice.viz.service.geometry.widgets.ShapeTreeContentProvider;
import org.eclipse.ice.viz.service.modeling.AbstractView;
import org.eclipse.ice.viz.service.modeling.Shape;
import org.eclipse.ice.viz.service.modeling.ShapeComponent;
import org.eclipse.ice.viz.service.modeling.ShapeController;
import org.eclipse.ice.viz.service.modeling.ShapeMesh;
import org.junit.Test;
/**
......@@ -49,20 +49,20 @@ public class ShapeTreeContentProviderTest {
ShapeTreeContentProvider shapeProvider = new ShapeTreeContentProvider();
// Create a shape
ShapeComponent geometryModel = new ShapeComponent();
ShapeMesh geometryModel = new ShapeMesh();
AbstractView geometryView = new AbstractView();
Shape geometryShape = new Shape(geometryModel, geometryView);
ShapeController geometryShape = new ShapeController(geometryModel, geometryView);
Shape sphere1 = (Shape) geometryShape.clone();
ShapeController sphere1 = (ShapeController) geometryShape.clone();
sphere1.setProperty("Type", ShapeType.Sphere.toString());
Shape cube1 = (Shape) geometryShape.clone();
ShapeController cube1 = (ShapeController) geometryShape.clone();
cube1.setProperty("Type", ShapeType.Cube.toString());
Shape union1 = (Shape) geometryShape.clone();
ShapeController union1 = (ShapeController) geometryShape.clone();
union1.setProperty("Operator", OperatorType.Union.toString());
Shape complement1 = (Shape) geometryShape.clone();
ShapeController complement1 = (ShapeController) geometryShape.clone();
complement1.setProperty("Operator", OperatorType.Complement.toString());
Shape intersection1 = (Shape) geometryShape.clone();
ShapeController intersection1 = (ShapeController) geometryShape.clone();
intersection1.setProperty("Operator",
OperatorType.Intersection.toString());
......@@ -125,20 +125,20 @@ public class ShapeTreeContentProviderTest {
ShapeTreeContentProvider shapeProvider = new ShapeTreeContentProvider();
// Create a shape
ShapeComponent geometryModel = new ShapeComponent();
ShapeMesh geometryModel = new ShapeMesh();
AbstractView geometryView = new AbstractView();
Shape geometryShape = new Shape(geometryModel, geometryView);
ShapeController geometryShape = new ShapeController(geometryModel, geometryView);
Shape sphere1 = (Shape) geometryShape.clone();
ShapeController sphere1 = (ShapeController) geometryShape.clone();
sphere1.setProperty("Type", ShapeType.Sphere.toString());
Shape cube1 = (Shape) geometryShape.clone();
ShapeController cube1 = (ShapeController) geometryShape.clone();
cube1.setProperty("Type", ShapeType.Cube.toString());
Shape union1 = (Shape) geometryShape.clone();
ShapeController union1 = (ShapeController) geometryShape.clone();
union1.setProperty("Operator", OperatorType.Union.toString());
Shape complement1 = (Shape) geometryShape.clone();
ShapeController complement1 = (ShapeController) geometryShape.clone();
complement1.setProperty("Operator", OperatorType.Complement.toString());
Shape intersection1 = (Shape) geometryShape.clone();
ShapeController intersection1 = (ShapeController) geometryShape.clone();
intersection1.setProperty("Operator",
OperatorType.Intersection.toString());
......@@ -200,16 +200,16 @@ public class ShapeTreeContentProviderTest {
ShapeTreeContentProvider shapeProvider = new ShapeTreeContentProvider();
ShapeComponent geometryModel = new ShapeComponent();
ShapeMesh geometryModel = new ShapeMesh();
geometryModel.setProperty("Type", ShapeType.Sphere.toString());
AbstractView geometryView = new AbstractView();
Shape geometry = new Shape(geometryModel, geometryView);
ShapeController geometry = new ShapeController(geometryModel, geometryView);
Shape sphere1 = (Shape) geometry.clone();
Shape cube1 = (Shape) geometry.clone();
Shape union1 = (Shape) geometry.clone();
Shape complement1 = (Shape) geometry.clone();
Shape intersection1 = (Shape) geometry.clone();
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();
// Put them all in a GeometryComponent
......
......@@ -19,8 +19,8 @@ import org.eclipse.ice.viz.service.geometry.shapes.OperatorType;
import org.eclipse.ice.viz.service.geometry.shapes.ShapeType;
import org.eclipse.ice.viz.service.geometry.widgets.ShapeTreeLabelProvider;
import org.eclipse.ice.viz.service.modeling.AbstractView;
import org.eclipse.ice.viz.service.modeling.Shape;
import org.eclipse.ice.viz.service.modeling.ShapeComponent;
import org.eclipse.ice.viz.service.modeling.ShapeController;
import org.eclipse.ice.viz.service.modeling.ShapeMesh;
import org.junit.Test;
/**
......@@ -65,13 +65,13 @@ public class ShapeTreeLabelProviderTest {
// Any input should produce a null return value
// Create a shape
ShapeComponent geometryModel = new ShapeComponent();
ShapeMesh geometryModel = new ShapeMesh();
AbstractView geometryView = new AbstractView();
Shape geometryShape = new Shape(geometryModel, geometryView);
ShapeController geometryShape = new ShapeController(geometryModel, geometryView);
Shape cube1 = (Shape) geometryShape.clone();
ShapeController cube1 = (ShapeController) geometryShape.clone();
cube1.setProperty("Type", ShapeType.Cube.toString());
Shape intersection1 = (Shape) geometryShape.clone();
ShapeController intersection1 = (ShapeController) geometryShape.clone();
intersection1.setProperty("Operator",
OperatorType.Intersection.toString());
......@@ -95,16 +95,16 @@ public class ShapeTreeLabelProviderTest {
// Create some named shapes
// Create a shape
ShapeComponent geometryModel = new ShapeComponent();
ShapeMesh geometryModel = new ShapeMesh();
AbstractView geometryView = new AbstractView();
Shape geometryShape = new Shape(geometryModel, geometryView);
ShapeController geometryShape = new ShapeController(geometryModel, geometryView);
Shape cube1 = (Shape) geometryShape.clone();
ShapeController cube1 = (ShapeController) geometryShape.clone();
cube1.setProperty("Type", ShapeType.Cube.toString());
Shape union1 = (Shape) geometryShape.clone();
ShapeController union1 = (ShapeController) geometryShape.clone();
union1.setProperty("Operator", OperatorType.Union.toString());
Shape intersection1 = (Shape) geometryShape.clone();
ShapeController intersection1 = (ShapeController) geometryShape.clone();
intersection1.setProperty("Operator",
OperatorType.Intersection.toString());
......
......@@ -20,7 +20,7 @@ import org.eclipse.ice.datastructures.form.Form;
import org.eclipse.ice.datastructures.form.MeshComponent;
import org.eclipse.ice.viz.service.mesh.properties.MeshSelection;
import org.eclipse.ice.viz.service.modeling.AbstractController;
import org.eclipse.ice.viz.service.modeling.Face;
import org.eclipse.ice.viz.service.modeling.FaceController;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.LabelProvider;
......@@ -226,8 +226,8 @@ public class MeshElementTreeView extends ViewPart
// An array of every unique vertex from the selection
ArrayList<AbstractController> vertices = new ArrayList<AbstractController>();
if (selection.selectedMeshPart instanceof Face) {
Face polygon = (Face) selection.selectedMeshPart;
if (selection.selectedMeshPart instanceof FaceController) {
FaceController polygon = (FaceController) selection.selectedMeshPart;
// Add new MeshSelections for the edges.
for (AbstractController e : polygon
.getEntitiesByCategory("Edges")) {
......@@ -278,7 +278,7 @@ public class MeshElementTreeView extends ViewPart
// Only selected Polygons will have children.
return (element instanceof MeshSelection
&& ((MeshSelection) element).selectedMeshPart instanceof Face);
&& ((MeshSelection) element).selectedMeshPart instanceof FaceController);
}
});
......
......@@ -17,9 +17,9 @@ import java.util.Hashtable;
import org.eclipse.ice.client.common.PropertySource;
import org.eclipse.ice.viz.service.modeling.AbstractController;
import org.eclipse.ice.viz.service.modeling.Edge;
import org.eclipse.ice.viz.service.modeling.Face;
import org.eclipse.ice.viz.service.modeling.Vertex;
import org.eclipse.ice.viz.service.modeling.EdgeController;
import org.eclipse.ice.viz.service.modeling.FaceController;
import org.eclipse.ice.viz.service.modeling.VertexController;
import org.eclipse.ui.views.properties.IPropertyDescriptor;
import org.eclipse.ui.views.properties.IPropertySource;
import org.eclipse.ui.views.properties.PropertyDescriptor;
......@@ -77,9 +77,9 @@ public class MeshElementTreeViewPropertySource extends PropertySource {
*/
static {
propDescMap = new Hashtable<Class<?>, IPropertyDescriptor[]>();
propDescMap.put(Face.class, polygonDescriptors);
propDescMap.put(Edge.class, edgeDescriptors);
propDescMap.put(Vertex.class, vertexDescriptors);
propDescMap.put(FaceController.class, polygonDescriptors);
propDescMap.put(EdgeController.class, edgeDescriptors);
propDescMap.put(VertexController.class, vertexDescriptors);
}
/**
......@@ -124,7 +124,7 @@ public class MeshElementTreeViewPropertySource extends PropertySource {
@Override
public Object getValue(Object data, Object id) {
Face polygon = (Face) data;
FaceController polygon = (FaceController) data;
ArrayList<String> propertySet = new ArrayList<String>();
// If the caller seeks the edges, get them from the wrapped
......@@ -162,7 +162,7 @@ public class MeshElementTreeViewPropertySource extends PropertySource {
@Override
public Object getValue(Object data, Object id) {
Edge edge = (Edge) data;
EdgeController edge = (EdgeController) data;
ArrayList<String> propertySet = new ArrayList<String>();
// Collect the given edge's vertices
......@@ -211,7 +211,7 @@ public class MeshElementTreeViewPropertySource extends PropertySource {
@Override
public Object getValue(Object data, Object id) {
Vertex vertex = (Vertex) data;
VertexController vertex = (VertexController) data;
ArrayList<String> propertySet = new ArrayList<String>();
// Get the vertex's location
......@@ -232,9 +232,9 @@ public class MeshElementTreeViewPropertySource extends PropertySource {
// Populate the handler map
propHandlerMap = new Hashtable<Class<?>, IPropertyTypeHandler>();
propHandlerMap.put(Face.class, polygonPropertyHandler);
propHandlerMap.put(Edge.class, edgePropertyHandler);
propHandlerMap.put(Vertex.class, vertexPropertyHandler);
propHandlerMap.put(FaceController.class, polygonPropertyHandler);
propHandlerMap.put(EdgeController.class, edgePropertyHandler);
propHandlerMap.put(VertexController.class, vertexPropertyHandler);
}
......
......@@ -26,8 +26,8 @@ import org.eclipse.ice.viz.service.geometry.shapes.OperatorType;
import org.eclipse.ice.viz.service.geometry.shapes.ShapeType;
import org.eclipse.ice.viz.service.modeling.AbstractController;
import org.eclipse.ice.viz.service.modeling.AbstractView;
import org.eclipse.ice.viz.service.modeling.Shape;
import org.eclipse.ice.viz.service.modeling.ShapeComponent;
import org.eclipse.ice.viz.service.modeling.ShapeController;
import org.eclipse.ice.viz.service.modeling.ShapeMesh;
import org.junit.Test;
/**
......@@ -50,23 +50,23 @@ public class GeometryComponentTester {
public void checkAddShapes() {
// Create a shape
ShapeComponent geometryModel = new ShapeComponent();
ShapeMesh geometryModel = new ShapeMesh();
geometryModel.setProperty("Type", ShapeType.Sphere.toString());
AbstractView geometryView = new AbstractView();
Shape geometryShape = new Shape(geometryModel, geometryView);
ShapeController geometryShape = new ShapeController(geometryModel, geometryView);
// Instantiate a GeometryComponent
GeometryComponent geometry = new GeometryComponent();
geometry.setGeometry(geometryShape);
// Add a PrimitiveShape
Shape sphere = (Shape) geometryShape.clone();
ShapeController sphere = (ShapeController) geometryShape.clone();
geometry.getGeometry().addEntity(sphere);
assertEquals(1, geometry.getGeometry().getEntities().size());
assertEquals(sphere, geometry.getGeometry().getEntities().get(0));
// Add a ComplexShape
Shape complex = (Shape) geometryShape.clone();
ShapeController complex = (ShapeController) geometryShape.clone();
geometry.getGeometry().addEntity(complex);
assertEquals(2, geometry.getGeometry().getEntities().size());
assertEquals(complex, geometry.getGeometry().getEntities().get(1));
......@@ -76,7 +76,7 @@ public class GeometryComponentTester {
assertEquals(2, geometry.getGeometry().getEntities().size());
// Add a shape with an unknown concrete type
Shape unknownShape = (Shape) geometryShape.clone();
ShapeController unknownShape = (ShapeController) geometryShape.clone();
geometry.getGeometry().addEntity(unknownShape);
assertEquals(3, geometry.getGeometry().getEntities().size());
assertEquals(unknownShape, geometry.getGeometry().getEntities().get(2));
......@@ -142,10 +142,10 @@ public class GeometryComponentTester {
public void checkNotifications() {
// Create a shape
ShapeComponent geometryModel = new ShapeComponent();
ShapeMesh geometryModel = new ShapeMesh();
geometryModel.setProperty("Type", ShapeType.Sphere.toString());
AbstractView geometryView = new AbstractView();
Shape geometryShape = new Shape(geometryModel, geometryView);
ShapeController geometryShape = new ShapeController(geometryModel, geometryView);
// Create a new listener and add it to a GeometryComponent
GeometryComponent geometry = new GeometryComponent();
......@@ -250,10 +250,10 @@ public class GeometryComponentTester {
@Test
public void checkEquality() {
ShapeComponent geometryModel = new ShapeComponent();
ShapeMesh geometryModel = new ShapeMesh();
geometryModel.setProperty("Type", ShapeType.Sphere.toString());
AbstractView geometryView = new AbstractView();
Shape geometryShape = new Shape(geometryModel, geometryView);
ShapeController geometryShape = new ShapeController(geometryModel, geometryView);
// Create GeometryComponent to test
GeometryComponent component = new GeometryComponent();
......@@ -261,14 +261,14 @@ public class GeometryComponentTester {
GeometryComponent unEqualComponent = new GeometryComponent();
GeometryComponent transitiveComponent = new GeometryComponent();
component.setGeometry(geometryShape);
equalComponent.setGeometry((Shape) geometryShape.clone());
unEqualComponent.setGeometry((Shape) geometryShape.clone());
transitiveComponent.setGeometry((Shape) geometryShape.clone());
equalComponent.setGeometry((ShapeController) geometryShape.clone());
unEqualComponent.setGeometry((ShapeController) geometryShape.clone());
transitiveComponent.setGeometry((ShapeController) geometryShape.clone());
// Change values
Shape shape = (Shape) geometryShape.clone();
ShapeController shape = (ShapeController) geometryShape.clone();
shape.setProperty("Type", ShapeType.Cylinder.toString());
Shape weirdShape = (Shape) geometryShape.clone();
ShapeController weirdShape = (ShapeController) geometryShape.clone();
shape.setProperty("Operator", OperatorType.Intersection.toString());
component.getGeometry().addEntity(shape);
......@@ -343,10 +343,10 @@ public class GeometryComponentTester {
public void checkCreation() {
// Create a shape
ShapeComponent geometryModel = new ShapeComponent();
ShapeMesh geometryModel = new ShapeMesh();
geometryModel.setProperty("Type", ShapeType.Sphere.toString());
AbstractView geometryView = new AbstractView();
Shape geometryShape = new Shape(geometryModel, geometryView);
ShapeController geometryShape = new ShapeController(geometryModel, geometryView);
// Create a new GeometryComponent
GeometryComponent geometry = new GeometryComponent();
......@@ -369,10 +369,10 @@ public class GeometryComponentTester {
public void checkCopying() {
// Create a shape
ShapeComponent geometryModel = new ShapeComponent();
ShapeMesh geometryModel = new ShapeMesh();
geometryModel.setProperty("Type", ShapeType.Sphere.toString());
AbstractView geometryView = new AbstractView();
Shape geometryShape = new Shape(geometryModel, geometryView);
ShapeController geometryShape = new ShapeController(geometryModel, geometryView);
GeometryComponent geometry = new GeometryComponent();
GeometryComponent cloneGeometry;
......@@ -385,15 +385,15 @@ public class GeometryComponentTester {
geometry.setName("Geometry name");
// Set up GeometryComponent-specific stuff
ShapeComponent sphereModel = new ShapeComponent();
ShapeMesh sphereModel = new ShapeMesh();
sphereModel.setProperty("Type", ShapeType.Sphere.toString());
AbstractView sphereView = new AbstractView();
Shape sphere1 = new Shape(sphereModel, sphereView);
ShapeController sphere1 = new ShapeController(sphereModel, sphereView);
ShapeComponent cubeModel = new ShapeComponent();
ShapeMesh cubeModel = new ShapeMesh();
cubeModel.setProperty("Operator", OperatorType.Union.toString());
AbstractView cubeView = new AbstractView();
Shape cube1 = new Shape(cubeModel, cubeView);
ShapeController cube1 = new ShapeController(cubeModel, cubeView);
geometry.getGeometry().addEntity(sphere1);
geometry.getGeometry().addEntity(cube1);
......
......@@ -12,26 +12,6 @@
*******************************************************************************/
package org.eclipse.ice.datastructures.test;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import javax.xml.bind.JAXBException;
import org.eclipse.ice.datastructures.ICEObject.ICEJAXBHandler;
import org.eclipse.ice.datastructures.form.GeometryComponent;
import org.eclipse.ice.viz.service.geometry.shapes.OperatorType;
import org.eclipse.ice.viz.service.geometry.shapes.ShapeType;
import org.eclipse.ice.viz.service.modeling.AbstractView;
import org.eclipse.ice.viz.service.modeling.Shape;
import org.eclipse.ice.viz.service.modeling.ShapeComponent;
import org.eclipse.ice.viz.service.modeling.Transformation;
import org.junit.Test;
/**
* <p>
* Checks the overall functionality of the geometry package and the interaction
......@@ -41,114 +21,118 @@ import org.junit.Test;
* @author Jay Jay Billings
*/
public class GeometryTester {
/**
* <p>
* Checks the functionality of exporting an entire CSG tree to XML
* </p>
*
* @throws IOException
* @throws JAXBException
* @throws NullPointerException
*
*/
@Test
public void checkCSGTree()
throws NullPointerException, JAXBException, IOException {
// Create a shape
ShapeComponent geometryModel = new ShapeComponent();
AbstractView geometryView = new AbstractView();
Shape geometryShape = new Shape(geometryModel, geometryView);
// Create the root GeometryComponent
GeometryComponent geometry = new GeometryComponent();
geometry.setGeometry(geometryShape);
geometry.setName("Root geometry");
geometry.setDescription("This here's a verr' fine geom'try structcha");
ICEJAXBHandler xmlHandler = new ICEJAXBHandler();
ArrayList<Class> classList = new ArrayList<Class>();
classList.add(GeometryComponent.class);
// Create the CSG elements
Shape union = (Shape) geometryShape.clone();
union.setProperty("Operator", OperatorType.Union.toString());
Shape intersection = (Shape) geometryShape.clone();
union.setProperty("Operator", OperatorType.Intersection.toString());
Shape complement = (Shape) geometryShape.clone();
complement.setProperty("OperatorType",
OperatorType.Complement.toString());
complement.setProperty("Operator", OperatorType.Complement.toString());
complement.setProperty("Description", "Official ICE shape");
Shape sphere1 = (Shape) geometryShape.clone();
sphere1.setProperty("Type", ShapeType.Sphere.toString());
Shape sphere2 = (Shape) geometryShape.clone();
sphere2.setProperty("Type", ShapeType.Sphere.toString());
Shape cube = (Shape) geometryShape.clone();
cube.setProperty("Type", ShapeType.Cube.toString());
Shape cone = (Shape) geometryShape.clone();
cone.setProperty("Type", ShapeType.Cone.toString());
Shape cylinder = (Shape) geometryShape.clone();
cylinder.setProperty("Type", ShapeType.Cylinder.toString());
// Edit the transformations
Transformation sphere1Transformation = sphere1.getTransformation();
Transformation sphere2Transformation = new Transformation();
Transformation intersectionTransformation = intersection
.getTransformation();
sphere1Transformation.setScale(0, 0, 2.0);
sphere1Transformation.setScale(1, 1, 2.0);
sphere1Transformation.setScale(2, 2, 2.0);
sphere2Transformation.setScale(2, 2, -4.5);
intersectionTransformation.setScale(3, 0, 2.0);
intersectionTransformation.setScale(3, 2, -1.5);
sphere1.setTransformation(sphere1Transformation);
sphere2.setTransformation(sphere2Transformation);
intersection.setTransformation(intersectionTransformation);
// Add some properties
intersection.setProperty("selected", "true");
union.setProperty("awesome?", "yes");
// Create the CSG tree
geometry.getGeometry().addEntity(union);
union.addEntity(complement);
union.addEntity(cone);
union.addEntity(cylinder);
complement.addEntity(cube);
complement.addEntity(intersection);
intersection.addEntity(sphere1);
intersection.addEntity(sphere2);
// Persist GeometryComponent to XML
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
xmlHandler.write(geometry, classList, outputStream);
// Print the XML output
// System.out.println(outputStream.toString());
ByteArrayInputStream inputStream = new ByteArrayInputStream(
outputStream.toByteArray());
// Load a new GeometryComponent from XML
GeometryComponent loadedGeometry = new GeometryComponent();
loadedGeometry = (GeometryComponent) xmlHandler.read(classList,
inputStream);
assertTrue(geometry.equals(loadedGeometry));
// Change one of the IShapes to check whether the two geometries are
// not equal
sphere1.setTransformation(new Transformation());
assertFalse(geometry.equals(loadedGeometry));
}
// TODO Reimplement this class in the event that XML persistence is ever
// reinstated for the geometry editor
// /**
// * <p>
// * Checks the functionality of exporting an entire CSG tree to XML
// * </p>
// *
// * @throws IOException
// * @throws JAXBException
// * @throws NullPointerException
// *