diff --git a/app/display/model/src/main/java/org/csstudio/display/builder/model/widgets/plots/XYPlotWidget.java b/app/display/model/src/main/java/org/csstudio/display/builder/model/widgets/plots/XYPlotWidget.java index 4067d24048..3182e36260 100644 --- a/app/display/model/src/main/java/org/csstudio/display/builder/model/widgets/plots/XYPlotWidget.java +++ b/app/display/model/src/main/java/org/csstudio/display/builder/model/widgets/plots/XYPlotWidget.java @@ -12,6 +12,7 @@ import static org.csstudio.display.builder.model.properties.CommonWidgetProperties.propColor; import static org.csstudio.display.builder.model.properties.CommonWidgetProperties.propForegroundColor; import static org.csstudio.display.builder.model.properties.CommonWidgetProperties.propInteractive; +import static org.csstudio.display.builder.model.properties.CommonWidgetProperties.propVisible; import static org.csstudio.display.builder.model.properties.CommonWidgetProperties.propPVName; import static org.csstudio.display.builder.model.properties.CommonWidgetProperties.runtimePropConfigure; import static org.csstudio.display.builder.model.widgets.plots.PlotWidgetProperties.propGridColor; @@ -99,7 +100,8 @@ protected MarkerProperty(final Widget widget, final String name) Arrays.asList(propColor.createProperty(widget, new WidgetColor(0, 0, 255)), propPVName.createProperty(widget, ""), propInteractive.createProperty(widget, true), - propValue.createProperty(widget, Double.NaN) + propValue.createProperty(widget, Double.NaN), + propVisible.createProperty(widget, true) )); } @@ -111,6 +113,8 @@ protected MarkerProperty(final Widget widget, final String name) public WidgetProperty interactive() { return getElement(2); } /** @return Marker value */ public WidgetProperty value() { return getElement(3); } + /** @return Marker visible */ + public WidgetProperty visible() { return getElement(4); } }; /** 'marker' array */ diff --git a/app/display/model/src/main/resources/examples/plots_xy.bob b/app/display/model/src/main/resources/examples/plots_xy.bob index 0613349893..11ee0b2727 100644 --- a/app/display/model/src/main/resources/examples/plots_xy.bob +++ b/app/display/model/src/main/resources/examples/plots_xy.bob @@ -9,7 +9,7 @@ 181 31 - + @@ -21,7 +21,7 @@ one for the "X" and one for the "Y" axis. 371 40 - + X/Y Plot_1 91 511 @@ -34,6 +34,12 @@ one for the "X" and one for the "Y" axis. loc://interactive(1) + + + false + + loc://visible(1) + @@ -79,6 +85,7 @@ one for the "X" and one for the "Y" axis. loc://pos(50) true + true @@ -95,7 +102,7 @@ one for the "X" and one for the "Y" axis. 441 221 - + @@ -293,7 +300,7 @@ Double-click zooms back out. 471 221 - + @@ -304,7 +311,7 @@ Double-click zooms back out. 711 70 - + RightPlot 591 91 @@ -335,11 +342,11 @@ pvs[1].write(err) 10.0 false - + - + true @@ -353,14 +360,19 @@ pvs[1].write(err) 120.0 false - + - + + false true + + + + @@ -407,7 +419,7 @@ pvs[1].write(err) 441 221 - + @@ -446,7 +458,7 @@ That local PV is then used as the error bar waveform. 429 69 - + @@ -464,6 +476,7 @@ Push button to re-enable. Action Button + Autoscale - Autoscale 1000 @@ -487,7 +499,7 @@ plot.setPropertyValue("y_axes[0].autoscale", True) 29 $(actions) - + X/Y Plot 900 @@ -498,11 +510,11 @@ plot.setPropertyValue("y_axes[0].autoscale", True) 22.0 false - + - + true @@ -516,14 +528,19 @@ plot.setPropertyValue("y_axes[0].autoscale", True) 10.0 false - + - + + false true + + + + @@ -582,7 +599,7 @@ For a "Line Width" of zero, the bar graph turns into a histogram-type display wi 900 221 - + @@ -606,10 +623,16 @@ For a "Line Width" of zero, the bar graph turns into a histogram-type display wi 500 140 60 - - + + + + + + + true + true Check Box @@ -618,4 +641,11 @@ For a "Line Width" of zero, the bar graph turns into a histogram-type display wi 380 470 + + Check Box_1 + loc://visible(1) + + 380 + 561 + diff --git a/app/display/representation-javafx/src/main/java/org/csstudio/display/builder/representation/javafx/widgets/plots/XYPlotRepresentation.java b/app/display/representation-javafx/src/main/java/org/csstudio/display/builder/representation/javafx/widgets/plots/XYPlotRepresentation.java index 11105cf3fa..30a1291914 100644 --- a/app/display/representation-javafx/src/main/java/org/csstudio/display/builder/representation/javafx/widgets/plots/XYPlotRepresentation.java +++ b/app/display/representation-javafx/src/main/java/org/csstudio/display/builder/representation/javafx/widgets/plots/XYPlotRepresentation.java @@ -451,7 +451,8 @@ private void createMarker(final MarkerProperty model_marker) { final PlotMarker plot_marker = plot.addMarker(JFXUtil.convert(model_marker.color().getValue()), model_marker.interactive().getValue(), - model_marker.value().getValue()); + model_marker.value().getValue(), + model_marker.visible().getValue()); // Listen to model_marker.value(), interactive() .. and update plot_marker final UntypedWidgetPropertyListener model_marker_listener = (o, old, value) -> @@ -461,11 +462,13 @@ private void createMarker(final MarkerProperty model_marker) changing_marker = true; plot_marker.setInteractive(model_marker.interactive().getValue()); plot_marker.setPosition(model_marker.value().getValue()); + plot_marker.setVisible(model_marker.visible().getValue()); changing_marker = false; plot.requestUpdate(); }; model_marker.value().addUntypedPropertyListener(model_marker_listener); model_marker.interactive().addUntypedPropertyListener(model_marker_listener); + model_marker.visible().addUntypedPropertyListener(model_marker_listener); } @Override diff --git a/app/rtplot/src/main/java/org/csstudio/javafx/rtplot/PlotMarker.java b/app/rtplot/src/main/java/org/csstudio/javafx/rtplot/PlotMarker.java index 0f4c320f60..e818b88b50 100644 --- a/app/rtplot/src/main/java/org/csstudio/javafx/rtplot/PlotMarker.java +++ b/app/rtplot/src/main/java/org/csstudio/javafx/rtplot/PlotMarker.java @@ -25,17 +25,20 @@ public class PlotMarker> private final Color color; private volatile boolean interactive; private volatile XTYPE position; + private volatile boolean visible; /** Not meant to be called by user, * call {@link RTPlot #addMarker()} to create a marker. */ public PlotMarker(final Color color, final boolean interactive, - final XTYPE position) + final XTYPE position, + final boolean visible) { this.color = color; this.interactive = interactive; this.position = position; + this.visible = visible; } /** @return Color of the marker */ @@ -69,6 +72,18 @@ public void setPosition(final XTYPE position) // Caller needs to request update of plot } + /** @return Is marker visible? */ + public boolean isVisible() + { + return visible; + } + + /** @param visible Set marker visibility */ + public void setVisible(final boolean visible) + { + this.visible = visible; + } + @Override public String toString() { diff --git a/app/rtplot/src/main/java/org/csstudio/javafx/rtplot/RTPlot.java b/app/rtplot/src/main/java/org/csstudio/javafx/rtplot/RTPlot.java index 2706c036e9..6223e69c99 100644 --- a/app/rtplot/src/main/java/org/csstudio/javafx/rtplot/RTPlot.java +++ b/app/rtplot/src/main/java/org/csstudio/javafx/rtplot/RTPlot.java @@ -497,11 +497,12 @@ public void removeTrace(final Trace trace) /** Add plot marker * @param color * @param interactive + * @param visible * @return {@link PlotMarker} */ - public PlotMarker addMarker(final javafx.scene.paint.Color color, final boolean interactive, final XTYPE position) + public PlotMarker addMarker(final javafx.scene.paint.Color color, final boolean interactive, final XTYPE position, final boolean visible) { - return plot.addMarker(color, interactive, position); + return plot.addMarker(color, interactive, position, visible); } /** @return {@link PlotMarker}s */ diff --git a/app/rtplot/src/main/java/org/csstudio/javafx/rtplot/internal/Plot.java b/app/rtplot/src/main/java/org/csstudio/javafx/rtplot/internal/Plot.java index 13f0fd4354..9f06346629 100644 --- a/app/rtplot/src/main/java/org/csstudio/javafx/rtplot/internal/Plot.java +++ b/app/rtplot/src/main/java/org/csstudio/javafx/rtplot/internal/Plot.java @@ -357,11 +357,12 @@ public void removeTrace(final Trace trace) /** Add plot marker * @param color * @param interactive + * @param visible * @return {@link PlotMarker} */ - public PlotMarker addMarker(final javafx.scene.paint.Color color, final boolean interactive, final XTYPE position) + public PlotMarker addMarker(final javafx.scene.paint.Color color, final boolean interactive, final XTYPE position, final boolean visible) { // Return a PlotMarker that triggers a redraw as it's changed - final PlotMarker marker = new PlotMarker<>(color, interactive, position) + final PlotMarker marker = new PlotMarker<>(color, interactive, position, visible) { @Override public void setPosition(XTYPE position) @@ -721,9 +722,11 @@ private void drawPlotMarkers(final Graphics2D gc) gc.setStroke(AxisPart.TICK_STROKE); for (PlotMarker marker : plot_markers) { - gc.setColor(GraphicsUtils.convert(marker.getColor())); - final int x = x_axis.getScreenCoord(marker.getPosition()); - gc.drawLine(x, y0, x, y1); + if(marker.isVisible()){ + gc.setColor(GraphicsUtils.convert(marker.getColor())); + final int x = x_axis.getScreenCoord(marker.getPosition()); + gc.drawLine(x, y0, x, y1); + } } gc.setStroke(old_stroke); } diff --git a/app/rtplot/src/test/java/org/csstudio/javafx/rtplot/TimePlotDemo.java b/app/rtplot/src/test/java/org/csstudio/javafx/rtplot/TimePlotDemo.java index d009f328e0..4a5e421483 100644 --- a/app/rtplot/src/test/java/org/csstudio/javafx/rtplot/TimePlotDemo.java +++ b/app/rtplot/src/test/java/org/csstudio/javafx/rtplot/TimePlotDemo.java @@ -67,7 +67,7 @@ public void start(final Stage stage) throws Exception plot.addTrace("Jane", "handbags", data[1], colors.next(), TraceType.AREA, 5, LineStyle.SOLID, PointType.NONE, 5, 1); plot.addTrace("Another", "mA", data[2], colors.next(), TraceType.LINES_DIRECT, 1, LineStyle.SOLID, PointType.TRIANGLES, 15, 2); - plot.addMarker(Color.BLUE, true, Instant.now().plusSeconds(5)); + plot.addMarker(Color.BLUE, true, Instant.now().plusSeconds(5), true); final AtomicBoolean run = new AtomicBoolean(true); // Update data at 50Hz