[vtkusers] vtkChartXY picking
Jeff Baumes
jeff.baumes at kitware.com
Mon Apr 25 07:57:03 EDT 2016
If you've added one plot to the chart, you can get the list of selected
indices with:
vtkIdTypeArray *idarray = chart->GetPlot(0)->GetSelection();
I am not sure the order of firing LEFT_BUTTON and updating the plot's
selection, hopefully the selection is available by the time that callback
is fired.
Jeff
On Fri, Apr 22, 2016 at 10:37 AM Richard Brown <richard.j.brown at live.co.uk>
wrote:
> I just advanced from where I was and I know have:
>
> void pointSelected(vtkObject* obj, unsigned long,void*, void*)
>
> {
>
> std::cout << "\nPoint selected.\n";
>
>
> // Print info of selected point
>
> }
>
>
> int main()
>
> {
>
> chart->SetActionToButton(vtkChartXY::SELECT, vtkContextMouseEvent::LEFT_BUTTON);
>
>
> vtkSmartPointer<vtkCallbackCommand> keypressCallback = vtkSmartPointer<vtkCallbackCommand>::New();
>
> keypressCallback->SetCallback ( pointSelected );
>
> chart->AddObserver(vtkContextMouseEvent::LEFT_BUTTON, keypressCallback);
>
> }
>
>
> And this works as expected; every time I left-click on a point, I cout
> “Point selected”.
>
> My initial question is still stands: how do I get information on the
> selected point?
>
> When plotting my points, they were part of a table. Could I get the table
> in question (there are multiple plots, so multiple tables), and then the
> index of the data point within the table?
>
> Regards,
> Richard
>
> On 22 Apr 2016, at 16:05, Richard Brown <richard.j.brown at live.co.uk>
> wrote:
>
> Hi Jeff,
>
> So if I want my left button to select the point underneath it (I think the
> right button by default creates a box and selects points within that box
> but then does nothing with them…) and then, for example, print the
> information pertaining to that point, how would I go about that?
>
> SetButtonToAction(vtkChartXY::SELECT, vtkContextMouseEvent::LEFT_MOUSE);
>
> Do I then set up an observer for vtkChartXY::SELECT?
>
> And from there, when I’m in the callback function, how do I get the
> information of the selected point?
>
> Thanks in advance,
> Richard
>
>
> On 18 Apr 2016, at 13:54, Jeff Baumes <jeff.baumes at kitware.com> wrote:
>
> I think you want SetActionToButton() on vtkChart to change mouse bindings.
> You should be able to listen for a selection event once that is set up.
>
>
> http://www.vtk.org/doc/nightly/html/classvtkChart.html#ac4162187f5f3ad97f0163a079e06f13d
>
> On Fri, Apr 15, 2016 at 9:13 AM mbcx9rb9 <richard.j.brown at live.co.uk>
> wrote:
>
>> Hi all,
>>
>> I'd like to create a custom interactor for vtkChartXY (inherited from
>> vtkContextInteractorStyle), but I can't figure out how to select single
>> points with the left click of the mouse. Once I manage to that, I would
>> need
>> to return the index of the selected point.
>>
>> This seems very straightforward to me, but I haven't seen any concrete
>> examples.
>>
>> Any pointers would be greatly appreciated.
>>
>> Regards,
>> Richard
>>
>>
>>
>>
>>
>> --
>> View this message in context:
>> http://vtk.1045678.n5.nabble.com/vtkChartXY-picking-tp5737711.html
>> Sent from the VTK - Users mailing list archive at Nabble.com
>> <http://nabble.com/>.
>> _______________________________________________
>> 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
>>
>> Search the list archives at: http://markmail.org/search/?q=vtkusers
>>
>> Follow this link to subscribe/unsubscribe:
>> http://public.kitware.com/mailman/listinfo/vtkusers
>>
>
> _______________________________________________
> 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
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20160425/12250f0f/attachment.html>
More information about the vtkusers
mailing list