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_plot3d
Class: TPlot3D
Declaration: OnDataRendered: TRenderEvent;
{ TRenderEvent = procedure (Sender: TObject; Canvas: TCanvas) of object; }

The events OnDataRendered and OnBeforeRenderPolygon  provide a hook for adding user defined graphics to a 3D surface plot. The event OnDataRendered occurs after the surface has been drawn. 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.

Hint1 : 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: 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: Following is an example on how to implement user defined graphics on top of the Plot3D data. It displays the text HALLO in the middle of the 3D surface. Please note the use of the procedure SetCanvasFontSizeScaled for setting the size of the font in order to avoid any nasty size effects due to different screen and printer resolutions.

procedure TForm1.Plot3D1DataRendered(Sender: TObject; Canvas: TCanvas);

begin
Canvas.Brush.Style := bsClear;
Canvas.Font.Color := clRed;
SetCanvasFontSizeScaled (Canvas, 14);
Canvas.TextOut(Plot3D1.CentX, Plot3D1.CentY, 'HALLO');
end;

Example: This event is used in the following example programs (see http://www.lohninger.com/examples.html for downloading the code): interpol3d, plotit3d



Last Update: 2023-Dec-13