blob: 2eb3cf41b608047d457be104ea861131a0ae4595 [file] [log] [blame]
package org.eclipse.apogy.addons.sensors.pose.ui.composites;
/*******************************************************************************
* Copyright (c) 2018 Agence spatiale canadienne / Canadian Space Agency
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Pierre Allard - initial API and implementation
* Regent L'Archeveque
*
* SPDX-License-Identifier: EPL-1.0
*******************************************************************************/
import org.eclipse.apogy.addons.sensors.pose.PositionSensor;
import org.eclipse.apogy.common.geometry.data3d.ApogyCommonGeometryData3DFacade;
import org.eclipse.apogy.common.geometry.data3d.CartesianPositionCoordinates;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
public class EditPositionComposite extends Composite {
private PositionSensor positionSensor;
private Text xValueText = null;
private Text yValueText = null;
private Text zValueText = null;
public EditPositionComposite(Composite parent, int style) {
super(parent, style);
}
public EditPositionComposite(Composite parent, int style, PositionSensor positionSensor) {
super(parent, style);
this.positionSensor = positionSensor;
GridLayout gridLayout = new GridLayout();
gridLayout.numColumns = 2;
this.setLayout(gridLayout);
Label xLabel = new Label(this, SWT.NONE);
xLabel.setText("X:");
GridData gridDataX = new GridData();
gridDataX.widthHint = 100;
gridDataX.horizontalAlignment = org.eclipse.swt.layout.GridData.FILL;
this.xValueText = new Text(this, SWT.BORDER);
this.xValueText.setLayoutData(gridDataX);
this.xValueText.setText(Double.toString(positionSensor.getPosition().getX()));
Label yLabel = new Label(this, SWT.NONE);
yLabel.setText("Y:");
GridData gridDataY = new GridData();
gridDataY.widthHint = 100;
gridDataY.horizontalAlignment = org.eclipse.swt.layout.GridData.FILL;
this.yValueText = new Text(this, SWT.BORDER);
this.yValueText.setLayoutData(gridDataY);
this.yValueText.setText(Double.toString(positionSensor.getPosition().getY()));
Label zLabel = new Label(this, SWT.NONE);
zLabel.setText("Z:");
GridData gridDataZ = new GridData();
gridDataZ.widthHint = 100;
gridDataZ.horizontalAlignment = org.eclipse.swt.layout.GridData.FILL;
this.zValueText = new Text(this, SWT.BORDER);
this.zValueText.setLayoutData(gridDataZ);
this.zValueText.setText(Double.toString(positionSensor.getPosition().getZ()));
this.setSize(new Point(300, 200));
}
public CartesianPositionCoordinates getNewValues() {
CartesianPositionCoordinates position = ApogyCommonGeometryData3DFacade.INSTANCE
.createCartesianPositionCoordinates(this.positionSensor.getPositionCoordinates());
try {
double x = Double.parseDouble(this.xValueText.getText());
double y = Double.parseDouble(this.yValueText.getText());
double z = Double.parseDouble(this.zValueText.getText());
position = ApogyCommonGeometryData3DFacade.INSTANCE.createCartesianPositionCoordinates(x, y, z);
} catch (Exception e) {
}
return position;
}
}