use of org.eclipse.scanning.api.points.models.TwoAxisGridStepModel in project gda-core by openGDA.
the class MScanSubmitterTest method setUp.
@Before
public void setUp() throws Exception {
try (final MockedStatic<JythonServerFacade> facade = mockStatic(JythonServerFacade.class)) {
facade.when(JythonServerFacade::getInstance).thenReturn(theFacadeInstance);
builder = new MScanSubmitter(eventService, runnableDeviceService, resolverFactory);
when(eventService.getEventConnectorService()).thenReturn(connectorService);
when(connectorService.marshal(any())).thenReturn("");
when(eventService.createSubmitter(any(), any())).thenReturn(submitter);
when(eventService.createSubscriber(any(), anyString())).thenReturn(eventSubscriber);
when(resolverFactory.getResolver(captor.capture())).thenReturn(resolver);
when(detector.getName()).thenReturn(DETECTOR_NAME);
when(runnableDeviceService.getRunnableDevice(DETECTOR_NAME)).thenReturn(runnableDevice);
when(runnableDevice.getModel()).thenReturn(detectorModel);
when(detectorRunnableDevice.getModel()).thenReturn(detectorModel);
when(monitor.getName()).thenReturn("monitor");
when(scannable.getName()).thenReturn("stage_x");
when(scannable.getUserUnits()).thenReturn("mm");
when(anotherScannable.getName()).thenReturn("stage_y");
when(anotherScannable.getUserUnits()).thenReturn("mm");
point = new TwoAxisPointSingleModel();
point.setX(2.0);
point.setY(3.0);
pointRoi = new PointROI(point.getX(), point.getY());
axPoints = new AxialPointsModel(scannable.getName(), 2, 3, 20);
axPoints.setContinuous(false);
axStep = new AxialStepModel(scannable.getName(), 2, 3, 0.2);
axStep.setContinuous(false);
axArray = new AxialArrayModel(scannable.getName(), positions);
axArray.setContinuous(false);
liPoints = new TwoAxisLinePointsModel();
liPoints.setPoints(20);
liStep = new TwoAxisLineStepModel();
liStep.setStep(0.2);
line = new LinearROI(new double[] { 2, 2 }, new double[] { 3, 3 });
grid = new TwoAxisGridPointsModel(scannable.getName(), anotherScannable.getName(), 20, 10);
grid.setContinuous(false);
steppedGrid = new TwoAxisGridStepModel();
steppedGrid.setxAxisStep(0.1);
steppedGrid.setyAxisStep(0.2);
steppedGrid.setContinuous(false);
rectangle = new RectangularROI(2, 3, 4, 5, 0);
rectangleX2 = rectangle.getPointX() + rectangle.getLength(X);
rectangleY2 = rectangle.getPointY() + rectangle.getLength(Y);
circle = new CircularROI(5.5, 2, 3);
}
}
use of org.eclipse.scanning.api.points.models.TwoAxisGridStepModel in project gda-core by openGDA.
the class ScanpathTest method createModelCreatesCorrectModelForRasterWithVerticalMutator.
@Test
public void createModelCreatesCorrectModelForRasterWithVerticalMutator() throws Exception {
pathParams = Arrays.asList(0.5, 6.5);
mutators.put(Mutator.VERTICAL, Arrays.asList(blankArray));
IScanPathModel model = GRID_STEP.createModel(scannables, pathParams, bboxParams, mutators);
assertThat(model, is(instanceOf(TwoAxisGridStepModel.class)));
TwoAxisGridStepModel rModel = (TwoAxisGridStepModel) model;
assertThat(rModel.getScannableNames(), contains("name1", "name2"));
assertThat(rModel.getBoundingBox().getxAxisStart(), is(1.0));
assertThat(rModel.getBoundingBox().getyAxisStart(), is(2.0));
assertThat(rModel.getBoundingBox().getxAxisLength(), is(3.0));
assertThat(rModel.getBoundingBox().getyAxisLength(), is(4.0));
assertThat(rModel.getxAxisStep(), is(0.5));
assertThat(rModel.getyAxisStep(), is(6.5));
assertThat(rModel.getBoundingBox().getyAxisStart(), is(2.0));
assertThat(rModel.isAlternating(), is(false));
assertThat(rModel.isContinuous(), is(false));
assertThat(rModel.getOrientation(), is(Orientation.VERTICAL));
}
use of org.eclipse.scanning.api.points.models.TwoAxisGridStepModel in project gda-core by openGDA.
the class ScanpathTest method createModelCreatesCorrectModelForRaster.
@Test
public void createModelCreatesCorrectModelForRaster() throws Exception {
pathParams = Arrays.asList(0.5, 6.5);
mutators.put(Mutator.ALTERNATING, new ArrayList<>());
IScanPathModel model = GRID_STEP.createModel(scannables, pathParams, bboxParams, mutators);
assertThat(model, is(instanceOf(TwoAxisGridStepModel.class)));
TwoAxisGridStepModel rModel = (TwoAxisGridStepModel) model;
assertThat(rModel.getScannableNames(), contains("name1", "name2"));
assertThat(rModel.getBoundingBox().getxAxisStart(), is(1.0));
assertThat(rModel.getBoundingBox().getyAxisStart(), is(2.0));
assertThat(rModel.getBoundingBox().getxAxisLength(), is(3.0));
assertThat(rModel.getBoundingBox().getyAxisLength(), is(4.0));
assertThat(rModel.getxAxisStep(), is(0.5));
assertThat(rModel.getyAxisStep(), is(6.5));
assertThat(rModel.getBoundingBox().getyAxisStart(), is(2.0));
assertThat(rModel.isAlternating(), is(true));
assertThat(rModel.isContinuous(), is(false));
assertThat(rModel.getOrientation(), is(Orientation.HORIZONTAL));
}
use of org.eclipse.scanning.api.points.models.TwoAxisGridStepModel in project gda-core by openGDA.
the class PtychographySubmitScanSection method onShow.
@Override
protected void onShow() {
// Ensure the scan path is set to Raster
final TwoAxisGridStepModel stepModel = getRasterStepModel();
if (stepModel == null) {
logger.error("No Raster scanning model is defined");
return;
}
// Set x & y step size
// Ideally, the corresponding controls should be made read-only, but there is currently no way to do this.
stepModel.setxAxisStep(xStepSize);
stepModel.setyAxisStep(yStepSize);
// Select XRF/Imaging detector: deselect other detectors
// Ideally, all other detectors should be hidden, but there is currently no way to do this.
getMappingBean().getDetectorParameters().stream().forEach(d -> d.setIncludeInScan(d.getName().equals(detectorName)));
// Redraw mapping section
getMappingView().updateControls();
// Set initial resolution
if (defaultToHighResolution) {
lowResButton.setSelection(false);
highResButton.setSelection(true);
} else {
lowResButton.setSelection(true);
highResButton.setSelection(false);
}
}
use of org.eclipse.scanning.api.points.models.TwoAxisGridStepModel in project gda-core by openGDA.
the class PtychographySubmitScanSection method getRasterStepModel.
/**
* Get the {@link TwoAxisGridStepModel} that is configured for this client (for raster scanning).
* <p>
* This may already be set in the mapping bean: if not, we need to obtain it from the controller and redraw the GUI
* accordingly.
*
* @return the model, or {@code null} in the (unlikely) event that none is configured in the client.
*/
private TwoAxisGridStepModel getRasterStepModel() {
final IScanPointGeneratorModel scanPath = getMappingBean().getScanDefinition().getMappingScanRegion().getScanPath();
if (scanPath instanceof TwoAxisPtychographyModel) {
return (TwoAxisGridStepModel) scanPath;
}
final RegionAndPathController controller = getService(RegionAndPathController.class);
final TwoAxisGridStepModel model = (TwoAxisGridStepModel) controller.getScanPathListAndLinkPath().stream().filter(TwoAxisGridStepModel.class::isInstance).findFirst().orElse(null);
if (model != null) {
controller.changePath(model);
}
return model;
}
Aggregations