Quantcast

Adding an ImageSlice to one renderer causes the image to disappear from a different renderer?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Adding an ImageSlice to one renderer causes the image to disappear from a different renderer?

David Doria-2-3
I have this situation:

- A QMainWindow that contains a left and right QVTKWidget.
- A vtkImageData* LeftImageData that will be displayed in the left QVTKWidget
- A vtkImageData* BothImageData that will be displayed in both QVTKWidgets

If I only add the ImageSlice made from BothImageData to the left
QVTKWidget, everything works as expected. However, as soon as I add
the BothImageSlice to the right QVTKWidget, it disappears from the
left QVTKWidget!

Has anyone seen anything like this before? Below is an excerpt:

void MainWindow::on_actionOpenImage_triggered()
{
  std::string filename = "bunny.jpg";

  JPEGReader->SetFileName(filename.c_str());
  JPEGReader->Update();

  this->LeftImageData->ShallowCopy(JPEGReader->GetOutput());

  // Clear everything
  this->LeftRenderer->RemoveAllViewProps();
  this->RightRenderer->RemoveAllViewProps();

  // Setup left pane
  this->LeftImageSliceMapper->SetInputConnection(this->LeftImageData->GetProducerPort());
  this->LeftImageSlice->SetMapper(this->LeftImageSliceMapper);
  this->LeftRenderer->AddViewProp(this->LeftImageSlice);

  // Setup the "Both" image
  Helpers::SetImageSize(this->LeftImageData, this->BothImageData);
  Helpers::CreateTransparentImage(this->LeftImageData,
this->BothImageData); // Makes BothImageData the same size as
LeftImageData, but transparent and empty

  this->BothImageSliceMapper->SetInputConnection(this->BothImageData->GetProducerPort());
  this->BothImageSlice->SetMapper(this->BothImageSliceMapper);

  // Add the "Both" image to both panes
  this->LeftRenderer->AddViewProp(this->BothImageSlice);
  this->RightRenderer->AddViewProp(this->BothImageSlice); // If this
is called (uncommented), the image in the *left* renderer
disappears???

  // Refresh
  this->LeftRenderer->ResetCamera();
  this->RightRenderer->ResetCamera();

  this->qvtkWidgetRight->GetInteractor()->Render();
  this->qvtkWidgetLeft->GetInteractor()->Render();
}


Unfortunately I could not try to recreate this without the Qt
components because I did not know how else to display two renderers.

The full code is available here:
http://daviddoria.com/Uploads/ImageSlice/

Thanks,

David
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Adding an ImageSlice to one renderer causes the image to disappear from a different renderer?

David Gobbi
On Thu, Sep 1, 2011 at 12:05 PM, David Doria <[hidden email]> wrote:
> I have this situation:
>
> - A QMainWindow that contains a left and right QVTKWidget.
> - A vtkImageData* LeftImageData that will be displayed in the left QVTKWidget
> - A vtkImageData* BothImageData that will be displayed in both QVTKWidgets

Do not try to share a mapper between multiple renderers.  Some simple
mappers might work in this kind of configuration, but many will not.
Create a new mapper and actor for each renderer.

 - David
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Adding an ImageSlice to one renderer causes the image to disappear from a different renderer?

David Doria-2-3
> Do not try to share a mapper between multiple renderers.  Some simple
> mappers might work in this kind of configuration, but many will not.
> Create a new mapper and actor for each renderer.
>
>  - David

Yep, that worked. I don't suppose there would be some way to throw an
error/warning if this setup is attempted with a mapper that does not
support being shared?

David
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Adding an ImageSlice to one renderer causes the image to disappear from a different renderer?

David Gobbi
On Thu, Sep 1, 2011 at 12:33 PM, David Doria <[hidden email]> wrote:
>> Do not try to share a mapper between multiple renderers.  Some simple
>> mappers might work in this kind of configuration, but many will not.
>> Create a new mapper and actor for each renderer.
>>
>>  - David
>
> Yep, that worked. I don't suppose there would be some way to throw an
> error/warning if this setup is attempted with a mapper that does not
> support being shared?

It wouldn't be easy.  A mapper doesn't know when its actor is
connected to a renderer.  It doesn't see the renderer until its Render
method is called, since the Renderer and Actor are passed as
parameters to the mapper Render method.  Storing the renderer in an
internal variable would not be a good solution, because when the
mapper sees multiple renderers, it would not know if it was in both
renderers at once, or if it had just been moved from one renderer to
another.

Any sort of a fix would require modifying (or at least adding to) ways
that the mapper, actor, and renderer talk to each other.  It would be
great if someone would take up the challenge, but I am not going to
hold my breath.  Note that it would not be enough for someone to fix
the issue, it would also be necessary to add dashboard tests to ensure
that the fix sticks.  (Experience has made me a bit pessimistic about
these things).

 - David
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers
Loading...