There are two vtkRenderWindow objects, each with two vtkRenderer objects, and the layers have been set. The vtkActor is initially set to the lower-level vtkRenderer of each vtkRenderWindow, and it displays normally.
Now, after changing the color and opacity of the vtkActor, if remove it from the lower-level renderer of each window and add it to the higher-level renderer, the vtkActor will only display correctly in the first rendered window. In the second rendered window, the vtkActor disappears.
void MoveActorToTop(vtkSmartPointer<vtkProp> actor)
{
if (leftWin_ != nullptr)
{
leftWin_ ->loewerRenderer_->RemoveActor(actor);
}
if (rightWin_ != nullptr)
{
rightWin_ ->loewerRenderer_->RemoveActor(actor);
}
if (leftWin_ != nullptr)
{
leftWin_ ->upperRenderer_->AddActor(actor);
}
if (rightWin_ != nullptr)
{
rightWin_ ->upperRenderer_->AddActor(actor);
}
}
Is lowerRenderer assigned to layer=0, and is upperRenderer assigned to layer=1? That should work. Can you confirm in your code whether the window has both the renderers?
FYI, this example may give you some ideas: MultipleLayersAndWindows. There seem to be no issues with multiple actors and windows. In this example, we have two windows each with with two layers and a single actor in each window.
Run the interactive example to see how it looks.
Note:
The layer 0 background is the only visible background, backgrounds in layer 1 and subsequent layers are transparent.
It is easy to access the renderers and actors from the interactor by iterating through the renderer and actor collections.
In renderer collections and actor collections it is important to remember that the references are stored in last in - first out order.