Well, I figured out my problem. When wanting to convert between mouse/viewport X/Y coordinates you need to do the following:<br><br>vtkRenderWindowInteractor* iren = vtkRenderWindowInteractor::SafeDownCast(obj);<br><div>
int event_pos[2];<br>
iren->GetEventPosition(event_pos); //generates X/Y coordinates based on viewport where 0,0 is bottom left of window<br>
plot->SetViewportCoordinate(event_pos[0], event_pos[1]); //sets the coordinates you want converted<br>
plot->ViewportToPlotCoordinate(renderer); //converts the coordinates into plot coordinates<br></div> double pos2[3];<br>
plot->GetViewPortCoordinate(pos2); //retrieves the newly created plot coordinates.<br><br><br>My new problem is the following:<br>When I have few x-axis data points (ie: 1-1000), the accuracy of the coordinate conversion is very good, however when the number of data points grows to 300000 or more, the accuracy is horrible. Also, if I resize the window, the accuracy is bad. Any ideas? Or is this normal?<br>
<br>Thanks,<br><br>Justin<br><br><br><br><div class="gmail_quote">On Fri, Feb 27, 2009 at 1:16 PM, Justin Giles <span dir="ltr"><<a href="mailto:jtgiles@gmail.com">jtgiles@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Thanks for the link, but I can't seem to get vtkPointPicker to work the the 2D XYPlotActor data correctly. I feel that I'm missing something dealing with the mapping of my polydata set to the viewport coordinates correctly (or vice-versa).<br>
<br>My input data is of the following format:<br><br>x = 0-100 (integer values)<br>y = 0-1 (floating point values)<br><br>Those get placed into my polydata structure as points and scalars respectively. I then add this dataset to the XYPlotActor. I've played around with the polydatamapper2d, but I don't understand it very well evidently.<br>
<br>When I click the mouse over one of the points in my plot, I'm able to extract the viewport x,y coordinate of the mouse from the windowinteractor. Then, using vtkPropPicker I'm able to pull out the point that was clicked on and get the x,y,z coordinates of the point picked by using picker->GetPickedPosition(). That gives me +- values between -1 and 1. What I am missing is how to map those values to find the point ids in my polydataset.<br>
<br>Any further thoughts? Do I need to add a mapper? Do I need to play with vtkCoordinate on the dataset? I'm basically at a loss...<br><br>Thanks,<br><font color="#888888"><br>Justin</font><div><div></div><div class="Wj3C7c">
<br><br><div class="gmail_quote">On Thu, Feb 26, 2009 at 4:23 PM, Shakes <span dir="ltr"><<a href="mailto:Shekhar.Chandra@sci.monash.edu.au" target="_blank">Shekhar.Chandra@sci.monash.edu.au</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi Justin,<br>
<br>
This link might help, not for XY Plot class but for picking values from the renderer by Mark Wyszomierski.<br>
<br>
<<a href="http://devsample.org/index.php?option=com_content&task=view&id=48&Itemid=27" target="_blank">http://devsample.org/index.php?option=com_content&task=view&id=48&Itemid=27</a>><br>
<br>
Its got iren->GetEventPosition(event_pos) stuff, uses the Picker class. Let me know how u go.... I will probably need to do this later. ;)<br>
<br>
HTH<br>
Cheers<br>
Shakes<br>
<br>
Justin Giles wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><div></div><div>
Can anyone tell me how ViewportToPlotCoordinate is supposed to work? No matter what I do I keep getting X = -25.8051 and Y = -0.167051.<br>
<br>
What I do when the mouse is clicked is the following:<br>
(plot is my vtkXYPlotActor object, renderer is my vtkRenderer object)<br>
-----------------------<br>
vtkRenderWindowInteractor* iren = vtkRenderWindowInteractor::SafeDownCast(obj);<br>
int event_pos[2];<br>
iren->GetEventPosition(event_pos); //generates X/Y coordinates based on viewport where 0,0 is bottom left of window<br>
plot->SetViewportCoordinate(event_pos[0], event_pos[1]);<br>
double pos2[3];<br>
plot->ViewportToPlotCoordinate(renderer, pos2[0], pos2[1]);<br>
<br>
//cout always shows -25.8051 and -0.167051<br>
cout << pos2[0] << " : " << pos2[1] << endl;<br>
-------------------------------<br>
<br>
Any thoughts on this? Am I doing something wrong? My assumption on how this should work is that I would get coordinates based on the X/Y axis of the actual 2D plot.<br>
<br>
I've been stuck on this for quite a few days, so any help would be appreciated.<br>
<br>
Thanks,<br>
<br>
Justin<br>
<br>
<br></div></div>
------------------------------------------------------------------------<br>
<br>
_______________________________________________<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>
</blockquote></div><br>
</div></div></blockquote></div><br>