/** * Update axis display depending the current scene camera view.<br> * You should call it after having modified camera settings. */ public void updateAxisView() { if (!isWindowSet()) return; lock(); try { double pos[] = cam.GetPosition(); double fp[] = cam.GetFocalPoint(); double viewup[] = cam.GetViewUp(); // mimic axis camera position to scene camera position axisCam.SetPosition(pos); axisCam.SetFocalPoint(fp); axisCam.SetViewUp(viewup); axisRenderer.ResetCamera(); final int[] size = rw.GetSize(); // adjust scale final double scale = size[1] / 512d; // adjust offset final int w = (int) (size[0] - (axisOffset[0] * scale)); final int h = (int) (size[1] - (axisOffset[1] * scale)); // zoom and translate zoomView(axisCam, axisRenderer, axisScale * (axisCam.GetDistance() / 17d)); translateView(axisCam, axisRenderer, -w, -h); } finally { unlock(); } }
public IcyVtkPanel() { super(); // picker // picker = new vtkPropPicker(); // picker.PickFromListOff(); picker = new vtkCellPicker(); picker.PickFromListOff(); // set ambient color to white lgt.SetAmbientColor(1d, 1d, 1d); lightFollowCamera = true; // assign default renderer to layer 0 (should be the case by default) ren.SetLayer(0); // initialize axis axisRenderer = new vtkRenderer(); // BUG: with OpenGL window the global render window viewport is limited to the last layer // viewport dimension // axisRenderer.SetViewport(0.0, 0.0, 0.2, 0.2); axisRenderer.SetLayer(1); axisRenderer.InteractiveOff(); rw.AddRenderer(axisRenderer); rw.SetNumberOfLayers(2); axisCam = axisRenderer.GetActiveCamera(); axis = new vtkAxesActor(); axisRenderer.AddActor(axis); // default axis offset and scale axisOffset = new int[] {124, 124}; axisScale = 1; // reset camera axisCam.SetViewUp(0, -1, 0); axisCam.Elevation(210); axisCam.SetParallelProjection(1); axisRenderer.ResetCamera(); axisRenderer.ResetCameraClippingRange(); // used for restore quality rendering after a given amount of time fineRenderingTime = 0; renderingMonitor = new Thread(this, "VTK panel rendering monitor"); renderingMonitor.start(); addMouseListener(this); addMouseMotionListener(this); addMouseWheelListener(this); addKeyListener(this); }