use of org.eclipse.scanning.api.points.models.BoundingLine in project gda-core by openGDA.
the class FocusScanConverterTest method testConvertFocusScanBean.
@Test
public void testConvertFocusScanBean() {
final ScanRequest scanRequest = focusScanConverter.convertToScanRequest(focusScanBean);
// test compound model
final CompoundModel compoundModel = scanRequest.getCompoundModel();
assertNotNull(compoundModel);
final List<IScanPointGeneratorModel> models = compoundModel.getModels();
assertEquals(2, models.size());
// test outer model - the focus model
assertThat(models.get(0), is(instanceOf(AxialStepModel.class)));
final AxialStepModel focusModel = (AxialStepModel) models.get(0);
assertEquals(1, focusModel.getScannableNames().size());
assertEquals(focusScanBean.getFocusScannableName(), focusModel.getScannableNames().get(0));
assertEquals(focusScanBean.getFocusCentre() - focusScanBean.getFocusRange() + focusModel.getStep() / 2, focusModel.getStart(), 1e-15);
assertEquals(focusScanBean.getFocusCentre() + focusScanBean.getFocusRange() - focusModel.getStep() / 2 + focusModel.getStep() / 100, focusModel.getStop(), 1e-15);
assertEquals(focusScanBean.getFocusRange() * 2 / focusScanBean.getNumberOfFocusSteps(), focusModel.getStep(), 1e-15);
// test inner model - the line model
assertThat(models.get(1), is(instanceOf(TwoAxisLinePointsModel.class)));
final TwoAxisLinePointsModel lineModel = (TwoAxisLinePointsModel) models.get(1);
assertEquals(2, lineModel.getScannableNames().size());
assertEquals(mappingStageInfo.getPlotYAxisName(), lineModel.getScannableNames().get(1));
assertEquals(mappingStageInfo.getPlotXAxisName(), lineModel.getScannableNames().get(0));
assertEquals(focusScanBean.getNumberOfLinePoints(), lineModel.getPoints());
final BoundingLine boundingLine = lineModel.getBoundingLine();
assertNotNull(boundingLine);
final LinearROI expectedRegion = (LinearROI) focusScanBean.getLineRegion().toROI();
assertEquals(expectedRegion.getPointX(), boundingLine.getxStart(), 1e-15);
assertEquals(expectedRegion.getPointY(), boundingLine.getyStart(), 1e-15);
assertEquals(expectedRegion.getAngle(), boundingLine.getAngle(), 1e-15);
assertEquals(expectedRegion.getLength(), boundingLine.getLength(), 1e-15);
// test scan regions
assertEquals(1, compoundModel.getRegions().size());
final ScanRegion scanRegion = compoundModel.getRegions().iterator().next();
assertEquals(2, scanRegion.getScannables().size());
assertEquals(mappingStageInfo.getPlotYAxisName(), scanRegion.getScannables().get(1));
assertEquals(mappingStageInfo.getPlotXAxisName(), scanRegion.getScannables().get(0));
assertThat(scanRegion.getRoi(), is(instanceOf(LinearROI.class)));
assertEquals(expectedRegion, scanRegion.getRoi());
// test detectors
final Map<String, IDetectorModel> detectors = scanRequest.getDetectors();
assertNotNull(detectors);
assertEquals(1, detectors.size());
assertTrue(detectors.containsKey("mandelbrot"));
assertThat(detectors.get("mandelbrot"), is(instanceOf(MandelbrotModel.class)));
// test that the remaining fields have not been set
assertThat(scanRequest.getMonitorNamesPerPoint(), is(empty()));
assertThat(scanRequest.getMonitorNamesPerScan(), is(empty()));
assertThat(scanRequest.getScanMetadata(), is(nullValue()));
assertThat(scanRequest.getAfterScript(), is(nullValue()));
assertThat(scanRequest.getBeforeScript(), is(nullValue()));
assertThat(scanRequest.isAlwaysRunAfterScript(), is(false));
assertThat(scanRequest.getStartPosition(), is(nullValue()));
assertThat(scanRequest.getEndPosition(), is(nullValue()));
assertThat(scanRequest.getFilePath(), is(nullValue()));
}
use of org.eclipse.scanning.api.points.models.BoundingLine in project gda-core by openGDA.
the class RegionAndPathMapper method mapRegionOntoBoundingLineModel.
/**
* Updates the {@link BoundingLine} of an {@link IBoundingLineModel} to conform to
* a {@link IMappingScanRegionShape}
* @param scanRegionShape The region to map onto the model
* @param lineModel The model to update
*/
private static void mapRegionOntoBoundingLineModel(IBoundingLineModel lineModel, IMappingScanRegionShape scanRegionShape) {
IROI roi = scanRegionShape.toROI();
if (roi instanceof LinearROI) {
LinearROI linearROI = (LinearROI) roi;
BoundingLine line = lineModel.getBoundingLine();
if (line == null) {
line = new BoundingLine();
lineModel.setBoundingLine(line);
}
line.setxStart(linearROI.getPointX());
line.setyStart(linearROI.getPointY());
line.setAngle(linearROI.getAngle());
line.setLength(linearROI.getLength());
}
}
use of org.eclipse.scanning.api.points.models.BoundingLine in project gda-core by openGDA.
the class FocusScanConverter method createLineModel.
private IBoundingLineModel createLineModel(FocusScanBean focusScanBean) {
final ILineMappingRegion lineRegion = focusScanBean.getLineRegion();
final int numPoints = focusScanBean.getNumberOfLinePoints();
final TwoAxisLinePointsModel lineModel = new TwoAxisLinePointsModel();
lineModel.setPoints(numPoints);
// continuous if possible (i.e. malcolm)
lineModel.setContinuous(true);
if (mappingStageInfo != null) {
lineModel.setxAxisName(mappingStageInfo.getPlotXAxisName());
lineModel.setyAxisName(mappingStageInfo.getPlotYAxisName());
}
// DO we need to do this, as we set the region in the scan request?
final LinearROI lineRoi = (LinearROI) lineRegion.toROI();
BoundingLine line = lineModel.getBoundingLine();
if (line == null) {
line = new BoundingLine();
lineModel.setBoundingLine(line);
}
line.setxStart(lineRoi.getPointX());
line.setyStart(lineRoi.getPointY());
line.setAngle(lineRoi.getAngle());
line.setLength(lineRoi.getLength());
lineModel.setBoundingLine(line);
return lineModel;
}
Aggregations