Recent

Author Topic: TAChart: Reticule  (Read 15155 times)

wp

  • Hero Member
  • *****
  • Posts: 13221
TAChart: Reticule
« on: May 22, 2011, 12:53:53 am »
In the toolsdemo, it is demonstrated how to activate the reticule by pressing ctrl. But when the ctrl button is released the reticule is still frozen on the screen. How can I remove the reticule in the situation?

Werner

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: TAChart: Reticule
« Reply #1 on: May 22, 2011, 01:02:14 am »
Probably repainting the control.

Ask

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 687
Re: TAChart: Reticule
« Reply #2 on: May 22, 2011, 06:23:03 am »
No, to hide the reticule you should either set ReticulePos to out-of-range coordinates
(i.e. ReticulePos := Point(-1, -1))  or set ReticuleMode to rmNone.

The current paragigm is that reticule is a "permanent" marker, and the tool only moves it,
this is why reticule is not hidden automatically when the tool is deactivated.
I can add auto-hiding, but perhaps some users prefer current behavior?
What do you think?

wp

  • Hero Member
  • *****
  • Posts: 13221
Re: TAChart: Reticule
« Reply #3 on: May 22, 2011, 05:10:46 pm »
Thanks for the answer. Yes, autohiding is maybe too much. Maybe it would be enough to provide a public method such as "HideReticule".

I am showing the reticule when the user presses the CTRL key, just as in your demo. it would be great to have an event whenever the tool appears or disappears (OnBeforeToolAction, OnAfterToolAction), i.e. in my case, when the user presses CTRL - then I could call HideReticule from that. (As far as I can see, there are only mouse events).

Ask

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 687
Re: TAChart: Reticule
« Reply #4 on: June 09, 2011, 12:40:04 pm »
As a first step to resolving this issue, i have added KeyUp/KeyDown events to chart tools.
Using them, you can implement the reticule auto-hiding -- see tools demo as of r31142.

To move further, I have a few questions:
1) I think it would be good to add key-based activation/deactivation to most click-based tools,
  so for example, reticule and zooming would activate by pressing the designated key
  as well as mouse button. The question is, should this be always-on, or a tool option
  (KeyActivation), and if latter, what the default should be?
2) The problem with the above is that to receive key events, chart must have focus,
  which it usually does not. See AfterMouseMove event handler in the demo for an example
  workaround. I am not sure what to do with this issue in general case -- any suggestions?

Unrelated note: I plan to seriously change reticule implementation
to make work on Qt and MacOS, so unfortunately you may be hit by some incompatibilities
in the near future.

wp

  • Hero Member
  • *****
  • Posts: 13221
Re: TAChart: Reticule
« Reply #5 on: June 11, 2011, 12:03:18 am »
Quote
As a first step to resolving this issue, i have added KeyUp/KeyDown events to chart tools.
Very nice! Thanks a lot!

Quote
I think it would be good to add key-based activation/deactivation to most click-based tools ... The question is, should this be always-on, or a tool option
I've always been a friend of having a keyboard interface to a program. But maybe others are not. So, having a tool option would be a good compromise. On the other hand, the current implementation is fine as it is since the various options can be activated by the shift parameter already now, there is no need for an additional KeyActivation property.

Quote
to receive key events, chart must have focus
Delphi has a THotKey component which might circumvent his issue. I have never used it, though. Does Lazarus have that too?
But I think, in general I can live with the workaround in your demo.

Working with the new tools, a couple of new ideas came up:

- Appearence of the reticule could be improved if it were a cross of user-selectable size instead of going across the entire chart.

- It would be nice also to have a status variable that indicates that a tool is currently in use.

- Why don't you derive the ReticuleTool from TDataPointTool? This would give access to the Series and the PointIndex.

- Can you make the methode HideReticule of TChart public? It is private now. The meaning of a call to a such-labelled method would be clearer than calling "ReticulePos := TPoint(-1,-1)".

Thank you again for your great work.

Ask

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 687
Re: TAChart: Reticule
« Reply #6 on: June 11, 2011, 12:34:12 am »
Quote
On the other hand, the current implementation is fine as it is since the various options can be activated by the shift parameter already now, there is no need for an additional KeyActivation property.

There is a subtle problem: notice that in the demo, you can deactivate reticule by depressing "Ctrl",
but if you press "Ctrl", reticule does not appear -- you have to move the mouse at least a bit.
This is what I referred to -- I am not sure if it is important enough,
so will probably postpone it until some user reports it as a bug ;-)

Quote
Appearence of the reticule could be improved if it were a cross of user-selectable size instead of going across the entire chart.
Hm, others also requested diagonal cross, and I have seen "cross with target" variant.
Will think about it.

Quote
- It would be nice also to have a status variable that indicates that a tool is currently in use.
- Why don't you derive the ReticuleTool from TDataPointTool? This would give access to the Series and the PointIndex.

These are historical artifacts. Reticule was implemented before I started to maintain TAChart,
and the current implementation is an awkward compromise between backwards compatibility
and the new tools design.
You have correctly noted some of the problems, and I can add more:
- reticule does not work on Qt and MacOS
- you can not control the color and width of reticule pen
- you can only have one reticule per chart

As I said, I plan to rewrite the tool, inheriting it from TDataPointTool,
but it will come at the cost of backwards compatibility.

Quote
Can you make the methode HideReticule of TChart public?
After the rewrite, it will be Reticule.Hide instead of Chart.HideReticule,
so I do not want to increase compatibility problem further.

Ask

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 687
Re: TAChart: Reticule
« Reply #7 on: August 13, 2011, 12:39:19 pm »
Quote
I plan to rewrite the tool, inheriting it from TDataPointTool,

Done in r31968-r31973.
See docs in http://wiki.lazarus.freepascal.org/TAChart_documentation#Drawing_mode and
http://wiki.lazarus.freepascal.org/TAChart_documentation#Data_point_crosshair_tool,
see example in "tools" demo.

I have now two questions about the fate of old TReticuleTool:
1) Should I remove it now or wait for another release?
2) Which name is better? If I remove old TReticuleTool, should I rename TDataPointCrosshair tool to TReticuleTool? The old name was invented by original TAChart developer, who is probably French. I actually like the name, but many users expressed confusion as to the meaning of the word "reticule".

wp

  • Hero Member
  • *****
  • Posts: 13221
Re: TAChart: Reticule
« Reply #8 on: August 13, 2011, 01:23:32 pm »
No problem with me if you remove the ReticuleTool after a grace period which I may need to adapt my projects.

I was not happy with the name Reticule, so CrossHairs is much clearer.

Ask

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 687
Re: TAChart: Reticule
« Reply #9 on: August 13, 2011, 01:38:28 pm »
Ok, then please report your results when you attempt a migration.

wp

  • Hero Member
  • *****
  • Posts: 13221
Re: TAChart: Reticule
« Reply #10 on: August 20, 2011, 08:59:30 pm »
Yes, the DatapointCrossHairTools is much better than the old Reticule. Thank you.

I think the TChart.ReticuleMode is obsolete now also, since the new tool has a similar property. But what about the OnDrawReticule event? I am using this event to draw info in the statusbar concerning the datapoint under the crosshairs, however, I did not find something like that for the DatapointCrossHairTool.

Except for this, the conversion from "reticule" to "crosshair" is straightforward.

Ask

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 687
Re: TAChart: Reticule
« Reply #11 on: August 20, 2011, 09:11:55 pm »
Quote
But what about the OnDrawReticule event?

You can use OnDraw event of the tool, see "tools" demo.

wp

  • Hero Member
  • *****
  • Posts: 13221
Re: TAChart: Reticule
« Reply #12 on: August 20, 2011, 09:35:37 pm »
Quote
You can use OnDraw event of the tool, see "tools" demo.

I know, but it does not pass the parameters that OnDrawReticule did.

Ask

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 687
Re: TAChart: Reticule
« Reply #13 on: August 21, 2011, 03:11:33 am »
You can access Series and PointIndex properties of ASender parameter.
Since r32023 I have also added Chart and NearestGraphPoint properties.

 

TinyPortal © 2005-2018