]> gerrit.simantics Code Review - simantics/3d.git/commitdiff
Improve cameraAndSelectorAction api 42/4542/1
authorMarko Luukkainen <marko.luukkainen@semantum.fi>
Thu, 15 Oct 2020 09:33:10 +0000 (12:33 +0300)
committerMarko Luukkainen <marko.luukkainen@semantum.fi>
Thu, 15 Oct 2020 09:33:10 +0000 (12:33 +0300)
Added get/set position/focus methods. Renamed focus method as setFocus.

gitlab #141

Change-Id: I854da4a344d9bfacba097982217848570d702978

org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/awt/vtkCameraAndSelectorAction.java

index d1d4ac0c62a69289e6cb45ede3d5a36fabd2df22..26d6843b19ca7725154c25929a139f6ef1159429 100644 (file)
@@ -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();
                }
                
                
+               
+               
 }