<html>
  <head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">I actually don't know how to remove
      widgets (for example vtkBoxWidget) properly. After<br>
          vtkBoxWidget *boxWidget = vtkBoxWidget::New();<br>
          boxWidget->SetInteractor(iren);<br>
      Shall I do <br>
          boxWidget->SetInteractor(NULL);<br>
          boxWidget->UnRegister(iren);<br>
          boxWidget->Delete();<br>
      to remove it? I see boxWidget is still alive because its
      ReferenceCount is 1 not 0.<br>
      <br>
      I don't mind moving up to use vtkSmartPointer if that can solve my
      problem. <br>
      <br>
      Weiguang<br>
      <br>
      On 26/02/2016 11:00 AM, Thales Luis Rodrigues Sabino wrote:<br>
    </div>
    <blockquote
cite="mid:CAHvrNaenfYpDiESjNyxFed0QgzofJ5+V9xBC8F+txrSc1euGig@mail.gmail.com"
      type="cite">
      <div dir="ltr">The way I'm doing things is just to remove the
        actors from the renderer.
        <div>Since I'm sure my program doesn't hold any other reference,
          I do trust that the vtkSmartPointer is doing its job.</div>
      </div>
      <div class="gmail_extra"><br>
        <div class="gmail_quote">On Thu, Feb 25, 2016 at 5:51 PM,
          Weiguang guan <span dir="ltr"><<a moz-do-not-send="true"
              href="mailto:guanw@rhpcs.mcmaster.ca" target="_blank">guanw@rhpcs.mcmaster.ca</a>></span>
          wrote:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0
            .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello,<br>
            <br>
            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?<br>
            <br>
            In "Examples/Tutorial/Step6/Cxx/Cone6.cxx", I see the last
            section of code doing clean-up at the end as follows:<br>
             170   cone->Delete();<br>
             171   coneMapper->Delete();<br>
             172   coneActor->Delete();<br>
             173   callback->Delete();<br>
             174   boxWidget->Delete();<br>
             175   ren1->Delete();<br>
             176   renWin->Delete();<br>
             177   iren->Delete();<br>
             178   style->Delete();<br>
            when it exits.<br>
            <br>
            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<br>
            ren1-RemoveActor(coneActor) in addtion to
            coneActor->Delete()? I just want to "undo" the creation
            as if cone had never been created.<br>
            <br>
            How about the widget boxWidget? It may be trickier. In
            addition to boxWidget->Delete(), do I need to do
            something like<br>
            boxWidget->SetInteractor(NULL);<br>
            boxWidget->UnRegister(iren);<br>
            ?<br>
            <br>
            Weiguang<br>
            <br>
            _______________________________________________<br>
            Powered by <a moz-do-not-send="true"
              href="http://www.kitware.com" rel="noreferrer"
              target="_blank">www.kitware.com</a><br>
            <br>
            Visit other Kitware open-source projects at <a
              moz-do-not-send="true"
              href="http://www.kitware.com/opensource/opensource.html"
              rel="noreferrer" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
            <br>
            Please keep messages on-topic and check the VTK FAQ at: <a
              moz-do-not-send="true"
              href="http://www.vtk.org/Wiki/VTK_FAQ" rel="noreferrer"
              target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
            <br>
            Search the list archives at: <a moz-do-not-send="true"
              href="http://markmail.org/search/?q=vtkusers"
              rel="noreferrer" target="_blank">http://markmail.org/search/?q=vtkusers</a><br>
            <br>
            Follow this link to subscribe/unsubscribe:<br>
            <a moz-do-not-send="true"
              href="http://public.kitware.com/mailman/listinfo/vtkusers"
              rel="noreferrer" target="_blank">http://public.kitware.com/mailman/listinfo/vtkusers</a><br>
          </blockquote>
        </div>
        <br>
        <br clear="all">
        <div><br>
        </div>
        -- <br>
        <div class="gmail_signature">
          <div dir="ltr">
            <div>
              <div dir="ltr">
                <div>Thales Luis Rodrigues Sabino</div>
                <div><br>
                </div>
                <div>PhD Student at <a moz-do-not-send="true"
                    href="http://www.ufjf.br/pgmc/" target="_blank">PGMC-UFJF</a></div>
                <div><a moz-do-not-send="true"
                    href="http://lattes.cnpq.br/0601030410417146"
                    target="_blank">Lattes</a> | <a
                    moz-do-not-send="true"
                    href="https://br.linkedin.com/in/tluisrs"
                    target="_blank">LinkedIn</a> | <a
                    moz-do-not-send="true"
                    href="https://www.researchgate.net/profile/Thales_Luis_Sabino"
                    target="_blank">ResearchGate</a></div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </blockquote>
    <br>
  </body>
</html>