replied too fast . The displaytoview() and viewToWorld does not take points as input.<br><br>But you can use the vtkCoordinate . Try this particular snippet of code.<br><br>vtkCamera *camera = renderer->GetActiveCamera();<br>
double *n = new double[2];<br>n = camera->GetClippingRange();<br> <br><br> vtkSmartPointer<vtkCoordinate> coordinate = vtkSmartPointer<vtkCoordinate>::New();<br> coordinate->SetCoordinateSystemToDisplay();<br>
coordinate->SetValue(x,y); // display coordinates<br> double *pt = new double[3];<br> pt = coordinate->GetComputedWorldValue(renderer);<br> cout << pt[0] << " " <<pt[1] << " " << pt[2] << endl;<br>
vtkSmartPointer<vtkSphereSource> sphereSource = <br> vtkSmartPointer<vtkSphereSource>::New();<br> sphereSource->SetCenter(pt[0],pt[1],pt[2]*-1*n[0]);<br> sphereSource->SetRadius(1.0);<br>
sphereSource->Update();<br><br>depth is assumed to be 1 and n[0] is the near clip..<br><br><br><div class="gmail_quote">On Wed, Apr 7, 2010 at 6:26 PM, Darshan Pai <span dir="ltr"><<a href="mailto:darshanpai@gmail.com">darshanpai@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">I don't know how to get the matrices defined . Maybe someone can help .<br>But vtkRenderer has some functions like DisplayToView() and ViewToWorld() which can get you the world coordinate for that point.<br>
The default camera has the clipping information . You provide the depth of the point<br>
The world point will be <x*depth, y*depth, depth*-1*nearclipplane><br><br>See if it works . <br><br>Regards<br><font color="#888888">Darshan<br><br></font><div class="gmail_quote"><div><div></div><div class="h5">On Wed, Apr 7, 2010 at 4:37 AM, Rakesh Patil <span dir="ltr"><<a href="mailto:rakeshthp@in.com" target="_blank">rakeshthp@in.com</a>></span> wrote:<br>
</div></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div><div></div><div class="h5"> <br>Hi David,<br><br>That is exactly what i want.. But how can i get the points or lines which are traced..?? And also it should work without any actor..<br>
I mean this class works only for some actors. But i need for with actor and without actor..<br><br>Thanks<br><br>Regards<br><font color="#888888">Rakesh Patil<br></font><blockquote><div><br>---------- Original message ----------<br>
From:David Doria< <a href="mailto:daviddoria%2Bvtk@gmail.com" target="_blank">daviddoria+vtk@gmail.com</a> ><br>Date: 06 Apr 10 17:59:52<br>Subject: Re: [vtkusers] Drawing objects interactively in VTK..??<br>To: Rakesh Patil <br>
<br></div><div>On Tue, Apr 6, 2010 at 5:13 AM, Rakesh Patil wrote:<br>> Hello,<br>><br>> I am trying to draw a polyline interactively (with help of mouse). What i'm<br>> doing is at every left button down event, i get the mouse position and store<br>
> it is a vector list. Later using this points am displaying on the rendering<br>> window.<br>><br>> But when i do this, i noticed the following:<br>><br>>
The mouse position values are totally different from the the points which<br>> are displayed.. I mean, i click at one location, and it is displayed at far<br>> end another location..<br>><br>> I tried changing the coordinate system also.. Still the result is<br>
> unchanged..<br>><br>> Any suggestions how it is to be done..??<br>><br>> Thanks<br>> Rakesh Patil<br>><br><br></div><div>Sounds like you may need a coordinate system conversion in there<br>
somewhere, check out:<br><a href="http://vtk.org/Wiki/VTK/Examples/Coordinate" target="_blank">http://vtk.org/Wiki/VTK/Examples/Coordinate</a><br><br>It also sounds like you are trying to duplicate already working code in:<br>
<a href="http://vtk.org/Wiki/VTK/Examples/Widgets/ImageTracerWidget" target="_blank">http://vtk.org/Wiki/VTK/Examples/Widgets/ImageTracerWidget</a><br><br>Thanks,<br><br>David<br></div></blockquote> <br><div><div></div><div>
<br><div style="border-top: 1px dashed rgb(204, 204, 204); border-bottom: 1px dashed rgb(204, 204, 204); padding: 5px;"><a href="http://mail.in.com/mails/new_reg.php?utm_source=invite&utm_medium=outgoing" style="font: 13px arial; color: rgb(30, 86, 161);" target="_blank">Get Yourself a cool, short <b>@in.com</b> Email ID now!</a></div>
</div></div><br></div></div><div class="im">_______________________________________________<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>
<br></div></blockquote></div><br>
</blockquote></div><br>