Search in sources :

Example 1 with AxisProperty

use of org.csstudio.opibuilder.widgets.model.IntensityGraphModel.AxisProperty in project yamcs-studio by yamcs.

the class IntensityGraphEditPart method doCreateFigure.

@Override
protected IFigure doCreateFigure() {
    IntensityGraphModel model = getWidgetModel();
    graph = new IntensityGraphFigure(getExecutionMode() == ExecutionMode.RUN_MODE);
    graph.setMin(model.getMinimum());
    graph.setMax(model.getMaximum());
    graph.setDataWidth(model.getDataWidth());
    graph.setDataHeight(model.getDataHeight());
    graph.setColorMap(model.getColorMap());
    graph.setShowRamp(model.isShowRamp());
    graph.setCropLeft(model.getCropLeft());
    graph.setCropRight(model.getCropRight());
    graph.setCropTop(model.getCropTOP());
    graph.setCropBottom(model.getCropBottom());
    graph.setInRGBMode(model.isRGBMode());
    graph.setColorDepth(model.getColorDepth());
    graph.setSingleLineProfiling(model.isSingleLineProfiling());
    graph.setROIColor(model.getROIColor().getSWTColor());
    // init X-Axis
    for (AxisProperty axisProperty : AxisProperty.values()) {
        String propID = IntensityGraphModel.makeAxisPropID(IntensityGraphModel.X_AXIS_ID, axisProperty.propIDPre);
        setAxisProperty(graph.getXAxis(), axisProperty, model.getPropertyValue(propID));
    }
    // init Y-Axis
    for (AxisProperty axisProperty : AxisProperty.values()) {
        String propID = IntensityGraphModel.makeAxisPropID(IntensityGraphModel.Y_AXIS_ID, axisProperty.propIDPre);
        setAxisProperty(graph.getYAxis(), axisProperty, model.getPropertyValue(propID));
    }
    if (getExecutionMode() == ExecutionMode.RUN_MODE) {
        // add profile data listener
        if (model.getHorizonProfileYPV().trim().length() > 0 || model.getVerticalProfileYPV().trim().length() > 0) {
            graph.addProfileDataListener(new IProfileDataChangeLisenter() {

                @Override
                public void profileDataChanged(double[] xProfileData, double[] yProfileData, Range xAxisRange, Range yAxisRange) {
                    // horizontal
                    setPVValue(IntensityGraphModel.PROP_HORIZON_PROFILE_Y_PV_NAME, xProfileData);
                    double[] horizonXData = new double[xProfileData.length];
                    double d = (xAxisRange.getUpper() - xAxisRange.getLower()) / (xProfileData.length - 1);
                    for (int i = 0; i < xProfileData.length; i++) {
                        horizonXData[i] = xAxisRange.getLower() + d * i;
                    }
                    setPVValue(IntensityGraphModel.PROP_HORIZON_PROFILE_X_PV_NAME, horizonXData);
                    // vertical
                    setPVValue(IntensityGraphModel.PROP_VERTICAL_PROFILE_Y_PV_NAME, yProfileData);
                    double[] verticalXData = new double[yProfileData.length];
                    d = (yAxisRange.getUpper() - yAxisRange.getLower()) / (yProfileData.length - 1);
                    for (int i = 0; i < yProfileData.length; i++) {
                        verticalXData[i] = yAxisRange.getUpper() - d * i;
                    }
                    setPVValue(IntensityGraphModel.PROP_VERTICAL_PROFILE_X_PV_NAME, verticalXData);
                }
            });
        }
        if (model.getPixelInfoPV().trim().length() > 0) {
            // Listen to pixel info, forward to PV
            graph.addPixelInfoListener(new IPixelInfoListener() {

                @Override
                public void pixelInfoChanged(final PixelInfo pixel_info, final boolean selected) {
                    // TODO "Selected" column should be boolean, but there is no 'ArrayBoolean', and List<Boolean>
                    // also fails
                    final List<Object> values = Arrays.<Object>asList(new ArrayDouble(pixel_info.xcoord), new ArrayDouble(pixel_info.ycoord), new ArrayDouble(pixel_info.value), new ArrayInt(selected ? 1 : 0));
                    final Object value = ValueFactory.newVTable(pixel_info_table_types, pixel_info_table_columns, values);
                    setPVValue(IntensityGraphModel.PROP_PIXEL_INFO_PV_NAME, value);
                }
            });
        }
    }
    updatePropSheet();
    return graph;
}
Also used : AxisProperty(org.csstudio.opibuilder.widgets.model.IntensityGraphModel.AxisProperty) IPixelInfoListener(org.csstudio.swt.widgets.figures.IntensityGraphFigure.IPixelInfoListener) IProfileDataChangeLisenter(org.csstudio.swt.widgets.figures.IntensityGraphFigure.IProfileDataChangeLisenter) Range(org.eclipse.nebula.visualization.xygraph.linearscale.Range) PixelInfo(org.csstudio.swt.widgets.figures.IntensityGraphFigure.PixelInfo) IntensityGraphFigure(org.csstudio.swt.widgets.figures.IntensityGraphFigure) ArrayDouble(org.diirt.util.array.ArrayDouble) List(java.util.List) IntensityGraphModel(org.csstudio.opibuilder.widgets.model.IntensityGraphModel) ArrayInt(org.diirt.util.array.ArrayInt)

Example 2 with AxisProperty

use of org.csstudio.opibuilder.widgets.model.IntensityGraphModel.AxisProperty in project yamcs-studio by yamcs.

the class IntensityGraphEditPart method registerAxisPropertyChangeHandler.

private void registerAxisPropertyChangeHandler() {
    for (String axisID : new String[] { IntensityGraphModel.X_AXIS_ID, IntensityGraphModel.Y_AXIS_ID }) {
        for (AxisProperty axisProperty : AxisProperty.values()) {
            final IWidgetPropertyChangeHandler handler = new AxisPropertyChangeHandler(axisID.equals(IntensityGraphModel.X_AXIS_ID) ? ((IntensityGraphFigure) getFigure()).getXAxis() : ((IntensityGraphFigure) getFigure()).getYAxis(), axisProperty);
            // must use listener instead of handler because the prop sheet need to be
            // refreshed immediately.
            getWidgetModel().getProperty(IntensityGraphModel.makeAxisPropID(axisID, axisProperty.propIDPre)).addPropertyChangeListener(new PropertyChangeListener() {

                @Override
                public void propertyChange(PropertyChangeEvent evt) {
                    handler.handleChange(evt.getOldValue(), evt.getNewValue(), getFigure());
                    UIBundlingThread.getInstance().addRunnable(getViewer().getControl().getDisplay(), new Runnable() {

                        @Override
                        public void run() {
                            getFigure().repaint();
                        }
                    });
                }
            });
        }
    }
}
Also used : IntensityGraphFigure(org.csstudio.swt.widgets.figures.IntensityGraphFigure) AxisProperty(org.csstudio.opibuilder.widgets.model.IntensityGraphModel.AxisProperty) PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener) IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler)

Aggregations

AxisProperty (org.csstudio.opibuilder.widgets.model.IntensityGraphModel.AxisProperty)2 IntensityGraphFigure (org.csstudio.swt.widgets.figures.IntensityGraphFigure)2 PropertyChangeEvent (java.beans.PropertyChangeEvent)1 PropertyChangeListener (java.beans.PropertyChangeListener)1 List (java.util.List)1 IWidgetPropertyChangeHandler (org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler)1 IntensityGraphModel (org.csstudio.opibuilder.widgets.model.IntensityGraphModel)1 IPixelInfoListener (org.csstudio.swt.widgets.figures.IntensityGraphFigure.IPixelInfoListener)1 IProfileDataChangeLisenter (org.csstudio.swt.widgets.figures.IntensityGraphFigure.IProfileDataChangeLisenter)1 PixelInfo (org.csstudio.swt.widgets.figures.IntensityGraphFigure.PixelInfo)1 ArrayDouble (org.diirt.util.array.ArrayDouble)1 ArrayInt (org.diirt.util.array.ArrayInt)1 Range (org.eclipse.nebula.visualization.xygraph.linearscale.Range)1