Class AbstractTransform
- All Implemented Interfaces:
Argument,KeyedStatefulCommand,SemiStatefulCommand,StatefulCommand<Void>,EventListener
- Direct Known Subclasses:
RotateSelection,ScaleSelection,TranslateSelection
This class implements the KeyedStatefulCommand interface and handles the
complex, shared logic required to enter a "transform mode." This includes:
- Collecting the selected objects (references) to be transformed.
- Storing their original positions for undo/cancel functionality.
- Spawning and managing the 3D interactive handles (gizmos).
- Registering and unregistering temporary keybindings (arrow keys, gear key).
- Drawing the UI overlay with command-specific information.
- Handling the final commit (Enter) or cancellation (Escape) of the transformation.
TranslateSelection extend this class to define the specific
actions that happen when the user interacts with the handles or presses the arrow keys.
Any command implementing this will inherit the need to take in a single optional
ArgSet called mode ("f", "t", "v", "p", "thing).
By default, is set to face-mode ("f" or "t"). The difference being within
face-mode, the command will filter the selection only for GTri and take the points of
each triangle as the points to transform. meaning if you had selected only a single point who
is parented to some triangle, all the points in the triangle are part of the transformation
selection as they share the same triangle up to hierarchy. To avoid this, use point-mode
("p", "v"). Otherwise, if you had selected the "thing" option
the command will filter the selection only for that Thing and take all the points of
each thing as the points to transform.
- Author:
- Lehlogonolo Poole
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ArgSetThe argument set for choosing between point/face selection mode.protected Vector3The calculated center of the current selection.private booleanprotected intThe index of the currently active step size in the gearTrain.protected StringThe name of the event associated with this stateful command.protected FaceModeA flag indicating if the transformation should operate on whole faces (tris) or individual points or whole things.protected J3KeyThe keybinding used to cycle through the gearTrain step sizes.protected double[]An array of step sizes (e.g., 1, 5, 20) that the user can cycle through.A list of temporary keybindings (e.g., arrow keys) active during this state.protected SafeJLabelThe label used for providing feedback to the user.private Stringprivate final TransformMouseOwnerThe mouse owner responsible for handling direct interaction with the 3D handles.A snapshot of the original positions of all points being transformed, for undo purposes.protected UUIDA unique ID for the UI overlay drawn by the sceneManager during the transform state.The list of actualGPointobjects that are being manipulated.private GPointFields inherited from class com.j3d.engine.interact.cmd.base.Command
aliases, args, description, usages -
Constructor Summary
ConstructorsConstructorDescriptionAbstractTransform(String commandName, String commandDesc, String eventName, TransformMouseOwner mouseOwner, double[] gearTrain) Constructs the abstract base for a transformation command. -
Method Summary
Modifier and TypeMethodDescriptionprivate Vector3voidfinished(boolean success, SafeJLabel lbl) Method which clears all state related to this which can be keys ghost previews temporary listeners ...doubleGets the currently active step size from the gear train.intGets the index of the currently active step size in the gear train.double[]Gets the array of available step sizes for the transformation (the "gear train").getKeys()Gets the list of temporaryJ3Keys that are active during this command's state.Retrieves the initial positions of all points being transformed.Retrieves the actualGPointobjects that are being manipulated.voidonEnter(Void object, SafeJLabel label) Called when the user presses Enter, committing the transformation.voidonEsc(Void object, SafeJLabel label) Called when the user presses Escape, canceling the transformation and reverting all changes.<K> voidonEvent(EventType event, EventPayload<K> properties) onEvent is called byEventEmitterviaEventEmitter.broadcast(EventType, EventPayload).voidonStart(Void object, SafeJLabel label) Called when the transformation state begins.voidrun(Invoker invoker, SafeJLabel logLabel, String aliasUsed, Object[] args, ArrayList<TaggedArgValue<?>> taggedArgs) The main entry point for the command.selfName()Returns the name of the specific command instance, used for creating unique key IDs.voidsetGearIndex(int index) Sets the current gear index, allowing the command to cycle through step sizes.private voidMethods inherited from class com.j3d.engine.interact.cmd.args.Subcommand
getDescription, getName, isOptionalMethods inherited from class com.j3d.engine.interact.cmd.base.Command
addNoArgUsage, aliases, aliasStream, args, dispatchToSubcommands, getUsages, hasNoArgs, parseUsages, usages, varTaggedArgsMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.j3d.engine.interact.cmd.base.KeyedStatefulCommand
newGearKey, setDownKey, setKey, setKeyAsSideEffects, setLeftKey, setRightKey, setUpKeyMethods inherited from interface com.j3d.engine.interact.cmd.base.SemiStatefulCommand
fireMethods inherited from interface com.j3d.engine.interact.cmd.base.StatefulCommand
run, run
-
Field Details
-
overlapId
A unique ID for the UI overlay drawn by the sceneManager during the transform state. -
mouseOwner
The mouse owner responsible for handling direct interaction with the 3D handles. -
keys
A list of temporary keybindings (e.g., arrow keys) active during this state. -
originalPointPos
A snapshot of the original positions of all points being transformed, for undo purposes. -
references
The list of actualGPointobjects that are being manipulated. -
center
The calculated center of the current selection. -
argSet
The argument set for choosing between point/face selection mode. -
eventName
The name of the event associated with this stateful command. -
faceMode
A flag indicating if the transformation should operate on whole faces (tris) or individual points or whole things. -
gearTrain
protected double[] gearTrainAn array of step sizes (e.g., 1, 5, 20) that the user can cycle through. -
currentIndex
protected int currentIndexThe index of the currently active step size in the gearTrain. -
gear
The keybinding used to cycle through the gearTrain step sizes. -
label
The label used for providing feedback to the user. -
centreIsSelectionPivot
private boolean centreIsSelectionPivot -
selectionPivot
-
label1
-
-
Constructor Details
-
AbstractTransform
public AbstractTransform(String commandName, String commandDesc, String eventName, TransformMouseOwner mouseOwner, double[] gearTrain) Constructs the abstract base for a transformation command.- Parameters:
commandName- The primary name of the command (e.g., "translate").commandDesc- A user-friendly description of the command.eventName- The name of the stateful event to run.mouseOwner- The specific mouse owner that will handle handle interaction.gearTrain- An array of step sizes for the command's "gear" system.
-
-
Method Details
-
onEvent
Description copied from interface:EventListeneronEvent is called byEventEmitterviaEventEmitter.broadcast(EventType, EventPayload). Allowing the emitter to call any other object that implements this.- Specified by:
onEventin interfaceEventListener- Type Parameters:
K- The type of the emitter of this event- Parameters:
event- The type of eventproperties- The given event payload
-
getCurrentStepSize
public double getCurrentStepSize()Gets the currently active step size from the gear train.- Returns:
- The current step size.
-
run
public void run(Invoker invoker, SafeJLabel logLabel, String aliasUsed, Object[] args, ArrayList<TaggedArgValue<?>> taggedArgs) The main entry point for the command. It gathers the selected objects and initiates the stateful transformation mode. -
onStart
Called when the transformation state begins. This method sets up the interactive environment.- Specified by:
onStartin interfaceStatefulCommand<Void>- Parameters:
object- The object that the command operates on.label- The SafeJLabel instance.
-
calculateCentre
-
finished
Description copied from interface:KeyedStatefulCommandMethod which clears all state related to this which can be- keys
- ghost previews
- temporary listeners
- ...
- Specified by:
finishedin interfaceKeyedStatefulCommand- Parameters:
success- Whether the command finished successfully or not. if the user had clicked escape or an error occurred that counts as an unsuccessful invocationlbl- The label.
-
onEnter
Called when the user presses Enter, committing the transformation.- Specified by:
onEnterin interfaceStatefulCommand<Void>- Parameters:
object- The object that the command operates on.label- The SafeJLabel instance.
-
toggleSaved
private void toggleSaved() -
onEsc
Called when the user presses Escape, canceling the transformation and reverting all changes.- Specified by:
onEscin interfaceStatefulCommand<Void>- Parameters:
object- The object that the command operates on.label- The SafeJLabel instance.
-
getKeys
Description copied from interface:KeyedStatefulCommandGets the list of temporaryJ3Keys that are active during this command's state.- Specified by:
getKeysin interfaceKeyedStatefulCommand- Returns:
- An
ArrayListof active keys.
-
selfName
Description copied from interface:KeyedStatefulCommandReturns the name of the specific command instance, used for creating unique key IDs.- Specified by:
selfNamein interfaceKeyedStatefulCommand- Returns:
- The name of the command.
-
getOriginalPointPositions
Retrieves the initial positions of all points being transformed. This is crucial for undoing the operation if the user cancels. -
getReferences
Retrieves the actualGPointobjects that are being manipulated.- Returns:
- An
ArrayListof the point references.
-
getGearTrain
public double[] getGearTrain()Description copied from interface:KeyedStatefulCommandGets the array of available step sizes for the transformation (the "gear train").- Specified by:
getGearTrainin interfaceKeyedStatefulCommand- Returns:
- An array of doubles representing different step magnitudes.
-
getGearIndex
public int getGearIndex()Description copied from interface:KeyedStatefulCommandGets the index of the currently active step size in the gear train.- Specified by:
getGearIndexin interfaceKeyedStatefulCommand- Returns:
- The current gear index.
-
setGearIndex
public void setGearIndex(int index) Description copied from interface:KeyedStatefulCommandSets the current gear index, allowing the command to cycle through step sizes.- Specified by:
setGearIndexin interfaceKeyedStatefulCommand- Parameters:
index- The new gear index.
-