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


Class: TPlot3D
Declaration: OnBeforeRenderPolygon: TBeforeRenderPolygonEvent;
{ TBeforeRenderPolygonEvent = procedure (Sender: TObject; Canvas: TCanvas; var Handled: boolean; CellX, CellY: integer; quad: TQuad; var color: TColor) of object; }

The events OnDataRendered and OnBeforeRenderPolygon provide a hook for adding user defined graphics to a Plot3D. While the event OndataRendered can be used to draw special graphics or text on top of the 3D surface, the event OnBeforeRenderPolygon is triggered immediately before a quadrilateral of the surface is going to be rendered.

The parameter Canvas provides access to the canvas of the surface plot. The variable parameter Handled determines whether the component actually draws the quadrilateral after returning from OnBeforeRenderPolygon. If the parameter Handled is TRUE the component assumes that the drawing has already been done in the event handler, if Handled is set to FALSE the component draws the quadrilateral using the color specified in the parameter color. Handled is, by default, FALSE. The parameters CellX and CellY specify the indices of the matrix cell to be represented by the quadrilateral. The parameter quad specifies the position of the quadrilateral (four corners in pixel coordinates).

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.

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: You should be aware of the fact that each quadrilateral is spanned by four cells of the matrix GridMat. The parameters CellX and CellY therefore may vary only from 1 to NrOfRows-1, or NrOfColumns-1, since these parameters always indicate the indices corresponding to the lower boundary of the quadrilateral.

Hint 3: 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 draw the cells corresponding to the second column of the matrix GridMat with a fixed color:

procedure TForm1.Plot3D1BeforeRenderPolygon(Sender: TObject;
  Canvas: TCanvas; var Handled: Boolean; CellX, CellY: Integer;
  quad: TQuad; var color: TColor);

if (CellX = 2) then
  color := clBlue;

Example: This event is used in the following example programs (see for downloading the code): interpol3d, plot3dhole, plotit3d

Last Update: 2012-Okt-26