blob: b6b4bc67f19fb0924ee55a581b6a12e9ca0b0f67 [file] [log] [blame]
/*******************************************************************************
* 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,
* Regent L'Archeveque,
* Sebastien Gemme - initial API and implementation
*
* SPDX-License-Identifier: EPL-1.0
*
*******************************************************************************/
package org.eclipse.apogy.common.topology.ui.composites;
import org.eclipse.apogy.common.math.ApogyCommonMathFacade;
import org.eclipse.apogy.common.math.Tuple3d;
import org.eclipse.apogy.common.topology.PositionNode;
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 EditPositionNodePositionComposite extends Composite {
private PositionNode positionNode;
private Text xValueText = null;
private Text yValueText = null;
private Text zValueText = null;
public EditPositionNodePositionComposite(Composite parent, int style) {
super(parent, style);
}
public EditPositionNodePositionComposite(Composite parent, int style, PositionNode positionNode) {
super(parent, style);
this.positionNode = positionNode;
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(positionNode.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(positionNode.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(positionNode.getPosition().getZ()));
this.setSize(new Point(300, 200));
}
public Tuple3d getNewValues() {
Tuple3d tuple = ApogyCommonMathFacade.INSTANCE.createTuple3d(this.positionNode.getPosition().asTuple3d());
try {
double x = Double.parseDouble(this.xValueText.getText());
double y = Double.parseDouble(this.yValueText.getText());
double z = Double.parseDouble(this.zValueText.getText());
tuple = ApogyCommonMathFacade.INSTANCE.createTuple3d(x, y, z);
} catch (Exception e) {
}
return tuple;
}
}