Commit 4553b9d0 authored by Robert Smith's avatar Robert Smith
Browse files

Various bug fixes



Fixed issues with the mesh editor allowing users to drag vertices off
the grid, the geometry editor camera behaving oddly at the start of a
drag, and many packages referencing Java 7 instead of 8.
Signed-off-by: Robert Smith's avatarRobert Smith <SmithRW@ornl.gov>
parent 0b0352b2
......@@ -33,32 +33,32 @@ public class Extrema {
/**
* The region's maximum x coordinate.
*/
double maxX;
private double maxX;
/**
* The region's maximum y coordinate.
*/
double maxY;
private double maxY;
/**
* The region's maximum z coordinate.
*/
double maxZ;
private double maxZ;
/**
* The region's minimum x coordinate.
*/
double minX;
private double minX;
/**
* The region's minimum y coordinate.
*/
double minY;
private double minY;
/**
* The region's minimum z coordinate.
*/
double minZ;
private double minZ;
/**
* A constructor which initializes the extrema to the given values
......
......@@ -43,6 +43,7 @@ import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.scene.input.MouseEvent;
import javafx.scene.input.PickResult;
import javafx.scene.layout.BorderPane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Box;
import javafx.scene.shape.Shape3D;
......@@ -582,70 +583,92 @@ public class FXMeshViewer extends FXViewer {
PickResult pickResult = event.getPickResult();
Node intersectedNode = pickResult.getIntersectedNode();
// If the user is not dragging a shape, ignore the motion
if (intersectedNode instanceof Shape3D || dragStarted) {
// The drag has started, so continue dragging even if the
// mouse has moved off a shape
dragStarted = true;
// The drag has started, so continue dragging even if the
// mouse has moved off a shape
dragStarted = true;
// Resolve the parent
Group nodeParent = (Group) intersectedNode.getParent();
// Resolve the parent
Group nodeParent = (Group) intersectedNode.getParent();
// Resolve the shape
AbstractController modelShape = (AbstractController) nodeParent
.getProperties().get(AbstractController.class);
// Resolve the shape
AbstractController modelShape = (AbstractController) nodeParent
.getProperties().get(AbstractController.class);
// If the user has selected a vertex, drag it
if (selectedVertices.contains(modelShape) || dragStarted) {
// If the vertex markers have not yet been made,
// create them
if (vertexMarkers.isEmpty()) {
// If the user has selected a vertex, drag it
if (selectedVertices.contains(modelShape) || dragStarted) {
// Get the location of the vertex which was clicked
double[] cursorLocation = ((VertexController) modelShape)
.getTranslation();
// If the vertex markers have not yet been made,
// create them
if (vertexMarkers.isEmpty()) {
for (AbstractController vertex : selectedVertices) {
// Get the location of the vertex which was clicked
double[] cursorLocation = ((VertexController) modelShape)
// Create the circle
Sphere marker = new Sphere(1);
// Place it at the vertex's position
double[] position = ((VertexController) vertex)
.getTranslation();
marker.setTranslateX(position[0]);
marker.setTranslateY(position[1]);
for (AbstractController vertex : selectedVertices) {
// Add it to the list
vertexMarkers.add(marker);
// Create the circle
Sphere marker = new Sphere(1);
// marker.setScaleZ(.25d);
// Get the relative position of this vertex from
// the vertex being dragged
relativeXCords.add(position[0] - cursorLocation[0]);
relativeYCords.add(position[1] - cursorLocation[1]);
// Place it at the vertex's position
double[] position = ((VertexController) vertex)
.getTranslation();
marker.setTranslateX(position[0]);
marker.setTranslateY(position[1]);
((FXAttachment) attachmentManager.getAttachments().get(1))
.getFxNode().getChildren().add(marker);
// Add it to the list
vertexMarkers.add(marker);
}
}
// Get the relative position of this vertex from
// the vertex being dragged
relativeXCords.add(position[0] - cursorLocation[0]);
relativeYCords.add(position[1] - cursorLocation[1]);
// Move each vertex
for (int i = 0; i < vertexMarkers.size(); i++) {
((FXAttachment) attachmentManager.getAttachments()
.get(1)).getFxNode().getChildren().add(marker);
// Get the vertex marker for this index
Sphere marker = vertexMarkers.get(i);
// The adjustments to the markers needed to keep them inside
// the grid
double xAdjust = 0;
double yAdjust = 0;
// Set the xAdjust so that all coordinates are within the
// bounds of the grid, adjusted for drawing scale
for (Double x : relativeXCords) {
if (x + mousePosX + xAdjust < -16d * SCALE) {
xAdjust = -16d * SCALE - x - mousePosX;
} else if (x + mousePosX + xAdjust > 16d * SCALE) {
xAdjust = 16d * SCALE - x - mousePosX;
}
}
// Move each vertex
for (int i = 0; i < vertexMarkers.size(); i++) {
// Get the vertex marker for this index
Sphere marker = vertexMarkers.get(i);
// Move the vertex to the mouse's current
// position, offset by the original distance
// between the vertices.
marker.setTranslateX(relativeXCords.get(i) + mousePosX);
marker.setTranslateY(relativeYCords.get(i) + mousePosY);
// Set the yAdjust so that all coordinates are within the
// bounds of the grid, adjusted for drawing scale
for (Double y : relativeYCords) {
if (y + mousePosY + yAdjust < -8d * SCALE) {
yAdjust = -8d * SCALE - y - mousePosY;
} else if (y + mousePosY + yAdjust > 8d * SCALE) {
yAdjust = 8d * SCALE - y - mousePosY;
}
}
// Move the vertex to the mouse's current
// position, offset by the original distance
// between the vertices and adjusted to lay within the
// bounds of the grid.
marker.setTranslateX(
relativeXCords.get(i) + mousePosX + xAdjust);
marker.setTranslateY(
relativeYCords.get(i) + mousePosY + yAdjust);
}
}
......@@ -670,17 +693,19 @@ public class FXMeshViewer extends FXViewer {
mousePosX = event.getX();
mousePosY = event.getY();
// Update the vertices
for (int i = 0; i < selectedVertices.size(); i++) {
// Get the vertex
VertexController vertex = (VertexController) selectedVertices
.get(i);
// Update its position, corected for the scale the editor is
// drawn at
// Set the vertex's location to the current location of the
// temporary marker in the scene
vertex.updateLocation(
(relativeXCords.get(i) + mousePosX) / SCALE,
(relativeYCords.get(i) + mousePosY) / SCALE, 0);
vertexMarkers.get(i).getTranslateX() / SCALE,
vertexMarkers.get(i).getTranslateY() / SCALE,
vertexMarkers.get(i).getTranslateZ() / SCALE);
// Remove the markers from the scene
for (Sphere marker : vertexMarkers) {
......@@ -705,15 +730,15 @@ public class FXMeshViewer extends FXViewer {
*/
private void handleMouseMoved(MouseEvent event) {
DecimalFormat format = new DecimalFormat("#.##");
// cursorPosition
// .setText("Cursor position (x,y): ("
// + format.format(event.getPickResult()
// .getIntersectedPoint().getX() / 3)
// + ","
// + event.getPickResult().getIntersectedPoint().getY() / 3
// + ")");
// cursorPosition.setTranslateX(scene.getWidth() / -20);
// cursorPosition.setTranslateZ(-5);
cursorPosition
.setText("Cursor position (x,y): ("
+ format.format(event.getPickResult()
.getIntersectedPoint().getX() / 3)
+ ","
+ event.getPickResult().getIntersectedPoint().getY() / 3
+ ")");
cursorPosition.setTranslateX(scene.getWidth() / -20);
cursorPosition.setTranslateZ(-5);
}
/**
......@@ -987,6 +1012,8 @@ public class FXMeshViewer extends FXViewer {
cursorPosition = new Text();
cursorPosition.setTranslateZ(-5);
internalRoot.getChildren().add(cursorPosition);
BorderPane pane = new BorderPane();
internalRoot.getChildren().add(pane);
}
}
\ No newline at end of file
......@@ -173,6 +173,15 @@ public class AbstractCameraController implements ICameraController {
});
// Set the handler for releasing the mouse button
scene.setOnMouseReleased(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent arg0) {
handleMouseReleased(arg0);
}
});
// Set the behavior for mouse scroll events
scene.setOnScroll(new EventHandler<ScrollEvent>() {
@Override
......@@ -227,6 +236,18 @@ public class AbstractCameraController implements ICameraController {
}
/**
* This function defines the camera's behavior when a mouse button is
* released. By default, it does nothing. It is intended to be overwritten
* by subclasses.
*
* @param event
* An event sent to the scene.
*/
public void handleMouseReleased(MouseEvent event) {
}
/**
* This function defines the camera's behavior when the mouse wheel is
* scrolled. By default, it does nothing. It is intended to be overwritten
......
......@@ -40,6 +40,8 @@ public class CenteredCameraController extends AbstractCameraController {
*/
final private double SPEED = 50;
private boolean dragStarted;
/**
* The X rotation applied to the camera.
*/
......@@ -69,6 +71,9 @@ public class CenteredCameraController extends AbstractCameraController {
FXCanvas canvas) {
super(camera, scene, canvas);
// Initialize the data members
dragStarted = false;
// Set the x axis rotation for the affine transformation
x = new Rotate();
x.setAxis(Rotate.X_AXIS);
......@@ -101,21 +106,45 @@ public class CenteredCameraController extends AbstractCameraController {
mouseOldX = mousePosX;
mouseOldY = mousePosY;
// Get the current mouse position and calculate the deltas
// Get the current mouse position
mousePosX = event.getSceneX();
mousePosY = event.getSceneY();
mouseDeltaX = (mousePosX - mouseOldX);
mouseDeltaY = (mousePosY - mouseOldY);
// Apply the change in mouse position to the camera's angle
if (event.isPrimaryButtonDown()) {
// If a drag action is in progress, adjust the camera angle
if (dragStarted) {
y.setAngle(y.getAngle() - mouseDeltaX);
x.setAngle(x.getAngle() + mouseDeltaY);
// Calculate the change in mouse position
mouseDeltaX = (mousePosX - mouseOldX);
mouseDeltaY = (mousePosY - mouseOldY);
// Apply the change in mouse position to the camera's angle
if (event.isPrimaryButtonDown()) {
y.setAngle(y.getAngle() - mouseDeltaX);
x.setAngle(x.getAngle() + mouseDeltaY);
}
}
// Ignore the first event of a drag action, as the mouse position will
// not be properly initialized during it
else {
dragStarted = true;
}
}
/*
* (non-Javadoc)
*
* @see org.eclipse.ice.viz.service.javafx.internal.scene.camera.
* AbstractCameraController#handleMouseReleased(javafx.scene.input.
* MouseEvent)
*/
@Override
public void handleMouseReleased(MouseEvent event) {
// End the current drag action, if any
dragStarted = false;
}
/*
* (non-Javadoc)
*
......
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src/"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src/"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.7
org.eclipse.jdt.core.compiler.source=1.8
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.7
org.eclipse.jdt.core.compiler.source=1.8
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.7
org.eclipse.jdt.core.compiler.source=1.8
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.7
org.eclipse.jdt.core.compiler.source=1.8
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.7
org.eclipse.jdt.core.compiler.source=1.8
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.7
org.eclipse.jdt.core.compiler.source=1.8
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.7
org.eclipse.jdt.core.compiler.source=1.8
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