From ad2048e383aa9283696656a66cb3b0c7fe0da8e7 Mon Sep 17 00:00:00 2001 From: m4xxed Date: Thu, 25 May 2023 23:25:33 +0200 Subject: [PATCH 01/69] add Action and NetAction to accept Divergences into Architecture --- .../Actions/AcceptDivergenceAction.cs | 152 ++++++++++++++++++ .../Net/Actions/AcceptDivergenceNetAction.cs | 63 ++++++++ 2 files changed, 215 insertions(+) create mode 100644 Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs create mode 100644 Assets/SEE/Net/Actions/AcceptDivergenceNetAction.cs diff --git a/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs b/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs new file mode 100644 index 0000000000..fa8a1edf9e --- /dev/null +++ b/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs @@ -0,0 +1,152 @@ +using System.Collections.Generic; +using SEE.DataModel.DG; +using SEE.Tools.ReflexionAnalysis; +using System.Linq; +using SEE.GO; +using SEE.Net.Actions; +using SEE.Utils; +using UnityEngine; + +namespace SEE.Controls.Actions +{ + /// + /// Action to create a new node for a selected city. + /// + internal class AcceptDivergenceAction : AbstractPlayerAction + { + /// + /// + private GameObject hitGraphElement; + + /// + /// + private ISet syncedGameObjects; + + /// + /// + /// true if completed + public override bool Update() + { + // FIXME: Needs adaptation for VR where no mouse is available. + if (Input.GetMouseButtonDown(0) + && Raycasting.RaycastGraphElement(out RaycastHit raycastHit, out GraphElementRef _) != HitGraphElement.None) + { + + // Syncing: + // Get Selected Edge + hitGraphElement = raycastHit.collider.gameObject; + + Debug.Log("1"); + // Check if Edge + if (hitGraphElement.TryGetEdge(out Edge selectedEdge)) + { + + // FIXME: This is a stupid workaround until the Diversion Edge can be selected + var graph = (ReflexionGraph)selectedEdge.ItsGraph; + foreach (Edge edge in graph.Edges()) + { + if (ReflexionGraph.IsDivergent(edge)) + { + graph.Transition(edge, State.Convergent); + + // Insert Edge into Architecture + graph.Transition(edge, State.Allowed); + + // Find Node in ArchitectureGraph the + // divergence's Source is explicitly or + // implicitly mapped to. + Node source = graph.MapsTo(edge.Source); + + // Find Node in ArchitectureGraph the + // divergence's Target is explicitly or + // implicitly mapped to. + Node target = graph.MapsTo(edge.Target); + + // Ensure the required Edge has not + // already been added (shouldn't be + // necessary outside of this workaround + // due to Incremental nature of + // ReflexionGraph) + if (graph.Edges().Any(x => x.Source == edge.Source && x.Target == edge.Target)) + { + // add new edge to node + graph.AddToArchitecture(source, target, edge.Type); + } + } + } + + // // Check if Edge is within architecture + // if (ReflexionGraph.IsDivergent(edge)) + // { + // // Syncing over Network + // new AcceptDivergenceNetAction(hitGraphElement.name).Execute(); + // return true; // the selected object is synced and this action is done + // } + } + else + { + Debug.LogWarning($"Selected Element {hitGraphElement.name} is not a reflexion edge.\n"); + } + } + return false; + } + + /// + /// Undoes this AddNodeAction. + /// + public override void Undo() + { + } + + /// + /// Redoes this AddNodeAction. + /// + public override void Redo() + { + } + + /// + /// Returns a new instance of . + /// + /// new instance + public static ReversibleAction CreateReversibleAction() + { + return new AcceptDivergenceAction(); + } + + /// + /// Returns a new instance of . + /// + /// new instance + public override ReversibleAction NewInstance() + { + return CreateReversibleAction(); + } + + /// + /// Returns the of this action. + /// + /// + public override ActionStateType GetActionStateType() + { + return ActionStateType.Sync; + } + + /// + /// Returns all IDs of gameObjects manipulated by this action. + /// + /// all IDs of gameObjects manipulated by this action + public override HashSet GetChangedObjects() + { + if (syncedGameObjects == null) + { + return new HashSet(); + } + else + { + return new HashSet(syncedGameObjects.Select(x => x.name)); + } + + } + } +} diff --git a/Assets/SEE/Net/Actions/AcceptDivergenceNetAction.cs b/Assets/SEE/Net/Actions/AcceptDivergenceNetAction.cs new file mode 100644 index 0000000000..cb4a4f2774 --- /dev/null +++ b/Assets/SEE/Net/Actions/AcceptDivergenceNetAction.cs @@ -0,0 +1,63 @@ +using SEE.Game; +using UnityEngine; + +namespace SEE.Net.Actions +{ + /// + /// This class is responsible for adding a node via network from one client to all others and + /// to the server. + /// + public class AcceptDivergenceNetAction : AbstractNetAction + { + // Note: All attributes are made public so that they will be serialized + // for the network transfer. + + /// + /// The ID of the parent gameObject of the new GameObject. + /// + public string ParentID; + + /// + /// The id of the new node. + /// + public string NewNodeID; + + /// + /// The position of the new node. + /// + public Vector3 Position; + + /// + /// The scale of the new node. + /// + public Vector3 Scale; + + /// + /// Constructor. + /// + /// unique ID of the parent in which to add the new node + /// id for the new node + /// the position for the new node + /// the scale of the new node in world space + public AcceptDivergenceNetAction(string gameObjectID) + : base() + { + } + + /// + /// Things to execute on the server (none for this class). Necessary because it is abstract + /// in the superclass. + /// + protected override void ExecuteOnServer() + { + // Intentionally left blank. + } + + /// + /// Creates a new GameObject on each client. + /// + protected override void ExecuteOnClient() + { + } + } +} From 19bad1116443e775212e1a13d8c3f1eaece37445 Mon Sep 17 00:00:00 2001 From: m4xxed Date: Thu, 25 May 2023 23:26:15 +0200 Subject: [PATCH 02/69] add ActionStateType for AcceptDivergenceAction --- Assets/SEE/Controls/Actions/ActionStateType.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Assets/SEE/Controls/Actions/ActionStateType.cs b/Assets/SEE/Controls/Actions/ActionStateType.cs index c297540a66..585c0c85c9 100644 --- a/Assets/SEE/Controls/Actions/ActionStateType.cs +++ b/Assets/SEE/Controls/Actions/ActionStateType.cs @@ -62,6 +62,10 @@ public class ActionStateType new(9, "Draw", "Draw a line", Color.magenta.Darker(), "Materials/ModernUIPack/Pencil", DrawAction.CreateReversibleAction); + public static ActionStateType Sync { get; } = + new(10, "AcceptDivergence", "Sync from Implementation into Architecture", + Color.grey.Darker(), "Materials/ModernUIPack/Arrow Bold", + AcceptDivergenceAction.CreateReversibleAction); #endregion /// From a2eb3e9256a2adbe9fdae6c9787284415dff039b Mon Sep 17 00:00:00 2001 From: m4xxed Date: Fri, 26 May 2023 00:24:15 +0200 Subject: [PATCH 03/69] add correct implementation next to current workaround --- .../Actions/AcceptDivergenceAction.cs | 70 ++++++++++++------- 1 file changed, 44 insertions(+), 26 deletions(-) diff --git a/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs b/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs index fa8a1edf9e..f8144a415e 100644 --- a/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs +++ b/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs @@ -10,19 +10,26 @@ namespace SEE.Controls.Actions { /// - /// Action to create a new node for a selected city. + /// Action to solve a Divergence between Implementation and + /// Architecture by adding the Edge to the Architecture that + /// solves the Divergence. /// internal class AcceptDivergenceAction : AbstractPlayerAction { /// + /// The edge that was hit by the user to be accepted + /// into the ArchitectureGraph. Set in . /// - private GameObject hitGraphElement; + private GameObject selectedDivergenceEdge; /// - /// + /// Contains all Edges that were explicitly added to + /// solve Divergences. + /// private ISet syncedGameObjects; /// + /// See . /// /// true if completed public override bool Update() @@ -31,27 +38,18 @@ public override bool Update() if (Input.GetMouseButtonDown(0) && Raycasting.RaycastGraphElement(out RaycastHit raycastHit, out GraphElementRef _) != HitGraphElement.None) { + // Find the edge representing the specific Divergence that should be solved. + selectedDivergenceEdge = raycastHit.collider.gameObject; - // Syncing: - // Get Selected Edge - hitGraphElement = raycastHit.collider.gameObject; - - Debug.Log("1"); - // Check if Edge - if (hitGraphElement.TryGetEdge(out Edge selectedEdge)) + // Check whether the object selected is actually an edge. + if (selectedDivergenceEdge.TryGetEdge(out Edge selectedEdge)) { - // FIXME: This is a stupid workaround until the Diversion Edge can be selected var graph = (ReflexionGraph)selectedEdge.ItsGraph; foreach (Edge edge in graph.Edges()) { if (ReflexionGraph.IsDivergent(edge)) { - graph.Transition(edge, State.Convergent); - - // Insert Edge into Architecture - graph.Transition(edge, State.Allowed); - // Find Node in ArchitectureGraph the // divergence's Source is explicitly or // implicitly mapped to. @@ -70,43 +68,63 @@ public override bool Update() if (graph.Edges().Any(x => x.Source == edge.Source && x.Target == edge.Target)) { // add new edge to node - graph.AddToArchitecture(source, target, edge.Type); + Edge newArchitectureEdge = graph.AddToArchitecture(source, target, edge.Type); } } } - // // Check if Edge is within architecture - // if (ReflexionGraph.IsDivergent(edge)) + // FIXME: this is the actual solution which should + // work using edge selection: + + // Check if Edge represents a Divergence + // if (ReflexionGraph.IsDivergent(selectedEdge)) // { - // // Syncing over Network - // new AcceptDivergenceNetAction(hitGraphElement.name).Execute(); + // // get the containing ReflexionGraph + // var graph = (ReflexionGraph)selectedEdge.ItsGraph; + + // // Find Node in ArchitectureGraph the + // // divergence's Source is explicitly or + // // implicitly mapped to. + // Node source = graph.MapsTo(selectedEdge.Source); + + // // Find Node in ArchitectureGraph the + // // divergence's Target is explicitly or + // // implicitly mapped to. + // Node target = graph.MapsTo(selectedEdge.Target); + + // // Create a new Edge that will solve the Divergence + // Edge newArchitectureEdge = graph.AddToArchitecture(source, target, selectedEdge.Type); + + // // Sync the Solution of the Divergence via Network + // new AcceptDivergenceNetAction(selectedDivergenceEdge.name).Execute(); // return true; // the selected object is synced and this action is done // } } else { - Debug.LogWarning($"Selected Element {hitGraphElement.name} is not a reflexion edge.\n"); + Debug.LogWarning($"Selected Element {selectedDivergenceEdge.name} is not an edge.\n"); } } return false; } + /// - /// Undoes this AddNodeAction. + /// Undoes this AcceptDivergenceAction. /// public override void Undo() { } /// - /// Redoes this AddNodeAction. + /// Redoes this AcceptDivergenceAction. /// public override void Redo() { } /// - /// Returns a new instance of . + /// Returns a new instance of . /// /// new instance public static ReversibleAction CreateReversibleAction() @@ -115,7 +133,7 @@ public static ReversibleAction CreateReversibleAction() } /// - /// Returns a new instance of . + /// Returns a new instance of . /// /// new instance public override ReversibleAction NewInstance() From 2ffd5a9ef3a5b6c27f69b10d4f80f302aa1e65c7 Mon Sep 17 00:00:00 2001 From: m4xxed Date: Fri, 26 May 2023 00:24:56 +0200 Subject: [PATCH 04/69] add convenience method to check for divergence --- .../Tools/ReflexionAnalysis/ReflexionAnalysis.cs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Assets/SEE/Tools/ReflexionAnalysis/ReflexionAnalysis.cs b/Assets/SEE/Tools/ReflexionAnalysis/ReflexionAnalysis.cs index 14a1de1ccb..f2c3c1a294 100644 --- a/Assets/SEE/Tools/ReflexionAnalysis/ReflexionAnalysis.cs +++ b/Assets/SEE/Tools/ReflexionAnalysis/ReflexionAnalysis.cs @@ -208,6 +208,19 @@ public static bool IsSpecified(Edge edge) return state == State.Specified || state == State.Convergent || state == State.Absent || state == State.AllowedAbsent; } + /// + /// Returns true if is a specified edge in the architecture (has one of the + /// following states: specified, convergent, absent, allowed absent). + /// Precondition: must be in the architecture graph. + /// + /// architecture dependency + /// true if edge is a specified architecture dependency + public static bool IsDivergent(Edge edge) + { + // AssertOrThrow(edge.IsInArchitecture(), () => new NotInSubgraphException(Architecture, edge)); + State state = edge.State(); + return state == State.Divergent; + } #endregion #region Edge counter attribute @@ -1425,4 +1438,4 @@ public static void DumpTable(Dictionary table) #endregion } -} \ No newline at end of file +} From f556b92e4c201818dbdcf1ed3bb7bb584f6df84a Mon Sep 17 00:00:00 2001 From: m4xxed Date: Fri, 26 May 2023 00:32:42 +0200 Subject: [PATCH 05/69] switch from "dirty hack" to actual solution - works --- .../Actions/AcceptDivergenceAction.cs | 92 +++++++++---------- 1 file changed, 46 insertions(+), 46 deletions(-) diff --git a/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs b/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs index f8144a415e..e929c93a7e 100644 --- a/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs +++ b/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs @@ -44,61 +44,61 @@ public override bool Update() // Check whether the object selected is actually an edge. if (selectedDivergenceEdge.TryGetEdge(out Edge selectedEdge)) { - // FIXME: This is a stupid workaround until the Diversion Edge can be selected - var graph = (ReflexionGraph)selectedEdge.ItsGraph; - foreach (Edge edge in graph.Edges()) - { - if (ReflexionGraph.IsDivergent(edge)) - { - // Find Node in ArchitectureGraph the - // divergence's Source is explicitly or - // implicitly mapped to. - Node source = graph.MapsTo(edge.Source); - - // Find Node in ArchitectureGraph the - // divergence's Target is explicitly or - // implicitly mapped to. - Node target = graph.MapsTo(edge.Target); - - // Ensure the required Edge has not - // already been added (shouldn't be - // necessary outside of this workaround - // due to Incremental nature of - // ReflexionGraph) - if (graph.Edges().Any(x => x.Source == edge.Source && x.Target == edge.Target)) - { - // add new edge to node - Edge newArchitectureEdge = graph.AddToArchitecture(source, target, edge.Type); - } - } - } + // // FIXME: This is a stupid workaround until the Diversion Edge can be selected + // var graph = (ReflexionGraph)selectedEdge.ItsGraph; + // foreach (Edge edge in graph.Edges()) + // { + // if (ReflexionGraph.IsDivergent(edge)) + // { + // // Find Node in ArchitectureGraph the + // // divergence's Source is explicitly or + // // implicitly mapped to. + // Node source = graph.MapsTo(edge.Source); + + // // Find Node in ArchitectureGraph the + // // divergence's Target is explicitly or + // // implicitly mapped to. + // Node target = graph.MapsTo(edge.Target); + + // // Ensure the required Edge has not + // // already been added (shouldn't be + // // necessary outside of this workaround + // // due to Incremental nature of + // // ReflexionGraph) + // if (graph.Edges().Any(x => x.Source == edge.Source && x.Target == edge.Target)) + // { + // // add new edge to node + // Edge newArchitectureEdge = graph.AddToArchitecture(source, target, edge.Type); + // } + // } + // } // FIXME: this is the actual solution which should // work using edge selection: // Check if Edge represents a Divergence - // if (ReflexionGraph.IsDivergent(selectedEdge)) - // { - // // get the containing ReflexionGraph - // var graph = (ReflexionGraph)selectedEdge.ItsGraph; + if (ReflexionGraph.IsDivergent(selectedEdge)) + { + // get the containing ReflexionGraph + var graph = (ReflexionGraph)selectedEdge.ItsGraph; - // // Find Node in ArchitectureGraph the - // // divergence's Source is explicitly or - // // implicitly mapped to. - // Node source = graph.MapsTo(selectedEdge.Source); + // Find Node in ArchitectureGraph the + // divergence's Source is explicitly or + // implicitly mapped to. + Node source = graph.MapsTo(selectedEdge.Source); - // // Find Node in ArchitectureGraph the - // // divergence's Target is explicitly or - // // implicitly mapped to. - // Node target = graph.MapsTo(selectedEdge.Target); + // Find Node in ArchitectureGraph the + // divergence's Target is explicitly or + // implicitly mapped to. + Node target = graph.MapsTo(selectedEdge.Target); - // // Create a new Edge that will solve the Divergence - // Edge newArchitectureEdge = graph.AddToArchitecture(source, target, selectedEdge.Type); + // Create a new Edge that will solve the Divergence + Edge newArchitectureEdge = graph.AddToArchitecture(source, target, selectedEdge.Type); - // // Sync the Solution of the Divergence via Network - // new AcceptDivergenceNetAction(selectedDivergenceEdge.name).Execute(); - // return true; // the selected object is synced and this action is done - // } + // Sync the Solution of the Divergence via Network + new AcceptDivergenceNetAction(selectedDivergenceEdge.name).Execute(); + return true; // the selected object is synced and this action is done + } } else { From 55566a6c9da1f56b0d3b00e04c804a3ec23a90cf Mon Sep 17 00:00:00 2001 From: m4xxed Date: Thu, 20 Jul 2023 17:36:49 +0200 Subject: [PATCH 06/69] fix grammar of documentation --- Assets/SEE/Game/GameEdgeAdder.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Assets/SEE/Game/GameEdgeAdder.cs b/Assets/SEE/Game/GameEdgeAdder.cs index 2b75968745..034aa55fb1 100644 --- a/Assets/SEE/Game/GameEdgeAdder.cs +++ b/Assets/SEE/Game/GameEdgeAdder.cs @@ -7,7 +7,7 @@ namespace SEE.Game { /// - /// Creates new game objects representing graph edges or deleting these again, + /// Creates new game objects representing graph edges or deletes these again, /// respectively. /// public class GameEdgeAdder From 28c9e41cfe28deb800b8a44d932bb6525cba1921 Mon Sep 17 00:00:00 2001 From: m4xxed Date: Thu, 27 Jul 2023 10:57:44 +0200 Subject: [PATCH 07/69] remove unused import #599 --- Assets/SEE/Net/Actions/AcceptDivergenceNetAction.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/Assets/SEE/Net/Actions/AcceptDivergenceNetAction.cs b/Assets/SEE/Net/Actions/AcceptDivergenceNetAction.cs index cb4a4f2774..8aaa4bacf7 100644 --- a/Assets/SEE/Net/Actions/AcceptDivergenceNetAction.cs +++ b/Assets/SEE/Net/Actions/AcceptDivergenceNetAction.cs @@ -1,4 +1,3 @@ -using SEE.Game; using UnityEngine; namespace SEE.Net.Actions From a50db64eede1b3f6fa25e281efa44b9762df7cce Mon Sep 17 00:00:00 2001 From: m4xxed Date: Thu, 27 Jul 2023 10:59:26 +0200 Subject: [PATCH 08/69] remove unneccesary workaround #599 --- .../Actions/AcceptDivergenceAction.cs | 33 ------------------- 1 file changed, 33 deletions(-) diff --git a/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs b/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs index e929c93a7e..9fd3fc2ea6 100644 --- a/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs +++ b/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs @@ -44,39 +44,6 @@ public override bool Update() // Check whether the object selected is actually an edge. if (selectedDivergenceEdge.TryGetEdge(out Edge selectedEdge)) { - // // FIXME: This is a stupid workaround until the Diversion Edge can be selected - // var graph = (ReflexionGraph)selectedEdge.ItsGraph; - // foreach (Edge edge in graph.Edges()) - // { - // if (ReflexionGraph.IsDivergent(edge)) - // { - // // Find Node in ArchitectureGraph the - // // divergence's Source is explicitly or - // // implicitly mapped to. - // Node source = graph.MapsTo(edge.Source); - - // // Find Node in ArchitectureGraph the - // // divergence's Target is explicitly or - // // implicitly mapped to. - // Node target = graph.MapsTo(edge.Target); - - // // Ensure the required Edge has not - // // already been added (shouldn't be - // // necessary outside of this workaround - // // due to Incremental nature of - // // ReflexionGraph) - // if (graph.Edges().Any(x => x.Source == edge.Source && x.Target == edge.Target)) - // { - // // add new edge to node - // Edge newArchitectureEdge = graph.AddToArchitecture(source, target, edge.Type); - // } - // } - // } - - // FIXME: this is the actual solution which should - // work using edge selection: - - // Check if Edge represents a Divergence if (ReflexionGraph.IsDivergent(selectedEdge)) { // get the containing ReflexionGraph From 64c5691a018c2f5e84460eea8448cff032268aac Mon Sep 17 00:00:00 2001 From: m4xxed Date: Thu, 27 Jul 2023 11:01:22 +0200 Subject: [PATCH 09/69] disable networkaction temporarily #599 --- Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs b/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs index 9fd3fc2ea6..5176fbc925 100644 --- a/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs +++ b/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs @@ -36,7 +36,9 @@ public override bool Update() { // FIXME: Needs adaptation for VR where no mouse is available. if (Input.GetMouseButtonDown(0) - && Raycasting.RaycastGraphElement(out RaycastHit raycastHit, out GraphElementRef _) != HitGraphElement.None) + && Raycasting.RaycastGraphElement( + out RaycastHit raycastHit, + out GraphElementRef _) != HitGraphElement.None) { // Find the edge representing the specific Divergence that should be solved. selectedDivergenceEdge = raycastHit.collider.gameObject; @@ -63,7 +65,7 @@ public override bool Update() Edge newArchitectureEdge = graph.AddToArchitecture(source, target, selectedEdge.Type); // Sync the Solution of the Divergence via Network - new AcceptDivergenceNetAction(selectedDivergenceEdge.name).Execute(); + // new AcceptDivergenceNetAction(selectedDivergenceEdge.name).Execute(); return true; // the selected object is synced and this action is done } } From 0d36940eb217a12db64ded314f80d109991fb330 Mon Sep 17 00:00:00 2001 From: m4xxed Date: Thu, 27 Jul 2023 11:02:40 +0200 Subject: [PATCH 10/69] update documentation #599 --- .../Actions/AcceptDivergenceAction.cs | 66 ++++++++++++++++--- 1 file changed, 57 insertions(+), 9 deletions(-) diff --git a/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs b/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs index 5176fbc925..34d1bcbcd0 100644 --- a/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs +++ b/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs @@ -40,29 +40,33 @@ public override bool Update() out RaycastHit raycastHit, out GraphElementRef _) != HitGraphElement.None) { - // Find the edge representing the specific Divergence that should be solved. + // Find the edge representing the divergence that should be solved. selectedDivergenceEdge = raycastHit.collider.gameObject; - // Check whether the object selected is actually an edge. + // Check whether the object selected is an edge. if (selectedDivergenceEdge.TryGetEdge(out Edge selectedEdge)) { + // Check if the selected edge represents a divergence if (ReflexionGraph.IsDivergent(selectedEdge)) { - // get the containing ReflexionGraph + // acquire the containing ReflexionGraph var graph = (ReflexionGraph)selectedEdge.ItsGraph; - // Find Node in ArchitectureGraph the - // divergence's Source is explicitly or - // implicitly mapped to. + // Find that node in the ArchitectureGraph, + // which the divergence's source node is + // explicitly or implicitly mapped to. Node source = graph.MapsTo(selectedEdge.Source); - // Find Node in ArchitectureGraph the - // divergence's Target is explicitly or - // implicitly mapped to. + // Find that node in the ArchitectureGraph, + // which the divergence's target is explicitly + // or implicitly mapped to. Node target = graph.MapsTo(selectedEdge.Target); // Create a new Edge that will solve the Divergence Edge newArchitectureEdge = graph.AddToArchitecture(source, target, selectedEdge.Type); + // We have both source and target of the edge + // and use a memento struct to remember which + // edge we have added. // Sync the Solution of the Divergence via Network // new AcceptDivergenceNetAction(selectedDivergenceEdge.name).Execute(); @@ -77,12 +81,56 @@ public override bool Update() return false; } + /// + /// Creates a new edge using the given . + /// In case of any error, null will be returned. + /// + /// information needed to create the edge + /// a new edge or null + private static Edge CreateEdge(ReflexionGraph graph, Memento memento) + { + try + { + // Create a new Edge that will solve the Divergence + var newArchitectureEdge = graph.AddToArchitecture( + memento.from, + memento.to, + "Architecture"); + + // Sync the Solution of the Divergence via Network + // new AcceptDivergenceNetAction().Execute(); + return newArchitectureEdge; + } + catch (Exception e) + { + ShowNotification.Error("New edge", $"An edge could not be created: {e.Message}."); + Debug.LogException(e); + return null; + } + } /// /// Undoes this AcceptDivergenceAction. /// public override void Undo() { + base.Undo(); + + // remove the synced edge (info is saved in memento) + var graph = (ReflexionGraph)createdEdge.ItsGraph; + + if (graph != null) + { + graph.RemoveEdge(createdEdge); + // use netaction to remove synced edge over net + } + else + { + throw new Exception($"Edge {createdEdge.ID} to be removed is not contained in a graph."); + } + + // set any edge references back to null + createdEdge = null; } /// From 169b7b6fa6ee0ed7e69bb76e9ea8134f58e06031 Mon Sep 17 00:00:00 2001 From: m4xxed Date: Thu, 27 Jul 2023 11:03:38 +0200 Subject: [PATCH 11/69] add functionality to create edges #599 --- .../Actions/AcceptDivergenceAction.cs | 44 +++++++++++++++++-- 1 file changed, 41 insertions(+), 3 deletions(-) diff --git a/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs b/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs index 34d1bcbcd0..94dd804866 100644 --- a/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs +++ b/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs @@ -62,11 +62,13 @@ public override bool Update() // or implicitly mapped to. Node target = graph.MapsTo(selectedEdge.Target); - // Create a new Edge that will solve the Divergence - Edge newArchitectureEdge = graph.AddToArchitecture(source, target, selectedEdge.Type); // We have both source and target of the edge // and use a memento struct to remember which // edge we have added. + memento = new Memento(source, target); + + createdEdge = CreateEdge(graph, memento); + AudioManagerImpl.EnqueueSoundEffect(IAudioManager.SoundEffect.NEW_EDGE_SOUND); // Sync the Solution of the Divergence via Network // new AcceptDivergenceNetAction(selectedDivergenceEdge.name).Execute(); @@ -158,6 +160,43 @@ public override ReversibleAction NewInstance() return CreateReversibleAction(); } + /// + /// The information we need to (re-)create an edge. + /// + private struct Memento + { + /// + /// The source of the edge. + /// + public Node from; + /// + /// The target of the edge. + /// + public Node to; + /// + /// The type of the edge. + /// + public Memento(Node source, Node target) + { + this.from = source; + this.to = target; + } + } + + /// + /// The information needed to re-create the synced edge after undo. + /// + private Memento memento; + + /// + /// The edge created by this action. Can be null if no edge + /// has been created yet or whether an Undo was called. The + /// created edge is stored only to delete it again if Undo is + /// called. All information to create the edge is kept in + /// . + /// + private Edge createdEdge; + /// /// Returns the of this action. /// @@ -181,7 +220,6 @@ public override HashSet GetChangedObjects() { return new HashSet(syncedGameObjects.Select(x => x.name)); } - } } } From c562db2fa549986891580a9e5fc98977d1a4cee0 Mon Sep 17 00:00:00 2001 From: m4xxed Date: Thu, 27 Jul 2023 11:04:06 +0200 Subject: [PATCH 12/69] fix imports #599 --- Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs b/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs index 94dd804866..dcbbf6dbb5 100644 --- a/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs +++ b/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs @@ -3,9 +3,11 @@ using SEE.Tools.ReflexionAnalysis; using System.Linq; using SEE.GO; -using SEE.Net.Actions; using SEE.Utils; using UnityEngine; +using SEE.Audio; +using System; +using SEE.Game.UI.Notification; namespace SEE.Controls.Actions { From d1284908546339c99988cd0cd9ca10827b5f11d2 Mon Sep 17 00:00:00 2001 From: m4xxed Date: Thu, 27 Jul 2023 11:04:18 +0200 Subject: [PATCH 13/69] start adding basic redo functionality #599 --- Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs b/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs index dcbbf6dbb5..e4162a35b5 100644 --- a/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs +++ b/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs @@ -142,6 +142,9 @@ public override void Undo() /// public override void Redo() { + base.Redo(); + // CreateEdge(); + // recreate edge from memento } /// From e63c849fa7e6e2aed483c233e67ef576e0126044 Mon Sep 17 00:00:00 2001 From: m4xxed Date: Sat, 29 Jul 2023 23:57:28 +0200 Subject: [PATCH 14/69] something went wrong while merging - reverted to master state #599 --- Assets/SEE/Controls/Actions/ActionStateType.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Assets/SEE/Controls/Actions/ActionStateType.cs b/Assets/SEE/Controls/Actions/ActionStateType.cs index b709f15eef..8478b96c43 100644 --- a/Assets/SEE/Controls/Actions/ActionStateType.cs +++ b/Assets/SEE/Controls/Actions/ActionStateType.cs @@ -1,7 +1,9 @@ +using SEE.Utils; using UnityEngine; namespace SEE.Controls.Actions { + /// /// The type of a state-based action. /// Implemented using the "Enumeration" (not enum) or "type safe enum" pattern. @@ -11,6 +13,7 @@ namespace SEE.Controls.Actions ///
  • https://ardalis.com/enum-alternatives-in-c/
  • /// ///
    + public class ActionStateType : AbstractActionStateType { /// /// Delegate to be called to create a new instance of this kind of action. @@ -25,8 +28,15 @@ namespace SEE.Controls.Actions /// /// The Name of this ActionStateType. Must be unique. /// Description for this ActionStateType. + /// The parent of this action in the nesting hierarchy in the menu. /// Color for this ActionStateType. /// Path to the material of the icon for this ActionStateType. + /// Delegate to be called to create a new instance of this kind of action. + /// Can be null, in which case no delegate will be called. + /// If true, this action state type will be registered in . + public ActionStateType(string name, string description, + Color color, string iconPath, CreateReversibleAction createReversible, ActionStateTypeGroup parent = null, bool register = true) + : base(name, description, color, iconPath, parent, register) { CreateReversible = createReversible; } @@ -45,10 +55,12 @@ public override bool Equals(object obj) return true; } + return obj.GetType() == GetType() && ((ActionStateType)obj).CreateReversible == CreateReversible; } public override int GetHashCode() { + return CreateReversible.GetHashCode(); } #endregion From 1c153b8b9f65b58e2eefafc9720b647cc5a11db5 Mon Sep 17 00:00:00 2001 From: m4xxed Date: Sat, 5 Aug 2023 21:22:18 +0200 Subject: [PATCH 15/69] use GameEdgeAdder to add Edge to Game --- .../Actions/AcceptDivergenceAction.cs | 41 +++++++++---------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs b/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs index e4162a35b5..8231d28762 100644 --- a/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs +++ b/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs @@ -5,9 +5,8 @@ using SEE.GO; using SEE.Utils; using UnityEngine; -using SEE.Audio; using System; -using SEE.Game.UI.Notification; +using SEE.Game; namespace SEE.Controls.Actions { @@ -70,7 +69,10 @@ public override bool Update() memento = new Memento(source, target); createdEdge = CreateEdge(graph, memento); - AudioManagerImpl.EnqueueSoundEffect(IAudioManager.SoundEffect.NEW_EDGE_SOUND); + createdEdge.UnsetToggle(Edge.IsVirtualToggle); + + // Audio + // AudioManagerImpl.EnqueueSoundEffect(IAudioManager.SoundEffect.NEW_EDGE_SOUND); // Sync the Solution of the Divergence via Network // new AcceptDivergenceNetAction(selectedDivergenceEdge.name).Execute(); @@ -93,24 +95,19 @@ public override bool Update() /// a new edge or null private static Edge CreateEdge(ReflexionGraph graph, Memento memento) { - try - { - // Create a new Edge that will solve the Divergence - var newArchitectureEdge = graph.AddToArchitecture( - memento.from, - memento.to, - "Architecture"); - - // Sync the Solution of the Divergence via Network - // new AcceptDivergenceNetAction().Execute(); - return newArchitectureEdge; - } - catch (Exception e) - { - ShowNotification.Error("New edge", $"An edge could not be created: {e.Message}."); - Debug.LogException(e); - return null; - } + // Add the new Edge to the ArhcitectureGraph + var newArchitectureEdge = graph.ActuallyAddToArchitecture( + memento.from, + memento.to, + "Source_Dependency"); + + // Add the new Edge to the Game + GameObject result = GameEdgeAdder.Draw(newArchitectureEdge); + + // Sync the Solution of the Divergence via Network + // new AcceptDivergenceNetAction().Execute(); + + return newArchitectureEdge; } /// @@ -208,7 +205,7 @@ public Memento(Node source, Node target) /// public override ActionStateType GetActionStateType() { - return ActionStateType.Sync; + return ActionStateTypes.AcceptDivergence; } /// From 9f565028ded5d8d48ced27f05e1310cade83886f Mon Sep 17 00:00:00 2001 From: m4xxed Date: Sat, 5 Aug 2023 21:25:36 +0200 Subject: [PATCH 16/69] add DrawEdge method that accepts an existing Edge as parameter --- Assets/SEE/Game/EdgeRenderer.cs | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/Assets/SEE/Game/EdgeRenderer.cs b/Assets/SEE/Game/EdgeRenderer.cs index 44f41e69b6..0c0b6ed116 100644 --- a/Assets/SEE/Game/EdgeRenderer.cs +++ b/Assets/SEE/Game/EdgeRenderer.cs @@ -216,6 +216,35 @@ public GameObject DrawEdge(GameObject source, GameObject target, string edgeType return DrawEdge(edge, source, target, true); } + /// + /// Draws and returns a new game edge + /// based on the current settings. + /// + /// Note: The default edge layout will be used if no edge layout, + /// i.e., , was chosen in the settings. + /// + /// Precondition: and must have a valid + /// node reference. The corresponding graph nodes must be in the same graph. + /// + /// the edge to be drawn + /// GameObject of source of the new edge + /// GameObject of target of the new edge + /// The new game object representing the given edge. + public GameObject DrawEdge(Edge edge, GameObject sourceNode = null, GameObject targetNode = null) + { + if (sourceNode == null) + { + sourceNode = GraphElementIDMap.Find(edge.Source.ID); + } + + if (targetNode == null) + { + targetNode = GraphElementIDMap.Find(edge.Target.ID); + } + + return DrawEdge(edge, sourceNode, targetNode, true); + } + /// /// Adds and all its transitive parent game objects tagged by /// to . @@ -393,4 +422,4 @@ private static ICollection> ConnectingEdges(ICollection return edges; } } -} \ No newline at end of file +} From dd9155c2ff3a829b8860548ebcae42782a15c8c1 Mon Sep 17 00:00:00 2001 From: m4xxed Date: Sat, 5 Aug 2023 21:26:14 +0200 Subject: [PATCH 17/69] add DrawEdge because it is required in GraphRenderer --- Assets/SEE/Game/Evolution/EvolutionRenderer.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Assets/SEE/Game/Evolution/EvolutionRenderer.cs b/Assets/SEE/Game/Evolution/EvolutionRenderer.cs index df73a6f44b..c6cdac8c10 100644 --- a/Assets/SEE/Game/Evolution/EvolutionRenderer.cs +++ b/Assets/SEE/Game/Evolution/EvolutionRenderer.cs @@ -932,6 +932,11 @@ public GameObject DrawNode(Node node, GameObject city = null) return Renderer.DrawNode(node, city); } + public GameObject DrawEdge(Edge edge, GameObject source = null, GameObject target = null) + { + throw new NotImplementedException(); + } + /// /// Returns an edge layout for the given . /// From 6180133ff59fc628957798f9b61477c5a343b31a Mon Sep 17 00:00:00 2001 From: m4xxed Date: Sat, 5 Aug 2023 21:27:05 +0200 Subject: [PATCH 18/69] overload DrawEdge to accept an existing DataModel.Edge as parameter --- Assets/SEE/Game/IGraphRenderer.cs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/Assets/SEE/Game/IGraphRenderer.cs b/Assets/SEE/Game/IGraphRenderer.cs index 5506c8d97f..eb696337e4 100644 --- a/Assets/SEE/Game/IGraphRenderer.cs +++ b/Assets/SEE/Game/IGraphRenderer.cs @@ -34,6 +34,22 @@ public interface IGraphRenderer /// are not contained in any graph or contained in different graphs GameObject DrawEdge(GameObject source, GameObject target, string edgeType); + /// + /// Draws and returns a new game edge + /// based on the current settings. + /// + /// Note: The default edge layout will be used if no edge layout, + /// i.e., , was chosen in the settings. + /// + /// Precondition: and must have a valid + /// node reference. The corresponding graph nodes must be in the same graph. + /// + /// the edge to be drawn + /// GameObject of source of the new edge + /// GameObject of target of the new edge + /// The new game object representing the given edge. + GameObject DrawEdge(Edge edge, GameObject source = null, GameObject target = null); + /// /// Returns an edge layout for the given . /// @@ -61,4 +77,4 @@ public interface IGraphRenderer /// game object representing given GameObject DrawNode(Node node, GameObject city = null); } -} \ No newline at end of file +} From 4c7a097d5c675c4a1415790f67e77bfe9be3365f Mon Sep 17 00:00:00 2001 From: m4xxed Date: Sat, 5 Aug 2023 21:28:13 +0200 Subject: [PATCH 19/69] fixed formatting --- Assets/SEE/Tools/ReflexionAnalysis/ReflexionGraph.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Assets/SEE/Tools/ReflexionAnalysis/ReflexionGraph.cs b/Assets/SEE/Tools/ReflexionAnalysis/ReflexionGraph.cs index 368852b9c9..45eb288c75 100644 --- a/Assets/SEE/Tools/ReflexionAnalysis/ReflexionGraph.cs +++ b/Assets/SEE/Tools/ReflexionAnalysis/ReflexionGraph.cs @@ -72,7 +72,7 @@ public ReflexionGraph(Graph implementation, Graph architecture, Graph mapping, s /// /// This does not really run the reflexion analysis. Use to start the analysis. /// - public ReflexionGraph(Graph fullGraph, bool allowDependenciesToParents = true): base(fullGraph) + public ReflexionGraph(Graph fullGraph, bool allowDependenciesToParents = true) : base(fullGraph) { AllowDependenciesToParents = allowDependenciesToParents; (Graph implementation, Graph architecture, _) = Disassemble(); From 1850bdfbfa47380d9ec8b23c2bf2ef6cff734135 Mon Sep 17 00:00:00 2001 From: m4xxed Date: Sat, 5 Aug 2023 21:29:55 +0200 Subject: [PATCH 20/69] add new Draw() method to GameEdgeAdder --- Assets/SEE/Game/GameEdgeAdder.cs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/Assets/SEE/Game/GameEdgeAdder.cs b/Assets/SEE/Game/GameEdgeAdder.cs index 034aa55fb1..84c8d99c00 100644 --- a/Assets/SEE/Game/GameEdgeAdder.cs +++ b/Assets/SEE/Game/GameEdgeAdder.cs @@ -54,6 +54,29 @@ public static GameObject Add(GameObject source, GameObject target, string edgeTy return result; } + // TODO Write docstring + public static GameObject Draw(Edge edge) + { + Transform cityObject = SceneQueries.GetCodeCity(GraphElementIDMap.Find(edge.Source.ID).transform); + GameObject result; + if (cityObject != null) + { + if (cityObject.TryGetComponent(out AbstractSEECity city)) + { + result = city.Renderer.DrawEdge(edge, cityObject.gameObject); + } + else + { + throw new Exception($"The code city for the new edge {edge.ToShortString()} cannot be determined.\n"); + } + } + else + { + throw new Exception($"Could not determine the code city for the new edge {edge.ToShortString()}.\n"); + } + return result; + } + /// /// Inverse operation of . /// Removes the given from the scene and its associated From fed7e6f0d5cb9525751b1c2d6d96e65d764af658 Mon Sep 17 00:00:00 2001 From: m4xxed Date: Sat, 5 Aug 2023 21:32:09 +0200 Subject: [PATCH 21/69] temporary placeholder until we figure out a better way --- Assets/SEE/Tools/ReflexionAnalysis/Incremental.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Assets/SEE/Tools/ReflexionAnalysis/Incremental.cs b/Assets/SEE/Tools/ReflexionAnalysis/Incremental.cs index 036a5ab3ed..8e81a7e11b 100644 --- a/Assets/SEE/Tools/ReflexionAnalysis/Incremental.cs +++ b/Assets/SEE/Tools/ReflexionAnalysis/Incremental.cs @@ -169,6 +169,14 @@ public Edge AddToArchitecture(Node from, Node to, string type) return edge; } + public Edge ActuallyAddToArchitecture(Node from, Node to, string type) + { + // Preconditions are checked in AddToArchitecture. + Edge edge = AddEdge(from, to, type, false, false); + AddToArchitecture(edge); + return edge; + } + /// /// Adds the given to the implementation graph, /// adjusting the reflexion analysis incrementally. From ca8e6346da1d4f520100aaa10b4d1983d800eaa4 Mon Sep 17 00:00:00 2001 From: Falko Galperin Date: Sun, 6 Aug 2023 18:14:57 +0200 Subject: [PATCH 22/69] Automatic changes by Unity --- .../Mirror Render Texture.renderTexture | 1 + .../Controls/Actions/AcceptDivergenceAction.cs.meta | 11 +++++++++++ .../SEE/Net/Actions/AcceptDivergenceNetAction.cs.meta | 11 +++++++++++ Packages/packages-lock.json | 2 +- 4 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs.meta create mode 100644 Assets/SEE/Net/Actions/AcceptDivergenceNetAction.cs.meta diff --git a/Assets/Resources/Materials/MirrorMaterial/Mirror Render Texture.renderTexture b/Assets/Resources/Materials/MirrorMaterial/Mirror Render Texture.renderTexture index 1f8372e532..a213549bee 100644 --- a/Assets/Resources/Materials/MirrorMaterial/Mirror Render Texture.renderTexture +++ b/Assets/Resources/Materials/MirrorMaterial/Mirror Render Texture.renderTexture @@ -26,6 +26,7 @@ RenderTexture: m_UseDynamicScale: 0 m_BindMS: 0 m_EnableCompatibleFormat: 1 + m_EnableRandomWrite: 0 m_TextureSettings: serializedVersion: 2 m_FilterMode: 1 diff --git a/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs.meta b/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs.meta new file mode 100644 index 0000000000..c69154aa4a --- /dev/null +++ b/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 6c0170e2fab3a75bda98c1062700a9d2 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/SEE/Net/Actions/AcceptDivergenceNetAction.cs.meta b/Assets/SEE/Net/Actions/AcceptDivergenceNetAction.cs.meta new file mode 100644 index 0000000000..e3ea553c32 --- /dev/null +++ b/Assets/SEE/Net/Actions/AcceptDivergenceNetAction.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 724ad0b3aa74ecf5f9afd1bde58e9762 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/packages-lock.json b/Packages/packages-lock.json index 179e5a56ab..dbf44ff2f8 100644 --- a/Packages/packages-lock.json +++ b/Packages/packages-lock.json @@ -302,7 +302,7 @@ } }, "com.unity.xr.core-utils": { - "version": "2.2.1", + "version": "2.2.2", "depth": 1, "source": "registry", "dependencies": { From 3941a48077fca353c187158d03c29a15397903b5 Mon Sep 17 00:00:00 2001 From: Falko Galperin Date: Sun, 6 Aug 2023 18:15:58 +0200 Subject: [PATCH 23/69] Use new new in EdgeRenderer --- Assets/SEE/Game/EdgeRenderer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Assets/SEE/Game/EdgeRenderer.cs b/Assets/SEE/Game/EdgeRenderer.cs index 0c0b6ed116..9eb8dcfe2f 100644 --- a/Assets/SEE/Game/EdgeRenderer.cs +++ b/Assets/SEE/Game/EdgeRenderer.cs @@ -155,7 +155,7 @@ private GameObject DrawEdge(Edge edge, GameObject from, GameObject to, bool addT Assert.IsNotNull(toLayoutNode, $"Target node {edge.Target.ID} does not have a layout node.\n"); // The single layout edge between source and target. We want the layout only for this edge. ICollection> layoutEdges = new List> - { new LayoutGraphEdge(fromLayoutNode, toLayoutNode, edge) }; + { new(fromLayoutNode, toLayoutNode, edge) }; // Calculate the edge layout (for the single edge only). From 28269048dcd19fa15b613f1565839c925e4daafd Mon Sep 17 00:00:00 2001 From: Falko Galperin Date: Sun, 6 Aug 2023 18:16:36 +0200 Subject: [PATCH 24/69] Pass correct source object to Renderer.DrawEdge --- Assets/SEE/Game/GameEdgeAdder.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Assets/SEE/Game/GameEdgeAdder.cs b/Assets/SEE/Game/GameEdgeAdder.cs index 84c8d99c00..6aab65c051 100644 --- a/Assets/SEE/Game/GameEdgeAdder.cs +++ b/Assets/SEE/Game/GameEdgeAdder.cs @@ -57,13 +57,14 @@ public static GameObject Add(GameObject source, GameObject target, string edgeTy // TODO Write docstring public static GameObject Draw(Edge edge) { - Transform cityObject = SceneQueries.GetCodeCity(GraphElementIDMap.Find(edge.Source.ID).transform); + GameObject source = GraphElementIDMap.Find(edge.Source.ID); + Transform cityObject = SceneQueries.GetCodeCity(source.transform); GameObject result; if (cityObject != null) { if (cityObject.TryGetComponent(out AbstractSEECity city)) { - result = city.Renderer.DrawEdge(edge, cityObject.gameObject); + result = city.Renderer.DrawEdge(edge, source: source); } else { From 9a60c00ed59dd59055a6569fa6d27f7c2e49a39b Mon Sep 17 00:00:00 2001 From: m4xxed Date: Tue, 8 Aug 2023 14:15:21 +0200 Subject: [PATCH 25/69] add audio and a networkaction to edge creation --- Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs b/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs index 8231d28762..0b42cec159 100644 --- a/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs +++ b/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs @@ -7,6 +7,8 @@ using UnityEngine; using System; using SEE.Game; +using SEE.Net.Actions; +using SEE.Audio; namespace SEE.Controls.Actions { @@ -71,11 +73,9 @@ public override bool Update() createdEdge = CreateEdge(graph, memento); createdEdge.UnsetToggle(Edge.IsVirtualToggle); - // Audio - // AudioManagerImpl.EnqueueSoundEffect(IAudioManager.SoundEffect.NEW_EDGE_SOUND); + // Add audio cue to the appearance of the new architecture edge + AudioManagerImpl.EnqueueSoundEffect(IAudioManager.SoundEffect.NEW_EDGE_SOUND); - // Sync the Solution of the Divergence via Network - // new AcceptDivergenceNetAction(selectedDivergenceEdge.name).Execute(); return true; // the selected object is synced and this action is done } } From 72c8a3fad5744b5d84c563fb5a0f225df4804572 Mon Sep 17 00:00:00 2001 From: m4xxed Date: Tue, 8 Aug 2023 14:16:23 +0200 Subject: [PATCH 26/69] reorder Class to fit order convention and add undo / redo --- .../Actions/AcceptDivergenceAction.cs | 214 +++++++++++------- 1 file changed, 132 insertions(+), 82 deletions(-) diff --git a/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs b/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs index 0b42cec159..7d37487562 100644 --- a/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs +++ b/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs @@ -19,6 +19,24 @@ namespace SEE.Controls.Actions /// internal class AcceptDivergenceAction : AbstractPlayerAction { + /// + /// Returns a new instance of . + /// + /// new instance + public static ReversibleAction CreateReversibleAction() + { + return new AcceptDivergenceAction(); + } + + /// + /// Returns a new instance of . + /// + /// new instance + public override ReversibleAction NewInstance() + { + return CreateReversibleAction(); + } + /// /// The edge that was hit by the user to be accepted /// into the ArchitectureGraph. Set in . @@ -31,6 +49,75 @@ internal class AcceptDivergenceAction : AbstractPlayerAction /// private ISet syncedGameObjects; + /// + /// The information we need to (re-)create an edge. + /// + private struct Memento + { + /// + /// The source of the edge. + /// + public Node from; + /// + /// The target of the edge. + /// + public Node to; + /// + /// The type of the edge. + /// + public Memento(Node source, Node target) + { + this.from = source; + this.to = target; + } + } + + /// + /// The information needed to re-create the synced edge after + /// undo. + /// + private Memento memento; + + /// + /// The edge created by this action. Can be null if no edge + /// has been created yet or whether an Undo was called. The + /// created edge is stored only to delete it again if Undo is + /// called. All information to create the edge is kept in + /// . + /// + private Edge createdEdgeDataModel; + + /// + /// TODO + /// + private GameObject createdEdgeGameObject; + + /// + /// Registers itself at to + /// listen for hovering events. + /// + public override void Start() + { + InteractableObject.LocalAnyHoverIn += LocalAnyHoverIn; + InteractableObject.LocalAnyHoverOut += LocalAnyHoverOut; + } + + /// + /// Unregisters itself from . Does no longer listen for + /// hovering events. + /// + public override void Stop() + { + InteractableObject.LocalAnyHoverIn -= LocalAnyHoverIn; + InteractableObject.LocalAnyHoverOut -= LocalAnyHoverOut; + } + + /// + /// The default type of an added edge. + /// + private const string DefaultEdgeType = "Source_Dependency"; + /// /// See . /// @@ -70,8 +157,11 @@ public override bool Update() // edge we have added. memento = new Memento(source, target); - createdEdge = CreateEdge(graph, memento); - createdEdge.UnsetToggle(Edge.IsVirtualToggle); + // The Edge in the DataModel and it's + // GameObject are created separately + var createdEdgeParts = CreateEdge(graph, memento); + createdEdgeDataModel = createdEdgeParts.edgeDataModel; + createdEdgeGameObject = createdEdgeParts.edgeGameObject; // Add audio cue to the appearance of the new architecture edge AudioManagerImpl.EnqueueSoundEffect(IAudioManager.SoundEffect.NEW_EDGE_SOUND); @@ -87,29 +177,6 @@ public override bool Update() return false; } - /// - /// Creates a new edge using the given . - /// In case of any error, null will be returned. - /// - /// information needed to create the edge - /// a new edge or null - private static Edge CreateEdge(ReflexionGraph graph, Memento memento) - { - // Add the new Edge to the ArhcitectureGraph - var newArchitectureEdge = graph.ActuallyAddToArchitecture( - memento.from, - memento.to, - "Source_Dependency"); - - // Add the new Edge to the Game - GameObject result = GameEdgeAdder.Draw(newArchitectureEdge); - - // Sync the Solution of the Divergence via Network - // new AcceptDivergenceNetAction().Execute(); - - return newArchitectureEdge; - } - /// /// Undoes this AcceptDivergenceAction. /// @@ -118,20 +185,29 @@ public override void Undo() base.Undo(); // remove the synced edge (info is saved in memento) - var graph = (ReflexionGraph)createdEdge.ItsGraph; + var graph = (ReflexionGraph)createdEdgeDataModel.ItsGraph; + + Debug.Log($"Trying to delete edge {createdEdgeDataModel.ID}"); if (graph != null) { - graph.RemoveEdge(createdEdge); - // use netaction to remove synced edge over net + // Remove the edge from the data model locally and on the network + graph.RemoveFromArchitecture(createdEdgeDataModel); + new DeleteNetAction(createdEdgeGameObject.name).Execute(); + + // Remove the edge's GameObject locally and on the network + GameEdgeAdder.Remove(createdEdgeGameObject); + new DeleteNetAction(createdEdgeGameObject.name).Execute(); + Destroyer.Destroy(createdEdgeGameObject); } else { - throw new Exception($"Edge {createdEdge.ID} to be removed is not contained in a graph."); + throw new Exception($"Edge {createdEdgeDataModel.ID} to be removed is not contained in a graph."); } // set any edge references back to null - createdEdge = null; + createdEdgeDataModel = null; + createdEdgeGameObject = null; } /// @@ -140,64 +216,33 @@ public override void Undo() public override void Redo() { base.Redo(); - // CreateEdge(); - // recreate edge from memento + var createdEdgeParts = CreateEdge((ReflexionGraph)createdEdgeDataModel.ItsGraph, memento); + createdEdgeDataModel = createdEdgeParts.edgeDataModel; + createdEdgeGameObject = createdEdgeParts.edgeGameObject; } /// - /// Returns a new instance of . - /// - /// new instance - public static ReversibleAction CreateReversibleAction() - { - return new AcceptDivergenceAction(); - } - - /// - /// Returns a new instance of . + /// Creates a new edge using the given . + /// In case of any error, null will be returned. /// - /// new instance - public override ReversibleAction NewInstance() + /// information needed to create the edge + /// a new edge or null + private static (Edge edgeDataModel, GameObject edgeGameObject) CreateEdge(ReflexionGraph graph, Memento memento) { - return CreateReversibleAction(); - } + // Add the new Edge to the ArhcitectureGraph + var edgeDataModel = graph.ActuallyAddToArchitecture( + memento.from, + memento.to, + "Source_Dependency"); - /// - /// The information we need to (re-)create an edge. - /// - private struct Memento - { - /// - /// The source of the edge. - /// - public Node from; - /// - /// The target of the edge. - /// - public Node to; - /// - /// The type of the edge. - /// - public Memento(Node source, Node target) - { - this.from = source; - this.to = target; - } - } + // Add the new Edge to the Game + GameObject edgeGameObject = GameEdgeAdder.Draw(edgeDataModel); - /// - /// The information needed to re-create the synced edge after undo. - /// - private Memento memento; + // Sync the Solution of the Divergence via Network + new AcceptDivergenceNetAction(memento.from.SourceName, memento.to.SourceName).Execute(); - /// - /// The edge created by this action. Can be null if no edge - /// has been created yet or whether an Undo was called. The - /// created edge is stored only to delete it again if Undo is - /// called. All information to create the edge is kept in - /// . - /// - private Edge createdEdge; + return (edgeDataModel, edgeGameObject); + } /// /// Returns the of this action. @@ -214,13 +259,18 @@ public override ActionStateType GetActionStateType() /// all IDs of gameObjects manipulated by this action public override HashSet GetChangedObjects() { - if (syncedGameObjects == null) + if (createdEdgeDataModel == null | createdEdgeGameObject == null) { return new HashSet(); } else { - return new HashSet(syncedGameObjects.Select(x => x.name)); + return new HashSet + { + memento.from.ID, + memento.to.ID, + createdEdgeDataModel.ID, + createdEdgeGameObject.name }; } } } From 25ae3a343375aef3b10a8893957af54874aedea6 Mon Sep 17 00:00:00 2001 From: m4xxed Date: Tue, 8 Aug 2023 14:16:54 +0200 Subject: [PATCH 27/69] add NetAction to accept divergences --- .../Net/Actions/AcceptDivergenceNetAction.cs | 43 ++++++++++++------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/Assets/SEE/Net/Actions/AcceptDivergenceNetAction.cs b/Assets/SEE/Net/Actions/AcceptDivergenceNetAction.cs index 8aaa4bacf7..2369abde40 100644 --- a/Assets/SEE/Net/Actions/AcceptDivergenceNetAction.cs +++ b/Assets/SEE/Net/Actions/AcceptDivergenceNetAction.cs @@ -1,3 +1,4 @@ +using SEE.Game; using UnityEngine; namespace SEE.Net.Actions @@ -12,24 +13,14 @@ public class AcceptDivergenceNetAction : AbstractNetAction // for the network transfer. /// - /// The ID of the parent gameObject of the new GameObject. + /// The id of the gameObject from which the edge should be drawn (source node). /// - public string ParentID; + public string FromId; /// - /// The id of the new node. + /// The id of the gameObject to which the edge should be drawn (target node). /// - public string NewNodeID; - - /// - /// The position of the new node. - /// - public Vector3 Position; - - /// - /// The scale of the new node. - /// - public Vector3 Scale; + public string ToId; /// /// Constructor. @@ -38,9 +29,11 @@ public class AcceptDivergenceNetAction : AbstractNetAction /// id for the new node /// the position for the new node /// the scale of the new node in world space - public AcceptDivergenceNetAction(string gameObjectID) + public AcceptDivergenceNetAction(string fromId, string toId) : base() { + FromId = fromId; + ToId = toId; } /// @@ -57,6 +50,26 @@ protected override void ExecuteOnServer() /// protected override void ExecuteOnClient() { + if (!IsRequester()) + { + GameObject fromGO = GraphElementIDMap.Find(FromId); + if (fromGO) + { + GameObject toGO = GraphElementIDMap.Find(ToId); + if (toGO) + { + GameEdgeAdder.Add(fromGO, toGO, "Source_Dependency"); + } + else + { + Debug.LogError($"There is no game node named {ToId} for the target.\n"); + } + } + else + { + Debug.LogError($"There is no game node named {FromId} for the source.\n"); + } + } } } } From 07c4283f6a5ffc10744a6e2b1cd787a99fd0c0b1 Mon Sep 17 00:00:00 2001 From: m4xxed Date: Tue, 8 Aug 2023 16:13:51 +0200 Subject: [PATCH 28/69] completed undo- and redo functionality --- .../Actions/AcceptDivergenceAction.cs | 32 +++++++++++-------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs b/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs index 7d37487562..a1aae7051f 100644 --- a/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs +++ b/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs @@ -1,7 +1,6 @@ using System.Collections.Generic; using SEE.DataModel.DG; using SEE.Tools.ReflexionAnalysis; -using System.Linq; using SEE.GO; using SEE.Utils; using UnityEngine; @@ -41,7 +40,7 @@ public override ReversibleAction NewInstance() /// The edge that was hit by the user to be accepted /// into the ArchitectureGraph. Set in . /// - private GameObject selectedDivergenceEdge; + private ReflexionGraph graph; /// /// Contains all Edges that were explicitly added to @@ -124,6 +123,8 @@ public override void Stop() /// true if completed public override bool Update() { + bool result = false; + // FIXME: Needs adaptation for VR where no mouse is available. if (Input.GetMouseButtonDown(0) && Raycasting.RaycastGraphElement( @@ -131,7 +132,7 @@ public override bool Update() out GraphElementRef _) != HitGraphElement.None) { // Find the edge representing the divergence that should be solved. - selectedDivergenceEdge = raycastHit.collider.gameObject; + GameObject selectedDivergenceEdge = raycastHit.collider.gameObject; // Check whether the object selected is an edge. if (selectedDivergenceEdge.TryGetEdge(out Edge selectedEdge)) @@ -139,8 +140,9 @@ public override bool Update() // Check if the selected edge represents a divergence if (ReflexionGraph.IsDivergent(selectedEdge)) { + // acquire the containing ReflexionGraph - var graph = (ReflexionGraph)selectedEdge.ItsGraph; + graph = (ReflexionGraph)selectedEdge.ItsGraph; // Find that node in the ArchitectureGraph, // which the divergence's source node is @@ -159,13 +161,19 @@ public override bool Update() // The Edge in the DataModel and it's // GameObject are created separately - var createdEdgeParts = CreateEdge(graph, memento); + var createdEdgeParts = CreateEdge(memento); createdEdgeDataModel = createdEdgeParts.edgeDataModel; createdEdgeGameObject = createdEdgeParts.edgeGameObject; + // Check whether edge creation was successfull + result = (createdEdgeDataModel != null && createdEdgeGameObject != null); + // Add audio cue to the appearance of the new architecture edge AudioManagerImpl.EnqueueSoundEffect(IAudioManager.SoundEffect.NEW_EDGE_SOUND); + // Update the curent state + currentState = result ? ReversibleAction.Progress.Completed : ReversibleAction.Progress.NoEffect; + return true; // the selected object is synced and this action is done } } @@ -187,18 +195,16 @@ public override void Undo() // remove the synced edge (info is saved in memento) var graph = (ReflexionGraph)createdEdgeDataModel.ItsGraph; - Debug.Log($"Trying to delete edge {createdEdgeDataModel.ID}"); - if (graph != null) { - // Remove the edge from the data model locally and on the network - graph.RemoveFromArchitecture(createdEdgeDataModel); - new DeleteNetAction(createdEdgeGameObject.name).Execute(); - // Remove the edge's GameObject locally and on the network GameEdgeAdder.Remove(createdEdgeGameObject); new DeleteNetAction(createdEdgeGameObject.name).Execute(); Destroyer.Destroy(createdEdgeGameObject); + + // Remove the edge from the data model locally and on the network + // graph.RemoveFromArchitecture(createdEdgeDataModel); + // new DeleteNetAction(createdEdgeGameObject.name).Execute(); } else { @@ -216,7 +222,7 @@ public override void Undo() public override void Redo() { base.Redo(); - var createdEdgeParts = CreateEdge((ReflexionGraph)createdEdgeDataModel.ItsGraph, memento); + var createdEdgeParts = CreateEdge(memento); createdEdgeDataModel = createdEdgeParts.edgeDataModel; createdEdgeGameObject = createdEdgeParts.edgeGameObject; } @@ -227,7 +233,7 @@ public override void Redo() /// /// information needed to create the edge /// a new edge or null - private static (Edge edgeDataModel, GameObject edgeGameObject) CreateEdge(ReflexionGraph graph, Memento memento) + private (Edge edgeDataModel, GameObject edgeGameObject) CreateEdge(Memento memento) { // Add the new Edge to the ArhcitectureGraph var edgeDataModel = graph.ActuallyAddToArchitecture( From 4373f92bb5bfd8334d6b539337d340b206b60004 Mon Sep 17 00:00:00 2001 From: m4xxed Date: Wed, 9 Aug 2023 00:23:55 +0200 Subject: [PATCH 29/69] complete overhaul of the docstrings and inline documentation --- .../Actions/AcceptDivergenceAction.cs | 114 +++++++++--------- 1 file changed, 59 insertions(+), 55 deletions(-) diff --git a/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs b/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs index a1aae7051f..e87a5f07c8 100644 --- a/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs +++ b/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs @@ -12,9 +12,9 @@ namespace SEE.Controls.Actions { /// - /// Action to solve a Divergence between Implementation and - /// Architecture by adding the Edge to the Architecture that - /// solves the Divergence. + /// Action to solve a divergence (see ) between + /// implementation and architecture by adding the exact edge to the architecture that solves + /// this divergence. /// internal class AcceptDivergenceAction : AbstractPlayerAction { @@ -27,8 +27,10 @@ public static ReversibleAction CreateReversibleAction() return new AcceptDivergenceAction(); } + /// - /// Returns a new instance of . + /// Returns a new instance of as a . /// /// new instance public override ReversibleAction NewInstance() @@ -36,20 +38,16 @@ public override ReversibleAction NewInstance() return CreateReversibleAction(); } + /// - /// The edge that was hit by the user to be accepted - /// into the ArchitectureGraph. Set in . + /// The graph that the edge which was hit by the user to be accepted into the graph is + /// in. Set in . /// private ReflexionGraph graph; - /// - /// Contains all Edges that were explicitly added to - /// solve Divergences. - /// - private ISet syncedGameObjects; /// - /// The information we need to (re-)create an edge. + /// The information required to (re-)create the edge that solves the divergence. /// private struct Memento { @@ -62,8 +60,10 @@ private struct Memento /// public Node to; /// - /// The type of the edge. + /// Construct a new memento. /// + /// the source node of the edge in the architecture graph + /// the target node of the edge in the architecture grpah public Memento(Node source, Node target) { this.from = source; @@ -71,29 +71,32 @@ public Memento(Node source, Node target) } } + /// - /// The information needed to re-create the synced edge after - /// undo. + /// The information required to (re-)create the edge that solves the divergence. /// private Memento memento; + /// - /// The edge created by this action. Can be null if no edge - /// has been created yet or whether an Undo was called. The - /// created edge is stored only to delete it again if Undo is - /// called. All information to create the edge is kept in - /// . + /// The edge created by this action. Can be null if no edge has been created yet or whether + /// an Undo was called. The created edge is stored only to delete it again if Undo is + /// called. All information to create the edge is kept in . /// private Edge createdEdgeDataModel; + /// - /// TODO + /// The edge created by this action's GameObject representation. Can be null if no edge has + /// been created yet or whether an Undo was called. The created edge is stored only to + /// delete it again if Undo is called. All information to create the edge is kept in . /// private GameObject createdEdgeGameObject; + /// - /// Registers itself at to - /// listen for hovering events. + /// Registers itself at to listen for hovering events. /// public override void Start() { @@ -101,9 +104,9 @@ public override void Start() InteractableObject.LocalAnyHoverOut += LocalAnyHoverOut; } + /// - /// Unregisters itself from . Does no longer listen for + /// Unregisters itself from . Does no longer listen for /// hovering events. /// public override void Stop() @@ -112,17 +115,20 @@ public override void Stop() InteractableObject.LocalAnyHoverOut -= LocalAnyHoverOut; } + /// /// The default type of an added edge. /// private const string DefaultEdgeType = "Source_Dependency"; + /// /// See . /// /// true if completed public override bool Update() { + // indicates whether the divergence has been solved ("true" means "solved") bool result = false; // FIXME: Needs adaptation for VR where no mouse is available. @@ -131,50 +137,50 @@ public override bool Update() out RaycastHit raycastHit, out GraphElementRef _) != HitGraphElement.None) { - // Find the edge representing the divergence that should be solved. + // find the edge representing the divergence that should be solved. GameObject selectedDivergenceEdge = raycastHit.collider.gameObject; - // Check whether the object selected is an edge. + // check whether the object selected is an edge. if (selectedDivergenceEdge.TryGetEdge(out Edge selectedEdge)) { - // Check if the selected edge represents a divergence + // check if the selected edge represents a divergence if (ReflexionGraph.IsDivergent(selectedEdge)) { // acquire the containing ReflexionGraph graph = (ReflexionGraph)selectedEdge.ItsGraph; - // Find that node in the ArchitectureGraph, + // find that node in the architecture graph, // which the divergence's source node is - // explicitly or implicitly mapped to. + // explicitly or implicitly mapped to Node source = graph.MapsTo(selectedEdge.Source); - // Find that node in the ArchitectureGraph, + // find that node in the ArchitectureGraph, // which the divergence's target is explicitly - // or implicitly mapped to. + // or implicitly mapped to Node target = graph.MapsTo(selectedEdge.Target); - // We have both source and target of the edge - // and use a memento struct to remember which - // edge we have added. + // we have both source and target of the edge and use a memento struct + // to remember which edge we have added memento = new Memento(source, target); - // The Edge in the DataModel and it's - // GameObject are created separately + // the Edge in the DataModel and it's GameObject are created separately var createdEdgeParts = CreateEdge(memento); createdEdgeDataModel = createdEdgeParts.edgeDataModel; createdEdgeGameObject = createdEdgeParts.edgeGameObject; - // Check whether edge creation was successfull + // check whether edge creation was successfull result = (createdEdgeDataModel != null && createdEdgeGameObject != null); - // Add audio cue to the appearance of the new architecture edge + // add audio cue to the appearance of the new architecture edge AudioManagerImpl.EnqueueSoundEffect(IAudioManager.SoundEffect.NEW_EDGE_SOUND); - // Update the curent state + // update the current state depending on whether the divergence has been solved + // (required in order to register as an undo-able action) currentState = result ? ReversibleAction.Progress.Completed : ReversibleAction.Progress.NoEffect; - return true; // the selected object is synced and this action is done + // the selected object is synced and this action is done + return true; } } else @@ -192,19 +198,15 @@ public override void Undo() { base.Undo(); - // remove the synced edge (info is saved in memento) + // remove the synced edge (its info is saved in memento) var graph = (ReflexionGraph)createdEdgeDataModel.ItsGraph; if (graph != null) { - // Remove the edge's GameObject locally and on the network + // remove the edge's GameObject and graph representation locally and on the network GameEdgeAdder.Remove(createdEdgeGameObject); new DeleteNetAction(createdEdgeGameObject.name).Execute(); Destroyer.Destroy(createdEdgeGameObject); - - // Remove the edge from the data model locally and on the network - // graph.RemoveFromArchitecture(createdEdgeDataModel); - // new DeleteNetAction(createdEdgeGameObject.name).Execute(); } else { @@ -222,29 +224,31 @@ public override void Undo() public override void Redo() { base.Redo(); + // recreate the edge var createdEdgeParts = CreateEdge(memento); + // save the references for later use createdEdgeDataModel = createdEdgeParts.edgeDataModel; createdEdgeGameObject = createdEdgeParts.edgeGameObject; } /// - /// Creates a new edge using the given . - /// In case of any error, null will be returned. + /// Creates a new edge using the given . In case of any error, + /// null will be returned. /// /// information needed to create the edge - /// a new edge or null + /// the new edge's GameObject and a reference to itself, or both null private (Edge edgeDataModel, GameObject edgeGameObject) CreateEdge(Memento memento) { - // Add the new Edge to the ArhcitectureGraph + // add the new edge to the architecture graph var edgeDataModel = graph.ActuallyAddToArchitecture( memento.from, memento.to, "Source_Dependency"); - // Add the new Edge to the Game + // add the new edge to the (game) GameObject edgeGameObject = GameEdgeAdder.Draw(edgeDataModel); - // Sync the Solution of the Divergence via Network + // sync the solution of the divergence via network new AcceptDivergenceNetAction(memento.from.SourceName, memento.to.SourceName).Execute(); return (edgeDataModel, edgeGameObject); @@ -260,9 +264,9 @@ public override ActionStateType GetActionStateType() } /// - /// Returns all IDs of gameObjects manipulated by this action. + /// Returns all IDs of GameObjects manipulated by this action. /// - /// all IDs of gameObjects manipulated by this action + /// all IDs of GameObjects manipulated by this action public override HashSet GetChangedObjects() { if (createdEdgeDataModel == null | createdEdgeGameObject == null) From b7b8701f7897549f4a99f055782526ad6e58c305 Mon Sep 17 00:00:00 2001 From: m4xxed Date: Wed, 9 Aug 2023 00:39:24 +0200 Subject: [PATCH 30/69] fixed order of actions - AcceptDivergence now before MetricBoard --- Assets/SEE/Controls/Actions/ActionStateTypes.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Assets/SEE/Controls/Actions/ActionStateTypes.cs b/Assets/SEE/Controls/Actions/ActionStateTypes.cs index 3f1df73587..3202b4337e 100644 --- a/Assets/SEE/Controls/Actions/ActionStateTypes.cs +++ b/Assets/SEE/Controls/Actions/ActionStateTypes.cs @@ -111,6 +111,11 @@ static ActionStateTypes() Color.magenta.Darker(), "Materials/ModernUIPack/Pencil", DrawAction.CreateReversibleAction); + AcceptDivergence = + new("Accept Divergence", "Accept a diverging edge into the Architecture", + Color.grey.Darker(), "Materials/ModernUIPack/Arrow Bold", + AcceptDivergenceAction.CreateReversibleAction); + // Metric Board actions MetricBoard = new("Metric Board", "Manipulate a metric board", @@ -163,11 +168,6 @@ static ActionStateTypes() Color.blue.Darker(), "Materials/ModernUIPack/Document", SaveBoardAction.CreateReversibleAction, parent: MetricBoard); - - AcceptDivergence = - new("Accept Divergence", "Accept a diverging edge into the Architecture", - Color.grey.Darker(), "Materials/ModernUIPack/Arrow Bold", - AcceptDivergenceAction.CreateReversibleAction); } @@ -181,6 +181,7 @@ static ActionStateTypes() public readonly static ActionStateType Delete; public readonly static ActionStateType ShowCode; public readonly static ActionStateType Draw; + public readonly static ActionStateType AcceptDivergence; public readonly static ActionStateTypeGroup MetricBoard; public readonly static ActionStateType AddBoard; @@ -191,7 +192,6 @@ static ActionStateTypes() public readonly static ActionStateType DeleteWidget; public readonly static ActionStateType LoadBoard; public readonly static ActionStateType SaveBoard; - public readonly static ActionStateType AcceptDivergence; #endregion From 2160453fcac5eeaf7fe91dc363d95993bab7f534 Mon Sep 17 00:00:00 2001 From: m4xxed Date: Wed, 9 Aug 2023 01:01:09 +0200 Subject: [PATCH 31/69] rename method to a less blame-y name and adjust documentation --- .../Actions/AcceptDivergenceAction.cs | 2 +- .../Tools/ReflexionAnalysis/Incremental.cs | 67 +++++++++++++------ 2 files changed, 47 insertions(+), 22 deletions(-) diff --git a/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs b/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs index e87a5f07c8..3ae53aa337 100644 --- a/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs +++ b/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs @@ -240,7 +240,7 @@ public override void Redo() private (Edge edgeDataModel, GameObject edgeGameObject) CreateEdge(Memento memento) { // add the new edge to the architecture graph - var edgeDataModel = graph.ActuallyAddToArchitecture( + var edgeDataModel = graph.AddToArchitectureNonVirtual( memento.from, memento.to, "Source_Dependency"); diff --git a/Assets/SEE/Tools/ReflexionAnalysis/Incremental.cs b/Assets/SEE/Tools/ReflexionAnalysis/Incremental.cs index 8e81a7e11b..8f0da39a76 100644 --- a/Assets/SEE/Tools/ReflexionAnalysis/Incremental.cs +++ b/Assets/SEE/Tools/ReflexionAnalysis/Incremental.cs @@ -21,13 +21,13 @@ public partial class ReflexionGraph /// adjusting the reflexion analysis incrementally. /// This will propagate and lift the new edge, thereby increasing the counter of the matching specified edge /// if it exists. - /// + /// /// Preconditions: ///
      ///
    • is contained in the implementation graph.
    • ///
    • is contained in the implementation graph.
    • ///
    - /// + /// /// Postcondition: A new edge from to /// is contained in the implementation graph and the reflexion data is updated; /// all observers are informed of the change by an event. @@ -52,10 +52,10 @@ public Edge AddToImplementation(Node from, Node to, string type) /// /// Adds the given to the implementation graph, /// adjusting the reflexion analysis incrementally. - /// + /// /// This will propagate and lift the new edge, thereby increasing the counter of the matching specified edge /// if it exists. - /// + /// /// Preconditions: ///
      ///
    • .Source is contained in the implementation graph.
    • @@ -67,9 +67,9 @@ public Edge AddToImplementation(Node from, Node to, string type) /// not in the implementation graph public void AddToImplementation(Edge edge) { - AssertOrThrow(ContainsNode(edge.Source) && edge.Source.IsInImplementation(), + AssertOrThrow(ContainsNode(edge.Source) && edge.Source.IsInImplementation(), () => new NotInSubgraphException(Implementation, edge.Source)); - AssertOrThrow(ContainsNode(edge.Target) && edge.Target.IsInImplementation(), + AssertOrThrow(ContainsNode(edge.Target) && edge.Target.IsInImplementation(), () => new NotInSubgraphException(Implementation, edge.Target)); edge.SetInImplementation(); SetState(edge, State.Undefined); @@ -143,7 +143,7 @@ public void RemoveFromImplementation(Edge edge) /// adjusting the reflexion analysis incrementally. /// This edge will be considered as a specified dependency. /// It may not be redundant. - /// + /// /// Preconditions: ///
        ///
      • is contained in the architecture graph.
      • @@ -169,7 +169,32 @@ public Edge AddToArchitecture(Node from, Node to, string type) return edge; } - public Edge ActuallyAddToArchitecture(Node from, Node to, string type) + /// + /// Creates an edge of given from the given node + /// to the given node and adds it to the architecture graph, + /// adjusting the reflexion analysis incrementally. + /// This edge will be considered as a specified dependency. + /// It may not be redundant. + /// It will also be non-virtual and be drawn immediatly. + /// + /// Preconditions: + ///
          + ///
        • is contained in the architecture graph.
        • + ///
        • is contained in the architecture graph.
        • + ///
        • The newly created specified edge will not be redundant.
        • + ///
        + /// Postcondition: A new edge from to is contained in the + /// architecture graph and the reflexion data is updated; all observers are informed of the change. + ///
        + /// source node of the new edge + /// target node of the new edge + /// type of the new edge + /// When or + /// is not contained in the architecture graph. + /// When the edge from to + /// would be redundant to another specified edge. + /// The newly created specified edge + public Edge AddToArchitectureNonVirtual(Node from, Node to, string type) { // Preconditions are checked in AddToArchitecture. Edge edge = AddEdge(from, to, type, false, false); @@ -180,10 +205,10 @@ public Edge ActuallyAddToArchitecture(Node from, Node to, string type) /// /// Adds the given to the implementation graph, /// adjusting the reflexion analysis incrementally. - /// + /// /// This will propagate and lift the new edge, thereby increasing the counter of the matching specified edge /// if it exists. - /// + /// /// Preconditions: ///
          ///
        • .Source is contained in the implementation graph.
        • @@ -195,9 +220,9 @@ public Edge ActuallyAddToArchitecture(Node from, Node to, string type) /// not in the implementation graph public void AddToArchitecture(Edge edge) { - AssertOrThrow(ContainsNode(edge.Source) && edge.Source.IsInArchitecture(), + AssertOrThrow(ContainsNode(edge.Source) && edge.Source.IsInArchitecture(), () => new NotInSubgraphException(Architecture, edge.Source)); - AssertOrThrow(ContainsNode(edge.Target) && edge.Target.IsInArchitecture(), + AssertOrThrow(ContainsNode(edge.Target) && edge.Target.IsInArchitecture(), () => new NotInSubgraphException(Architecture, edge.Target)); AssertNotRedundant(edge.Source, edge.Target, edge.Type); edge.SetInArchitecture(); @@ -422,7 +447,7 @@ public void AddToArchitecture(Node node) /// If is true, the children of /// become root nodes. Otherwise they become children of the parent of /// if there is a parent. - /// + /// /// Precondition: must be contained in the architecture graph. /// Postcondition: is no longer contained in the architecture graph and the reflexion /// data is updated; all observers are informed of the change. @@ -468,7 +493,7 @@ public void AddToImplementation(Node node) /// If is true, the children of /// become root nodes. Otherwise they become children of the parent of /// if there is a parent. - /// + /// /// Precondition: must be contained in the implementation graph. /// Postcondition: is no longer contained in the implementation graph and the reflexion /// data is updated; all observers are informed of the change. @@ -556,7 +581,7 @@ public void UnparentInImplementation(Node child) child.Reparent(null); if (formerTarget != null && !IsExplicitlyMapped(child)) { - // If child was implicitly mapped, this was due to parent, which means we now + // If child was implicitly mapped, this was due to parent, which means we now // have to revert that effect on child and its subtree. List subtree = MappedSubtree(child); Unmap(subtree, formerTarget); @@ -605,7 +630,7 @@ public void AddChildInArchitecture(Node child, Node parent) foreach (Edge outgoing in ascendant.Outgoings) { // We needn't check the "supertree", as we are already iterating over ascendants, hence - // we are setting that parameter to empty collections. + // we are setting that parameter to empty collections. // Since the only change in this operation will be the additional subtree rooted by `child`, // we only need to compare this outgoing edge by that subtree. AssertNotRedundant(outgoing.Source, outgoing.Target, outgoing.Type, @@ -616,7 +641,7 @@ public void AddChildInArchitecture(Node child, Node parent) foreach (Edge incoming in ascendant.Incomings) { // We needn't check the "supertree", as we are already iterating over ascendants, hence - // we are setting that parameter to empty collections. + // we are setting that parameter to empty collections. // Since the only change in this operation will be the additional subtree rooted by `child`, // we only need to compare this outgoing edge by that subtree. AssertNotRedundant(incoming.Source, incoming.Target, incoming.Type, @@ -702,7 +727,7 @@ public void UnparentInArchitecture(Node child) child.Reparent(null); } - + #region Helper /// @@ -762,7 +787,7 @@ private static PartitionedDependencies RefsInSubtree(Node root, Predicate return new PartitionedDependencies(oc, ic, i); } - + /// /// Returns all allowed propagated dependencies of the subtree rooted by . /// See for details. @@ -802,7 +827,7 @@ private void RemoveMapsTo(Edge mapsTo) List subtree = MappedSubtree(mapsTo.Source); Unmap(subtree, mapsTo.Target); Node implSourceParent = mapsTo.Source.Parent; - + if (implSourceParent == null) { // If mapsTo.Source has no parent, all nodes in subtree are not mapped at all any longer. @@ -1010,4 +1035,4 @@ private static void AssertOrThrow(bool condition, Func exception) #endregion } -} \ No newline at end of file +} From 4b7a95a28a2abe5f1874042345a69564510ed74b Mon Sep 17 00:00:00 2001 From: m4xxed Date: Wed, 9 Aug 2023 01:01:38 +0200 Subject: [PATCH 32/69] fix and / or add documentation --- Assets/SEE/Game/Evolution/EvolutionRenderer.cs | 5 +++++ Assets/SEE/Game/GameEdgeAdder.cs | 8 +++++++- .../Net/Actions/AcceptDivergenceNetAction.cs | 18 +++++++----------- .../ReflexionAnalysis/ReflexionAnalysis.cs | 6 ++---- 4 files changed, 21 insertions(+), 16 deletions(-) diff --git a/Assets/SEE/Game/Evolution/EvolutionRenderer.cs b/Assets/SEE/Game/Evolution/EvolutionRenderer.cs index c6cdac8c10..2483d4c4bb 100644 --- a/Assets/SEE/Game/Evolution/EvolutionRenderer.cs +++ b/Assets/SEE/Game/Evolution/EvolutionRenderer.cs @@ -932,6 +932,11 @@ public GameObject DrawNode(Node node, GameObject city = null) return Renderer.DrawNode(node, city); } + /// + /// Placeholder to satisfy the compiler. This method is not + /// called anywhere as of yet, but was required in . + /// public GameObject DrawEdge(Edge edge, GameObject source = null, GameObject target = null) { throw new NotImplementedException(); diff --git a/Assets/SEE/Game/GameEdgeAdder.cs b/Assets/SEE/Game/GameEdgeAdder.cs index 6aab65c051..f2273ba16f 100644 --- a/Assets/SEE/Game/GameEdgeAdder.cs +++ b/Assets/SEE/Game/GameEdgeAdder.cs @@ -54,7 +54,13 @@ public static GameObject Add(GameObject source, GameObject target, string edgeTy return result; } - // TODO Write docstring + /// + /// (Re)draws an edge in those cases where the + /// ReflexionAnalysis isn't run after adding it, and so it + /// will not be drawn before after the next change. + /// + /// the edge that should be (re)drawn + /// the GameObject of the drawn edge public static GameObject Draw(Edge edge) { GameObject source = GraphElementIDMap.Find(edge.Source.ID); diff --git a/Assets/SEE/Net/Actions/AcceptDivergenceNetAction.cs b/Assets/SEE/Net/Actions/AcceptDivergenceNetAction.cs index 2369abde40..3470dd2fee 100644 --- a/Assets/SEE/Net/Actions/AcceptDivergenceNetAction.cs +++ b/Assets/SEE/Net/Actions/AcceptDivergenceNetAction.cs @@ -9,26 +9,21 @@ namespace SEE.Net.Actions /// public class AcceptDivergenceNetAction : AbstractNetAction { - // Note: All attributes are made public so that they will be serialized - // for the network transfer. - /// - /// The id of the gameObject from which the edge should be drawn (source node). + /// The ID of the GameObject from which the edge should be drawn (source node). /// public string FromId; /// - /// The id of the gameObject to which the edge should be drawn (target node). + /// The ID of the GameObject to which the edge should be drawn (target node). /// public string ToId; /// /// Constructor. /// - /// unique ID of the parent in which to add the new node - /// id for the new node - /// the position for the new node - /// the scale of the new node in world space + /// ID of the source node of the edge + /// ID for target node of the edge public AcceptDivergenceNetAction(string fromId, string toId) : base() { @@ -37,8 +32,9 @@ public AcceptDivergenceNetAction(string fromId, string toId) } /// - /// Things to execute on the server (none for this class). Necessary because it is abstract - /// in the superclass. + /// Things to execute on the server (none for this + /// class). Necessary because it is abstract in the + /// superclass. /// protected override void ExecuteOnServer() { diff --git a/Assets/SEE/Tools/ReflexionAnalysis/ReflexionAnalysis.cs b/Assets/SEE/Tools/ReflexionAnalysis/ReflexionAnalysis.cs index a921435b2c..49df8ea612 100644 --- a/Assets/SEE/Tools/ReflexionAnalysis/ReflexionAnalysis.cs +++ b/Assets/SEE/Tools/ReflexionAnalysis/ReflexionAnalysis.cs @@ -209,15 +209,13 @@ public static bool IsSpecified(Edge edge) } /// - /// Returns true if is a specified edge in the architecture (has one of the - /// following states: specified, convergent, absent, allowed absent). + /// Returns true if is a divergent edge in the architecture. /// Precondition: must be in the architecture graph. /// /// architecture dependency - /// true if edge is a specified architecture dependency + /// true if edge is a divergent architecture dependency public static bool IsDivergent(Edge edge) { - // AssertOrThrow(edge.IsInArchitecture(), () => new NotInSubgraphException(Architecture, edge)); State state = edge.State(); return state == State.Divergent; } From bf8fbba33b0c90cf374bdb2c93355f9874a03ff1 Mon Sep 17 00:00:00 2001 From: m4xxed Date: Wed, 9 Aug 2023 17:35:39 +0200 Subject: [PATCH 33/69] passing GUID to clients to have matching GUID --- .../Net/Actions/AcceptDivergenceNetAction.cs | 31 +++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/Assets/SEE/Net/Actions/AcceptDivergenceNetAction.cs b/Assets/SEE/Net/Actions/AcceptDivergenceNetAction.cs index 3470dd2fee..3f96cd9eaa 100644 --- a/Assets/SEE/Net/Actions/AcceptDivergenceNetAction.cs +++ b/Assets/SEE/Net/Actions/AcceptDivergenceNetAction.cs @@ -1,5 +1,8 @@ +using SEE.DataModel.DG; using SEE.Game; using UnityEngine; +using SEE.GO; +using SEE.Tools.ReflexionAnalysis; namespace SEE.Net.Actions { @@ -19,16 +22,28 @@ public class AcceptDivergenceNetAction : AbstractNetAction /// public string ToId; + /// + /// The ID of the GameObject to which the edge should be drawn (target node). + /// + public string EdgeId; + + /// + /// The ID of the GameObject to which the edge should be drawn (target node). + /// + public string Type; + /// /// Constructor. /// /// ID of the source node of the edge /// ID for target node of the edge - public AcceptDivergenceNetAction(string fromId, string toId) + public AcceptDivergenceNetAction(string fromId, string toId, string edgeId, string type) : base() { FromId = fromId; ToId = toId; + EdgeId = edgeId; + Type = type; } /// @@ -54,7 +69,19 @@ protected override void ExecuteOnClient() GameObject toGO = GraphElementIDMap.Find(ToId); if (toGO) { - GameEdgeAdder.Add(fromGO, toGO, "Source_Dependency"); + fromGO.TryGetNode(out Node fromDM); + toGO.TryGetNode(out Node toDM); + + // create edge + var edgeToPropagate = new Edge(fromDM, toDM, Type); + edgeToPropagate.ID = EdgeId; + + // add the new edge to the architecture graph + if (fromDM.ItsGraph is ReflexionGraph graph) + graph.AddToArchitecture(edgeToPropagate); + + // add the new edge to the (game) + GameObject edgeGameObject = GameEdgeAdder.Draw(edgeToPropagate); } else { From 5d1d558b52ea9a8944f654c206764bf82153b497 Mon Sep 17 00:00:00 2001 From: m4xxed Date: Wed, 9 Aug 2023 17:55:34 +0200 Subject: [PATCH 34/69] corrected, appended and adjusted documentation --- .../Net/Actions/AcceptDivergenceNetAction.cs | 32 ++++++++++++------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/Assets/SEE/Net/Actions/AcceptDivergenceNetAction.cs b/Assets/SEE/Net/Actions/AcceptDivergenceNetAction.cs index 3f96cd9eaa..3a10fca67d 100644 --- a/Assets/SEE/Net/Actions/AcceptDivergenceNetAction.cs +++ b/Assets/SEE/Net/Actions/AcceptDivergenceNetAction.cs @@ -7,36 +7,42 @@ namespace SEE.Net.Actions { /// - /// This class is responsible for adding a node via network from one client to all others and - /// to the server. + /// This class is responsible for adding a node via network from + /// one client to all others and to the server. /// public class AcceptDivergenceNetAction : AbstractNetAction { /// - /// The ID of the GameObject from which the edge should be drawn (source node). + /// The ID of the GameObject from which the edge should be + /// drawn (source node). /// public string FromId; /// - /// The ID of the GameObject to which the edge should be drawn (target node). + /// The ID of the GameObject to which the edge should be drawn + /// (target node). /// public string ToId; /// - /// The ID of the GameObject to which the edge should be drawn (target node). + /// The ID of the server-based edge to ensure they match + /// between server and clients. /// public string EdgeId; /// - /// The ID of the GameObject to which the edge should be drawn (target node). + /// The type of the edge that should be created in order to + /// solve the divergence. /// public string Type; /// /// Constructor. /// - /// ID of the source node of the edge - /// ID for target node of the edge + /// ID of the source node of the edge + /// ID for target node of the edge + /// ID of the edge to be propagated to the clients + /// the type of the created edge public AcceptDivergenceNetAction(string fromId, string toId, string edgeId, string type) : base() { @@ -72,15 +78,17 @@ protected override void ExecuteOnClient() fromGO.TryGetNode(out Node fromDM); toGO.TryGetNode(out Node toDM); - // create edge - var edgeToPropagate = new Edge(fromDM, toDM, Type); + // create the edge beforehand (to change its ID) + Edge edgeToPropagate = new Edge(fromDM, toDM, Type); + + // change the edges ID before adding it to a graph edgeToPropagate.ID = EdgeId; - // add the new edge to the architecture graph + // add the already created edge to the architecture graph if (fromDM.ItsGraph is ReflexionGraph graph) graph.AddToArchitecture(edgeToPropagate); - // add the new edge to the (game) + // (re)draw the new edge GameObject edgeGameObject = GameEdgeAdder.Draw(edgeToPropagate); } else From 50665469f1fd98a84ac9bc46a93d95e98b4cddcd Mon Sep 17 00:00:00 2001 From: m4xxed Date: Wed, 9 Aug 2023 19:56:26 +0200 Subject: [PATCH 35/69] removed unused function (AddEdge(Edge) works better) --- .../Actions/AcceptDivergenceAction.cs | 87 +++++++++++-------- .../Tools/ReflexionAnalysis/Incremental.cs | 32 ------- 2 files changed, 49 insertions(+), 70 deletions(-) diff --git a/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs b/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs index 3ae53aa337..9ff9036642 100644 --- a/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs +++ b/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs @@ -60,14 +60,19 @@ private struct Memento /// public Node to; /// + /// The type of the edge. + /// + public string type; + /// /// Construct a new memento. /// /// the source node of the edge in the architecture graph /// the target node of the edge in the architecture grpah - public Memento(Node source, Node target) + public Memento(Node source, Node target, string type) { this.from = source; this.to = target; + this.type = type; } } @@ -83,7 +88,7 @@ public Memento(Node source, Node target) /// an Undo was called. The created edge is stored only to delete it again if Undo is /// called. All information to create the edge is kept in . ///
        - private Edge createdEdgeDataModel; + private Edge createdEdge; /// @@ -92,7 +97,7 @@ public Memento(Node source, Node target) /// delete it again if Undo is called. All information to create the edge is kept in . /// - private GameObject createdEdgeGameObject; + // private GameObject createdEdgeGameObject; /// @@ -162,15 +167,13 @@ public override bool Update() // we have both source and target of the edge and use a memento struct // to remember which edge we have added - memento = new Memento(source, target); + memento = new Memento(source, target, "Source_Dependency"); - // the Edge in the DataModel and it's GameObject are created separately - var createdEdgeParts = CreateEdge(memento); - createdEdgeDataModel = createdEdgeParts.edgeDataModel; - createdEdgeGameObject = createdEdgeParts.edgeGameObject; + // create the edge + createdEdge = CreateEdge(memento); // check whether edge creation was successfull - result = (createdEdgeDataModel != null && createdEdgeGameObject != null); + result = createdEdge != null; // add audio cue to the appearance of the new architecture edge AudioManagerImpl.EnqueueSoundEffect(IAudioManager.SoundEffect.NEW_EDGE_SOUND); @@ -199,23 +202,30 @@ public override void Undo() base.Undo(); // remove the synced edge (its info is saved in memento) - var graph = (ReflexionGraph)createdEdgeDataModel.ItsGraph; + ReflexionGraph graph = (ReflexionGraph)createdEdge.ItsGraph; if (graph != null) { + // find the corresponding GameObject + GameObject createdEdgeGO = GraphElementIDMap.Find(createdEdge.ID); // remove the edge's GameObject and graph representation locally and on the network - GameEdgeAdder.Remove(createdEdgeGameObject); - new DeleteNetAction(createdEdgeGameObject.name).Execute(); - Destroyer.Destroy(createdEdgeGameObject); + GameEdgeAdder.Remove(createdEdgeGO); + + // synthesize the remote ID ourselves + // string remoteID = createdEdge.Type + "#" + createdEdge.Source.ID + "#" + createdEdge.Target.ID; + new DeleteNetAction(createdEdge.ID).Execute(); + + // this way doesn't work - because fkin unique ID requirement + // new DeleteNetAction(createdEdgeGO.name).Execute(); + Destroyer.Destroy(createdEdgeGO); } else { - throw new Exception($"Edge {createdEdgeDataModel.ID} to be removed is not contained in a graph."); + throw new Exception($"Edge {createdEdge.ID} to be removed is not contained in a graph."); } // set any edge references back to null - createdEdgeDataModel = null; - createdEdgeGameObject = null; + createdEdge = null; } /// @@ -225,33 +235,31 @@ public override void Redo() { base.Redo(); // recreate the edge - var createdEdgeParts = CreateEdge(memento); - // save the references for later use - createdEdgeDataModel = createdEdgeParts.edgeDataModel; - createdEdgeGameObject = createdEdgeParts.edgeGameObject; + createdEdge = CreateEdge(memento); } /// - /// Creates a new edge using the given . In case of any error, - /// null will be returned. + /// Creates a new edge using the given . In case of any error, null will be + /// returned. /// /// information needed to create the edge /// the new edge's GameObject and a reference to itself, or both null - private (Edge edgeDataModel, GameObject edgeGameObject) CreateEdge(Memento memento) + private Edge CreateEdge(Memento memento) { - // add the new edge to the architecture graph - var edgeDataModel = graph.AddToArchitectureNonVirtual( - memento.from, - memento.to, - "Source_Dependency"); + // create the edge beforehand + Edge newEdge = new Edge(memento.from, memento.to, memento.type); + + // add the already created edge to the architecture graph + graph.AddToArchitecture(newEdge); - // add the new edge to the (game) - GameObject edgeGameObject = GameEdgeAdder.Draw(edgeDataModel); + // (re)draw the new edge + GameEdgeAdder.Draw(newEdge); - // sync the solution of the divergence via network - new AcceptDivergenceNetAction(memento.from.SourceName, memento.to.SourceName).Execute(); + // propagate the edge (including matching ID) over network + new AcceptDivergenceNetAction(memento.from.ID, memento.to.ID, newEdge.ID, newEdge.Type).Execute(); - return (edgeDataModel, edgeGameObject); + return newEdge; } /// @@ -269,7 +277,7 @@ public override ActionStateType GetActionStateType() /// all IDs of GameObjects manipulated by this action public override HashSet GetChangedObjects() { - if (createdEdgeDataModel == null | createdEdgeGameObject == null) + if (createdEdge == null) { return new HashSet(); } @@ -277,10 +285,13 @@ public override HashSet GetChangedObjects() { return new HashSet { - memento.from.ID, - memento.to.ID, - createdEdgeDataModel.ID, - createdEdgeGameObject.name }; + GraphElementIDMap.Find(memento.from.ID).name, + // memento.from.ID, + GraphElementIDMap.Find(memento.to.ID).name, + // memento.to.ID, + // createdEdgeDataModel.ID, + GraphElementIDMap.Find(createdEdge.ID).name, + }; } } } diff --git a/Assets/SEE/Tools/ReflexionAnalysis/Incremental.cs b/Assets/SEE/Tools/ReflexionAnalysis/Incremental.cs index 8f0da39a76..045157c2bb 100644 --- a/Assets/SEE/Tools/ReflexionAnalysis/Incremental.cs +++ b/Assets/SEE/Tools/ReflexionAnalysis/Incremental.cs @@ -169,38 +169,6 @@ public Edge AddToArchitecture(Node from, Node to, string type) return edge; } - /// - /// Creates an edge of given from the given node - /// to the given node and adds it to the architecture graph, - /// adjusting the reflexion analysis incrementally. - /// This edge will be considered as a specified dependency. - /// It may not be redundant. - /// It will also be non-virtual and be drawn immediatly. - /// - /// Preconditions: - ///
          - ///
        • is contained in the architecture graph.
        • - ///
        • is contained in the architecture graph.
        • - ///
        • The newly created specified edge will not be redundant.
        • - ///
        - /// Postcondition: A new edge from to is contained in the - /// architecture graph and the reflexion data is updated; all observers are informed of the change. - ///
        - /// source node of the new edge - /// target node of the new edge - /// type of the new edge - /// When or - /// is not contained in the architecture graph. - /// When the edge from to - /// would be redundant to another specified edge. - /// The newly created specified edge - public Edge AddToArchitectureNonVirtual(Node from, Node to, string type) - { - // Preconditions are checked in AddToArchitecture. - Edge edge = AddEdge(from, to, type, false, false); - AddToArchitecture(edge); - return edge; - } /// /// Adds the given to the implementation graph, From b352259fc053ae88d9aedcd02784405806b47f5d Mon Sep 17 00:00:00 2001 From: m4xxed Date: Wed, 9 Aug 2023 20:00:06 +0200 Subject: [PATCH 36/69] check whether both GameObject and Node can be found --- Assets/SEE/Net/Actions/AcceptDivergenceNetAction.cs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Assets/SEE/Net/Actions/AcceptDivergenceNetAction.cs b/Assets/SEE/Net/Actions/AcceptDivergenceNetAction.cs index 3a10fca67d..c7c692e9b5 100644 --- a/Assets/SEE/Net/Actions/AcceptDivergenceNetAction.cs +++ b/Assets/SEE/Net/Actions/AcceptDivergenceNetAction.cs @@ -70,22 +70,21 @@ protected override void ExecuteOnClient() if (!IsRequester()) { GameObject fromGO = GraphElementIDMap.Find(FromId); - if (fromGO) + fromGO.TryGetNode(out Node fromNode); + if (fromGO && fromNode) { GameObject toGO = GraphElementIDMap.Find(ToId); - if (toGO) + toGO.TryGetNode(out Node toNode); + if (toGO && toNode) { - fromGO.TryGetNode(out Node fromDM); - toGO.TryGetNode(out Node toDM); - // create the edge beforehand (to change its ID) - Edge edgeToPropagate = new Edge(fromDM, toDM, Type); + Edge edgeToPropagate = new Edge(fromNode, toNode, Type); // change the edges ID before adding it to a graph edgeToPropagate.ID = EdgeId; // add the already created edge to the architecture graph - if (fromDM.ItsGraph is ReflexionGraph graph) + if (fromNode.ItsGraph is ReflexionGraph graph) graph.AddToArchitecture(edgeToPropagate); // (re)draw the new edge From 36ac009fce5d0780346ba54a6d8f942a182ebcaa Mon Sep 17 00:00:00 2001 From: m4xxed Date: Wed, 9 Aug 2023 23:11:45 +0200 Subject: [PATCH 37/69] improve documentation --- Assets/SEE/Net/Actions/AcceptDivergenceNetAction.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Assets/SEE/Net/Actions/AcceptDivergenceNetAction.cs b/Assets/SEE/Net/Actions/AcceptDivergenceNetAction.cs index c7c692e9b5..e7a41eec40 100644 --- a/Assets/SEE/Net/Actions/AcceptDivergenceNetAction.cs +++ b/Assets/SEE/Net/Actions/AcceptDivergenceNetAction.cs @@ -13,19 +13,19 @@ namespace SEE.Net.Actions public class AcceptDivergenceNetAction : AbstractNetAction { /// - /// The ID of the GameObject from which the edge should be + /// The ID of the Node's GameObject from which the edge should be /// drawn (source node). /// public string FromId; /// - /// The ID of the GameObject to which the edge should be drawn + /// The ID of the Node's GameObject to which the edge should be drawn /// (target node). /// public string ToId; /// - /// The ID of the server-based edge to ensure they match + /// The ID of the server's edge to ensure they match /// between server and clients. /// public string EdgeId; From ce1fd9f4ee5e94ef55070ed343df1dd18fa3fc32 Mon Sep 17 00:00:00 2001 From: Max Julian Herrmann Date: Fri, 11 Aug 2023 19:40:37 +0200 Subject: [PATCH 38/69] remove extraneous newlines and dead code autoformatting for those extraneous newlines would be super neat here, right? :grin: --- .../Controls/Actions/AcceptDivergenceAction.cs | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs b/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs index 9ff9036642..973cb0884d 100644 --- a/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs +++ b/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs @@ -27,7 +27,6 @@ public static ReversibleAction CreateReversibleAction() return new AcceptDivergenceAction(); } - /// /// Returns a new instance of as a . @@ -38,7 +37,6 @@ public override ReversibleAction NewInstance() return CreateReversibleAction(); } - /// /// The graph that the edge which was hit by the user to be accepted into the graph is /// in. Set in . @@ -76,13 +74,11 @@ public Memento(Node source, Node target, string type) } } - /// /// The information required to (re-)create the edge that solves the divergence. /// private Memento memento; - /// /// The edge created by this action. Can be null if no edge has been created yet or whether /// an Undo was called. The created edge is stored only to delete it again if Undo is @@ -90,16 +86,6 @@ public Memento(Node source, Node target, string type) /// private Edge createdEdge; - - /// - /// The edge created by this action's GameObject representation. Can be null if no edge has - /// been created yet or whether an Undo was called. The created edge is stored only to - /// delete it again if Undo is called. All information to create the edge is kept in . - /// - // private GameObject createdEdgeGameObject; - - /// /// Registers itself at to listen for hovering events. /// @@ -109,7 +95,6 @@ public override void Start() InteractableObject.LocalAnyHoverOut += LocalAnyHoverOut; } - /// /// Unregisters itself from . Does no longer listen for /// hovering events. @@ -120,13 +105,11 @@ public override void Stop() InteractableObject.LocalAnyHoverOut -= LocalAnyHoverOut; } - /// /// The default type of an added edge. /// private const string DefaultEdgeType = "Source_Dependency"; - /// /// See . /// From 362f28edde04f67bc59bbe6b060b99ab6fd3c455 Mon Sep 17 00:00:00 2001 From: Max Julian Herrmann Date: Fri, 11 Aug 2023 19:53:01 +0200 Subject: [PATCH 39/69] add assertion, that the new edge is actually in architecture for consistency, I'd commit anything! Co-authored-by: Falko <10247603+falko17@users.noreply.github.com> --- Assets/SEE/Tools/ReflexionAnalysis/ReflexionAnalysis.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Assets/SEE/Tools/ReflexionAnalysis/ReflexionAnalysis.cs b/Assets/SEE/Tools/ReflexionAnalysis/ReflexionAnalysis.cs index 49df8ea612..b3438fc08f 100644 --- a/Assets/SEE/Tools/ReflexionAnalysis/ReflexionAnalysis.cs +++ b/Assets/SEE/Tools/ReflexionAnalysis/ReflexionAnalysis.cs @@ -216,8 +216,8 @@ public static bool IsSpecified(Edge edge) /// true if edge is a divergent architecture dependency public static bool IsDivergent(Edge edge) { - State state = edge.State(); - return state == State.Divergent; + AssertOrThrow(edge.IsInArchitecture(), () => new NotInSubgraphException(Architecture, edge)); + return edge.State() == State.Divergent; } #endregion From f8579f0e2e1bc2809c9d4a358b3e7e36fbee88f9 Mon Sep 17 00:00:00 2001 From: Max Julian Herrmann Date: Fri, 11 Aug 2023 19:54:34 +0200 Subject: [PATCH 40/69] ensure edge is in archticture to avoid exceptions Co-authored-by: Falko <10247603+falko17@users.noreply.github.com> --- Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs b/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs index 973cb0884d..2e42e27f38 100644 --- a/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs +++ b/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs @@ -132,7 +132,7 @@ public override bool Update() if (selectedDivergenceEdge.TryGetEdge(out Edge selectedEdge)) { // check if the selected edge represents a divergence - if (ReflexionGraph.IsDivergent(selectedEdge)) + if (selectedEdge.IsInArchitecture() && ReflexionGraph.IsDivergent(selectedEdge)) { // acquire the containing ReflexionGraph From abc12dc0ff97ac0880683cbc4f1cab9ba1258115 Mon Sep 17 00:00:00 2001 From: m4xxed Date: Fri, 11 Aug 2023 19:42:53 +0200 Subject: [PATCH 41/69] renamed variable to be more descriptive --- Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs b/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs index 2e42e27f38..a9a6f4d44d 100644 --- a/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs +++ b/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs @@ -117,7 +117,7 @@ public override void Stop() public override bool Update() { // indicates whether the divergence has been solved ("true" means "solved") - bool result = false; + bool divergenceSolved = false; // FIXME: Needs adaptation for VR where no mouse is available. if (Input.GetMouseButtonDown(0) @@ -156,14 +156,14 @@ public override bool Update() createdEdge = CreateEdge(memento); // check whether edge creation was successfull - result = createdEdge != null; + divergenceSolved = createdEdge != null; // add audio cue to the appearance of the new architecture edge AudioManagerImpl.EnqueueSoundEffect(IAudioManager.SoundEffect.NEW_EDGE_SOUND); // update the current state depending on whether the divergence has been solved // (required in order to register as an undo-able action) - currentState = result ? ReversibleAction.Progress.Completed : ReversibleAction.Progress.NoEffect; + currentState = divergenceSolved ? ReversibleAction.Progress.Completed : ReversibleAction.Progress.NoEffect; // the selected object is synced and this action is done return true; From 75139944634269ce5880d765afbc306992ddd734 Mon Sep 17 00:00:00 2001 From: m4xxed Date: Fri, 11 Aug 2023 19:44:31 +0200 Subject: [PATCH 42/69] remove old comments and add missing documentation --- Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs b/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs index a9a6f4d44d..e035326ca6 100644 --- a/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs +++ b/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs @@ -194,8 +194,7 @@ public override void Undo() // remove the edge's GameObject and graph representation locally and on the network GameEdgeAdder.Remove(createdEdgeGO); - // synthesize the remote ID ourselves - // string remoteID = createdEdge.Type + "#" + createdEdge.Source.ID + "#" + createdEdge.Target.ID; + // propagate the new edge via network new DeleteNetAction(createdEdge.ID).Execute(); // this way doesn't work - because fkin unique ID requirement From eaa02b2d91897630e0f2a48b613b12b735166c6f Mon Sep 17 00:00:00 2001 From: m4xxed Date: Fri, 11 Aug 2023 19:46:00 +0200 Subject: [PATCH 43/69] remove comment that should've been removed before commit --- Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs b/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs index e035326ca6..0ca8237d28 100644 --- a/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs +++ b/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs @@ -197,8 +197,7 @@ public override void Undo() // propagate the new edge via network new DeleteNetAction(createdEdge.ID).Execute(); - // this way doesn't work - because fkin unique ID requirement - // new DeleteNetAction(createdEdgeGO.name).Execute(); + // ensure the edge's GameObject gets destroyed properly Destroyer.Destroy(createdEdgeGO); } else From 7e3cb0a48cda5b95c9e297ed384f67843a0e830c Mon Sep 17 00:00:00 2001 From: m4xxed Date: Fri, 11 Aug 2023 19:54:44 +0200 Subject: [PATCH 44/69] add "missing" braces --- Assets/SEE/Net/Actions/AcceptDivergenceNetAction.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Assets/SEE/Net/Actions/AcceptDivergenceNetAction.cs b/Assets/SEE/Net/Actions/AcceptDivergenceNetAction.cs index e7a41eec40..d205eba06b 100644 --- a/Assets/SEE/Net/Actions/AcceptDivergenceNetAction.cs +++ b/Assets/SEE/Net/Actions/AcceptDivergenceNetAction.cs @@ -85,7 +85,9 @@ protected override void ExecuteOnClient() // add the already created edge to the architecture graph if (fromNode.ItsGraph is ReflexionGraph graph) + { graph.AddToArchitecture(edgeToPropagate); + } // (re)draw the new edge GameObject edgeGameObject = GameEdgeAdder.Draw(edgeToPropagate); From aa14af6d99471573187d22bb88535e595612c268 Mon Sep 17 00:00:00 2001 From: m4xxed Date: Fri, 11 Aug 2023 19:54:58 +0200 Subject: [PATCH 45/69] refactor code to make it look smoother --- Assets/SEE/Net/Actions/AcceptDivergenceNetAction.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Assets/SEE/Net/Actions/AcceptDivergenceNetAction.cs b/Assets/SEE/Net/Actions/AcceptDivergenceNetAction.cs index d205eba06b..838bd9eb8d 100644 --- a/Assets/SEE/Net/Actions/AcceptDivergenceNetAction.cs +++ b/Assets/SEE/Net/Actions/AcceptDivergenceNetAction.cs @@ -70,12 +70,10 @@ protected override void ExecuteOnClient() if (!IsRequester()) { GameObject fromGO = GraphElementIDMap.Find(FromId); - fromGO.TryGetNode(out Node fromNode); - if (fromGO && fromNode) + if (fromGO && fromGO.TryGetNode(out Node fromNode)) { GameObject toGO = GraphElementIDMap.Find(ToId); - toGO.TryGetNode(out Node toNode); - if (toGO && toNode) + if (toGO && toGO.TryGetNode(out Node toNode)) { // create the edge beforehand (to change its ID) Edge edgeToPropagate = new Edge(fromNode, toNode, Type); From 8d572025e4bc9c9e8924e310e3259eb1c82d2f4a Mon Sep 17 00:00:00 2001 From: m4xxed Date: Fri, 11 Aug 2023 20:30:36 +0200 Subject: [PATCH 46/69] remove unneccessary lookups --- Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs b/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs index 0ca8237d28..c60bc25e56 100644 --- a/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs +++ b/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs @@ -266,12 +266,9 @@ public override HashSet GetChangedObjects() { return new HashSet { - GraphElementIDMap.Find(memento.from.ID).name, - // memento.from.ID, - GraphElementIDMap.Find(memento.to.ID).name, - // memento.to.ID, - // createdEdgeDataModel.ID, - GraphElementIDMap.Find(createdEdge.ID).name, + memento.from.ID, + memento.to.ID, + createdEdge.ID }; } } From ba361ff44445a023dfcdbda7040642dcabfdd8c3 Mon Sep 17 00:00:00 2001 From: Max Julian Herrmann Date: Fri, 11 Aug 2023 20:40:14 +0200 Subject: [PATCH 47/69] update documentation Co-authored-by: Falko <10247603+falko17@users.noreply.github.com> --- Assets/SEE/Game/IGraphRenderer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Assets/SEE/Game/IGraphRenderer.cs b/Assets/SEE/Game/IGraphRenderer.cs index eb696337e4..9b3efe7b0a 100644 --- a/Assets/SEE/Game/IGraphRenderer.cs +++ b/Assets/SEE/Game/IGraphRenderer.cs @@ -41,8 +41,8 @@ public interface IGraphRenderer /// Note: The default edge layout will be used if no edge layout, /// i.e., , was chosen in the settings. /// - /// Precondition: and must have a valid - /// node reference. The corresponding graph nodes must be in the same graph. + /// Precondition: and must either have a valid + /// node reference or be null. The corresponding graph nodes must be in the same graph. /// /// the edge to be drawn /// GameObject of source of the new edge From 1ffa907b0762bf8a4c2e9ae58906e826aed2b25c Mon Sep 17 00:00:00 2001 From: m4xxed Date: Fri, 11 Aug 2023 20:33:04 +0200 Subject: [PATCH 48/69] simplify documentation --- Assets/SEE/Game/GameEdgeAdder.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Assets/SEE/Game/GameEdgeAdder.cs b/Assets/SEE/Game/GameEdgeAdder.cs index f2273ba16f..6bf291cc9a 100644 --- a/Assets/SEE/Game/GameEdgeAdder.cs +++ b/Assets/SEE/Game/GameEdgeAdder.cs @@ -55,9 +55,7 @@ public static GameObject Add(GameObject source, GameObject target, string edgeTy } /// - /// (Re)draws an edge in those cases where the - /// ReflexionAnalysis isn't run after adding it, and so it - /// will not be drawn before after the next change. + /// Simply (re)draws an edge. /// /// the edge that should be (re)drawn /// the GameObject of the drawn edge From 375f2fe39b8cefa640e4d8e4fa9122be53a16649 Mon Sep 17 00:00:00 2001 From: m4xxed Date: Fri, 11 Aug 2023 20:41:32 +0200 Subject: [PATCH 49/69] update documentation --- Assets/SEE/Net/Actions/AcceptDivergenceNetAction.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Assets/SEE/Net/Actions/AcceptDivergenceNetAction.cs b/Assets/SEE/Net/Actions/AcceptDivergenceNetAction.cs index 838bd9eb8d..364b7fc838 100644 --- a/Assets/SEE/Net/Actions/AcceptDivergenceNetAction.cs +++ b/Assets/SEE/Net/Actions/AcceptDivergenceNetAction.cs @@ -7,8 +7,9 @@ namespace SEE.Net.Actions { /// - /// This class is responsible for adding a node via network from - /// one client to all others and to the server. + /// This class is responsible for adding a specific edge via + /// network from one client to all others and to the server, in + /// order to solve an occuring divergence. /// public class AcceptDivergenceNetAction : AbstractNetAction { From 6e099faa19a6a6cada6f16cab01a98ffa5c18d6f Mon Sep 17 00:00:00 2001 From: m4xxed Date: Fri, 11 Aug 2023 22:35:02 +0200 Subject: [PATCH 50/69] remove variable and nesting complexity --- Assets/SEE/Game/GameEdgeAdder.cs | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/Assets/SEE/Game/GameEdgeAdder.cs b/Assets/SEE/Game/GameEdgeAdder.cs index 6bf291cc9a..d74ea654d8 100644 --- a/Assets/SEE/Game/GameEdgeAdder.cs +++ b/Assets/SEE/Game/GameEdgeAdder.cs @@ -63,23 +63,18 @@ public static GameObject Draw(Edge edge) { GameObject source = GraphElementIDMap.Find(edge.Source.ID); Transform cityObject = SceneQueries.GetCodeCity(source.transform); - GameObject result; - if (cityObject != null) + + if (!cityObject) { - if (cityObject.TryGetComponent(out AbstractSEECity city)) - { - result = city.Renderer.DrawEdge(edge, source: source); - } - else - { - throw new Exception($"The code city for the new edge {edge.ToShortString()} cannot be determined.\n"); - } + throw new Exception($"The code city for the new edge {edge.ToShortString()} cannot be determined.\n"); } - else + + if (!cityObject.TryGetComponent(out AbstractSEECity city)) { throw new Exception($"Could not determine the code city for the new edge {edge.ToShortString()}.\n"); } - return result; + + return city.Renderer.DrawEdge(edge, source: source); } /// From 00a5e648aa520918ff8f131408d8e958d4e01020 Mon Sep 17 00:00:00 2001 From: Max Julian Herrmann Date: Fri, 11 Aug 2023 22:39:32 +0200 Subject: [PATCH 51/69] remove redundancy in documentation Co-authored-by: Falko <10247603+falko17@users.noreply.github.com> --- Assets/SEE/Net/Actions/AcceptDivergenceNetAction.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Assets/SEE/Net/Actions/AcceptDivergenceNetAction.cs b/Assets/SEE/Net/Actions/AcceptDivergenceNetAction.cs index 364b7fc838..666a19a0a7 100644 --- a/Assets/SEE/Net/Actions/AcceptDivergenceNetAction.cs +++ b/Assets/SEE/Net/Actions/AcceptDivergenceNetAction.cs @@ -9,7 +9,7 @@ namespace SEE.Net.Actions /// /// This class is responsible for adding a specific edge via /// network from one client to all others and to the server, in - /// order to solve an occuring divergence. + /// order to solve a divergence. /// public class AcceptDivergenceNetAction : AbstractNetAction { From f2ac554003d72cf4568fc833aa3befa25842dc1c Mon Sep 17 00:00:00 2001 From: m4xxed Date: Fri, 11 Aug 2023 23:24:24 +0200 Subject: [PATCH 52/69] fixed checking in wrong graph --- Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs b/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs index c60bc25e56..44f8760091 100644 --- a/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs +++ b/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs @@ -132,9 +132,8 @@ public override bool Update() if (selectedDivergenceEdge.TryGetEdge(out Edge selectedEdge)) { // check if the selected edge represents a divergence - if (selectedEdge.IsInArchitecture() && ReflexionGraph.IsDivergent(selectedEdge)) + if (selectedEdge.IsInImplementation() && ReflexionGraph.IsDivergent(selectedEdge)) { - // acquire the containing ReflexionGraph graph = (ReflexionGraph)selectedEdge.ItsGraph; From ad2429ce9d3562f53236d9ae3b196fa660866f1a Mon Sep 17 00:00:00 2001 From: m4xxed Date: Fri, 11 Aug 2023 23:29:05 +0200 Subject: [PATCH 53/69] fixed check for wrong graph --- Assets/SEE/Tools/ReflexionAnalysis/ReflexionAnalysis.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Assets/SEE/Tools/ReflexionAnalysis/ReflexionAnalysis.cs b/Assets/SEE/Tools/ReflexionAnalysis/ReflexionAnalysis.cs index b3438fc08f..f5e0055f82 100644 --- a/Assets/SEE/Tools/ReflexionAnalysis/ReflexionAnalysis.cs +++ b/Assets/SEE/Tools/ReflexionAnalysis/ReflexionAnalysis.cs @@ -216,7 +216,7 @@ public static bool IsSpecified(Edge edge) /// true if edge is a divergent architecture dependency public static bool IsDivergent(Edge edge) { - AssertOrThrow(edge.IsInArchitecture(), () => new NotInSubgraphException(Architecture, edge)); + AssertOrThrow(edge.IsInImplementation(), () => new NotInSubgraphException(Implementation, edge)); return edge.State() == State.Divergent; } #endregion From 0f93c7f92b2dcd302e87711fec823adbad49e4e6 Mon Sep 17 00:00:00 2001 From: m4xxed Date: Sun, 13 Aug 2023 10:55:12 +0200 Subject: [PATCH 54/69] fixed documentation --- Assets/SEE/Tools/ReflexionAnalysis/ReflexionAnalysis.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Assets/SEE/Tools/ReflexionAnalysis/ReflexionAnalysis.cs b/Assets/SEE/Tools/ReflexionAnalysis/ReflexionAnalysis.cs index f5e0055f82..dfc2194d1e 100644 --- a/Assets/SEE/Tools/ReflexionAnalysis/ReflexionAnalysis.cs +++ b/Assets/SEE/Tools/ReflexionAnalysis/ReflexionAnalysis.cs @@ -209,7 +209,9 @@ public static bool IsSpecified(Edge edge) } /// - /// Returns true if is a divergent edge in the architecture. + /// Returns true if is a divergent + /// edge (present in the implementation graph, but missing in + /// the architecture graph). /// Precondition: must be in the architecture graph. /// /// architecture dependency From 08bd443f9dc24630cab6e06fe5af03391451b9f1 Mon Sep 17 00:00:00 2001 From: Rainer Koschke Date: Wed, 16 Aug 2023 17:50:24 +0200 Subject: [PATCH 55/69] #599 Fixed copy&paste error in documentation. --- Assets/SEE/Tools/ReflexionAnalysis/ReflexionAnalysis.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Assets/SEE/Tools/ReflexionAnalysis/ReflexionAnalysis.cs b/Assets/SEE/Tools/ReflexionAnalysis/ReflexionAnalysis.cs index dfc2194d1e..4e4b9ba90a 100644 --- a/Assets/SEE/Tools/ReflexionAnalysis/ReflexionAnalysis.cs +++ b/Assets/SEE/Tools/ReflexionAnalysis/ReflexionAnalysis.cs @@ -212,7 +212,7 @@ public static bool IsSpecified(Edge edge) /// Returns true if is a divergent /// edge (present in the implementation graph, but missing in /// the architecture graph). - /// Precondition: must be in the architecture graph. + /// Precondition: must be in the implementation graph. /// /// architecture dependency /// true if edge is a divergent architecture dependency From abac9635a73ffdc5b5559dbf797cb7119f4a8d57 Mon Sep 17 00:00:00 2001 From: Rainer Koschke Date: Wed, 16 Aug 2023 17:50:55 +0200 Subject: [PATCH 56/69] #599 GlobalHistoryEntry can be readonly. --- Assets/SEE/Utils/ActionHistory.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Assets/SEE/Utils/ActionHistory.cs b/Assets/SEE/Utils/ActionHistory.cs index 9d087821d9..728cadee04 100644 --- a/Assets/SEE/Utils/ActionHistory.cs +++ b/Assets/SEE/Utils/ActionHistory.cs @@ -68,7 +68,7 @@ public class ActionHistory /// /// An entry describing an executed action in the global action history. /// - public struct GlobalHistoryEntry + public readonly struct GlobalHistoryEntry { /// /// Represents an entry in the globalHistory. From 9f2f3587f6bb323c64461d274ca1b4ba0f1d6ae4 Mon Sep 17 00:00:00 2001 From: Rainer Koschke Date: Wed, 16 Aug 2023 17:51:37 +0200 Subject: [PATCH 57/69] #599 Replaced magic strings by edge-type declarations in Edge. --- .../Actions/AcceptDivergenceAction.cs | 8 +------ Assets/SEE/Controls/Actions/AddEdgeAction.cs | 2 +- Assets/SEE/DataModel/DG/Edge.cs | 22 +++++++++++++++++++ Assets/SEE/Game/ArchitectureInteraction.cs | 21 ++++++++++-------- 4 files changed, 36 insertions(+), 17 deletions(-) diff --git a/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs b/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs index 44f8760091..a0df4c7bee 100644 --- a/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs +++ b/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs @@ -43,7 +43,6 @@ public override ReversibleAction NewInstance() /// private ReflexionGraph graph; - /// /// The information required to (re-)create the edge that solves the divergence. /// @@ -105,11 +104,6 @@ public override void Stop() InteractableObject.LocalAnyHoverOut -= LocalAnyHoverOut; } - /// - /// The default type of an added edge. - /// - private const string DefaultEdgeType = "Source_Dependency"; - /// /// See . /// @@ -149,7 +143,7 @@ public override bool Update() // we have both source and target of the edge and use a memento struct // to remember which edge we have added - memento = new Memento(source, target, "Source_Dependency"); + memento = new Memento(source, target, Edge.SourceDependency); // create the edge createdEdge = CreateEdge(memento); diff --git a/Assets/SEE/Controls/Actions/AddEdgeAction.cs b/Assets/SEE/Controls/Actions/AddEdgeAction.cs index 4bf2a0bf7b..4c5bea638a 100644 --- a/Assets/SEE/Controls/Actions/AddEdgeAction.cs +++ b/Assets/SEE/Controls/Actions/AddEdgeAction.cs @@ -121,7 +121,7 @@ public override void Stop() /// /// The default type of an added edge. /// - private const string DefaultEdgeType = "Source_Dependency"; + private const string DefaultEdgeType = Edge.SourceDependency; /// /// . diff --git a/Assets/SEE/DataModel/DG/Edge.cs b/Assets/SEE/DataModel/DG/Edge.cs index 29b393d3c0..81f16b7362 100644 --- a/Assets/SEE/DataModel/DG/Edge.cs +++ b/Assets/SEE/DataModel/DG/Edge.cs @@ -7,6 +7,28 @@ namespace SEE.DataModel.DG /// public sealed class Edge : GraphElement { + /// + /// The most general edge type for all dependencies extracted from the code. + /// This name must correspond to Axivion's nomenclatura. + /// + public const string SourceDependency = "Source_Dependency"; + + /// + /// Edge type for absences (reflexion analysis). + /// This name must correspond to Axivion's nomenclatura. + /// + public const string Absence = "Absence"; + /// + /// Edge type for convergences (reflexion analysis). + /// This name must correspond to Axivion's nomenclatura. + /// + public const string Convergence = "Convergence"; + /// + /// Edge type for divergences (reflexion analysis). + /// This name must correspond to Axivion's nomenclatura. + /// + public const string Divergence = "Divergence"; + // IMPORTANT NOTES: // // If you use Clone() to create a copy of an edge, be aware that the clone diff --git a/Assets/SEE/Game/ArchitectureInteraction.cs b/Assets/SEE/Game/ArchitectureInteraction.cs index dac81784d5..756b663dab 100644 --- a/Assets/SEE/Game/ArchitectureInteraction.cs +++ b/Assets/SEE/Game/ArchitectureInteraction.cs @@ -29,24 +29,27 @@ public class ArchitectureInteraction : MonoBehaviour /// /// Edge types generated by the reflexion analysis. /// - public static readonly HashSet ReflexionEdgeTypes = new HashSet() + public static readonly HashSet ReflexionEdgeTypes = new() { - "Absence", - "Convergence", - "Divergence", + Edge.Absence, + Edge.Convergence, + Edge.Divergence, }; /// /// Edge types representing implementation dependencies. /// - public static readonly HashSet ArchitectureEdgeTypes = new HashSet() + public static readonly HashSet ArchitectureEdgeTypes = new() { - "Source_Dependency", + Edge.SourceDependency, }; - public static readonly HashSet AllEdgeTypes = new HashSet(); + public static readonly HashSet AllEdgeTypes = new(); - private HashSet implementationEdgeTypes = new HashSet(); + /// + /// See property . + /// + private HashSet implementationEdgeTypes = new(); /// /// All edge types in the graph that are neither reflexion edges /// nor architecture dependencies. @@ -60,7 +63,7 @@ public HashSet ImplementationEdgeTypes implementationEdgeTypes = GetImplementationEdgeTypes(); foreach (string type in implementationEdgeTypes) { - Debug.LogFormat("implementation edge type {0}\n", type); + Debug.Log($"implementation edge type {type}\n"); } } return implementationEdgeTypes; From 1e09e7c0ebb8b3ef045ce4edef364b365c412fd3 Mon Sep 17 00:00:00 2001 From: Rainer Koschke Date: Wed, 16 Aug 2023 17:56:25 +0200 Subject: [PATCH 58/69] #599 Simplified new operator. --- Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs b/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs index a0df4c7bee..f6f9eae910 100644 --- a/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs +++ b/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs @@ -222,7 +222,7 @@ public override void Redo() private Edge CreateEdge(Memento memento) { // create the edge beforehand - Edge newEdge = new Edge(memento.from, memento.to, memento.type); + Edge newEdge = new(memento.from, memento.to, memento.type); // add the already created edge to the architecture graph graph.AddToArchitecture(newEdge); From c41791978ff910afafcc2f57f15c3563277b9db6 Mon Sep 17 00:00:00 2001 From: Rainer Koschke Date: Wed, 16 Aug 2023 18:01:55 +0200 Subject: [PATCH 59/69] #599 Architecture does not need to be capitalized. --- Assets/SEE/Controls/Actions/ActionStateTypes.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Assets/SEE/Controls/Actions/ActionStateTypes.cs b/Assets/SEE/Controls/Actions/ActionStateTypes.cs index 3202b4337e..3c7b029180 100644 --- a/Assets/SEE/Controls/Actions/ActionStateTypes.cs +++ b/Assets/SEE/Controls/Actions/ActionStateTypes.cs @@ -112,7 +112,7 @@ static ActionStateTypes() DrawAction.CreateReversibleAction); AcceptDivergence = - new("Accept Divergence", "Accept a diverging edge into the Architecture", + new("Accept Divergence", "Accept a diverging edge into the architecture", Color.grey.Darker(), "Materials/ModernUIPack/Arrow Bold", AcceptDivergenceAction.CreateReversibleAction); From 10fa2f34b14a9102eaf7aabbfdf07595f97abee7 Mon Sep 17 00:00:00 2001 From: Rainer Koschke Date: Wed, 16 Aug 2023 18:02:17 +0200 Subject: [PATCH 60/69] #599 Removed obsolete implementation hint. --- Assets/SEE/Controls/Actions/ActionStateType.cs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Assets/SEE/Controls/Actions/ActionStateType.cs b/Assets/SEE/Controls/Actions/ActionStateType.cs index 8478b96c43..0cb5a51ccf 100644 --- a/Assets/SEE/Controls/Actions/ActionStateType.cs +++ b/Assets/SEE/Controls/Actions/ActionStateType.cs @@ -6,12 +6,6 @@ namespace SEE.Controls.Actions /// /// The type of a state-based action. - /// Implemented using the "Enumeration" (not enum) or "type safe enum" pattern. - /// The following two pages have been used for reference: - ///
          - ///
        • https://docs.microsoft.com/en-us/dotnet/architecture/microservices/microservice-ddd-cqrs-patterns/enumeration-classes-over-enum-types#implement-an-enumeration-base-class
        • - ///
        • https://ardalis.com/enum-alternatives-in-c/
        • - ///
        ///
        public class ActionStateType : AbstractActionStateType { From 8e60295e0f3adbc9dfbfc75eacfeee5421c26cf8 Mon Sep 17 00:00:00 2001 From: Rainer Koschke Date: Wed, 16 Aug 2023 18:16:25 +0200 Subject: [PATCH 61/69] #599 Added missing import. --- Assets/SEE/Controls/Actions/AddEdgeAction.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Assets/SEE/Controls/Actions/AddEdgeAction.cs b/Assets/SEE/Controls/Actions/AddEdgeAction.cs index 4c5bea638a..71765853b4 100644 --- a/Assets/SEE/Controls/Actions/AddEdgeAction.cs +++ b/Assets/SEE/Controls/Actions/AddEdgeAction.cs @@ -7,6 +7,7 @@ using System; using UnityEngine; using SEE.Audio; +using SEE.DataModel.DG; namespace SEE.Controls.Actions { From 735a67bd42c9a7131aab8c82870aa73ae010c1ca Mon Sep 17 00:00:00 2001 From: Rainer Koschke Date: Wed, 16 Aug 2023 18:17:05 +0200 Subject: [PATCH 62/69] #599 We can use Find. Fixed misleading error message. Added a FIXME marker. --- .../Net/Actions/AcceptDivergenceNetAction.cs | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/Assets/SEE/Net/Actions/AcceptDivergenceNetAction.cs b/Assets/SEE/Net/Actions/AcceptDivergenceNetAction.cs index 666a19a0a7..df4960052c 100644 --- a/Assets/SEE/Net/Actions/AcceptDivergenceNetAction.cs +++ b/Assets/SEE/Net/Actions/AcceptDivergenceNetAction.cs @@ -70,17 +70,22 @@ protected override void ExecuteOnClient() { if (!IsRequester()) { - GameObject fromGO = GraphElementIDMap.Find(FromId); - if (fromGO && fromGO.TryGetNode(out Node fromNode)) + GameObject fromGO = Find(FromId); + if (fromGO.TryGetNode(out Node fromNode)) { - GameObject toGO = GraphElementIDMap.Find(ToId); - if (toGO && toGO.TryGetNode(out Node toNode)) + GameObject toGO = Find(ToId); + if (toGO.TryGetNode(out Node toNode)) { - // create the edge beforehand (to change its ID) - Edge edgeToPropagate = new Edge(fromNode, toNode, Type); + // FIXME: This code is very similar to AcceptDivergenceAction.CreateEdge. + // NetActions must be as dump as possible. All logic shared by these + // and their corresponding Action must be extracted to a separate class. - // change the edges ID before adding it to a graph - edgeToPropagate.ID = EdgeId; + // create the edge beforehand (to change its ID) + Edge edgeToPropagate = new(fromNode, toNode, Type) + { + // change the edges ID before adding it to a graph + ID = EdgeId + }; // add the already created edge to the architecture graph if (fromNode.ItsGraph is ReflexionGraph graph) @@ -89,16 +94,16 @@ protected override void ExecuteOnClient() } // (re)draw the new edge - GameObject edgeGameObject = GameEdgeAdder.Draw(edgeToPropagate); + GameEdgeAdder.Draw(edgeToPropagate); } else { - Debug.LogError($"There is no game node named {ToId} for the target.\n"); + Debug.LogError($"Game node {ToId} has not graph node attached.\n"); } } else { - Debug.LogError($"There is no game node named {FromId} for the source.\n"); + Debug.LogError($"Game node {FromId} has not graph node attached.\n"); } } } From d27b8d5b07e13b70e0ce8e10e37d8a285715502e Mon Sep 17 00:00:00 2001 From: m4xxed Date: Wed, 16 Aug 2023 19:15:29 +0200 Subject: [PATCH 63/69] fix documentation - change check to catch propagated edges too --- Assets/SEE/Tools/ReflexionAnalysis/ReflexionAnalysis.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Assets/SEE/Tools/ReflexionAnalysis/ReflexionAnalysis.cs b/Assets/SEE/Tools/ReflexionAnalysis/ReflexionAnalysis.cs index 4e4b9ba90a..99690a112e 100644 --- a/Assets/SEE/Tools/ReflexionAnalysis/ReflexionAnalysis.cs +++ b/Assets/SEE/Tools/ReflexionAnalysis/ReflexionAnalysis.cs @@ -218,7 +218,7 @@ public static bool IsSpecified(Edge edge) /// true if edge is a divergent architecture dependency public static bool IsDivergent(Edge edge) { - AssertOrThrow(edge.IsInImplementation(), () => new NotInSubgraphException(Implementation, edge)); + AssertOrThrow(edge.IsInReflexion(), () => new NotInSubgraphException(Implementation, edge)); return edge.State() == State.Divergent; } #endregion From 63b8b36a60e0932731a8b41041a2dbcf9b42ac29 Mon Sep 17 00:00:00 2001 From: Rainer Koschke Date: Thu, 17 Aug 2023 08:33:24 +0200 Subject: [PATCH 64/69] #599 Removed obsolete class that was once created only for video recording. --- Assets/SEE/Game/ArchitectureInteraction.cs | 783 ------------------ .../SEE/Game/ArchitectureInteraction.cs.meta | 11 - 2 files changed, 794 deletions(-) delete mode 100644 Assets/SEE/Game/ArchitectureInteraction.cs delete mode 100644 Assets/SEE/Game/ArchitectureInteraction.cs.meta diff --git a/Assets/SEE/Game/ArchitectureInteraction.cs b/Assets/SEE/Game/ArchitectureInteraction.cs deleted file mode 100644 index 756b663dab..0000000000 --- a/Assets/SEE/Game/ArchitectureInteraction.cs +++ /dev/null @@ -1,783 +0,0 @@ -using System.Collections.Generic; -using SEE.DataModel.DG; -using SEE.Game.City; -using SEE.GO; -using UnityEngine; - -namespace SEE.Game -{ - /// - /// This component is intended to provide interactions with a - /// code city representing a reflexion model. One can show/hide nodes - /// and edges in the architecture by user interactions. - /// - /// Its only purpose was to create a video. Do not use this class. - /// - [ExecuteAlways] - public class ArchitectureInteraction : MonoBehaviour - { - /// - /// The code city to be manipulated by this component. - /// - [Tooltip("The code city to be manipulated by this component.")] - public SEECity CodeCity; - - //------------------ - // Edge types - //------------------ - - /// - /// Edge types generated by the reflexion analysis. - /// - public static readonly HashSet ReflexionEdgeTypes = new() - { - Edge.Absence, - Edge.Convergence, - Edge.Divergence, - }; - - /// - /// Edge types representing implementation dependencies. - /// - public static readonly HashSet ArchitectureEdgeTypes = new() - { - Edge.SourceDependency, - }; - - public static readonly HashSet AllEdgeTypes = new(); - - /// - /// See property . - /// - private HashSet implementationEdgeTypes = new(); - /// - /// All edge types in the graph that are neither reflexion edges - /// nor architecture dependencies. - /// - public HashSet ImplementationEdgeTypes - { - get - { - if (implementationEdgeTypes.Count == 0) - { - implementationEdgeTypes = GetImplementationEdgeTypes(); - foreach (string type in implementationEdgeTypes) - { - Debug.Log($"implementation edge type {type}\n"); - } - } - return implementationEdgeTypes; - } - } - - /// - /// Returns all edge types in the graph that are neither reflexion edges - /// nor architecture dependencies. - /// - /// all implementation edge types - private HashSet GetImplementationEdgeTypes() - { - HashSet result = new HashSet(); - foreach (GameObject go in GetAllEdges()) - { - string type = GetGraphEdge(go).Type; - if (!ReflexionEdgeTypes.Contains(type) && !ArchitectureEdgeTypes.Contains(type)) - { - result.Add(type); - } - } - return result; - } - - // ----------------------- - // Edge property defaults - // ----------------------- - private static readonly Color implementationEdgesColorDefault = Color.black; - private static readonly Color architectureEdgesColorDefault = Color.blue; - private static readonly float implementationEdgeWidthDefault = 0.001f; - private static readonly float architectureEdgeWidthDefault = 0.005f; - private static readonly float reflexionEdgeWidthDefault = 0.005f; - - /// - /// Resets the settings to their defaults. Called in editor mode when the - /// user resets the component. - /// - private void Reset() - { - implementationEdgesVisible = false; - implementationEdgesStartColor = Lighter(implementationEdgesColorDefault); - implementationEdgesEndColor = implementationEdgesColorDefault; - implementationEdgesWidth = implementationEdgeWidthDefault; - - architectureEdgesVisible = false; - architectureEdgesStartColor = Lighter(architectureEdgesColorDefault); - architectureEdgesEndColor = architectureEdgesColorDefault; - architectureEdgesWidth = architectureEdgeWidthDefault; - - reflexionEdgesVisible = false; - reflexionEdgesWidth = reflexionEdgeWidthDefault; - - architectureNodesVisible = true; - implementationNodesVisible = false; - } - - /// - /// Assigns . - /// - private void Awake() - { - if (!gameObject.TryGetComponent(out CodeCity)) - { - Debug.LogError($"Game object {name} does not have a SEECity component.\n"); - enabled = false; - } - else - { - UpdateCity(); - } - } - - // -------------------------------------------- - // Update - // -------------------------------------------- - - private void Update() - { - if (Input.GetKeyDown(KeyCode.F5)) - { - ImplementationEdgesVisible = !ImplementationEdgesVisible; - Debug.Log("F5 pressed.\n"); - } - if (Input.GetKeyDown(KeyCode.F6)) - { - ArchitectureEdgesVisible = !ArchitectureEdgesVisible; - } - if (Input.GetKeyDown(KeyCode.F7)) - { - ReflexionEdgesVisible = !ReflexionEdgesVisible; - } - if (Input.GetKeyDown(KeyCode.F11)) - { - ArchitectureNodesVisible = !ArchitectureNodesVisible; - } - if (Input.GetKeyDown(KeyCode.F12)) - { - ImplementationNodesVisible = !ImplementationNodesVisible; - } - } - - /// - /// Sets the edge references of all edges in - /// and colors the nodes. - /// - public void UpdateCity() - { - if (CodeCity != null) - { - CodeCity.SetNodeEdgeRefs(); - GameObject root = GetCityRootNode(); - if (root != null) - { - Debug.LogFormat("Root of {0} is {1}\n", CodeCity.name, root.name); - SetAllNodes(root); - SetAllEdges(); - } - } - else - { - Debug.LogErrorFormat("Code city is null in {0}.\n", name); - } - } - - /// - /// Sets all attributes of all nodes. - /// - /// root node of the code city - private void SetAllNodes(GameObject root) - { - ColorNodes(root); - SetNodeVisibility(ArchitectureNodes(), architectureNodesVisible); - SetNodeVisibility(ImplementationNodes(), implementationNodesVisible); - } - - /// - /// Sets all attributes of all edges. - /// - private void SetAllEdges() - { - SetArchitectureEdges(); - SetImplementationEdges(); - SetReflexionEdges(); - } - - /// - /// Returns the root node of . - /// - /// root node of - private GameObject GetCityRootNode() - { - return SceneQueries.GetCityRootNode(CodeCity.gameObject); - } - - /// - /// Colors architecture node with increasingly darker colors starting from white - /// and implementation nodes with increasingly darker colors starting from yellow. - /// The actual color used gets darker from nesting level to nesting level. - /// Implementation leaf nodes keep their original color, however. - /// - /// the root of the node tree to be colored - private void ColorNodes(GameObject root) - { - ColorNodes(root, architectureNode: false, Color.yellow); - ColorNodes(root, architectureNode: true, Color.white); - } - - /// - /// Colors all nodes in the node tree rooted by using - /// the given if and only if: - /// (1) if is true, the nodes are architecture nodes - /// or - /// (2) if is false, the nodes are implementation nodes. - /// The color is increasingly darkened from level to level, that is, the deeper a node - /// in the node tree, the darker its color originating from the initial given . - /// - /// Note: The color of implementation leaf nodes is never changed. - /// - /// root of the node tree to be colored - /// whether architecture nodes should be colored - /// the new color of the nodes - private void ColorNodes(GameObject parent, bool architectureNode, Color color) - { - // Is root a node at all? It may as well be an edge, for instance. - if (parent.CompareTag(Tags.Node)) - { - if (parent.TryGetComponent(out NodeRef nodeRef) && nodeRef.Value != null) - { - bool isArchitectureNode = IsArchitectureNode(parent); - Color childColor = color; - - if (!isArchitectureNode && GetGraphNode(parent).IsLeaf()) - { - // We are dealing with an implementation node that is a leaf. - // We will not change the color of implementation nodes that are leaves; - // neither do we need to traverse any children because there are none. - } - else - { - if ((architectureNode && isArchitectureNode) || (!architectureNode && !isArchitectureNode)) - { - parent.SetColor(color); - childColor = Darker(color, 0.35f); - } - foreach (Transform child in parent.transform) - { - ColorNodes(child.gameObject, architectureNode, childColor); - } - } - } - else - { - Debug.LogErrorFormat("Game object {0} has no valid node reference.\n", parent.name); - } - } - } - - //------------------- - // Edges in CodeCity - //------------------- - - /// - /// Returns all edges in the subtree rooted by . - /// - /// all edges in the subtree rooted by - private List GetAllEdges() - { - List edges = new List(); - GameObject root = GetCityRootNode(); - AddAllEdges(root, edges); - return edges; - } - - /// - /// Adds all edges in the subtree rooted by to . - /// - /// root of the subtree to be traversed - /// where to add the found edges - private void AddAllEdges(GameObject root, List edges) - { - foreach (Transform child in root.transform) - { - GameObject childGO = child.gameObject; - if (childGO.CompareTag(Tags.Edge)) - { - if (childGO.TryGetComponent(out EdgeRef edgeRef) && edgeRef.Value != null) - { - edges.Add(childGO); - } - else - { - Debug.LogErrorFormat("Edge {0} has no valid edge reference.\n", childGO.name); - } - } - else if (childGO.CompareTag(Tags.Node)) - { - AddAllEdges(childGO, edges); - } - } - } - - /// - /// Returns the graph edge represented by if there is any. - /// Returns null if does not have a valid graph edge. - /// - /// game object representing an edge - /// graph edge represented or null - private static Edge GetGraphEdge(GameObject gameEdge) - { - if (gameEdge.TryGetComponent(out EdgeRef edgeRef)) - { - return edgeRef.Value; - } - else - { - Debug.LogError($"Edge {gameEdge.name} has no valid edge reference.\n"); - return null; - } - } - - //------------------ - // Nodes in CodeCity - //------------------ - - /// - /// Returns all nodes in the subtree rooted by . - /// - /// all nodes in the subtree rooted by - private List GetAllNodes() - { - GameObject root = GetCityRootNode(); - List nodes = new List() { root }; - AddAllNodes(root, nodes); - return nodes; - } - - /// - /// Adds all nodes in the subtree rooted by to . - /// - /// root of the subtree to be traversed - /// where to add the found nodes - private void AddAllNodes(GameObject root, List nodes) - { - foreach (Transform child in root.transform) - { - GameObject childGO = child.gameObject; - if (childGO.CompareTag(Tags.Node)) - { - if (childGO.TryGetComponent(out NodeRef nodeRef) && nodeRef.Value != null) - { - nodes.Add(childGO); - } - else - { - Debug.LogError($"Node {childGO.name} has no valid node reference.\n"); - } - } - AddAllNodes(childGO, nodes); - } - } - - /// - /// Returns the graph node represented by if there is any. - /// Returns null if does not have a valid graph node. - /// - /// game object representing a node - /// graph node represented or null - private static Node GetGraphNode(GameObject gameNode) - { - if (gameNode.TryGetComponent(out NodeRef nodeRef)) - { - return nodeRef.Value; - } - else - { - Debug.LogErrorFormat("Node {0} has no valid node reference.\n", gameNode.name); - return null; - } - } - - //------------------------------------ - // Implementation edge type properties - //------------------------------------ - - private bool implementationEdgesVisible = false; - /// - /// Whether implementation edges are visible. - /// - public bool ImplementationEdgesVisible - { - get => implementationEdgesVisible; - set - { - if (implementationEdgesVisible != value) - { - implementationEdgesVisible = value; - SetEdgeVisiblity(ImplementationEdgeTypes, implementationEdgesVisible); - } - } - } - - private Color implementationEdgesStartColor = Lighter(implementationEdgesColorDefault); - /// - /// Start color of implementation dependencies. - /// - public Color ImplementationEdgesStartColor - { - get => implementationEdgesStartColor; - set - { - if (implementationEdgesStartColor != value) - { - implementationEdgesStartColor = value; - SetImplementationEdges(); - } - } - } - - private Color implementationEdgesEndColor = implementationEdgesColorDefault; - /// - /// End color of implementation dependencies. - /// - public Color ImplementationEdgesEndColor - { - get => implementationEdgesEndColor; - set - { - if (implementationEdgesEndColor != value) - { - implementationEdgesEndColor = value; - SetImplementationEdges(); - } - } - } - - private float implementationEdgesWidth = implementationEdgeWidthDefault; - /// - /// The width of implementation dependencies. - /// - public float ImplementationEdgesWidth - { - get => implementationEdgesWidth; - set - { - if (implementationEdgesWidth != value) - { - implementationEdgesWidth = value; - SetImplementationEdges(); - } - } - } - - /// - /// Sets all attributes of implementation edges. - /// - private void SetImplementationEdges() - { - SetLine(ImplementationEdgeTypes, implementationEdgesStartColor, implementationEdgesEndColor, implementationEdgesWidth); - SetEdgeVisiblity(ImplementationEdgeTypes, implementationEdgesVisible); - } - - //------------------------------------ - // Reflexion edge type properties - //------------------------------------ - - private bool reflexionEdgesVisible = false; - /// - /// Whether reflexion edges are visible. - /// - public bool ReflexionEdgesVisible - { - get => reflexionEdgesVisible; - set - { - if (reflexionEdgesVisible != value) - { - reflexionEdgesVisible = value; - SetEdgeVisiblity(ReflexionEdgeTypes, reflexionEdgesVisible); - } - } - } - - private float reflexionEdgesWidth = reflexionEdgeWidthDefault; - /// - /// The width of reflexion edges. - /// - public float ReflexionEdgesWidth - { - get => reflexionEdgesWidth; - set - { - if (reflexionEdgesWidth != value) - { - reflexionEdgesWidth = value; - SetReflexionEdges(); - } - } - } - - /// - /// Sets start and end color and width for the lines of all reflexion edges. - /// Absences will be colored yellow, convergences will be colored green, and - /// divergences will be colored red. Sets the visibility of the reflexion edges. - /// - private void SetReflexionEdges() - { - SetLine(new HashSet() { "Absence" }, Color.yellow, Darker(Color.yellow), reflexionEdgesWidth); - SetLine(new HashSet() { "Convergence" }, Color.green, Darker(Color.green), reflexionEdgesWidth); - SetLine(new HashSet() { "Divergence" }, Color.red, Darker(Color.red), reflexionEdgesWidth); - SetEdgeVisiblity(ReflexionEdgeTypes, reflexionEdgesVisible); - } - - //------------------------------------ - // Architecture edge type properties - //------------------------------------ - - private bool architectureEdgesVisible = false; - /// - /// Whether architecture dependencies are visible. - /// - public bool ArchitectureEdgesVisible - { - get => architectureEdgesVisible; - set - { - if (architectureEdgesVisible != value) - { - architectureEdgesVisible = value; - SetEdgeVisiblity(ArchitectureEdgeTypes, architectureEdgesVisible); - } - } - } - - private Color architectureEdgesStartColor = Lighter(Color.blue); - /// - /// Start color of architecture dependencies. - /// - public Color ArchitectureEdgesStartColor - { - get => architectureEdgesStartColor; - set - { - if (architectureEdgesStartColor != value) - { - architectureEdgesStartColor = value; - SetArchitectureEdges(); - } - } - } - - private Color architectureEdgesEndColor = Color.blue; - /// - /// End color of architecture dependencies. - /// - public Color ArchitectureEdgesEndColor - { - get => architectureEdgesEndColor; - set - { - if (architectureEdgesEndColor != value) - { - architectureEdgesEndColor = value; - SetArchitectureEdges(); - } - } - } - - private float architectureEdgesWidth = architectureEdgeWidthDefault; - /// - /// The width of architecture dependencies. - /// - public float ArchitectureEdgesWidth - { - get => architectureEdgesWidth; - set - { - if (architectureEdgesWidth != value) - { - architectureEdgesWidth = value; - SetArchitectureEdges(); - } - } - } - - /// - /// Sets all attributes of all architecture edges. - /// - private void SetArchitectureEdges() - { - SetLine(ArchitectureEdgeTypes, architectureEdgesStartColor, architectureEdgesEndColor, architectureEdgesWidth); - SetEdgeVisiblity(ArchitectureEdgeTypes, architectureEdgesVisible); - } - - /// - /// Set the visibility of all edges in the that have - /// any of the given to . - /// - /// relevant edge types for setting the visibility - /// new visibility - private void SetEdgeVisiblity(HashSet edgeTypes, bool show) - { - foreach (GameObject go in GetAllEdges()) - { - if (edgeTypes == AllEdgeTypes || edgeTypes.Contains(GetGraphEdge(go).Type)) - { - go.SetVisibility(show); - } - } - } - - /// - /// For every edge in having a type included in the given - /// , the given line attributes will be set. - /// - /// relevant edge types - /// starting color of the line - /// ending color of the line - /// width of the line - private void SetLine(HashSet edgeTypes, Color startColor, Color endColor, float width) - { - foreach (GameObject go in GetAllEdges()) - { - if (edgeTypes == AllEdgeTypes || edgeTypes.Contains(GetGraphEdge(go).Type)) - { - LineRenderer renderer = go.GetComponent(); - if (renderer != null) - { - renderer.startColor = startColor; - renderer.endColor = endColor; - renderer.startWidth = width; - renderer.endWidth = width; - } - } - } - } - - //------------------------------------ - // Architecture node type properties - //------------------------------------ - - private bool architectureNodesVisible = true; - /// - /// Whether architecture nodes are visible. - /// - public bool ArchitectureNodesVisible - { - get => architectureNodesVisible; - set - { - if (architectureNodesVisible != value) - { - architectureNodesVisible = value; - SetNodeVisibility(ArchitectureNodes(), architectureNodesVisible); - } - } - } - - private bool implementationNodesVisible = false; - /// - /// Whether implementation nodes are visible. - /// - public bool ImplementationNodesVisible - { - get => implementationNodesVisible; - set - { - if (implementationNodesVisible != value) - { - implementationNodesVisible = value; - SetNodeVisibility(ImplementationNodes(), implementationNodesVisible); - } - } - } - - /// - /// Returns all architecture nodes in . - /// - /// all architecture nodes - private List ArchitectureNodes() - { - List result = new List(); - foreach (GameObject go in GetAllNodes()) - { - if (IsArchitectureNode(go)) - { - result.Add(go); - } - } - return result; - } - - /// - /// Returns true if is an architecture node (has - /// type Cluster). - /// - /// game object representing a node - /// true if architecture node - private static bool IsArchitectureNode(GameObject go) - { - return GetGraphNode(go).Type == "Cluster"; - } - - /// - /// Returns all implementation nodes in the . - /// - /// all implementation nodes - private List ImplementationNodes() - { - List result = new List(); - foreach (GameObject go in GetAllNodes()) - { - if (!IsArchitectureNode(go)) - { - result.Add(go); - } - } - return result; - } - - /// - /// Sets the visibility of all to . - /// - /// game objects whose visibility is to be set - /// the new visibility - private static void SetNodeVisibility(ICollection nodes, bool show) - { - foreach (GameObject go in nodes) - { - go.SetVisibility(show, includingChildren: false); - } - } - - /// - /// Returns given lightened by 50%. - /// - /// base color to be lightened - /// given lightened by 50% - private static Color Lighter(Color color) - { - return Color.Lerp(color, Color.white, 0.5f); // To lighten by 50 % - } - - /// - /// Returns given darkened by . - /// - /// Precondition: 0 <= <= 1 - /// - /// base color to be darkened - /// degree by which to darker the given - /// given darkened by - private static Color Darker(Color color, float degree = 0.5f) - { - return Color.Lerp(color, Color.black, degree); - } - } -} \ No newline at end of file diff --git a/Assets/SEE/Game/ArchitectureInteraction.cs.meta b/Assets/SEE/Game/ArchitectureInteraction.cs.meta deleted file mode 100644 index 02d74be976..0000000000 --- a/Assets/SEE/Game/ArchitectureInteraction.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 4f25e472fae0c304e994d615ed8259db -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: From 9df862b8d53cdda9d050d96a862a721806f7d275 Mon Sep 17 00:00:00 2001 From: Rainer Koschke Date: Thu, 17 Aug 2023 09:00:37 +0200 Subject: [PATCH 65/69] #599 Created namespace for classes manipulating game objects in the scene. This namespace contains (typically static) classes that manipulate game objects in the scene representing nodes or edges. They will be shared among our Actions and their corresponding NetActions. The intention here is to avoid redundancy among Actions and NetActions as both need to change the scene the same way. --- .../Actions/AcceptDivergenceAction.cs | 3 ++- Assets/SEE/Controls/Actions/AddEdgeAction.cs | 1 + Assets/SEE/Controls/Actions/AddNodeAction.cs | 2 +- Assets/SEE/Controls/Actions/DeleteAction.cs | 2 +- Assets/SEE/Controls/Actions/MoveAction.cs | 1 + .../Interactables/InteractableObject.cs | 2 +- Assets/SEE/Game/InteractionDecorator.cs | 1 + Assets/SEE/Game/SceneManipulation.meta | 8 ++++++++ .../{ => SceneManipulation}/GameEdgeAdder.cs | 2 +- .../GameEdgeAdder.cs.meta | 0 .../GameElementDeleter.cs | 2 +- .../GameElementDeleter.cs.meta | 0 .../{ => SceneManipulation}/GameNodeAdder.cs | 2 +- .../GameNodeAdder.cs.meta | 0 .../{ => SceneManipulation}/GameNodeMover.cs | 2 +- .../GameNodeMover.cs.meta | 0 .../{ => SceneManipulation}/GameNodeScaler.cs | 4 ++-- .../GameNodeScaler.cs.meta | 0 .../GameObjectFader.cs | 2 +- .../GameObjectFader.cs.meta | 0 .../GameObjectFlasher.cs | 2 +- .../GameObjectFlasher.cs.meta | 0 .../SceneManipulation/SceneManipulation.cs | 10 ++++++++++ .../SceneManipulation.cs.meta | 11 ++++++++++ .../Net/Actions/AcceptDivergenceNetAction.cs | 2 +- Assets/SEE/Net/Actions/AddEdgeNetAction.cs | 20 ++----------------- Assets/SEE/Net/Actions/AddNodeNetAction.cs | 2 +- Assets/SEE/Net/Actions/DeleteNetAction.cs | 1 + Assets/SEE/Net/Actions/MoveNetAction.cs | 1 + .../SEE/Net/Actions/PutOnAndFitNetAction.cs | 1 + Assets/SEE/Net/Actions/ReviveNetAction.cs | 1 + Assets/SEE/Net/Actions/SetParentNetAction.cs | 1 + Assets/SEE/Net/Actions/VersionNetAction.cs | 2 +- 33 files changed, 55 insertions(+), 33 deletions(-) create mode 100644 Assets/SEE/Game/SceneManipulation.meta rename Assets/SEE/Game/{ => SceneManipulation}/GameEdgeAdder.cs (99%) rename Assets/SEE/Game/{ => SceneManipulation}/GameEdgeAdder.cs.meta (100%) rename Assets/SEE/Game/{ => SceneManipulation}/GameElementDeleter.cs (99%) rename Assets/SEE/Game/{ => SceneManipulation}/GameElementDeleter.cs.meta (100%) rename Assets/SEE/Game/{ => SceneManipulation}/GameNodeAdder.cs (99%) rename Assets/SEE/Game/{ => SceneManipulation}/GameNodeAdder.cs.meta (100%) rename Assets/SEE/Game/{ => SceneManipulation}/GameNodeMover.cs (99%) rename Assets/SEE/Game/{ => SceneManipulation}/GameNodeMover.cs.meta (100%) rename Assets/SEE/Game/{ => SceneManipulation}/GameNodeScaler.cs (98%) rename Assets/SEE/Game/{ => SceneManipulation}/GameNodeScaler.cs.meta (100%) rename Assets/SEE/Game/{ => SceneManipulation}/GameObjectFader.cs (99%) rename Assets/SEE/Game/{ => SceneManipulation}/GameObjectFader.cs.meta (100%) rename Assets/SEE/Game/{ => SceneManipulation}/GameObjectFlasher.cs (98%) rename Assets/SEE/Game/{ => SceneManipulation}/GameObjectFlasher.cs.meta (100%) create mode 100644 Assets/SEE/Game/SceneManipulation/SceneManipulation.cs create mode 100644 Assets/SEE/Game/SceneManipulation/SceneManipulation.cs.meta diff --git a/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs b/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs index f6f9eae910..46af73a299 100644 --- a/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs +++ b/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs @@ -5,9 +5,10 @@ using SEE.Utils; using UnityEngine; using System; -using SEE.Game; +using SEE.Game.SceneManipulation; using SEE.Net.Actions; using SEE.Audio; +using SEE.Game; namespace SEE.Controls.Actions { diff --git a/Assets/SEE/Controls/Actions/AddEdgeAction.cs b/Assets/SEE/Controls/Actions/AddEdgeAction.cs index 71765853b4..d13e5d0b22 100644 --- a/Assets/SEE/Controls/Actions/AddEdgeAction.cs +++ b/Assets/SEE/Controls/Actions/AddEdgeAction.cs @@ -8,6 +8,7 @@ using UnityEngine; using SEE.Audio; using SEE.DataModel.DG; +using SEE.Game.SceneManipulation; namespace SEE.Controls.Actions { diff --git a/Assets/SEE/Controls/Actions/AddNodeAction.cs b/Assets/SEE/Controls/Actions/AddNodeAction.cs index 3179a77b5c..389b610b10 100644 --- a/Assets/SEE/Controls/Actions/AddNodeAction.cs +++ b/Assets/SEE/Controls/Actions/AddNodeAction.cs @@ -1,10 +1,10 @@ using System.Collections.Generic; -using SEE.Game; using SEE.GO; using SEE.Net.Actions; using SEE.Utils; using UnityEngine; using SEE.Audio; +using SEE.Game.SceneManipulation; namespace SEE.Controls.Actions { diff --git a/Assets/SEE/Controls/Actions/DeleteAction.cs b/Assets/SEE/Controls/Actions/DeleteAction.cs index 3c583edd99..c3bc01ae11 100644 --- a/Assets/SEE/Controls/Actions/DeleteAction.cs +++ b/Assets/SEE/Controls/Actions/DeleteAction.cs @@ -1,12 +1,12 @@ using System.Collections.Generic; using System.Linq; -using SEE.Game; using SEE.GO; using SEE.Net.Actions; using SEE.Utils; using UnityEngine; using UnityEngine.Assertions; using SEE.Audio; +using SEE.Game.SceneManipulation; namespace SEE.Controls.Actions { diff --git a/Assets/SEE/Controls/Actions/MoveAction.cs b/Assets/SEE/Controls/Actions/MoveAction.cs index 5097cc1942..eb0a624e71 100644 --- a/Assets/SEE/Controls/Actions/MoveAction.cs +++ b/Assets/SEE/Controls/Actions/MoveAction.cs @@ -4,6 +4,7 @@ using SEE.Game; using SEE.Game.City; using SEE.Game.Operator; +using SEE.Game.SceneManipulation; using SEE.Game.UI.Notification; using SEE.GO; using SEE.Net.Actions; diff --git a/Assets/SEE/Controls/Interactables/InteractableObject.cs b/Assets/SEE/Controls/Interactables/InteractableObject.cs index 4503a4731c..49417b07d8 100644 --- a/Assets/SEE/Controls/Interactables/InteractableObject.cs +++ b/Assets/SEE/Controls/Interactables/InteractableObject.cs @@ -9,7 +9,7 @@ #if INCLUDE_STEAM_VR using Valve.VR.InteractionSystem; #endif -using SEE.Game; +using SEE.Game.SceneManipulation; using SEE.Net.Actions; using SEE.Audio; diff --git a/Assets/SEE/Game/InteractionDecorator.cs b/Assets/SEE/Game/InteractionDecorator.cs index 67419b67c6..8ca06b2b95 100644 --- a/Assets/SEE/Game/InteractionDecorator.cs +++ b/Assets/SEE/Game/InteractionDecorator.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using SEE.Controls; using SEE.Controls.Actions; +using SEE.Game.SceneManipulation; using SEE.GO; using UnityEngine; diff --git a/Assets/SEE/Game/SceneManipulation.meta b/Assets/SEE/Game/SceneManipulation.meta new file mode 100644 index 0000000000..29ac170949 --- /dev/null +++ b/Assets/SEE/Game/SceneManipulation.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2f2874a20ebd0a5428e97d6c6f3494d8 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/SEE/Game/GameEdgeAdder.cs b/Assets/SEE/Game/SceneManipulation/GameEdgeAdder.cs similarity index 99% rename from Assets/SEE/Game/GameEdgeAdder.cs rename to Assets/SEE/Game/SceneManipulation/GameEdgeAdder.cs index d74ea654d8..06614980ff 100644 --- a/Assets/SEE/Game/GameEdgeAdder.cs +++ b/Assets/SEE/Game/SceneManipulation/GameEdgeAdder.cs @@ -4,7 +4,7 @@ using SEE.GO; using UnityEngine; -namespace SEE.Game +namespace SEE.Game.SceneManipulation { /// /// Creates new game objects representing graph edges or deletes these again, diff --git a/Assets/SEE/Game/GameEdgeAdder.cs.meta b/Assets/SEE/Game/SceneManipulation/GameEdgeAdder.cs.meta similarity index 100% rename from Assets/SEE/Game/GameEdgeAdder.cs.meta rename to Assets/SEE/Game/SceneManipulation/GameEdgeAdder.cs.meta diff --git a/Assets/SEE/Game/GameElementDeleter.cs b/Assets/SEE/Game/SceneManipulation/GameElementDeleter.cs similarity index 99% rename from Assets/SEE/Game/GameElementDeleter.cs rename to Assets/SEE/Game/SceneManipulation/GameElementDeleter.cs index c44bcad5ff..fa789fbf2a 100644 --- a/Assets/SEE/Game/GameElementDeleter.cs +++ b/Assets/SEE/Game/SceneManipulation/GameElementDeleter.cs @@ -6,7 +6,7 @@ using SEE.Tools.ReflexionAnalysis; using UnityEngine; -namespace SEE.Game +namespace SEE.Game.SceneManipulation { /// /// Allows to delete nodes and edges. diff --git a/Assets/SEE/Game/GameElementDeleter.cs.meta b/Assets/SEE/Game/SceneManipulation/GameElementDeleter.cs.meta similarity index 100% rename from Assets/SEE/Game/GameElementDeleter.cs.meta rename to Assets/SEE/Game/SceneManipulation/GameElementDeleter.cs.meta diff --git a/Assets/SEE/Game/GameNodeAdder.cs b/Assets/SEE/Game/SceneManipulation/GameNodeAdder.cs similarity index 99% rename from Assets/SEE/Game/GameNodeAdder.cs rename to Assets/SEE/Game/SceneManipulation/GameNodeAdder.cs index 9dd226312f..d4d771aa4b 100644 --- a/Assets/SEE/Game/GameNodeAdder.cs +++ b/Assets/SEE/Game/SceneManipulation/GameNodeAdder.cs @@ -4,7 +4,7 @@ using SEE.GO; using UnityEngine; -namespace SEE.Game +namespace SEE.Game.SceneManipulation { /// /// Creates new game objects representing graph nodes or deleting these again, diff --git a/Assets/SEE/Game/GameNodeAdder.cs.meta b/Assets/SEE/Game/SceneManipulation/GameNodeAdder.cs.meta similarity index 100% rename from Assets/SEE/Game/GameNodeAdder.cs.meta rename to Assets/SEE/Game/SceneManipulation/GameNodeAdder.cs.meta diff --git a/Assets/SEE/Game/GameNodeMover.cs b/Assets/SEE/Game/SceneManipulation/GameNodeMover.cs similarity index 99% rename from Assets/SEE/Game/GameNodeMover.cs rename to Assets/SEE/Game/SceneManipulation/GameNodeMover.cs index 55cc9b706a..51a7134225 100644 --- a/Assets/SEE/Game/GameNodeMover.cs +++ b/Assets/SEE/Game/SceneManipulation/GameNodeMover.cs @@ -3,7 +3,7 @@ using UnityEngine; using UnityEngine.Assertions; -namespace SEE.Game +namespace SEE.Game.SceneManipulation { /// /// Allows to move game nodes (game objects representing a graph node). diff --git a/Assets/SEE/Game/GameNodeMover.cs.meta b/Assets/SEE/Game/SceneManipulation/GameNodeMover.cs.meta similarity index 100% rename from Assets/SEE/Game/GameNodeMover.cs.meta rename to Assets/SEE/Game/SceneManipulation/GameNodeMover.cs.meta diff --git a/Assets/SEE/Game/GameNodeScaler.cs b/Assets/SEE/Game/SceneManipulation/GameNodeScaler.cs similarity index 98% rename from Assets/SEE/Game/GameNodeScaler.cs rename to Assets/SEE/Game/SceneManipulation/GameNodeScaler.cs index 6fe3e02124..b037e27e04 100644 --- a/Assets/SEE/Game/GameNodeScaler.cs +++ b/Assets/SEE/Game/SceneManipulation/GameNodeScaler.cs @@ -2,10 +2,10 @@ using UnityEditor; using UnityEngine; -namespace SEE.Game +namespace SEE.Game.SceneManipulation { /// - /// This GameNodeScaler allows us to scale a game node without modifying the + /// This GameNodeScaler allows us to scale a game node without modifying the /// scale of its children. /// [ExecuteInEditMode] diff --git a/Assets/SEE/Game/GameNodeScaler.cs.meta b/Assets/SEE/Game/SceneManipulation/GameNodeScaler.cs.meta similarity index 100% rename from Assets/SEE/Game/GameNodeScaler.cs.meta rename to Assets/SEE/Game/SceneManipulation/GameNodeScaler.cs.meta diff --git a/Assets/SEE/Game/GameObjectFader.cs b/Assets/SEE/Game/SceneManipulation/GameObjectFader.cs similarity index 99% rename from Assets/SEE/Game/GameObjectFader.cs rename to Assets/SEE/Game/SceneManipulation/GameObjectFader.cs index 5645babf91..2788aa598f 100644 --- a/Assets/SEE/Game/GameObjectFader.cs +++ b/Assets/SEE/Game/SceneManipulation/GameObjectFader.cs @@ -5,7 +5,7 @@ using SEE.Utils; using UnityEngine; -namespace SEE.Game +namespace SEE.Game.SceneManipulation { /// /// Provides fading in and out for game objects. There are static as well as instance methods diff --git a/Assets/SEE/Game/GameObjectFader.cs.meta b/Assets/SEE/Game/SceneManipulation/GameObjectFader.cs.meta similarity index 100% rename from Assets/SEE/Game/GameObjectFader.cs.meta rename to Assets/SEE/Game/SceneManipulation/GameObjectFader.cs.meta diff --git a/Assets/SEE/Game/GameObjectFlasher.cs b/Assets/SEE/Game/SceneManipulation/GameObjectFlasher.cs similarity index 98% rename from Assets/SEE/Game/GameObjectFlasher.cs rename to Assets/SEE/Game/SceneManipulation/GameObjectFlasher.cs index ad7615121b..ca53ce9c17 100644 --- a/Assets/SEE/Game/GameObjectFlasher.cs +++ b/Assets/SEE/Game/SceneManipulation/GameObjectFlasher.cs @@ -2,7 +2,7 @@ using DG.Tweening; using SEE.Utils; -namespace SEE.Game +namespace SEE.Game.SceneManipulation { /// /// Flashes a game object, that is, animates its color pulsating from its diff --git a/Assets/SEE/Game/GameObjectFlasher.cs.meta b/Assets/SEE/Game/SceneManipulation/GameObjectFlasher.cs.meta similarity index 100% rename from Assets/SEE/Game/GameObjectFlasher.cs.meta rename to Assets/SEE/Game/SceneManipulation/GameObjectFlasher.cs.meta diff --git a/Assets/SEE/Game/SceneManipulation/SceneManipulation.cs b/Assets/SEE/Game/SceneManipulation/SceneManipulation.cs new file mode 100644 index 0000000000..7442f512f1 --- /dev/null +++ b/Assets/SEE/Game/SceneManipulation/SceneManipulation.cs @@ -0,0 +1,10 @@ +/// +/// This namespace contains (typically static) classes that manipulate +/// game objects in the scene representing nodes or edges. They will +/// be shared among our Actions and their corresponding NetActions. +/// The intention here is to avoid redundancy among Actions and +/// NetActions as both need to change the scene the same way. +/// +namespace SEE.Game.SceneManipulation +{ +} \ No newline at end of file diff --git a/Assets/SEE/Game/SceneManipulation/SceneManipulation.cs.meta b/Assets/SEE/Game/SceneManipulation/SceneManipulation.cs.meta new file mode 100644 index 0000000000..1df626b538 --- /dev/null +++ b/Assets/SEE/Game/SceneManipulation/SceneManipulation.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 2d32acb5594a0914b9461bd09533736f +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/SEE/Net/Actions/AcceptDivergenceNetAction.cs b/Assets/SEE/Net/Actions/AcceptDivergenceNetAction.cs index df4960052c..991ca8a405 100644 --- a/Assets/SEE/Net/Actions/AcceptDivergenceNetAction.cs +++ b/Assets/SEE/Net/Actions/AcceptDivergenceNetAction.cs @@ -1,8 +1,8 @@ using SEE.DataModel.DG; -using SEE.Game; using UnityEngine; using SEE.GO; using SEE.Tools.ReflexionAnalysis; +using SEE.Game.SceneManipulation; namespace SEE.Net.Actions { diff --git a/Assets/SEE/Net/Actions/AddEdgeNetAction.cs b/Assets/SEE/Net/Actions/AddEdgeNetAction.cs index 303993f920..1cfa434925 100644 --- a/Assets/SEE/Net/Actions/AddEdgeNetAction.cs +++ b/Assets/SEE/Net/Actions/AddEdgeNetAction.cs @@ -1,5 +1,5 @@ using SEE.Game; -using UnityEngine; +using SEE.Game.SceneManipulation; namespace SEE.Net.Actions { @@ -52,23 +52,7 @@ protected override void ExecuteOnClient() { if (!IsRequester()) { - GameObject fromGO = GraphElementIDMap.Find(FromId); - if (fromGO) - { - GameObject toGO = GraphElementIDMap.Find(ToId); - if (toGO) - { - GameEdgeAdder.Add(fromGO, toGO, EdgeType); - } - else - { - Debug.LogError($"There is no game node named {ToId} for the target of new edge {EdgeType}.\n"); - } - } - else - { - Debug.LogError($"There is no game node named {FromId} for the source of new edge {EdgeType}.\n"); - } + GameEdgeAdder.Add(Find(FromId), GraphElementIDMap.Find(ToId), EdgeType); } } } diff --git a/Assets/SEE/Net/Actions/AddNodeNetAction.cs b/Assets/SEE/Net/Actions/AddNodeNetAction.cs index 8a12c1dda2..53a3421cbc 100644 --- a/Assets/SEE/Net/Actions/AddNodeNetAction.cs +++ b/Assets/SEE/Net/Actions/AddNodeNetAction.cs @@ -1,4 +1,4 @@ -using SEE.Game; +using SEE.Game.SceneManipulation; using UnityEngine; namespace SEE.Net.Actions diff --git a/Assets/SEE/Net/Actions/DeleteNetAction.cs b/Assets/SEE/Net/Actions/DeleteNetAction.cs index 1e39122978..e32324a655 100644 --- a/Assets/SEE/Net/Actions/DeleteNetAction.cs +++ b/Assets/SEE/Net/Actions/DeleteNetAction.cs @@ -1,4 +1,5 @@ using SEE.Game; +using SEE.Game.SceneManipulation; using UnityEngine; namespace SEE.Net.Actions diff --git a/Assets/SEE/Net/Actions/MoveNetAction.cs b/Assets/SEE/Net/Actions/MoveNetAction.cs index a97db27055..8362336813 100644 --- a/Assets/SEE/Net/Actions/MoveNetAction.cs +++ b/Assets/SEE/Net/Actions/MoveNetAction.cs @@ -1,4 +1,5 @@ using SEE.Game; +using SEE.Game.SceneManipulation; using UnityEngine; namespace SEE.Net.Actions diff --git a/Assets/SEE/Net/Actions/PutOnAndFitNetAction.cs b/Assets/SEE/Net/Actions/PutOnAndFitNetAction.cs index 14744bee5f..b011efebfb 100644 --- a/Assets/SEE/Net/Actions/PutOnAndFitNetAction.cs +++ b/Assets/SEE/Net/Actions/PutOnAndFitNetAction.cs @@ -1,4 +1,5 @@ using SEE.Game; +using SEE.Game.SceneManipulation; using UnityEngine; namespace SEE.Net.Actions diff --git a/Assets/SEE/Net/Actions/ReviveNetAction.cs b/Assets/SEE/Net/Actions/ReviveNetAction.cs index 5da8003146..c4ada31951 100644 --- a/Assets/SEE/Net/Actions/ReviveNetAction.cs +++ b/Assets/SEE/Net/Actions/ReviveNetAction.cs @@ -1,4 +1,5 @@ using SEE.Game; +using SEE.Game.SceneManipulation; using SEE.Utils; using System.Collections.Generic; using UnityEngine; diff --git a/Assets/SEE/Net/Actions/SetParentNetAction.cs b/Assets/SEE/Net/Actions/SetParentNetAction.cs index d802eb8a47..b50eb99b46 100644 --- a/Assets/SEE/Net/Actions/SetParentNetAction.cs +++ b/Assets/SEE/Net/Actions/SetParentNetAction.cs @@ -1,4 +1,5 @@ using SEE.Game; +using SEE.Game.SceneManipulation; namespace SEE.Net.Actions { diff --git a/Assets/SEE/Net/Actions/VersionNetAction.cs b/Assets/SEE/Net/Actions/VersionNetAction.cs index e3a7906306..9020d5dbf2 100644 --- a/Assets/SEE/Net/Actions/VersionNetAction.cs +++ b/Assets/SEE/Net/Actions/VersionNetAction.cs @@ -1,5 +1,5 @@ using SEE.Game; -using UnityEngine; +using SEE.Game.SceneManipulation; namespace SEE.Net.Actions { From 832b437eee1a14e0263a092ab22b7b93e4f1c8ab Mon Sep 17 00:00:00 2001 From: Rainer Koschke Date: Thu, 17 Aug 2023 09:03:09 +0200 Subject: [PATCH 66/69] #599 Removed obsolete class. --- .../Editor/ArchitectureInteractionEditor.cs | 72 ------------------- .../ArchitectureInteractionEditor.cs.meta | 11 --- 2 files changed, 83 deletions(-) delete mode 100644 Assets/Editor/ArchitectureInteractionEditor.cs delete mode 100644 Assets/Editor/ArchitectureInteractionEditor.cs.meta diff --git a/Assets/Editor/ArchitectureInteractionEditor.cs b/Assets/Editor/ArchitectureInteractionEditor.cs deleted file mode 100644 index 478a74d019..0000000000 --- a/Assets/Editor/ArchitectureInteractionEditor.cs +++ /dev/null @@ -1,72 +0,0 @@ -using SEE.Game; -using SEE.Game.City; -using UnityEditor; -using UnityEngine; - -#if UNITY_EDITOR - -namespace SEEEditor -{ - /// - /// Editor for ArchitectureInteraction. - /// - //[Obsolete("Introduced only for capturing videos.")] - [CustomEditor(typeof(ArchitectureInteraction))] - public class ArchitectureInteractionEditor : Editor - { - public override void OnInspectorGUI() - { - ArchitectureInteraction animator = target as ArchitectureInteraction; - - animator.CodeCity = (SEECity)EditorGUILayout.ObjectField - (label: "Code City", - obj: animator.CodeCity, - objType: typeof(SEECity), - allowSceneObjects: true); - - EditorGUILayout.BeginHorizontal(); - GUILayout.Label("Implementation Edges"); - { - animator.ImplementationEdgesVisible = EditorGUILayout.Toggle(animator.ImplementationEdgesVisible); - animator.ImplementationEdgesStartColor = EditorGUILayout.ColorField(animator.ImplementationEdgesStartColor); - animator.ImplementationEdgesEndColor = EditorGUILayout.ColorField(animator.ImplementationEdgesEndColor); - animator.ImplementationEdgesWidth = EditorGUILayout.FloatField(animator.ImplementationEdgesWidth); - } - EditorGUILayout.EndHorizontal(); - - EditorGUILayout.BeginHorizontal(); - GUILayout.Label("Architecture Edges"); - { - animator.ArchitectureEdgesVisible = EditorGUILayout.Toggle(animator.ArchitectureEdgesVisible); - animator.ArchitectureEdgesStartColor = EditorGUILayout.ColorField(animator.ArchitectureEdgesStartColor); - animator.ArchitectureEdgesEndColor = EditorGUILayout.ColorField(animator.ArchitectureEdgesEndColor); - animator.ArchitectureEdgesWidth = EditorGUILayout.FloatField(animator.ArchitectureEdgesWidth); - } - EditorGUILayout.EndHorizontal(); - - EditorGUILayout.BeginHorizontal(); - GUILayout.Label("Reflexion Edges"); - { - animator.ReflexionEdgesVisible = EditorGUILayout.Toggle(animator.ReflexionEdgesVisible); - animator.ReflexionEdgesWidth = EditorGUILayout.FloatField(animator.ReflexionEdgesWidth); - } - EditorGUILayout.EndHorizontal(); - - EditorGUILayout.BeginHorizontal(); - { - GUILayout.Label("Architecture Nodes"); - animator.ArchitectureNodesVisible = EditorGUILayout.Toggle(animator.ArchitectureNodesVisible); - GUILayout.Label("Implementation Nodes"); - animator.ImplementationNodesVisible = EditorGUILayout.Toggle(animator.ImplementationNodesVisible); - } - EditorGUILayout.EndHorizontal(); - - if (GUILayout.Button("Update")) - { - animator.UpdateCity(); - } - } - } -} - -#endif \ No newline at end of file diff --git a/Assets/Editor/ArchitectureInteractionEditor.cs.meta b/Assets/Editor/ArchitectureInteractionEditor.cs.meta deleted file mode 100644 index 4119343cf8..0000000000 --- a/Assets/Editor/ArchitectureInteractionEditor.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 3ef6249495394044fbb78b81be55017b -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: From 2a69e52dcab8822e8cc516c92b6f3dd849035acb Mon Sep 17 00:00:00 2001 From: Rainer Koschke Date: Thu, 17 Aug 2023 09:06:56 +0200 Subject: [PATCH 67/69] #599 Removed obsolete class. --- Assets/SEE/Game/InteractionDecorator.cs | 2 - .../Game/SceneManipulation/GameNodeScaler.cs | 101 ------------------ .../SceneManipulation/GameNodeScaler.cs.meta | 11 -- 3 files changed, 114 deletions(-) delete mode 100644 Assets/SEE/Game/SceneManipulation/GameNodeScaler.cs delete mode 100644 Assets/SEE/Game/SceneManipulation/GameNodeScaler.cs.meta diff --git a/Assets/SEE/Game/InteractionDecorator.cs b/Assets/SEE/Game/InteractionDecorator.cs index 8ca06b2b95..2ee3d90228 100644 --- a/Assets/SEE/Game/InteractionDecorator.cs +++ b/Assets/SEE/Game/InteractionDecorator.cs @@ -1,7 +1,6 @@ using System.Collections.Generic; using SEE.Controls; using SEE.Controls.Actions; -using SEE.Game.SceneManipulation; using SEE.GO; using UnityEngine; @@ -41,7 +40,6 @@ public static void PrepareForInteraction(GameObject gameObject) gameObject.AddComponentIfNecessary(); if (gameObject.HasNodeRef()) { - gameObject.AddComponentIfNecessary(); gameObject.AddComponentIfNecessary(); gameObject.AddComponentIfNecessary(); gameObject.AddComponentIfNecessary(); diff --git a/Assets/SEE/Game/SceneManipulation/GameNodeScaler.cs b/Assets/SEE/Game/SceneManipulation/GameNodeScaler.cs deleted file mode 100644 index b037e27e04..0000000000 --- a/Assets/SEE/Game/SceneManipulation/GameNodeScaler.cs +++ /dev/null @@ -1,101 +0,0 @@ -using System.Collections.Generic; -using UnityEditor; -using UnityEngine; - -namespace SEE.Game.SceneManipulation -{ - /// - /// This GameNodeScaler allows us to scale a game node without modifying the - /// scale of its children. - /// - [ExecuteInEditMode] - public class GameNodeScaler : MonoBehaviour - { - /// - /// The target scale of the game object in world space co-ordinates. - /// - public Vector3 TargetScale; - - /// - /// Sets to the current scale of the game object. - /// - void Start() - { - Init(); - } - - /// - /// Sets to the current scale of the game object. - /// Called when the component is reset in the editor. - /// - void Reset() - { - Init(); - } - - private void Init() - { - TargetScale = transform.lossyScale; - enabled = false; - } - - /// - /// If has changed, the scale of the game object is set - /// to (in world space). The children of the game object - /// are not re-sized. - /// - void Update() - { - if (TargetScale != transform.lossyScale) - { - Debug.LogFormat("{0} original world scale = {1}; target world scale: {2}\n", - name, transform.lossyScale.ToString("F4"), TargetScale.ToString("F4")); - ScaleOnlyRootGameObject(gameObject, TargetScale); - -#if UNITY_EDITOR - EditorUtility.SetDirty(gameObject); - SceneView.RepaintAll(); -#endif - TargetScale = transform.lossyScale; - } - } - - /// - /// Resizes given to given - /// in world space without resizing any of its children. - /// - /// game object to be resized - /// the target scale in world-space co-ordinates - private static void ScaleOnlyRootGameObject(GameObject gameObject, Vector3 targetScale) - { - // The children of gameObject: - List children = new List(); - // Save the children of gameObject. - foreach (Transform child in gameObject.transform) - { - children.Add(child); - } - // Unparent all children of gameObject so that they do not scale along with gameObject. - foreach (Transform child in children) - { - child.parent = null; - } - { - // Resize gameObject and only gameObject in world space. - // The parent of gameObject (may be null): - Transform parent = gameObject.transform.parent; - // Unparent gameObject because targetScale is meant to be in world space. - gameObject.transform.parent = null; - // Resize gameObject. - gameObject.transform.localScale = targetScale; - // Re-parent gameObject. - gameObject.transform.parent = parent; - } - // Re-parent all children of gameObject. - foreach (Transform child in children) - { - child.parent = gameObject.transform; - } - } - } -} \ No newline at end of file diff --git a/Assets/SEE/Game/SceneManipulation/GameNodeScaler.cs.meta b/Assets/SEE/Game/SceneManipulation/GameNodeScaler.cs.meta deleted file mode 100644 index a304f1b36a..0000000000 --- a/Assets/SEE/Game/SceneManipulation/GameNodeScaler.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: a7be02c91dc83d3478cd70695ab975ad -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: From a8e1b6befa2c1c2464f974b935b99453d86d91d5 Mon Sep 17 00:00:00 2001 From: Rainer Koschke Date: Thu, 17 Aug 2023 09:37:41 +0200 Subject: [PATCH 68/69] #599 Use simplified new operator. --- Assets/SEE/Game/SceneManipulation/GameElementDeleter.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Assets/SEE/Game/SceneManipulation/GameElementDeleter.cs b/Assets/SEE/Game/SceneManipulation/GameElementDeleter.cs index fa789fbf2a..5f7aa824c7 100644 --- a/Assets/SEE/Game/SceneManipulation/GameElementDeleter.cs +++ b/Assets/SEE/Game/SceneManipulation/GameElementDeleter.cs @@ -106,7 +106,7 @@ private static (GraphElementsMemento, ISet) DeleteEdge(GameObject ga { // The edge memento must be created before the edge is removed; // otherwise ItsGraph would be null. - EdgeMemento edgeMemento = new EdgeMemento(edgeRef.Value); + EdgeMemento edgeMemento = new(edgeRef.Value); edgeRef.Value.ItsGraph.RemoveEdge(edgeRef.Value); GameObjectFader.FadingOut(gameEdge, SetInactive); return (edgeMemento, new HashSet() { gameEdge }); From eba445103a677b2077ce021912242e022af68eee Mon Sep 17 00:00:00 2001 From: Rainer Koschke Date: Thu, 17 Aug 2023 10:11:17 +0200 Subject: [PATCH 69/69] #599 Extracted class for code shared among AcceptDivergenceAction and AcceptDivergenceNetAction. --- .../Actions/AcceptDivergenceAction.cs | 9 +- .../SceneManipulation/AcceptDivergence.cs | 83 +++++++++++++++++++ .../AcceptDivergence.cs.meta | 11 +++ .../Net/Actions/AcceptDivergenceNetAction.cs | 36 +------- 4 files changed, 96 insertions(+), 43 deletions(-) create mode 100644 Assets/SEE/Game/SceneManipulation/AcceptDivergence.cs create mode 100644 Assets/SEE/Game/SceneManipulation/AcceptDivergence.cs.meta diff --git a/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs b/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs index 46af73a299..45197890f9 100644 --- a/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs +++ b/Assets/SEE/Controls/Actions/AcceptDivergenceAction.cs @@ -222,14 +222,7 @@ public override void Redo() /// the new edge's GameObject and a reference to itself, or both null private Edge CreateEdge(Memento memento) { - // create the edge beforehand - Edge newEdge = new(memento.from, memento.to, memento.type); - - // add the already created edge to the architecture graph - graph.AddToArchitecture(newEdge); - - // (re)draw the new edge - GameEdgeAdder.Draw(newEdge); + Edge newEdge = AcceptDivergence.Accept(memento.from, memento.to, memento.type); // propagate the edge (including matching ID) over network new AcceptDivergenceNetAction(memento.from.ID, memento.to.ID, newEdge.ID, newEdge.Type).Execute(); diff --git a/Assets/SEE/Game/SceneManipulation/AcceptDivergence.cs b/Assets/SEE/Game/SceneManipulation/AcceptDivergence.cs new file mode 100644 index 0000000000..34aec28767 --- /dev/null +++ b/Assets/SEE/Game/SceneManipulation/AcceptDivergence.cs @@ -0,0 +1,83 @@ +using SEE.DataModel.DG; +using SEE.GO; +using SEE.Tools.ReflexionAnalysis; +using UnityEngine; + +namespace SEE.Game.SceneManipulation +{ + /// + /// Adds an edge to a reflexion graph allowing a currently divergent implementation + /// dependency. + /// + public static class AcceptDivergence + { + /// + /// Adds a new edge of given from + /// to to the graph is contained in + /// via . Then the edge is + /// drawn. + /// + /// Preconditions: and both have + /// valid s that are in the same graph and this graph is a + /// . Given must be a unique + /// edge ID. + /// + /// the game object holding the source of the edge + /// the game object holding the target of the edge + /// the type of the edge + /// the unique ID the edge should have + /// the edge that was created and added to the graph + public static Edge Accept(GameObject from, GameObject to, string edgeType, string edgeId) + { + if (from.TryGetNode(out Node fromNode)) + { + if (to.TryGetNode(out Node toNode)) + { + return Accept(fromNode, toNode, edgeType, edgeId); + } + else + { + throw new System.Exception($"Game node {toNode.ID} has not graph node attached.\n"); + } + } + else + { + throw new System.Exception($"Game node {fromNode.ID} has not graph node attached.\n"); + } + } + + /// + /// Adds a new edge of given from + /// to to the graph is contained in + /// via . Then the edge is + /// drawn. + /// + /// Preconditions: and are in the + /// same graph and this graph is a . If + /// is given, it must be a unique edge ID. + /// + /// the source of the edge + /// the target of the edge + /// the type of the edge + /// the unique ID the edge should have; if null or empty + /// a unique ID will be created + /// the edge that was created and added to the graph + public static Edge Accept(Node from, Node to, string edgeType, string edgeId = null) + { + Edge result = new(from, to, edgeType); + + if (!string.IsNullOrEmpty(edgeId)) + { + result.ID = edgeId; + } + + if (from.ItsGraph is ReflexionGraph graph) + { + graph.AddToArchitecture(result); + } + + GameEdgeAdder.Draw(result); + return result; + } + } +} \ No newline at end of file diff --git a/Assets/SEE/Game/SceneManipulation/AcceptDivergence.cs.meta b/Assets/SEE/Game/SceneManipulation/AcceptDivergence.cs.meta new file mode 100644 index 0000000000..e442d446cf --- /dev/null +++ b/Assets/SEE/Game/SceneManipulation/AcceptDivergence.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e48734750aff8b2438f688d5e62c11c8 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/SEE/Net/Actions/AcceptDivergenceNetAction.cs b/Assets/SEE/Net/Actions/AcceptDivergenceNetAction.cs index 991ca8a405..e4e26df2dd 100644 --- a/Assets/SEE/Net/Actions/AcceptDivergenceNetAction.cs +++ b/Assets/SEE/Net/Actions/AcceptDivergenceNetAction.cs @@ -70,41 +70,7 @@ protected override void ExecuteOnClient() { if (!IsRequester()) { - GameObject fromGO = Find(FromId); - if (fromGO.TryGetNode(out Node fromNode)) - { - GameObject toGO = Find(ToId); - if (toGO.TryGetNode(out Node toNode)) - { - // FIXME: This code is very similar to AcceptDivergenceAction.CreateEdge. - // NetActions must be as dump as possible. All logic shared by these - // and their corresponding Action must be extracted to a separate class. - - // create the edge beforehand (to change its ID) - Edge edgeToPropagate = new(fromNode, toNode, Type) - { - // change the edges ID before adding it to a graph - ID = EdgeId - }; - - // add the already created edge to the architecture graph - if (fromNode.ItsGraph is ReflexionGraph graph) - { - graph.AddToArchitecture(edgeToPropagate); - } - - // (re)draw the new edge - GameEdgeAdder.Draw(edgeToPropagate); - } - else - { - Debug.LogError($"Game node {ToId} has not graph node attached.\n"); - } - } - else - { - Debug.LogError($"Game node {FromId} has not graph node attached.\n"); - } + AcceptDivergence.Accept(Find(FromId), Find(ToId), Type, EdgeId); } } }