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_rchart
Class: TContourPlot
Declaration: property OnDataRendered: TRenderEvent;
{ TRenderEvent = procedure (Sender: TObject; canvas: TCanvas; Top, Left: integer) of object; }

The event OnDataRendered provides a hook for adding user defined graphics to a contour plot. The event occurs after the plot has been drawn and before the crosshairs are inserted and the plot is copied to the screen. The variable parameter Canvas provides access to the canvas of the plot 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 plot area relative to the entire plot area. You need these two values if you want to position your own drawing elements relative to the coordinate system of the plot (by using the method R2M).

Hint 1: Graphic elements outside the data window are cut automatically

Hint 2: In order to avoid unwanted size effects regarding characters displayed on canvases of different resolution (i.e. the screen and a printer) you should never directly assign the font size within the event. Use SetCanvasFontSizeScaled instead. So, for example, the statement Canvas.Font.Size := 12; should be replaced by SetCanvasFontSizeScaled (Canvas, 12);

Hint 3: You can use the property InvalidDataBmp in order to decide whether the contour plot has been actually reconstructed before the OnDataRendered event has been triggered.

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

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

var
  xout,yout: longint;

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



Last Update: 2016-Aug-15