Commit 80adb4d9 authored by Robert Smith's avatar Robert Smith
Browse files

Moved plant conversion code



Refactored the conversion from ICE Components to JavaFX data structures
so that the ICE packages depend on the viz.service.* packages, instead
of the other way around. 
Signed-off-by: Robert Smith's avatarRobert Smith <SmithRW@ornl.gov>
parent 77549fb1
......@@ -33,6 +33,7 @@ Import-Package: org.apache.commons.io;version="2.0.1",
org.eclipse.ice.reactor.plant,
org.eclipse.ice.viz.service,
org.eclipse.ice.viz.service.javafx.geometry,
org.eclipse.ice.viz.service.javafx.geometry.plant,
org.eclipse.jgit.api;version="4.0.0",
org.eclipse.jgit.api.errors;version="4.0.0",
org.eclipse.ui,
......
......@@ -35,9 +35,9 @@ import org.eclipse.ice.datastructures.form.TreeComposite;
import org.eclipse.ice.datastructures.resource.ICEResource;
import org.eclipse.ice.item.nuclear.MOOSE;
import org.eclipse.ice.item.nuclear.MOOSEModel;
import org.eclipse.ice.reactor.plant.IPlantView;
import org.eclipse.ice.reactor.plant.PlantComposite;
import org.eclipse.ice.viz.service.javafx.geometry.ViewFactory;
import org.eclipse.ice.reactor.plant.ViewFactory;
import org.eclipse.ice.viz.service.javafx.geometry.plant.IPlantView;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.action.ToolBarManager;
......
/*******************************************************************************
* 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:
* Jordan Deyton (UT-Battelle, LLC.) - initial API and implementation and/or initial documentation
*
*******************************************************************************/
package org.eclipse.ice.client.widgets.reactoreditor.plant.test;
import java.util.ArrayList;
import org.eclipse.ice.client.widgets.reactoreditor.plant.PlantAppState;
import org.eclipse.ice.reactor.plant.CoreChannel;
import org.eclipse.ice.reactor.plant.HeatExchanger;
import org.eclipse.ice.reactor.plant.Junction;
import org.eclipse.ice.reactor.plant.Pipe;
import org.eclipse.ice.reactor.plant.PlantComposite;
import org.eclipse.ice.reactor.plant.Reactor;
import org.eclipse.ice.viz.service.jme3.application.MasterApplication;
import org.eclipse.ice.viz.service.jme3.application.ViewAppState;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
/**
* This class can be used to test an embedded, custom {@link ViewAppState}. This
* test in particular tests the <code>MeshEditor</code>'s view.
*
* @author Jordan Deyton
*
*/
public class PlantViewLauncher {
public static void main(String[] args) {
// Create the display and shell.
Display display = new Display();
Shell shell = new Shell(display);
shell.open();
// Create the application and widgets that can create and dispose of jME
// views.
final MasterApplication app = MasterApplication.createApplication();
// Set the shell's Layout and create a SashForm with a left and right
// Composite.
shell.setLayout(new FillLayout());
// Wait until the Application is initialized.
app.blockUntilInitialized(0);
// Create a plant view, start it, and embed it in the shell.
PlantAppState view = new PlantAppState();
view.start(app);
view.createComposite(shell);
// Lay out the shell.
shell.layout();
// ---- Add a plant to the view. ---- //
PlantComposite plant = new PlantComposite();
Junction j1, j2;
Pipe p1, p2;
HeatExchanger h;
p1 = new Pipe(3.0, 0.5);
p1.setId(1);
p1.setPosition(new double[] { 0, 0, 0 });
p1.setOrientation(new double[] { 0, 1, 0 });
p2 = new Pipe(5.0, 0.3);
p2.setId(2);
p2.setPosition(new double[] { 3.5, 7, -1 });
p2.setOrientation(new double[] { 1, 1, 1 });
h = new HeatExchanger();
h.setId(3);
h.setPosition(new double[] { 3, 0, -1 });
h.setOrientation(new double[] { 0, 1, 0 });
h.setLength(7);
h.setInnerRadius(0.5);
j1 = new Junction();
j1.setId(4);
j1.addInput(p1);
j1.addOutput(h);
j2 = new Junction();
j2.setId(5);
j2.addInput(h.getPrimaryPipe());
j2.addOutput(p2);
// Set the plant.
view.setPlant(plant);
// Add several plant components.
// plant.addPlantComponent(j1);
// plant.addPlantComponent(p1);
// plant.addPlantComponent(j2);
// plant.addPlantComponent(p2);
// plant.addPlantComponent(h);
CoreChannel c1 = new CoreChannel();
c1.setId(7);
c1.setLength(5);
c1.setPosition(new double[] { 5, 0, 0 });
c1.setOrientation(new double[] { 0, 1, 0 });
c1.setRadius(0.5f);
plant.addPlantComponent(c1);
Reactor r = new Reactor();
r.setId(6);
plant.addPlantComponent(r);
ArrayList<CoreChannel> coreChannels = new ArrayList<CoreChannel>(3);
coreChannels.add(c1);
r.setCoreChannels(coreChannels);
// ---------------------------------- //
// Close the display and shell.
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
// Stop the ViewAppState and the Application.
view.stop();
app.stop();
return;
}
}
/// *******************************************************************************
// * 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:
// * Jordan Deyton (UT-Battelle, LLC.) - initial API and implementation and/or
/// initial documentation
// *
// *******************************************************************************/
// package org.eclipse.ice.client.widgets.reactoreditor.plant.test;
//
// import java.util.ArrayList;
//
// import org.eclipse.ice.client.widgets.reactoreditor.plant.PlantAppState;
// import org.eclipse.ice.reactor.plant.CoreChannel;
// import org.eclipse.ice.reactor.plant.HeatExchanger;
// import org.eclipse.ice.reactor.plant.Junction;
// import org.eclipse.ice.reactor.plant.Pipe;
// import org.eclipse.ice.reactor.plant.PlantComposite;
// import org.eclipse.ice.reactor.plant.Reactor;
// import org.eclipse.ice.viz.service.jme3.application.MasterApplication;
// import org.eclipse.ice.viz.service.jme3.application.ViewAppState;
// import org.eclipse.swt.layout.FillLayout;
// import org.eclipse.swt.widgets.Display;
// import org.eclipse.swt.widgets.Shell;
//
/// **
// * This class can be used to test an embedded, custom {@link ViewAppState}.
/// This
// * test in particular tests the <code>MeshEditor</code>'s view.
// *
// * @author Jordan Deyton
// *
// */
// public class PlantViewLauncher {
//
// public static void main(String[] args) {
// // Create the display and shell.
// Display display = new Display();
// Shell shell = new Shell(display);
// shell.open();
//
// // Create the application and widgets that can create and dispose of jME
// // views.
// final MasterApplication app = MasterApplication.createApplication();
//
// // Set the shell's Layout and create a SashForm with a left and right
// // Composite.
// shell.setLayout(new FillLayout());
//
// // Wait until the Application is initialized.
// app.blockUntilInitialized(0);
//
// // Create a plant view, start it, and embed it in the shell.
// PlantAppState view = new PlantAppState();
// view.start(app);
// view.createComposite(shell);
//
// // Lay out the shell.
// shell.layout();
//
// // ---- Add a plant to the view. ---- //
// PlantComposite plant = new PlantComposite();
//
// Junction j1, j2;
// Pipe p1, p2;
// HeatExchanger h;
//
// p1 = new Pipe(3.0, 0.5);
// p1.setId(1);
// p1.setPosition(new double[] { 0, 0, 0 });
// p1.setOrientation(new double[] { 0, 1, 0 });
//
// p2 = new Pipe(5.0, 0.3);
// p2.setId(2);
// p2.setPosition(new double[] { 3.5, 7, -1 });
// p2.setOrientation(new double[] { 1, 1, 1 });
//
// h = new HeatExchanger();
// h.setId(3);
// h.setPosition(new double[] { 3, 0, -1 });
// h.setOrientation(new double[] { 0, 1, 0 });
// h.setLength(7);
// h.setInnerRadius(0.5);
//
// j1 = new Junction();
// j1.setId(4);
// j1.addInput(p1);
// j1.addOutput(h);
//
// j2 = new Junction();
// j2.setId(5);
// j2.addInput(h.getPrimaryPipe());
// j2.addOutput(p2);
//
// // Set the plant.
// view.setPlant(plant);
//
// // Add several plant components.
// // plant.addPlantComponent(j1);
// // plant.addPlantComponent(p1);
// // plant.addPlantComponent(j2);
// // plant.addPlantComponent(p2);
// // plant.addPlantComponent(h);
//
// CoreChannel c1 = new CoreChannel();
// c1.setId(7);
// c1.setLength(5);
// c1.setPosition(new double[] { 5, 0, 0 });
// c1.setOrientation(new double[] { 0, 1, 0 });
// c1.setRadius(0.5f);
// plant.addPlantComponent(c1);
//
// Reactor r = new Reactor();
// r.setId(6);
// plant.addPlantComponent(r);
//
// ArrayList<CoreChannel> coreChannels = new ArrayList<CoreChannel>(3);
// coreChannels.add(c1);
// r.setCoreChannels(coreChannels);
// // ---------------------------------- //
//
// // Close the display and shell.
// while (!shell.isDisposed()) {
// if (!display.readAndDispatch()) {
// display.sleep();
// }
// }
// display.dispose();
//
// // Stop the ViewAppState and the Application.
// view.stop();
// app.stop();
//
// return;
// }
// }
......@@ -6,7 +6,12 @@ Bundle-Version: 2.1.8
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Import-Package: org.eclipse.ice.datastructures.ICEObject,
org.eclipse.ice.datastructures.componentVisitor,
org.eclipse.ice.viz.service,
org.eclipse.ice.viz.service.datastructures.VizObject,
org.eclipse.ice.viz.service.geometry.reactor,
org.eclipse.ice.viz.service.javafx.geometry,
org.eclipse.ice.viz.service.javafx.geometry.plant,
org.eclipse.ice.viz.service.modeling,
org.eclipse.swt.widgets,
org.slf4j;version="1.7.2"
Service-Component: OSGI-INF/PlantIOFactory.xml
......
......@@ -8,44 +8,10 @@
* Contributors:
* Robert Smith
*******************************************************************************/
package org.eclipse.ice.viz.service.javafx.geometry.plant;
package org.eclipse.ice.reactor.plant;
import java.util.List;
import org.eclipse.ice.reactor.plant.Boundary;
import org.eclipse.ice.reactor.plant.Branch;
import org.eclipse.ice.reactor.plant.CoreChannel;
import org.eclipse.ice.reactor.plant.DownComer;
import org.eclipse.ice.reactor.plant.FlowJunction;
import org.eclipse.ice.reactor.plant.GeometricalComponent;
import org.eclipse.ice.reactor.plant.HeatExchanger;
import org.eclipse.ice.reactor.plant.IPlantComponentVisitor;
import org.eclipse.ice.reactor.plant.IdealPump;
import org.eclipse.ice.reactor.plant.Inlet;
import org.eclipse.ice.reactor.plant.Junction;
import org.eclipse.ice.reactor.plant.MassFlowInlet;
import org.eclipse.ice.reactor.plant.OneInOneOutJunction;
import org.eclipse.ice.reactor.plant.Outlet;
import org.eclipse.ice.reactor.plant.Pipe;
import org.eclipse.ice.reactor.plant.PipeToPipeJunction;
import org.eclipse.ice.reactor.plant.PipeWithHeatStructure;
import org.eclipse.ice.reactor.plant.PlantComponent;
import org.eclipse.ice.reactor.plant.PlantComposite;
import org.eclipse.ice.reactor.plant.PointKinetics;
import org.eclipse.ice.reactor.plant.Pump;
import org.eclipse.ice.reactor.plant.Reactor;
import org.eclipse.ice.reactor.plant.SeparatorDryer;
import org.eclipse.ice.reactor.plant.SolidWall;
import org.eclipse.ice.reactor.plant.SpecifiedDensityAndVelocityInlet;
import org.eclipse.ice.reactor.plant.Subchannel;
import org.eclipse.ice.reactor.plant.SubchannelBranch;
import org.eclipse.ice.reactor.plant.TDM;
import org.eclipse.ice.reactor.plant.TimeDependentJunction;
import org.eclipse.ice.reactor.plant.TimeDependentVolume;
import org.eclipse.ice.reactor.plant.Turbine;
import org.eclipse.ice.reactor.plant.Valve;
import org.eclipse.ice.reactor.plant.VolumeBranch;
import org.eclipse.ice.reactor.plant.WetWell;
import org.eclipse.ice.viz.service.datastructures.VizObject.IVizUpdateable;
import org.eclipse.ice.viz.service.datastructures.VizObject.IVizUpdateableListener;
import org.eclipse.ice.viz.service.geometry.reactor.HeatExchangerController;
......@@ -56,6 +22,9 @@ 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.FXPlantViewRootController;
import org.eclipse.ice.viz.service.javafx.geometry.plant.IPlantData;
import org.eclipse.ice.viz.service.modeling.AbstractController;
import org.eclipse.ice.viz.service.modeling.AbstractMesh;
import org.eclipse.ice.viz.service.modeling.AbstractView;
......@@ -68,7 +37,8 @@ import org.eclipse.ice.viz.service.modeling.AbstractView;
* @author Robert Smith
*
*/
public class FXPlantCompositeConverter implements IVizUpdateableListener {
public class FXPlantCompositeConverter
implements IPlantData, IVizUpdateableListener {
/**
* The scale which translates between RELAP7 units and JavaFX units. Each
......
......@@ -10,14 +10,13 @@
* initial documentation
*
*******************************************************************************/
package org.eclipse.ice.viz.service.javafx.geometry;
package org.eclipse.ice.reactor.plant;
import org.eclipse.ice.reactor.plant.IPlantView;
import org.eclipse.ice.reactor.plant.PlantComposite;
import org.eclipse.ice.viz.service.IVizCanvas;
import org.eclipse.ice.viz.service.IVizService;
import org.eclipse.ice.viz.service.IVizServiceFactory;
import org.eclipse.ice.viz.service.javafx.geometry.plant.FXPlantCompositeConverter;
import org.eclipse.ice.viz.service.javafx.geometry.FXGeometryVizService;
import org.eclipse.ice.viz.service.javafx.geometry.plant.IPlantView;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......
......@@ -15,15 +15,14 @@ import java.io.IOException;
import javax.imageio.ImageIO;
import org.eclipse.ice.reactor.plant.IPlantView;
import org.eclipse.ice.reactor.plant.PlantComposite;
import org.eclipse.ice.viz.service.geometry.widgets.TransformationView;
import org.eclipse.ice.viz.service.javafx.canvas.AbstractAttachment;
import org.eclipse.ice.viz.service.javafx.canvas.AbstractViewer;
import org.eclipse.ice.viz.service.javafx.canvas.FXSelection;
import org.eclipse.ice.viz.service.javafx.canvas.FXViewer;
import org.eclipse.ice.viz.service.javafx.canvas.FXVizCanvas;
import org.eclipse.ice.viz.service.javafx.geometry.plant.FXPlantCompositeConverter;
import org.eclipse.ice.viz.service.javafx.geometry.plant.IPlantData;
import org.eclipse.ice.viz.service.javafx.geometry.plant.IPlantView;
import org.eclipse.ice.viz.service.modeling.AbstractController;
import org.eclipse.ice.viz.service.modeling.IWireFramePart;
import org.eclipse.ice.viz.service.modeling.ShapeController;
......@@ -382,12 +381,10 @@ public class FXGeometryCanvas extends FXVizCanvas implements IPlantView {
* .plant.PlantComposite)
*/
@Override
public void setPlant(PlantComposite plant) {
public void setPlant(IPlantData plant) {
// Convert the plant composite into an AbstractController
FXPlantCompositeConverter converter = new FXPlantCompositeConverter(
plant);
AbstractController newRoot = converter.getPlant();
AbstractController newRoot = plant.getPlant();
// Remove everything from the root to ensure it will be
for (AbstractController entity : root.getEntities()) {
......
/*******************************************************************************
* 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;
import org.eclipse.ice.viz.service.modeling.AbstractController;
/**
* An interface for objects which contain the data which will be set to an
* IPlantView.
*
* @author Robert Smith
*
*/
public interface IPlantData {
/**
* Get the plant's structure converted into a tree of modeling parts.
*
* @return The root of the tree structure containing the plant.
*/
public AbstractController getPlant();
}
......@@ -8,7 +8,7 @@
* Contributors:
* Robert Smith
*******************************************************************************/
package org.eclipse.ice.reactor.plant;
package org.eclipse.ice.viz.service.javafx.geometry.plant;
import org.eclipse.swt.widgets.Composite;
......@@ -113,7 +113,7 @@ public interface IPlantView {
// */
// public void setDefaultCameraPosition(float x, float y, float z);
public void setPlant(PlantComposite plant);
public void setPlant(IPlantData plant);
/**
* Sets all rendered plant components to be viewed as wireframes or as solid
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment