| /******************************************************************************* |
| * 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.fov.ui.impl; |
| |
| import javax.vecmath.Point3d; |
| |
| import org.eclipse.apogy.addons.sensors.fov.ui.Activator; |
| import org.eclipse.apogy.addons.sensors.fov.ui.preferences.MRTFOVPreferencesConstants; |
| import org.eclipse.apogy.addons.sensors.fov.ui.scene_objects.CircularSectorFieldOfViewSceneObject; |
| import org.eclipse.apogy.common.math.ApogyCommonMathFacade; |
| import org.eclipse.apogy.common.math.Tuple3d; |
| import org.eclipse.apogy.common.topology.ui.MeshPresentationMode; |
| import org.eclipse.jface.preference.IPreferenceStore; |
| import org.eclipse.jface.preference.PreferenceConverter; |
| import org.eclipse.swt.graphics.RGB; |
| |
| public class CircularSectorFieldOfViewPresentationCustomImpl extends CircularSectorFieldOfViewPresentationImpl { |
| |
| protected CircularSectorFieldOfViewPresentationCustomImpl() { |
| super(); |
| |
| // Initializes values from preferences |
| applyPreferences(); |
| } |
| |
| @Override |
| public Tuple3d basicGetCentroid() { |
| Point3d point3d = new Point3d(); |
| if (getSceneObject() != null) { |
| point3d = getSceneObject().getCentroid(); |
| } |
| |
| return ApogyCommonMathFacade.INSTANCE.createTuple3d(point3d); |
| } |
| |
| @Override |
| public void setPresentationMode(MeshPresentationMode newPresentationMode) { |
| |
| super.setPresentationMode(newPresentationMode); |
| |
| if (getSceneObject() instanceof CircularSectorFieldOfViewSceneObject) { |
| CircularSectorFieldOfViewSceneObject j3dObject = (CircularSectorFieldOfViewSceneObject) getSceneObject(); |
| j3dObject.setPresentationMode(newPresentationMode); |
| } |
| } |
| |
| @Override |
| protected void initialSceneObject() { |
| super.initialSceneObject(); |
| } |
| |
| @Override |
| public double getZRange() { |
| return 0.0; |
| } |
| |
| @Override |
| protected void applyPreferences() { |
| IPreferenceStore store = Activator.getDefault().getPreferenceStore(); |
| |
| // Change visibility. |
| setVisible(store.getBoolean(MRTFOVPreferencesConstants.DEFAULT_CIRCULAR_SECTOR_VISIBILITY_ID)); |
| |
| // Change FOV Visibility |
| setFovVisible(store.getBoolean(MRTFOVPreferencesConstants.DEFAULT_CIRCULAR_SECTOR_FOV_VISIBILITY_ID)); |
| |
| // Change Axis visibility. |
| setAxisVisible(store.getBoolean(MRTFOVPreferencesConstants.DEFAULT_CIRCULAR_SECTOR_FOV_AXIS_VISIBLE_ID)); |
| |
| // Change color. |
| RGB rgb = PreferenceConverter.getColor(store, MRTFOVPreferencesConstants.DEFAULT_CIRCULAR_SECTOR_FOV_COLOR_ID); |
| if (rgb != null) |
| setColor(rgb); |
| |
| // Set Transparency |
| // TODO |
| |
| // Change outline only |
| setShowOutlineOnly( |
| store.getBoolean(MRTFOVPreferencesConstants.DEFAULT_CIRCULAR_SECTOR_FOV_SHOW_OUTLINE_ONLY_ID)); |
| |
| // Change projection |
| setShowProjection(store.getBoolean(MRTFOVPreferencesConstants.DEFAULT_CIRCULAR_SECTOR_FOV_SHOW_PROJECTION_ID)); |
| |
| // Change projection color. |
| RGB projectionColor = PreferenceConverter.getColor(store, |
| MRTFOVPreferencesConstants.DEFAULT_CIRCULAR_SECTOR_FOV_PROJECTION_COLOR_ID); |
| if (projectionColor != null) |
| setProjectionColor(projectionColor); |
| |
| // Change mode. |
| setPresentationMode(MeshPresentationMode |
| .get(store.getInt(MRTFOVPreferencesConstants.DEFAULT_CIRCULAR_SECTOR_FOV_PRESENTATION_MODE_ID))); |
| |
| super.applyPreferences(); |
| } |
| } // CircularSectorFieldOfViewPresentationImpl |