[vtkusers] How to delete an interactorstyle in runtime?

sercani sercanimailgroups at gmail.com
Sat Mar 6 04:46:52 EST 2010


Thanks Clinton;
How should i set the interactor and render window of vtkImageViewer2 and 
QVTKWidget? What is the correct order and implementation? And which 
interactor's interactor style shoud be set at the runtime, 
vtkImageViewer2 or QVTKWidget? When i set the interactor style of 
vtkImageViewer2's interactor, it throws an unhandled exception and 
program exits...But if i set the interactorstyle's interactor 
(cis->SetInteractor(interactor);) it doesn't throw an exception but the 
program behaves like there are two different interactors...




05.03.2010 17:33, Clinton Stimpson yazmış:
>
> On Mar 5, 2010, at 7:53 AM, sercani wrote:
>
>> Hi David;
>> This is the declaration of cis:
>> /CustomInteractorStyle *cis=CustomInteractorStyle::New();/
>>
>> and this is the definiton of CustomInteractorStyle class:
>> /
>> class CustomInteractorStyle : public QObject, public 
>> vtkInteractorStyleImage
>> {
>> };/
>>  this class contains virtual mouse functions of 
>> vtkInteractorStyleImage and handles these events according to my 
>> software's tools...When another tool selected, it'is own custom style 
>> is set to interactor's style and handles events too...When i set the 
>> interactor style in runtime like this:
>>
>> /vtkImageViewer2 viewer;
>> viewer->GetRenderWindow()->GetInteractor()->SetInteractorStyle(cis);/
>>  it throws an
>> "/Unhandled exception at 0x60772abb (vtkRendering.dll) in VTKTry.exe: 
>> 0xC0000005: Access violation reading location 0x00000050.
>> The program '[2568] VTKTry.exe: Native' has exited with code 
>> -1073741819 (0xc0000005)/."
>>
>> If i don't set the interactor's interactorstyle,but set the 
>> interactorstyle's interactor like this:
>> /cis->SetInteractor(viewer->GetRenderWindow()->GetInteractor());/  
>> QVTKWidget and my vtkImageViewer2 handles the mousewheel event 
>> seperately and this cause wrong behaviour in my program...
>>  I am setting the viewer's and QVTKWidget's interactor like this:
>> /
>>     vtkImageViewer2 viewer=vtkImageViewer2::New();
>>     qvtk->SetRenderWindow(viewer->GetRenderWindow());
>>     vtkRenderWindowInteractor 
>> *interactor=vtkRenderWindowInteractor::New();
>>     viewer->GetRenderWindow()->SetInteractor(interactor);
>>     
>> qvtk->GetRenderWindow()->SetInteractor(viewer->GetRenderWindow()->GetInteractor());/
>>
>> How can i solve these problems?
>
>
> vtkRenderWindowInteractor::New() gives you one that is incompatible 
> with QVTKWidget.
> Use a QVTKInteractor instead.
>
> Clint
>
>>
>>
>>
>>
>>
>>
>>
>> 05.03.2010 16:18, David Doria yazmış:
>>> On Fri, Mar 5, 2010 at 9:04 AM, sercani <sercanimailgroups at gmail.com 
>>> <mailto:sercanimailgroups at gmail.com>> wrote:
>>>
>>>     Hi everyone,
>>>     I've written subclass of vtkInteractorStyleImage and set it to
>>>     an interactor, but i need to set another custom interactorstyle
>>>     in runtime. When i want to delete the current custom interactor
>>>     style like this:
>>>     if(cis->GetEnabled())
>>>        {
>>>            cis->EnabledOff();
>>>            cis->SetInteractor(0);
>>>            cis->Delete();
>>>        }
>>>
>>>     it throws :
>>>
>>>     "ERROR: In ..\..\VTK_Source\VTK\Common\vtkObject.cxx, line 160
>>>     vtkObject (0155E128): Trying to delete object with non-zero
>>>     reference count."
>>>
>>>     How can i delete this custom interactorstyle and set another
>>>     custom interactorstyle as current interactor's new interactorstyle?
>>>
>>>
>>> Is cis a smart pointer? If so then you should let it delete itself 
>>> instead of deleting it manually - or if you want to delete it 
>>> manually then don't use a smart pointer. Can you send us some more 
>>> code for context?
>>>
>>> Thanks,
>>>
>>> David
>>
>>
>> _______________________________________________
>> 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
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.vtk.org/mailman/listinfo/vtkusers
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100306/333ff61b/attachment.htm>


More information about the vtkusers mailing list