blob: 60d92e0b26047408e505d8a012bb8eb38ed5f158 [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 - initial API and implementation
*
* SPDX-License-Identifier: EPL-1.0
*******************************************************************************/
package org.eclipse.apogy.core.ui.composites;
import org.eclipse.apogy.core.ApogySystemApiAdapter;
import org.eclipse.apogy.core.invocator.VariableFeatureReference;
import org.eclipse.apogy.core.invocator.VariablesList;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
public class ApogySystemPoseComparativeComposite extends Composite {
private final ApogySystemPoseComposite variable1ApogySystemPoseComposite;
private final ApogySystemPoseComposite variable2ApogySystemPoseComposite;
private final DeltaPoseComposite deltaPoseComposite;
public ApogySystemPoseComparativeComposite(Composite parent, int style) {
this(parent, style, null, null, null, 0, 0);
}
public ApogySystemPoseComparativeComposite(Composite parent, int style, VariablesList variablesList,
VariableFeatureReference variable1FeatureReference, VariableFeatureReference variable2FeatureReference,
double trip1Distance, double trip2Distance) {
super(parent, style);
setLayout(new GridLayout(1, false));
Group grpVariable1 = new Group(this, SWT.BORDER);
grpVariable1.setText("Variable 1");
grpVariable1.setLayout(new GridLayout(1, false));
this.variable1ApogySystemPoseComposite = new ApogySystemPoseComposite(grpVariable1, SWT.NONE, variablesList,
variable1FeatureReference, trip1Distance) {
@Override
protected void updateApogySystemApiAdapter(ApogySystemApiAdapter oldApogySystemApiAdapter,
ApogySystemApiAdapter newApogySystemApiAdapter) {
super.updateApogySystemApiAdapter(oldApogySystemApiAdapter, newApogySystemApiAdapter);
ApogySystemPoseComparativeComposite.this.deltaPoseComposite
.setVariable1ApogySystemApiAdapter(newApogySystemApiAdapter);
}
};
Group grpVariable2 = new Group(this, SWT.BORDER);
grpVariable2.setText("Variable 2");
grpVariable2.setLayout(new GridLayout(1, false));
this.variable2ApogySystemPoseComposite = new ApogySystemPoseComposite(grpVariable2, SWT.NONE, variablesList,
variable2FeatureReference, trip2Distance) {
@Override
protected void updateApogySystemApiAdapter(ApogySystemApiAdapter oldApogySystemApiAdapter,
ApogySystemApiAdapter newApogySystemApiAdapter) {
super.updateApogySystemApiAdapter(oldApogySystemApiAdapter, newApogySystemApiAdapter);
ApogySystemPoseComparativeComposite.this.deltaPoseComposite
.setVariable2ApogySystemApiAdapter(newApogySystemApiAdapter);
}
};
Group grpRelative = new Group(this, SWT.NONE);
grpRelative.setText("Relative Pose");
grpRelative.setLayout(new GridLayout(1, false));
this.deltaPoseComposite = new DeltaPoseComposite(grpRelative, SWT.BORDER);
}
public void setVariableFeatureReference1(VariableFeatureReference newVariableFeatureReference) {
if (this.variable1ApogySystemPoseComposite != null && !this.variable1ApogySystemPoseComposite.isDisposed()) {
this.variable1ApogySystemPoseComposite.setVariableFeatureReference(newVariableFeatureReference);
}
}
public void setVariableFeatureReference2(VariableFeatureReference newVariableFeatureReference) {
if (this.variable2ApogySystemPoseComposite != null && !this.variable2ApogySystemPoseComposite.isDisposed()) {
this.variable2ApogySystemPoseComposite.setVariableFeatureReference(newVariableFeatureReference);
}
}
public void setVariableList(final VariablesList variablesList) {
// Do this on UI Thread.
getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
ApogySystemPoseComparativeComposite.this.variable1ApogySystemPoseComposite
.setVariableList(variablesList);
ApogySystemPoseComparativeComposite.this.variable2ApogySystemPoseComposite
.setVariableList(variablesList);
}
});
}
public double getTripDistance1() {
if (this.variable1ApogySystemPoseComposite != null && !this.variable1ApogySystemPoseComposite.isDisposed()) {
return this.variable1ApogySystemPoseComposite.getTripDistance();
} else {
return 0;
}
}
public void setTripDistance1(double tripDistance) {
if (this.variable1ApogySystemPoseComposite != null && !this.variable1ApogySystemPoseComposite.isDisposed()) {
this.variable1ApogySystemPoseComposite.setTripDistance(tripDistance);
}
}
public double getTripDistance2() {
if (this.variable2ApogySystemPoseComposite != null && !this.variable2ApogySystemPoseComposite.isDisposed()) {
return this.variable2ApogySystemPoseComposite.getTripDistance();
} else {
return 0;
}
}
public void setTripDistance2(double tripDistance) {
if (this.variable2ApogySystemPoseComposite != null && !this.variable2ApogySystemPoseComposite.isDisposed()) {
this.variable2ApogySystemPoseComposite.setTripDistance(tripDistance);
}
}
}