Commit b4449572 authored by Robert Smith's avatar Robert Smith
Browse files

Geometry Editor is now saveable



The Geometry Editor will can now be saved to xml when a change occurs to
its data.
Signed-off-by: Robert Smith's avatarRobert Smith <SmithRW@ornl.gov>
parent 47885a0a
......@@ -15,17 +15,18 @@ package org.eclipse.ice.client.widgets;
import org.eclipse.eavp.viz.service.IVizCanvas;
import org.eclipse.eavp.viz.service.IVizService;
import org.eclipse.eavp.viz.service.IVizServiceFactory;
import org.eclipse.eavp.viz.service.geometry.widgets.ShapeTreeView;
import org.eclipse.eavp.viz.service.geometry.widgets.TransformationView;
import org.eclipse.ice.datastructures.ICEObject.IUpdateable;
import org.eclipse.ice.datastructures.ICEObject.IUpdateableListener;
import org.eclipse.ice.datastructures.form.GeometryComponent;
import org.eclipse.eavp.viz.service.geometry.widgets.ShapeTreeView;
import org.eclipse.eavp.viz.service.geometry.widgets.TransformationView;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.forms.IManagedForm;
import org.eclipse.ui.forms.editor.FormEditor;
import org.eclipse.ui.forms.widgets.ScrolledForm;
......@@ -117,7 +118,19 @@ public class ICEGeometryPage extends ICEFormPage
* @param geometryComponent
*/
public void setGeometry(GeometryComponent geometryComponent) {
// Unregister from the old component
if (geometryComp != null) {
geometryComp.unregister(this);
}
// Set the component
geometryComp = geometryComponent;
// Register with the new component
if (geometryComp != null) {
geometryComp.register(this);
}
}
/**
......@@ -208,7 +221,14 @@ public class ICEGeometryPage extends ICEFormPage
*/
@Override
public void update(IUpdateable component) {
dirty = true;
// If the geometry was updated, the editor is now dirty
PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
editor.setDirty(true);
};
});
}
@Override
......
......@@ -20,14 +20,14 @@ import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
import org.eclipse.eavp.viz.modeling.properties.MeshProperty;
import org.eclipse.eavp.viz.service.IVizService;
import org.eclipse.eavp.viz.service.geometry.persistence.PersistableShape;
import org.eclipse.eavp.viz.modeling.ShapeController;
import org.eclipse.eavp.viz.modeling.ShapeMesh;
import org.eclipse.eavp.viz.datastructures.VizObject.IManagedUpdateable;
import org.eclipse.eavp.viz.datastructures.VizObject.IManagedUpdateableListener;
import org.eclipse.eavp.viz.datastructures.VizObject.SubscriptionType;
import org.eclipse.eavp.viz.modeling.ShapeController;
import org.eclipse.eavp.viz.modeling.ShapeMesh;
import org.eclipse.eavp.viz.modeling.properties.MeshProperty;
import org.eclipse.eavp.viz.service.IVizService;
import org.eclipse.eavp.viz.service.geometry.persistence.PersistableShape;
import org.eclipse.ice.datastructures.ICEObject.Component;
import org.eclipse.ice.datastructures.ICEObject.ICEObject;
import org.eclipse.ice.datastructures.ICEObject.IUpdateable;
......@@ -46,13 +46,13 @@ import org.eclipse.ice.datastructures.componentVisitor.IComponentVisitor;
@XmlAccessorType(XmlAccessType.FIELD)
public class GeometryComponent extends ICEObject
implements Component, IUpdateableListener, IManagedUpdateableListener {
/**
* The component's geometry in a temporary compresed form.
*/
@XmlTransient
private PersistableShape compressedGeometry;
/**
* <p>
* The set of ComponentListeners observing the GeometryComponent
......@@ -67,7 +67,7 @@ public class GeometryComponent extends ICEObject
*/
@XmlTransient
private ShapeController geometry;
/**
* The service being used to render this component.
*/
......@@ -146,14 +146,15 @@ public class GeometryComponent extends ICEObject
public ShapeController getGeometry() {
return geometry;
}
/**
* Get the component's geometry in a persistable format. It is intended that this function will only be called by JAXB.
* Get the component's geometry in a persistable format. It is intended that
* this function will only be called by JAXB.
*
* @return A PersistableShape representing the component's CSG tree
*/
@XmlElement
private PersistableShape getPersistableGeometry(){
@XmlElement(name = "Geometry")
private PersistableShape getPersistableGeometry() {
return PersistableShape.compress((ShapeMesh) geometry.getModel());
}
......@@ -175,35 +176,42 @@ public class GeometryComponent extends ICEObject
// Notify listeners
notifyListeners();
}
/**
* Set the compressed form of the component's geometry. It is intended that this function will only be called by JAXB.
* Set the compressed form of the component's geometry. It is intended that
* this function will only be called by JAXB.
*
* @param root The compressed root of the CSG tree to be displayed by this component.
* @param root
* The compressed root of the CSG tree to be displayed by this
* component.
*/
private void setPersistableGeometry(PersistableShape root){
private void setPersistableGeometry(PersistableShape root) {
compressedGeometry = root;
}
/**
* Set the IVizService that will be used to visualize this component.
*
* @param service The service that will be used to visualize this component.
* @param service
* The service that will be used to visualize this component.
*/
public void setService(IVizService service){
public void setService(IVizService service) {
this.service = service;
//If a geometry was read from the xml, expand it
if(compressedGeometry != null){
//Unregister from the old geometry
geometry.unregister(this);
//Set the component's contents to a full version of the geometry
// If a geometry was read from the xml, expand it
if (compressedGeometry != null) {
// Unregister from the old geometry
if (geometry != null) {
geometry.unregister(this);
}
// Set the component's contents to a full version of the geometry
geometry = compressedGeometry.unpack(service.getFactory());
geometry.register(this);
//The full geometry is now in memory, so delete the compressed version
// The full geometry is now in memory, so delete the compressed
// version
compressedGeometry = null;
}
}
......@@ -214,7 +222,7 @@ public class GeometryComponent extends ICEObject
* </p>
*
* @return
* <p>
* <p>
* The hashcode of the ICEObject.
* </p>
*/
......@@ -240,7 +248,7 @@ public class GeometryComponent extends ICEObject
* The other ICEObject that should be compared with this one.
* </p>
* @return
* <p>
* <p>
* True if the ICEObjects are equal, false otherwise.
* </p>
*/
......@@ -295,9 +303,12 @@ public class GeometryComponent extends ICEObject
super.copy(iceObject);
// Copy shapes list
this.setGeometry((ShapeController) iceObject.getGeometry().clone());
// this.geometry.copy(iceObject.getGeometry());
ShapeController otherGeometry = iceObject.getGeometry();
if (otherGeometry != null) {
this.setGeometry((ShapeController) otherGeometry.clone());
} else {
geometry = null;
}
this.notifyListeners();
}
......@@ -309,7 +320,7 @@ public class GeometryComponent extends ICEObject
* </p>
*
* @return
* <p>
* <p>
* The new clone
* </p>
*/
......@@ -424,9 +435,7 @@ public class GeometryComponent extends ICEObject
*/
@Override
public void update(IManagedUpdateable component, SubscriptionType[] type) {
notifyListeners();
}
/*
......
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