]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
Sysdyn loops to work correctly with shadows (refs #4907).
authormiettinen <miettinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Tue, 27 May 2014 07:49:44 +0000 (07:49 +0000)
committermiettinen <miettinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Tue, 27 May 2014 07:49:44 +0000 (07:49 +0000)
Simulation Playback profile not as default active profile so the default active profile is Default with warnings on diagram (refs #4910).

git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@29548 ac1ea38d-2e2b-0410-8846-a27921b304fc

org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/LoopNode.java
org.simantics.sysdyn/src/org/simantics/sysdyn/utils/LoopUtils.java
org.simantics.sysdyn/src/org/simantics/sysdyn/utils/ProfileEntries.java

index 11c9c71fc4e0fa2bf2ecf53fefa0f8ad33740158..865ddf6586ea72d528a185d6f3b065db188f6641 100644 (file)
@@ -128,13 +128,16 @@ public class LoopNode extends HoverShapeNode {
 \r
                // Dependencies\r
                if (n instanceof ConnectionNode) {\r
-                       // See the first (and only) child of n has a DependencyNode as a child.\r
-                       n = ((ConnectionNode) n).getNodes().iterator().next();\r
-                       if (n instanceof ParentNode<?>) {\r
-                               nodeIds = ((ParentNode<?>)n).getNodeIds();\r
-                               for (String id : nodeIds) {\r
-                                       if (id.startsWith("edge_"))\r
-                                               return ((ParentNode<?>)n).getNode(id);\r
+                       // See the if a child of n has a DependencyNode as a child.\r
+                       Iterator<IG2DNode> it = ((ConnectionNode) n).getNodes().iterator();\r
+                       while (it.hasNext()) {\r
+                               n = it.next();\r
+                               if (n instanceof ParentNode<?>) {\r
+                                       nodeIds = ((ParentNode<?>)n).getNodeIds();\r
+                                       for (String id : nodeIds) {\r
+                                               if (id.startsWith("edge_"))\r
+                                                       return ((ParentNode<?>)n).getNode(id);\r
+                                       }\r
                                }\r
                        }\r
                }\r
@@ -179,6 +182,12 @@ public class LoopNode extends HoverShapeNode {
                                        \r
                                        // Go through forward dependencies and flows\r
                                        Collection<Resource> forwardDependencies = graph.getObjects(loopItems.get(i), sr.Variable_isTailOf);\r
+                                       \r
+                                       // And also through the forward dependencies of possible shadows.\r
+                                       Collection<Resource> shadows = graph.getObjects(loopItems.get(i), sr.Shadow_original_Inverse);\r
+                                       for (Resource shadow : shadows)\r
+                                               forwardDependencies.addAll(graph.getObjects(shadow, sr.Variable_isTailOf));\r
+                                               \r
                                        for (Resource dependency : forwardDependencies) {\r
                                                Resource dependingVariable = graph.getSingleObject(dependency, sr.Variable_HasHead);\r
                                                if (dependingVariable.equals(loopItems.get((i + 1) % loopItems.size()))) {\r
index bd3d9095ea875db5c5a90062a949903b18e80c12..731151f15ca64aba870d2e774edb947ca6a63c98 100644 (file)
@@ -270,6 +270,12 @@ public class LoopUtils {
                \r
                // Go through forward dependencies and flows\r
                Collection<Resource> forwardDependencies = graph.getObjects(loop.get(i), sr.Variable_isTailOf);\r
+               \r
+               // And also through the forward dependencies of possible shadows.\r
+               Collection<Resource> shadows = graph.getObjects(loop.get(i), sr.Shadow_original_Inverse);\r
+               for (Resource shadow : shadows)\r
+                       forwardDependencies.addAll(graph.getObjects(shadow, sr.Variable_isTailOf));\r
+               \r
                for (Resource dependency : forwardDependencies) {\r
                        Resource dependingVariable = graph.getSingleObject(dependency, sr.Variable_HasHead);\r
                        if (dependingVariable.equals(loop.get((i + 1) % loop.size()))) {\r
index cb18b8682bafa6cc414a992296754ee82966d92f..0856f36bf1af8e71097500b2932938d09c220c85 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************\r
- * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
+ * Copyright (c) 2007, 2011, 2014 Association for Decentralized Information Management in\r
  * Industry THTH ry.\r
  * All rights reserved. This program and the accompanying materials\r
  * are made available under the terms of the Eclipse Public License v1.0\r
@@ -47,7 +47,6 @@ public class ProfileEntries  {
                 SimulationResource SIMU = SimulationResource.getInstance(graph);\r
                 graph.claim(defaultProfile, SIMU.IsActive, null, sr.Profiles_IssueWarnings);\r
                 graph.claim(defaultProfile, SIMU.IsActive, null, sr.Profiles_ShadowVisualizations);\r
-                graph.claim(model, DIA.HasActiveProfile, simulationPlaybackProfile);\r
                 graph.claim(simulationPlaybackProfile, SIMU.IsActive, null, sr.Profiles_SimulationPlaybackColours);\r
                 \r
 //            }\r