Search in sources :

Example 1 with IntensityGraphFigure

use of org.csstudio.swt.widgets.figures.IntensityGraphFigure 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 IntensityGraphFigure

use of org.csstudio.swt.widgets.figures.IntensityGraphFigure in project yamcs-studio by yamcs.

the class IntensityGraphEditPart method registerPropertyChangeHandlers.

@Override
protected void registerPropertyChangeHandlers() {
    innerUpdateGraphAreaSizeProperty();
    registerAxisPropertyChangeHandler();
    registerROIPropertyChangeHandlers();
    registerROIAmountChangeHandler();
    IWidgetPropertyChangeHandler handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            if (newValue == null)
                return false;
            VType value = (VType) newValue;
            if (value instanceof VNumberArray) {
                setValue(((VNumberArray) value).getData());
                return false;
            }
            ((IntensityGraphFigure) figure).setDataArray(VTypeHelper.getDoubleArray(value));
            return false;
        }
    };
    setPropertyChangeHandler(AbstractPVWidgetModel.PROP_PVVALUE, handler);
    getWidgetModel().getProperty(IntensityGraphModel.PROP_MIN).addPropertyChangeListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            ((IntensityGraphFigure) figure).setMin((Double) evt.getNewValue());
            figure.repaint();
            innerUpdateGraphAreaSizeProperty();
        }
    });
    getWidgetModel().getProperty(IntensityGraphModel.PROP_MAX).addPropertyChangeListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            ((IntensityGraphFigure) figure).setMax((Double) evt.getNewValue());
            figure.repaint();
            innerUpdateGraphAreaSizeProperty();
        }
    });
    getWidgetModel().getProperty(IntensityGraphModel.PROP_BORDER_STYLE).removeAllPropertyChangeListeners();
    getWidgetModel().getProperty(IntensityGraphModel.PROP_BORDER_STYLE).addPropertyChangeListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            figure.setBorder(BorderFactory.createBorder(BorderStyle.values()[(Integer) evt.getNewValue()], getWidgetModel().getBorderWidth(), getWidgetModel().getBorderColor(), getWidgetModel().getName()));
            innerUpdateGraphAreaSizeProperty();
        }
    });
    getWidgetModel().getProperty(IntensityGraphModel.PROP_BORDER_WIDTH).removeAllPropertyChangeListeners();
    getWidgetModel().getProperty(IntensityGraphModel.PROP_BORDER_WIDTH).addPropertyChangeListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            figure.setBorder(BorderFactory.createBorder(getWidgetModel().getBorderStyle(), (Integer) evt.getNewValue(), getWidgetModel().getBorderColor(), getWidgetModel().getName()));
            innerUpdateGraphAreaSizeProperty();
        }
    });
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            ((IntensityGraphFigure) figure).setDataWidth((Integer) newValue);
            return true;
        }
    };
    setPropertyChangeHandler(IntensityGraphModel.PROP_DATA_WIDTH, handler);
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            ((IntensityGraphFigure) figure).setDataHeight((Integer) newValue);
            return true;
        }
    };
    setPropertyChangeHandler(IntensityGraphModel.PROP_DATA_HEIGHT, handler);
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            ((IntensityGraphFigure) figure).setColorMap((ColorMap) newValue);
            return true;
        }
    };
    setPropertyChangeHandler(IntensityGraphModel.PROP_COLOR_MAP, handler);
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            ((IntensityGraphFigure) figure).setCropLeft((Integer) newValue);
            return true;
        }
    };
    setPropertyChangeHandler(IntensityGraphModel.PROP_CROP_LEFT, handler);
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            ((IntensityGraphFigure) figure).setCropRight((Integer) newValue);
            return true;
        }
    };
    setPropertyChangeHandler(IntensityGraphModel.PROP_CROP_RIGHT, handler);
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            ((IntensityGraphFigure) figure).setCropTop((Integer) newValue);
            return true;
        }
    };
    setPropertyChangeHandler(IntensityGraphModel.PROP_CROP_TOP, handler);
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            ((IntensityGraphFigure) figure).setCropBottom((Integer) newValue);
            return true;
        }
    };
    setPropertyChangeHandler(IntensityGraphModel.PROP_CROP_BOTTOM, handler);
    getWidgetModel().getProperty(IntensityGraphModel.PROP_SHOW_RAMP).addPropertyChangeListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            ((IntensityGraphFigure) getFigure()).setShowRamp((Boolean) evt.getNewValue());
            Dimension d = ((IntensityGraphFigure) getFigure()).getGraphAreaInsets();
            innerTrig = true;
            getWidgetModel().setPropertyValue(IntensityGraphModel.PROP_GRAPH_AREA_WIDTH, getWidgetModel().getWidth() - d.width);
            innerTrig = false;
        }
    });
    getWidgetModel().getProperty(IntensityGraphModel.PROP_WIDTH).addPropertyChangeListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            if (!innerTrig) {
                // if it is not triggered from inner
                innerTrig = true;
                Dimension d = ((IntensityGraphFigure) getFigure()).getGraphAreaInsets();
                getWidgetModel().setPropertyValue(IntensityGraphModel.PROP_GRAPH_AREA_WIDTH, ((Integer) evt.getNewValue()) - d.width);
                // reset innerTrig to false after each inner triggering
                innerTrig = false;
            } else
                // if it is triggered from inner, do nothing
                innerTrig = false;
        }
    });
    getWidgetModel().getProperty(IntensityGraphModel.PROP_GRAPH_AREA_WIDTH).addPropertyChangeListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            if (!innerTrig) {
                innerTrig = true;
                Dimension d = ((IntensityGraphFigure) getFigure()).getGraphAreaInsets();
                getWidgetModel().setPropertyValue(IntensityGraphModel.PROP_WIDTH, ((Integer) evt.getNewValue()) + d.width);
                // reset innerTrig to false after each inner triggering
                innerTrig = false;
            } else
                innerTrig = false;
        }
    });
    getWidgetModel().getProperty(IntensityGraphModel.PROP_HEIGHT).addPropertyChangeListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            if (!innerTrig) {
                innerTrig = true;
                Dimension d = ((IntensityGraphFigure) getFigure()).getGraphAreaInsets();
                getWidgetModel().setPropertyValue(IntensityGraphModel.PROP_GRAPH_AREA_HEIGHT, ((Integer) evt.getNewValue()) - d.height);
                // reset innerTrig to false after each inner triggering
                innerTrig = false;
            } else
                innerTrig = false;
        }
    });
    getWidgetModel().getProperty(IntensityGraphModel.PROP_GRAPH_AREA_HEIGHT).addPropertyChangeListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            if (!innerTrig) {
                innerTrig = true;
                Dimension d = ((IntensityGraphFigure) getFigure()).getGraphAreaInsets();
                getWidgetModel().setPropertyValue(IntensityGraphModel.PROP_HEIGHT, ((Integer) evt.getNewValue()) + d.height);
                // reset innerTrig to false after each inner triggering
                innerTrig = false;
            } else
                innerTrig = false;
        }
    });
    getWidgetModel().getProperty(IntensityGraphModel.PROP_RGB_MODE).addPropertyChangeListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            updatePropSheet();
            ((IntensityGraphFigure) getFigure()).setInRGBMode((Boolean) (evt.getNewValue()));
        }
    });
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            ((IntensityGraphFigure) getFigure()).setColorDepth(getWidgetModel().getColorDepth());
            return false;
        }
    };
    setPropertyChangeHandler(IntensityGraphModel.PROP_COLOR_DEPTH, handler);
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            ((IntensityGraphFigure) getFigure()).setSingleLineProfiling((Boolean) newValue);
            return false;
        }
    };
    setPropertyChangeHandler(IntensityGraphModel.PROP_SINGLE_LINE_PROFILING, handler);
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            ((IntensityGraphFigure) getFigure()).setROIColor(((OPIColor) newValue).getSWTColor());
            return false;
        }
    };
    setPropertyChangeHandler(IntensityGraphModel.PROP_ROI_COLOR, handler);
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener) ColorMap(org.csstudio.swt.widgets.datadefinition.ColorMap) PredefinedColorMap(org.csstudio.swt.widgets.datadefinition.ColorMap.PredefinedColorMap) Dimension(org.eclipse.draw2d.geometry.Dimension) ArrayDouble(org.diirt.util.array.ArrayDouble) VNumberArray(org.diirt.vtype.VNumberArray) IntensityGraphFigure(org.csstudio.swt.widgets.figures.IntensityGraphFigure) VType(org.diirt.vtype.VType) IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler) OPIColor(org.csstudio.opibuilder.util.OPIColor) IFigure(org.eclipse.draw2d.IFigure)

Example 3 with IntensityGraphFigure

use of org.csstudio.swt.widgets.figures.IntensityGraphFigure in project yamcs-studio by yamcs.

the class IntensityGraphEditPart method innerUpdateGraphAreaSizeProperty.

private synchronized void innerUpdateGraphAreaSizeProperty() {
    Dimension d = ((IntensityGraphFigure) figure).getGraphAreaInsets();
    innerTrig = true;
    getWidgetModel().setPropertyValue(IntensityGraphModel.PROP_GRAPH_AREA_WIDTH, getWidgetModel().getSize().width - d.width);
    // recover innerTrig
    innerTrig = true;
    getWidgetModel().setPropertyValue(IntensityGraphModel.PROP_GRAPH_AREA_HEIGHT, getWidgetModel().getSize().height - d.height);
    // reset innerTrig to false after each inner triggering
    innerTrig = false;
}
Also used : IntensityGraphFigure(org.csstudio.swt.widgets.figures.IntensityGraphFigure) Dimension(org.eclipse.draw2d.geometry.Dimension)

Example 4 with IntensityGraphFigure

use of org.csstudio.swt.widgets.figures.IntensityGraphFigure 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

IntensityGraphFigure (org.csstudio.swt.widgets.figures.IntensityGraphFigure)4 PropertyChangeEvent (java.beans.PropertyChangeEvent)2 PropertyChangeListener (java.beans.PropertyChangeListener)2 IWidgetPropertyChangeHandler (org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler)2 AxisProperty (org.csstudio.opibuilder.widgets.model.IntensityGraphModel.AxisProperty)2 ArrayDouble (org.diirt.util.array.ArrayDouble)2 Dimension (org.eclipse.draw2d.geometry.Dimension)2 List (java.util.List)1 OPIColor (org.csstudio.opibuilder.util.OPIColor)1 IntensityGraphModel (org.csstudio.opibuilder.widgets.model.IntensityGraphModel)1 ColorMap (org.csstudio.swt.widgets.datadefinition.ColorMap)1 PredefinedColorMap (org.csstudio.swt.widgets.datadefinition.ColorMap.PredefinedColorMap)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 ArrayInt (org.diirt.util.array.ArrayInt)1 VNumberArray (org.diirt.vtype.VNumberArray)1 VType (org.diirt.vtype.VType)1 IFigure (org.eclipse.draw2d.IFigure)1 Range (org.eclipse.nebula.visualization.xygraph.linearscale.Range)1