Recent

Author Topic: DatapointCrosshairTool issues for two charts sharing the same ChartToolset  (Read 9570 times)

wp

  • Hero Member
  • *****
  • Posts: 6471
The attached little demo project contains two charts that share the same ChartToolset. The ChartToolset contains a ZoomDragTool activated by the left mouse button and a DatapointCrosshairTool activated by the right mouse button. While the ZoomDragTools works as expected there is an issue with the DatapointCrosshairTool:

- Run the project
- Right-drag in the left chart --> the crosshair appears
- Note that the crosshairs do not disappear at mouse-up although this behavior is implemented in the corresponding event.
- Now right-drag the mouse in the right chart --> no cross-hairs
- Left-drag in the right chart to zoom, and immediately afterwards left-click to unzoom
- Right-drag in the right chart --> now the cross-hair appears
- Again, the crosshairs does not disappear upon mouse-up.
- The same happens if you right-drag in the left chart again.

It should be mentioned also that the crosshairs seem to work only with TLineSeries, not with TFuncSeries that I used in this demo initially.
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

madepabloh

  • Full Member
  • ***
  • Posts: 158
Nice idea wp,

However i can not compile it. It returns this error:
Quote
unit1.pas(21,66) Error: Identifier not found "TDataPointCrosshairTool"

is it my problem or other people had similar problem?

Thanks!

wp

  • Hero Member
  • *****
  • Posts: 6471
The DatapointCrosshairTool has been added by ask to the package only recently, you need to use the current svn version.
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

madepabloh

  • Full Member
  • ***
  • Posts: 158
Where could i locate it? I do not see that information anywhere... thanks!

Ask

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 687

Ask

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 687
- Note that the crosshairs do not disappear at mouse-up although this behavior is implemented in the corresponding event.

Fixed in r32024

- Now right-drag the mouse in the right chart --> no cross-hairs
- Left-drag in the right chart to zoom, and immediately afterwards left-click to unzoom
- Right-drag in the right chart --> now the cross-hair appears
The problem is that the tool only stores a single local state (in this case, Position),
but it should generally store a separate state for each chart it is used on.
I actually plan to implement this, but do not have time right now.
Added workaround in r32025 which fixes the issues you mentioned.
(But does not fix some other problems -- for example, if you minimize the application
while holding right mouse button, then restore it, crosshair will be drawn on both charts).
Hopefully the workaround will suffice until the full solution arrives.

It should be mentioned also that the crosshairs seem to work only with TLineSeries, not with TFuncSeries that I used in this demo initially.
This is because finding nearest point of the function graph requires full recalculation of the function,
which I avoided on performance grounds.
In r32026 I have added a compromise solution -- it just takes the point with the same X as the cursor,
and declares it the nearest one.
What do you think -- is it enough?

wp

  • Hero Member
  • *****
  • Posts: 6471
Quote
I actually plan to implement this, but do not have time right now.
Don't hurry...

Quote
It just takes the point with the same X as the cursor,
and declares it the nearest one.
Maybe you should scan at least the step interval.
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

wp

  • Hero Member
  • *****
  • Posts: 6471
Mouse-up is now handled correctly. Also changing from one chart to the other works much better now.
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

Ask

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 687
Quote
It just takes the point with the same X as the cursor,
and declares it the nearest one.
Maybe you should scan at least the step interval.

Since r32075 points inside GrabRaduis are considered.

wp

  • Hero Member
  • *****
  • Posts: 6471
I've got to bring up this old thread again, since the issue mentioned in the beginning occurs similarly for the new ZoomMouseWheelTool: Zooming by means of the mouse wheel works only in one of the two charts. Only when the second chart is zoomed by means of an additional ZoomDragTool zooming by mouse wheel works in this chart, however, no longer in the first chart. I tried to SetFocus in the OnBeforeMouseWheel events, but this event is not triggered for the other chart.

The same holds for the PanDragTool.

See the attached demo.
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

Ask

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 687
Re: DatapointCrosshairTool issues for two charts sharing the same ChartToolset
« Reply #10 on: October 16, 2011, 09:09:45 am »
Should be fixed in r32917

wp

  • Hero Member
  • *****
  • Posts: 6471
Re: DatapointCrosshairTool issues for two charts sharing the same ChartToolset
« Reply #11 on: October 16, 2011, 10:21:39 am »
Thank you. Perfect!
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10