]> gerrit.simantics Code Review - simantics/district.git/commitdiff
Move remaining profiles to visualisations for perf 45/3845/1
authorjsimomaa <jani.simomaa@gmail.com>
Wed, 19 Feb 2020 08:00:20 +0000 (10:00 +0200)
committerTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Wed, 19 Feb 2020 14:54:33 +0000 (14:54 +0000)
* Static property information
* Dynamic symbols
* Not in simulation
* Elevation server bounding box

gitlab #59

Change-Id: Ia17e7fe59042edcd71426e91c7d8ad5f9996c7c3
(cherry picked from commit 3730466cd1e90c50c988292e107639952448d6a6)

22 files changed:
org.simantics.district.network.ontology/graph/DistrictNetwork.pgraph
org.simantics.district.network.ontology/graph/DistrictNetworkProfiles.pgraph
org.simantics.district.network.ui/META-INF/MANIFEST.MF
org.simantics.district.network.ui/adapters.xml
org.simantics.district.network.ui/src/org/simantics/district/network/ui/DistrictDiagramViewer.java
org.simantics.district.network.ui/src/org/simantics/district/network/ui/nodes/DistrictNetworkEdgeArrayNode.java
org.simantics.district.network.ui/src/org/simantics/district/network/ui/nodes/DistrictNetworkEdgeNode.java
org.simantics.district.network.ui/src/org/simantics/district/network/ui/nodes/DistrictNetworkVertexNode.java
org.simantics.district.network.ui/src/org/simantics/district/network/ui/nodes/NotInSimulationNode.java [new file with mode: 0644]
org.simantics.district.network.ui/src/org/simantics/district/network/ui/participants/DynamicVisualisationContributionsParticipant.java
org.simantics.district.network.ui/src/org/simantics/district/network/ui/participants/ElevationServerParticipant.java [deleted file]
org.simantics.district.network.ui/src/org/simantics/district/network/ui/styles/DistrictNetworkStaticInfoStyle.java
org.simantics.district.network.ui/src/org/simantics/district/network/ui/visualisations/DynamicVisualisationsUI.java
org.simantics.district.network/adapters.xml
org.simantics.district.network/scl/Simantics/District/DynamicVisualisations/StaticDynamicContribution.scl [new file with mode: 0644]
org.simantics.district.network/src/org/simantics/district/network/profile/ActiveDynamicVisualisationsRequest.java
org.simantics.district.network/src/org/simantics/district/network/profile/VertexSymbolStyle.java
org.simantics.district.network/src/org/simantics/district/network/visualisations/DynamicVisualisations.java
org.simantics.district.network/src/org/simantics/district/network/visualisations/DynamicVisualisationsContributions.java
org.simantics.district.network/src/org/simantics/district/network/visualisations/model/DynamicSymbolContribution.java [new file with mode: 0644]
org.simantics.district.network/src/org/simantics/district/network/visualisations/model/DynamicVisualisation.java
org.simantics.district.network/src/org/simantics/district/network/visualisations/model/StaticInformationContribution.java [new file with mode: 0644]

index 87547328b36afa7ea002841b4c35d1eb28e3fc8b..4405434e33f6707bdcfc9e7c88125114322b88f2 100644 (file)
@@ -279,6 +279,10 @@ DN.Diagram.Visualisations <T L0.Entity
         @defProperty "Key Variables for Vertices on Hover" L0.Boolean
     >-- DN.Diagram.Visualisations.KeyVariableEdgeHover
         @defProperty "Key Variables for Edges on Hover" L0.Boolean
+    >-- DN.Diagram.Visualisations.ShowElevationServerBoundingBox
+        @defProperty "Show Elevation server bounding box" L0.Boolean
+    >-- DN.Diagram.Visualisations.NotInSimulation
+        @defProperty "Not in Simulation" L0.Boolean
 
 DN.Diagram.Visualisations.ColorContribution <T L0.Entity
 DN.Diagram.Visualisations.SizeContribution <T L0.Entity
index 56488bface216ef92297291f6d6b89b37af0e7e6..0bac7530ad2783c2cac5b988d06a57536a7a3185 100644 (file)
@@ -27,12 +27,12 @@ DN.Groups.EdgeGroup : DIA.TypeGroup
 
 //DN.ArrowLengthStyle : DIA.Style
 //DN.HideStyle : DIA.Style
-DN.VertexSymbolStyle : DIA.Style
+//DN.VertexSymbolStyle : DIA.Style
 DN.ConnectionLineStyle : DIA.Style
-DN.ElevationRectangleStyle : DIA.Style
+//DN.ElevationRectangleStyle : DIA.Style
 
 // Style for user component-specified static info text for network branches
-DN.DistrictNetworkStaticInfoStyle : DIA.Style
+//DN.DistrictNetworkStaticInfoStyle : DIA.Style
 
 // Function for dynamic selection of symbols for a vertex
 // The input of the function is a DN.Vertex
index 9399017efb7fe373f6488b058b2098c30fa4bc58..8802b40e2c40a32aad2e7cabeac9ddb4cb2a32c5 100644 (file)
@@ -9,7 +9,8 @@ Export-Package: org.simantics.district.network.ui,
  org.simantics.district.network.ui.breakdown,
  org.simantics.district.network.ui.function,
  org.simantics.district.network.ui.nodes,
- org.simantics.district.network.ui.participants
+ org.simantics.district.network.ui.participants,
+ org.simantics.district.network.ui.styles
 Require-Bundle: org.eclipse.e4.ui.model.workbench;bundle-version="1.1.100.v20150407-1430",
  org.eclipse.swt,
  org.simantics.g2d,
index 1699360561e87f6370fde46c874eee953ea5c1d5..8702a82d5321813097e5b87e1df18892d52a622c 100644 (file)
         <resource uri="http://www.simantics.org/DistrictNetwork-1.0/ConnectionLineStyle"
             class="org.simantics.district.network.ui.styles.ConnectionLineStyle">
         </resource>
-        <resource uri="http://www.simantics.org/DistrictNetwork-1.0/DistrictNetworkStaticInfoStyle"
-            class="org.simantics.district.network.ui.styles.DistrictNetworkStaticInfoStyle">
-            <this />
-        </resource>
-        <resource uri="http://www.simantics.org/DistrictNetwork-1.0/ElevationRectangleStyle"
-            class="org.simantics.district.network.ui.styles.ElevationRectangleStyle">
-        </resource>
     </target>
     
     <target interface="org.simantics.g2d.diagram.DiagramClass">
index 903c2ffa3223b74c251d25154adab949e0a6470b..198389551768a250b22c6be34a293f6f99ba2acb 100644 (file)
@@ -24,7 +24,6 @@ import org.simantics.district.network.ui.nodes.DistrictRenderingPreparationNode;
 import org.simantics.district.network.ui.nodes.DistrictSelectionNode;
 import org.simantics.district.network.ui.participants.DNPointerInteractor;
 import org.simantics.district.network.ui.participants.DynamicVisualisationContributionsParticipant;
-import org.simantics.district.network.ui.participants.ElevationServerParticipant;
 import org.simantics.district.network.ui.participants.MapRulerPainter;
 import org.simantics.district.network.visualisations.DynamicVisualisations;
 import org.simantics.district.network.visualisations.model.ColorBarOptions;
@@ -76,7 +75,6 @@ public class DistrictDiagramViewer extends DiagramViewer {
         
         DynamicVisualisationContributionsParticipant dynamicVisualisationContributionsParticipant = new DynamicVisualisationContributionsParticipant(tr);
         ctx.add(new NetworkDrawingParticipant(dynamicVisualisationContributionsParticipant, tr));
-        ctx.add(new ElevationServerParticipant(tr));
         ctx.add(dynamicVisualisationContributionsParticipant);
         
         // Optimize AffineTransform memory allocations during district diagram rendering
@@ -142,6 +140,7 @@ public class DistrictDiagramViewer extends DiagramViewer {
         setupColorBarOptions();
         setupSizingObjects();
         setupSizeBarOptions();
+        setupShowElevationServerBoundingBox();
         
         // add listeners
         DistrictDiagramViewerListener[] listeners = Activator.getInstance().getDistrictDiagramViewerListeners();
@@ -203,13 +202,18 @@ public class DistrictDiagramViewer extends DiagramViewer {
                 () -> DistrictDiagramViewer.this.isDisposed()));
     }
 
-    
     private void setupSizeBarOptions() {
         sessionContext.getSession().asyncRequest(new SizeBarOptionsRequest(getInputResource()), new SizeBarOptionsListener(
                 result -> queueSizeBarOptionsChangeEvent(result),
                 () -> DistrictDiagramViewer.this.isDisposed()));
     }
-    
+
+    private void setupShowElevationServerBoundingBox() {
+        sessionContext.getSession().asyncRequest(new ShowElevationServerRequest(getInputResource()), new ShowElevationServerListener(
+                result -> queueShowElevationServerChangeEvent(result),
+                () -> DistrictDiagramViewer.this.isDisposed()));
+    }
+
     public static final Key KEY_MAP_COLOR_BAR_OPTIONS = new KeyOf(ColorBarOptions.class, "colorBarOptions");
     public static final Command MAP_COLOR_BAR_OPTIONS_CHANGE = new Command("colorBarOptionsChange");
     public static final Key KEY_MAP_SIZE_BAR_OPTIONS = new KeyOf(SizeBarOptions.class, "sizeBarOptions");
@@ -221,11 +225,13 @@ public class DistrictDiagramViewer extends DiagramViewer {
     public static final Key KEY_MAP_SIZING_OBJECTS = new KeyOf(Map.class, "sizingObjects");
     public static final Command MAP_SIZING_OBJECTS_CHANGE = new Command("sizingObjectsChange");
 
-    
+    public static final Key KEY_SHOW_ELEVATION_SERVER = new KeyOf(Boolean.class, "showElevationServer");
+    public static final Command SHOW_ELEVATION_SERVER_CHANGE = new Command("showElevationServerChange");
+
     private void queueColoringObjectsChangeEvent(Map<String, DynamicColorContribution> result) {
         queueEventInternal(KEY_MAP_COLORING_OBJECTS, MAP_COLORING_OBJECTS_CHANGE, result);
     }
-    
+
     private void queueColorBarOptionsChangeEvent(ColorBarOptions result) {
         queueEventInternal(KEY_MAP_COLOR_BAR_OPTIONS, MAP_COLOR_BAR_OPTIONS_CHANGE, result);
     }
@@ -233,11 +239,15 @@ public class DistrictDiagramViewer extends DiagramViewer {
     private void queueSizingObjectsChangeEvent(Map<String, DynamicSizeContribution> result) {
         queueEventInternal(KEY_MAP_SIZING_OBJECTS, MAP_SIZING_OBJECTS_CHANGE, result);
     }
-    
+
     private void queueSizeBarOptionsChangeEvent(SizeBarOptions result) {
         queueEventInternal(KEY_MAP_SIZE_BAR_OPTIONS, MAP_SIZE_BAR_OPTIONS_CHANGE, result);
     }
 
+    private void queueShowElevationServerChangeEvent(Boolean result) {
+        queueEventInternal(KEY_SHOW_ELEVATION_SERVER, SHOW_ELEVATION_SERVER_CHANGE, result);
+    }
+
     private void queueEventInternal(Key key, Command command, Object result) {
         if (result != null && !canvasContext.isDisposed()) {
             canvasContext.getThreadAccess().asyncExec(() -> {
@@ -411,7 +421,7 @@ public class DistrictDiagramViewer extends DiagramViewer {
 
         @Override
         public void exception(Throwable t) {
-            LOGGER.error("Could not listen ColorBarOptions", t);
+            LOGGER.error("Could not listen ColoringObjects", t);
         }
 
         @Override
@@ -545,7 +555,60 @@ public class DistrictDiagramViewer extends DiagramViewer {
 
         @Override
         public void exception(Throwable t) {
-            LOGGER.error("Could not listen ColorBarOptions", t);
+            LOGGER.error("Could not listen SizingObjectsOptions", t);
+        }
+
+        @Override
+        public boolean isDisposed() {
+            return isDisposed.get();
+        }
+    }
+
+    private static class ShowElevationServerRequest extends UnaryRead<Resource, Boolean> {
+
+        public ShowElevationServerRequest(Resource diagram) {
+            super(diagram);
+        }
+
+        @Override
+        public Boolean perform(ReadGraph graph) throws DatabaseException {
+            DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph);
+            Resource model = graph.syncRequest(new PossibleIndexRoot(parameter));
+            if (model != null) {
+                Resource vf = DynamicVisualisations.getVisualisationFolder(graph, model);
+                if (vf != null) {
+                    Resource activeVisualisation = graph.getPossibleObject(vf, DN.Diagram_hasActiveVisualisation);
+                    if (activeVisualisation != null) {
+                        return DynamicVisualisations.showElevationServerBoundingBox(graph, activeVisualisation);
+                    }
+                } else {
+                    LOGGER.debug("No visualisation folder available for model {}", model);
+                }
+            }
+            return false;
+        }
+    }
+    
+    private static class ShowElevationServerListener implements Listener<Boolean> {
+
+        private static final Logger LOGGER = LoggerFactory.getLogger(ShowElevationServerListener.class);
+
+        private Consumer<Boolean> callback;
+        private Supplier<Boolean> isDisposed;
+
+        public ShowElevationServerListener(Consumer<Boolean> callback, Supplier<Boolean> isDisposed) {
+            this.callback = callback;
+            this.isDisposed = isDisposed;
+        }
+
+        @Override
+        public void execute(Boolean result) {
+            callback.accept(result);
+        }
+
+        @Override
+        public void exception(Throwable t) {
+            LOGGER.error("Could not listen Show Elevation Server", t);
         }
 
         @Override
index c387c435f4b9babda1b020f9e03c85fd017fc595..a28abada5b88f5f1f0c08365d418fa9f55ad7994 100644 (file)
@@ -30,7 +30,7 @@ public class DistrictNetworkEdgeArrayNode extends G2DNode implements DeferredNod
     @Override
     public void render(Graphics2D g2d) {
         ParentNode<?> root = (ParentNode<?>) NodeUtil.getNearestParentOfType(this, RTreeNode.class);
-        DeferredRenderingNode deferred = root != null ? (DeferredRenderingNode) root.getNode(DistrictNetworkStaticInfoStyle.STATIC_INFO_DEFERRED) : null;
+        DeferredRenderingNode deferred = root != null ? (DeferredRenderingNode) root.getNode(RENDERER_ID) : null;
         if (deferred != null)
             deferred.deferNode(g2d.getTransform(), this);
         else
index 195472fcd2474b0b060de1df3b032c350c672c5e..4d460f5d13bf5c8615bd6a26edc2f8ba66210462 100644 (file)
@@ -5,10 +5,10 @@ import java.awt.Color;
 import java.awt.Graphics2D;
 import java.awt.RenderingHints;
 import java.awt.geom.AffineTransform;
-import java.awt.geom.Line2D;
 import java.awt.geom.Path2D;
 import java.awt.geom.Point2D;
 import java.awt.geom.Rectangle2D;
+import java.util.Optional;
 
 import org.simantics.district.network.ModelledCRS;
 import org.simantics.district.network.ui.DistrictNetworkEdge;
@@ -290,4 +290,24 @@ public class DistrictNetworkEdgeNode extends G2DParentNode implements ISelection
         this.hidden = value;
     }
 
+    public void setStaticInformation(Optional<String> staticInformation) {
+        DistrictNetworkStaticInfoNode child = getOrCreateNode(DistrictNetworkStaticInfoNode.NODE_KEY, DistrictNetworkStaticInfoNode.class);
+        child.setEdgeNode(this);
+        if (staticInformation.isPresent()) {
+            child.setInfo(staticInformation.get());
+        } else {
+            child.setInfo(null);
+        }
+    }
+
+    public void setInSimulation(Optional<Boolean> isInSimulation) {
+        if (!isInSimulation.isPresent()) {
+            removeNode(NotInSimulationNode.NODE_NAME);
+        } else {
+            NotInSimulationNode child = getOrCreateNode(NotInSimulationNode.NODE_NAME, NotInSimulationNode.class);
+            child.setZIndex(1000);
+            child.setIsInSimulation(isInSimulation.get());
+        }
+    }
+
 }
index 76151a83fd879b41b1fc8ce7e528f7f6d59d60f8..b1bb1468dd63653ee1c423a9653fbc307088bc8e 100644 (file)
@@ -7,6 +7,7 @@ import java.awt.RenderingHints;
 import java.awt.geom.AffineTransform;
 import java.awt.geom.Point2D;
 import java.awt.geom.Rectangle2D;
+import java.util.Optional;
 
 import org.simantics.district.network.ui.adapters.DistrictNetworkVertex;
 import org.simantics.maps.MapScalingTransform;
@@ -245,4 +246,25 @@ public class DistrictNetworkVertexNode extends G2DParentNode implements ISelecti
     public void setHidden(Boolean value) {
         this.hidden = value;
     }
+
+    public void setStaticInformation(Optional<String> staticInformation) {
+        DistrictNetworkStaticInfoNode child = getOrCreateNode(DistrictNetworkStaticInfoNode.NODE_KEY, DistrictNetworkStaticInfoNode.class);
+        Point2D calculatePoint2D = DistrictNetworkNodeUtils.calculatePoint2D(vertex.getPoint(), null);
+        child.setLocation(calculatePoint2D, new Point2D.Double(1.0, 0.0));
+        if (staticInformation.isPresent()) {
+            child.setInfo(staticInformation.get());
+        } else {
+            child.setInfo(null);
+        }
+    }
+    
+    public void setInSimulation(Optional<Boolean> isInSimulation) {
+        if (!isInSimulation.isPresent()) {
+            removeNode(NotInSimulationNode.NODE_NAME);
+        } else {
+            NotInSimulationNode child = getOrCreateNode(NotInSimulationNode.NODE_NAME, NotInSimulationNode.class);
+            child.setZIndex(1000);
+            child.setIsInSimulation(isInSimulation.get());
+        }
+    }
 }
diff --git a/org.simantics.district.network.ui/src/org/simantics/district/network/ui/nodes/NotInSimulationNode.java b/org.simantics.district.network.ui/src/org/simantics/district/network/ui/nodes/NotInSimulationNode.java
new file mode 100644 (file)
index 0000000..b0db41c
--- /dev/null
@@ -0,0 +1,53 @@
+package org.simantics.district.network.ui.nodes;
+
+import java.awt.BasicStroke;
+import java.awt.Color;
+import java.awt.geom.Rectangle2D;
+
+import org.simantics.scenegraph.ParentNode;
+import org.simantics.scenegraph.g2d.G2DNode;
+import org.simantics.scenegraph.utils.GeometryUtils;
+
+public class NotInSimulationNode extends G2DNode {
+
+    private static final BasicStroke STROKE = new BasicStroke(1.5f);
+    public static final String NODE_NAME = "notInSimulation";
+
+    private static final long serialVersionUID = 1503248449618244809L;
+    private boolean isInSimulation;
+
+    @Override
+    public Rectangle2D getBoundsInLocal() {
+        return null;
+    }
+
+    @Override
+    public Rectangle2D getBoundsInLocal(boolean b) {
+        return null;
+    }
+
+    @Override
+    public Rectangle2D getBounds() {
+        return null;
+    }
+    
+    public void render(java.awt.Graphics2D g) {
+        if (!isInSimulation) {
+            ParentNode<?> parent = getParent();
+            if (!(parent instanceof DistrictNetworkVertexNode))
+                return;
+            
+            Rectangle2D bounds = ((DistrictNetworkVertexNode)parent).getBoundsInLocal();
+            Rectangle2D expandedBounds = GeometryUtils.expandRectangle( bounds, bounds.getWidth() / 2 );
+            
+            g.setColor(Color.RED);
+            g.setStroke(GeometryUtils.scaleStroke(STROKE, 1.f / (float)g.getTransform().getScaleX()));
+            g.draw(expandedBounds);
+        }
+    }
+
+    public void setIsInSimulation(boolean isInSimulation) {
+        this.isInSimulation = isInSimulation;
+    }
+
+}
index 36eaaf619f618e8e0bd9d572018e8ce7a251e2c2..8ddb04916cefa70da43cc3d49079e233a24f7cee 100644 (file)
@@ -2,6 +2,9 @@ package org.simantics.district.network.ui.participants;
 
 import java.awt.geom.AffineTransform;
 import java.awt.geom.Point2D;
+import java.awt.geom.Rectangle2D;
+import java.util.Collection;
+import java.util.Collections;
 import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.CompletableFuture;
@@ -21,6 +24,7 @@ import org.simantics.district.network.ui.nodes.DeferredRenderingNode;
 import org.simantics.district.network.ui.nodes.DistrictNetworkEdgeArrayNode;
 import org.simantics.district.network.ui.nodes.DistrictNetworkHoverInfoNode;
 import org.simantics.district.network.ui.nodes.DynamicVisualisationContributionsNode;
+import org.simantics.district.network.ui.nodes.ElevationServerNode;
 import org.simantics.district.network.ui.styles.DistrictNetworkHoverInfoStyle;
 import org.simantics.district.network.ui.styles.DistrictNetworkHoverInfoStyle.StyleResult;
 import org.simantics.district.network.visualisations.model.ColorBarOptions;
@@ -31,6 +35,7 @@ import org.simantics.district.network.visualisations.model.SizeBarOptions;
 import org.simantics.g2d.canvas.ICanvasContext;
 import org.simantics.g2d.canvas.impl.AbstractCanvasParticipant;
 import org.simantics.g2d.canvas.impl.SGNodeReflection.SGInit;
+import org.simantics.maps.elevation.server.SingletonTiffTileInterface;
 import org.simantics.scenegraph.INode;
 import org.simantics.scenegraph.g2d.G2DParentNode;
 import org.simantics.scenegraph.g2d.events.EventHandlerReflection.EventHandler;
@@ -64,6 +69,8 @@ public class DynamicVisualisationContributionsParticipant extends AbstractCanvas
     private DistrictNetworkHoverInfoNode hoverInfoNode;
     private DeferredRenderingNode deferredEdgeArrowRendererNode;
 
+    private ElevationServerNode showElevationServerBoundingBoxNode;
+
     public DynamicVisualisationContributionsParticipant(AffineTransform tr) {
         this.transform = tr;
     }
@@ -75,6 +82,7 @@ public class DynamicVisualisationContributionsParticipant extends AbstractCanvas
         getHintStack().addKeyHintListener(getThread(), DistrictDiagramViewer.KEY_MAP_COLOR_BAR_OPTIONS, hintListener);
         getHintStack().addKeyHintListener(getThread(), DistrictDiagramViewer.KEY_MAP_SIZING_OBJECTS, hintListener);
         getHintStack().addKeyHintListener(getThread(), DistrictDiagramViewer.KEY_MAP_SIZE_BAR_OPTIONS, hintListener);
+        getHintStack().addKeyHintListener(getThread(), DistrictDiagramViewer.KEY_SHOW_ELEVATION_SERVER, hintListener);
     }
 
     @Override
@@ -88,6 +96,7 @@ public class DynamicVisualisationContributionsParticipant extends AbstractCanvas
         getHintStack().removeKeyHintListener(getThread(), DistrictDiagramViewer.KEY_MAP_COLOR_BAR_OPTIONS, hintListener);
         getHintStack().removeKeyHintListener(getThread(), DistrictDiagramViewer.KEY_MAP_SIZING_OBJECTS, hintListener);
         getHintStack().removeKeyHintListener(getThread(), DistrictDiagramViewer.KEY_MAP_SIZE_BAR_OPTIONS, hintListener);
+        getHintStack().removeKeyHintListener(getThread(), DistrictDiagramViewer.KEY_SHOW_ELEVATION_SERVER, hintListener);
         super.removedFromContext(ctx);
     }
 
@@ -105,6 +114,9 @@ public class DynamicVisualisationContributionsParticipant extends AbstractCanvas
         
         Pair<String, Class<DeferredRenderingNode>> dearn = DistrictNetworkEdgeArrayNode.renderer();
         deferredEdgeArrowRendererNode = parent.addNode(dearn.first, dearn.second);
+        
+        showElevationServerBoundingBoxNode = parent.addNode(ElevationServerNode.ID, ElevationServerNode.class);
+        showElevationServerBoundingBoxNode.setTransform(transform);
     }
 
     @EventHandler(priority = 0)
@@ -121,6 +133,15 @@ public class DynamicVisualisationContributionsParticipant extends AbstractCanvas
         node.setColorBarOptions(getColorBarOptions());
         node.setDynamicSizingObjects(getDynamicSizingObjects());
         node.setSizeBarOptions(getSizeBarOptions());
+        
+        showElevationServerBoundingBoxNode.setRectangles(getRectangles());
+    }
+
+    private Collection<Rectangle2D> getRectangles() {
+        Boolean enabled = getHint(DistrictDiagramViewer.KEY_SHOW_ELEVATION_SERVER);
+        if (enabled != null && enabled)
+            return SingletonTiffTileInterface.getBoundingBoxes();
+        return Collections.emptyList();
     }
 
     private Map<String, DynamicColorContribution> getDynamicColoringObjects() {
diff --git a/org.simantics.district.network.ui/src/org/simantics/district/network/ui/participants/ElevationServerParticipant.java b/org.simantics.district.network.ui/src/org/simantics/district/network/ui/participants/ElevationServerParticipant.java
deleted file mode 100644 (file)
index d5f02bb..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-package org.simantics.district.network.ui.participants;
-
-import java.awt.geom.AffineTransform;
-
-import org.simantics.district.network.ui.nodes.ElevationServerNode;
-import org.simantics.g2d.canvas.impl.SGNodeReflection.SGInit;
-import org.simantics.g2d.diagram.participant.AbstractDiagramParticipant;
-import org.simantics.scenegraph.g2d.G2DParentNode;
-
-public class ElevationServerParticipant extends AbstractDiagramParticipant {
-
-    private ElevationServerNode node;
-
-    private AffineTransform transform;
-    
-    public ElevationServerParticipant(AffineTransform transform) {
-        this.transform = transform;
-    }
-
-    @SGInit
-    public void initSG(G2DParentNode parent) {
-        node = parent.addNode(ElevationServerNode.ID, ElevationServerNode.class);
-        node.setTransform(transform);
-    }
-
-}
index ebdc01418e848423c3d3f30b0fd3f4a3f38251c8..ca592acfdd52d58647b2da056949273a403485fd 100644 (file)
@@ -42,6 +42,7 @@ import org.simantics.structural.stubs.StructuralResource2;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+@Deprecated
 public class DistrictNetworkStaticInfoStyle extends StyleBase<DistrictNetworkStaticInfoStyle.StyleResult> {
 
     private static final Logger LOGGER = LoggerFactory.getLogger(DistrictNetworkStaticInfoStyle.class);
@@ -93,61 +94,65 @@ public class DistrictNetworkStaticInfoStyle extends StyleBase<DistrictNetworkSta
        @Override
        public StyleResult calculateStyle(ReadGraph graph, Resource runtimeDiagram, Resource entry, Resource mapElement)
                        throws DatabaseException {
-               DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph);
-               Set<Resource> types = graph.getTypes(mapElement);
-               boolean isEdge = types.contains(DN.Edge);
-               boolean isVertex = types.contains(DN.Vertex);
-               if (!isEdge && !isVertex)
-                       return null;
-
-               if (isEdge) {
-                       Resource diagram = graph.getSingleObject(mapElement, Layer0.getInstance(graph).PartOf);
-                       Set<Resource> edgesToUse = graph.syncRequest(new MidBranchEdgeSetRequest(diagram), TransientCacheListener.instance());
-                       if (!edgesToUse.contains(mapElement))
-                               return null;
-               }
-
-               Resource module = DistrictNetworkUtil.getMappedComponentCached(graph, mapElement);
-               if (module == null)
-                       return null;
-
-               StructuralResource2 STR = StructuralResource2.getInstance(graph);
-               Resource moduleType = graph.getPossibleType(module, STR.Component);
-               if (moduleType == null)
-                       return null;
-
-               Function1<Variable, String> function = getUCPipelineInfoFunctionCached(graph, moduleType);
-               if (function == null)
-                       return null;
-
-               String result;
-               try {
-                       Variable variable = Variables.getVariable(graph, module);
-                       Variable moduleVariable = Variables.possibleActiveVariable(graph, variable);
-                       if (moduleVariable == null)
-                               moduleVariable = variable;
-
-                       result = Simantics.applySCLRead(graph, function, moduleVariable);
-               } catch (PendingVariableException | MissingVariableValueException e) {
-                       result = null;
-               } catch (MissingVariableException e) {
-                       // the requested variable is missing from the UC
-                       String message = e.getMessage();
-                       LOGGER.warn("Missing variable for calculating style with function {} {}", function, message);
-                       result = "<" + message + ">";
-               }
-
-               if (isVertex) {
-                       DiagramResource DIA = DiagramResource.getInstance(graph);
-                       double[] coords = graph.getRelatedValue(mapElement, DIA.HasLocation);
-                       Point2D p = DistrictNetworkNodeUtils.calculatePoint2D(new Point2D.Double(coords[0], coords[1]), null);
-                       return new StyleResult(mapElement, p, result);
-               } else if (isEdge) {
-                       return new StyleResult(mapElement, EDGE, result);
-               }
-               return null;
+           return calculateStyle(graph, entry, mapElement);
        }
 
+       public static StyleResult calculateStyle(ReadGraph graph, Resource entry, Resource mapElement) throws DatabaseException {
+        DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph);
+        Set<Resource> types = graph.getTypes(mapElement);
+        boolean isEdge = types.contains(DN.Edge);
+        boolean isVertex = types.contains(DN.Vertex);
+        if (!isEdge && !isVertex)
+            return null;
+
+        if (isEdge) {
+            Resource diagram = graph.getSingleObject(mapElement, Layer0.getInstance(graph).PartOf);
+            Set<Resource> edgesToUse = graph.syncRequest(new MidBranchEdgeSetRequest(diagram), TransientCacheListener.instance());
+            if (!edgesToUse.contains(mapElement))
+                return null;
+        }
+
+        Resource module = DistrictNetworkUtil.getMappedComponentCached(graph, mapElement);
+        if (module == null)
+            return null;
+
+        StructuralResource2 STR = StructuralResource2.getInstance(graph);
+        Resource moduleType = graph.getPossibleType(module, STR.Component);
+        if (moduleType == null)
+            return null;
+
+        Function1<Variable, String> function = getUCPipelineInfoFunctionCached(graph, moduleType);
+        if (function == null)
+            return null;
+
+        String result;
+        try {
+            Variable variable = Variables.getVariable(graph, module);
+            Variable moduleVariable = Variables.possibleActiveVariable(graph, variable);
+            if (moduleVariable == null)
+                moduleVariable = variable;
+
+            result = Simantics.applySCLRead(graph, function, moduleVariable);
+        } catch (PendingVariableException | MissingVariableValueException e) {
+            result = null;
+        } catch (MissingVariableException e) {
+            // the requested variable is missing from the UC
+            String message = e.getMessage();
+            LOGGER.warn("Missing variable for calculating style with function {} {}", function, message);
+            result = "<" + message + ">";
+        }
+
+        if (isVertex) {
+            DiagramResource DIA = DiagramResource.getInstance(graph);
+            double[] coords = graph.getRelatedValue(mapElement, DIA.HasLocation);
+            Point2D p = DistrictNetworkNodeUtils.calculatePoint2D(new Point2D.Double(coords[0], coords[1]), null);
+            return new StyleResult(mapElement, p, result);
+        } else if (isEdge) {
+            return new StyleResult(mapElement, EDGE, result);
+        }
+        return null;
+       }
+       
        @Override
        public void applyStyleForNode(EvaluationContext evaluationContext, INode parent, StyleResult result) {
                if (result == null) {
index a1b21629d4b21fbd914c90d29efd3797ddd65d5d..e21bcb2a241a59e68a05c1815bb223deb1b34ceb 100644 (file)
@@ -101,6 +101,8 @@ public class DynamicVisualisationsUI {
     private Button resetVisualisationButton;
     private Button hoveringVertexEnabledButton;
     private Button hoveringEdgesEnabledButton;
+    private Button elevationServerEnabledButton;
+    private Button notInSimulationButton;
 
     private List<Supplier<Pair<String, DynamicArrowContribution>>> edgeArrowSuppliers;
 
@@ -184,6 +186,11 @@ public class DynamicVisualisationsUI {
         GridLayoutFactory.fillDefaults().numColumns(1).applyTo(intervalElementsComposite);
         initializeIntervalElements(intervalElementsComposite);
         
+        Composite hoverElementsComposite = new Composite(parent, SWT.NONE);
+        GridDataFactory.fillDefaults().grab(true, false).applyTo(hoverElementsComposite);
+        GridLayoutFactory.fillDefaults().numColumns(1).applyTo(hoverElementsComposite);
+        initializeHoverElements(hoverElementsComposite);
+        
         Composite hideElementsComposite = new Composite(parent, SWT.NONE);
         GridDataFactory.fillDefaults().grab(true, false).applyTo(hideElementsComposite);
         GridLayoutFactory.fillDefaults().numColumns(1).applyTo(hideElementsComposite);
@@ -252,9 +259,9 @@ public class DynamicVisualisationsUI {
     
     private void initializeIntervalElements(Composite parent) {
         Group group = new Group(parent, SWT.NONE);
-        group.setText("Interval");
+        group.setText("Generic");
         GridDataFactory.fillDefaults().grab(true, false).applyTo(group);
-        GridLayoutFactory.fillDefaults().numColumns(6).margins(5, 5).applyTo(group);
+        GridLayoutFactory.fillDefaults().numColumns(2).margins(5, 5).applyTo(group);
         
         createIntervalElements(group);
     }
@@ -262,8 +269,9 @@ public class DynamicVisualisationsUI {
     private void createIntervalElements(Composite parent) {
 
         Label label = new Label(parent, SWT.NONE);
-        label.setText("Generic");
+        label.setText("Interval (seconds)");
         intervalText = new Text(parent, SWT.BORDER);
+        GridDataFactory.fillDefaults().grab(true, false).applyTo(intervalText);
         addSelectionListener(intervalText);
         
         disableUpdatesButton = new Button(parent, SWT.CHECK);
@@ -274,6 +282,25 @@ public class DynamicVisualisationsUI {
         resetVisualisationButton.setText("Reset Visualisation");
         addSelectionListener(resetVisualisationButton);
         
+        notInSimulationButton = new Button(parent, SWT.CHECK);
+        notInSimulationButton.setText("Not in Simulation");
+        addSelectionListener(notInSimulationButton);
+
+        elevationServerEnabledButton = new Button(parent, SWT.CHECK);
+        elevationServerEnabledButton.setText("Elevation Server Bounding Box");
+        addSelectionListener(elevationServerEnabledButton);
+    }
+    
+    private void initializeHoverElements(Composite parent) {
+        Group group = new Group(parent, SWT.NONE);
+        group.setText("Hover");
+        GridDataFactory.fillDefaults().grab(true, false).applyTo(group);
+        GridLayoutFactory.fillDefaults().numColumns(2).margins(5, 5).applyTo(group);
+        
+        createHoverElements(group);
+    }
+    
+    private void createHoverElements(Composite parent) {
         hoveringVertexEnabledButton = new Button(parent, SWT.CHECK);
         hoveringVertexEnabledButton.setText("Vertex Key Variables on Hover");
         addSelectionListener(hoveringVertexEnabledButton);
@@ -446,15 +473,14 @@ public class DynamicVisualisationsUI {
         
         Combo variableCombo = new Combo(parent, SWT.READ_ONLY);
         variableCombo.setItems(arrowContributions.keySet().toArray(new String[arrowContributions.size()]));
-        
-        GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.CENTER).applyTo(variableCombo);
+        GridDataFactory.fillDefaults().grab(true, false).hint(100, SWT.DEFAULT).align(SWT.CENTER, SWT.CENTER).applyTo(variableCombo);
         
         Text gainText = new Text(parent, SWT.BORDER);
-        GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.CENTER).applyTo(gainText);
+        GridDataFactory.fillDefaults().grab(true, false).hint(100, SWT.DEFAULT).align(SWT.CENTER, SWT.CENTER).applyTo(gainText);
         addSelectionListener(gainText);
         
         Text biasText = new Text(parent, SWT.BORDER);
-        GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.CENTER).applyTo(biasText);
+        GridDataFactory.fillDefaults().grab(true, false).hint(100, SWT.DEFAULT).align(SWT.CENTER, SWT.CENTER).applyTo(biasText);
         addSelectionListener(biasText);
         
         Button defaultButton = new Button(parent, SWT.CHECK);
@@ -631,7 +657,9 @@ public class DynamicVisualisationsUI {
         boolean resetVisualisation = resetVisualisationButton.getSelection();
         Long interval;
         try {
-            interval = Long.parseLong(intervalText.getText());
+            // inteval is in milliseconds but shown as seconds
+            
+            interval = (long)(Double.parseDouble(intervalText.getText()) * 1000);
         } catch (NumberFormatException e) {
             // ignore
             interval = 2000L;
@@ -641,6 +669,9 @@ public class DynamicVisualisationsUI {
         boolean hoverVertex = hoveringVertexEnabledButton.getSelection();
         boolean hoverEdges = hoveringEdgesEnabledButton.getSelection();
         
+        boolean elevationServerBoundingBox = elevationServerEnabledButton.getSelection();
+        boolean notInSimulation = notInSimulationButton.getSelection();
+        
         Simantics.getSession().asyncRequest(new WriteRequest() {
             
             @Override
@@ -679,6 +710,9 @@ public class DynamicVisualisationsUI {
                         dynamicSymbolsPumpingStations
                     );
                 DynamicVisualisations.setKeyVariablesHover(graph, exist, hoverVertex, hoverEdges);
+                
+                DynamicVisualisations.setElevationServerBoundingBox(graph, exist, elevationServerBoundingBox);
+                DynamicVisualisations.setNotInSimulation(graph, exist, notInSimulation);
             }
         });
     }
@@ -915,21 +949,21 @@ public class DynamicVisualisationsUI {
         Combo variableCombo = new Combo(parent, SWT.READ_ONLY);
         variableCombo.setItems(colorContributions.keySet().toArray(new String[colorContributions.size()]));
         
-        GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.CENTER).applyTo(variableCombo);
+        GridDataFactory.fillDefaults().grab(true, false).hint(100, SWT.DEFAULT).align(SWT.CENTER, SWT.CENTER).applyTo(variableCombo);
         
         Text minText = new Text(parent, SWT.BORDER);
-        GridDataFactory.fillDefaults().grab(true, false).hint(150, SWT.DEFAULT).align(SWT.CENTER, SWT.CENTER).applyTo(minText);
+        GridDataFactory.fillDefaults().grab(true, false).hint(100, SWT.DEFAULT).align(SWT.CENTER, SWT.CENTER).applyTo(minText);
         addSelectionListener(minText);
         
         Text maxText = new Text(parent, SWT.BORDER);
-        GridDataFactory.fillDefaults().grab(true, false).hint(150, SWT.DEFAULT).align(SWT.CENTER, SWT.CENTER).applyTo(maxText);
+        GridDataFactory.fillDefaults().grab(true, false).hint(100, SWT.DEFAULT).align(SWT.CENTER, SWT.CENTER).applyTo(maxText);
         addSelectionListener(maxText);
         
         Text unit = new Text(parent, SWT.READ_ONLY);
-        GridDataFactory.fillDefaults().grab(true, false).align(SWT.CENTER, SWT.CENTER).applyTo(unit);
+        GridDataFactory.fillDefaults().grab(true, false).hint(30, SWT.DEFAULT).align(SWT.CENTER, SWT.CENTER).applyTo(unit);
         
         Combo colorMapCombo = new Combo(parent, SWT.READ_ONLY);
-        GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.CENTER).applyTo(colorMapCombo);
+        GridDataFactory.fillDefaults().grab(true, false).hint(100, SWT.DEFAULT).align(SWT.CENTER, SWT.CENTER).applyTo(colorMapCombo);
         colorMapCombo.setItems(colorMaps.keySet().toArray(new String[colorMaps.keySet().size()]));
         addSelectionListener(colorMapCombo);
         
@@ -1077,22 +1111,21 @@ public class DynamicVisualisationsUI {
         
         Combo variableCombo = new Combo(parent, SWT.READ_ONLY);
         variableCombo.setItems(sizeContributions.keySet().toArray(new String[sizeContributions.size()]));
-        
-        GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.CENTER).applyTo(variableCombo);
+        GridDataFactory.fillDefaults().grab(true, false).hint(100, SWT.DEFAULT).align(SWT.CENTER, SWT.CENTER).applyTo(variableCombo);
         
         Text minText = new Text(parent, SWT.BORDER);
-        GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.CENTER).applyTo(minText);
+        GridDataFactory.fillDefaults().grab(true, false).hint(100, SWT.DEFAULT).align(SWT.CENTER, SWT.CENTER).applyTo(minText);
         addSelectionListener(minText);
         
         Text maxText = new Text(parent, SWT.BORDER);
-        GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.CENTER).applyTo(maxText);
+        GridDataFactory.fillDefaults().grab(true, false).hint(100, SWT.DEFAULT).align(SWT.CENTER, SWT.CENTER).applyTo(maxText);
         addSelectionListener(maxText);
         
         Label unit = new Label(parent, SWT.NONE);
-        GridDataFactory.fillDefaults().grab(true, false).align(SWT.CENTER, SWT.CENTER).applyTo(unit);
+        GridDataFactory.fillDefaults().grab(true, false).hint(30, SWT.DEFAULT).align(SWT.CENTER, SWT.CENTER).applyTo(unit);
         
         Combo sizeMapCombo = new Combo(parent, SWT.READ_ONLY);
-        GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.CENTER).applyTo(sizeMapCombo);
+        GridDataFactory.fillDefaults().grab(true, false).hint(100, SWT.DEFAULT).align(SWT.CENTER, SWT.CENTER).applyTo(sizeMapCombo);
         sizeMapCombo.setItems(sizeMaps.keySet().toArray(new String[sizeMaps.keySet().size()]));
         addSelectionListener(sizeMapCombo);
         
@@ -1449,7 +1482,7 @@ public class DynamicVisualisationsUI {
                     }
                 }
                 
-                intervalText.setText(Long.toString(visualisation.getInterval()));
+                intervalText.setText(Double.toString(((double)visualisation.getInterval()) / 1000.0));
                 disableUpdatesButton.setSelection(visualisation.disabledUpdates());
                 
                 hoveringVertexEnabledButton.setSelection(visualisation.isKeyVariablesVertexHover());
@@ -1523,6 +1556,10 @@ public class DynamicVisualisationsUI {
                         break;
                     }
                 }
+                
+                pointsStaticPropertiesButton.setSelection(visualisation.isStaticPropertiesPoints());
+                networkBranchesStaticPropertiesButton.setSelection(visualisation.isStaticPropertiesNetworkBranches());
+                consumersStaticPropertiesButton.setSelection(visualisation.isStaticPropertiesConsumers());
             }
         });
     }
index 05ecb506d12906407fac650264b08c0b566d0ab0..7c574668f570ab0902794887d282f44c136543d5 100644 (file)
@@ -8,26 +8,6 @@
                        <this />
                </type>
        </target>
-       <target interface="org.simantics.scenegraph.profile.Style">
-               <!-- 
-               <resource uri="http://www.simantics.org/DistrictNetwork-1.0/ElementColoringStyle"
-                       class="org.simantics.district.network.profile.DNElementColorStyle">
-               </resource>
-               <resource uri="http://www.simantics.org/DistrictNetwork-1.0/ElementSizingStyle"
-                       class="org.simantics.district.network.profile.DNElementSizeStyle">
-               </resource>
-               <resource uri="http://www.simantics.org/DistrictNetwork-1.0/ArrowLengthStyle"
-                       class="org.simantics.district.network.profile.ArrowLengthStyle">
-               </resource>
-               <resource uri="http://www.simantics.org/DistrictNetwork-1.0/HideStyle"
-                       class="org.simantics.district.network.profile.HideStyle">
-               </resource>
-               -->
-               <resource uri="http://www.simantics.org/DistrictNetwork-1.0/VertexSymbolStyle"
-                       class="org.simantics.district.network.profile.VertexSymbolStyle">
-               </resource>
-       </target>
        <target interface="org.simantics.scenegraph.profile.Group">
                <type
                        uri="http://www.simantics.org/DistrictNetwork-1.0/DistrictNodeGroup"
diff --git a/org.simantics.district.network/scl/Simantics/District/DynamicVisualisations/StaticDynamicContribution.scl b/org.simantics.district.network/scl/Simantics/District/DynamicVisualisations/StaticDynamicContribution.scl
new file mode 100644 (file)
index 0000000..2a82d34
--- /dev/null
@@ -0,0 +1,14 @@
+import "Map" as Map
+import "Simantics/DB"
+
+importJava "org.simantics.district.network.visualisations.model.StaticInformationContribution" where
+    data StaticInformationContribution
+    
+    @JavaName "<init>"
+    staticInformationContribution :: String -> String -> String -> String -> StaticInformationContribution
+
+importJava "org.simantics.district.network.visualisations.model.DynamicSymbolContribution" where
+    data DynamicSymbolContribution
+    
+    @JavaName "<init>"
+    dynamicSymbolContribution :: [String] -> (Map.T String Integer -> Map.T String String -> <a> Maybe String) -> (() -> <ReadGraph, Proc> Map.T String String) -> DynamicSymbolContribution
\ No newline at end of file
index 7bff718e732b4200d8b694ab5b41118c0872a99d..08a1b01330642f3abbe99d37b426fb0c482c083c 100644 (file)
@@ -15,6 +15,8 @@ import org.simantics.district.network.visualisations.DynamicVisualisationsContri
 import org.simantics.district.network.visualisations.DynamicVisualisationsContributions.DynamicArrowObject;
 import org.simantics.district.network.visualisations.DynamicVisualisationsContributions.DynamicColoringObject;
 import org.simantics.district.network.visualisations.DynamicVisualisationsContributions.DynamicSizingObject;
+import org.simantics.district.network.visualisations.DynamicVisualisationsContributions.DynamicSymbolContributionObject;
+import org.simantics.district.network.visualisations.DynamicVisualisationsContributions.StaticInformationContributionObject;
 import org.simantics.district.network.visualisations.model.ColorBarOptions;
 import org.simantics.district.network.visualisations.model.DynamicArrowContribution;
 import org.simantics.district.network.visualisations.model.DynamicColorContribution;
@@ -60,6 +62,16 @@ public class ActiveDynamicVisualisationsRequest extends ResourceRead<DynamicVisu
                 SizeBarOptions sizeBarOptions = DynamicVisualisations.sizeBarOptions(graph, visualisationResource);
                 Map<String, DynamicArrowContribution> arrowContributions = DynamicVisualisations.arrowContributions(graph, visualisationResource);
                 
+                Collection<StaticInformationContributionObject> staticInformationContributions = DynamicVisualisationsContributions.staticInformationContributionObjects(graph);
+                Map<String, StaticInformationContributionObject> staticInformationContributionObjects = staticInformationContributions.stream().collect(Collectors.toMap(dcc -> dcc.getStaticInformationContributionObject().getName(), dcc -> dcc));
+
+                Collection<DynamicSymbolContributionObject> dynamicSymbolContributions = DynamicVisualisationsContributions.dynamicSymbolContributionObjects(graph);
+                Map<String, DynamicSymbolContributionObject> dynamicSymbolContributionObjects = dynamicSymbolContributions.stream().map(dsc -> {
+                    // here we resolve the symbol map with the help of readgraph
+                    dsc.resolveSymbols(graph);
+                    return dsc;
+                }).collect(Collectors.toMap(dcc -> dcc.getDynamicSymbolContributionObject().getName(), dcc -> dcc));
+
                 Boolean hideEdges = graph.getPossibleRelatedValue(visualisationResource, DN.Diagram_Visualisations_HideEdges, Bindings.BOOLEAN);
                 Boolean hidePoints = graph.getPossibleRelatedValue(visualisationResource, DN.Diagram_Visualisations_HidePoints, Bindings.BOOLEAN);
                 Boolean hideConsumers = graph.getPossibleRelatedValue(visualisationResource, DN.Diagram_Visualisations_HideConsumers, Bindings.BOOLEAN);
@@ -77,6 +89,9 @@ public class ActiveDynamicVisualisationsRequest extends ResourceRead<DynamicVisu
                 Boolean keyVariablesVertexHover = graph.getPossibleRelatedValue(visualisationResource, DN.Diagram_Visualisations_KeyVariableVertexHover, Bindings.BOOLEAN);
                 Boolean keyVariablesEdgesHover = graph.getPossibleRelatedValue(visualisationResource, DN.Diagram_Visualisations_KeyVariableEdgeHover, Bindings.BOOLEAN);
                 
+                Boolean showElevationServerBoundingBox = graph.getPossibleRelatedValue(visualisationResource, DN.Diagram_Visualisations_ShowElevationServerBoundingBox, Bindings.BOOLEAN);
+                Boolean notInSimulation = graph.getPossibleRelatedValue(visualisationResource, DN.Diagram_Visualisations_NotInSimulation, Bindings.BOOLEAN);
+                
                 DynamicVisualisation visualisation = new DynamicVisualisation(name, visualisationResource,
                         interval != null ? interval : 2000,
                         disabledUpdates != null ? disabledUpdates : false,
@@ -89,6 +104,8 @@ public class ActiveDynamicVisualisationsRequest extends ResourceRead<DynamicVisu
                         sizeBarOptions,
                         defaultArrowObjects,
                         arrowContributions,
+                        staticInformationContributionObjects,
+                        dynamicSymbolContributionObjects,
                         hideEdges != null ? hideEdges : false,
                         hidePoints != null ? hidePoints : false,
                         hideConsumers != null ? hideConsumers : false,
@@ -103,7 +120,9 @@ public class ActiveDynamicVisualisationsRequest extends ResourceRead<DynamicVisu
                         dynamicSymbolsValves != null ? dynamicSymbolsValves : false,
                         dynamicSymbolsPumpingStations != null ? dynamicSymbolsPumpingStations : false,
                         keyVariablesVertexHover != null ? keyVariablesVertexHover : false,
-                        keyVariablesEdgesHover != null ? keyVariablesEdgesHover : false
+                        keyVariablesEdgesHover != null ? keyVariablesEdgesHover : false,
+                        showElevationServerBoundingBox != null ? showElevationServerBoundingBox : false,
+                        notInSimulation != null ? notInSimulation : false
                     );
                 return visualisation; 
             }
index 26a5564d5fade5e47180b437fd12b5c56f66032f..913ba201222bf705978d8abae418976475c7d935 100644 (file)
@@ -18,34 +18,39 @@ import org.simantics.scl.runtime.function.FunctionImpl1;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+@Deprecated
 public class VertexSymbolStyle extends ThrottledStyleBase<String> {
 
        private static final Logger LOGGER = LoggerFactory.getLogger(VertexSymbolStyle.class);
-       
-       @SuppressWarnings({ "rawtypes", "unchecked" })
-       @Override
-       public String calculateThrottledStyle(ReadGraph graph, Resource runtimeDiagram, Resource entry, Resource groupItem) throws DatabaseException {
-               // Prevent PendingVariableExceptions from coming through
-               boolean wasSynchronous = graph.setSynchronous(true);
-               try {
-                       Function symbolFunction = getSymbolFunction(graph, entry);
-                       if (symbolFunction == null)
-                               return null;
-                       
-                       try {
-                               return (String) Simantics.applySCLRead(graph, symbolFunction, groupItem);
-                       } catch (Exception e) {
-                               LOGGER.error("Getting dynamic symbol for " + groupItem + " (" + graph.getPossibleRelatedValue(groupItem, Layer0.getInstance(graph).HasName) + ") failed", e);
-                               return null;
-                       }
-               }
-               finally {
-                       graph.setSynchronous(wasSynchronous);
-               }
-       }
+
+    @Override
+    public String calculateThrottledStyle(ReadGraph graph, Resource runtimeDiagram, Resource entry, Resource groupItem) throws DatabaseException {
+        return calculateStyle(graph, entry, groupItem);
+    }
+
+    @SuppressWarnings({ "rawtypes", "unchecked" })
+    public static String calculateStyle(ReadGraph graph, Resource entry, Resource groupItem) throws DatabaseException {
+        // Prevent PendingVariableExceptions from coming through
+        boolean wasSynchronous = graph.setSynchronous(true);
+        try {
+            Function symbolFunction = getSymbolFunction(graph, entry);
+            if (symbolFunction == null)
+                return null;
+
+            try {
+                return (String) Simantics.applySCLRead(graph, symbolFunction, groupItem);
+            } catch (Exception e) {
+                LOGGER.error("Getting dynamic symbol for " + groupItem + " ("
+                        + graph.getPossibleRelatedValue(groupItem, Layer0.getInstance(graph).HasName) + ") failed", e);
+                return null;
+            }
+        } finally {
+            graph.setSynchronous(wasSynchronous);
+        }
+    }
 
        @SuppressWarnings("rawtypes")
-       protected static Function getSymbolFunction(ReadGraph graph, Resource entry) throws DatabaseException {
+       public static Function getSymbolFunction(ReadGraph graph, Resource entry) throws DatabaseException {
                // Cache function read for profile entry
                return graph.syncRequest(new SymbolFunctionRequest(entry), TransientCacheListener.<Function>instance());
        }
index cf4feead607fafc8b76f4bf079474a13ffa49651..e2cb72bfb0cbb3b6f05476d77380a8e681acbf0b 100644 (file)
@@ -341,5 +341,26 @@ public class DynamicVisualisations {
         DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph);
         graph.claimLiteral(visualisation, DN.Diagram_Visualisations_KeyVariableVertexHover, hoverVertex, Bindings.BOOLEAN);
         graph.claimLiteral(visualisation, DN.Diagram_Visualisations_KeyVariableEdgeHover, hoverEdges, Bindings.BOOLEAN);
+    } 
+
+    public static void setElevationServerBoundingBox(WriteGraph graph, Resource visualisation, boolean elevationServerBoundingBox) throws DatabaseException {
+        DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph);
+        graph.claimLiteral(visualisation, DN.Diagram_Visualisations_ShowElevationServerBoundingBox, elevationServerBoundingBox, Bindings.BOOLEAN);
+    }
+
+    public static Boolean showElevationServerBoundingBox(ReadGraph graph, Resource visualisation) throws DatabaseException {
+        DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph);
+        return graph.getPossibleRelatedValue(visualisation, DN.Diagram_Visualisations_ShowElevationServerBoundingBox, Bindings.BOOLEAN);
+    }
+
+    public static void setNotInSimulation(WriteGraph graph, Resource visualisation, boolean notInSimulation) throws DatabaseException {
+        DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph);
+        graph.claimLiteral(visualisation, DN.Diagram_Visualisations_NotInSimulation, notInSimulation, Bindings.BOOLEAN);
+    }
+
+    public static Boolean isNotInSimulation(ReadGraph graph, Resource visualisation) throws DatabaseException {
+        DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph);
+        return graph.getPossibleRelatedValue(visualisation, DN.Diagram_Visualisations_NotInSimulation, Bindings.BOOLEAN);
     }
+
 }
index 1a16ee55389214e4cb39f7862cb06e5a6231235a..3fd5a25f341a444a7e188f9eea60ab5e941adaee 100644 (file)
@@ -5,6 +5,7 @@ import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Optional;
 import java.util.function.Supplier;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
@@ -22,6 +23,8 @@ import org.simantics.district.network.visualisations.model.DynamicColorContribut
 import org.simantics.district.network.visualisations.model.DynamicColorMap;
 import org.simantics.district.network.visualisations.model.DynamicSizeContribution;
 import org.simantics.district.network.visualisations.model.DynamicSizeMap;
+import org.simantics.district.network.visualisations.model.DynamicSymbolContribution;
+import org.simantics.district.network.visualisations.model.StaticInformationContribution;
 import org.simantics.layer0.Layer0;
 import org.simantics.scl.compiler.top.ValueNotFound;
 import org.simantics.scl.osgi.SCLOsgi;
@@ -43,6 +46,8 @@ public class DynamicVisualisationsContributions {
     private static final String COLOR_CONTRIBUTION = "colorContribution";
     private static final String SIZE_CONTRIBUTION = "sizeContribution";
     private static final String ARROW_CONTRIBUTION = "arrowContribution";
+    private static final String STATIC_INFORMATION_CONTRIBUTION = "staticInformationContribution";
+    private static final String DYNAMIC_SYMBOL_CONTRIBUTION = "symbolContribution";
 
     public static Map<String, DynamicColorMap> dynamicColorMaps(ReadGraph graph) throws DatabaseException {
         List<Resource> sharedOntologies = Simantics.applySCL("Simantics/SharedOntologies", "getSharedOntologies", graph, Tuple0.INSTANCE);
@@ -204,7 +209,64 @@ public class DynamicVisualisationsContributions {
             }
         };
     }
+
+    public static Collection<StaticInformationContributionObject> staticInformationContributionObjects(ReadGraph graph) throws DatabaseException {
+        
+        List<Resource> sharedOntologies = Simantics.applySCL("Simantics/SharedOntologies", "getSharedOntologies", graph, Tuple0.INSTANCE);
+        
+        List<StaticInformationContributionObject> results = new ArrayList<>();
+        
+        for (Resource sharedOntology : sharedOntologies) {
+            Collection<Resource> findByType = graph.syncRequest(new ObjectsWithSupertype(sharedOntology, Layer0.getInstance(graph).ConsistsOf, StructuralResource2.getInstance(graph).Component));
+            //Collection<Resource> findByType = QueryIndexUtils.searchByType(graph, sharedOntology, );
+            for (Resource find : findByType) {
+                NamedResource moduleType = new NamedResource(NameLabelUtil.modalName(graph, find), find);
+                StaticInformationContributionObject staticInformationContributionObject = staticInformationContributionObject(graph, moduleType);
+                if (staticInformationContributionObject != null)
+                    results.add(staticInformationContributionObject);
+            }
+        }
+        return results;
+    }
+    
+    private static StaticInformationContributionObject staticInformationContributionObject(ReadGraph graph, NamedResource moduleType) throws DatabaseException {
+        Layer0 L0 = Layer0.getInstance(graph);
+        Resource sclModule = Layer0Utils.getPossibleChild(graph, moduleType.getResource(), L0.SCLModule, DYNAMIC_VISUALISATIONS_CONTRIBUTION_MODULE);
+        if (sclModule != null) {
+            String moduleURI = graph.getURI(sclModule);
+            return new StaticInformationContributionObject(moduleType, getContributionSupplier(moduleURI, STATIC_INFORMATION_CONTRIBUTION));
+        }
+        return null;
+    }
+
+    public static Collection<DynamicSymbolContributionObject> dynamicSymbolContributionObjects(ReadGraph graph) throws DatabaseException {
+        
+        List<Resource> sharedOntologies = Simantics.applySCL("Simantics/SharedOntologies", "getSharedOntologies", graph, Tuple0.INSTANCE);
+        List<DynamicSymbolContributionObject> results = new ArrayList<>();
+        
+        for (Resource sharedOntology : sharedOntologies) {
+            Collection<Resource> findByType = graph.syncRequest(new ObjectsWithSupertype(sharedOntology, Layer0.getInstance(graph).ConsistsOf, StructuralResource2.getInstance(graph).Component));
+            //Collection<Resource> findByType = QueryIndexUtils.searchByType(graph, sharedOntology, );
+            for (Resource find : findByType) {
+                NamedResource moduleType = new NamedResource(NameLabelUtil.modalName(graph, find), find);
+                DynamicSymbolContributionObject dynamicSymbolContributionObject = dynamicSymbolContributionObject(graph, moduleType);
+                if (dynamicSymbolContributionObject != null)
+                    results.add(dynamicSymbolContributionObject);
+            }
+        }
+        return results;
+    }
     
+    private static DynamicSymbolContributionObject dynamicSymbolContributionObject(ReadGraph graph, NamedResource moduleType) throws DatabaseException {
+        Layer0 L0 = Layer0.getInstance(graph);
+        Resource sclModule = Layer0Utils.getPossibleChild(graph, moduleType.getResource(), L0.SCLModule, DYNAMIC_VISUALISATIONS_CONTRIBUTION_MODULE);
+        if (sclModule != null) {
+            String moduleURI = graph.getURI(sclModule);
+            return new DynamicSymbolContributionObject(moduleType, getContributionSupplier(moduleURI, DYNAMIC_SYMBOL_CONTRIBUTION));
+        }
+        return null;
+    }
+
     public static class DynamicArrowObject {
 
         private final NamedResource arrowObject;
@@ -226,7 +288,67 @@ public class DynamicVisualisationsContributions {
             return arrowContributions;
         }
     }
-    
+
+    public static class StaticInformationContributionObject {
+
+        private final NamedResource staticInformationContributionObject;
+        private final Supplier<Stream<StaticInformationContribution>> staticInformationContributionSupplier;
+        private Map<String, StaticInformationContribution> staticInformationContributions;
+
+        public StaticInformationContributionObject(NamedResource staticInformationContributionObject, Supplier<Stream<StaticInformationContribution>> staticInformationContributionSupplier) {
+            this.staticInformationContributionObject = staticInformationContributionObject;
+            this.staticInformationContributionSupplier = staticInformationContributionSupplier;
+        }
+
+        public NamedResource getStaticInformationContributionObject() {
+            return staticInformationContributionObject;
+        }
+
+        public Map<String, StaticInformationContribution> getStaticInformationContributions() {
+            if (staticInformationContributions == null)
+                staticInformationContributions = staticInformationContributionSupplier.get().collect(Collectors.toMap(c -> c.getLabel(), c -> c));
+            return staticInformationContributions;
+        }
+    }
+
+    public static class DynamicSymbolContributionObject {
+
+        private final NamedResource dynamicSymbolContributionObject;
+        private final Supplier<Stream<DynamicSymbolContribution>> dynamicSymbolContributionSupplier;
+        private DynamicSymbolContribution dynamicSymbolContribution;
+
+        public DynamicSymbolContributionObject(NamedResource dynamicSymbolContributionObject, Supplier<Stream<DynamicSymbolContribution>> dynamicSymbolContributionSupplier) {
+            this.dynamicSymbolContributionObject = dynamicSymbolContributionObject;
+            this.dynamicSymbolContributionSupplier = dynamicSymbolContributionSupplier;
+        }
+
+        public NamedResource getDynamicSymbolContributionObject() {
+            return dynamicSymbolContributionObject;
+        }
+
+        public DynamicSymbolContribution getDynamicSymbolContribution() {
+            if (dynamicSymbolContribution == null) {
+                Optional<DynamicSymbolContribution> findFirst = dynamicSymbolContributionSupplier.get().findFirst();
+                findFirst.ifPresent(dsc -> {
+                    dynamicSymbolContribution = dsc;
+                });
+            }
+            return dynamicSymbolContribution;
+        }
+
+        public void resolveSymbols(ReadGraph graph) {
+            SCLContext current = SCLContext.getCurrent();
+            Object oldGraph = current.put("graph", graph);
+            try {
+                DynamicSymbolContribution dsc = getDynamicSymbolContribution();
+                if (dsc != null)
+                    dsc.resolveSymbolMap();
+            } finally {
+                current.put("graph", oldGraph);
+            }
+        }
+    }
+
     public static class DynamicColoringObject {
 
         private final NamedResource coloringObject;
diff --git a/org.simantics.district.network/src/org/simantics/district/network/visualisations/model/DynamicSymbolContribution.java b/org.simantics.district.network/src/org/simantics/district/network/visualisations/model/DynamicSymbolContribution.java
new file mode 100644 (file)
index 0000000..cbd3ed8
--- /dev/null
@@ -0,0 +1,60 @@
+package org.simantics.district.network.visualisations.model;
+
+import java.util.List;
+import java.util.Map;
+
+import org.simantics.scl.runtime.function.Function1;
+import org.simantics.scl.runtime.function.Function2;
+import org.simantics.scl.runtime.tuple.Tuple0;
+
+public class DynamicSymbolContribution {
+
+    private List<String> children;
+    private Function2<Map<String, Integer>, Map<String, String>, String> symbolFunction;
+    private Function1<Tuple0, Map<String, String>> symbolMapFunction;
+    
+    private Map<String, String> symbolMap;
+    
+    // for graph persistence only
+    private boolean used;
+    private boolean useDefault;
+
+    public DynamicSymbolContribution(List<String> children, Function2<Map<String, Integer>, Map<String, String>, String> symbolFunction, Function1<Tuple0, Map<String, String>> symbolMapFunction) {
+        this.children = children;
+        this.symbolFunction = symbolFunction;
+        this.symbolMapFunction = symbolMapFunction;
+    }
+
+    public List<String> getChildren() {
+        return children;
+    }
+    
+    public Function2<Map<String, Integer>, Map<String, String>, String> getSymbolFunction() {
+        return symbolFunction;
+    }
+    
+    public void resolveSymbolMap() {
+        symbolMap = symbolMapFunction.apply(Tuple0.INSTANCE);
+    }
+    
+    public Map<String, String> getSymbolMap() {
+        return symbolMap;
+    }
+
+    public boolean isUsed() {
+        return used;
+    }
+    
+    public void setUsed(boolean used) {
+        this.used = used;
+    }
+    
+    public boolean isUseDefault() {
+        return useDefault;
+    }
+    
+    public void setUseDefault(boolean useDefault) {
+        this.useDefault = useDefault;
+    }
+
+}
\ No newline at end of file
index ca5773232b482e3202d41be2b4ddeda20c54082d..d64461e18936e6884f1ba5b686f0807415baecfe 100644 (file)
@@ -6,6 +6,8 @@ import org.simantics.db.Resource;
 import org.simantics.district.network.visualisations.DynamicVisualisationsContributions.DynamicArrowObject;
 import org.simantics.district.network.visualisations.DynamicVisualisationsContributions.DynamicColoringObject;
 import org.simantics.district.network.visualisations.DynamicVisualisationsContributions.DynamicSizingObject;
+import org.simantics.district.network.visualisations.DynamicVisualisationsContributions.DynamicSymbolContributionObject;
+import org.simantics.district.network.visualisations.DynamicVisualisationsContributions.StaticInformationContributionObject;
 
 public class DynamicVisualisation {
 
@@ -24,6 +26,9 @@ public class DynamicVisualisation {
     private final Map<String, DynamicArrowObject> defaultArrowContributions;
     private final Map<String, DynamicArrowContribution> arrowContributions;
     
+    private final Map<String, StaticInformationContributionObject> staticInformationContributions;
+    private final Map<String, DynamicSymbolContributionObject> dynamicSymbolContributions;
+    
     private final boolean hideEdges;
     private final boolean hidePoints;
     private final boolean hideConsumers;
@@ -43,6 +48,9 @@ public class DynamicVisualisation {
     private boolean keyVariablesEdgesHover;
     private boolean resetVisualisation;
     
+    private boolean showElevationServerBoundingBox;
+    private boolean isInSimulation;
+    
     public DynamicVisualisation(String name, Resource visualisationResource, long interval, boolean disabled,
             boolean resetVisualisation, Map<String, DynamicColorContribution> colorContributions,
             Map<String, DynamicColoringObject> defaultColoringObjects, ColorBarOptions colorBarOptions,
@@ -50,6 +58,8 @@ public class DynamicVisualisation {
             Map<String, DynamicSizingObject> defaultSizingObjects, SizeBarOptions sizeBarOptions,
             Map<String, DynamicArrowObject> defaultArrowContributions,
             Map<String, DynamicArrowContribution> arrowContributions,
+            Map<String, StaticInformationContributionObject> staticInformationContributions,
+            Map<String, DynamicSymbolContributionObject> dynamicSymbolContributions,
             boolean hideEdges,
             boolean hidePoints,
             boolean hideConsumers,
@@ -64,7 +74,9 @@ public class DynamicVisualisation {
             boolean dynamicSymbolsValves,
             boolean dynamicSymbolsPumpingStations,
             boolean keyVariablesVertexHover,
-            boolean keyVariablesEdgesHover
+            boolean keyVariablesEdgesHover,
+            boolean showElevationServerBoundingBox,
+            boolean isInSimulation
             ) {
         this.name = name;
         this.visualisationResource = visualisationResource;
@@ -79,6 +91,8 @@ public class DynamicVisualisation {
         this.sizeBarOptions = sizeBarOptions;
         this.defaultArrowContributions = defaultArrowContributions;
         this.arrowContributions = arrowContributions;
+        this.staticInformationContributions = staticInformationContributions;
+        this.dynamicSymbolContributions = dynamicSymbolContributions;
         
         this.hidePoints = hidePoints;
         this.hideConsumers = hideConsumers;
@@ -97,6 +111,9 @@ public class DynamicVisualisation {
         
         this.keyVariablesVertexHover = keyVariablesVertexHover;
         this.keyVariablesEdgesHover = keyVariablesEdgesHover;
+        
+        this.showElevationServerBoundingBox = showElevationServerBoundingBox;
+        this.isInSimulation = isInSimulation;
     }
 
     public String getName() {
@@ -139,6 +156,10 @@ public class DynamicVisualisation {
         return arrowContributions;
     }
     
+    public Map<String, StaticInformationContributionObject> getStaticInformationContributions() {
+        return staticInformationContributions;
+    }
+    
     public boolean isHideEdges() {
         return hideEdges;
     }
@@ -210,4 +231,12 @@ public class DynamicVisualisation {
     public boolean isResetVisualisation() {
         return resetVisualisation;
     }
+    
+    public boolean isInSimulation() {
+        return isInSimulation;
+    }
+
+    public Map<String, DynamicSymbolContributionObject> getDynamicSymbolContributions() {
+        return dynamicSymbolContributions;
+    }
 }
diff --git a/org.simantics.district.network/src/org/simantics/district/network/visualisations/model/StaticInformationContribution.java b/org.simantics.district.network/src/org/simantics/district/network/visualisations/model/StaticInformationContribution.java
new file mode 100644 (file)
index 0000000..6e8b936
--- /dev/null
@@ -0,0 +1,53 @@
+package org.simantics.district.network.visualisations.model;
+
+public class StaticInformationContribution {
+
+    private String label;
+    private String moduleName;
+    private String attributeName;
+    private String unit;
+    
+    // for graph persistence only
+    private boolean used;
+    private boolean useDefault;
+
+    public StaticInformationContribution(String label, String moduleName, String attributeName, String unit) {
+        this.label = label;
+        this.moduleName = moduleName;
+        this.attributeName = attributeName;
+        this.unit = unit;
+    }
+
+    public String getLabel() {
+        return label;
+    }
+    
+    public String getModuleName() {
+        return moduleName;
+    }
+    
+    public String getAttributeName() {
+        return attributeName;
+    }
+
+    public String getUnit() {
+        return unit;
+    }
+    
+    public boolean isUsed() {
+        return used;
+    }
+    
+    public void setUsed(boolean used) {
+        this.used = used;
+    }
+    
+    public boolean isUseDefault() {
+        return useDefault;
+    }
+    
+    public void setUseDefault(boolean useDefault) {
+        this.useDefault = useDefault;
+    }
+
+}
\ No newline at end of file