Chapter 4:
Graph Imaging Functions
 

The graph imaging functions are the ones that perform the actual drawing of the chart.

 

DrawAnnotationLayer(); Draw annotation layer

 

DrawBackgroundLayer(); Draw background layer

 

DrawGraphLayer(); Draw Graph Layer

 

DrawTheGraph(); Draw the Graph

 

DryRunTheGraph(); Dry Run The Graph

 

IsGraphBackgroundVisible(); Is the graph background visible?

DrawAnnotationLayer()

 

This function draws the graph's annotation layer. The graph consists of these layers: background, annotation, and graph. This function draws the annotation layer. Use DrawBackgroundLayer() to draw the background layer and DrawGraphLayer() to draw the graph layer.

Syntax:

INT16 PUBLIC
DrawAnnotationLayer (
     DrawEnvPtr pDE,
     GraphPtr pGraph
);

Input:

pDE: Pointer to a draw environment created by AllocDrawEnvPtr()

 

pGraph: A graph pointer allocated by AllocGraphPtr()

Return:

INT16: 1

Example:

/* draw annotation layer */
if (wantAnnotation && !nError)
     nError = DrawAnnotationLayer(pDE,
          pGraph);

Also See:

DrawBackgroundLayer(), DrawGraphLayer()

DrawBackgroundLayer()

 

This function draws the graph's background layer. The graph consists of these layers: background, annotation, and graph. This function draws the background layer. Use DrawGraphLayer() to draw the graph layer and DrawAnnotationLayer() to draw the annotation layer.

Syntax:

INT16 PUBLIC
DrawBackgroundLayer (
     DrawEnvPtr pDE,
     GraphPtr pGraph
);

Input:

pDE: Pointer to a draw environment created by AllocDrawEnvPtr()

 

pGraph: A graph pointer allocated by AllocGraphPtr()

Return:

INT16:

 

E00_OK =

No Errors

 

E00_RANGE_ERROR =

Failure

Example:

if(pDE->nDrawProcs == DE_PROCS_ADVANCED_3D)
{
     // draw the background in regular 2D
     DESetDrawProcs(pDE, DE_PROCS_DEFAULT);
     nError = DrawBackgroundLayer(pDE,
          pGraph);
     DESetDrawProcs(pDE,
          DE_PROCS_ADVANCED_3D);
}

Also See:

DrawAnnotationLayer(), DrawGraphLayer()

   

DrawGraphLayer()

 

This function draws the graph's graph layer. The graph consists of these layers: background, annotation, and graph. This function draws the graph layer. Use DrawBackgroundLayer() to draw the background layer and DrawAnnotationLayer() to draw the annotation layer.

Syntax:

INT16 PUBLIC
DrawGraphLayer (
     DrawEnvPtr pDE,
     GraphPtr pGraph
);

Input:

pDE: Pointer to a draw environment created by AllocDrawEnvPtr()

 

pGraph: A graph pointer allocated by AllocGraphPtr()

Return:

INT16: 0=Successful, Any other value = error

Example:

/* draw the background layer */
if (wantBackground && !nError)
     nError = DrawBackgroundLayer(pDE,
          pGraph);
/* draw the graph layer */
if (wantGraph && !nError)
     nError = DrawGraphLayer(pDE,
          pGraph);
/* draw the annotation layer */
if (wantAnnotation && !nError)
     nError = DrawAnnotationLayer(pDE,
          pGraph);

Also See:

DrawAnnotationLayer(), DrawBackgroundLayer()

DrawTheGraph()

 

This function images the chart on the output device. The draw environment pointer (pDE) identifies the output device to image the chart and the graph pointer (pGraph) identifies the chart for imaging. The chart is imaged in three distinct layers, background, graph, and annotation. The three layers are described in the PGSDK Programmer's Manual. The INT16s identify which of the three layers is imaged. Any combination of the three layers can be imaged.

Syntax:

INT16
DrawTheGraph (
     DrawEnvPtr pDE,
     GraphPtr pGraph,
     short wantGraph,
     short wantBackground,
     short wantAnnotation
);

Input:

pDE: Pointer to a draw environment created by AllocDrawEnvPtr()

 

pGraph: A graph pointer allocated by AllocGraphPtr

 

wantGraph: 0/1

 

0=

Don't draw the graph layer

 

1=

Draw the graph layer

 

wantBackground: 0/1

 

0=

Don't draw the background layer

 

1=

Draw the background layer

 

wantAnnotation: 0/1

 

0=

Draw the annotation layer

 

1=

Don't draw the annotation layer

Return:

Zero = No Error, Non-Zero = Error

Notes:

Also see the PGSDK Programmer's Manual (Graph Basics) for more information about this and other API functions that are essential elements in using the graphics library.

Example:

DrawBegin(gpDrawEnv);
DrawTheGraph(gpDrawEnv, gpGraph,
     TRUE, /* true-draw graph layer */
     TRUE, /* true-draw background layer */
     TRUE);/* true-draw annotation layer */
DrawEnd(gpDrawEnv);

Also See:

DrawBegin(), DryRunTheGraph()

DryRunTheGraph()

 

This function calculates, but does not draw, all graph primitives. It is functionally identical to DrawTheGraph() except the graph primitives are not drawn. This function DOES generate detection nodes.

Syntax:

INT16 PUBLIC
DryRunTheGraph (
     DrawEnvPtr pDE,
     GraphPtr pGraph,
     INT16 wantGraph,
     INT16 wantBackground,
     INT16 wantAnnotation
);

Input:

pDE: Pointer to a draw environment created by AllocDrawEnvPtr()

 

pGraph: Pointer to a graph created by AllocGraphPtr()

 

wantGraph: 0/1

 

0=

Don't draw the graph layer

 

1=

Draw the graph layer

 

wantBackground: 0/1

 

0=

Don't draw the background layer

 

1=

Draw the background layer

 

wantAnnotation: 0/1

 

0=

Draw the annotation layer

 

1=

Don't draw the annotation layer

Return:

Zero = No Error, Non-Zero = Error

Notes:

DryRunTheGraph() actually binds the data to the graph. It is needed by the system to accurately keep track of which Series and Group ID's correlate to which actual riser. Note that you must give it a DC to operate in - as some resizing operations must actually query the "external" world (See Sample).

Example:

foohdc = GetDC( hWnd );
SetDrawEnv( gpDrawEnv, foohdc,
     DE_PORT_NORMAL );
DryRunTheGraph ( gpDrawEnv, gpGraph,
     TRUE, FALSE, FALSE );
ReleaseDC( hWnd, foohdc );

Also See:

DrawTheGraph(), CreateRisers(), HS_DryRunTheGraph()

   

IsGraphBackgroundVisible()

 

This function returns an integer value that indicates whether or not the graph background visibility

Syntax:

INT16 PUBLIC
IsGraphBackgroundVisible (
     GraphPtr pGraph
);

Input:

pGraph: A graph pointer allocated by AllocGraphPtr()

Return:

INT16: 0/1

 

0=

Background is not visible

 

1=

Background is visible

Also See:

DrawBackgroundLayer()