[vtkusers] Adding an ImageSlice to one renderer causes the image to disappear from a different renderer?
David Doria
daviddoria at gmail.com
Thu Sep 1 14:05:50 EDT 2011
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
More information about the vtkusers
mailing list