Cogs.Core
Public Member Functions | Public Attributes | Protected Attributes | Private Attributes | List of all members
Cogs::Core::EditorCommand Struct Referenceabstract

Base class for Cogs Editor commands. More...

#include <EditorCommand.h>

Inheritance diagram for Cogs::Core::EditorCommand:
Cogs::Core::AddComponentCommand Cogs::Core::ChangeEditingModeCommand Cogs::Core::CreateEntityCommand Cogs::Core::DestroyCommand Cogs::Core::DumpStatsCommand Cogs::Core::ExportCommand Cogs::Core::ExportGltfCommand Cogs::Core::GenNormalsCommand Cogs::Core::GenerateTangentsCommand Cogs::Core::GroupCommand Cogs::Core::MergeCommand Cogs::Core::MergeMaterialCommand Cogs::Core::MergeMeshCommand Cogs::Core::ModalEditorCommand Cogs::Core::PackMeshCommand Cogs::Core::PasteEntityCommand Cogs::Core::PostCommand Cogs::Core::RemapMaterialCommand Cogs::Core::RotateCommand Cogs::Core::ScaleCommand Cogs::Core::ScaleMeshCommand Cogs::Core::ScaleToUnitCubeCommand Cogs::Core::SelectCommand Cogs::Core::SetFieldCommand< T > Cogs::Core::SetMaterialPropertyCommand< T > Cogs::Core::SetTexturePropertyCommand Cogs::Core::TranslateCommand

Public Member Functions

 EditorCommand (EditorState *state, Context *context)
 
virtual void apply ()=0
 Run the command.
 
virtual void undo ()=0
 
virtual void redo ()
 
virtual bool mergeWith (const EditorCommand *)
 
virtual MeshHandle applyMesh (MeshHandle)
 Workaround for having extendable mesh processing available without linking (e.g command -> RR).
 
virtual void close ()
 Close command, i.e. prevent merging with another command.
 
bool isClosed () const
 
bool merge (const EditorCommand *command)
 Merge into this if not this is closed.
 

Public Attributes

std::vector< ParsedValueoptions
 Options passed to the command when running in batch mode.
 
bool permanentUndo = false
 True if cannot Redo after Undo.
 

Protected Attributes

EditorStatestate = nullptr
 
Contextcontext = nullptr
 

Private Attributes

bool closed = false
 

Detailed Description

Base class for Cogs Editor commands.

A framework for commands with undo/redo capabilities.

Definition at line 18 of file EditorCommand.h.

Constructor & Destructor Documentation

◆ EditorCommand()

Cogs::Core::EditorCommand::EditorCommand ( EditorState state,
Context context 
)

Definition at line 3 of file EditorCommand.cpp.

Member Function Documentation

◆ apply()

virtual void Cogs::Core::EditorCommand::apply ( )
pure virtual

◆ applyMesh()

virtual MeshHandle Cogs::Core::EditorCommand::applyMesh ( MeshHandle  )
inlinevirtual

Workaround for having extendable mesh processing available without linking (e.g command -> RR).

Reimplemented in Cogs::Core::RRSimplifiyCommand.

Definition at line 42 of file EditorCommand.h.

◆ close()

virtual void Cogs::Core::EditorCommand::close ( )
inlinevirtual

Close command, i.e. prevent merging with another command.

See also
mergeWith

Reimplemented in Cogs::Core::SetFieldCommand< T >.

Definition at line 45 of file EditorCommand.h.

◆ isClosed()

bool Cogs::Core::EditorCommand::isClosed ( ) const
inline

Definition at line 50 of file EditorCommand.h.

◆ merge()

bool Cogs::Core::EditorCommand::merge ( const EditorCommand command)
inline

Merge into this if not this is closed.

Definition at line 53 of file EditorCommand.h.

◆ mergeWith()

virtual bool Cogs::Core::EditorCommand::mergeWith ( const EditorCommand )
inlinevirtual

Check if the action in the given command should be merged into this. I.e. Multiple field-changes commands merged info one for undoing all-in-one. Client code shall use

See also
merge(EditorCommand * command)

Reimplemented in Cogs::Core::TranslateCommand, Cogs::Core::RotateCommand, Cogs::Core::ScaleCommand, Cogs::Core::SetFieldCommand< T >, and Cogs::Core::SetMaterialPropertyCommand< T >.

Definition at line 39 of file EditorCommand.h.

◆ redo()

virtual void Cogs::Core::EditorCommand::redo ( )
inlinevirtual

Definition at line 31 of file EditorCommand.h.

Member Data Documentation

◆ closed

bool Cogs::Core::EditorCommand::closed = false
private

Definition at line 71 of file EditorCommand.h.

◆ context

Context* Cogs::Core::EditorCommand::context = nullptr
protected

Definition at line 68 of file EditorCommand.h.

◆ options

std::vector<ParsedValue> Cogs::Core::EditorCommand::options

Options passed to the command when running in batch mode.

Definition at line 61 of file EditorCommand.h.

Referenced by Cogs::Core::DumpStatsCommand::apply(), Cogs::Core::ExportCommand::apply(), Cogs::Core::MergeCommand::apply(), and Cogs::Core::RRSimplifiyCommand::apply().

◆ permanentUndo

bool Cogs::Core::EditorCommand::permanentUndo = false

True if cannot Redo after Undo.

Definition at line 64 of file EditorCommand.h.

◆ state

EditorState* Cogs::Core::EditorCommand::state = nullptr
protected

Definition at line 67 of file EditorCommand.h.


The documentation for this struct was generated from the following files: