The SDL Component Suite is an industry leading collection of components supporting scientific and engineering computing. Please visit the SDL Web site for more information....



OnDataRendered


Unit:SDL_polchart
Class: TPolChart
Declaration: OnDataRendered: TpcRenderEvent;
{ TpcRenderEvent = procedure (Sender: TObject; var canvas: TCanvas; Top, Left: integer) of object; }

The events OnDataRendered and OnBeforeDrawScaleLabel  provide a hook for adding user defined graphics to a TPolChart. Internally, a chart is constructed in three phases before the result is copied to the screen: in the first phase the scales are drawn, then the data are drawn and finally the crosshairs are rendered.

The event OnDataRendered occurs after the chart has been drawn and before the crosshairs are inserted and the chart is copied to the screen. The variable parameter Canvas provides access to the canvas of the data area. Please note that the state of the canvas (e.g. the color of its pen, or the fill mode of the brush) depends on the graphics elements drawn before. The parameters Top and Left contain the offset of the data area relative to the entire chart area. You need these two values if you want to position your own drawing elements relative to the real-world coordinate system (by using the method R2M).

Hint: Graphic elements outside the data window are cut automatically

Example: Following is an example on how to implement user defined graphics on top of the PolChart data. It displays the text HALLO twice, one text is positioned at absolute coordinates (120,120), the other text is drawn relative to the world-coordinates at position [20.0, 1.0]. Note that the method R2M returns coordinates relative to the chart window (and not relative to the data area); you have therefore subtract Top and Left before positioning the graphics.

procedure TForm2.PolChart1DataRendered (Sender: TObject;
                         var Canvas: TCanvas; Top, Left: integer);

var
  xout,yout: longint;

begin
canvas.Font.Color := clBlue;
Canvas.TextOut (120,120,'HALLO');
PolChart1.R2M (20.0, 1.0, xout,yout);
Canvas.TextOut (xout-Left, yout-Top,'HALLO');
end;



Last Update: 2008-Okt-29