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