<div dir="ltr"><div>If you've added one plot to the chart, you can get the list of selected indices with:</div><div><br></div><div>vtkIdTypeArray *idarray = chart->GetPlot(0)->GetSelection();</div><div><br></div><div>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.</div><div><br></div><div>Jeff</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr">On Fri, Apr 22, 2016 at 10:37 AM Richard Brown <<a href="mailto:richard.j.brown@live.co.uk">richard.j.brown@live.co.uk</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">I just advanced from where I was and I know have:<br><div><br></div><div>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#808000">void </span>pointSelected(<span style="color:#800080">vtkObject</span>*<span style="color:#c0c0c0"> </span>obj,<span style="color:#c0c0c0"> </span><span style="color:#808000">unsigned</span><span style="color:#c0c0c0"> </span><span style="color:#808000">long</span>,<span style="color:#808000">void</span>*,<span style="color:#c0c0c0"> </span><span style="color:#808000">void</span>*)</pre>
<pre style="margin-top:0px;margin-bottom:0px">{</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span><span style="color:#800080">std</span>::cout<span style="color:#c0c0c0"> </span><<<span style="color:#c0c0c0"> </span><span style="color:#008000">"\nPoint</span><span style="color:#c0c0c0"> </span><span style="color:#008000">selected.\n"</span>;</pre>
<pre style="margin-top:0px;margin-bottom:0px"><br></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span><span style="color:#008000">//</span><span style="color:#c0c0c0"> </span><span style="color:#008000">Print</span><span style="color:#c0c0c0"> </span><span style="color:#008000">info</span><span style="color:#c0c0c0"> </span><span style="color:#008000">of</span><span style="color:#c0c0c0"> </span><span style="color:#008000">selected</span><span style="color:#c0c0c0"> </span><span style="color:#008000">point</span></pre>
<pre style="margin-top:0px;margin-bottom:0px">}</pre><div><br></div></div><div>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#808000">int</span><span style="color:#c0c0c0"> </span>main()</pre>
<pre style="margin-top:0px;margin-bottom:0px">{</pre></div><div>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#800000"> chart</span>-><span style="font-style:italic">SetActionToButton</span>(<span style="color:#800080">vtkChartXY</span>::<span style="color:#800080">SELECT</span>,<span style="color:#c0c0c0"> </span><span style="color:#800080">vtkContextMouseEvent</span>::<span style="color:#800080">LEFT_BUTTON</span>);</pre>
<pre style="margin-top:0px;margin-bottom:0px"><br></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#800080"> vtkSmartPointer</span><<span style="color:#800080">vtkCallbackCommand</span>><span style="color:#c0c0c0"> </span>keypressCallback<span style="color:#c0c0c0"> </span>=<span style="color:#c0c0c0"> </span><span style="color:#800080">vtkSmartPointer</span><<span style="color:#800080">vtkCallbackCommand</span>>::New();</pre>
<pre style="margin-top:0px;margin-bottom:0px"> keypressCallback-><span style="font-style:italic">SetCallback</span><span style="color:#c0c0c0"> </span>(<span style="color:#c0c0c0"> </span>pointSelected<span style="color:#c0c0c0"> </span>);</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#800000"> chart</span>->AddObserver(<span style="color:#800080">vtkContextMouseEvent</span>::<span style="color:#800080">LEFT_BUTTON</span>,<span style="color:#c0c0c0"> </span>keypressCallback);</pre><pre style="margin-top:0px;margin-bottom:0px"><pre style="margin-top:0px;margin-bottom:0px">}</pre><div><br></div></pre></div><div>And this works as expected; every time I left-click on a point, I cout “Point selected”.</div><div><br></div><div>My initial question is still stands: how do I get information on the selected point?</div><div><br></div><div>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? </div><div><br></div><div>Regards,</div><div>Richard</div></div><div style="word-wrap:break-word"><div><br><div><div><blockquote type="cite"><div>On 22 Apr 2016, at 16:05, Richard Brown <<a href="mailto:richard.j.brown@live.co.uk" target="_blank">richard.j.brown@live.co.uk</a>> wrote:</div><br><div><div style="word-wrap:break-word">Hi Jeff,<div><br></div><div>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?</div><div><br></div><div>SetButtonToAction(vtkChartXY::SELECT, vtkContextMouseEvent::LEFT_MOUSE);</div><div><br></div><div>Do I then set up an observer for vtkChartXY::SELECT?</div><div><br></div><div>And from there, when I’m in the callback function, how do I get the information of the selected point?</div><div><br></div><div>Thanks in advance,</div><div>Richard</div><div><br></div><div><br><div><blockquote type="cite"><div>On 18 Apr 2016, at 13:54, Jeff Baumes <<a href="mailto:jeff.baumes@kitware.com" target="_blank">jeff.baumes@kitware.com</a>> wrote:</div><br><div><div dir="ltr">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.<div><br></div><div><a href="http://www.vtk.org/doc/nightly/html/classvtkChart.html#ac4162187f5f3ad97f0163a079e06f13d" target="_blank">http://www.vtk.org/doc/nightly/html/classvtkChart.html#ac4162187f5f3ad97f0163a079e06f13d</a></div></div><br><div class="gmail_quote"><div dir="ltr">On Fri, Apr 15, 2016 at 9:13 AM mbcx9rb9 <<a href="mailto:richard.j.brown@live.co.uk" target="_blank">richard.j.brown@live.co.uk</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi all,<br>
<br>
I'd like to create a custom interactor for vtkChartXY (inherited from<br>
vtkContextInteractorStyle), but I can't figure out how to select single<br>
points with the left click of the mouse. Once I manage to that, I would need<br>
to return the index of the selected point.<br>
<br>
This seems very straightforward to me, but I haven't seen any concrete<br>
examples.<br>
<br>
Any pointers would be greatly appreciated.<br>
<br>
Regards,<br>
Richard<br>
<br>
<br>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://vtk.1045678.n5.nabble.com/vtkChartXY-picking-tp5737711.html" rel="noreferrer" target="_blank">http://vtk.1045678.n5.nabble.com/vtkChartXY-picking-tp5737711.html</a><br>
Sent from the VTK - Users mailing list archive at <a href="http://nabble.com/" target="_blank">Nabble.com</a>.<br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com/" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" 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" rel="noreferrer" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Search the list archives at: <a href="http://markmail.org/search/?q=vtkusers" rel="noreferrer" target="_blank">http://markmail.org/search/?q=vtkusers</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/vtkusers" rel="noreferrer" target="_blank">http://public.kitware.com/mailman/listinfo/vtkusers</a><br>
</blockquote></div>
</div></blockquote></div><br></div></div>_______________________________________________<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>Search the list archives at: <a href="http://markmail.org/search/?q=vtkusers" target="_blank">http://markmail.org/search/?q=vtkusers</a><br><br>Follow this link to subscribe/unsubscribe:<br><a href="http://public.kitware.com/mailman/listinfo/vtkusers" target="_blank">http://public.kitware.com/mailman/listinfo/vtkusers</a><br></div></blockquote></div><br></div></div></div></blockquote></div>