Skip to content

Commit 7101978

Browse files
authored
Merge pull request #3650 from mnabywan/add_plot_marker_visible_property
Add plot marker visible property
2 parents fe88497 + b5da154 commit 7101978

File tree

7 files changed

+87
-31
lines changed

7 files changed

+87
-31
lines changed

app/display/model/src/main/java/org/csstudio/display/builder/model/widgets/plots/XYPlotWidget.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import static org.csstudio.display.builder.model.properties.CommonWidgetProperties.propColor;
1313
import static org.csstudio.display.builder.model.properties.CommonWidgetProperties.propForegroundColor;
1414
import static org.csstudio.display.builder.model.properties.CommonWidgetProperties.propInteractive;
15+
import static org.csstudio.display.builder.model.properties.CommonWidgetProperties.propVisible;
1516
import static org.csstudio.display.builder.model.properties.CommonWidgetProperties.propPVName;
1617
import static org.csstudio.display.builder.model.properties.CommonWidgetProperties.runtimePropConfigure;
1718
import static org.csstudio.display.builder.model.widgets.plots.PlotWidgetProperties.propGridColor;
@@ -99,7 +100,8 @@ protected MarkerProperty(final Widget widget, final String name)
99100
Arrays.asList(propColor.createProperty(widget, new WidgetColor(0, 0, 255)),
100101
propPVName.createProperty(widget, ""),
101102
propInteractive.createProperty(widget, true),
102-
propValue.createProperty(widget, Double.NaN)
103+
propValue.createProperty(widget, Double.NaN),
104+
propVisible.createProperty(widget, true)
103105
));
104106
}
105107

@@ -111,6 +113,8 @@ protected MarkerProperty(final Widget widget, final String name)
111113
public WidgetProperty<Boolean> interactive() { return getElement(2); }
112114
/** @return Marker value */
113115
public WidgetProperty<Double> value() { return getElement(3); }
116+
/** @return Marker visible */
117+
public WidgetProperty<Boolean> visible() { return getElement(4); }
114118
};
115119

116120
/** 'marker' array */

app/display/model/src/main/resources/examples/plots_xy.bob

Lines changed: 50 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<width>181</width>
1010
<height>31</height>
1111
<font>
12-
<font name="Header 1" family="Source Sans Pro" style="BOLD_ITALIC" size="36.0">
12+
<font name="Header 1" family="Liberation Sans" style="BOLD" size="22.0">
1313
</font>
1414
</font>
1515
</widget>
@@ -21,7 +21,7 @@ one for the "X" and one for the "Y" axis.</text>
2121
<width>371</width>
2222
<height>40</height>
2323
</widget>
24-
<widget type="xyplot" version="2.0.0">
24+
<widget type="xyplot" version="3.0.0">
2525
<name>X/Y Plot_1</name>
2626
<y>91</y>
2727
<width>511</width>
@@ -34,6 +34,12 @@ one for the "X" and one for the "Y" axis.</text>
3434
</exp>
3535
<pv_name>loc://interactive(1)</pv_name>
3636
</rule>
37+
<rule name="Visible" prop_id="marker[0].visible" out_exp="false">
38+
<exp bool_exp="pv0&lt;1">
39+
<value>false</value>
40+
</exp>
41+
<pv_name>loc://visible(1)</pv_name>
42+
</rule>
3743
</rules>
3844
<traces>
3945
<trace>
@@ -79,6 +85,7 @@ one for the "X" and one for the "Y" axis.</text>
7985
</color>
8086
<pv_name>loc://pos(50)</pv_name>
8187
<interactive>true</interactive>
88+
<visible>true</visible>
8289
</marker>
8390
</marker>
8491
</widget>
@@ -95,7 +102,7 @@ one for the "X" and one for the "Y" axis.</text>
95102
<y>441</y>
96103
<width>221</width>
97104
<font>
98-
<font name="Header 2" family="Source Sans Pro" style="BOLD_ITALIC" size="21.0">
105+
<font name="Header 2" family="Liberation Sans" style="BOLD" size="18.0">
99106
</font>
100107
</font>
101108
</widget>
@@ -293,7 +300,7 @@ Double-click zooms back out.</text>
293300
<y>471</y>
294301
<width>221</width>
295302
<font>
296-
<font name="Header 3" family="Source Sans Pro" style="BOLD_ITALIC" size="18.0">
303+
<font name="Header 3" family="Liberation Sans" style="BOLD" size="16.0">
297304
</font>
298305
</font>
299306
</widget>
@@ -304,7 +311,7 @@ Double-click zooms back out.</text>
304311
<y>711</y>
305312
<width>70</width>
306313
</widget>
307-
<widget type="xyplot" version="2.0.0">
314+
<widget type="xyplot" version="3.0.0">
308315
<name>RightPlot</name>
309316
<x>591</x>
310317
<y>91</y>
@@ -335,11 +342,11 @@ pvs[1].write(err)
335342
<maximum>10.0</maximum>
336343
<show_grid>false</show_grid>
337344
<title_font>
338-
<font name="Default Bold" family="Source Sans Pro" style="BOLD" size="16.0">
345+
<font name="Default Bold" family="Liberation Sans" style="BOLD" size="14.0">
339346
</font>
340347
</title_font>
341348
<scale_font>
342-
<font name="Default" family="Source Sans Pro" style="REGULAR" size="16.0">
349+
<font name="Default" family="Liberation Sans" style="REGULAR" size="14.0">
343350
</font>
344351
</scale_font>
345352
<visible>true</visible>
@@ -353,14 +360,19 @@ pvs[1].write(err)
353360
<maximum>120.0</maximum>
354361
<show_grid>false</show_grid>
355362
<title_font>
356-
<font name="Default Bold" family="Source Sans Pro" style="BOLD" size="16.0">
363+
<font name="Default Bold" family="Liberation Sans" style="BOLD" size="14.0">
357364
</font>
358365
</title_font>
359366
<scale_font>
360-
<font name="Default" family="Source Sans Pro" style="REGULAR" size="16.0">
367+
<font name="Default" family="Liberation Sans" style="REGULAR" size="14.0">
361368
</font>
362369
</scale_font>
370+
<on_right>false</on_right>
363371
<visible>true</visible>
372+
<color>
373+
<color name="Text" red="0" green="0" blue="0">
374+
</color>
375+
</color>
364376
</y_axis>
365377
</y_axes>
366378
<traces>
@@ -407,7 +419,7 @@ pvs[1].write(err)
407419
<y>441</y>
408420
<width>221</width>
409421
<font>
410-
<font name="Header 2" family="Source Sans Pro" style="BOLD_ITALIC" size="21.0">
422+
<font name="Header 2" family="Liberation Sans" style="BOLD" size="18.0">
411423
</font>
412424
</font>
413425
</widget>
@@ -446,7 +458,7 @@ That local PV is then used as the error bar waveform.</text>
446458
<width>429</width>
447459
<height>69</height>
448460
<font>
449-
<font name="Comment" family="Source Sans Pro" style="ITALIC" size="16.0">
461+
<font name="Comment" family="Liberation Sans" style="ITALIC" size="14.0">
450462
</font>
451463
</font>
452464
</widget>
@@ -464,6 +476,7 @@ Push button to re-enable.</text>
464476
<name>Action Button</name>
465477
<actions>
466478
<action type="execute">
479+
<description>Autoscale</description>
467480
<script file="EmbeddedPy">
468481
<text><![CDATA[from org.csstudio.display.builder.runtime.script import ScriptUtil
469482
@@ -478,7 +491,6 @@ plot.setPropertyValue("y_axes[0].autoscale", False)
478491
plot.setPropertyValue("y_axes[0].autoscale", True)
479492
]]></text>
480493
</script>
481-
<description>Autoscale</description>
482494
</action>
483495
</actions>
484496
<x>1000</x>
@@ -487,7 +499,7 @@ plot.setPropertyValue("y_axes[0].autoscale", True)
487499
<height>29</height>
488500
<tooltip>$(actions)</tooltip>
489501
</widget>
490-
<widget type="xyplot" version="2.0.0">
502+
<widget type="xyplot" version="3.0.0">
491503
<name>X/Y Plot</name>
492504
<y>900</y>
493505
<x_axis>
@@ -498,11 +510,11 @@ plot.setPropertyValue("y_axes[0].autoscale", True)
498510
<maximum>22.0</maximum>
499511
<show_grid>false</show_grid>
500512
<title_font>
501-
<font name="Default Bold" family="Source Sans Pro" style="BOLD" size="16.0">
513+
<font name="Default Bold" family="Liberation Sans" style="BOLD" size="14.0">
502514
</font>
503515
</title_font>
504516
<scale_font>
505-
<font name="Default" family="Source Sans Pro" style="REGULAR" size="16.0">
517+
<font name="Default" family="Liberation Sans" style="REGULAR" size="14.0">
506518
</font>
507519
</scale_font>
508520
<visible>true</visible>
@@ -516,14 +528,19 @@ plot.setPropertyValue("y_axes[0].autoscale", True)
516528
<maximum>10.0</maximum>
517529
<show_grid>false</show_grid>
518530
<title_font>
519-
<font name="Default Bold" family="Source Sans Pro" style="BOLD" size="16.0">
531+
<font name="Default Bold" family="Liberation Sans" style="BOLD" size="14.0">
520532
</font>
521533
</title_font>
522534
<scale_font>
523-
<font name="Default" family="Source Sans Pro" style="REGULAR" size="16.0">
535+
<font name="Default" family="Liberation Sans" style="REGULAR" size="14.0">
524536
</font>
525537
</scale_font>
538+
<on_right>false</on_right>
526539
<visible>true</visible>
540+
<color>
541+
<color name="Text" red="0" green="0" blue="0">
542+
</color>
543+
</color>
527544
</y_axis>
528545
</y_axes>
529546
<traces>
@@ -582,7 +599,7 @@ For a "Line Width" of zero, the bar graph turns into a histogram-type display wi
582599
<y>900</y>
583600
<width>221</width>
584601
<font>
585-
<font name="Header 2" family="Source Sans Pro" style="BOLD_ITALIC" size="21.0">
602+
<font name="Header 2" family="Liberation Sans" style="BOLD" size="18.0">
586603
</font>
587604
</font>
588605
</widget>
@@ -606,10 +623,16 @@ For a "Line Width" of zero, the bar graph turns into a histogram-type display wi
606623
<y>500</y>
607624
<width>140</width>
608625
<height>60</height>
609-
<font>
610-
<font name="Comment" family="Source Sans Pro" style="ITALIC" size="16.0">
626+
<font use_class="true">
627+
<font name="Comment" family="Liberation Sans" style="ITALIC" size="14.0">
611628
</font>
612629
</font>
630+
<foreground_color use_class="true">
631+
<color name="Text" red="0" green="0" blue="0">
632+
</color>
633+
</foreground_color>
634+
<transparent use_class="true">true</transparent>
635+
<wrap_words use_class="true">true</wrap_words>
613636
</widget>
614637
<widget type="checkbox" version="2.0.0">
615638
<name>Check Box</name>
@@ -618,4 +641,11 @@ For a "Line Width" of zero, the bar graph turns into a histogram-type display wi
618641
<x>380</x>
619642
<y>470</y>
620643
</widget>
644+
<widget type="checkbox" version="2.0.0">
645+
<name>Check Box_1</name>
646+
<pv_name>loc://visible(1)</pv_name>
647+
<label> Visible</label>
648+
<x>380</x>
649+
<y>561</y>
650+
</widget>
621651
</display>

app/display/representation-javafx/src/main/java/org/csstudio/display/builder/representation/javafx/widgets/plots/XYPlotRepresentation.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,8 @@ private void createMarker(final MarkerProperty model_marker)
451451
{
452452
final PlotMarker<Double> plot_marker = plot.addMarker(JFXUtil.convert(model_marker.color().getValue()),
453453
model_marker.interactive().getValue(),
454-
model_marker.value().getValue());
454+
model_marker.value().getValue(),
455+
model_marker.visible().getValue());
455456

456457
// Listen to model_marker.value(), interactive() .. and update plot_marker
457458
final UntypedWidgetPropertyListener model_marker_listener = (o, old, value) ->
@@ -461,11 +462,13 @@ private void createMarker(final MarkerProperty model_marker)
461462
changing_marker = true;
462463
plot_marker.setInteractive(model_marker.interactive().getValue());
463464
plot_marker.setPosition(model_marker.value().getValue());
465+
plot_marker.setVisible(model_marker.visible().getValue());
464466
changing_marker = false;
465467
plot.requestUpdate();
466468
};
467469
model_marker.value().addUntypedPropertyListener(model_marker_listener);
468470
model_marker.interactive().addUntypedPropertyListener(model_marker_listener);
471+
model_marker.visible().addUntypedPropertyListener(model_marker_listener);
469472
}
470473

471474
@Override

app/rtplot/src/main/java/org/csstudio/javafx/rtplot/PlotMarker.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,20 @@ public class PlotMarker<XTYPE extends Comparable<XTYPE>>
2525
private final Color color;
2626
private volatile boolean interactive;
2727
private volatile XTYPE position;
28+
private volatile boolean visible;
2829

2930
/** Not meant to be called by user,
3031
* call {@link RTPlot #addMarker()} to create a marker.
3132
*/
3233
public PlotMarker(final Color color,
3334
final boolean interactive,
34-
final XTYPE position)
35+
final XTYPE position,
36+
final boolean visible)
3537
{
3638
this.color = color;
3739
this.interactive = interactive;
3840
this.position = position;
41+
this.visible = visible;
3942
}
4043

4144
/** @return Color of the marker */
@@ -69,6 +72,18 @@ public void setPosition(final XTYPE position)
6972
// Caller needs to request update of plot
7073
}
7174

75+
/** @return Is marker visible? */
76+
public boolean isVisible()
77+
{
78+
return visible;
79+
}
80+
81+
/** @param visible Set marker visibility */
82+
public void setVisible(final boolean visible)
83+
{
84+
this.visible = visible;
85+
}
86+
7287
@Override
7388
public String toString()
7489
{

app/rtplot/src/main/java/org/csstudio/javafx/rtplot/RTPlot.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -497,11 +497,12 @@ public void removeTrace(final Trace<XTYPE> trace)
497497
/** Add plot marker
498498
* @param color
499499
* @param interactive
500+
* @param visible
500501
* @return {@link PlotMarker}
501502
*/
502-
public PlotMarker<XTYPE> addMarker(final javafx.scene.paint.Color color, final boolean interactive, final XTYPE position)
503+
public PlotMarker<XTYPE> addMarker(final javafx.scene.paint.Color color, final boolean interactive, final XTYPE position, final boolean visible)
503504
{
504-
return plot.addMarker(color, interactive, position);
505+
return plot.addMarker(color, interactive, position, visible);
505506
}
506507

507508
/** @return {@link PlotMarker}s */

app/rtplot/src/main/java/org/csstudio/javafx/rtplot/internal/Plot.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -357,11 +357,12 @@ public void removeTrace(final Trace<XTYPE> trace)
357357
/** Add plot marker
358358
* @param color
359359
* @param interactive
360+
* @param visible
360361
* @return {@link PlotMarker}
361362
*/
362-
public PlotMarker<XTYPE> addMarker(final javafx.scene.paint.Color color, final boolean interactive, final XTYPE position)
363+
public PlotMarker<XTYPE> addMarker(final javafx.scene.paint.Color color, final boolean interactive, final XTYPE position, final boolean visible)
363364
{ // Return a PlotMarker that triggers a redraw as it's changed
364-
final PlotMarker<XTYPE> marker = new PlotMarker<>(color, interactive, position)
365+
final PlotMarker<XTYPE> marker = new PlotMarker<>(color, interactive, position, visible)
365366
{
366367
@Override
367368
public void setPosition(XTYPE position)
@@ -721,9 +722,11 @@ private void drawPlotMarkers(final Graphics2D gc)
721722
gc.setStroke(AxisPart.TICK_STROKE);
722723
for (PlotMarker<XTYPE> marker : plot_markers)
723724
{
724-
gc.setColor(GraphicsUtils.convert(marker.getColor()));
725-
final int x = x_axis.getScreenCoord(marker.getPosition());
726-
gc.drawLine(x, y0, x, y1);
725+
if(marker.isVisible()){
726+
gc.setColor(GraphicsUtils.convert(marker.getColor()));
727+
final int x = x_axis.getScreenCoord(marker.getPosition());
728+
gc.drawLine(x, y0, x, y1);
729+
}
727730
}
728731
gc.setStroke(old_stroke);
729732
}

app/rtplot/src/test/java/org/csstudio/javafx/rtplot/TimePlotDemo.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public void start(final Stage stage) throws Exception
6767
plot.addTrace("Jane", "handbags", data[1], colors.next(), TraceType.AREA, 5, LineStyle.SOLID, PointType.NONE, 5, 1);
6868
plot.addTrace("Another", "mA", data[2], colors.next(), TraceType.LINES_DIRECT, 1, LineStyle.SOLID, PointType.TRIANGLES, 15, 2);
6969

70-
plot.addMarker(Color.BLUE, true, Instant.now().plusSeconds(5));
70+
plot.addMarker(Color.BLUE, true, Instant.now().plusSeconds(5), true);
7171

7272
final AtomicBoolean run = new AtomicBoolean(true);
7373
// Update data at 50Hz

0 commit comments

Comments
 (0)