From 28353640bd6d81bb1d506430a64ddd926a3f798a Mon Sep 17 00:00:00 2001 From: miettinen Date: Tue, 27 May 2014 07:49:44 +0000 Subject: [PATCH] Sysdyn loops to work correctly with shadows (refs #4907). 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 --- .../sysdyn/ui/elements/LoopNode.java | 23 +++++++++++++------ .../org/simantics/sysdyn/utils/LoopUtils.java | 6 +++++ .../sysdyn/utils/ProfileEntries.java | 3 +-- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/LoopNode.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/LoopNode.java index 11c9c71f..865ddf65 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/LoopNode.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/LoopNode.java @@ -128,13 +128,16 @@ public class LoopNode extends HoverShapeNode { // Dependencies if (n instanceof ConnectionNode) { - // See the first (and only) child of n has a DependencyNode as a child. - n = ((ConnectionNode) n).getNodes().iterator().next(); - if (n instanceof ParentNode) { - nodeIds = ((ParentNode)n).getNodeIds(); - for (String id : nodeIds) { - if (id.startsWith("edge_")) - return ((ParentNode)n).getNode(id); + // See the if a child of n has a DependencyNode as a child. + Iterator it = ((ConnectionNode) n).getNodes().iterator(); + while (it.hasNext()) { + n = it.next(); + if (n instanceof ParentNode) { + nodeIds = ((ParentNode)n).getNodeIds(); + for (String id : nodeIds) { + if (id.startsWith("edge_")) + return ((ParentNode)n).getNode(id); + } } } } @@ -179,6 +182,12 @@ public class LoopNode extends HoverShapeNode { // Go through forward dependencies and flows Collection forwardDependencies = graph.getObjects(loopItems.get(i), sr.Variable_isTailOf); + + // And also through the forward dependencies of possible shadows. + Collection shadows = graph.getObjects(loopItems.get(i), sr.Shadow_original_Inverse); + for (Resource shadow : shadows) + forwardDependencies.addAll(graph.getObjects(shadow, sr.Variable_isTailOf)); + for (Resource dependency : forwardDependencies) { Resource dependingVariable = graph.getSingleObject(dependency, sr.Variable_HasHead); if (dependingVariable.equals(loopItems.get((i + 1) % loopItems.size()))) { diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/utils/LoopUtils.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/utils/LoopUtils.java index bd3d9095..731151f1 100644 --- a/org.simantics.sysdyn/src/org/simantics/sysdyn/utils/LoopUtils.java +++ b/org.simantics.sysdyn/src/org/simantics/sysdyn/utils/LoopUtils.java @@ -270,6 +270,12 @@ public class LoopUtils { // Go through forward dependencies and flows Collection forwardDependencies = graph.getObjects(loop.get(i), sr.Variable_isTailOf); + + // And also through the forward dependencies of possible shadows. + Collection shadows = graph.getObjects(loop.get(i), sr.Shadow_original_Inverse); + for (Resource shadow : shadows) + forwardDependencies.addAll(graph.getObjects(shadow, sr.Variable_isTailOf)); + for (Resource dependency : forwardDependencies) { Resource dependingVariable = graph.getSingleObject(dependency, sr.Variable_HasHead); if (dependingVariable.equals(loop.get((i + 1) % loop.size()))) { diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/utils/ProfileEntries.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/utils/ProfileEntries.java index cb18b868..0856f36b 100644 --- a/org.simantics.sysdyn/src/org/simantics/sysdyn/utils/ProfileEntries.java +++ b/org.simantics.sysdyn/src/org/simantics/sysdyn/utils/ProfileEntries.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2011 Association for Decentralized Information Management in + * Copyright (c) 2007, 2011, 2014 Association for Decentralized Information Management in * Industry THTH ry. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -47,7 +47,6 @@ public class ProfileEntries { SimulationResource SIMU = SimulationResource.getInstance(graph); graph.claim(defaultProfile, SIMU.IsActive, null, sr.Profiles_IssueWarnings); graph.claim(defaultProfile, SIMU.IsActive, null, sr.Profiles_ShadowVisualizations); - graph.claim(model, DIA.HasActiveProfile, simulationPlaybackProfile); graph.claim(simulationPlaybackProfile, SIMU.IsActive, null, sr.Profiles_SimulationPlaybackColours); // } -- 2.47.1