Search in sources :

Example 1 with TwoAxisSpiralModel

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

the class SpiralPathEditor method createEditorPart.

@Override
public Composite createEditorPart(Composite parent) {
    final Composite composite = super.createEditorPart(parent);
    final Label scaleLabel = new Label(composite, SWT.NONE);
    scaleLabel.setText("Scale");
    /*
		 * Scale is not backed by an actual scannable, but its value is treated approximately as millimetres, so simulate
		 * this here.
		 */
    final TwoAxisSpiralModel model = (TwoAxisSpiralModel) getModel();
    final Unit<Length> modelUnit = MILLI(METRE);
    final Unit<Length> initialScaleUnit = QuantityFactory.createUnitFromString(model.getInitialScaleUnit());
    @SuppressWarnings({ "rawtypes", "unchecked" }) final NumberAndUnitsComposite<Length> scaleText = new NumberAndUnitsComposite(composite, SWT.NONE, modelUnit, UnitsProvider.getCompatibleUnits(modelUnit), initialScaleUnit);
    grabHorizontalSpace.applyTo(scaleText);
    binder.bind(scaleText, "scale", model, val -> ((double) val == 0.0) ? ValidationStatus.error("Scale cannot be zero!") : ValidationStatus.ok());
    makeCommonOptionsControls(composite);
    final String scaleDescription = "This parameter gives approximately both " + "the distance between arcs and the arclength between consecutive points.";
    scaleLabel.setToolTipText(scaleDescription);
    scaleText.setToolTipText(scaleDescription);
    return composite;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) NumberAndUnitsComposite(uk.ac.gda.client.NumberAndUnitsComposite) Length(javax.measure.quantity.Length) NumberAndUnitsComposite(uk.ac.gda.client.NumberAndUnitsComposite) Label(org.eclipse.swt.widgets.Label) TwoAxisSpiralModel(org.eclipse.scanning.api.points.models.TwoAxisSpiralModel)

Example 2 with TwoAxisSpiralModel

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

the class ScanpathTest method createModelCreatesCorrectModelForSpiral.

@Test
public void createModelCreatesCorrectModelForSpiral() throws Exception {
    pathParams = Arrays.asList(5.0);
    mutators.put(Mutator.CONTINUOUS, Arrays.asList(blankArray));
    IScanPathModel model = SPIRAL.createModel(scannables, pathParams, bboxParams, mutators);
    assertThat(model, is(instanceOf(TwoAxisSpiralModel.class)));
    TwoAxisSpiralModel sModel = (TwoAxisSpiralModel) model;
    assertThat(sModel.getScannableNames(), contains("name1", "name2"));
    assertThat(sModel.getBoundingBox().getxAxisStart(), is(1.0));
    assertThat(sModel.getBoundingBox().getyAxisStart(), is(2.0));
    assertThat(sModel.getBoundingBox().getxAxisLength(), is(3.0));
    assertThat(sModel.getBoundingBox().getyAxisLength(), is(4.0));
    assertThat(sModel.getScale(), is(5.0));
    assertThat(sModel.getBoundingBox().getyAxisStart(), is(2.0));
    assertThat(sModel.isContinuous(), is(true));
}
Also used : TwoAxisSpiralModel(org.eclipse.scanning.api.points.models.TwoAxisSpiralModel) IScanPathModel(org.eclipse.scanning.api.points.models.IScanPathModel) Test(org.junit.Test)

Aggregations

TwoAxisSpiralModel (org.eclipse.scanning.api.points.models.TwoAxisSpiralModel)2 Length (javax.measure.quantity.Length)1 IScanPathModel (org.eclipse.scanning.api.points.models.IScanPathModel)1 Composite (org.eclipse.swt.widgets.Composite)1 Label (org.eclipse.swt.widgets.Label)1 Test (org.junit.Test)1 NumberAndUnitsComposite (uk.ac.gda.client.NumberAndUnitsComposite)1