TeeChart cursor pos to chart pos (CalcPosPoint equivalent)

TeeTree VCL for Borland Delphi and C++ Builder.
Post Reply
runfastman
Newbie
Newbie
Posts: 5
Joined: Fri Aug 29, 2008 12:00 am

TeeChart cursor pos to chart pos (CalcPosPoint equivalent)

Post by runfastman » Thu Oct 14, 2010 3:05 pm

I am trying to see if my cursor is in a certain position inside of a TTreeNodeShape or on the Tree.
I see how to do it with a TChart (CacPosPoint in the help doc, "Custom drawing on the Chart"), is there an equivalent for TTree.

I can do it just fine, if the chart is not zoomed, but as soon as I zoom, I can't figure out the math to get me the correct chart coordinate with zoom level and scroll bar position.

Yeray
Site Admin
Site Admin
Posts: 8738
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: TeeChart cursor pos to chart pos (CalcPosPoint equivalent)

Post by Yeray » Mon Oct 18, 2010 10:40 am

Hi,

I'd do it with the Clicked method. Have you tried it?
The following works fine for me here:

Code: Select all

procedure TForm1.Tree1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
  if TreeNodeShape1.Clicked(X,Y) then Caption:='over the shape'
  else Caption:='';
end;
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

runfastman
Newbie
Newbie
Posts: 5
Joined: Fri Aug 29, 2008 12:00 am

Re: TeeChart cursor pos to chart pos (CalcPosPoint equivalent)

Post by runfastman » Mon Oct 18, 2010 1:58 pm

Yes, I do this, but I need to know if the mouse is in a certain spot in the shape.
Example : If mouse is over top half or shape then Caption := 'Top Section' else if in bottom half then Caption := 'Bottom Section'

node := tttGraphic.ClickedShape(x, y);
realY := tttGraphic.HorzScrollBar.Position;

if (realY > (node.Top + (node.Height div2))) and
(realY < node.Top) then
begin
tttGraphic.Hint := 'Top Section'
end
else if (realY < (node.Top + (node.Height div2))) and
(realY > (node.Top+node.Height)) then
begin
tttGraphic.Hint := 'Bottom Section'
end;

This works fine with a 100% zoom, but as soon as I change the zoom it will no longer work. I tried multiplying x,y by the zoom %, but that didn't work. I need to translate the mouse X,Y position to the Graphic position.

Thanks,

Steve

runfastman
Newbie
Newbie
Posts: 5
Joined: Fri Aug 29, 2008 12:00 am

Re: TeeChart cursor pos to chart pos (CalcPosPoint equivalent)

Post by runfastman » Mon Oct 18, 2010 3:55 pm

Never mind, I found it.

tttGraphic.Canvas.Calculate2DPosition(realX, realY, 0);

Yeray
Site Admin
Site Admin
Posts: 8738
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: TeeChart cursor pos to chart pos (CalcPosPoint equivalent)

Post by Yeray » Mon Oct 18, 2010 5:12 pm

Hi,

I'm glad to see you've found it!
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply