[vtkusers] vtkXYPlotActor
Justin Giles
jtgiles at gmail.com
Fri Feb 27 14:16:03 EST 2009
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).
My input data is of the following format:
x = 0-100 (integer values)
y = 0-1 (floating point values)
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.
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.
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...
Thanks,
Justin
On Thu, Feb 26, 2009 at 4:23 PM, Shakes
<Shekhar.Chandra at sci.monash.edu.au>wrote:
> Hi Justin,
>
> This link might help, not for XY Plot class but for picking values from the
> renderer by Mark Wyszomierski.
>
> <
> http://devsample.org/index.php?option=com_content&task=view&id=48&Itemid=27
> >
>
> 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. ;)
>
> HTH
> Cheers
> Shakes
>
> Justin Giles wrote:
>
>> 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.
>>
>> What I do when the mouse is clicked is the following:
>> (plot is my vtkXYPlotActor object, renderer is my vtkRenderer object)
>> -----------------------
>> vtkRenderWindowInteractor* iren =
>> vtkRenderWindowInteractor::SafeDownCast(obj);
>> int event_pos[2];
>> iren->GetEventPosition(event_pos); //generates X/Y coordinates based on
>> viewport where 0,0 is bottom left of window
>> plot->SetViewportCoordinate(event_pos[0], event_pos[1]);
>> double pos2[3];
>> plot->ViewportToPlotCoordinate(renderer, pos2[0], pos2[1]);
>>
>> //cout always shows -25.8051 and -0.167051
>> cout << pos2[0] << " : " << pos2[1] << endl;
>> -------------------------------
>>
>> 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.
>>
>> I've been stuck on this for quite a few days, so any help would be
>> appreciated.
>>
>> Thanks,
>>
>> Justin
>>
>>
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Please keep messages on-topic and check the VTK FAQ at:
>> http://www.vtk.org/Wiki/VTK_FAQ
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.vtk.org/mailman/listinfo/vtkusers
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20090227/258203cc/attachment.htm>
More information about the vtkusers
mailing list