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
// * Copyright (c) 2014 UT-Battelle, LLC. /// UT-Battelle,LLC.*All rights reserved.This program and the accompanying
// * All rights reserved. This program and the accompanying materials /// materials*are made available under the terms of the Eclipse Public License
// * are made available under the terms of the Eclipse Public License v1.0 /// v1.0*which accompanies this distribution,and is available
// * which accompanies this distribution, and is available at /// at*http://www.eclipse.org/legal/epl-v10.html
// * 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
// * Contributors: /// J.McCaskey,Taylor Patterson,*Claire Saunders,Matthew Wang,Anna
// * Initial API and implementation and/or initial documentation - Jay Jay /// Wojtowicz*******************************************************************************/package
/// Billings, /// org.eclipse.ice.client.widgets.reactoreditor.plant;
// * 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 org.eclipse.ice.reactor.plant.HeatExchanger;
// //
// import com.jme3.bounding.BoundingBox; // import com.jme3.bounding.BoundingBox;import com.jme3.material.Material;import
// import com.jme3.material.Material; /// com.jme3.math.FastMath;import com.jme3.math.Quaternion;import
// import com.jme3.math.FastMath; /// com.jme3.math.Vector3f;import com.jme3.scene.Geometry;import
// import com.jme3.math.Quaternion; /// com.jme3.scene.shape.Box;
// import com.jme3.math.Vector3f; //
// import com.jme3.scene.Geometry; /// ***This
// import com.jme3.scene.shape.Box; //
// // class provides
/// ** // a view for a
// * This class provides a view for a {@link HeatExchanger}. This view provides //
/// a // {@link HeatExchanger}.
// * standard pipe as its primary pipe, but it also provides a {@link //
/// #container} // This view provides/a*
// * around the pipe and secondary input and output pipes that extend from the // standard pipe
// * container to their respective junctions.<br> // as its
// * <br> // primary pipe, but
// * <b>Operations in this class (not including the constructor) should be // it also
/// called // provides a
// * from a SimpleApplication's simpleUpdate() thread.</b> //
// {@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 // * @author Jordan H. Deyton
// * // *
......
...@@ -44,7 +44,7 @@ public class FXPlantCompositeConverter ...@@ -44,7 +44,7 @@ public class FXPlantCompositeConverter
* The scale which translates between RELAP7 units and JavaFX units. Each * The scale which translates between RELAP7 units and JavaFX units. Each
* RELAP7 unit will be treated as SCALE JavaFX units. * 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. * The root of the tree of plant parts converted from the source.
...@@ -163,6 +163,8 @@ public class FXPlantCompositeConverter ...@@ -163,6 +163,8 @@ public class FXPlantCompositeConverter
JunctionController junction = (JunctionController) factory JunctionController junction = (JunctionController) factory
.createController(mesh); .createController(mesh);
junction.setProperty("Name", plantComp.getName());
// Create a list of all pipes in the plant by combining the pipes // Create a list of all pipes in the plant by combining the pipes
// with the core channels // with the core channels
List<AbstractController> pipeList = root List<AbstractController> pipeList = root
...@@ -251,11 +253,10 @@ public class FXPlantCompositeConverter ...@@ -251,11 +253,10 @@ public class FXPlantCompositeConverter
pipeList.addAll( pipeList.addAll(
root.getEntitiesByCategory("Core Channels")); 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 // was added when visited, find the pipe with that id and
// add it // add it
for (AbstractController pipe : root for (AbstractController pipe : pipeList) {
.getEntitiesByCategory("Pipes")) {
if (Integer.parseInt(pipe.getProperty("Id")) == output if (Integer.parseInt(pipe.getProperty("Id")) == output
.getId()) { .getId()) {
junction.addEntityByCategory(pipe, "Output"); junction.addEntityByCategory(pipe, "Output");
...@@ -294,99 +295,103 @@ public class FXPlantCompositeConverter ...@@ -294,99 +295,103 @@ public class FXPlantCompositeConverter
@Override @Override
public void visit(HeatExchanger plantComp) { 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 // Create a new heat exchanger
HeatExchangerMesh mesh = new HeatExchangerMesh(); HeatExchangerMesh mesh = new HeatExchangerMesh(pipe);
HeatExchangerController heatExchanger = (HeatExchangerController) factory HeatExchangerController heatExchanger = (HeatExchangerController) factory
.createController(mesh); .createController(mesh);
// Get the primary pipe // // Get the primary pipe
Pipe primary = plantComp.getPrimaryPipe(); // Pipe primary = plantComp.getPrimaryPipe();
//
// Whether or not a match was found // // Whether or not a match was found
boolean found = false; // boolean found = false;
//
// Create a list of all pipes in the plant by combining the pipes // // Create a list of all pipes in the plant by combining the pipes
// with the core channels // // with the core channels
List<AbstractController> pipeList = root // List<AbstractController> pipeList = root
.getEntitiesByCategory("Pipes"); // .getEntitiesByCategory("Pipes");
pipeList.addAll(root.getEntitiesByCategory("Core Channels")); // pipeList.addAll(root.getEntitiesByCategory("Core Channels"));
//
// Check the root to see if a pipe with that id already exists // // Check the root to see if a pipe with that id already exists
for (AbstractController pipe : pipeList) { // for (AbstractController pipe : pipeList) {
if (Integer.parseInt(pipe.getProperty("Id")) == primary // if (Integer.parseInt(pipe.getProperty("Id")) == primary
.getId()) { // .getId()) {
//
// If found, set the pipe as the exchanger's primary // // If found, set the pipe as the exchanger's primary
heatExchanger.setPrimaryPipe((PipeController) pipe); // heatExchanger.setPrimaryPipe((PipeController) pipe);
//
// Match found, stop the search // // Match found, stop the search
found = true; // found = true;
break; // break;
} // }
} // }
//
// If a match was not found, create a new pipe // // If a match was not found, create a new pipe
if (!found) { // if (!found) {
//
// Convert the pipe into a modeling data structure // // Convert the pipe into a modeling data structure
// primary.accept(this); // // primary.accept(this);
source.getPlantComponent(primary.getId()).accept(this); // source.getPlantComponent(primary.getId()).accept(this);
//
// Refresh the list of pipes // // Refresh the list of pipes
pipeList = root.getEntitiesByCategory("Pipes"); // pipeList = root.getEntitiesByCategory("Pipes");
pipeList.addAll(root.getEntitiesByCategory("Core Channels")); // pipeList.addAll(root.getEntitiesByCategory("Core Channels"));
//
// Now that the pipe is guaranteed to be in the root, as it was // // 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 // // added when visited, find the pipe with that id and add it
for (AbstractController pipe : pipeList) { // for (AbstractController pipe : pipeList) {
if (Integer.parseInt(pipe.getProperty("Id")) == primary // if (Integer.parseInt(pipe.getProperty("Id")) == primary
.getId()) { // .getId()) {
heatExchanger.setPrimaryPipe((PipeController) pipe); // heatExchanger.setPrimaryPipe((PipeController) pipe);
break; // break;
} // }
} // }
} // }
//
// Get the secondary pipe // // Get the secondary pipe
Pipe secondary = plantComp.getSecondaryPipe(); // Pipe secondary = plantComp.getSecondaryPipe();
//
found = false; // found = false;
//
// Check the root to see if a pipe with that id already exists // // Check the root to see if a pipe with that id already exists
for (AbstractController pipe : pipeList) { // for (AbstractController pipe : pipeList) {
if (Integer.parseInt(pipe.getProperty("Id")) == secondary // if (Integer.parseInt(pipe.getProperty("Id")) == secondary
.getId()) { // .getId()) {
//
// If found, set the pipe as the exchanger's primary // // If found, set the pipe as the exchanger's primary
heatExchanger.setSecondaryPipe((PipeController) pipe); // heatExchanger.setSecondaryPipe((PipeController) pipe);
//
// Match found, stop the search // // Match found, stop the search
found = true; // found = true;
break; // break;
} // }
} // }
//
// If a match was not found, create a new pipe // // If a match was not found, create a new pipe
if (!found) { // if (!found) {
//
// Convert the pipe into a modeling data structure // // Convert the pipe into a modeling data structure
// primary.accept(this); // // primary.accept(this);
source.getPlantComponent(secondary.getId()).accept(this); // source.getPlantComponent(secondary.getId()).accept(this);
//
// Refresh the list of pipes // // Refresh the list of pipes
pipeList = root.getEntitiesByCategory("Pipes"); // pipeList = root.getEntitiesByCategory("Pipes");
pipeList.addAll(root.getEntitiesByCategory("Core Channels")); // pipeList.addAll(root.getEntitiesByCategory("Core Channels"));
//
// Now that the pipe is guaranteed to be in the root, as it was // // 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 // // added when visited, find the pipe with that id and add it
for (AbstractController pipe : pipeList) { // for (AbstractController pipe : pipeList) {
if (Integer.parseInt(pipe.getProperty("Id")) == secondary // if (Integer.parseInt(pipe.getProperty("Id")) == secondary
.getId()) { // .getId()) {
heatExchanger.setSecondaryPipe((PipeController) pipe); // heatExchanger.setSecondaryPipe((PipeController) pipe);
break; // break;
} // }
} // }
} // }
// Add the heat exchanger to the root // Add the heat exchanger to the root
root.addEntityByCategory(heatExchanger, "Heat Exchangers"); root.addEntityByCategory(heatExchanger, "Heat Exchangers");
...@@ -623,6 +628,8 @@ public class FXPlantCompositeConverter ...@@ -623,6 +628,8 @@ public class FXPlantCompositeConverter
mesh.setInnerRadius(plantComp.getRadius() * SCALE); mesh.setInnerRadius(plantComp.getRadius() * SCALE);
mesh.setAxialSamples(plantComp.getNumElements()); mesh.setAxialSamples(plantComp.getNumElements());
mesh.setProperty("Name", plantComp.getName());
// Create the view and controller // Create the view and controller
PipeController pipe = (PipeController) factory PipeController pipe = (PipeController) factory
.createController(mesh); .createController(mesh);
......
...@@ -24,12 +24,25 @@ import org.eclipse.ice.viz.service.modeling.AbstractMesh; ...@@ -24,12 +24,25 @@ import org.eclipse.ice.viz.service.modeling.AbstractMesh;
public class HeatExchangerMesh extends AbstractMesh { public class HeatExchangerMesh extends AbstractMesh {
/** /**
* The default constructor. * The nullary constructor.
*/ */
public HeatExchangerMesh() { public HeatExchangerMesh() {
super(); 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. * Convenience getter method for the primary pipe.
* *
......
...@@ -12,7 +12,7 @@ package org.eclipse.ice.viz.service.javafx.geometry; ...@@ -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.canvas.FXViewer;
import org.eclipse.ice.viz.service.javafx.internal.model.FXCameraAttachment; 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.ice.viz.service.javafx.scene.base.ICamera;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
...@@ -59,7 +59,7 @@ public class FXGeometryViewer extends FXViewer { ...@@ -59,7 +59,7 @@ public class FXGeometryViewer extends FXViewer {
} }
// Create a controller // Create a controller
cameraController = new CenteredController(fxCamera, scene, fxCanvas); cameraController = new CenteredCameraController(fxCamera, scene, fxCanvas);
// Set the camera on the scene // Set the camera on the scene
scene.setCamera(fxCamera); scene.setCamera(fxCamera);
......
...@@ -231,7 +231,14 @@ public class FXShapeView extends AbstractView implements IWireFramePart { ...@@ -231,7 +231,14 @@ public class FXShapeView extends AbstractView implements IWireFramePart {
break; break;
case Tube: case Tube:
// There is no conditional on Tubes as tubes are set to draw based // 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 // Cast the model as a PipeComponent and get the parameters
TubeMesh pipe = (TubeMesh) model; TubeMesh pipe = (TubeMesh) model;
int axialSamples = pipe.getAxialSamples(); int axialSamples = pipe.getAxialSamples();
...@@ -239,9 +246,15 @@ public class FXShapeView extends AbstractView implements IWireFramePart { ...@@ -239,9 +246,15 @@ public class FXShapeView extends AbstractView implements IWireFramePart {
double outerRadius = pipe.getRadius(); double outerRadius = pipe.getRadius();
double innerRadius = pipe.getInnerRadius(); 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 // Create the mesh
tubeShape = new FXTube(height, innerRadius, outerRadius, tubeShape = new FXTube(height, innerRadius, outerRadius,
axialSamples, 50); axialSamples, 10);
// Get the actual mesh and set it to a view // Get the actual mesh and set it to a view
TriangleMesh tubeMesh = tubeShape.getMesh(); TriangleMesh tubeMesh = tubeShape.getMesh();
...@@ -281,6 +294,7 @@ public class FXShapeView extends AbstractView implements IWireFramePart { ...@@ -281,6 +294,7 @@ public class FXShapeView extends AbstractView implements IWireFramePart {
else if (initial) { else if (initial) {
node.getChildren().add(shape); node.getChildren().add(shape);
} }
} }
/** /**
...@@ -295,6 +309,7 @@ public class FXShapeView extends AbstractView implements IWireFramePart { ...@@ -295,6 +309,7 @@ public class FXShapeView extends AbstractView implements IWireFramePart {
// Put the controller in the node's data structure // Put the controller in the node's data structure
node.getProperties().put(ShapeController.class, shape); node.getProperties().put(ShapeController.class, shape);
} }
/** /**
...@@ -327,6 +342,7 @@ public class FXShapeView extends AbstractView implements IWireFramePart { ...@@ -327,6 +342,7 @@ public class FXShapeView extends AbstractView implements IWireFramePart {
*/ */
@Override @Override
public Object getRepresentation() { public Object getRepresentation() {
return node; return node;
} }
...@@ -371,6 +387,7 @@ public class FXShapeView extends AbstractView implements IWireFramePart { ...@@ -371,6 +387,7 @@ public class FXShapeView extends AbstractView implements IWireFramePart {
gizmo.setVisible(false); gizmo.setVisible(false);
} }
} }
} }
} }
...@@ -426,6 +443,15 @@ public class FXShapeView extends AbstractView implements IWireFramePart { ...@@ -426,6 +443,15 @@ public class FXShapeView extends AbstractView implements IWireFramePart {
} else { } else {
shape.setDrawMode(DrawMode.FILL); 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 ...@@ -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.Extrema;
import org.eclipse.ice.viz.service.geometry.reactor.HeatExchangerMesh; 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.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.geometry.datatypes.FXTube;
import org.eclipse.ice.viz.service.javafx.internal.Util; import org.eclipse.ice.viz.service.javafx.internal.Util;
import org.eclipse.ice.viz.service.modeling.AbstractController; import org.eclipse.ice.viz.service.modeling.AbstractController;
...@@ -280,29 +279,30 @@ public class FXHeatExchangerView extends AbstractView ...@@ -280,29 +279,30 @@ public class FXHeatExchangerView extends AbstractView
node.getChildren().remove(secondaryInlet); node.getChildren().remove(secondaryInlet);
node.getChildren().remove(secondaryOutlet); 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 // Recolor the primary pipe to blue and add its mesh to the node
((FXPipeController) ((HeatExchangerMesh) model).getPrimaryPipe()) primaryPipeController.setMaterial(new PhongMaterial(Color.BLUE));
.setMaterial(new PhongMaterial(Color.BLUE)); primaryPipe = (Group) primaryPipeController.getRepresentation();
primaryPipe = (Group) ((HeatExchangerMesh) model).getPrimaryPipe()
.getRepresentation();
node.getChildren().add(primaryPipe); node.getChildren().add(primaryPipe);
// Create the wall around the primary pipe // Create the wall around the primary pipe
double wallSize = ((HeatExchangerMesh) model).getPrimaryPipe() double wallSize = primaryPipeController.getRadius() * 4;
.getRadius() * 4; wall = new Box(wallSize, primaryPipeController.getLength() * 0.8d,
wall = new Box(wallSize, ((PipeMesh) model).getLength() * 0.8d,
wallSize); wallSize);
// Create the secondary inlet // Create the secondary inlet
AbstractController inletJunction = ((HeatExchangerMesh) model) AbstractController inletJunction = model
.getSecondaryPipe().getEntitiesByCategory("Input").get(0);