From 4e9851013456ea1a8aa20eee5e33ccb97eed03ef Mon Sep 17 00:00:00 2001 From: Reino Ruusu Date: Thu, 6 Jun 2019 12:53:33 +0300 Subject: [PATCH] Enable static info labels for vertex elements gitlab #47 APROS-15309 Change-Id: If37d3256d6bed52a444573e957c47b9997abcb6a --- .../nodes/DistrictNetworkStaticInfoStyle.java | 53 +++++++++++++------ .../scl/Simantics/District/Algorithm.scl | 14 +++++ 2 files changed, 50 insertions(+), 17 deletions(-) diff --git a/org.simantics.district.network.ui/src/org/simantics/district/network/ui/nodes/DistrictNetworkStaticInfoStyle.java b/org.simantics.district.network.ui/src/org/simantics/district/network/ui/nodes/DistrictNetworkStaticInfoStyle.java index 49d524a4..20e8ecbc 100644 --- a/org.simantics.district.network.ui/src/org/simantics/district/network/ui/nodes/DistrictNetworkStaticInfoStyle.java +++ b/org.simantics.district.network.ui/src/org/simantics/district/network/ui/nodes/DistrictNetworkStaticInfoStyle.java @@ -55,13 +55,17 @@ public class DistrictNetworkStaticInfoStyle extends StyleBase edgesToUse = graph.syncRequest(new MidBranchEdgeSetRequest(diagram), TransientCacheListener.instance()); - if (!edgesToUse.contains(mapElement)) - return null; + if (isEdge) { + Resource diagram = graph.getSingleObject(mapElement, Layer0.getInstance(graph).PartOf); + Set edgesToUse = graph.syncRequest(new MidBranchEdgeSetRequest(diagram), TransientCacheListener.instance()); + if (!edgesToUse.contains(mapElement)) + return null; + } DiagramResource DIA = DiagramResource.getInstance(graph); StructuralResource2 STR = StructuralResource2.getInstance(graph); @@ -90,14 +94,23 @@ public class DistrictNetworkStaticInfoStyle extends StyleBase print "* e\(i): \(s)") +""" +Get a set of vertices that acts as break points between network branches. +""" +branchPoints :: Resource -> [Resource] +branchPoints networkDiagram = runProc let + in + filter isBranchPoint vertices + where + all = if isInstanceOf networkDiagram DIA.Diagram + then networkDiagram # L0.ConsistsOf + else singleObject networkDiagram MOD.CompositeToDiagram # L0.ConsistsOf + vertices = filter (flip isInstanceOf DN.Vertex) all + isBranchPoint v = length (v # DN.HasEndVertex_Inverse) != 1 || length (v # DN.HasStartVertex_Inverse) != 1 + """ Get a set of the edges that are at the middle points of each span between branch points. """ -- 2.47.1