<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 "<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">." 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:'courier new',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->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->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->UCDeviceCallbackCommand = vtkCallbackCommand::New();</font></div><div>
<font face="courier new, monospace"><span class="" style="white-space:pre">        </span>this->UCDeviceCallbackCommand->SetClientData(this); </font></div><div><font face="courier new, monospace"><span class="" style="white-space:pre">        </span><b>this->UCDeviceCallbackCommand->SetCallback(ProcessEvents);</b></font></div>
<div><font face="courier new, monospace"><span class="" style="white-space:pre">        </span>//this->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->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->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<DeviceVolumeInteractor *>( 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->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->m_ActiveHand == DeviceMediator::ActiveHand::AH_LEFT || </font></div>
<div><font face="courier new, monospace"><span class="" style="white-space:pre">                </span>mKm->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->SetCurrentRenderer(this->Interactor->FindPokedRenderer(mKm->mpHandLeft.x, mKm->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->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->SetCurrentRenderer(this->Interactor->FindPokedRenderer(mKm->mpHandRight.x, mKm->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->GrabFocus(this->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->Interactor )</font></div>
<div><font face="courier new, monospace"> {</font></div><div><font face="courier new, monospace"> this->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->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->Interactor;</font></div>
<div><font face="courier new, monospace"> double *center = this->CurrentRenderer->GetCenter();</font></div><div><font face="courier new, monospace"> //double dy = rwi->GetEventPosition()[1] - center[1];</font></div>
<div><font face="courier new, monospace"> <b>double dy = (mKm->mpHandLeft.depth - mKm->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->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"><<a href="mailto:daviddoria@gmail.com" target="_blank">daviddoria@gmail.com</a>></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 <<a href="mailto:f.erguner@gmail.com">f.erguner@gmail.com</a>> wrote:<br>
> Hello all,<br>
><br>
> i want to create custom event for manipuating the rendered 3d volumes. For<br>
> example when i say "hello" then this event is invoked and i move the objects<br>
> etc. I created a custom interactorstyle which is a subclass of<br>
> vtkInteractorStyle.<br>
><br>
> <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>
> in above example, a test class which is inherited from vtkPolyDataAlgorithm<br>
> has a user defined RefreshEvent which is invoked in RequestData.<br>
><br>
> But vtkInteractorStyle class has no RequestData method. is there a way of<br>
> overriding the ProgressEvent Method. Or how can i accomplish this task?<br>
><br>
> thanks in advance...<br>
><br>
> --<br>
> Best Regards;<br>
> Fatih Ergüner<br>
<br>
<br>
</div></div>Perhaps you can be a bit more concrete. What do you mean by "say hello"?<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'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>