Search in sources :

Example 1 with ROIWidgetProperty

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);
}
Also used : ROIWidgetProperty(org.csstudio.display.builder.model.widgets.plots.ImageWidget.ROIWidgetProperty) RTImagePlot(org.csstudio.javafx.rtplot.RTImagePlot) Pane(javafx.scene.layout.Pane)

Example 2 with ROIWidgetProperty

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());
    }
}
Also used : ROIWidgetProperty(org.csstudio.display.builder.model.widgets.plots.ImageWidget.ROIWidgetProperty)

Example 3 with ROIWidgetProperty

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));
}
Also used : Arrays(java.util.Arrays) DisplayModel(org.csstudio.display.builder.model.DisplayModel) PredefinedColorMaps(org.csstudio.display.builder.model.properties.PredefinedColorMaps) Interpolation(org.csstudio.javafx.rtplot.Interpolation) VImageType(org.diirt.vtype.VImageType) Level(java.util.logging.Level) RTImagePlotListener(org.csstudio.javafx.rtplot.RTImagePlotListener) ValueFactory(org.diirt.vtype.ValueFactory) ImageWidget(org.csstudio.display.builder.model.widgets.plots.ImageWidget) RTImagePlot(org.csstudio.javafx.rtplot.RTImagePlot) ArrayInt(org.diirt.util.array.ArrayInt) DirtyFlag(org.csstudio.display.builder.model.DirtyFlag) WidgetProperty(org.csstudio.display.builder.model.WidgetProperty) ModelThreadPool(org.csstudio.display.builder.model.util.ModelThreadPool) AxisWidgetProperty(org.csstudio.display.builder.model.widgets.plots.ImageWidget.AxisWidgetProperty) VNumberArray(org.diirt.vtype.VNumberArray) Pane(javafx.scene.layout.Pane) NamedColorMappings(org.csstudio.javafx.rtplot.NamedColorMappings) ModelResourceUtil(org.csstudio.display.builder.model.util.ModelResourceUtil) Rectangle2D(javafx.geometry.Rectangle2D) ROIWidgetProperty(org.csstudio.display.builder.model.widgets.plots.ImageWidget.ROIWidgetProperty) RegionBaseRepresentation(org.csstudio.display.builder.representation.javafx.widgets.RegionBaseRepresentation) RepresentationUpdateThrottle(org.csstudio.display.builder.representation.RepresentationUpdateThrottle) RegionOfInterest(org.csstudio.javafx.rtplot.RegionOfInterest) VType(org.diirt.vtype.VType) ColorMap(org.csstudio.display.builder.model.properties.ColorMap) ToolkitRepresentation.logger(org.csstudio.display.builder.representation.ToolkitRepresentation.logger) TimeUnit(java.util.concurrent.TimeUnit) Platform(javafx.application.Platform) List(java.util.List) MacroHandler(org.csstudio.display.builder.model.macros.MacroHandler) WidgetPropertyListener(org.csstudio.display.builder.model.WidgetPropertyListener) ArrayDouble(org.diirt.util.array.ArrayDouble) ColorMappingFunction(org.csstudio.javafx.rtplot.ColorMappingFunction) JFXUtil(org.csstudio.display.builder.representation.javafx.JFXUtil) Axis(org.csstudio.javafx.rtplot.Axis) VImage(org.diirt.vtype.VImage) Image(javafx.scene.image.Image) RegionOfInterest(org.csstudio.javafx.rtplot.RegionOfInterest) Rectangle2D(javafx.geometry.Rectangle2D) ArrayDouble(org.diirt.util.array.ArrayDouble)

Aggregations

ROIWidgetProperty (org.csstudio.display.builder.model.widgets.plots.ImageWidget.ROIWidgetProperty)3 Pane (javafx.scene.layout.Pane)2 RTImagePlot (org.csstudio.javafx.rtplot.RTImagePlot)2 Arrays (java.util.Arrays)1 List (java.util.List)1 TimeUnit (java.util.concurrent.TimeUnit)1 Level (java.util.logging.Level)1 Platform (javafx.application.Platform)1 Rectangle2D (javafx.geometry.Rectangle2D)1 Image (javafx.scene.image.Image)1 DirtyFlag (org.csstudio.display.builder.model.DirtyFlag)1 DisplayModel (org.csstudio.display.builder.model.DisplayModel)1 WidgetProperty (org.csstudio.display.builder.model.WidgetProperty)1 WidgetPropertyListener (org.csstudio.display.builder.model.WidgetPropertyListener)1 MacroHandler (org.csstudio.display.builder.model.macros.MacroHandler)1 ColorMap (org.csstudio.display.builder.model.properties.ColorMap)1 PredefinedColorMaps (org.csstudio.display.builder.model.properties.PredefinedColorMaps)1 ModelResourceUtil (org.csstudio.display.builder.model.util.ModelResourceUtil)1 ModelThreadPool (org.csstudio.display.builder.model.util.ModelThreadPool)1 ImageWidget (org.csstudio.display.builder.model.widgets.plots.ImageWidget)1