Vixen
5cf01f31
csharp
public abstract class NodeGraphCommand

The half of an undoable graph edit that every one of them shares.

No guide page documents this yet — the page shows what the code says about itself.

Remarks

A command holds the model, not the document. A graph is edited the same way whether it is an open asset, a sub-graph being previewed, or a fixture in a test with no project behind it — so the document is optional and its only job is to be marked dirty. That is also what makes every command here testable without a command stack.

⚠ Undo depends on identities never being reused. Restore puts a node back under the identity it had, which is what lets the edges a deletion took with it be restored by name rather than rewritten. Every command below relies on it, and a model that renumbered on undo would break all of them at once.

Fields and properties (3)

  • protected NodeGraphModel Graph

    The graph being edited.

  • protected IAuthoredDocument? Document

    The document it belongs to, if it belongs to one.

  • public abstract string Name

    What this is called in the undo history, as a person would say it.

Methods (6)

  • protected NodeGraphCommand(NodeGraphModel graph, IAuthoredDocument? document)

    Starts a command against a graph.

  • public void Do(ICommandContext context)

    Applies the change. Called on execute and again on every redo.

  • public void Undo(ICommandContext context)

    Puts back exactly what Do changed.

  • public virtual bool TryMergeWith(IAuthoringCommand previous, out IAuthoringCommand? merged)
  • protected abstract void Apply()

    Makes the change. Called once on execute and again on every redo.

  • protected abstract void Revert()

    Puts back exactly what Apply changed.

Used by (15)

  • AddCommentCommandVixen.NodeGraph
  • AddGroupCommandVixen.NodeGraph
  • AddNodeCommandVixen.NodeGraph
  • ConnectCommandVixen.NodeGraph
  • DisconnectCommandVixen.NodeGraph
  • ExtractSubGraphCommandVixen.NodeGraph
  • MoveNodesCommandVixen.NodeGraph
  • PasteCommandVixen.NodeGraph
  • RemoveCommentCommandVixen.NodeGraph
  • RemoveGroupCommandVixen.NodeGraph
  • RemoveNodesCommandVixen.NodeGraph
  • RenameGroupCommandVixen.NodeGraph
  • SetCommentCommandVixen.NodeGraph
  • SetPortTextCommandVixen.NodeGraph
  • SetPortValueCommandVixen.NodeGraph