de.grogra.imp3d.edit
Class ToolRoot3D

java.lang.Object
  extended by de.grogra.graph.impl.Edge
      extended by de.grogra.graph.impl.Node
          extended by de.grogra.imp.edit.ToolRoot
              extended by de.grogra.imp3d.edit.ToolRoot3D
All Implemented Interfaces:
Transformation, Manageable, PersistenceCapable, Shareable, UserFields, XObject, Disposable, Map, java.io.Serializable, java.util.EventListener
Direct Known Subclasses:
TransformTool

public abstract class ToolRoot3D
extends ToolRoot
implements Transformation, EventListener

This class is the base class for roots of tool graphs which manipulate 3D objects (the latter are called tool targets). It defines three coordinate systems:

  1. The parent coordinate system is the coordinate system of the parent object of the tool target.
  2. The target coordinate system is the coordinate system of the tool target. It is computed by the method computeTargetTransformation(Matrix4d, Matrix4d) based on the global transformation of the parent coordinate system.
  3. The tool coordinate system is the coordinate system of the tool graph. Normally, the translational and rotational components of its transformation matrix are equal to those of the target coordinate system. However, the scaling factors differ to ensure a constant size of the tool handles (independent of the size of the tool target).
This class implements Transformation such that its local coordinates correspond to the tool coordinate system.

Author:
Ole Kniemeyer
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class de.grogra.graph.impl.Node
Node.AccessorBridge, Node.FieldAttributeAccessor, Node.NType
 
Nested classes/interfaces inherited from interface de.grogra.util.EventListener
EventListener.Bicast, EventListener.Multicaster
 
Nested classes/interfaces inherited from interface de.grogra.util.Map
Map.Chain
 
Field Summary
static Node.NType $TYPE
           
 
Fields inherited from class de.grogra.imp.edit.ToolRoot
tool
 
Fields inherited from class de.grogra.graph.impl.Node
ADDITIONAL_FIELDS, bits, DELETED, EXTENT_BIT, EXTENT_MASK, extentIndex$FIELD, extentTail$FIELD, HAS_OBSERVERS, IS_INTERPRETIVE, isInterpretive$FIELD, LAST_EXTENT_INDEX, layer$FIELD, MARK, mark$FIELD, MIME_TYPE, MIN_UNUSED_SPECIAL_OF_SOURCE, MIN_UNUSED_SPECIAL_OF_TARGET, name$FIELD, USED_BITS
 
Fields inherited from interface de.grogra.util.Map
DEFAULT_VALUE, EMPTY_MAP
 
Constructor Summary
ToolRoot3D()
           
 
Method Summary
protected static void adjustScale(Matrix4d t, CameraBase c, float scale)
           
protected  void adjustToolTransformation(Matrix4d t, CameraBase c)
          This method is invoked to compute an adjustment of the tool coordinates system.
protected  void attributeChanged(Attribute[] a)
          This method is invoked to notify the tool root about modifications of attributes of the tool target.
protected abstract  void computeTargetTransformation(Matrix4d t, Matrix4d parent)
          This method is invoked to compute the transformation matrix from target coordinates to world coordinates, based on the transformation matrix from parent coordinates to world coordinates.
 void dispose()
           
 void eventOccured(java.util.EventObject e)
          This method implements the EventListener-interface.
protected  Matrix4d getAdjustment()
          This method returns the adjustment matrix from tool coordinates to target coordinates.
protected  Matrix4d getParentTransformation()
          This method returns the transformation matrix from parent coordinates to world coordinates.
protected  Matrix4d getTargetTransformation()
          This method returns the transformation matrix from target coordinates to world coordinates.
protected  Matrix4d getToolTransformation()
          This method returns the transformation matrix from tool coordinates to world coordinates.
protected  boolean initialize(Tool tool)
          Initializes this tool root.
 void postTransform(java.lang.Object object, boolean asNode, Matrix4d in, Matrix4d out, Matrix4d pre, GraphState gs)
          Implements the change from object's transformation in to the object's post-transformation out.
 void preTransform(java.lang.Object object, boolean asNode, Matrix4d in, Matrix4d out, GraphState gs)
          Implements the change from the parent's post-transformation in to the object's transformation out.
 
Methods inherited from class de.grogra.imp.edit.ToolRoot
executeWithWriteLock, getToolTarget, isTargetNode
 
Methods inherited from class de.grogra.graph.impl.Node
addEdgeBitsTo, addReference, appendBranchNode, appendBranchNode, appendReferencesTo, clone, clone, cloneGraph, dump, dumpTree, dup, dupUnmanagedFields, edgeChanged, fieldModified, findAdjacent, get, getAccessor, getAccessor, getAttributes, getAxisParent, getBoolean, getBranch, getBranchLength, getBranchNode, getBranchTail, getByte, getChar, getCommonAncestor, getCurrentGraphState, getDirectChildCount, getDouble, getEdgeAttributeAccessor, getEdgeAttributes, getEdgeBitsTo, getEdgeTo, getExtentIndex, getFirst, getFirstEdge, getFloat, getGraph, getId, getIndex, getInstantiator, getInt, getLayer, getLong, getManageableType, getName, getNeighbor, getNext, getNType, getNTypeImpl, getObject, getOrCreateEdgeTo, getOrNull, getPersistenceManager, getPredecessor, getProvider, getShort, getSource, getStamp, getSuccessor, getSymbol, getSymbolColor, getTarget, getTransaction, getUserField, getUserFieldCount, getXClass, getXData, hasName, initProvider, initXClass, insertBranchNode, insertBranchNode, instantiateGraph, isAncestorOf, isDirection, isManagingInstance, isMarked, isRoot, isSource, isTarget, manageableReadResolve, manageableWriteReplace, newInstance, paramString, removeAll, removeEdgeBitsTo, removeFromChain, removeFromChain, removeReference, setBranch, setBranch, setExtentIndex, setGraphForDeserialization, setLayer, setMark, setName, setSuccessor, setSuccessor, specialEdgeAdded, specialEdgeRefModified, specialEdgeRemoved, toString, writeReplace
 
Methods inherited from class de.grogra.graph.impl.Edge
addEdgeBits, getBitMark, getEdgeBits, getObjectMark, getSpecialEdgeDescriptor, parseEdgeKeys, remove, removeEdgeBits, setBitMark, setEdgeBits, setObjectMark, testEdgeBits
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface de.grogra.persistence.PersistenceCapable
getBitMark, getObjectMark, setBitMark, setObjectMark
 

Field Detail

$TYPE

public static final Node.NType $TYPE
Constructor Detail

ToolRoot3D

public ToolRoot3D()
Method Detail

adjustScale

protected static final void adjustScale(Matrix4d t,
                                        CameraBase c,
                                        float scale)

adjustToolTransformation

protected void adjustToolTransformation(Matrix4d t,
                                        CameraBase c)
This method is invoked to compute an adjustment of the tool coordinates system. The invoker sets t to the transformation matrix from target coordinates to world coordinates. Implementations of this method may adjust t, e.g., they may set a certain scaling factor between tool coordinates and camera coordinates in order to ensure a fixed size of tool nodes on the 3D view.

Parameters:
t - the tool transformation to be adjusted
c - the camera of the tool's 3D view

attributeChanged

protected void attributeChanged(Attribute[] a)
Description copied from class: ToolRoot
This method is invoked to notify the tool root about modifications of attributes of the tool target.

Specified by:
attributeChanged in class ToolRoot
Parameters:
a - an array of attributes which have changed

computeTargetTransformation

protected abstract void computeTargetTransformation(Matrix4d t,
                                                    Matrix4d parent)
This method is invoked to compute the transformation matrix from target coordinates to world coordinates, based on the transformation matrix from parent coordinates to world coordinates.

Parameters:
t - the computed matrix has to be placed in here
parent - the global transformation of parent coordinates

dispose

public void dispose()
Specified by:
dispose in interface Disposable

eventOccured

public void eventOccured(java.util.EventObject e)
This method implements the EventListener-interface. If this method is overriden, it has to be invoked by the overriding method.

Parameters:
e - an event

getAdjustment

protected final Matrix4d getAdjustment()
This method returns the adjustment matrix from tool coordinates to target coordinates.

Returns:
the adjustment between tool and target coordinates

getParentTransformation

protected final Matrix4d getParentTransformation()
This method returns the transformation matrix from parent coordinates to world coordinates.

Returns:
the transformation matrix of the parent coordinate system
See Also:
ToolRoot3D

getTargetTransformation

protected final Matrix4d getTargetTransformation()
This method returns the transformation matrix from target coordinates to world coordinates.

Returns:
the transformation matrix of the target coordinate system
See Also:
ToolRoot3D

getToolTransformation

protected final Matrix4d getToolTransformation()
This method returns the transformation matrix from tool coordinates to world coordinates.

Returns:
the transformation matrix of the tool coordinate system
See Also:
ToolRoot3D

initialize

protected boolean initialize(Tool tool)
Description copied from class: ToolRoot
Initializes this tool root. This method initializes the field ToolRoot.tool with the given tool.

Overrides:
initialize in class ToolRoot
Parameters:
tool - the tool to which this tool root is associated
Returns:
true if this tool root actually shall be used for the tool, false if it shall not be used (e.g., if the actual tool target cannot be manipulated by the tool graph of this tool root).

postTransform

public void postTransform(java.lang.Object object,
                          boolean asNode,
                          Matrix4d in,
                          Matrix4d out,
                          Matrix4d pre,
                          GraphState gs)
Description copied from interface: Transformation
Implements the change from object's transformation in to the object's post-transformation out.

Specified by:
postTransform in interface Transformation
Parameters:
object - the object for which the transformation is computed
asNode - is object a node or an edge?
in - the transformation of the object
out - the post-tranformation of the object to be computed
pre - the post-transformation of the object's parent
gs - the graph state in which the computation has to be done

preTransform

public void preTransform(java.lang.Object object,
                         boolean asNode,
                         Matrix4d in,
                         Matrix4d out,
                         GraphState gs)
Description copied from interface: Transformation
Implements the change from the parent's post-transformation in to the object's transformation out.

Specified by:
preTransform in interface Transformation
Parameters:
object - the object for which the transformation is computed
asNode - is object a node or an edge?
in - the post-transformation of the object's parent
out - the tranformation of the object to be computed
gs - the graph state in which the computation has to be done