Files
UnrealEngineUWP/Engine/Source/Runtime/InteractiveToolsFramework/Public/InteractiveCommand.h
ryan schmidt 46630c002f ModelingMode: Selection system improvements. Add Disconnect command and various new Selection-Edit Commands
Add UInteractiveCommandResult, UInteractiveCommand::ExecuteCommand() now optionally can return a result subclass
Add UGeometrySelectionEditCommandResult, UGeometrySelectionEditCommand now can optionally return an "output" selection via this type
UGeometrySelectionManager::ExecuteSelectionCommand optionally can restore a selection after a command, via UGeometrySelectionEditCommandResult

Add UDisconnectGeometrySelectionCommand, implements disconnection of selected triangles (ie separates but not into a new mesh)
Add UModifyGeometrySelectionCommand, implements various selection edits (select all, expand to connected, invert, invert connected, expand, contract)
Add IGeometrySelector::InitializeSelectionFromPredicate() and ::UpdateSelectionFromSelection(), implement in UDynamicMeshSelector, used to implement selection edit commands
Add UI to enable new commands in Modeling Mode

#rb none
#preflight 63c047f4305002c64170f6a2

[CL 23667880 by ryan schmidt in ue5-main branch]
2023-01-12 14:52:52 -05:00

81 lines
2.4 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "ToolContextInterfaces.h"
#include "InteractiveCommand.generated.h"
class IToolsContextTransactionsAPI;
/**
* UInteractiveCommandArguments are arguments passed to a UInteractiveCommand.
* Subclasses of UInteractiveCommand will generally be paired with subclasses of UInteractiveCommandArguments.
*
* The base UInteractiveCommandArguments provides support for transactions via
* a IToolsContextTransactionsAPI
*/
UCLASS()
class INTERACTIVETOOLSFRAMEWORK_API UInteractiveCommandArguments : public UObject
{
GENERATED_BODY()
public:
virtual void SetTransactionsAPI(IToolsContextTransactionsAPI* TransactionsAPIIn) { TransactionsAPI = TransactionsAPIIn; }
virtual bool HasTransactionsAPI() const { return TransactionsAPI != nullptr; }
virtual IToolsContextTransactionsAPI* GetTransactionsAPI() const { return TransactionsAPI; }
protected:
IToolsContextTransactionsAPI* TransactionsAPI = nullptr;
};
/**
* UInteractiveCommandResult subclasses are returned from UInteractiveCommands, to allow
* commands to return custom information.
*/
UCLASS()
class INTERACTIVETOOLSFRAMEWORK_API UInteractiveCommandResult : public UObject
{
GENERATED_BODY()
};
/**
* A UInteractiveCommand is an atomic action that can be executed via some user interaction.
* For example clicking a button that deletes an active selection can be considered an Interactive Command.
* This differs from an Interactive Tool in that there is no ongoing user interaction once the
* command has been initiated.
*/
UCLASS(Abstract)
class INTERACTIVETOOLSFRAMEWORK_API UInteractiveCommand : public UObject
{
GENERATED_BODY()
public:
/**
* @return a short text string that can be used for the command in (eg) Editor transaction/undo toasts
*/
virtual FText GetCommandShortString() const
{
return FText();
}
/**
* @return true if it is safe to call ExecuteCommand() with the given Arguments
*/
virtual bool CanExecuteCommand(UInteractiveCommandArguments* Arguments)
{
return false;
}
/**
* Execute the command with the given Arguments
* @param Result optional command result. Command would have to allocate the UInteractiveCommandResult object to return it, but is not required to. Caller should not assume that a non-null Result is necessarily returned.
*/
virtual void ExecuteCommand(UInteractiveCommandArguments* Arguments, UInteractiveCommandResult** Result = nullptr)
{
}
};