blob: 671757ed48aceb5413eba04c982363f777e63b4c [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.addons.sensors.imaging.camera.impl;
import org.eclipse.apogy.addons.sensors.fov.RectangularFrustrumFieldOfView;
import org.eclipse.apogy.addons.sensors.imaging.AbstractCamera;
import org.eclipse.apogy.addons.sensors.imaging.AzimuthDirection;
import org.eclipse.apogy.addons.sensors.imaging.ElevationDirection;
import org.eclipse.apogy.addons.sensors.imaging.ImageSnapshot;
import org.eclipse.apogy.addons.sensors.imaging.ImagingUtilities;
import org.eclipse.apogy.addons.sensors.imaging.camera.OverlayAlignment;
import org.eclipse.apogy.common.images.AbstractEImage;
import org.eclipse.apogy.common.images.EImagesUtilities;
public class AzimuthElevationFOVOverlayCustomImpl extends AzimuthElevationFOVOverlayImpl {
protected double azimuth = 0;
protected double elevation = 0;
@Override
public void changeAzimuth(double azimuth) {
this.azimuth = azimuth;
}
@Override
public void changeElevation(double elevation) {
this.elevation = elevation;
}
@Override
public AbstractEImage applyOverlay(AbstractCamera camera, AbstractEImage cameraImage,
OverlayAlignment overlayAlignment, int overlayWidth, int overlayHeight) {
RectangularFrustrumFieldOfView fov = camera.getFieldOfView();
double horizontalFOVAngle = Math.toDegrees(fov.getHorizontalFieldOfViewAngle());
double verticalFOVAngle = Math.toDegrees(fov.getVerticalFieldOfViewAngle());
AbstractEImage overlayImage = ImagingUtilities.INSTANCE.getAzimuthElevationOverlay(overlayWidth, overlayHeight,
this.azimuth, this.elevation, horizontalFOVAngle, verticalFOVAngle, getAzimuthDirection(),
getElevationDirection(), getAngleInterval(), getFontName(), getFontSize(), getColorOfPositive(),
getColorOfNegative(), getLineWidth());
AbstractEImage result = EImagesUtilities.INSTANCE.applyOverlay(cameraImage, overlayImage, false);
return result;
}
@Override
public String getToolTipText(AbstractCamera camera, ImageSnapshot imageSnapshot, int mouseButton, int x, int y) {
String text = null;
if (imageSnapshot != null) {
double hDelta = Math.toDegrees(imageSnapshot.convertToHorizontalAngle(x));
double vDelta = Math.toDegrees(imageSnapshot.convertToVerticalAngle(y));
double hAngle = 0;
double vAngle = 0;
if (getAzimuthDirection() == AzimuthDirection.POSITIVE_TOWARD_RIGHT) {
hAngle = this.azimuth - hDelta;
} else {
hAngle = this.azimuth + hDelta;
}
if (getElevationDirection() == ElevationDirection.POSITIVE_DOWN) {
vAngle = this.elevation - vDelta;
} else {
vAngle = this.elevation + vDelta;
}
text = this.angleFormat.format(hAngle) + "°, " + this.angleFormat.format(vAngle) + "°";
}
return text;
}
} // AzimuthElevationFOVOverlayImpl