Commit 6b901de3 authored by Robert Smith's avatar Robert Smith
Browse files

Fixed wireframe mode and broke dependencies



Got the wireframe mode for the Plant View working and broke all
dependencies of ice.viz.* packages on non-viz ice.* packages.
Signed-off-by: Robert Smith's avatarRobert Smith <SmithRW@ornl.gov>
parent 54edfde4
......@@ -26,12 +26,14 @@ import org.eclipse.ice.datastructures.ICEObject.Component;
*/
@XmlRootElement(name = "ReactorComponent")
public interface IReactorComponent extends Component {
/**
* <p>
* This operation returns the contents of the ILWRComponent as a string.
* </p>
*
* @return <p>
* @return
* <p>
* The contents of the LWRComponent as a string.
* </p>
*/
......
......@@ -11,8 +11,6 @@ Bundle-Vendor: Oak Ridge National Laboratory
Eclipse-ExtensibleAPI: true
Import-Package: javafx.scene;version="2.2.0",
javafx.scene.image;version="2.2.0",
org.eclipse.ice.datastructures.ICEObject,
org.eclipse.ice.reactor.plant,
org.eclipse.ice.viz.service,
org.eclipse.ice.viz.service.datastructures.VizObject,
org.eclipse.ice.viz.service.geometry.reactor,
......
......@@ -23,7 +23,6 @@ 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.datatypes.FXShapeController;
import org.eclipse.ice.viz.service.javafx.geometry.plant.FXPlantCompositeConverter;
import org.eclipse.ice.viz.service.modeling.AbstractController;
import org.eclipse.ice.viz.service.modeling.IWireFramePart;
......@@ -231,7 +230,9 @@ public class FXGeometryCanvas extends FXVizCanvas implements IPlantView {
public void setWireframe(boolean wireframe) {
// Set all objects in the tree to wireframe mode
recursiveSetWireframe(root, wireframe);
for (AbstractController entity : root.getEntities()) {
recursiveSetWireframe(entity, wireframe);
}
}
/**
......@@ -249,10 +250,10 @@ public class FXGeometryCanvas extends FXVizCanvas implements IPlantView {
boolean wireframe) {
// Set this object to the correct mode
((FXShapeController) root).setWireFrameMode(wireframe);
((IWireFramePart) target).setWireFrameMode(wireframe);
// Iterate over each of its children, setting them to the correct mode
for (AbstractController child : root
for (AbstractController child : target
.getEntitiesByCategory("Children")) {
((IWireFramePart) child).setWireFrameMode(wireframe);
}
......@@ -362,12 +363,24 @@ public class FXGeometryCanvas extends FXVizCanvas implements IPlantView {
((FXViewer) viewer).setDefaultCameraZByX();
}
/*
* (non-Javadoc)
*
* @see org.eclipse.ice.reactor.plant.IPlantView#dispose()
*/
@Override
public void dispose() {
// TODO Auto-generated method stub
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.ice.reactor.plant.IPlantView#setPlant(org.eclipse.ice.reactor
* .plant.PlantComposite)
*/
@Override
public void setPlant(PlantComposite plant) {
......
......@@ -79,6 +79,12 @@ public class FXShapeView extends AbstractView implements IWireFramePart {
/** */
private boolean selected;
/**
* Whether the shape is displaying in wireframe mode. The shape will be a
* wireframe if true, or solid if false.
*/
private boolean wireframe;
/**
* The nullary constructor.
*/
......@@ -90,6 +96,7 @@ public class FXShapeView extends AbstractView implements IWireFramePart {
gizmo = new TransformGizmo(0);
gizmo.setVisible(false);
node.getChildren().add(gizmo);
wireframe = true;
}
......@@ -257,6 +264,13 @@ public class FXShapeView extends AbstractView implements IWireFramePart {
return;
}
// Set the correct wireframe mode
if (wireframe) {
shape.setDrawMode(DrawMode.LINE);
} else {
shape.setDrawMode(DrawMode.FILL);
}
// If the function didn't return, a change has occurred. Replace the old
// shape with the new shape in the group
if (prevShape != null) {
......@@ -333,7 +347,7 @@ public class FXShapeView extends AbstractView implements IWireFramePart {
// handle their own views.
if (model.getProperty("Operator") == null) {
// Create the shape if neccesary
// Create the shape if necessary
createShape(model, ShapeType.valueOf(model.getProperty("Type")));
// Convert the model's selected property to a boolean
......@@ -392,7 +406,6 @@ public class FXShapeView extends AbstractView implements IWireFramePart {
UpdateableSubscriptionType[] eventTypes = {
UpdateableSubscriptionType.All };
updateManager.notifyListeners(eventTypes);
;
}
/*
......@@ -404,7 +417,10 @@ public class FXShapeView extends AbstractView implements IWireFramePart {
@Override
public void setWireFrameMode(boolean on) {
// Set the shape to the correct draw mode
// Save the new state
wireframe = on;
// Set the current shape to the correct draw mode
if (on) {
shape.setDrawMode(DrawMode.LINE);
} else {
......
......@@ -93,13 +93,13 @@ public class FXJunctionView extends JunctionView implements IWireFramePart {
// Get the bottom end of each input pipe
for (AbstractController input : model.getEntitiesByCategory("Input")) {
pipeEdges.add(((PipeController) input).getLowerExtrema());
pipeEdges.add(((PipeController) input).getUpperExtrema());
}
// Get the top end of each output pipe
for (AbstractController output : model
.getEntitiesByCategory("Output")) {
pipeEdges.add(((PipeController) output).getUpperExtrema());
pipeEdges.add(((PipeController) output).getLowerExtrema());
}
// Get the bounds of the region encompassing all pipe ends
......
......@@ -74,7 +74,7 @@ public class FXPlantCompositeConverter implements IVizUpdateableListener {
* The scale which translates between RELAP7 units and JavaFX units. Each
* RELAP7 unit will be treated as SCALE JavaFX units.
*/
private final int SCALE = 50;
private final int SCALE = 25;
/**
* The root of the tree of plant parts converted from the source.
......@@ -614,14 +614,8 @@ public class FXPlantCompositeConverter implements IVizUpdateableListener {
position[1] = position[1] * SCALE;
position[2] = position[2] * SCALE;
// System.out.println("Original Position: " + position[0] + " "
// + position[1] + " " + position[2]);
double[] orientation = plantComp.getOrientation();
// System.out.println("Orientation Vector: " + orientation[0] + " "
// + orientation[1] + " " + orientation[2]);
// Normalize the orientation vector
double[] normalized = new double[3];
double length = Math.sqrt(
......
......@@ -113,11 +113,6 @@ public class FXReactorView extends AbstractView implements IWireFramePart {
// reactor
ArrayList<Extrema> extrema = new ArrayList<Extrema>();
// // Add a small region to the list to ensure that the reactor will
// never
// // be displayed as below some small default size
// extrema.add(new Extrema(0, 50, 0, 51, 0, 200));
// Check all the reactor's children for core channels
for (AbstractController channel : model.getEntities()) {
if ("True".equals(channel.getProperty("Core Channel"))) {
......
......@@ -43,7 +43,6 @@ Import-Package: com.jme3.app,
com.jme3.system.awt,
com.jme3.texture,
com.jme3.util,
org.eclipse.ice.datastructures.ICEObject,
org.eclipse.ice.viz.service,
org.eclipse.ice.viz.service.datastructures,
org.eclipse.ice.viz.service.datastructures.VizObject,
......
......@@ -8,7 +8,6 @@ Import-Package: com.google.gson,
org.eclipse.core.runtime;version="3.5.0",
org.eclipse.core.runtime.jobs,
org.eclipse.core.runtime.preferences;version="3.3.0",
org.eclipse.ice.client.common,
org.eclipse.ice.viz.service,
org.eclipse.ice.viz.service.connections,
org.eclipse.ice.viz.service.connections.preferences,
......
......@@ -11,7 +11,6 @@ Import-Package: ca.odell.glazedlists,
org.eclipse.core.filesystem,
org.eclipse.core.resources,
org.eclipse.emf.common.util,
org.eclipse.ice.client.widgets.test.utils,
org.eclipse.ice.viz.service,
org.eclipse.ice.viz.service.connections,
org.eclipse.ice.viz.service.connections.preferences,
......
......@@ -13,10 +13,10 @@ package org.eclipse.ice.viz.service.connections.preferences.test;
import java.util.ArrayList;
import org.eclipse.ice.client.widgets.test.utils.AbstractSWTTester;
import org.eclipse.ice.viz.service.connections.preferences.TableComponentComposite;
import org.eclipse.ice.viz.service.datastructures.VizEntry;
import org.eclipse.ice.viz.service.datastructures.VizTableComponent;
import org.eclipse.ice.viz.service.test.utils.AbstractSWTTester;
import org.eclipse.jface.bindings.keys.KeyStroke;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Point;
......
/*******************************************************************************
* Copyright (c) 2015 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 - Initial API and implementation and/or initial documentation
*
*******************************************************************************/
package org.eclipse.ice.viz.service.test.utils;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.atomic.AtomicReference;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
import org.eclipse.swtbot.swt.finder.SWTBot;
import org.eclipse.swtbot.swt.finder.SWTBotTestCase;
import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
import org.hamcrest.BaseMatcher;
import org.hamcrest.Description;
import org.hamcrest.Matcher;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
/**
* This class provides a base for UI-based tests that use an {@link SWTBot} (or
* a sub-class thereof) and provides a reference to the main UI thread's
* {@link Display} that is created at startup time.
* <p>
* This class also provides hooks for test class implementations, to facilitate
* easy initialization and disposal of shared test resources and resources that
* can be re-allocated on a per-test basis.
* </p>
* <p>
* To use an {@code SWTBot} to simulate user interaction, use the bot provided
* via {@link #getBot()}.
* </p>
* <p>
* <b>Note:</b> Changes to the UI must be coordinated with the main UI thread
* using {@link Display#syncExec(Runnable)} or
* {@link Display#asyncExec(Runnable)}. To get the shared display, you may call
* {@link #getDisplay()}.
* </p>
*
* @author Jordan Deyton
*
* @param <T>
* The type of {@code SWTBot}, e.g., {@link SWTBot} or
* {@link SWTWorkbenchBot}.
*
* @see AbstractICESWTTester
* @see AbstractICEWorkbenchTester
*/
@RunWith(SWTBotJunit4ClassRunner.class)
public abstract class AbstractICEUITester<T extends SWTBot> extends
SWTBotTestCase {
/**
* The main UI thread's {@code Display}. This class does not create the
* display or the UI thread.
*/
private static Display display;
/**
* The first instance of the tester that hits {@link #beforeEachTest()}. We
* use this to trigger {@link #beforeAllTests()} and
* {@link #afterAllTests()} for sub-classes so they need not wrap their
* heads around the {@code BeforeClass} tag and inheritance/hiding/shadowing
* issues.
*/
private static final AtomicReference<AbstractICEUITester<?>> firstTester = new AtomicReference<AbstractICEUITester<?>>();
/**
* A map of temporary files, keyed on their filenames. This is created only
* when {@link #createTemporaryFile(String, String...)} is called. All
* temporary files created for a test method are deleted after the test
* method completes.
*/
private Map<String, File> tmpFiles;
/**
* Gets the main UI thread's {@code Display}. This should <b>always</b> be
* used to perform updates to the UI from test code using the display's sync
* methods.
*
* @return The main UI thread's display.
*
* @see Display#syncExec(Runnable)
* @see Display#asyncExec(Runnable)
*/
protected static Display getDisplay() {
return display;
}
/**
* Gets the {@code SWTBot} for this test class instance. This bot is to aid
* in performing UI tests that simulate user interaction with SWT-based
* applications.
*
* @return The {@code SWTBot} for testing.
*/
protected abstract T getBot();
/**
* Sets the shared reference to the UI thread's {@link #display}.
*/
@BeforeClass
public static void beforeClass() {
// Set the reference to the main UI thread's Display.
if (display == null) {
display = Display.getDefault();
}
}
/**
* This method is called <i>before</i> <b>all</b> tests are run. It should
* be used to set up any <b>static</b> resources shared among all test
* cases.
* <p>
* <b>When overriding, be sure to call {@code super.beforeAllTests()} at the
* <i>***BEGINNING OF YOUR METHOD***!</i></b>
* </p>
*/
public void beforeAllTests() {
// Nothing to do yet.
}
/**
* This method is called <i>before</i> <b>each</b> test is run. It should be
* used to set up any <b>non-static</b> resources required for <i>all</i>
* tests but that can be allocated once per test.
* <p>
* <b>When overriding, be sure to call {@code super.beforeEachTest()} at the
* <i>***BEGINNING OF YOUR METHOD***!</i></b>
* </p>
*/
@Before
public void beforeEachTest() {
// If this is the first test to be run, make sure all shared resources
// have been allocated.
if (firstTester.compareAndSet(null, this)) {
beforeAllTests();
}
}
/**
* This method is called <i>after</i> <b>each</b> test is run. It should be
* used to clean up any <b>non-static</b> resources required for <i>all</i>
* tests but that can be allocated once per test.
* <p>
* <b>When overriding, be sure to call {@code super.afterEachTest()} at the
* <i>***END OF YOUR METHOD***!</i></b>
* </p>
*/
@After
public void afterEachTest() {
// Delete all temporary files.
if (tmpFiles != null) {
Iterator<Entry<String, File>> iter = tmpFiles.entrySet().iterator();
while (iter.hasNext()) {
File file = iter.next().getValue();
if (!file.delete()) {
fail("AbstractICEUITester error: "
+ "Could not delete the file \"" + file.getPath()
+ "\".");
}
iter.remove();
}
tmpFiles = null;
}
return;
}
/**
* This method is called <i>after</i> <b>all</b> tests are run. It should be
* used to clean up any <b>static</b> resources shared among all test cases.
* <p>
* <b>When overriding, be sure to call {@code super.afterAllTests()} at the
* <i>***END OF YOUR METHOD***!</i></b>
* </p>
*/
public void afterAllTests() {
display = null;
}
/**
* This is run by JUnit at the end of all tests. It merely redirects to the
* non-static {@link #afterAllTests()} for the {@link #firstTester} to
* trigger the cleanup of shared test resources.
*/
@AfterClass
public static void afterClass() {
AbstractICEUITester<?> instance = firstTester.getAndSet(null);
if (instance != null) {
instance.afterAllTests();
}
}
/**
* Gets a {@link Matcher} (used by {@code SWTBot} to find widgets) that
* matches the exact object. This is helpful if you have a reference to the
* widget itself but want an {@code SWTBot} wrapper for it.
*
* @param object
* The object or widget to match.
* @return The matcher that can be passed to the {@code SWTBot}.
*/
protected <E> Matcher<E> getExactMatcher(final E object) {
return new BaseMatcher<E>() {
@Override
public boolean matches(Object item) {
return item == object;
}
@Override
public void describeTo(Description description) {
// Nothing to do.
}
};
}
/**
* Creates a temporary file for a single test method. This file will be
* stored in the directory equivalent to "/user.home/ICETests/" and with the
* specified file name.
* <p>
* Files created with this method are <b>not</b> stored for use across test
* methods. However, this file does not need to be deleted by the caller as
* it will be deleted at the end of the test case.
* </p>
*
* @param filename
* The name of the file. If {@code null}, the name "tmp" will be
* used.
* @param lines
* The contents of the file. Each non-null element will be placed
* on a new line.
* @return The created file, or {@code null} if a file could not be created.
* @throws IOException
* An IOException occurs if the file could not be written.
*/
protected File createTemporaryFile(String filename, String... lines)
throws IOException {
// Change the filename to "tmp" if none was provided.
if (filename == null) {
filename = "tmp";
}
// Set up the File based on the provided name.
String separator = System.getProperty("file.separator");
String home = System.getProperty("user.home");
File file = new File(home + separator + "ICETests" + separator
+ filename);
// Set up the writer and write out the lines.
FileWriter writer = new FileWriter(file);
BufferedWriter buffer = new BufferedWriter(writer);
for (String line : lines) {
if (line != null) {
buffer.write(line);
buffer.newLine();
}
}
// Be sure to close the writers!
buffer.close();
writer.close();
// Store the file in the collection of temporary files.
if (tmpFiles == null) {
tmpFiles = new HashMap<String, File>();
}
tmpFiles.put(filename, file);
return file;
}
}
\ No newline at end of file
/*******************************************************************************
* Copyright (c) 2015 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 - Initial API and implementation and/or initial documentation
*
*******************************************************************************/
package org.eclipse.ice.viz.service.test.utils;
import java.util.concurrent.atomic.AtomicReference;
import org.eclipse.swt.SWTException;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swtbot.swt.finder.SWTBot;
/**
* This abstract class provides a basic framework for performing SWTBot tests
* for an SWT application inside a JUnit test framework. As such, test classes
* sub-classing this abstract class can be run as JUnit tests, JUnit plug-in
* tests (on or off the UI thread), or SWTBot tests.
* <p>
* A {@link Shell} is opened (outside the default Eclipse workbench if used as a
* plug-in test). This shell provides the "sandbox" in which UI tests are
* performed. For instance, to test a specific {@code Composite}, you may create
* an instance of said {@code Composite} in the shell and perform its UI tests.
* The shell is shared among sub-class tests, and can be acquired via
* {@link #getShell()}.
* </p>
* <p>
* An {@link SWTBot} is opened for each test class instance and should be used
* for the actual UI tests. The bot can be acquired via {@link #getBot()}.