title: vtkWidget position on multiple renderers
body: <p>I am running into a relative simple problem for days, and I didn't find any solving: I have a vtkRenderWindow where I spread up 4 renderers, but on runtime I hide 3 of them, so I could have 1 or 4 renderers at the time ...</p>
  
  <p>On renderer 1 I intend to put a vtkSliderWidget ... to achieve that, I wrote:</p>
  
  <pre><code>        vtkSliderRepresentation2D* pSliderRep = vtkSliderRepresentation2D::New();
  ......
  ......
          pSliderRep-&gt;GetPoint1Coordinate()-&gt;SetCoordinateSystemToNormalizedViewport();
          pSliderRep-&gt;GetPoint1Coordinate()-&gt;SetValue(0.1, 0.1);
          pSliderRep-&gt;GetPoint2Coordinate()-&gt;SetCoordinateSystemToNormalizedViewport();
          pSliderRep-&gt;GetPoint2Coordinate()-&gt;SetValue(0.9, 0.1);
          m_pSlider-&gt;SetInteractor(m_pInteractor);
          m_pSlider-&gt;SetRepresentation(pSliderRep);
  </code></pre>
  
  <p>where <strong>m_pSlider</strong> is a <strong>vtkSliderWidget</strong> object ...</p>
  
  <p>the problem become where I have 4 renderers:</p>
  
  <pre><code>Renderer 1    Renderer 2
  Renderer 3    Renderer 4
  </code></pre>
  
  <p>in this stage, the widget I found over renderer 3, not over renderer 1 where is belong ... why ?</p>
  
  <p>Is there something that I am doing wrong ? I dig in for this issue for days !! Can you help me ?</p>
  
  <p>Later edit:</p>
  
  <p>I made a simple test using <a href="http://www.vtk.org/Wiki/VTK/Examples/Cxx/Visualization/MultipleViewports" rel="nofollow">this test project</a>: </p>
  
  <pre><code>int main(int, char *[])
  {
  vtkSmartPointer&lt;vtkRenderWindow&gt; renderWindow = 
      vtkSmartPointer&lt;vtkRenderWindow&gt;::New();
  
  vtkSmartPointer&lt;vtkRenderWindowInteractor&gt; renderWindowInteractor = 
      vtkSmartPointer&lt;vtkRenderWindowInteractor&gt;::New();
  
  renderWindowInteractor-&gt;SetRenderWindow(renderWindow);
  
  vtkRenderer* renderer[4];
  
  // Define viewport ranges
  double xmins[4] = {0, .5, 0, .5};
  double xmaxs[4] = {0.5, 1, 0.5, 1};
  double ymins[4] = {0, 0, .5, .5};
  double ymaxs[4] = {0.5, 0.5, 1, 1};
  for(unsigned i = 0; i &lt; 4; i++)
  {
      renderer[i] = vtkRenderer::New();
      renderWindow-&gt;AddRenderer(renderer[i]);
      CString sTemp;
      sTemp.Format("%.1f, %.1f, %.1f, %.1f\n", xmins[i], ymins[i], xmaxs[i], ymaxs[i]);
      renderer[i]-&gt;SetViewport(xmins[i], ymins[i], xmaxs[i], ymaxs[i]);
      // Create a sphere
      vtkSmartPointer&lt;vtkSphereSource&gt; sphereSource = 
          vtkSmartPointer&lt;vtkSphereSource&gt;::New();
      sphereSource-&gt;SetCenter(0.0, 0.0, 0.0);
      sphereSource-&gt;SetRadius(5);
      sphereSource-&gt;Update();
      // Create a mapper and actor
      vtkSmartPointer&lt;vtkPolyDataMapper&gt; mapper = 
          vtkSmartPointer&lt;vtkPolyDataMapper&gt;::New();
      mapper-&gt;SetInputConnection(sphereSource-&gt;GetOutputPort());
      vtkSmartPointer&lt;vtkActor&gt; actor = vtkSmartPointer&lt;vtkActor&gt;::New();
      actor-&gt;SetMapper(mapper);
      renderer[i]-&gt;AddActor(actor);
      renderer[i]-&gt;ResetCamera();
      renderWindow-&gt;Render();
      renderWindow-&gt;SetWindowName(_T("Multiple ViewPorts"));
  }
  
  vtkSliderRepresentation2D* pSliderRep = vtkSliderRepresentation2D::New();
  pSliderRep-&gt;SetMinimumValue(3.0);
  pSliderRep-&gt;SetMaximumValue(20.0);
  pSliderRep-&gt;SetPlaceFactor(1);
  pSliderRep-&gt;GetSliderProperty()-&gt;SetColor(0.65, 0.75, 0.90);
  pSliderRep-&gt;GetTitleProperty()-&gt;SetColor(1, 0, 0);
  pSliderRep-&gt;SetLabelFormat(_T("%.2g"));
  pSliderRep-&gt;GetLabelProperty()-&gt;SetColor(1, 0, 0);
  pSliderRep-&gt;GetSelectedProperty()-&gt;SetColor(0, 1, 0);
  pSliderRep-&gt;GetTubeProperty()-&gt;SetColor(0.36, 0.5, 0.66);
  pSliderRep-&gt;GetTubeProperty()-&gt;SetDisplayLocationToForeground();
  pSliderRep-&gt;GetCapProperty()-&gt;SetColor(0.36, 0.5, 0.66);
  pSliderRep-&gt;SetEndCapLength(0);
  pSliderRep-&gt;SetEndCapWidth(0.025);
  pSliderRep-&gt;SetSliderWidth(0.025);
  pSliderRep-&gt;SetSliderLength(0.045);
  pSliderRep-&gt;SetHandleSize(6);
  pSliderRep-&gt;SetTubeWidth(0.032);
  
  pSliderRep-&gt;GetPoint1Coordinate()-&gt;SetCoordinateSystemToNormalizedDisplay();
  pSliderRep-&gt;GetPoint1Coordinate()-&gt;SetValue(0.01, 0.99);
  pSliderRep-&gt;GetPoint2Coordinate()-&gt;SetCoordinateSystemToNormalizedDisplay();
  pSliderRep-&gt;GetPoint2Coordinate()-&gt;SetValue(0.99, 0.99);
  
  vtkSliderWidget* pSlider = vtkSliderWidget::New();
  pSlider-&gt;SetInteractor(renderWindowInteractor);
  pSlider-&gt;SetCurrentRenderer(renderer[0]);
  pSlider-&gt;SetRepresentation(pSliderRep);
  pSlider-&gt;EnabledOn();
  pSlider-&gt;SetDefaultRenderer(renderer[0]);
  pSlider-&gt;SetAnimationModeToAnimate();
  
  renderWindowInteractor-&gt;Start();
  
  pSliderRep-&gt;Delete();
  pSlider-&gt;Delete();
  
  for(unsigned i = 0; i &lt; 4; i++)
      renderer[i]-&gt;Delete();
  
  return EXIT_SUCCESS;
  }
  </code></pre>
  
  <p>But I see no slider ... what I have done wrong ?</p>
  
  <p>[New data] In fact, the problem is reduced on setting up the slider on other renderer than renderer 0:</p>
  
  <pre><code>int main(int, char *[])
  {
  vtkSmartPointer&lt;vtkRenderWindow&gt; renderWindow = 
      vtkSmartPointer&lt;vtkRenderWindow&gt;::New();
  
  vtkSmartPointer&lt;vtkRenderWindowInteractor&gt; renderWindowInteractor = 
      vtkSmartPointer&lt;vtkRenderWindowInteractor&gt;::New();
  
  renderWindowInteractor-&gt;SetRenderWindow(renderWindow);
  
  vtkRenderer* renderer[4];
  
  // Define viewport ranges
  double xmins[4] = {0, .5, 0, .5};
  double xmaxs[4] = {0.5, 1, 0.5, 1};
  double ymins[4] = {0, 0, .5, .5};
  double ymaxs[4] = {0.5, 0.5, 1, 1};
  for(unsigned i = 0; i &lt; 4; i++)
  {
      renderer[i] = vtkRenderer::New();
      renderWindow-&gt;AddRenderer(renderer[i]);
      CString sTemp;
      sTemp.Format("%.1f, %.1f, %.1f, %.1f\n", xmins[i], ymins[i], xmaxs[i], ymaxs[i]);
      renderer[i]-&gt;SetViewport(xmins[i], ymins[i], xmaxs[i], ymaxs[i]);
      // Create a sphere
      vtkSmartPointer&lt;vtkSphereSource&gt; sphereSource = 
          vtkSmartPointer&lt;vtkSphereSource&gt;::New();
      sphereSource-&gt;SetCenter(0.0, 0.0, 0.0);
      sphereSource-&gt;SetRadius(5);
      sphereSource-&gt;Update();
      // Create a mapper and actor
      vtkSmartPointer&lt;vtkPolyDataMapper&gt; mapper = 
          vtkSmartPointer&lt;vtkPolyDataMapper&gt;::New();
      mapper-&gt;SetInputConnection(sphereSource-&gt;GetOutputPort());
      vtkSmartPointer&lt;vtkActor&gt; actor = vtkSmartPointer&lt;vtkActor&gt;::New();
      actor-&gt;SetMapper(mapper);
      renderer[i]-&gt;AddActor(actor);
      renderer[i]-&gt;ResetCamera();
      renderWindow-&gt;Render();
      renderWindow-&gt;SetWindowName(_T("Multiple ViewPorts"));
  }
  
  vtkSliderRepresentation2D* pSliderRep = vtkSliderRepresentation2D::New();
  pSliderRep-&gt;SetMinimumValue(3.0);
  pSliderRep-&gt;SetMaximumValue(20.0);
  
  pSliderRep-&gt;GetPoint1Coordinate()-&gt;SetCoordinateSystemToNormalizedViewport();
  pSliderRep-&gt;GetPoint1Coordinate()-&gt;SetValue(0.1, 0.9);
  pSliderRep-&gt;GetPoint2Coordinate()-&gt;SetCoordinateSystemToNormalizedViewport();
  pSliderRep-&gt;GetPoint2Coordinate()-&gt;SetValue(0.9, 0.9);
  
  vtkSliderWidget* pSlider = vtkSliderWidget::New();
  pSlider-&gt;SetInteractor(renderWindowInteractor);
  pSlider-&gt;SetCurrentRenderer(renderer[1]);    // &lt;-- not working !!!
  pSlider-&gt;SetDefaultRenderer(renderer[1]);    // &lt;-- not working !!!
  pSlider-&gt;SetAnimationModeToAnimate();
  
  pSlider-&gt;SetRepresentation(pSliderRep);
  pSlider-&gt;EnabledOn();
  
  pSliderRep-&gt;Modified();
  
  renderWindowInteractor-&gt;Start();
  
  pSliderRep-&gt;Delete();
  pSlider-&gt;Delete();
  
  for(int i = 0; i &lt; 4; i++)
      renderer[i]-&gt;Delete();
  
  return EXIT_SUCCESS;
  }
  </code></pre>
  
  <p>the question is, how can I show the slider on renderer 1 (or 2, or 3), but on renderer 0 ?</p>
  
  <p>Might be something simple ... </p>