[vtkusers] create and delete vtkActor and vtk3DWidget
Weiguang guan
guanw at rhpcs.mcmaster.ca
Tue Mar 1 09:58:26 EST 2016
I actually don't know how to remove widgets (for example vtkBoxWidget)
properly. After
vtkBoxWidget *boxWidget = vtkBoxWidget::New();
boxWidget->SetInteractor(iren);
Shall I do
boxWidget->SetInteractor(NULL);
boxWidget->UnRegister(iren);
boxWidget->Delete();
to remove it? I see boxWidget is still alive because its ReferenceCount
is 1 not 0.
I don't mind moving up to use vtkSmartPointer if that can solve my problem.
Weiguang
On 26/02/2016 11:00 AM, Thales Luis Rodrigues Sabino wrote:
> The way I'm doing things is just to remove the actors from the renderer.
> Since I'm sure my program doesn't hold any other reference, I do trust
> that the vtkSmartPointer is doing its job.
>
> On Thu, Feb 25, 2016 at 5:51 PM, Weiguang guan
> <guanw at rhpcs.mcmaster.ca <mailto:guanw at rhpcs.mcmaster.ca>> wrote:
>
> Hello,
>
> In my program (C++), a user can create/remove an object (cone,
> cylinder, ...) or a widget (vtkBoxWidget, ...). What's the right
> way of doing so without causing memory leaking or trashing?
>
> In "Examples/Tutorial/Step6/Cxx/Cone6.cxx", I see the last section
> of code doing clean-up at the end as follows:
> 170 cone->Delete();
> 171 coneMapper->Delete();
> 172 coneActor->Delete();
> 173 callback->Delete();
> 174 boxWidget->Delete();
> 175 ren1->Delete();
> 176 renWin->Delete();
> 177 iren->Delete();
> 178 style->Delete();
> when it exits.
>
> Lines 170-172 won't delete coneActor because ren1 still use it 99
> ren1->AddActor( coneActor ). This example works fine as it delete
> ren1, renWin, and iren as well at exit point. Shall I do
> ren1-RemoveActor(coneActor) in addtion to coneActor->Delete()? I
> just want to "undo" the creation as if cone had never been created.
>
> How about the widget boxWidget? It may be trickier. In addition to
> boxWidget->Delete(), do I need to do something like
> boxWidget->SetInteractor(NULL);
> boxWidget->UnRegister(iren);
> ?
>
> Weiguang
>
> _______________________________________________
> Powered by www.kitware.com <http://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
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers
>
>
>
>
> --
> Thales Luis Rodrigues Sabino
>
> PhD Student at PGMC-UFJF <http://www.ufjf.br/pgmc/>
> Lattes <http://lattes.cnpq.br/0601030410417146> | LinkedIn
> <https://br.linkedin.com/in/tluisrs> | ResearchGate
> <https://www.researchgate.net/profile/Thales_Luis_Sabino>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20160301/fe3f5a33/attachment.html>
More information about the vtkusers
mailing list