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;
}
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));
}
Aggregations