<div dir="ltr"><div style>Firstly thank you very much for reply.</div><div style><br></div><div style>To be more concrete: im in front of a camera and im getting the both hand coordinates ready to use in interactorStyle class via a device mediator class.</div>
<div style><br></div><div style>There is a DeviceVolumeInteractor class which is derived from vtkInteractorStyleJoystickCamera. This class has the hand coordinates(x,y values are same as in GetEventPosition()  ) as stated above. The problem is that even i know the hand coordinates i cannot inject the hand.x,hand.y values into GetEventPosition().</div>
<div style><br></div><div style>I created custom events in another thread to overcome, but in this case i got &quot;<span style="color:rgb(68,68,68);font-family:arial,sans-serif;line-height:16px">failed in MakeCurrent(), error: The requested </span><em style="font-weight:bold;font-style:normal;color:rgb(68,68,68);font-family:arial,sans-serif;line-height:16px">resource is in use</em><span style="color:rgb(68,68,68);font-family:arial,sans-serif;line-height:16px">.&quot; i give call the callback from another thread but </span>i couldnt figure out where should i trigger it every time.</div>
<div><br></div><div><br></div>here is the code summary:<div><br></div><div><br></div><div><span style="font-family:&#39;courier new&#39;,monospace">//-------------------------------</span><br></div><div><div><font face="courier new, monospace">//------DeviceVolumeInteractor is derived from vtkInteractorStyleJoystickCamera</font></div>
<div><font face="courier new, monospace">//-------------------------------</font></div><div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace">//ctor</font></div><div><font face="courier new, monospace">DeviceVolumeInteractor::DeviceVolumeInteractor()</font></div>
<div><font face="courier new, monospace">{</font></div><div><font face="courier new, monospace"><span class="" style="white-space:pre">        </span>// Use timers to handle continous interaction</font></div><div><font face="courier new, monospace"><span class="" style="white-space:pre">        </span>this-&gt;UseTimers = 1;</font></div>
<div><font face="courier new, monospace"><span class="" style="white-space:pre">        </span>// user defined event number starts from vtkCommand::UserEvent</font></div><div><font face="courier new, monospace"><span class="" style="white-space:pre">        </span>this-&gt;DeviceControlEvent = vtkCommand::UserEvent + 1;<span class="" style="white-space:pre">        </span></font></div>
<div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace"><span class="" style="white-space:pre">        </span>this-&gt;UCDeviceCallbackCommand = vtkCallbackCommand::New();</font></div><div>
<font face="courier new, monospace"><span class="" style="white-space:pre">        </span>this-&gt;UCDeviceCallbackCommand-&gt;SetClientData(this); </font></div><div><font face="courier new, monospace"><span class="" style="white-space:pre">        </span><b>this-&gt;UCDeviceCallbackCommand-&gt;SetCallback(ProcessEvents);</b></font></div>
<div><font face="courier new, monospace"><span class="" style="white-space:pre">        </span>//this-&gt;SetEnabled(1);</font></div><div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace"><span class="" style="white-space:pre">        </span><b>//adding User Control Device Callback as an observer to user-defined Interactor</b></font></div>
<div><font face="courier new, monospace"><b><span class="" style="white-space:pre">        </span>this-&gt;AddObserver(DeviceControlEvent,UCDeviceCallbackCommand);</b></font></div><div><font face="courier new, monospace"><br></font></div>
<div><font face="courier new, monospace"><span class="" style="white-space:pre">        </span>DeviceCS = DeviceControlState::CS_NONE;</font></div><div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace"><span class="" style="white-space:pre">        </span>initialize();</font></div>
<div><font face="courier new, monospace">}</font></div><div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace">/// Thread to handle Device controls</font></div><div><font face="courier new, monospace">DWORD WINAPI     DeviceVolumeInteractor::DeviceEventLoop( )</font></div>
<div><font face="courier new, monospace">{  </font></div><div><font face="courier new, monospace"><span class="" style="white-space:pre">        </span>while(true)</font></div><div><font face="courier new, monospace"><span class="" style="white-space:pre">        </span>{</font></div>
<div><font face="courier new, monospace"><span class="" style="white-space:pre">                </span>//if hand is active</font></div><div><font face="courier new, monospace"><span class="" style="white-space:pre">                </span>if(mKm-&gt;m_ActiveHand != DeviceMediator::ActiveHand::AH_NOT_ACTIVE)</font></div>
<div><font face="courier new, monospace"><span class="" style="white-space:pre">                </span>{</font></div><div><font face="courier new, monospace"><span class="" style="white-space:pre">                        </span>//InvokeEvent(DeviceControlEvent,NULL);</font></div>
<div><font face="courier new, monospace"><span class="" style="white-space:pre">                        </span>setDeviceControlState(DeviceControlState::CS_ZOOM);</font></div><div><font face="courier new, monospace"><span class="" style="white-space:pre">                </span>}</font></div>
<div><font face="courier new, monospace"><span class="" style="white-space:pre">                </span>else</font></div><div><font face="courier new, monospace"><span class="" style="white-space:pre">                </span>{</font></div><div><font face="courier new, monospace"><span class="" style="white-space:pre">                        </span>setDeviceControlState(DeviceControlState::CS_NONE);</font></div>
<div><font face="courier new, monospace"><span class="" style="white-space:pre">                </span>}</font></div><div><font face="courier new, monospace"><span class="" style="white-space:pre">        </span>}</font></div><div><span class="" style="white-space:pre"><font face="courier new, monospace">        </font></span></div>
<div><font face="courier new, monospace"><span class="" style="white-space:pre">        </span>return 0;</font></div><div><font face="courier new, monospace">}</font></div><div><font face="courier new, monospace"><br></font></div>
<div><font face="courier new, monospace"><b>// The Callback method</b></font></div><div><font face="courier new, monospace">void    DeviceVolumeInteractor::ProcessEvents(vtkObject* vtkNotUsed(object), </font></div><div><font face="courier new, monospace">                                       unsigned long event,</font></div>
<div><font face="courier new, monospace">                                       void* clientdata, </font></div><div><font face="courier new, monospace">                                       void* calldata )</font></div><div>
<font face="courier new, monospace">{</font></div><div><font face="courier new, monospace"><span class="" style="white-space:pre">        </span>DeviceVolumeInteractor* self </font></div><div><font face="courier new, monospace">    = reinterpret_cast&lt;DeviceVolumeInteractor *&gt;( clientdata );</font></div>
<div style><font face="courier new, monospace">        <b>//CAN BE WRONG</b></font></div><div><font face="courier new, monospace"><span class="" style="white-space:pre">        </span><b>self-&gt;OnHandActive();</b></font></div>
<div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace">}</font></div><div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace">//----------------------------------------------------------------------------</font></div>
<div><font face="courier new, monospace">void DeviceVolumeInteractor::OnHandActive()</font></div><div><font face="courier new, monospace">{</font></div><div><font face="courier new, monospace"><span class="" style="white-space:pre">        </span>if ( mKm-&gt;m_ActiveHand == DeviceMediator::ActiveHand::AH_LEFT || </font></div>
<div><font face="courier new, monospace"><span class="" style="white-space:pre">                </span>mKm-&gt;m_ActiveHand == DeviceMediator::ActiveHand::AH_BOTH)</font></div><div><font face="courier new, monospace"><span class="" style="white-space:pre">        </span>{</font></div>
<div><font face="courier new, monospace"><span class="" style="white-space:pre">                </span>this-&gt;SetCurrentRenderer(this-&gt;Interactor-&gt;FindPokedRenderer(mKm-&gt;mpHandLeft.x, mKm-&gt;mpHandLeft.y));</font></div><div>
<font face="courier new, monospace"><span class="" style="white-space:pre">        </span>}</font></div><div><font face="courier new, monospace"><span class="" style="white-space:pre">        </span>else if ( mKm-&gt;m_ActiveHand == DeviceMediator::ActiveHand::AH_RIGHT )</font></div>
<div><font face="courier new, monospace"><span class="" style="white-space:pre">        </span>{</font></div><div><font face="courier new, monospace"><span class="" style="white-space:pre">                </span>this-&gt;SetCurrentRenderer(this-&gt;Interactor-&gt;FindPokedRenderer(mKm-&gt;mpHandRight.x, mKm-&gt;mpHandRight.y));</font></div>
<div><font face="courier new, monospace"><span class="" style="white-space:pre">        </span>}</font></div><div><font face="courier new, monospace"><br></font></div><div style><font face="courier new, monospace">        <b>//CAN BE WRONG</b></font></div>
<div><font face="courier new, monospace"><span class="" style="white-space:pre">        </span><b>this-&gt;GrabFocus(this-&gt;UCDeviceCallbackCommand);</b></font></div><div><font face="courier new, monospace"><b><span class="" style="white-space:pre">        </span>//setDeviceControlState(DeviceControlState::CS_ZOOM);</b></font></div>
<div><font face="courier new, monospace"><span class="" style="white-space:pre">        </span>Dolly();</font></div><div><span class="" style="white-space:pre"><font face="courier new, monospace">        </font></span></div><div><font face="courier new, monospace"><span class="" style="white-space:pre">        </span>if ( this-&gt;Interactor )</font></div>
<div><font face="courier new, monospace">        {</font></div><div><font face="courier new, monospace">         this-&gt;ReleaseFocus();</font></div><div><font face="courier new, monospace">        }</font></div><div><font face="courier new, monospace">}</font></div>
<div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace">//----------------------------------------------------------------------------</font></div><div><font face="courier new, monospace">void DeviceVolumeInteractor::Dolly()</font></div>
<div><font face="courier new, monospace">{</font></div><div><font face="courier new, monospace">  if (this-&gt;CurrentRenderer == NULL)</font></div><div><font face="courier new, monospace">    {</font></div><div><font face="courier new, monospace">    return;</font></div>
<div><font face="courier new, monospace">    }</font></div><div><font face="courier new, monospace">  </font></div><div><font face="courier new, monospace">  vtkRenderWindowInteractor *rwi = this-&gt;Interactor;</font></div>
<div><font face="courier new, monospace">  double *center = this-&gt;CurrentRenderer-&gt;GetCenter();</font></div><div><font face="courier new, monospace">  //double dy = rwi-&gt;GetEventPosition()[1] - center[1];</font></div>
<div><font face="courier new, monospace">  <b>double dy = (mKm-&gt;mpHandLeft.depth - mKm-&gt;mpHandRight.depth);// - center[1];</b></font></div><div><font face="courier new, monospace">  double dyf = 0.5 * dy;// / center[1];</font></div>
<div><font face="courier new, monospace">  this-&gt;Dolly(pow(1.1, dyf));</font></div><div><font face="courier new, monospace">}</font></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div>
<br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div>
<br></div><div><br></div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, May 20, 2013 at 4:44 PM, David Doria <span dir="ltr">&lt;<a href="mailto:daviddoria@gmail.com" target="_blank">daviddoria@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Fri, May 17, 2013 at 5:33 PM, Fatih Ergüner &lt;<a href="mailto:f.erguner@gmail.com">f.erguner@gmail.com</a>&gt; wrote:<br>

&gt; Hello all,<br>
&gt;<br>
&gt; i want to create custom event for manipuating the rendered 3d volumes. For<br>
&gt; example when i say &quot;hello&quot; then this event is invoked and i move the objects<br>
&gt; etc. I created a custom interactorstyle which is a subclass of<br>
&gt; vtkInteractorStyle.<br>
&gt;<br>
&gt; <a href="http://www.vtk.org/Wiki/VTK/Examples/Cxx/Interaction/UserEvent" target="_blank">http://www.vtk.org/Wiki/VTK/Examples/Cxx/Interaction/UserEvent</a><br>
&gt; in above example, a test class which is inherited from vtkPolyDataAlgorithm<br>
&gt; has a  user defined RefreshEvent which is invoked in RequestData.<br>
&gt;<br>
&gt; But vtkInteractorStyle class has no RequestData method. is there a way of<br>
&gt; overriding the ProgressEvent Method. Or how can i accomplish this task?<br>
&gt;<br>
&gt; thanks in advance...<br>
&gt;<br>
&gt; --<br>
&gt; Best Regards;<br>
&gt; Fatih Ergüner<br>
<br>
<br>
</div></div>Perhaps you can be a bit more concrete. What do you mean by &quot;say hello&quot;?<br>
<br>
You should be able to invoke an event from anywhere as long as the<br>
class is derived from vtkObject. It would probably be easier if you<br>
could show us a minimal, compilable example of what you&#39;ve tried so<br>
far, and explain exactly where it is not working for you.<br>
<span class="HOEnZb"><font color="#888888"><br>
David<br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br>Saygılarımla;<br>Fatih Ergüner<br>
</div>