Hello Rakesh,<br><br>I remember an example which is related to double click:<br><br>Â Â <a href="http://www.vtk.org/Wiki/VTK_Mouse_Picking">http://www.vtk.org/Wiki/VTK_Mouse_Picking</a><br><br>But the principles exactly the same as Allan had explained.<br>
<br>Regards,<br>Pawel~<br>_________________<br>PaweÅ‚~~Åubniewski<br>__________________________________________________________________________<br><br><div class="gmail_quote">2010/3/10 Allan James <span dir="ltr"><<a href="mailto:ar.james@qut.edu.au">ar.james@qut.edu.au</a>></span><br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><br>
Hi Rakesh,<br>
<br>
<br>
There are numerous ways to capture double-clicks... The (simple and incomplete) example below essentially counts the number of clicks that have occurred when mouse is not moving. When the has moved more pixels than resetPixelDistance, number of clicks is reset.<br>
<br>
Attach the callback to your interactor style to capture these events: "LeftButtonPressEvent", "LeftButtonReleaseEvent" and "MouseMoveEvent"<br>
<br>
This should give you an idea for one way to approach this, another way would be to instead include a timer so that double-click needs to occur within a specified time interval.<br>
<br>
--------------<br>
<br>
void MyCallback::Execute(vtkObject *caller, unsigned long eventId, void* data)<br>
{<br>
    if(eventId == vtkCommand::LeftButtonPressEvent)<br>
    {<br>
        // propogate event<br>
        if(sceneRenderWindowInteractorStyle)<br>
            sceneRenderWindowInteractorStyle->OnLeftButtonDown();<br>
<br>
    }<br>
    else if(eventId == vtkCommand::LeftButtonReleaseEvent)<br>
    {<br>
        numClicks++;<br>
<br>
        if(numClicks >= 2)<br>
        {<br>
            // this block is executed on double-click<br>
<br>
            numClicks = 0;<br>
<br>
            int pickPosition[2];<br>
            sceneRenderWindowInteractor->GetEventPosition(pickPosition);<br>
        }<br>
<br>
        // propogate event<br>
        if(sceneRenderWindowInteractorStyle)<br>
            sceneRenderWindowInteractorStyle->OnLeftButtonUp();<br>
    }<br>
    else if(eventId == vtkCommand::MouseMoveEvent)<br>
    {<br>
        if(numClicks > 0)<br>
        {<br>
            int pickPosition[2];<br>
            sceneRenderWindowInteractor->GetEventPosition(pickPosition);<br>
<br>
            int xdist = pickPosition[0]-prevPosition[0];<br>
            int ydist = pickPosition[1]-prevPosition[1];<br>
<br>
            prevPosition[0] = pickPosition[0];<br>
            prevPosition[1] = pickPosition[1];<br>
<br>
            int moveDistance = (int)sqrt((double)(xdist*xdist + ydist*ydist));<br>
<br>
            // Reset numClicks - If mouse moved further than resetPixelDistance<br>
            if(moveDistance > resetPixelDistance)<br>
                numClicks = 0;<br>
        }<br>
<br>
        // propogate event<br>
        if(sceneRenderWindowInteractorStyle)<br>
            sceneRenderWindowInteractorStyle->OnMouseMove();<br>
    }<br>
}<br>
<br>
MyCallback::MyCallback()<br>
{<br>
    numClicks = 0;<br>
    resetPixelDistance = 10;<br>
    prevPosition[0] = prevPosition[1] = 0;<br>
}<br>
<br>
---------------<br>
<br>
Allan James<br>
High Performance Computing & Research Support<br>
Queensland University of Technology<br>
(07) 3138 9264<br>
<a href="mailto:ar.james@qut.edu.au">ar.james@qut.edu.au</a><br>
<a href="http://www.qut.edu.au/its/hpc" target="_blank">http://www.qut.edu.au/its/hpc</a><br>
<br>
><(((º>  ._.·´¯`·..  >++(((º>  ._.·´¯`·..  >++(((º><br>
<div class="im"><br>
<br>
> You can catch keys like this:<br>
> <a href="http://vtk.org/Wiki/VTK/Examples/Interaction/KeypressEvents" target="_blank">http://vtk.org/Wiki/VTK/Examples/Interaction/KeypressEvents</a><br>
><br>
> Double click is a good question - anyone have any ideas?<br>
><br>
> Thanks,<br>
><br>
> David<br>
</div>> -------------- next part --------------<br>
> An HTML attachment was scrubbed...<br>
> URL:<br>
> <<a href="http://www.vtk.org/pipermail/vtkusers/attachments/20100309/c1" target="_blank">http://www.vtk.org/pipermail/vtkusers/attachments/20100309/c1</a><br>
> 74cdfc/attachment-0001.htm><br>
><br>
> ------------------------------<br>
><br>
> Message: 12<br>
> Date: Tue, 9 Mar 2010 09:53:47 -0500<br>
> From: David Doria <<a href="mailto:daviddoria%2Bvtk@gmail.com">daviddoria+vtk@gmail.com</a>><br>
> Subject: Re: [vtkusers] Which interactor style to use..??<br>
> To: Rakesh Patil <<a href="mailto:rakeshthp@in.com">rakeshthp@in.com</a>><br>
> Cc: vtkusers <<a href="mailto:vtkusers@vtk.org">vtkusers@vtk.org</a>><br>
> Message-ID:<br>
> Â Â Â <<a href="mailto:c19fcadc1003090653odcbd660xb233091f6f7d2b22@mail.gmail.com">c19fcadc1003090653odcbd660xb233091f6f7d2b22@mail.gmail.com</a>><br>
> Content-Type: text/plain; charset="iso-8859-1"<br>
<div class="im">><br>
> On Tue, Mar 9, 2010 at 7:52 AM, Rakesh Patil <<a href="mailto:rakeshthp@in.com">rakeshthp@in.com</a>> wrote:<br>
><br>
> > Hello,<br>
> ><br>
> > I need to catch double click event,.. Is there any<br>
> interactor style that<br>
> > has this facility..?? Also, i need catch keypress events,<br>
> like deleting<br>
> > objects by pressing delete button..<br>
> ><br>
> > How do i do this..??<br>
> ><br>
> > Thanks in advance<br>
> ><br>
> > Regards<br>
> > Rakesh Patil<br>
> ><br>
> ><br>
<br>
<br>
<br>
</div>_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">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" target="_blank">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" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
</blockquote></div><br>