Commit 0df390e4 authored by Robert Smith's avatar Robert Smith
Browse files

Fixed Plant View bugs



Fixed bugs with the Plant View, including an issue with the converter
hooking up core channels to junctions and FXPipeViews not removing old
renderings of themselves from the scene graph. Also started changing the
HeatExchanger to work without having to be given child pipes.
Signed-off-by: Robert Smith's avatarRobert Smith <SmithRW@ornl.gov>
parent 4d0caa68
/// *******************************************************************************
// * Copyright (c) 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.reactoreditor.plant;
/// ********************************************************************************Copyright(c)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.reactoreditor.plant;
//
// import org.eclipse.ice.reactor.plant.HeatExchanger;
//
// import com.jme3.bounding.BoundingBox;
// import com.jme3.material.Material;
// import com.jme3.math.FastMath;
// import com.jme3.math.Quaternion;
// import com.jme3.math.Vector3f;
// import com.jme3.scene.Geometry;
// import com.jme3.scene.shape.Box;
//
/// **
// * This class provides a view for a {@link HeatExchanger}. This view provides
/// a
// * standard pipe as its primary pipe, but it also provides a {@link
/// #container}
// * around the pipe and secondary input and output pipes that extend from the
// * container to their respective junctions.<br>
// * <br>
// * <b>Operations in this class (not including the constructor) should be
/// called
// * from a SimpleApplication's simpleUpdate() thread.</b>
// import com.jme3.bounding.BoundingBox;import com.jme3.material.Material;import
/// com.jme3.math.FastMath;import com.jme3.math.Quaternion;import
/// com.jme3.math.Vector3f;import com.jme3.scene.Geometry;import
/// com.jme3.scene.shape.Box;
//
/// ***This
//
// class provides
// a view for a
//
// {@link HeatExchanger}.
//
// This view provides/a*
// standard pipe
// as its
// primary pipe, but
// it also
// provides a
//
// {@link
/// #container}*
//
// around the
// pipe and
// secondary input
// and output
// pipes that
// extend from the*
// container to
// their respective junctions.<br>*<br>*<b>
// Operations in this class(
// not including
// the constructor)
// should be/called*
// from a SimpleApplication's
//
// simpleUpdate() thread.</b>
// *
// * @author Jordan H. Deyton
// *
......
......@@ -44,7 +44,7 @@ public class FXPlantCompositeConverter
* The scale which translates between RELAP7 units and JavaFX units. Each
* RELAP7 unit will be treated as SCALE JavaFX units.
*/
private final int SCALE = 25;
private final int SCALE = 50;
/**
* The root of the tree of plant parts converted from the source.
......@@ -163,6 +163,8 @@ public class FXPlantCompositeConverter
JunctionController junction = (JunctionController) factory
.createController(mesh);
junction.setProperty("Name", plantComp.getName());
// Create a list of all pipes in the plant by combining the pipes
// with the core channels
List<AbstractController> pipeList = root
......@@ -251,11 +253,10 @@ public class FXPlantCompositeConverter
pipeList.addAll(
root.getEntitiesByCategory("Core Channels"));
// Now that the pipe is gauranteed to be in the root, as it
// Now that the pipe is guaranteed to be in the root, as it
// was added when visited, find the pipe with that id and
// add it
for (AbstractController pipe : root
.getEntitiesByCategory("Pipes")) {
for (AbstractController pipe : pipeList) {
if (Integer.parseInt(pipe.getProperty("Id")) == output
.getId()) {
junction.addEntityByCategory(pipe, "Output");
......@@ -294,99 +295,103 @@ public class FXPlantCompositeConverter
@Override
public void visit(HeatExchanger plantComp) {
// Heat Exchangers require a contained primary pipe, so create one
// for it.
PipeController pipe = createPipe(plantComp.getPrimaryPipe());
// Create a new heat exchanger
HeatExchangerMesh mesh = new HeatExchangerMesh();
HeatExchangerMesh mesh = new HeatExchangerMesh(pipe);
HeatExchangerController heatExchanger = (HeatExchangerController) factory
.createController(mesh);
// Get the primary pipe
Pipe primary = plantComp.getPrimaryPipe();
// Whether or not a match was found
boolean found = false;
// Create a list of all pipes in the plant by combining the pipes
// with the core channels
List<AbstractController> pipeList = root
.getEntitiesByCategory("Pipes");
pipeList.addAll(root.getEntitiesByCategory("Core Channels"));
// Check the root to see if a pipe with that id already exists
for (AbstractController pipe : pipeList) {
if (Integer.parseInt(pipe.getProperty("Id")) == primary
.getId()) {
// If found, set the pipe as the exchanger's primary
heatExchanger.setPrimaryPipe((PipeController) pipe);
// Match found, stop the search
found = true;
break;
}
}
// If a match was not found, create a new pipe
if (!found) {
// Convert the pipe into a modeling data structure
// primary.accept(this);
source.getPlantComponent(primary.getId()).accept(this);
// Refresh the list of pipes
pipeList = root.getEntitiesByCategory("Pipes");
pipeList.addAll(root.getEntitiesByCategory("Core Channels"));
// Now that the pipe is guaranteed to be in the root, as it was
// added when visited, find the pipe with that id and add it
for (AbstractController pipe : pipeList) {
if (Integer.parseInt(pipe.getProperty("Id")) == primary
.getId()) {
heatExchanger.setPrimaryPipe((PipeController) pipe);
break;
}
}
}
// Get the secondary pipe
Pipe secondary = plantComp.getSecondaryPipe();
found = false;
// Check the root to see if a pipe with that id already exists
for (AbstractController pipe : pipeList) {
if (Integer.parseInt(pipe.getProperty("Id")) == secondary
.getId()) {
// If found, set the pipe as the exchanger's primary
heatExchanger.setSecondaryPipe((PipeController) pipe);
// Match found, stop the search
found = true;
break;
}
}
// If a match was not found, create a new pipe
if (!found) {
// Convert the pipe into a modeling data structure
// primary.accept(this);
source.getPlantComponent(secondary.getId()).accept(this);
// Refresh the list of pipes
pipeList = root.getEntitiesByCategory("Pipes");
pipeList.addAll(root.getEntitiesByCategory("Core Channels"));
// Now that the pipe is guaranteed to be in the root, as it was
// added when visited, find the pipe with that id and add it
for (AbstractController pipe : pipeList) {
if (Integer.parseInt(pipe.getProperty("Id")) == secondary
.getId()) {
heatExchanger.setSecondaryPipe((PipeController) pipe);
break;
}
}
}
// // Get the primary pipe
// Pipe primary = plantComp.getPrimaryPipe();
//
// // Whether or not a match was found
// boolean found = false;
//
// // Create a list of all pipes in the plant by combining the pipes
// // with the core channels
// List<AbstractController> pipeList = root
// .getEntitiesByCategory("Pipes");
// pipeList.addAll(root.getEntitiesByCategory("Core Channels"));
//
// // Check the root to see if a pipe with that id already exists
// for (AbstractController pipe : pipeList) {
// if (Integer.parseInt(pipe.getProperty("Id")) == primary
// .getId()) {
//
// // If found, set the pipe as the exchanger's primary
// heatExchanger.setPrimaryPipe((PipeController) pipe);
//
// // Match found, stop the search
// found = true;
// break;
// }
// }
//
// // If a match was not found, create a new pipe
// if (!found) {
//
// // Convert the pipe into a modeling data structure
// // primary.accept(this);
// source.getPlantComponent(primary.getId()).accept(this);
//
// // Refresh the list of pipes
// pipeList = root.getEntitiesByCategory("Pipes");
// pipeList.addAll(root.getEntitiesByCategory("Core Channels"));
//
// // Now that the pipe is guaranteed to be in the root, as it was
// // added when visited, find the pipe with that id and add it
// for (AbstractController pipe : pipeList) {
// if (Integer.parseInt(pipe.getProperty("Id")) == primary
// .getId()) {
// heatExchanger.setPrimaryPipe((PipeController) pipe);
// break;
// }
// }
// }
//
// // Get the secondary pipe
// Pipe secondary = plantComp.getSecondaryPipe();
//
// found = false;
//
// // Check the root to see if a pipe with that id already exists
// for (AbstractController pipe : pipeList) {
// if (Integer.parseInt(pipe.getProperty("Id")) == secondary
// .getId()) {
//
// // If found, set the pipe as the exchanger's primary
// heatExchanger.setSecondaryPipe((PipeController) pipe);
//
// // Match found, stop the search
// found = true;
// break;
// }
// }
//
// // If a match was not found, create a new pipe
// if (!found) {
//
// // Convert the pipe into a modeling data structure
// // primary.accept(this);
// source.getPlantComponent(secondary.getId()).accept(this);
//
// // Refresh the list of pipes
// pipeList = root.getEntitiesByCategory("Pipes");
// pipeList.addAll(root.getEntitiesByCategory("Core Channels"));
//
// // Now that the pipe is guaranteed to be in the root, as it was
// // added when visited, find the pipe with that id and add it
// for (AbstractController pipe : pipeList) {
// if (Integer.parseInt(pipe.getProperty("Id")) == secondary
// .getId()) {
// heatExchanger.setSecondaryPipe((PipeController) pipe);
// break;
// }
// }
// }
// Add the heat exchanger to the root
root.addEntityByCategory(heatExchanger, "Heat Exchangers");
......@@ -623,6 +628,8 @@ public class FXPlantCompositeConverter
mesh.setInnerRadius(plantComp.getRadius() * SCALE);
mesh.setAxialSamples(plantComp.getNumElements());
mesh.setProperty("Name", plantComp.getName());
// Create the view and controller
PipeController pipe = (PipeController) factory
.createController(mesh);
......
......@@ -24,12 +24,25 @@ import org.eclipse.ice.viz.service.modeling.AbstractMesh;
public class HeatExchangerMesh extends AbstractMesh {
/**
* The default constructor.
* The nullary constructor.
*/
public HeatExchangerMesh() {
super();
}
/**
* The default constructor
*
* @param primary
* The heat exchanger's primary pipe.
*/
public HeatExchangerMesh(PipeController primary) {
this();
// Add the primary pipe to its category
setPrimaryPipe(primary);
}
/**
* Convenience getter method for the primary pipe.
*
......
......@@ -12,7 +12,7 @@ package org.eclipse.ice.viz.service.javafx.geometry;
import org.eclipse.ice.viz.service.javafx.canvas.FXViewer;
import org.eclipse.ice.viz.service.javafx.internal.model.FXCameraAttachment;
import org.eclipse.ice.viz.service.javafx.internal.scene.camera.CenteredController;
import org.eclipse.ice.viz.service.javafx.internal.scene.camera.CenteredCameraController;
import org.eclipse.ice.viz.service.javafx.scene.base.ICamera;
import org.eclipse.swt.widgets.Composite;
......@@ -59,7 +59,7 @@ public class FXGeometryViewer extends FXViewer {
}
// Create a controller
cameraController = new CenteredController(fxCamera, scene, fxCanvas);
cameraController = new CenteredCameraController(fxCamera, scene, fxCanvas);
// Set the camera on the scene
scene.setCamera(fxCamera);
......
......@@ -231,7 +231,14 @@ public class FXShapeView extends AbstractView implements IWireFramePart {
break;
case Tube:
// There is no conditional on Tubes as tubes are set to draw based
// on information from the model's properties
// on information from the model's properties, and thus may require
// redrawing even without a change in type.
// Get the previous shape, if any
if (shape != null) {
prevShape = shape;
}
// Cast the model as a PipeComponent and get the parameters
TubeMesh pipe = (TubeMesh) model;
int axialSamples = pipe.getAxialSamples();
......@@ -239,9 +246,15 @@ public class FXShapeView extends AbstractView implements IWireFramePart {
double outerRadius = pipe.getRadius();
double innerRadius = pipe.getInnerRadius();
// If the number of axial samples is less than 3 the tube cannot be
// created.
if (axialSamples < 3) {
axialSamples = 3;
}
// Create the mesh
tubeShape = new FXTube(height, innerRadius, outerRadius,
axialSamples, 50);
axialSamples, 10);
// Get the actual mesh and set it to a view
TriangleMesh tubeMesh = tubeShape.getMesh();
......@@ -281,6 +294,7 @@ public class FXShapeView extends AbstractView implements IWireFramePart {
else if (initial) {
node.getChildren().add(shape);
}
}
/**
......@@ -295,6 +309,7 @@ public class FXShapeView extends AbstractView implements IWireFramePart {
// Put the controller in the node's data structure
node.getProperties().put(ShapeController.class, shape);
}
/**
......@@ -327,6 +342,7 @@ public class FXShapeView extends AbstractView implements IWireFramePart {
*/
@Override
public Object getRepresentation() {
return node;
}
......@@ -371,6 +387,7 @@ public class FXShapeView extends AbstractView implements IWireFramePart {
gizmo.setVisible(false);
}
}
}
}
......@@ -426,6 +443,15 @@ public class FXShapeView extends AbstractView implements IWireFramePart {
} else {
shape.setDrawMode(DrawMode.FILL);
}
//
// node.getChildren().clear();
// node.getChildren().add(shape);
// Notify listeners of the change
UpdateableSubscriptionType[] eventTypes = {
UpdateableSubscriptionType.Property };
updateManager.notifyListeners(eventTypes);
}
}
......@@ -15,7 +15,6 @@ import org.eclipse.ice.viz.service.datastructures.VizObject.UpdateableSubscripti
import org.eclipse.ice.viz.service.geometry.reactor.Extrema;
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.PipeMesh;
import org.eclipse.ice.viz.service.javafx.geometry.datatypes.FXTube;
import org.eclipse.ice.viz.service.javafx.internal.Util;
import org.eclipse.ice.viz.service.modeling.AbstractController;
......@@ -280,29 +279,30 @@ public class FXHeatExchangerView extends AbstractView
node.getChildren().remove(secondaryInlet);
node.getChildren().remove(secondaryOutlet);
// Get a reference to the primary pipe
FXPipeController primaryPipeController = (FXPipeController) ((HeatExchangerMesh) model)
.getPrimaryPipe();
// Recolor the primary pipe to blue and add its mesh to the node
((FXPipeController) ((HeatExchangerMesh) model).getPrimaryPipe())
.setMaterial(new PhongMaterial(Color.BLUE));
primaryPipe = (Group) ((HeatExchangerMesh) model).getPrimaryPipe()
.getRepresentation();
primaryPipeController.setMaterial(new PhongMaterial(Color.BLUE));
primaryPipe = (Group) primaryPipeController.getRepresentation();
node.getChildren().add(primaryPipe);
// Create the wall around the primary pipe
double wallSize = ((HeatExchangerMesh) model).getPrimaryPipe()
.getRadius() * 4;
wall = new Box(wallSize, ((PipeMesh) model).getLength() * 0.8d,
double wallSize = primaryPipeController.getRadius() * 4;
wall = new Box(wallSize, primaryPipeController.getLength() * 0.8d,
wallSize);
// Create the secondary inlet
AbstractController inletJunction = ((HeatExchangerMesh) model)
.getSecondaryPipe().getEntitiesByCategory("Input").get(0);
AbstractController inletJunction = model
.getEntitiesByCategory("Secondary Input").get(0);
secondaryInlet = createTubeToPoint(
((JunctionController) inletJunction).getCenter(),
(HeatExchangerMesh) model);
// Create the secondary outlet
AbstractController outletJunction = ((HeatExchangerMesh) model)
.getSecondaryPipe().getEntitiesByCategory("Output").get(0);
AbstractController outletJunction = model
.getEntitiesByCategory("Secondary Output").get(0);
secondaryOutlet = createTubeToPoint(
((JunctionController) outletJunction).getCenter(),
(HeatExchangerMesh) model);
......
......@@ -49,6 +49,12 @@ public class FXJunctionView extends JunctionView implements IWireFramePart {
*/
PhongMaterial material;
/**
* Whether or not to display the junction in wireframe mode. It will be in
* wireframe mode if true or drawn regularly if false.
*/
boolean wireframe;
/**
* The nullary constructor.
*/
......@@ -58,6 +64,7 @@ public class FXJunctionView extends JunctionView implements IWireFramePart {
// Initialize the date members
node = new Group();
material = new PhongMaterial(Color.GRAY);
wireframe = false;
}
/**
......@@ -74,6 +81,7 @@ public class FXJunctionView extends JunctionView implements IWireFramePart {
node = new Group();
node.setId(model.getProperty("Name"));
material = new PhongMaterial(Color.GRAY);
wireframe = false;
// Initialize the mesh
createMesh(model);
......@@ -113,10 +121,10 @@ public class FXJunctionView extends JunctionView implements IWireFramePart {
centerY = Math.max(boxBounds.getMaxY() - boxBounds.getMinY(), 1);
centerZ = Math.max(boxBounds.getMaxZ() - boxBounds.getMinZ(), 1);
// Create a box which fills the box bounds, adding 1 to each dimension
// Create a box which fills the box bounds, adding 2 to each dimension
// to give enough space between the meshes that they won't clip through
// each other.
box = new Box(centerX + 1, centerY + 1, centerZ + 1);
box = new Box(centerX + 3, centerY + 3, centerZ + 3);
// Move the box to the center of the bounded area
box.setTranslateX((boxBounds.getMaxX() - boxBounds.getMinX()) / 2
......@@ -129,6 +137,13 @@ public class FXJunctionView extends JunctionView implements IWireFramePart {
// Add the box to the scene and set its material
node.getChildren().add(box);
box.setMaterial(material);
// Set the box to the correct wireframe mode
if (wireframe) {
box.setDrawMode(DrawMode.LINE);
} else {
box.setDrawMode(DrawMode.FILL);
}
}
/*
......@@ -168,6 +183,9 @@ public class FXJunctionView extends JunctionView implements IWireFramePart {
@Override
public void setWireFrameMode(boolean on) {
// Save the new state
wireframe = on;
// Set the box to the proper mode
if (on) {
box.setDrawMode(DrawMode.LINE);
......
......@@ -13,14 +13,11 @@ package org.eclipse.ice.viz.service.javafx.geometry.plant;
import org.eclipse.ice.viz.service.geometry.reactor.Extrema;
import org.eclipse.ice.viz.service.geometry.reactor.PipeMesh;
import org.eclipse.ice.viz.service.geometry.reactor.PipeView;