diff --git a/Assets/SEE/Controls/Actions/MarkAction.cs b/Assets/SEE/Controls/Actions/MarkAction.cs index fabb43d535..27c735c91f 100644 --- a/Assets/SEE/Controls/Actions/MarkAction.cs +++ b/Assets/SEE/Controls/Actions/MarkAction.cs @@ -13,8 +13,8 @@ namespace SEE.Controls.Actions internal class MarkAction : AbstractPlayerAction { /// - /// If the user clicks with the mouse hitting a game object representing a graph node, - /// this graph node is a parent to which a new node is created and added as a child. + /// If the user clicks with the mouse hitting a game object representing a node mark, + /// this node mark is a mark to which a node is created. /// . /// /// true if completed @@ -44,14 +44,14 @@ public override bool Update() } else { - Debug.LogError($"New node could not be created.\n"); + Debug.LogError($"New mark could not be created.\n"); } } return result; } /// - /// The node that was added when this action was executed. It is saved so + /// The mark that was added when this action was executed. It is saved so /// that it can be removed on Undo(). /// private GameObject addedGameMark; @@ -105,13 +105,11 @@ public Memento(GameObject mark,int diameter ,int x,int y,string nodeid) } /// - /// Returns a scale of a square with the given center - /// that fits into the ground area of . + /// Returns a diameter of a sphere /// - /// parent in which to fit the rectangle - /// center position of the rectangle - /// the scale of a square (actually a cube, but with a very small height) - /// with center that fits into the ground area of + /// width of the marked node + /// depth of the markde node + /// the diameter of the sphere private static int FindDiameter(int x, int y) { int diameter = 0; @@ -128,7 +126,34 @@ private static int FindDiameter(int x, int y) } /// - /// Undoes this AddNodeAction. + /// Returns a scale of a square with the given center + /// that fits into the ground area of . + /// + /// parent in which to fit the rectangle + /// center position of the rectangle + /// the scale of a square (actually a cube, but with a very small height) + /// with center that fits into the ground area of + private static Vector3 FindSize(GameObject parent, Vector3 position) + { + // TODO: We might want to implement something smarter + // than that, see for instance: + // https://stackoverflow.com/questions/51574829/how-to-algorithmically-find-the-biggest-rectangle-that-can-fit-in-a-space-with-o + Vector3 result = parent.transform.lossyScale / 10; + // The ground area of the result must be a square. + if (result.x > result.z) + { + result.x = result.z; + } + else + { + result.z = result.x; + } + result.y = 0.01f; + return result; + } + + /// + /// Undoes this MarkAction. /// public override void Undo() { @@ -143,7 +168,7 @@ public override void Undo() } /// - /// Redoes this AddNodeAction. + /// Redoes this MarkAction. /// public override void Redo() { @@ -156,7 +181,7 @@ public override void Redo() } /// - /// Returns a new instance of . + /// Returns a new instance of . /// /// new instance public static ReversibleAction CreateReversibleAction() @@ -165,7 +190,7 @@ public static ReversibleAction CreateReversibleAction() } /// - /// Returns a new instance of . + /// Returns a new instance of . /// /// new instance public override ReversibleAction NewInstance() @@ -176,7 +201,7 @@ public override ReversibleAction NewInstance() /// /// Returns the of this action. /// - /// + /// public override ActionStateType GetActionStateType() { return ActionStateType.NewMark; @@ -190,7 +215,7 @@ public override HashSet GetChangedObjects() { return new HashSet { - memento.Parent.name, + memento.Mark.name, memento.NodeID }; }