<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">Hello everyone<br>In one of the examples given in vtk (cone2) i am
trying to use mouse interatcively to create some events for eg. if i do right click on mouse the
cone should stop rotating. How do i do it in vtk. <br>&nbsp;<br>Thank you<br>Frency Varghese<br>Here is the code<br><br>#include "vtkConeSource.h"<br>#include "vtkPolyDataMapper.h"<br>#include "vtkRenderWindow.h"<br>#include "vtkCommand.h"<br>#include "vtkCamera.h"<br>#include "vtkActor.h"<br>#include "vtkRenderer.h"<br><br>// Callback for the interaction<br>class vtkMyCallback : public vtkCommand<br>{<br>public:<br>&nbsp; static vtkMyCallback *New()<br>&nbsp;&nbsp;&nbsp; { return new vtkMyCallback; }<br>&nbsp; virtual void Execute(vtkObject *caller, unsigned long, void*)<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vtkRenderer *renderer = reinterpret_cast&lt;vtkRenderer*&gt;(caller);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cout &lt;&lt;
 renderer-&gt;GetActiveCamera()-&gt;GetPosition()[0] &lt;&lt; " "<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;&lt; renderer-&gt;GetActiveCamera()-&gt;GetPosition()[1] &lt;&lt; " "<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;&lt; renderer-&gt;GetActiveCamera()-&gt;GetPosition()[2] &lt;&lt; "\n";<br>&nbsp;&nbsp;&nbsp; }<br>};<br><br>int main()<br>{<br>&nbsp; //<br>&nbsp; // The pipeline creation is documented in Step1<br>&nbsp; //<br>&nbsp; vtkConeSource *cone = vtkConeSource::New();<br>&nbsp; cone-&gt;SetHeight( 3.0 );<br>&nbsp; cone-&gt;SetRadius( 1.0 );<br>&nbsp; cone-&gt;SetResolution( 10 );<br><br>&nbsp; vtkPolyDataMapper *coneMapper = vtkPolyDataMapper::New();<br>&nbsp; coneMapper-&gt;SetInputConnection( cone-&gt;GetOutputPort() );<br>&nbsp; vtkActor *coneActor = vtkActor::New();<br>&nbsp; coneActor-&gt;SetMapper( coneMapper );<br><br>&nbsp; vtkRenderer *ren1= vtkRenderer::New();<br>&nbsp;
 ren1-&gt;AddActor( coneActor );<br>&nbsp; ren1-&gt;SetBackground( 0.1, 0.2, 0.4 );<br>&nbsp; ren1-&gt;ResetCamera();<br><br>&nbsp; vtkRenderWindow *renWin = vtkRenderWindow::New();<br>&nbsp; renWin-&gt;AddRenderer( ren1 );<br>&nbsp; renWin-&gt;SetSize( 300, 300 );<br><br>&nbsp; // Here is where we setup the observer, we do a new and ren1 will<br>&nbsp; // eventually free the observer<br>&nbsp; vtkMyCallback *mo1 = vtkMyCallback::New();<br>&nbsp; ren1-&gt;AddObserver(vtkCommand::StartEvent,mo1);<br>&nbsp; mo1-&gt;Delete();<br><br>&nbsp; //<br>&nbsp; // now we loop over 360 degrees and render the cone each time<br>&nbsp; //<br>&nbsp; int i;<br>&nbsp; for (i = 0; i &lt; 360; ++i)<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; // render the image<br>&nbsp;&nbsp;&nbsp; renWin-&gt;Render();<br>&nbsp;&nbsp;&nbsp; // rotate the active camera by one degree<br>&nbsp;&nbsp;&nbsp; ren1-&gt;GetActiveCamera()-&gt;Azimuth( 1 );<br>&nbsp;&nbsp;&nbsp; }<br><br>&nbsp;
 //<br>&nbsp; // Free up any objects we created<br>&nbsp; //<br>&nbsp; cone-&gt;Delete();<br>&nbsp; coneMapper-&gt;Delete();<br>&nbsp; coneActor-&gt;Delete();<br>&nbsp; ren1-&gt;Delete();<br>&nbsp; renWin-&gt;Delete();<br><br>&nbsp; return 0;<br>}<br><br></td></tr></table><br>