<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Mar 5, 2010, at 7:53 AM, sercani wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">
<div bgcolor="#ffffff" text="#000000">
Hi David;<br>
This is the declaration of cis:<br>
<i>CustomInteractorStyle *cis=CustomInteractorStyle::New();</i><br>
<br>
and this is the definiton of CustomInteractorStyle class:<br>
<i><br>
class CustomInteractorStyle : public QObject, public
vtkInteractorStyleImage<br>
{<br>
};</i><br>
&nbsp;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:<br>
<br>
<i>vtkImageViewer2 viewer;<br>
viewer-&gt;GetRenderWindow()-&gt;GetInteractor()-&gt;SetInteractorStyle(cis);</i><br>
&nbsp;it throws an <br>
"<i>Unhandled exception at 0x60772abb (vtkRendering.dll) in VTKTry.exe:
0xC0000005: Access violation reading location 0x00000050.<br>
The program '[2568] VTKTry.exe: Native' has exited with code
-1073741819 (0xc0000005)</i>."<br>
<br>
If i don't set the interactor's interactorstyle,but set the
interactorstyle's interactor like this:<br>
<i>cis-&gt;SetInteractor(viewer-&gt;GetRenderWindow()-&gt;GetInteractor());</i>&nbsp;
QVTKWidget and my vtkImageViewer2 handles the mousewheel event
seperately and this cause wrong behaviour in my program...<br>
&nbsp;I am setting the viewer's and QVTKWidget's interactor like this:<br>
<i><br>
&nbsp;&nbsp;&nbsp; vtkImageViewer2 viewer=vtkImageViewer2::New();<br>
&nbsp;&nbsp;&nbsp; qvtk-&gt;SetRenderWindow(viewer-&gt;GetRenderWindow());&nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp; vtkRenderWindowInteractor
*interactor=vtkRenderWindowInteractor::New();<br>
&nbsp;&nbsp;&nbsp; viewer-&gt;GetRenderWindow()-&gt;SetInteractor(interactor);<br>
&nbsp;&nbsp;&nbsp;
qvtk-&gt;GetRenderWindow()-&gt;SetInteractor(viewer-&gt;GetRenderWindow()-&gt;GetInteractor());</i><br>
<br>
How can i solve these problems?<br></div></blockquote><div><br></div><div><br></div><div>vtkRenderWindowInteractor::New() gives you one that is incompatible with QVTKWidget.</div><div>Use a QVTKInteractor instead.</div><div><br></div><div>Clint</div><br><blockquote type="cite"><div bgcolor="#ffffff" text="#000000">
<br>
<br>
<br>
<br>
<br>
<br>
<br>
05.03.2010 16:18, David Doria yazmış:
<blockquote cite="mid:c19fcadc1003050618v3765b107gf7721c20f68eddc9@mail.gmail.com" type="cite">
  <div class="gmail_quote">On Fri, Mar 5, 2010 at 9:04 AM, sercani <span dir="ltr">&lt;<a moz-do-not-send="true" href="mailto:sercanimailgroups@gmail.com">sercanimailgroups@gmail.com</a>&gt;</span>
wrote:<br>
  <blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi
everyone,<br>
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:<br>
if(cis-&gt;GetEnabled())<br>
&nbsp; &nbsp;{<br>
&nbsp; &nbsp; &nbsp; &nbsp;cis-&gt;EnabledOff();<br>
&nbsp; &nbsp; &nbsp; &nbsp;cis-&gt;SetInteractor(0);<br>
&nbsp; &nbsp; &nbsp; &nbsp;cis-&gt;Delete();<br>
&nbsp; &nbsp;}<br>
    <br>
it throws :<br>
    <br>
"ERROR: In ..\..\VTK_Source\VTK\Common\vtkObject.cxx, line 160<br>
vtkObject (0155E128): Trying to delete object with non-zero reference
count."<br>
    <br>
How can i delete this custom interactorstyle and set another custom
interactorstyle as current interactor's new interactorstyle?<br>
    <br>
  </blockquote>
  <div><br>
  </div>
  <div>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?</div>
  <br clear="all">
Thanks,<br>
  <br>
  <div>David</div>
  </div>
</blockquote>
<br>
<br>
</div>

_______________________________________________<br>Powered by <a href="http://www.kitware.com">www.kitware.com</a><br><br>Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a><br><br>Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ">http://www.vtk.org/Wiki/VTK_FAQ</a><br><br>Follow this link to subscribe/unsubscribe:<br><a href="http://www.vtk.org/mailman/listinfo/vtkusers">http://www.vtk.org/mailman/listinfo/vtkusers</a><br></blockquote></div><br></body></html>