Commit 1de0994e authored by Robert Smith's avatar Robert Smith
Browse files

Finished Mesh Editor and added tests



Finished the Mesh Editor and added JavaFX Mesh tests.
Signed-off-by: Robert Smith's avatarRobert Smith <SmithRW@ornl.gov>
parent da2b637f
......@@ -20,7 +20,6 @@ import org.eclipse.ice.client.common.ActionTree;
import org.eclipse.ice.datastructures.ICEObject.ICEObject;
import org.eclipse.ice.datastructures.form.MeshComponent;
import org.eclipse.ice.viz.service.IVizService;
import org.eclipse.ice.viz.service.geometry.widgets.ShapeTreeView;
import org.eclipse.ice.viz.service.geometry.widgets.TransformationView;
import org.eclipse.ice.viz.service.jme3.mesh.IMeshSelectionListener;
import org.eclipse.ice.viz.service.mesh.datastructures.IMeshVizCanvas;
......@@ -196,7 +195,7 @@ public class ICEMeshPage extends ICEFormPage
try {
getSite().getWorkbenchWindow().getActivePage()
.showView(ShapeTreeView.ID);
.showView(MeshElementTreeView.ID);
getSite().getWorkbenchWindow().getActivePage()
.showView(TransformationView.ID);
......
......@@ -26,8 +26,9 @@ import org.eclipse.ice.datastructures.ICEObject.ICEObject;
import org.eclipse.ice.datastructures.ICEObject.IUpdateable;
import org.eclipse.ice.datastructures.ICEObject.IUpdateableListener;
import org.eclipse.ice.datastructures.componentVisitor.IComponentVisitor;
import org.eclipse.ice.viz.service.datastructures.VizObject.IVizUpdateable;
import org.eclipse.ice.viz.service.datastructures.VizObject.IVizUpdateableListener;
import org.eclipse.ice.viz.service.datastructures.VizObject.IManagedVizUpdateable;
import org.eclipse.ice.viz.service.datastructures.VizObject.IManagedVizUpdateableListener;
import org.eclipse.ice.viz.service.datastructures.VizObject.UpdateableSubscriptionType;
import org.eclipse.ice.viz.service.modeling.Shape;
/**
......@@ -40,8 +41,8 @@ import org.eclipse.ice.viz.service.modeling.Shape;
*/
@XmlRootElement(name = "GeometryComponent")
@XmlAccessorType(XmlAccessType.FIELD)
public class GeometryComponent extends ICEObject
implements Component, IUpdateableListener, IVizUpdateableListener {
public class GeometryComponent extends ICEObject implements Component,
IUpdateableListener, IManagedVizUpdateableListener {
/**
* <p>
* The set of ComponentListeners observing the GeometryComponent
......@@ -365,9 +366,27 @@ public class GeometryComponent extends ICEObject
* VizObject.IVizUpdateable)
*/
@Override
public void update(IVizUpdateable component) {
public void update(IManagedVizUpdateable component,
UpdateableSubscriptionType[] type) {
notifyListeners();
}
/*
* (non-Javadoc)
*
* @see org.eclipse.ice.viz.service.datastructures.VizObject.
* IManagedVizUpdateableListener#getSubscriptions(org.eclipse.ice.viz.
* service.datastructures.VizObject.IVizUpdateable)
*/
@Override
public ArrayList<UpdateableSubscriptionType> getSubscriptions(
IManagedVizUpdateable source) {
// Register for all event types
ArrayList<UpdateableSubscriptionType> types = new ArrayList<UpdateableSubscriptionType>();
types.add(UpdateableSubscriptionType.All);
return types;
}
}
\ No newline at end of file
......@@ -12,6 +12,7 @@
*******************************************************************************/
package org.eclipse.ice.datastructures.form;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
......@@ -21,8 +22,9 @@ import javax.xml.bind.annotation.XmlRootElement;
import org.eclipse.ice.datastructures.ICEObject.Component;
import org.eclipse.ice.datastructures.ICEObject.ICEObject;
import org.eclipse.ice.datastructures.componentVisitor.IComponentVisitor;
import org.eclipse.ice.viz.service.datastructures.VizObject.IVizUpdateable;
import org.eclipse.ice.viz.service.datastructures.VizObject.IVizUpdateableListener;
import org.eclipse.ice.viz.service.datastructures.VizObject.IManagedVizUpdateable;
import org.eclipse.ice.viz.service.datastructures.VizObject.IManagedVizUpdateableListener;
import org.eclipse.ice.viz.service.datastructures.VizObject.UpdateableSubscriptionType;
import org.eclipse.ice.viz.service.modeling.AbstractController;
import org.eclipse.ice.viz.service.modeling.AbstractController;
import org.eclipse.ice.viz.service.modeling.AbstractMeshComponent;
......@@ -42,7 +44,7 @@ import org.eclipse.ice.viz.service.modeling.Face;
@XmlRootElement(name = "MeshComponent")
@XmlAccessorType(XmlAccessType.FIELD)
public class MeshComponent extends ICEObject
implements Component, IVizUpdateableListener {
implements Component, IManagedVizUpdateableListener {
/**
* The wrapped VizMeshComponent.
......@@ -306,10 +308,44 @@ public class MeshComponent extends ICEObject
return;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.ice.viz.service.datastructures.VizObject.
* IManagedVizUpdateableListener#update(org.eclipse.ice.viz.service.
* datastructures.VizObject.IManagedVizUpdateable,
* org.eclipse.ice.viz.service.datastructures.VizObject.
* UpdateableSubscriptionType[])
*/
@Override
public void update(IVizUpdateable component) {
notifyListeners();
public void update(IManagedVizUpdateable component,
UpdateableSubscriptionType[] types) {
// Only pass on updates for the root part's list of children changing,
// in order to refresh the tree view of components.
for (UpdateableSubscriptionType type : types) {
if (type == UpdateableSubscriptionType.Child) {
notifyListeners();
}
}
}
/*
* (non-Javadoc)
*
* @see org.eclipse.ice.viz.service.datastructures.VizObject.
* IManagedVizUpdateableListener#getSubscriptions(org.eclipse.ice.viz.
* service.datastructures.VizObject.IVizUpdateable)
*/
@Override
public ArrayList<UpdateableSubscriptionType> getSubscriptions(
IManagedVizUpdateable source) {
// Register for all event types
ArrayList<UpdateableSubscriptionType> types = new ArrayList<UpdateableSubscriptionType>();
types.add(UpdateableSubscriptionType.All);
return types;
}
}
\ No newline at end of file
......@@ -10,9 +10,11 @@
*******************************************************************************/
package org.eclipse.ice.viz.service.geometry.shapes;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.ice.viz.service.datastructures.VizObject.IVizUpdateable;
import org.eclipse.ice.viz.service.datastructures.VizObject.IManagedVizUpdateable;
import org.eclipse.ice.viz.service.datastructures.VizObject.UpdateableSubscriptionType;
import org.eclipse.ice.viz.service.modeling.AbstractController;
import org.eclipse.ice.viz.service.modeling.AbstractView;
import org.eclipse.ice.viz.service.modeling.Shape;
......@@ -57,7 +59,8 @@ public class FXShapeController extends Shape {
*/
public void refreshRecursive() {
notifyLock.set(true);
// Queue all messages from recursive refreshing
updateManager.enqueue();
refresh();
// Refresh for child
......@@ -66,7 +69,8 @@ public class FXShapeController extends Shape {
((FXShapeController) child).refreshRecursive();
}
notifyLock.set(false);
// Send updates for all the recursive refreshing
updateManager.flushQueue();
}
/*
......@@ -233,14 +237,19 @@ public class FXShapeController extends Shape {
* eclipse.ice.viz.service.datastructures.VizObject.IVizUpdateable)
*/
@Override
public void update(IVizUpdateable component) {
public void update(IManagedVizUpdateable component,
UpdateableSubscriptionType[] type) {
// If the view updated, recursively refresh all children
// If the view updated, recursively refresh all children and propagate
// the update to own listeners
if (component == view) {
refreshRecursive();
}
super.update(component);
// Otherwise just propagate to own listeners
else {
super.update(component, type);
}
}
// /*
......@@ -277,4 +286,36 @@ public class FXShapeController extends Shape {
//
// }
/*
* (non-Javadoc)
*
* @see org.eclipse.ice.viz.service.datastructures.VizObject.
* IManagedVizUpdateableListener#getSubscriptions(org.eclipse.ice.viz.
* service.datastructures.VizObject.IVizUpdateable)
*/
@Override
public ArrayList<UpdateableSubscriptionType> getSubscriptions(
IManagedVizUpdateable source) {
// Create a list of events to subscribe to
ArrayList<UpdateableSubscriptionType> types = new ArrayList<UpdateableSubscriptionType>();
// Listen only to new child events from the model
if (source == model) {
types.add(UpdateableSubscriptionType.Child);
types.add(UpdateableSubscriptionType.Selection);
}
// Listen only to transformation events from the view
else if (source == view) {
types.add(UpdateableSubscriptionType.Transformation);
}
// For other objects, register for everything
else {
types.add(UpdateableSubscriptionType.All);
}
return types;
}
}
......@@ -10,8 +10,8 @@
*******************************************************************************/
package org.eclipse.ice.viz.service.geometry.shapes;
import org.eclipse.ice.viz.service.datastructures.VizObject.IVizUpdateable;
import org.eclipse.ice.viz.service.datastructures.VizObject.UpdateableSubscription;
import org.eclipse.ice.viz.service.datastructures.VizObject.IManagedVizUpdateable;
import org.eclipse.ice.viz.service.datastructures.VizObject.UpdateableSubscriptionType;
import org.eclipse.ice.viz.service.javafx.internal.Util;
import org.eclipse.ice.viz.service.javafx.internal.scene.TransformGizmo;
import org.eclipse.ice.viz.service.modeling.AbstractController;
......@@ -284,12 +284,16 @@ public class FXShapeView extends AbstractView {
public Object clone() {
FXShapeView clone = new FXShapeView();
clone.copy(this);
clone.update(clone.transformation);
// clone.update(clone.transformation);
// Force an update from the transformation
clone.transformation.setSize(clone.transformation.getSize());
return clone;
}
@Override
public void update(IVizUpdateable component) {
public void update(IManagedVizUpdateable component,
UpdateableSubscriptionType[] type) {
// If the transformation updated, update the JavaFX transformation
if (component == transformation) {
......@@ -299,8 +303,10 @@ public class FXShapeView extends AbstractView {
}
// Notify own listeners of the change
UpdateableSubscription[] eventTypes = {UpdateableSubscription.All};
updateManager.notifyListeners(eventTypes);;
UpdateableSubscriptionType[] eventTypes = {
UpdateableSubscriptionType.All };
updateManager.notifyListeners(eventTypes);
;
}
}
......@@ -102,72 +102,86 @@ public class TransformationView extends ViewPart {
public void createPartControl(Composite parent) {
// Create a scrolled composite - scroll bars!
ScrolledComposite scrolledParent = new ScrolledComposite(parent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
ScrolledComposite scrolledParent = new ScrolledComposite(parent,
SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
// Create a sub-composite to hold the actual widgets
final Composite realParent = new Composite(scrolledParent, SWT.NONE);
// Main layout
realParent.setLayout(new GridLayout(4, false));
realParent.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));
realParent.setLayoutData(
new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));
// Size parameter
Label sizeLabel = new Label(realParent, SWT.NONE);
sizeLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1));
sizeLabel.setLayoutData(
new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1));
sizeLabel.setText("Size");
sizeSpinner = new RealSpinner(realParent);
sizeSpinner.getControl().setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1));
sizeSpinner.getControl().setLayoutData(
new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1));
sizeSpinner.setBounds(0.0, 1.0e6);
sizeSpinner.setValue(1.0);
// Horizontal line
Label separator = new Label(realParent, SWT.SEPARATOR | SWT.HORIZONTAL);
separator.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 4, 1));
separator.setLayoutData(
new GridData(SWT.FILL, SWT.CENTER, false, false, 4, 1));
// Coordinate labels
Label labelBlank = new Label(realParent, SWT.NONE);
Label labelX = new Label(realParent, SWT.NONE);
labelX.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1));
labelX.setLayoutData(
new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1));
labelX.setText("X");
Label labelY = new Label(realParent, SWT.NONE);
labelY.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1));
labelY.setLayoutData(
new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1));
labelY.setText("Y");
Label labelZ = new Label(realParent, SWT.NONE);
labelZ.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1));
labelZ.setLayoutData(
new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1));
labelZ.setText("Z");
// Translation
Label translateLabel = new Label(realParent, SWT.NONE);
translateLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1));
translateLabel.setLayoutData(
new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1));
translateLabel.setText("Translate");
for (int i = 0; i < 3; i++) {
translateSpinners[i] = new RealSpinner(realParent);
translateSpinners[i].getControl().setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
translateSpinners[i].getControl().setLayoutData(
new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
translateSpinners[i].setBounds(-1.0e6, 1.0e6);
}
// Rotation
Label rotationLabel = new Label(realParent, SWT.NONE);
rotationLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1));
rotationLabel.setLayoutData(
new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1));
rotationLabel.setText("Rotation");
for (int i = 0; i < 3; i++) {
rotationSpinners[i] = new RealSpinner(realParent);
rotationSpinners[i].getControl().setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
rotationSpinners[i].getControl().setLayoutData(
new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
rotationSpinners[i].setBounds(-1.0e6, 1.0e6);
}
// Scale
Label scaleLabel = new Label(realParent, SWT.NONE);
scaleLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1));
scaleLabel.setLayoutData(
new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1));
scaleLabel.setText("Scale");
for (int i = 0; i < 3; i++) {
scaleSpinners[i] = new RealSpinner(realParent);
scaleSpinners[i].getControl().setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
scaleSpinners[i].getControl().setLayoutData(
new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
scaleSpinners[i].setBounds(0.0, 1.0e6);
scaleSpinners[i].setValue(1.0);
}
......@@ -196,7 +210,8 @@ public class TransformationView extends ViewPart {
// Set the expansion sizes and minimum size of the scrolled composite
scrolledParent.setExpandHorizontal(true);
scrolledParent.setExpandVertical(true);
scrolledParent.setMinSize(realParent.computeSize(SWT.DEFAULT, SWT.DEFAULT));
scrolledParent
.setMinSize(realParent.computeSize(SWT.DEFAULT, SWT.DEFAULT));
scrolledParent.setShowFocusedControl(true);
}
......@@ -314,11 +329,13 @@ public class TransformationView extends ViewPart {
transformation.setSize(size);
transformation.setScale(scaleX, scaleY, scaleZ);
transformation.setRotation(rotationX, rotationY, rotationZ);
transformation.setTranslation(translationX, translationY, translationZ);
transformation.setTranslation(translationX, translationY,
translationZ);
// Reset the shape's transformation
currentShape.setTransformation(transformation);
if (!currentShape.getTransformation().equals(transformation)) {
currentShape.setTransformation(transformation);
}
}
};
......
......@@ -13,8 +13,9 @@ package org.eclipse.ice.viz.service.javafx.internal.model.geometry;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.ice.viz.service.datastructures.VizObject.IVizUpdateable;
import org.eclipse.ice.viz.service.datastructures.VizObject.IVizUpdateableListener;
import org.eclipse.ice.viz.service.datastructures.VizObject.IManagedVizUpdateable;
import org.eclipse.ice.viz.service.datastructures.VizObject.IManagedVizUpdateableListener;
import org.eclipse.ice.viz.service.datastructures.VizObject.UpdateableSubscriptionType;
import org.eclipse.ice.viz.service.geometry.scene.base.GeometryAttachment;
import org.eclipse.ice.viz.service.geometry.scene.base.IGeometry;
import org.eclipse.ice.viz.service.geometry.scene.model.IAttachment;
......@@ -121,9 +122,10 @@ public class FXGeometryAttachment extends GeometryAttachment {
if (!knownGeometry.contains(geom)) {
final AbstractController finalGeom = geom;
geom.register(new IVizUpdateableListener() {
geom.register(new IManagedVizUpdateableListener() {
@Override
public void update(IVizUpdateable component) {
public void update(IManagedVizUpdateable component,
UpdateableSubscriptionType[] type) {
javafx.application.Platform.runLater(new Runnable() {
@Override
......@@ -141,6 +143,16 @@ public class FXGeometryAttachment extends GeometryAttachment {
}
});
}
@Override
public ArrayList<UpdateableSubscriptionType> getSubscriptions(
IManagedVizUpdateable source) {
// Register to receive all updates
ArrayList<UpdateableSubscriptionType> types = new ArrayList<UpdateableSubscriptionType>();
types.add(UpdateableSubscriptionType.All);
return types;
}
});
knownGeometry.add(geom);
......
/*******************************************************************************
* 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.viz.service.mesh.datastructures.test;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.eclipse.ice.viz.service.mesh.datastructures.BezierEdge;
import org.eclipse.ice.viz.service.mesh.datastructures.IMeshPart;
import org.junit.Ignore;
import org.junit.Test;
/**
* <p>
* Tests the BezierEdge class.
* </p>
*
* @author Jordan H. Deyton
*/
@Ignore
public class BezierEdgeTester {
/**
* <p>
* This operation tests the construction of the BezierEdge class and the
* functionality inherited from ICEObject.
* </p>
*
*/
@Test
public void checkCreation() {
// TODO Auto-generated method stub
}
/**
* <p>
* This operation checks BezierEdge to ensure that it can be correctly
* visited by a realization of the IMeshPartVisitor interface.
* </p>
*
*/
@Test
public void checkVisitation() {
IMeshPart part = new BezierEdge();
// ---- Check visiting with an IMeshPartVisitor. ---- //
// Create a new TestMeshVisitor that only does anything useful when
// visiting a BezierEdge.
TestMeshVisitor meshVisitor = new TestMeshVisitor() {
@Override
public void visit(BezierEdge edge) {
visited = true;
}
};
assertFalse(meshVisitor.wasVisited());
// Now try to visit the MeshComponent with the TestMeshVisitor.
part.acceptMeshVisitor(meshVisitor);
assertTrue(meshVisitor.wasVisited());
// -------------------------------------------------- //
return;
}
}
\ No newline at end of file
/*******************************************************************************
* 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.viz.service.mesh.datastructures.test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import javax.xml.bind.JAXBException;
import org.eclipse.ice.viz.service.datastructures.VizObject.VizJAXBHandler;
import org.eclipse.ice.viz.service.mesh.datastructures.Custom2DShape;
import org.eclipse.ice.viz.service.mesh.datastructures.Edge;
import org.eclipse.ice.viz.service.mesh.datastructures.Polygon;
import org.eclipse.ice.viz.service.mesh.datastructures.Vertex;