[vtkusers] vtkAssembly::SetVisiblity(int)
Barth, Sebastian
sebastian.barth at iosb.fraunhofer.de
Fri Jul 9 07:26:01 EDT 2010
Hello Eric,
I've worked out the problem. I've used the following example for testing.
The problem is, that the motherAssembly ignores the visibility of the line2Assembly and decides directly on the visibility of the line2 actor if it should render the line.
In the following example the line2 (green) should not be rendered because of the visibility, which is set to false, of the line2Assembly. But the line2 is rendered anyway.
Is this a bug?
vtkLineSource * source = vtkLineSource::New();
source->SetPoint1(0, 0, 0);
source->SetPoint2(20, 0, 0);
vtkPolyDataMapper * mapper = vtkPolyDataMapper::New();
mapper->SetInputConnection(source->GetOutputPort());
vtkActor * line1 = vtkActor::New();
line1->SetMapper(mapper);
line1->GetProperty()->SetColor(1,0,0);
vtkActor * line2 = vtkActor::New();
line2->SetMapper(mapper);
line2->GetProperty()->SetColor(0,1,0);
line2->SetPosition(0, 2, 0);
vtkAssembly * line2Assembly = vtkAssembly::New();
line2Assembly->AddPart(line2);
vtkAssembly * motherAssembly = vtkAssembly::New();
motherAssembly->AddPart(line1);
motherAssembly->AddPart(line2Assembly);
line1->SetVisibility(true);
line2->SetVisibility(true);
line2Assembly->SetVisibility(false);
motherAssembly->SetVisibility(true);
vtkRenderer * ren = vtkRenderer::New();
vtkRenderWindow * renWin = vtkRenderWindow::New();
renWin->AddRenderer(ren);
vtkRenderWindowInteractor * iren = vtkRenderWindowInteractor::New();
iren->SetRenderWindow(renWin);
ren->AddActor(motherAssembly);
ren->ResetCamera();
renWin->Render();
iren->Start();
Thanks a lot for your help!
Best Regards,
Sebastian Barth
-----Ursprüngliche Nachricht-----
Von: Eric E. Monson [mailto:emonson at cs.duke.edu]
Gesendet: Donnerstag, 8. Juli 2010 16:02
An: Barth, Sebastian
Cc: vtkusers at vtk.org
Betreff: Re: [vtkusers] vtkAssembly::SetVisiblity(int)
Hey Sebastian,
Well, it works for me. Here's a Python example where setting visibility to False gives a blank window, but setting it to True gives a cube and a sphere:
# -------------------------------
import vtk
sphere = vtk.vtkSphereSource()
mapper1 = vtk.vtkPolyDataMapper()
mapper1.SetInputConnection(sphere.GetOutputPort())
actor1 = vtk.vtkActor()
actor1.SetMapper(mapper1)
cube = vtk.vtkCubeSource()
mapper2 = vtk.vtkPolyDataMapper()
mapper2.SetInputConnection(cube.GetOutputPort())
actor2 = vtk.vtkActor()
actor2.SetMapper(mapper2)
actor2.SetPosition(1,1,1)
assemb = vtk.vtkAssembly()
assemb.AddPart(actor1)
assemb.AddPart(actor2)
assemb.SetVisibility(True)
ren = vtk.vtkRenderer()
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
ren.AddActor(assemb)
ren.ResetCamera()
renWin.Render()
iren.Start()
# -------------------------------
Maybe there's something else happening with yours? What version of VTK and platform are your using?
Talk to you later,
-Eric
------------------------------------------------------
Eric E Monson
Duke Visualization Technology Group
On Jul 8, 2010, at 9:26 AM, Barth, Sebastian wrote:
> Hello vtkusers,
>
> I have a vtkAssembly that controls some vtkActors. Everything works fine with rotating and translating the vtkActors with the vtkAssembly.
> If I want to use vtkAssembly::SetVisibility(false) or vtkAssembly::SetVisibilityOff() nothing happens. The actors ignore the visibility of its assembly.
>
> Is this a bug or a wanted behavior?
> How can I set all of the props added to the assembly set invisible or visible?
>
> Thanks a lot!
>
> Best Regards,
> Sebastian Barth
> _______________________________________________
> 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
More information about the vtkusers
mailing list