Commit 10770a1f authored by amccaskey's avatar amccaskey
Browse files

Merge branch 'next' of https://github.com/eclipse/ice into next

parents bd78edcc 9a0f6536
......@@ -22,7 +22,7 @@ import org.eclipse.ice.viz.service.geometry.reactor.PipeController;
import org.eclipse.ice.viz.service.geometry.reactor.PipeMesh;
import org.eclipse.ice.viz.service.geometry.reactor.ReactorController;
import org.eclipse.ice.viz.service.geometry.reactor.ReactorMesh;
import org.eclipse.ice.viz.service.javafx.geometry.plant.FXPlantViewFactory;
import org.eclipse.ice.viz.service.javafx.geometry.plant.FXPlantViewControllerFactory;
import org.eclipse.ice.viz.service.javafx.geometry.plant.FXPlantViewRootController;
import org.eclipse.ice.viz.service.javafx.geometry.plant.IPlantData;
import org.eclipse.ice.viz.service.modeling.AbstractController;
......@@ -112,7 +112,7 @@ public class FXPlantCompositeConverter
/**
* The factory for constructing controllers and views for the meshs.
*/
FXPlantViewFactory factory;
FXPlantViewControllerFactory factory;
/**
* The default constructor.
......@@ -122,7 +122,7 @@ public class FXPlantCompositeConverter
*/
public FXPlantComponentVisitor(FXPlantViewRootController root) {
this.root = root;
factory = new FXPlantViewFactory();
factory = new FXPlantViewControllerFactory();
}
/**
......
......@@ -7,7 +7,9 @@ Fragment-Host: org.eclipse.ice.viz.service.javafx.geometry
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-Vendor: Oak Ridge National Laboratory
Eclipse-ExtensibleAPI: true
Import-Package: junit.framework;version="4.12.0",
Import-Package: javafx.scene;version="2.2.0",
junit.framework;version="4.12.0",
org.eclipse.ice.viz.service.geometry.reactor,
org.eclipse.ice.viz.service.modeling.test.utils,
org.hamcrest.core;version="1.3.0",
org.junit;version="4.12.0"
......
......@@ -35,6 +35,22 @@ import javafx.scene.Group;
*/
public class FXShapeControllerTester {
/**
* Check that FXShapeControllers can be properly cloned.
*/
@Test
public void checkClone() {
// Create a cloned FXShape and check that it is identical to the
// original
ShapeMesh mesh = new ShapeMesh();
FXShapeController shape = new FXShapeController(mesh,
new FXShapeView(mesh));
shape.setProperty("Test", "Property");
FXShapeController clone = (FXShapeController) shape.clone();
assertTrue(shape.equals(clone));
}
/**
* Test the FXShapeController's handling of the JavaFX Nodes' associations
* with ICE datastructures.
......
......@@ -33,6 +33,20 @@ import javafx.scene.shape.Sphere;
*/
public class FXShapeViewTester {
/**
* Test that FXShapeViews are cloned correctly
*/
@Test
public void checkClone() {
// Create a cloned view and check that it is identical to the original
ShapeMesh mesh = new ShapeMesh();
mesh.setProperty("Type", "Cube");
FXShapeView view = new FXShapeView(mesh);
FXShapeView clone = (FXShapeView) view.clone();
assertTrue(view.equals(clone));
}
/**
* Check that the view is constructed properly.
*/
......@@ -62,7 +76,7 @@ public class FXShapeViewTester {
assertTrue(((Shape3D) node).getDrawMode() == DrawMode.FILL);
// Check if a box has been found
if (view.getRepresentation() instanceof Box) {
if (node instanceof Box) {
boxFound = true;
}
}
......
......@@ -27,6 +27,24 @@ import org.junit.Test;
*/
public class FXHeatExchangerControllerTester {
/**
* Test that the FXHeatExchangerController is cloned correctly.
*/
@Test
public void checkClone() {
// Create a cloned FXHeatExchangerController and check that it is
// identical to the
// original
HeatExchangerMesh mesh = new HeatExchangerMesh();
FXHeatExchangerController exchanger = new FXHeatExchangerController(
mesh, new FXHeatExchangerView(mesh));
exchanger.setProperty("Test", "Property");
FXHeatExchangerController clone = (FXHeatExchangerController) exchanger
.clone();
assertTrue(exchanger.equals(clone));
}
/**
* Check that the exchanger will ignore Wireframe type messages except when
* they are sent by the controller's view.
......
......@@ -11,6 +11,7 @@
package org.eclipse.ice.viz.service.javafx.geometry.plant.test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import org.eclipse.ice.viz.service.geometry.reactor.HeatExchangerMesh;
import org.eclipse.ice.viz.service.geometry.reactor.JunctionController;
......@@ -36,6 +37,19 @@ import javafx.scene.shape.MeshView;
*/
public class FXHeatExchangerViewTester {
/**
* Test that FXHeatExchangerViews are cloned correctly
*/
@Test
public void checkClone() {
// Create a cloned view and check that it is identical to the original
HeatExchangerMesh mesh = new HeatExchangerMesh();
FXHeatExchangerView view = new FXHeatExchangerView(mesh);
FXHeatExchangerView clone = (FXHeatExchangerView) view.clone();
assertTrue(view.equals(clone));
}
/**
* Check that the view produces the correct JavaFX output.
*/
......
......@@ -12,6 +12,7 @@ package org.eclipse.ice.viz.service.javafx.geometry.plant.test;
import static org.junit.Assert.assertTrue;
import org.eclipse.ice.viz.service.geometry.reactor.JunctionController;
import org.eclipse.ice.viz.service.geometry.reactor.JunctionMesh;
import org.eclipse.ice.viz.service.geometry.reactor.PipeMesh;
import org.eclipse.ice.viz.service.javafx.geometry.plant.FXJunctionView;
......@@ -19,6 +20,10 @@ import org.eclipse.ice.viz.service.javafx.geometry.plant.FXPipeController;
import org.eclipse.ice.viz.service.javafx.geometry.plant.FXPipeView;
import org.junit.Test;
import javafx.scene.Group;
import javafx.scene.shape.DrawMode;
import javafx.scene.shape.Shape3D;
/**
* A class to test the functionality of FXJunctionView
*
......@@ -27,6 +32,19 @@ import org.junit.Test;
*/
public class FXJunctionViewTester {
/**
* Test that FXJunctionViews are cloned correctly
*/
@Test
public void checkClone() {
// Create a cloned view and check that it is identical to the original
JunctionMesh mesh = new JunctionMesh();
FXJunctionView view = new FXJunctionView(mesh);
FXJunctionView clone = (FXJunctionView) view.clone();
assertTrue(view.equals(clone));
}
/**
* Check that the junction is drawn in the right position to cover the ends
* of its pipes.
......@@ -37,6 +55,7 @@ public class FXJunctionViewTester {
// Create a view on a junction with no connecting pipes
JunctionMesh mesh = new JunctionMesh();
FXJunctionView view = new FXJunctionView(mesh);
JunctionController junction = new JunctionController(mesh, view);
// Check that the junction is centered at the origin by default
assertTrue(view.getCenter()[0] == 0d);
......@@ -46,17 +65,104 @@ public class FXJunctionViewTester {
// Create a pipe
PipeMesh pipeMesh = new PipeMesh();
pipeMesh.setLength(100);
pipeMesh.setInnerRadius(25);
pipeMesh.setRadius(25);
pipeMesh.setInnerRadius(5);
pipeMesh.setRadius(5);
pipeMesh.setAxialSamples(3);
FXPipeView pipeView = new FXPipeView(pipeMesh);
FXPipeController pipe = new FXPipeController(pipeMesh, pipeView);
// Add the pipe as input
mesh.addEntityByCategory(pipe, "Input");
junction.addEntityByCategory(pipe, "Input");
// The junction's center point
double[] center = view.getCenter();
// Since the pipe is an input to the junction, it will be centered about
// the pipe's upper edge, at (0, 50, 0).
assertTrue(Math.abs(center[0] - 0d) < 1);
assertTrue(Math.abs(center[1] - 50d) < 1);
assertTrue(Math.abs(center[2] - 0d) < 1);
// Add the other end of the pipe to the junction, so that the junction
// is completely enveloping the pipe
junction.addEntityByCategory(pipe, "Output");
// The junction should now be centered at the origin, as it is a
// rectangular bounding box around the pipe which is also centered on
// the origin
center = view.getCenter();
assertTrue(Math.abs(center[0] - 0d) < 1);
assertTrue(Math.abs(center[1] - 0d) < 1);
assertTrue(Math.abs(center[2] - 0d) < 1);
// Set the junction to only have the pipe as output
junction.removeEntity(pipe);
junction.addEntityByCategory(pipe, "Output");
// The junction should centered on the other side of the pipe, at (0,
// -50, 0)
center = view.getCenter();
assertTrue(Math.abs(center[0] - 0d) < 1);
assertTrue(Math.abs(center[1] - -50d) < 1);
assertTrue(Math.abs(center[2] - 0d) < 1);
// Rotate the pipe 90 degrees about the x axis.
pipe.setRotation(Math.PI / 2, 0, 0);
// The pipe should now be lying on its side, with the mouth at (0, 0,
// -50)
center = view.getCenter();
assertTrue(Math.abs(center[0] - 0d) < 1);
assertTrue(Math.abs(center[1] - 0d) < 1);
assertTrue(Math.abs(center[2] - -50d) < 1);
// Create a second pipe
PipeMesh pipeMesh2 = new PipeMesh();
pipeMesh2.setLength(100);
pipeMesh2.setInnerRadius(5);
pipeMesh2.setRadius(5);
pipeMesh2.setAxialSamples(3);
FXPipeView pipeView2 = new FXPipeView(pipeMesh2);
FXPipeController pipe2 = new FXPipeController(pipeMesh2, pipeView2);
// Set the pipe as input
junction.addEntityByCategory(pipe2, "Input");
// The junction is now covering two circles of radius 5, one centered
// on (0, 50, 0) on the XZ plane and the other centered on (0, 0, 50) on
// the XY plane. Thus the center should be at (0, 12.5, -12.5)
center = view.getCenter();
assertTrue(Math.abs(center[0] - 0) < 1);
assertTrue(Math.abs(center[1] - 22.5d) < 1);
assertTrue(Math.abs(center[2] - -22.5d) < 1);
}
/**
* Test that the view's representation is set to the proper draw mode for
* wireframe drawing.
*/
@Test
public void checkWireframe() {
// Create a view on a junction with no connecting pipes
JunctionMesh mesh = new JunctionMesh();
FXJunctionView view = new FXJunctionView(mesh);
JunctionController junction = new JunctionController(mesh, view);
// The box should be solid by default
assertTrue(((Shape3D) ((Group) junction.getRepresentation())
.getChildren().get(0)).getDrawMode() == DrawMode.FILL);
System.out.println(view.getCenter());
// Set the junction to wireframe mode and check that the box is drawn
// correctly
junction.setWireFrameMode(true);
assertTrue(((Shape3D) ((Group) junction.getRepresentation())
.getChildren().get(0)).getDrawMode() == DrawMode.LINE);
// Turn off wireframe mode and check that the box has been returned to
// normal
junction.setWireFrameMode(false);
assertTrue(((Shape3D) ((Group) junction.getRepresentation())
.getChildren().get(0)).getDrawMode() == DrawMode.FILL);
}
}
/*******************************************************************************
* Copyright (c) 2016 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:
* Robert Smith
*******************************************************************************/
package org.eclipse.ice.viz.service.javafx.geometry.plant.test;
import static org.junit.Assert.assertTrue;
import org.eclipse.ice.viz.service.geometry.reactor.Extrema;
import org.eclipse.ice.viz.service.geometry.reactor.PipeMesh;
import org.eclipse.ice.viz.service.javafx.geometry.plant.FXPipeController;
import org.eclipse.ice.viz.service.javafx.geometry.plant.FXPipeView;
import org.junit.Test;
/**
* A class to test the functionality of the FXPipeView.
*
* @author Robert Smith
*
*/
public class FXPipeViewTester {
/**
* Test that FXPipeViews are cloned correctly
*/
@Test
public void checkClone() {
// Create a cloned view and check that it is identical to the original
PipeMesh mesh = new PipeMesh();
mesh.setLength(100);
mesh.setInnerRadius(5);
mesh.setRadius(5);
mesh.setAxialSamples(3);
FXPipeView view = new FXPipeView(mesh);
FXPipeView clone = (FXPipeView) view.clone();
assertTrue(view.equals(clone));
}
/**
* Check that a pipe returns the bounds of its ends correctly
*/
@Test
public void checkExtrema() {
// Create a pipe
PipeMesh pipeMesh = new PipeMesh();
pipeMesh.setLength(100);
pipeMesh.setInnerRadius(5);
pipeMesh.setRadius(5);
pipeMesh.setAxialSamples(3);
FXPipeView pipeView = new FXPipeView(pipeMesh);
FXPipeController pipe = new FXPipeController(pipeMesh, pipeView);
// The top end of the pipe is a radius 5 circle centered at (0, 50, 0)
Extrema top = pipe.getUpperExtrema();
assertTrue(Math.abs(top.getMaxX() - 5d) < 1);
assertTrue(Math.abs(top.getMinX() - -5d) < 1);
assertTrue(Math.abs(top.getMaxY() - 50d) < 1);
assertTrue(Math.abs(top.getMinY() - 50d) < 1);
assertTrue(Math.abs(top.getMaxZ() - 5d) < 1);
assertTrue(Math.abs(top.getMinZ() - -5d) < 1);
// The bottom end of the pipe is a radius 5 circle centered at (0, -50,
// 0)
Extrema bottom = pipe.getLowerExtrema();
assertTrue(Math.abs(bottom.getMaxX() - 5d) < 1);
assertTrue(Math.abs(bottom.getMinX() - -5d) < 1);
assertTrue(Math.abs(bottom.getMaxY() - -50d) < 1);
assertTrue(Math.abs(bottom.getMinY() - -50d) < 1);
assertTrue(Math.abs(bottom.getMaxZ() - 5d) < 1);
assertTrue(Math.abs(bottom.getMinZ() - -5d) < 1);
// Move the pipe
pipe.setTranslation(1, 2, 3);
// The top end of the pipe is a radius 5 circle centered at (1, 52, 3)
top = pipe.getUpperExtrema();
assertTrue(Math.abs(top.getMaxX() - 6d) < 1);
assertTrue(Math.abs(top.getMinX() - -4d) < 1);
assertTrue(Math.abs(top.getMaxY() - 52d) < 1);
assertTrue(Math.abs(top.getMinY() - 52d) < 1);
assertTrue(Math.abs(top.getMaxZ() - 8d) < 1);
assertTrue(Math.abs(top.getMinZ() - -2d) < 1);
// The bottom end of the pipe is a radius 5 circle centered at (1, -48,
// 3)
bottom = pipe.getLowerExtrema();
assertTrue(Math.abs(bottom.getMaxX() - 6d) < 1);
assertTrue(Math.abs(bottom.getMinX() - -4d) < 1);
assertTrue(Math.abs(bottom.getMaxY() - -48d) < 1);
assertTrue(Math.abs(bottom.getMinY() - -48d) < 1);
assertTrue(Math.abs(bottom.getMaxZ() - 8d) < 1);
assertTrue(Math.abs(bottom.getMinZ() - -2d) < 1);
// Return the pipe to the origin and scale it
pipe.setTranslation(0, 0, 0);
pipe.setScale(2, 3, 4);
// The top end of the pipe is an ellipse with a major axis of 20 and a
// minor axis of 10, centered on (0, 150, 0)
top = pipe.getUpperExtrema();
assertTrue(Math.abs(top.getMaxX() - 10d) < 1);
assertTrue(Math.abs(top.getMinX() - -10d) < 1);
assertTrue(Math.abs(top.getMaxY() - 150d) < 1);
assertTrue(Math.abs(top.getMinY() - 150d) < 1);
assertTrue(Math.abs(top.getMaxZ() - 20d) < 1);
assertTrue(Math.abs(top.getMinZ() - -20d) < 1);
// The bottome end of the pipe is an ellipse with a major axis of 20 and
// a minor axis of 10, centered on (0, -150, 0)
bottom = pipe.getLowerExtrema();
assertTrue(Math.abs(bottom.getMaxX() - 10d) < 1);
assertTrue(Math.abs(bottom.getMinX() - -10d) < 1);
assertTrue(Math.abs(bottom.getMaxY() - -150d) < 1);
assertTrue(Math.abs(bottom.getMinY() - -150d) < 1);
assertTrue(Math.abs(bottom.getMaxZ() - 20d) < 1);
assertTrue(Math.abs(bottom.getMinZ() - -20d) < 1);
// Return the pipe to its default scale and rotate it 90 degrees about
// the x axis.
pipe.setScale(1, 1, 1);
pipe.setRotation(Math.PI / 2, 0, 0);
// The top end of the pipe is a circle with radius 5 centered on (0, 0,
// 50)
top = pipe.getUpperExtrema();
assertTrue(Math.abs(top.getMaxX() - 5d) < 1);
assertTrue(Math.abs(top.getMinX() - -5d) < 1);
assertTrue(Math.abs(top.getMaxY() - 5d) < 1);
assertTrue(Math.abs(top.getMinY() - -5d) < 1);
assertTrue(Math.abs(top.getMaxZ() - 50d) < 1);
assertTrue(Math.abs(top.getMinZ() - 50d) < 1);
// The bottom end of the pipe is a circle with radius 5 centered on (0,
// 0, -50)
bottom = pipe.getLowerExtrema();
assertTrue(Math.abs(bottom.getMaxX() - 5d) < 1);
assertTrue(Math.abs(bottom.getMinX() - -5d) < 1);
assertTrue(Math.abs(bottom.getMaxY() - 5d) < 1);
assertTrue(Math.abs(bottom.getMinY() - -5d) < 1);
assertTrue(Math.abs(bottom.getMaxZ() - -50d) < 1);
assertTrue(Math.abs(bottom.getMinZ() - -50d) < 1);
}
}
/*******************************************************************************
* Copyright (c) 2016 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:
* Robert Smith
*******************************************************************************/
package org.eclipse.ice.viz.service.javafx.geometry.plant.test;
import org.eclipse.ice.viz.service.geometry.reactor.HeatExchangerMesh;
import org.eclipse.ice.viz.service.geometry.reactor.JunctionController;
import org.eclipse.ice.viz.service.geometry.reactor.JunctionMesh;
import org.eclipse.ice.viz.service.geometry.reactor.PipeMesh;
import org.eclipse.ice.viz.service.geometry.reactor.ReactorController;
import org.eclipse.ice.viz.service.geometry.reactor.ReactorMesh;
import org.eclipse.ice.viz.service.javafx.geometry.plant.FXHeatExchangerController;
import org.eclipse.ice.viz.service.javafx.geometry.plant.FXPipeController;
import org.eclipse.ice.viz.service.javafx.geometry.plant.FXPlantViewControllerFactory;
import org.junit.Test;
/**
* A class to test the functionality of the FXPlantViewFactory
*
* @author Robert Smith
*
*/
public class FXPlantViewControllerFactoryTester {
/**
* Check that the factory produces the correct types of output.
*/
@Test
public void checkCreation() {
// The factory to test
FXPlantViewControllerFactory factory = new FXPlantViewControllerFactory();
// A HeatExchangerMesh should be given a FXHeatExchangerController
HeatExchangerMesh heatExchangerMesh = new HeatExchangerMesh();
FXHeatExchangerController exchanger = (FXHeatExchangerController) factory
.createController(heatExchangerMesh);
// A JunctionMesh should be given a JunctionController
JunctionMesh junctionMesh = new JunctionMesh();
JunctionController junction = (JunctionController) factory
.createController(junctionMesh);
// A PipeMesh should be given a FXPipeController
PipeMesh pipeMesh = new PipeMesh();
FXPipeController pipeController = (FXPipeController) factory
.createController(pipeMesh);
// A ReactorMesh should be given a ReactorController
ReactorMesh reactorMesh = new ReactorMesh();
ReactorController reactorController = (ReactorController) factory
.createController(reactorMesh);
}
}
/*******************************************************************************
* Copyright (c) 2016 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:
* Robert Smith
*******************************************************************************/
package org.eclipse.ice.viz.service.javafx.geometry.plant.test;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.eclipse.ice.viz.service.geometry.reactor.PipeMesh;