Commit 889f344b authored by Robert Smith's avatar Robert Smith
Browse files

Further Mesh Editor refactoring



Finished refactoring non-viz.service packages to utilize the unified
modeling data types and began implementing features in the FXMeshCanvas
to allow it to handle all of the ICE UI's commands.
Signed-off-by: Robert Smith's avatarRobert Smith <SmithRW@ornl.gov>
parent e8f983d1
......@@ -22,6 +22,9 @@ import org.eclipse.ice.datastructures.form.MeshComponent;
import org.eclipse.ice.viz.service.IVizService;
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;
import org.eclipse.ice.viz.service.mesh.javafx.FXMeshCanvas;
import org.eclipse.ice.viz.service.mesh.javafx.FXMeshVizService;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.ToolBarManager;
......
......@@ -18,6 +18,7 @@ import org.eclipse.ice.datastructures.ICEObject.IUpdateable;
import org.eclipse.ice.datastructures.ICEObject.IUpdateableListener;
import org.eclipse.ice.datastructures.form.Form;
import org.eclipse.ice.datastructures.form.MeshComponent;
import org.eclipse.ice.viz.service.mesh.properties.MeshSelection;
import org.eclipse.ice.viz.service.modeling.AbstractController;
import org.eclipse.ice.viz.service.modeling.Face;
import org.eclipse.jface.viewers.ISelection;
......
......@@ -26,6 +26,9 @@ import org.eclipse.ice.datastructures.form.DataComponent;
import org.eclipse.ice.datastructures.form.Entry;
import org.eclipse.ice.datastructures.form.MeshComponent;
import org.eclipse.ice.viz.service.geometry.shapes.FXShapeControllerFactory;
import org.eclipse.ice.viz.service.mesh.datastructures.BoundaryCondition;
import org.eclipse.ice.viz.service.mesh.datastructures.BoundaryConditionType;
import org.eclipse.ice.viz.service.mesh.datastructures.NekPolygon;
import org.eclipse.ice.viz.service.modeling.Edge;
import org.eclipse.ice.viz.service.modeling.EdgeComponent;
import org.eclipse.ice.viz.service.modeling.FaceComponent;
......
/*******************************************************************************
* 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:
* Robert Smith
*******************************************************************************/
package org.eclipse.ice.viz.service.mesh.datastructures;
import org.eclipse.ice.viz.service.modeling.AbstractController;
import org.eclipse.ice.viz.service.modeling.AbstractView;
import org.eclipse.ice.viz.service.modeling.Edge;
import org.eclipse.ice.viz.service.modeling.EdgeComponent;
/**
* An extension of edge that manages its vertices' states as being selected and
* under cosntruction.
*
* @author Robert Smith
*
*/
public class FXEdge extends Edge {
/**
* The default constructor
*
* @param model
* The edge's model
* @param view
* The edge's view
*/
public FXEdge(EdgeComponent model, AbstractView view) {
super(model, view);
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.ice.viz.service.modeling.AbstractController#setProperty(java.
* lang.String, java.lang.String)
*/
@Override
public void setProperty(String property, String value) {
// If the Edge's constructing or selected properties are being changed,
// propagate that change to its vertices
if ("Constructing".equals(property) || "Selected".equals(property)) {
// Lock notifications from changing own vertices
notifyLock.set(true);
for (AbstractController vertex : model
.getEntitiesByCategory("Vertices")) {
vertex.setProperty(property, value);
}
notifyLock.set(false);
}
super.setProperty(property, value);
}
}
/*******************************************************************************
* 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:
* Robert Smith
*******************************************************************************/
package org.eclipse.ice.viz.service.mesh.datastructures;
import org.eclipse.ice.viz.service.modeling.AbstractController;
import org.eclipse.ice.viz.service.modeling.AbstractView;
import org.eclipse.ice.viz.service.modeling.Face;
import org.eclipse.ice.viz.service.modeling.FaceComponent;
/**
* An extension of Face for JavaFX that manages its edges' status as under
* construction and selected.
*
* @author Robert Smith
*
*/
public class FXFace extends Face {
public FXFace() {
super();
}
public FXFace(FaceComponent model, AbstractView view) {
super(model, view);
}
@Override
public void setProperty(String property, String value) {
// If the Edge's constructing or selected properties are being changed,
// propogate that change to its vertices
if ("Constructing".equals(property) || "Selected".equals(property)) {
// Lock notifications from changing own edges
notifyLock.set(true);
for (AbstractController vertex : model
.getEntitiesByCategory("Edges")) {
vertex.setProperty(property, value);
}
notifyLock.set(false);
}
super.setProperty(property, value);
}
}
......@@ -169,6 +169,10 @@ public class FXVertexView extends AbstractView {
}
}
}
else {
mesh.setMaterial(constructingMaterial);
}
}
/*
......
/********************************************************************************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;
import java.util.ArrayList;import java.util.HashMap;import java.util.HashSet;import java.util.Map.Entry;import java.util.Set;import java.util.TreeMap;import java.util.TreeSet;import java.util.concurrent.atomic.AtomicBoolean;
import javax.xml.bind.annotation.XmlAccessType;import javax.xml.bind.annotation.XmlAccessorType;import javax.xml.bind.annotation.XmlRootElement;import javax.xml.bind.annotation.XmlTransient;
**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;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map.Entry;
import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;
import java.util.concurrent.atomic.AtomicBoolean;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
import org.eclipse.ice.viz.service.datastructures.VizObject.VizObject;
/***<p>*Composite container for Polygons along with any additional information*required to interpret the mesh data.<br>*<br>*The VizMeshComponent breaks a mesh down into vertices and edges.As/polygons are*added,the new edges and vertices are incorporated into the mesh,and*IUpdateableListeners registered with the VizMeshComponent are notified that/it*has changed.<br>*<br>*All polygons are expected to have a unique ID among all other polygons./This*also holds for vertices and edges.*</p>**
/***
* <p>
* *Composite container for Polygons along with any additional
* information*required to interpret the mesh data.<br>
* *<br>
* *The VizMeshComponent breaks a mesh down into vertices and edges.As/polygons
* are*added,the new edges and vertices are incorporated into the
* mesh,and*IUpdateableListeners registered with the VizMeshComponent are
* notified that/it*has changed.<br>
* *<br>
* *All polygons are expected to have a unique ID among all other
* polygons./This*also holds for vertices and edges.*
* </p>
* **
*
* @author Jordan H.Deyton
*/
@author
Jordan H.Deyton*/@XmlRootElement(name = "VizMeshComponent")
@XmlRootElement(name = "VizMeshComponent")
@XmlAccessorType(XmlAccessType.FIELD)
public class VizMeshComponent extends VizObject implements IMeshPart {
......@@ -78,31 +104,32 @@ public class VizMeshComponent extends VizObject implements IMeshPart {
private final AtomicBoolean copying;
/**
* <p>
* The default constructor for a VizMeshComponent. Initializes the list of
* polygons and any associated bookkeeping structures.
* </p>
*
*/
public VizMeshComponent() {
super();
* <p>
* The default constructor for a VizMeshComponent. Initializes the list of
* polygons and any associated bookkeeping structures.
* </p>
*
*/
public VizMeshComponent() {
super();
// Initialize the trees of shapes, vertices, and edges.
polygons = new TreeMap<Integer, Polygon>();
vertices = new TreeMap<Integer, Vertex>();
edges = new TreeMap<Integer, Edge>();
// Initialize the trees of shapes, vertices, and edges.
polygons = new TreeMap<Integer, Polygon>();
vertices = new TreeMap<Integer, Vertex>();
edges = new TreeMap<Integer, Edge>();
// Initialize the trees of polygon IDs per vertex/edge.
vertexPolygons = new TreeMap<Integer, TreeSet<Integer>>();
edgePolygons = new TreeMap<Integer, TreeSet<Integer>>();
vertexEdges = new TreeMap<Integer, TreeSet<Integer>>();
// Initialize the trees of polygon IDs per vertex/edge.
vertexPolygons = new TreeMap<Integer, TreeSet<Integer>>();
edgePolygons = new TreeMap<Integer, TreeSet<Integer>>();
vertexEdges = new TreeMap<Integer, TreeSet<Integer>>();
// Initialize the flag to signify when the VizMeshComponent is copying data
// from another VizMeshComponent.
copying = new AtomicBoolean(false);
// Initialize the flag to signify when the VizMeshComponent is copying
// data
// from another VizMeshComponent.
copying = new AtomicBoolean(false);
return;
}
return;
}
/**
* <p>
......
......@@ -21,7 +21,6 @@ import org.eclipse.ice.viz.service.geometry.scene.model.IAttachment;
import org.eclipse.ice.viz.service.geometry.scene.model.INode;
import org.eclipse.ice.viz.service.javafx.internal.Util;
import org.eclipse.ice.viz.service.modeling.AbstractController;
import org.eclipse.ice.viz.service.modeling.Shape;
import javafx.scene.Group;
import javafx.scene.Node;
......@@ -157,7 +156,7 @@ public class FXMeshAttachment extends GeometryAttachment {
* an ICE Geometry IShape
*/
@Override
public void processShape(Shape shape) {
public void processShape(AbstractController shape) {
// Nothing to do.
}
......@@ -165,7 +164,7 @@ public class FXMeshAttachment extends GeometryAttachment {
*
*/
@Override
protected void disposeShape(Shape shape) {
protected void disposeShape(AbstractController shape) {
Node node = (Group) shape.getRepresentation();
if (node == null) {
......@@ -181,7 +180,7 @@ public class FXMeshAttachment extends GeometryAttachment {
* @return
*/
@Override
public List<Shape> getShapes(boolean copy) {
public List<AbstractController> getShapes(boolean copy) {
return super.getShapes(copy);
}
......
......@@ -21,10 +21,17 @@ import org.eclipse.ice.viz.service.datastructures.VizObject.IVizUpdateableListen
import org.eclipse.ice.viz.service.geometry.scene.base.GNode;
import org.eclipse.ice.viz.service.geometry.scene.base.GeometryAttachment;
import org.eclipse.ice.viz.service.geometry.scene.model.INode;
import org.eclipse.ice.viz.service.geometry.shapes.FXShapeControllerFactory;
import org.eclipse.ice.viz.service.geometry.viewer.GeometryViewer;
import org.eclipse.ice.viz.service.geometry.viewer.IRenderer;
import org.eclipse.ice.viz.service.mesh.datastructures.IMeshVizCanvas;
import org.eclipse.ice.viz.service.modeling.AbstractController;
import org.eclipse.ice.viz.service.modeling.Edge;
import org.eclipse.ice.viz.service.modeling.EdgeAndVertexFaceComponent;
import org.eclipse.ice.viz.service.modeling.EdgeComponent;
import org.eclipse.ice.viz.service.modeling.Face;
import org.eclipse.ice.viz.service.modeling.Vertex;
import org.eclipse.ice.viz.service.modeling.VertexComponent;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.swt.SWT;
......@@ -32,6 +39,14 @@ import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.ISelectionListener;
import javafx.event.EventHandler;
import javafx.geometry.Point3D;
import javafx.scene.Group;
import javafx.scene.Node;
import javafx.scene.input.MouseEvent;
import javafx.scene.input.PickResult;
import javafx.scene.shape.Shape3D;
/**
* <p>
* GeometryCanvas provides the ability to visualize and manipulate 3D geometry
......@@ -67,13 +82,37 @@ public class FXMeshCanvas implements IMeshVizCanvas, IVizUpdateableListener {
/** ICE properties. */
private Map<String, String> properties;
private ArrayList<ISelectionListener> listeners;
/**
* A manager for the selection state of the entities displayed on this
* canvas.
* A handler which places new polygons on the screen based on mouse clicks.
*/
MeshSelectionManager manager;
private EventHandler<MouseEvent> addHandler;
private ArrayList<ISelectionListener> listeners;
/**
* A handler which allows the user to select and drag vertices with the
* mouse.
*/
private EventHandler<MouseEvent> editHandler;
/**
* A list of vertices currently selected by the user, because they were
* selected in edit mode or were input vertices which have not yet been
* formed into a complete polygon in add mode.
*/
private ArrayList<AbstractController> selectedVertices;
/**
* A list of edges input by the user which have not yet been formed into a
* complete polygon
*/
private ArrayList<AbstractController> tempEdges;
/**
* The factory responsible for creating views/controllers for new model
* components.
*/
private FXShapeControllerFactory factory;
/**
* <p>
......@@ -84,8 +123,153 @@ public class FXMeshCanvas implements IMeshVizCanvas, IVizUpdateableListener {
* ICE Geometry instance to visualizer in the canvas.
*/
public FXMeshCanvas(AbstractController mesh) {
// Initialize the data members
this.mesh = mesh;
listeners = new ArrayList<ISelectionListener>();
factory = new FXShapeControllerFactory();
selectedVertices = new ArrayList<AbstractController>();
tempEdges = new ArrayList<AbstractController>();
// Create the handler for add mode
addHandler = new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent event) {
// Get the user's selection
PickResult pickResult = event.getPickResult();
Node intersectedNode = pickResult.getIntersectedNode();
// Whether or not a new vertex has been added
boolean changed = false;
// If the user clicked a shape, try to add it to a polygon
if (intersectedNode instanceof Shape3D) {
// Resolve the parent
Group nodeParent = (Group) intersectedNode.getParent();
// Resolve the shape
AbstractController modelShape = (AbstractController) nodeParent
.getProperties().get(AbstractController.class);
// If the vertex is already in the polygon currently being
// constructed, ignore it
if (selectedVertices.contains(modelShape)) {
return;
}
// If the selected shape is a vertex, add it to the list
if (modelShape instanceof Vertex) {
selectedVertices.add(modelShape);
changed = true;
// Change the vertex's color to show that it is part of
// the new polygon
modelShape.setProperty("Constructing", "True");
}
}
// If the user didn't select a shape, add a new shape where they
// clicked
else {
// Get the click location
Point3D location = pickResult.getIntersectedPoint();
// Create a new vertex at that point
VertexComponent tempComponent = new VertexComponent(
location.getX(), 0, location.getZ());
Vertex tempVertex = (Vertex) factory
.createController(tempComponent);
// Add the new vertex to the list
selectedVertices.add(tempVertex);
changed = true;
}
// If a new vertex was added, then construct edges/polygons as
// needed
if (changed) {
// The number of vertices in the polygon under construction
int numVertices = selectedVertices.size();
// If this is not the first vertex, create an edge between
// it and the last one
if (numVertices > 1) {
EdgeComponent tempComponent = new EdgeComponent();
Edge tempEdge = (Edge) factory
.createController(tempComponent);
tempEdge.addEntity(selectedVertices.get(numVertices - 2));
tempEdge.addEntity(selectedVertices.get(numVertices - 1));
// Add the edge to the list
tempEdges.add(tempEdge);
}
// If this was the fourth vertex, the quadrilateral is done
// so finish up the polygon
if (numVertices == 4) {
// Crete an edge between the last vertex and the first
EdgeComponent tempComponent = new EdgeComponent();
Edge tempEdge = (Edge) factory
.createController(tempComponent);
tempEdge.addEntity(selectedVertices.get(numVertices - 1));
tempEdge.addEntity(selectedVertices.get(0));
tempEdges.add(tempEdge);
// Create a face out of all the edges
EdgeAndVertexFaceComponent faceComponent = new EdgeAndVertexFaceComponent();
Face newFace = (Face) factory
.createController(faceComponent);
for (AbstractController edge : tempEdges) {
newFace.addEntity(edge);
}
// Set the new polygon to the default color
newFace.setProperty("Constructing", "False");
// Empty the lists of temporary constructs
selectedVertices = new ArrayList<AbstractController>();
tempEdges = new ArrayList<AbstractController>();
}
}
}
};
//Create the handler for edit mode
editHandler = new EventHandler<MouseEvent>(){
@Override
public void handle(MouseEvent event) {
// Get the user's selection
PickResult pickResult = event.getPickResult();
Node intersectedNode = pickResult.getIntersectedNode();
if (intersectedNode instanceof Shape3D){
// Resolve the parent
Group nodeParent = (Group) intersectedNode.getParent();
// Resolve the shape
AbstractController modelShape = (AbstractController) nodeParent
.getProperties().get(AbstractController.class);
if (modelShape instanceof Vertex){
if()
}
}
}
};
}
/**
......@@ -294,4 +478,28 @@ public class FXMeshCanvas implements IMeshVizCanvas, IVizUpdateableListener {
}
@Override
public boolean HUDIsVisible() {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean AxisAreVisible() {
// TODO Auto-generated method stub
return false;
}
@Override
public void deleteSelection() {
// TODO Auto-generated method stub
}
@Override
public void setSelection(Object[] selection) {
// TODO Auto-generated method stub
}
}
......@@ -10,9 +10,12 @@
*******************************************************************************/
package org.eclipse.ice.viz.service.mesh.javafx;
import java.util.ArrayList;
import org.eclipse.ice.viz.service.geometry.GeometrySelection;
import org.eclipse.ice.viz.service.geometry.scene.base.GeometryAttachment;
import org.eclipse.ice.viz.service.geometry.scene.base.ICamera;
import org.eclipse.ice.viz.service.geometry.shapes.FXShapeControllerFactory;
import org.eclipse.ice.viz.service.geometry.viewer.GeometryViewer;