View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0006913VTK(No Category)public2008-04-28 08:002016-08-12 09:54
ReporterJulian Ibarz 
Assigned ToKitware Robot 
PrioritynormalSeveritymajorReproducibilityalways
StatusclosedResolutionmoved 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0006913: 2 Bugs of pursuit of the light in vtkCanvas
DescriptionWhen we create a camera and send it to the renderer the vtkPanel member cam is not refreshed to point to the new active camera, this has to effect that the light does not follow the new camera but the old. To correct this we can change the UpdateLight method :

  public void UpdateLight()
  {
    lgt.SetPosition(cam.GetPosition());
    lgt.SetFocalPoint(cam.GetFocalPoint());
  }

in

    public void UpdateLight()
    {
        cam = GetRenderer().GetActiveCamera();
        
                lgt.SetPosition(cam.GetPosition());
                lgt.SetFocalPoint(cam.GetFocalPoint());
    }


Also vtkCanvas.mouseDragged does not take in case the value of this.LightFollowCamera state :

vtkPanel.mouseDragged version (correct version) :

        if (this.LightFollowCamera == 1)
          {
            lgt.SetPosition(cam.GetPosition());
            lgt.SetFocalPoint(cam.GetFocalPoint());
          }

vtkCanvas.mouseDragged override version :

  public void mouseDragged(MouseEvent e)
  {
    if (ren.VisibleActorCount() == 0) return;
    int x = e.getX();
    int y = e.getY();

    ctrlPressed = (e.getModifiers() & InputEvent.CTRL_MASK) == InputEvent.CTRL_MASK ? 1:0;
    shiftPressed = (e.getModifiers() & InputEvent.SHIFT_MASK) == InputEvent.SHIFT_MASK ? 1:0;

    iren.SetEventInformationFlipY(e.getX(), e.getY(),
                                  ctrlPressed, shiftPressed, '0', 0, "0");

    Lock();
    iren.MouseMoveEvent();
    UnLock();

    UpdateLight();
  }
TagsNo tags attached.
Project
Type
Attached Files

 Relationships

  Notes
(0011564)
Julian Ibarz (reporter)
2008-04-28 08:11

The refresh of the light is made when the mouse is dragged but the camera can be changed by programming and not in mouse so we cant be sure if the position of the camera was changed or not in vtkPanel. The simplier solution is to always refresh the position of the light on vtkPanel.Render :

  
  public synchronized void Render()
  {
    if (!rendering)
      {
        rendering = true;
        if (ren.VisibleActorCount() == 0) {rendering = false; return;}
        if (rw != null)
          {
            if (windowset == 0)
              {
                // set the window id and the active camera
                cam = ren.GetActiveCamera();
                if (lightingset == 0) {
                  ren.AddLight(lgt);
                  lgt.SetPosition(cam.GetPosition());
                  lgt.SetFocalPoint(cam.GetFocalPoint());
                  lightingset = 1;
                }
                RenderCreate(rw);
                Lock();
                rw.SetSize(getWidth(), getHeight());
                UnLock();
                windowset = 1;
                // notify observers that we have a renderwindow created
                windowSetObservable.notifyObservers();
              }
            Lock();
            rw.Render();
            UnLock();
            rendering = false;
          }
      }
  }

Can be changed by :

  
  public synchronized void Render()
  {
    if (!rendering)
      {
        rendering = true;
        if (ren.VisibleActorCount() == 0) {rendering = false; return;}
        if (rw != null)
          {
            if (windowset == 0)
              {
                // set the window id and the active camera
                cam = ren.GetActiveCamera();
                if (lightingset == 0) {
                  ren.AddLight(lgt);
                  lightingset = 1;
                }
                UpdateLight();

                RenderCreate(rw);
                Lock();
                rw.SetSize(getWidth(), getHeight());
                UnLock();
                windowset = 1;
                // notify observers that we have a renderwindow created
                windowSetObservable.notifyObservers();
              }
            Lock();
            rw.Render();
            UnLock();
            rendering = false;
          }
      }
  }
(0011601)
Julian Ibarz (reporter)
2008-04-30 10:29
edited on: 2008-05-10 17:13

The previous version is bugged. That is the utility class i'm use to solve the different problems i have with vtkCanvas (this code should be placed directly in vtkCanvas and vtkPanel) :

/**
 * This class is temporary. It permits to correct bugs on VTK.
 * See :
 * http://www.vtk.org/Bug/view.php?id=6268 [^]
 * http://ij-plugins.svn.sourceforge.net/viewvc/ij-plugins/trunk/VTK-Examples/Wrapping/Java/vtk/util/VtkPanelUtil.java?view=markup [^]
 * @author ibarz
 */
public class Canvas extends vtkCanvas
{
    Object renderingDownMutex = new Object();
    boolean renderingDown = false;
    public Canvas()
    {
                super();
        setMinimumSize(new Dimension(0, 0));
        setPreferredSize(new Dimension(0, 0));
        vtkInteractorStyleTrackballCamera style = new vtkInteractorStyleTrackballCamera();
        style.AutoAdjustCameraClippingRangeOn();
        getIren().SetInteractorStyle(style);
    }
    
    /**
     * Correct a bug : update the reference of camera.
     * If we change the original camera the light does not follow the camera anymore.
     * @see http://www.vtk.org/Bug/view.php?id=6913 [^]
     */
    @Override
    public void UpdateLight()
    {
        if(LightFollowCamera == 0)
            return;
        
        cam = GetRenderer().GetActiveCamera();
        
        super.UpdateLight();
    }
    
    /**
     * Override to correct the bug of the UpdateLight (the light position is not updated
     * if the camera is moved by programming.
     * @see http://www.vtk.org/Bug/view.php?id=6913 [^]
     */
    @Override
    public synchronized void Render()
  {
    if (!rendering)
      {
        rendering = true;
        if (ren.VisibleActorCount() == 0) {rendering = false; return;}
        if (rw != null)
          {
            if (windowset == 0)
              {
                // set the window id and the active camera
                if (lightingset == 0) {
                  ren.AddLight(lgt);
                  lightingset = 1;
                }
                RenderCreate(rw);
                Lock();
                rw.SetSize(getWidth(), getHeight());
                UnLock();
                windowset = 1;
              }
            UpdateLight();
            Lock();
            rw.Render();
            UnLock();
            rendering = false;
          }
      }
  }

         /**
         * Workaround for http://www.vtk.org/Bug/view.php?id=6268 [^]
         * Pass through the case the rendering window is not linked to the canvas
         * because it's created (see vtkPanel constructor).
         *
         * @param width the new width of this component in pixels.
         * @param height the new height of this component in pixels
         */
            @Override
            public void setSize(int x, int y) {
                super.setSize(x, y);
                  Lock();
                  rw.SetSize(x,y);
                  iren.SetSize(x, y);
                  iren.ConfigureEvent();
                  UnLock();
            }
}

(0036971)
Kitware Robot (administrator)
2016-08-12 09:54

Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current VTK Issues page linked in the banner at the top of this page.

 Issue History
Date Modified Username Field Change
2008-04-28 08:00 Julian Ibarz New Issue
2008-04-28 08:11 Julian Ibarz Note Added: 0011564
2008-04-30 10:29 Julian Ibarz Note Added: 0011601
2008-05-10 17:13 Julian Ibarz Note Edited: 0011601
2011-06-16 13:11 Zack Galbreath Category => (No Category)
2016-08-12 09:54 Kitware Robot Note Added: 0036971
2016-08-12 09:54 Kitware Robot Status expired => closed
2016-08-12 09:54 Kitware Robot Resolution open => moved
2016-08-12 09:54 Kitware Robot Assigned To => Kitware Robot


Copyright © 2000 - 2018 MantisBT Team