NDEVR
API Documentation
SetLayerCommand

A command that assigns one or more models to a specified layer, with full undo support. More...

Inheritance diagram for SetLayerCommand:
[legend]
Collaboration diagram for SetLayerCommand:
[legend]

Public Member Functions

 SetLayerCommand (UUID layer)
 Constructs a SetLayerCommand targeting the given layer.
virtual bool addTarget (UUID target_id) override
 Adds a model to the set of targets for this layer command.
virtual void execute (DesignObjectLookup *lookup) override
 Executes the layer assignment (or reverses it during undo).
virtual StringView icon () const override
 Returns the icon identifier for this command.
virtual TranslatedString name () const override
 Returns the translated display name of this command.
Public Member Functions inherited from DesignCommand
 DesignCommand ()
 Default constructor.
 DesignCommand (const DesignCommand &command)=default
 Default copy constructor.
virtual ~DesignCommand ()
 Virtual destructor.
virtual bool canCombineWith (const DynamicPointer< DesignCommand > &)
 Checks whether this command can be combined with another command into a single operation.
virtual bool canGroupWith (const DynamicPointer< DesignCommand > &)
 Checks whether this command can be grouped with another command for batch execution.
virtual void combineWith (const DynamicPointer< DesignCommand > &command)
 Combines this command with another compatible command, merging their operations.
virtual bool isAsyncExecution () const
 Whether this command should be executed asynchronously.
void setUndoRedoID (UUID undo_redo_group)
 Sets the undo-redo group identifier for this command.
UUID undoRedoID () const
 Gets the undo-redo group identifier for this command.

Public Attributes

UUID m_layer
 The UUID of the destination layer. Invalid UUID means clear layer.
Buffer< UUIDm_models_to_set
 UUIDs of models to be assigned to the layer.
Buffer< UUIDm_original_layers
 Original layer UUIDs for each model, stored for undo support.
Public Attributes inherited from DesignCommand
bool can_undo = true
 Whether this command supports being undone.
bool has_executed = false
 Whether this command has already been executed.
UUID id
 Unique identifier for this command instance.
bool is_undo = false
 Whether this command represents an undo operation.
LogPtr log
 Log pipe for reporting command progress and errors.
Time time = Constant<Time>::Invalid
 Timestamp of when the command was created or executed.
bool update_project_modified = true
 Whether executing this command should mark the project as modified.

Additional Inherited Members

Protected Attributes inherited from DesignCommand
UUID m_undo_redo_group
 The undo-redo group this command belongs to, for batch undo/redo.

Detailed Description

A command that assigns one or more models to a specified layer, with full undo support.

When executed, each target model is moved to the layer identified by m_layer. The original layer assignment of each model is stored so that the operation can be reversed when is_undo is set. If the target layer UUID is invalid, the models are cleared of any layer assignment instead.

See also
DesignCommand, Model

Definition at line 20 of file LayerCommand.h.

Constructor & Destructor Documentation

◆ SetLayerCommand()

SetLayerCommand::SetLayerCommand ( UUID layer)
inline

Constructs a SetLayerCommand targeting the given layer.

Parameters
[in]layerThe UUID of the layer to assign models to. Pass an invalid UUID to clear layer assignments.

Definition at line 28 of file LayerCommand.h.

References DesignCommand::DesignCommand(), and m_layer.

Member Function Documentation

◆ addTarget()

virtual bool SetLayerCommand::addTarget ( UUID target_id)
inlineoverridevirtual

Adds a model to the set of targets for this layer command.

Parameters
[in]target_idThe UUID of the model to reassign.
Returns
True, indicating the target was accepted.

Reimplemented from DesignCommand.

Definition at line 105 of file LayerCommand.h.

References m_models_to_set.

◆ execute()

virtual void SetLayerCommand::execute ( DesignObjectLookup * lookup)
inlineoverridevirtual

Executes the layer assignment (or reverses it during undo).

Acquires a write lock on the lookup, deduplicates the target model list, and iterates over each model. During a forward execution the model's current layer is recorded before reassignment; during undo the previously recorded layer is restored. If the destination layer does not yet exist in the model's scene it is created automatically.

Parameters
[in]lookupThe design object lookup used to resolve models, layers, and scenes.

Reimplemented from DesignCommand.

Definition at line 62 of file LayerCommand.h.

References Model::clearLayer(), Model::directLayer(), DesignObjectLookup::ensureLayerExistsInScene(), DesignObject::get(), DesignObject::getScene(), guid, DesignObjectLookup::hasLayerID(), DesignCommand::is_undo, IsInvalid(), IsValid(), DesignObject::isValid(), DesignObjectLookup::layer(), m_layer, m_models_to_set, m_original_layers, DesignObjectLookup::model(), Model::setLayer(), Model::updateModifiedTime(), and DesignObjectLookup::writeLock().

◆ icon()

virtual StringView SetLayerCommand::icon ( ) const
inlineoverridevirtual

Returns the icon identifier for this command.

Returns
A StringView containing the icon name "new".
Note
The icon name "new" seems generic and may not accurately represent a layer assignment operation. This may be a placeholder or shared icon.

Implements DesignCommand.

Definition at line 40 of file LayerCommand.h.

◆ name()

virtual TranslatedString SetLayerCommand::name ( ) const
inlineoverridevirtual

Returns the translated display name of this command.

Returns
A TranslatedString containing "Set Layer".

Implements DesignCommand.

Definition at line 48 of file LayerCommand.h.


The documentation for this class was generated from the following file: