From: Marko Luukkainen Date: Thu, 15 Oct 2020 09:33:10 +0000 (+0300) Subject: Improve cameraAndSelectorAction api X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=588f20ae6b9f08b615f32d27fed7ee28e14c2b4c;p=simantics%2F3d.git Improve cameraAndSelectorAction api Added get/set position/focus methods. Renamed focus method as setFocus. gitlab #141 Change-Id: I854da4a344d9bfacba097982217848570d702978 --- diff --git a/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/awt/vtkCameraAndSelectorAction.java b/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/awt/vtkCameraAndSelectorAction.java index d1d4ac0c..26d6843b 100644 --- a/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/awt/vtkCameraAndSelectorAction.java +++ b/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/awt/vtkCameraAndSelectorAction.java @@ -17,6 +17,8 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; +import javax.vecmath.Point3d; + import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.ISelectionProvider; @@ -380,16 +382,51 @@ public class vtkCameraAndSelectorAction extends vtkAwtAction implements ISelecti }); } - public void focus(double x, double y, double z) { + public vtkCamera getCamera() { + return cam; + } + + public Point3d getPosition() { + double pos[] = cam.GetPosition(); + return new Point3d(pos); + } + + public Point3d getFocus() { + double pos[] = cam.GetFocalPoint(); + return new Point3d(pos); + } + + public void setFocus(Point3d focus) { + setFocus(focus.x,focus.y,focus.z); + } + + public void setFocus(double x, double y, double z) { Lock(); cam.SetFocalPoint(x, y, z); if (doNotRotate) cam.SetRoll(0); cam.OrthogonalizeViewUp(); - resetCameraClippingRange(); + ren.ResetCameraClippingRange(); + panel.UpdateLight(); + UnLock(); + } + + public void setPosition(Point3d position) { + setPosition(position.x,position.y,position.z); + } + + public void setPosition(double x, double y, double z) { + Lock(); + cam.SetPosition(x, y, z); + if (doNotRotate) + cam.SetRoll(0); + cam.OrthogonalizeViewUp(); + ren.ResetCameraClippingRange(); panel.UpdateLight(); UnLock(); } + + }