use of org.csstudio.display.builder.model.widgets.plots.ImageWidget.ROIWidgetProperty in project org.csstudio.display.builder by kasemir.
the class ImageRepresentation method createJFXNode.
@Override
public Pane createJFXNode() throws Exception {
// Plot is only active in runtime mode, not edit mode
image_plot = new RTImagePlot(!toolkit.isEditMode());
image_plot.setUpdateThrottle(RepresentationUpdateThrottle.plot_update_delay, TimeUnit.MILLISECONDS);
image_plot.setAutoscale(false);
if (!toolkit.isEditMode()) {
// Create ROIs once. Not allowing adding/removing ROIs in runtime.
for (ROIWidgetProperty roi : model_widget.propROIs().getValue()) createROI(roi);
}
return new Pane(image_plot);
}
use of org.csstudio.display.builder.model.widgets.plots.ImageWidget.ROIWidgetProperty in project org.csstudio.display.builder by kasemir.
the class ImageWidgetRuntime method start.
@Override
public void start() throws Exception {
super.start();
// Connect cursor related PVs
cursor_pv = bindPV(widget.propCursorInfoPV().getValue());
x_pv = bindPV(widget.propCursorXPV().getValue());
y_pv = bindPV(widget.propCursorYPV().getValue());
if (cursor_pv != null)
widget.runtimePropCursorInfo().addPropertyListener(cursor_info_listener);
if (x_pv != null || y_pv != null)
widget.runtimePropCrosshair().addPropertyListener(crosshair_listener);
if (x_pv != null && y_pv != null) {
x_pv.addListener(cursor_pv_listener);
y_pv.addListener(cursor_pv_listener);
}
// Connect ROI PVs
for (ROIWidgetProperty roi : widget.propROIs().getValue()) {
bindROI(roi.x_pv(), roi.x_value());
bindROI(roi.y_pv(), roi.y_value());
bindROI(roi.width_pv(), roi.width_value());
bindROI(roi.height_pv(), roi.height_value());
}
}
use of org.csstudio.display.builder.model.widgets.plots.ImageWidget.ROIWidgetProperty in project org.csstudio.display.builder by kasemir.
the class ImageRepresentation method createROI.
private void createROI(final ROIWidgetProperty model_roi) {
final RegionOfInterest plot_roi = image_plot.addROI(model_roi.name().getValue(), JFXUtil.convert(model_roi.color().getValue()), model_roi.visible().getValue(), model_roi.interactive().getValue());
// Show/hide ROI as roi.visible() changes
model_roi.visible().addPropertyListener((prop, old, visible) -> {
plot_roi.setVisible(visible);
Platform.runLater(() -> image_plot.removeROITracker());
image_plot.requestUpdate();
});
// For now _not_ listening to runtime changes of roi.interactive() or roi.file() ...
// Listen to roi.x_value(), .. and update plot_roi
final WidgetPropertyListener<Double> model_roi_listener = (o, old, value) -> {
if (changing_roi)
return;
Rectangle2D region = plot_roi.getRegion();
region = new Rectangle2D(existingOrProperty(region.getMinX(), model_roi.x_value()), existingOrProperty(region.getMinY(), model_roi.y_value()), existingOrProperty(region.getWidth(), model_roi.width_value()), existingOrProperty(region.getHeight(), model_roi.height_value()));
changing_roi = true;
plot_roi.setRegion(region);
changing_roi = false;
image_plot.requestUpdate();
};
model_roi.x_value().addPropertyListener(model_roi_listener);
model_roi.y_value().addPropertyListener(model_roi_listener);
model_roi.width_value().addPropertyListener(model_roi_listener);
model_roi.height_value().addPropertyListener(model_roi_listener);
// Load image file (if there is one) on background thread
ModelThreadPool.getExecutor().execute(() -> loadROI_Image(plot_roi, model_roi));
}
Aggregations