Page 1 of 1

TPoint3DSeries - mouse move and click problems

Posted: Thu Oct 25, 2007 2:55 pm
by 10546991
I'm creating a TPoint3DSeries, aPS, on the fly and putting it along with a TSurfaceSeries, aSS, on a chart as follows:

aPS := TPoint3DSeries.Create(nil);
aPS.LinePen.Visible := false;
aPS.ParentChart := aChart;
aPS.Pointer.Draw3D := true;
aPS.DepthSize := 1;
aPS.OnGetMarkText := Self.GetMarkText;
aPS.OnMouseEnter := Self.SeriesMouseEnter;
aPS.OnMouseLeave := Self.SeriesMouseLeave;
aPS.OnClickPointer := Self.SeriesClickPointer;

Both series display fine, but:

1) I only get OnMouseEnter/OnMouseLeave messages reliably when I have set both aChart.Elevation and aChart.Rotation to 360 (i.e., the chart is "edge on")

2) I cannot get my OnClickPointer handler to fire at all (I have put a breakpoint in there, but it never gets hit when I click on a series point).

Can you advise? Thanks! Jim.

Posted: Fri Oct 26, 2007 10:17 am
by narcis
Hi Jim,

This happens when Chart1.Aspect.Orthogonal:=false; and the difficulty to convert from 2D screen coordinates to 3D chart coordinates. This is a known issue and is very difficult to solve as neither GDI nor GDI+ provide methods for such conversions.

Posted: Fri Oct 26, 2007 11:19 am
by 10546991
narcis wrote:Hi Jim,

This happens when Chart1.Aspect.Orthogonal:=false; and the difficulty to convert from 2D screen coordinates to 3D chart coordinates. This is a known issue and is very difficult to solve as neither GDI nor GDI+ provide methods for such conversions.
Understood, in general, but you do the geometric calculations to translate from points to screen coordinates when you plot the chart, so there must surely be a way (however slow) to do the inverse operation.

Still doesn't fire

Posted: Fri Oct 26, 2007 11:52 am
by 10546991
narcis wrote:Hi Jim,

This happens when Chart1.Aspect.Orthogonal:=false; and the difficulty to convert from 2D screen coordinates to 3D chart coordinates. This is a known issue and is very difficult to solve as neither GDI nor GDI+ provide methods for such conversions.
I tried both
chtAC.Aspect.Orthogonal := true;
and
chtAC.View3DOptions.Orthogonal := true;
but I could not get OnClickPointer for my TPoint3DSeries to fire when I clicked on points on the chart.

Is there something else I need to do?

Posted: Fri Oct 26, 2007 2:24 pm
by narcis
Hi Jim,

It works fine for me here dropping a TChart in a form with a TSurfaceSeries and a TPoint3DSeries and this code:

Code: Select all

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, TeePoin3, TeEngine, TeeSurfa, ExtCtrls, TeeProcs, Chart,
  TeeComma;

type
  TForm1 = class(TForm)
    Chart1: TChart;
    Series1: TSurfaceSeries;
    Series2: TPoint3DSeries;
    TeeCommander1: TTeeCommander;
    procedure FormCreate(Sender: TObject);
    procedure Series2ClickPointer(Sender: TPoint3DSeries; ValueIndex, X,
      Y: Integer);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
var x,z: Integer;
    y: Double;
begin
  for x:=0 to 10 do
  begin
    for z:=0 to 10 do
    begin
      y:=random;
      Series1.AddXYZ(x,y,z);
      Series2.AddXYZ(x,y,z);
    end;
  end;
end;

procedure TForm1.Series2ClickPointer(Sender: TPoint3DSeries; ValueIndex, X,
  Y: Integer);
begin
  Chart1.Title.Text[0]:='Point clicked: ' + IntToStr(ValueIndex);
end;

end.

Following up

Posted: Fri Oct 26, 2007 6:40 pm
by 10546991
I did it at runtime, like this:

Code: Select all

   aChart.Aspect.Orthogonal := true;

   aSS := TSurfaceSeries.Create(nil);
   aSS.Pen.Visible := false;
   aSS.ParentChart := aChart;

   aPS := TPoint3DSeries.Create(nil);
   aPS.LinePen.Visible := false;
   aPS.ParentChart := aChart;
   aPS.Pointer.Draw3D := true;
   aPS.DepthSize := 1;
   aPS.OnGetMarkText := Self.GetMarkText;
   aPS.OnClickPointer := Self.SeriesClickPointer;
but a breakpoint inside SeriesClickPointer never gets called.

Posted: Tue Oct 30, 2007 9:50 am
by narcis
Hi Jim,

Could you please try with a new example project like I suggested in my previous reply?

Thanks in advance!