import org.eclipse.core.commands.ExecutionException;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.handlers.HandlerUtil;
+import org.simantics.g3d.vtk.action.vtkAction;
import org.simantics.g3d.vtk.common.VtkView;
+import org.simantics.g3d.vtk.swt.vtkCameraAndSelectorAction;
import org.simantics.utils.threads.ThreadUtils;
public class CameraPositionHandler extends AbstractHandler {
dir.set(direction);
dir.scale(distance);
dir.add(focal);
+
panel.getRenderer().GetActiveCamera().SetPosition(dir.x, dir.y, dir.z);
- if (Math.abs(direction.dot(new Vector3d(0,1,0))) < 0.95)
- panel.getRenderer().GetActiveCamera().SetViewUp(0, 1, 0);
- else
- panel.getRenderer().GetActiveCamera().SetViewUp(1, 0, 0);
-
- panel.getRenderer().ResetCameraClippingRange();
-
+
+ vtkAction action = panel.getDefaultAction();
+ if (action instanceof vtkCameraAndSelectorAction)
+ ((vtkCameraAndSelectorAction)action).focus(focal.x, focal.y, focal.z);
+ else {
+ if (Math.abs(direction.dot(new Vector3d(0,1,0))) < 0.95)
+ panel.getRenderer().GetActiveCamera().SetViewUp(0, 1, 0);
+ else
+ panel.getRenderer().GetActiveCamera().SetViewUp(1, 0, 0);
+
+ panel.getRenderer().ResetCameraClippingRange();
+ }
+
//panel.UpdateLight();
panel.refresh();
}