libtpcsvg
 All Data Structures Files Functions Variables Enumerations Enumerator Defines
Functions | Variables
svg_plot.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include "libtpcsvg.h"
Include dependency graph for svg_plot.c:

Go to the source code of this file.

Functions

int get_line_intersection (double a1x, double a1y, double a2x, double a2y, double b1x, double b1y, double b2x, double b2y, double *ix, double *iy)
int check_intersection_with_viewport (double x1, double y1, double x2, double y2, struct svg_viewport_pos *cavp, double *nx1, double *ny1, double *nx2, double *ny2)
int svg_start_plot_viewport (FILE *fp, struct svg_viewports *vp, char *errmsg)
int svg_end_plot_viewport (FILE *fp, struct svg_viewports *vp, char *errmsg)
int svg_start_coordinate_viewport (FILE *fp, struct svg_viewports *vp, char *errmsg)
int svg_end_coordinate_viewport (FILE *fp, char *errmsg)
int svg_calculate_axes (struct svg_viewports *vp)
int svg_write_axes (FILE *fp, struct svg_viewports *vp, char *errmsg)
int svg_write_xticks (FILE *fp, struct svg_viewports *vp, char *errmsg)
int svg_write_yticks (FILE *fp, struct svg_viewports *vp, char *errmsg)
int svg_write_tac (FILE *fp, struct svg_viewports *vp, int plot_type, char *tac_id, char *tac_title, double *x, double *y, int data_nr, char *color, svgSymbolType symbol_type, char *errmsg)

Variables

int SVG_INLINE
int SVG_TEST

Function Documentation

int check_intersection_with_viewport ( double  x1,
double  y1,
double  x2,
double  y2,
struct svg_viewport_pos cavp,
double *  nx1,
double *  ny1,
double *  nx2,
double *  ny2 
)
Parameters:
x1x,y coordinates of line at points 1 and 2; x coordinate of point 1
y1y coordinate of point 1
x2x coordinate of point 2
y2y coordinate of point 2
cavpPointer to coordinate area viewport
nx1Pointers for (possibly) modified line coordinates; NULL if not needed
ny1new y coordinate of point 1
nx2new x coordinate of point 2
ny2new y coordinate of point 2

Definition at line 132 of file svg_plot.c.

References get_line_intersection(), svg_viewport_pos::h, SVG_TEST, and svg_viewport_pos::w.

Referenced by svg_write_tac().

Here is the call graph for this function:

int get_line_intersection ( double  a1x,
double  a1y,
double  a2x,
double  a2y,
double  b1x,
double  b1y,
double  b2x,
double  b2y,
double *  ix,
double *  iy 
)

Check whether two lines, each drawn between two points, intersect each other. If either end of lines intersects with the other line, that is NOT counted as intersection.

Returns:
Returns 1 in case of intersection, and 0 if they do not cross.
Parameters:
a1xx,y coordinates of line a at points 1 and 2; x coordinate of point 1
a1yy coordinate of point 1
a2xx coordinate of point 2
a2yy coordinate of point 2
b1xx,y coordinates of line b at points 1 and 2; x coordinate of point 1
b1yy coordinate of point 1
b2xx coordinate of point 2
b2yy coordinate of point 2
ixPointers for intersection point coordinates; NULL if not needed
iyIntersection y coordinate

Definition at line 87 of file svg_plot.c.

References SVG_TEST.

Referenced by check_intersection_with_viewport().

int svg_calculate_axes ( struct svg_viewports vp)

Calculate the axis tick positions. Before calling this, viewport must be filled with curve min and max values. This routine checks that max>min, changing the values if necessary.

Returns:
Returns 0 if successful, <>0 in case of error.
Parameters:
vpStruct containing the viewport sizes

Definition at line 381 of file svg_plot.c.

References axis_check_range(), axis_tick_positions(), svg_coord::fixed_max, svg_coord::fixed_min, svg_coord::max, MAX_TICK_NR, svg_coord::min, svg_coord::tick, svg_coord::tick_decimals, svg_coord::tick_label, svg_coord::tick_nr, svg_coord::tickscale, svg_viewports::x, and svg_viewports::y.

Here is the call graph for this function:

int svg_end_coordinate_viewport ( FILE *  fp,
char *  errmsg 
)

End coordinate area viewport.

Returns:
Returns 0 if successful, <>0 in case of error.
Parameters:
fpSVG graphics file pointer
errmsgChar pointer to string (at least of length 128) where possible error description is copied; set to NULL if not necessary

Definition at line 353 of file svg_plot.c.

References SVG_INLINE, and svg_write().

Here is the call graph for this function:

int svg_end_plot_viewport ( FILE *  fp,
struct svg_viewports vp,
char *  errmsg 
)

End plot viewport.

Returns:
Returns 0 if successful, <>0 in case of error.
Parameters:
fpSVG graphics file pointer
vpStruct containing the viewport sizes
errmsgChar pointer to string (at least of length 128) where possible error description is copied; set to NULL if not necessary

Definition at line 280 of file svg_plot.c.

References SVG_INLINE, and svg_write().

Here is the call graph for this function:

int svg_start_coordinate_viewport ( FILE *  fp,
struct svg_viewports vp,
char *  errmsg 
)

Start coordinate area viewport.

Returns:
Returns 0 if successful, <>0 in case of error.
Parameters:
fpSVG graphics file pointer
vpStruct containing the viewport sizes
errmsgChar pointer to string (at least of length 128) where possible error description is copied; set to NULL if not necessary

Definition at line 310 of file svg_plot.c.

References svg_viewports::coordinate_area_viewport, svg_viewport_pos::h, SVG_INLINE, svg_write(), svg_viewport_pos::w, svg_viewport_pos::x, and svg_viewport_pos::y.

Here is the call graph for this function:

int svg_start_plot_viewport ( FILE *  fp,
struct svg_viewports vp,
char *  errmsg 
)

Start plot area viewport.

Returns:
Returns 0 if successful, <>0 in case of error.
Parameters:
fpSVG graphics file pointer
vpStruct containing the viewport sizes
errmsgChar pointer to string (at least of length 128) where possible error description is copied; set to NULL if not necessary

Definition at line 234 of file svg_plot.c.

References svg_viewport_pos::h, svg_viewports::plot_area_viewport, svg_define_symbols(), SVG_INLINE, svg_write(), svg_viewport_pos::w, svg_viewport_pos::x, and svg_viewport_pos::y.

Here is the call graph for this function:

int svg_write_axes ( FILE *  fp,
struct svg_viewports vp,
char *  errmsg 
)

Draw the axes into SVG plot coordinate area.

Returns:
Returns 0 if successful, <>0 in case of error.
Parameters:
fpSVG graphics file pointer
vpStruct containing the viewport sizes
errmsgPointer to string where error message is written; NULL if not needed

Definition at line 438 of file svg_plot.c.

References svg_viewports::coordinate_area_viewport, svg_viewport_pos::h, svg_coord::max, svg_coord::min, svg_coord::origo, svg_coord::scale, SVG_INLINE, SVG_TEST, svg_write(), svg_coord::upper_margin, svg_viewport_pos::w, svg_viewports::x, and svg_viewports::y.

Here is the call graph for this function:

int svg_write_tac ( FILE *  fp,
struct svg_viewports vp,
int  plot_type,
char *  tac_id,
char *  tac_title,
double *  x,
double *  y,
int  data_nr,
char *  color,
svgSymbolType  symbol_type,
char *  errmsg 
)

Draw sample curve in an SVG file.

Returns:
Returns 0 if successful, <>0 in case of error.
Parameters:
fpSVG graphics file pointer
vpStruct containing the viewport sizes
plot_typePlot type: 1=line, 2=symbols, 0=both line and symbols
tac_idUnique ID for the curve
tac_titleTitle of the curve, which may be shown in the graph
xPointer to the polyline data x array (original quantities)
yPointer to the polyline data y array (original quantities)
data_nrNr of data points in the array (half of array length)
colorSVG color name as a string, e.g. aqua,black,blue,fuchsia,gray, green,lime,maroon,navy,olive,purple,red,silver,teal,yellow. Note that this string is not tested
symbol_typeSymbol type: RECTANGLE,CIRCLE,UPTRIANGLE,DOWNTRIANGLE,DIAMOND, LEFTTRIANGLE, RIGHTTRIANGLE
errmsgChar pointer to string (at least of length 128) where possible error description is copied; set to NULL if not necessary

Definition at line 665 of file svg_plot.c.

References check_intersection_with_viewport(), CIRCLE, svg_viewports::coordinate_area_viewport, DIAMOND, DOWNTRIANGLE, svg_viewport_pos::h, LEFTTRIANGLE, svg_coord::origo, RECTANGLE, RIGHTTRIANGLE, svg_coord::scale, SVG_INLINE, SVG_TEST, svg_write(), UPTRIANGLE, svg_viewport_pos::w, svg_viewports::x, and svg_viewports::y.

Here is the call graph for this function:

int svg_write_xticks ( FILE *  fp,
struct svg_viewports vp,
char *  errmsg 
)

Create SVG plot x axis ticks.

Returns:
Returns 0 if successful, <>0 in case of error.
Parameters:
fpSVG graphics file pointer
vpStruct containing the viewport sizes
errmsgChar pointer to string (at least of length 128) where possible error description is copied; set to NULL if not necessary

Definition at line 523 of file svg_plot.c.

References svg_viewport_pos::chr_size, svg_viewports::coordinate_area_viewport, svg_viewport_pos::h, svg_coord::origo, svg_viewports::plot_area_viewport, svg_coord::scale, SVG_INLINE, SVG_TEST, svg_write(), svg_coord::tick, svg_coord::tick_label, svg_coord::tick_nr, svg_coord::tickscale, svg_viewport_pos::w, and svg_viewports::x.

Here is the call graph for this function:

int svg_write_yticks ( FILE *  fp,
struct svg_viewports vp,
char *  errmsg 
)

Create SVG plot y axis ticks.

Returns:
Returns 0 if successful, <>0 in case of error.
Parameters:
fpSVG graphics file pointer
vpStruct containing the viewport sizes
errmsgChar pointer to string (at least of length 128) where possible error description is copied; set to NULL if not necessary

Definition at line 591 of file svg_plot.c.

References svg_viewport_pos::chr_size, svg_viewports::coordinate_area_viewport, svg_viewport_pos::h, svg_coord::origo, svg_viewports::plot_area_viewport, svg_coord::scale, SVG_INLINE, SVG_TEST, svg_write(), svg_coord::tick, svg_coord::tick_decimals, svg_coord::tick_label, svg_coord::tick_nr, svg_coord::tickscale, svg_viewport_pos::w, and svg_viewports::y.

Here is the call graph for this function:


Variable Documentation

Definition at line 50 of file svg_file.c.

int SVG_TEST

Definition at line 51 of file svg_file.c.