Page 1 of 1

Axis captions in OpenGL

Posted: Tue Aug 28, 2012 9:07 am
by 9339158
Hi

I have been making a 3D OpenGL plot. The axis caption titles for the Depth and Right Axes are not plotted in the correct position (I believe this is a know bug). Hence I am trying to custom draw these titles using an after draw. The problem is I cannot figure out how to accurately find the position of the axes on the plot. Currently I am using for the Depth axis caption :

Code: Select all

procedure TCapPressFuncXplot.Draw3DAxisLabels;
Var
   fTchart : TChart;
   fCanvas : TCanvas3D;
   x, y, z : Integer;
begin
   fTchart := XplotChartFrm.Chart1;
   fCanvas := fTchart.Canvas;
   fCanvas.Font.Size := fTchart.DepthAxis.Title.Font.Size;
   fCanvas.Font.Color := fTchart.DepthAxis.Title.Font.Color;
   x := fTchart.ChartWidth - fTchart.MarginLeft;
   y := fTchart.ChartHeight - fTchart.MarginTop;
   Z := fTchart.Width3D div 2;
   fCanvas.TextOut3D(X,Y,Z,fTchart.DepthAxis.Title.Caption);
end;
This puts the Caption in the right place for the Depth Axis but the X position is too far to the right and the Y position is too high.
What is the correct method for calculating the X and Y values (should be bottom right corner of plot) for use in the routine TextOut3D.

Thanks Frank

Re: Axis captions in OpenGL

Posted: Wed Aug 29, 2012 1:33 pm
by yeray
Hi Frank,

You should use positions relative to the axes position. Ie, this seems to work fine for me here:

Code: Select all

procedure TForm1.Chart1AfterDraw(Sender: TObject);
var x, y, z: Integer;
begin
  x:=Chart1.Axes.Bottom.IEndPos + 20;
  y:=Chart1.Axes.Bottom.PosAxis;
  z:=Chart1.Axes.Depth.IAxisSize div 2;

  Chart1.Canvas.TextOut3D(x, y, z, 'my text');
end;