blob: f335f03eb9bb3053eba2e6a05d8f876f513c7a9f [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 - initial API and implementation
* Regent L'Archeveque
*
* SPDX-License-Identifier: EPL-1.0
*******************************************************************************/
package org.eclipse.apogy.addons.ui.composites;
import org.eclipse.apogy.addons.GeometryPlacementAtFeatureOfInterestTool;
import org.eclipse.apogy.common.math.Matrix3x3;
import org.eclipse.apogy.common.math.ui.composites.RotationMatrixComposite;
import org.eclipse.apogy.common.math.ui.composites.Tuple3dComposite;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
public class GeometryPlacementAtFeatureOfInterestToolPoseComposite extends Composite {
private final EditingDomain editingDomain;
private GeometryPlacementAtFeatureOfInterestTool geometryPlacementAtFeatureOfInterestTool;
private final RotationMatrixComposite rotationMatrixComposite;
private final Tuple3dComposite translationComposite;
public GeometryPlacementAtFeatureOfInterestToolPoseComposite(Composite parent, int style) {
this(parent, style, null);
}
public GeometryPlacementAtFeatureOfInterestToolPoseComposite(Composite parent, int style,
EditingDomain editingDomain) {
super(parent, style);
this.editingDomain = editingDomain;
setLayout(new GridLayout(1, true));
Group grpTranslation = new Group(this, SWT.NONE);
grpTranslation.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
grpTranslation.setLayout(new FillLayout(SWT.HORIZONTAL));
grpTranslation.setText("Translation (x,y,z)");
this.translationComposite = new Tuple3dComposite(grpTranslation, SWT.NONE, this.editingDomain, "0.000");
Group grpRotation = new Group(this, SWT.NONE);
grpRotation.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
grpRotation.setLayout(new FillLayout(SWT.HORIZONTAL));
grpRotation.setText("Rotation");
this.rotationMatrixComposite = new RotationMatrixComposite(this, style, this.editingDomain);
this.rotationMatrixComposite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
}
public GeometryPlacementAtFeatureOfInterestTool getGeometryPlacementAtFeatureOfInterestTool() {
return this.geometryPlacementAtFeatureOfInterestTool;
}
public void setGeometryPlacementAtFeatureOfInterestTool(
GeometryPlacementAtFeatureOfInterestTool newGeometryPlacementAtFeatureOfInterestTool) {
setGeometryPlacementAtFeatureOfInterestTool(newGeometryPlacementAtFeatureOfInterestTool, true);
}
public void setGeometryPlacementAtFeatureOfInterestTool(
GeometryPlacementAtFeatureOfInterestTool newGeometryPlacementAtFeatureOfInterestTool, boolean update) {
if (update) {
this.geometryPlacementAtFeatureOfInterestTool = newGeometryPlacementAtFeatureOfInterestTool;
if (this.translationComposite != null && !this.translationComposite.isDisposed()
&& this.rotationMatrixComposite != null && !this.rotationMatrixComposite.isDisposed()) {
if (newGeometryPlacementAtFeatureOfInterestTool != null
&& newGeometryPlacementAtFeatureOfInterestTool.getTransformNode() != null) {
Matrix3x3 rotation = newGeometryPlacementAtFeatureOfInterestTool.getTransformNode()
.getRotationMatrix();
this.translationComposite
.setTuple3d(newGeometryPlacementAtFeatureOfInterestTool.getTransformNode().getPosition());
this.rotationMatrixComposite.setMatrix3x3(rotation);
} else {
this.translationComposite.setTuple3d(null);
this.rotationMatrixComposite.setMatrix3x3(null);
}
}
}
}
}