]> gerrit.simantics Code Review - simantics/district.git/blobdiff - org.simantics.district.network.ui/src/org/simantics/district/network/ui/visualisations/DynamicVisualisationsUI.java
Move remaining profiles to visualisations for perf
[simantics/district.git] / org.simantics.district.network.ui / src / org / simantics / district / network / ui / visualisations / DynamicVisualisationsUI.java
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());
             }
         });
     }