[vtkusers] vtkInteractorStyle etc
Charl P. Botha
c.p.botha at ewi.tudelft.nl
Fri Mar 12 09:53:48 EST 2004
On Fri, 2004-03-12 at 15:37, James C. Robinson wrote:
> As I haven't had any responses yet in regard my queries, I am trying to
> investigate further. One logic that coccurred to me in regard the new setup
> (vtkRenderWindowInteractor having a pointer to an vtkInteractorObsever
> instead of a vtkInteractorStyle) was the idea that, the very basic
> functionalities required must be in vtkInteractorObsever, and then the
> vtkInteractorStyle (and sub classes) are built upon this. You then put a
> pointer to the base class in the vtkRenderWindowInteractor and maybe
> recast(?) in your own code, depending on which subclass you use. This would
> mean that one should have to new an instance of vtkInteractorStyle in one's
> code explicitly and point the vtkRenderWindowInteractor at it (using
> this->SetInteractorStyle())??
Something like that, although it's far simpler than you make it sound.
:) Just create the InteractorStyle you need, call the
SetInteractorStyle method of the relevant RenderWindowInteractor with
your instance pointer as parameter, and call Delete() again. The RWI
will make sure it removes its reference when it dies. Please continue
reading for a 3 sentence crash course on VTK reference counting.
>
> However, in the code for vtkRenderWindowInteractor, in its constructor we
> have:
>
> this->RenderWindow = NULL;
> this->InteractorStyle = NULL;
> this->SetInteractorStyle(vtkInteractorStyleSwitch::New());
> this->InteractorStyle->Delete();
>
> I am probably not understanding this clearly, but, why does it create a new
> instance of vtkInteractorStyleSwitch and then destroy it?
It creates it with a reference count of 1, sets it, which adds 1 more to
the ref count bringing it to 2 and then Delete()s it, bringing the ref
count back to 1. This means it's not destroyed.
As with all things in life, references you give and references you take
away have to balance in the end.
>
> Is my understanding in the first paragraph correct? Should I be creating a
> new instance of my choice of vtkInteractorStyle in my MFCView?
>
> Please advise.
>
> Jim
> ______________________
>
> James C. Robinson, PhD,
> Chartered Engineer,
> Kepler Simulation Systems Ltd.,
> 42 Rivergrove,
> Glanmire, Co. Cork,
> Eire
>
> Tel: +353-21-4822028
> Tel: +353-87-2393010
> Fax: +353-21-4822028
> E-mail: j.robinson at kepler-systems.com
> ______________________
>
>
>
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at: <http://public.kitware.com/cgi-bin/vtkfaq>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
--
charl p. botha http://cpbotha.net/ http://visualisation.tudelft.nl/
More information about the vtkusers
mailing list