Search in sources :

Example 1 with BoundingBox

use of org.eclipse.scanning.api.points.models.BoundingBox in project gda-core by openGDA.

the class MScanSubmitterTest method getBoundedCompoundModel.

private CompoundModel getBoundedCompoundModel(AbstractBoundingBoxModel model, IROI roi) {
    IRectangularROI boundingRoi = roi.getBounds();
    model.setBoundingBox(new BoundingBox(boundingRoi.getPointX(), boundingRoi.getPointY(), boundingRoi.getLength(X), boundingRoi.getLength(Y)));
    return getCompoundModel(model, roi);
}
Also used : IRectangularROI(org.eclipse.dawnsci.analysis.api.roi.IRectangularROI) BoundingBox(org.eclipse.scanning.api.points.models.BoundingBox)

Example 2 with BoundingBox

use of org.eclipse.scanning.api.points.models.BoundingBox in project gda-core by openGDA.

the class TwoAxisGridPointsModelDocument method getBoundingBox.

private BoundingBox getBoundingBox() {
    ScannableTrackDocument scannableOne = getScanpathDocument().getScannableTrackDocuments().get(0);
    ScannableTrackDocument scannableTwo = getScanpathDocument().getScannableTrackDocuments().get(1);
    return new BoundingBox(scannableOne.getStart(), scannableTwo.getStart(), scannableOne.length(), scannableTwo.length());
}
Also used : ScannableTrackDocument(uk.ac.diamond.daq.mapping.api.document.scanpath.ScannableTrackDocument) BoundingBox(org.eclipse.scanning.api.points.models.BoundingBox)

Example 3 with BoundingBox

use of org.eclipse.scanning.api.points.models.BoundingBox in project gda-core by openGDA.

the class MappingUISerializationTest method createScanRegion.

private IMappingScanRegion createScanRegion() {
    IMappingScanRegion scanRegion = new MappingScanRegion();
    TwoAxisGridPointsModel gmodel = new TwoAxisGridPointsModel();
    gmodel.setxAxisName("xNex");
    gmodel.setxAxisPoints(50);
    gmodel.setyAxisName("yNex");
    gmodel.setyAxisPoints(20);
    gmodel.setBoundingBox(new BoundingBox(0, 0, 3, 3));
    RectangularMappingRegion region = new RectangularMappingRegion();
    region.setxStart(10.0);
    region.setxStop(20.0);
    region.setyStart(5.5);
    region.setyStop(13.2);
    scanRegion.setScanPath(gmodel);
    scanRegion.setRegion(region);
    return scanRegion;
}
Also used : IMappingScanRegion(uk.ac.diamond.daq.mapping.api.IMappingScanRegion) TwoAxisGridPointsModel(org.eclipse.scanning.api.points.models.TwoAxisGridPointsModel) IMappingScanRegion(uk.ac.diamond.daq.mapping.api.IMappingScanRegion) MappingScanRegion(uk.ac.diamond.daq.mapping.impl.MappingScanRegion) BoundingBox(org.eclipse.scanning.api.points.models.BoundingBox) RectangularMappingRegion(uk.ac.diamond.daq.mapping.region.RectangularMappingRegion)

Example 4 with BoundingBox

use of org.eclipse.scanning.api.points.models.BoundingBox in project gda-core by openGDA.

the class ScannableNexusWrapperScanTest method createGridScan.

private IRunnableDevice<ScanModel> createGridScan(final IRunnableDevice<? extends IDetectorModel> detector, String outerScannableName, int... size) throws Exception {
    // Create scan points for a grid and make a generator
    final TwoAxisGridPointsModel gridModel = new TwoAxisGridPointsModel();
    gridModel.setxAxisName("salong");
    gridModel.setxAxisPoints(size[size.length - 1]);
    gridModel.setyAxisName("saperp");
    gridModel.setyAxisPoints(size[size.length - 2]);
    gridModel.setBoundingBox(new BoundingBox(0, 0, 3, 3));
    final CompoundModel compoundModel = new CompoundModel();
    // We add the outer scans, if any
    if (outerScannableName != null) {
        for (int dim = 0; dim < size.length - 2; dim++) {
            if (size[dim] > 1) {
                // TODO outer scannable name(s)? could use cryostat temperature as an outer scan
                compoundModel.addModel(new AxialStepModel(outerScannableName, 10000, 20000, 9999.99d / (size[dim] - 1)));
            } else {
                // Will generate one value at 10
                compoundModel.addModel(new AxialStepModel(outerScannableName + (dim + 1), 10, 20, 30));
            }
        }
    }
    compoundModel.addModel(gridModel);
    final IPointGenerator<CompoundModel> pointGen = pointGenService.createCompoundGenerator(compoundModel);
    // Create the model for a scan
    final ScanModel scanModel = new ScanModel();
    scanModel.setPointGenerator(pointGen);
    scanModel.setScanPathModel(compoundModel);
    scanModel.setDetector(detector);
    final IScannable<?> attributeScannable = scannableDeviceService.getScannable("attributes");
    final IScannable<?> beamSizeScannable = scannableDeviceService.getScannable("beam");
    scanModel.setMonitorsPerScan(attributeScannable, beamSizeScannable);
    // Create a file to scan into
    final File output = File.createTempFile("test_legacy_nexus", ".nxs");
    output.deleteOnExit();
    scanModel.setFilePath(output.getAbsolutePath());
    System.out.println("File writing to " + scanModel.getFilePath());
    // Create a scan and run it without publishing events
    final IRunnableDevice<ScanModel> scanner = scanService.createScanDevice(scanModel);
    final IPointGenerator<?> fgen = pointGen;
    ((IRunnableEventDevice<ScanModel>) scanner).addRunListener(new IRunListener() {

        @Override
        public void runWillPerform(RunEvent evt) throws ScanningException {
            System.out.println("Running acquisition scan of size " + fgen.size());
        }
    });
    return scanner;
}
Also used : ScanModel(org.eclipse.scanning.api.scan.models.ScanModel) IRunListener(org.eclipse.scanning.api.scan.event.IRunListener) TwoAxisGridPointsModel(org.eclipse.scanning.api.points.models.TwoAxisGridPointsModel) IRunnableEventDevice(org.eclipse.scanning.api.device.IRunnableEventDevice) CompoundModel(org.eclipse.scanning.api.points.models.CompoundModel) ScanningException(org.eclipse.scanning.api.scan.ScanningException) BoundingBox(org.eclipse.scanning.api.points.models.BoundingBox) AxialStepModel(org.eclipse.scanning.api.points.models.AxialStepModel) NexusFile(org.eclipse.dawnsci.nexus.NexusFile) File(java.io.File) TreeFile(org.eclipse.dawnsci.analysis.api.tree.TreeFile) RunEvent(org.eclipse.scanning.api.scan.event.RunEvent)

Example 5 with BoundingBox

use of org.eclipse.scanning.api.points.models.BoundingBox in project gda-core by openGDA.

the class RegionAndPathMapper method mapRegionOntoBoundingBoxModel.

/**
 * Updates the {@link BoundingBox} of an {@link IBoundingBoxModel} to conform to
 * a {@link IMappingScanRegionShape}
 * @param scanRegionShape The region to map onto the model
 * @param boxModel The model to update
 */
private static void mapRegionOntoBoundingBoxModel(IMappingScanRegionShape scanRegionShape, IBoundingBoxModel boxModel) {
    IRectangularROI roi = scanRegionShape.toROI().getBounds();
    if (roi != null) {
        BoundingBox box = boxModel.getBoundingBox();
        if (box == null) {
            box = new BoundingBox();
            boxModel.setBoundingBox(box);
        }
        box.setxAxisStart(roi.getPointX());
        box.setyAxisStart(roi.getPointY());
        box.setxAxisLength(roi.getLength(0));
        box.setyAxisLength(roi.getLength(1));
    }
}
Also used : IRectangularROI(org.eclipse.dawnsci.analysis.api.roi.IRectangularROI) BoundingBox(org.eclipse.scanning.api.points.models.BoundingBox)

Aggregations

BoundingBox (org.eclipse.scanning.api.points.models.BoundingBox)5 IRectangularROI (org.eclipse.dawnsci.analysis.api.roi.IRectangularROI)2 TwoAxisGridPointsModel (org.eclipse.scanning.api.points.models.TwoAxisGridPointsModel)2 File (java.io.File)1 TreeFile (org.eclipse.dawnsci.analysis.api.tree.TreeFile)1 NexusFile (org.eclipse.dawnsci.nexus.NexusFile)1 IRunnableEventDevice (org.eclipse.scanning.api.device.IRunnableEventDevice)1 AxialStepModel (org.eclipse.scanning.api.points.models.AxialStepModel)1 CompoundModel (org.eclipse.scanning.api.points.models.CompoundModel)1 ScanningException (org.eclipse.scanning.api.scan.ScanningException)1 IRunListener (org.eclipse.scanning.api.scan.event.IRunListener)1 RunEvent (org.eclipse.scanning.api.scan.event.RunEvent)1 ScanModel (org.eclipse.scanning.api.scan.models.ScanModel)1 IMappingScanRegion (uk.ac.diamond.daq.mapping.api.IMappingScanRegion)1 ScannableTrackDocument (uk.ac.diamond.daq.mapping.api.document.scanpath.ScannableTrackDocument)1 MappingScanRegion (uk.ac.diamond.daq.mapping.impl.MappingScanRegion)1 RectangularMappingRegion (uk.ac.diamond.daq.mapping.region.RectangularMappingRegion)1