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....


Unit: SDL_rchart
Class: TSmithChart
Declaration: OnDataRendered: TRenderEvent;
{ TRenderEvent = procedure (Sender: TObject; canvas: TCanvas; Top, Left: integer) of object; }

The events OnBeforeRenderData, OnDataRendered and OnScalesRendered provide hooks for adding user defined graphics to a SmithChart. The event 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 1: The declaration of this event has been changed with the introduction of release 10.1 of the SDL Suite. Please see the corresponding type declaration and the section How to Deal with a Canvas Reference Change for details.

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

Hint 3: Please note that drawing graphic elements in the OnDataRendered event does not create an entry in the data container. Thus you are at your own as far as the management of these drawing elements is concerned.

Hint 4: 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);

Example 1: Following is an example on how to implement user defined graphics on top of the SmithChart 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 [0.4, 0.8]. 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.SmithChart1DataRendered (Sender: TObject;
                        Canvas: TCanvas; Top, Left: integer);

  xout,yout: longint;

canvas.Font.Color := clBlue;
Canvas.TextOut (120,120,'HALLO');
SmithChart1.R2M (0.4, 0.8, xout,yout);
Canvas.TextOut (xout-Left, yout-Top,'HALLO');

Example 2: This event is used in the following example program (see for downloading the code): schart

Last Update: 2017-Okt-16