This function defines the output of the graphical information retrieved from the database. In this example, the information is written into the report. The information can also be passed to an actual drawing routine, if desired.
The name of the activity,
ac_name
, is passed as a second parameter because the activity name is used in a graphic drawing such as a plot, although this information is part of the element’s textual record.stm_ac_graphic_ptr ac_graphic;
stm_name ac_name;
ac_graphic
is a pointer to an activity’s graphical record;ac_name
is the name of the activity.{
int i = 0;
stm_coordinate prev_x;
stm_coordinate prev_y;Declares the following variables:
●i
—Controls the loop of the routine.
●printf ("\n\n activity graphical information\n");
printf ("==============================\n");These statements are the title of the output; they begin the retrieved information for each activity retrieved.
draw_string (ac_name, ac_graphic->ac_name_color,
ac_graphic->ac_x_coor,ac_graphic->ac_y_coor);This uses the routine
draw_string
to plot the activity name. It sends as parameters the string that holds the name, color, and X-Y coordinates where the name is drawn.for (i=1; iac_polygon.points_no; i++)
Plots the element. It loops through the coordinates and draw lines between the control points of the box representing the activity.
{
prev_x = ac_graphic->ac_polygon.outline[i-1].x;
prev_y = ac_graphic->ac_polygon.outline[i-1].y;
draw_line(ac_graphic->ac_color,prev_x,prev_y,
ac_graphic->ac_polygon.outline
[i % ac_graphic->ac_polygon.points_no].x,
ac_graphic->ac_polygon.outline
[i % ac_graphic->ac_polygon.points_no].y);
}
}For each coordinate, the following parameters are passed to the
draw_line
routine:The
draw_line
function is called for each side of the activity individually.Note: The lines of code beginning withac_graphic
to.x
andac_graphic
to.y
should be entered on a single line, which cannot be shown in the example.