dkfigw.c File Reference

Fig writer module. More...

#include <dk.h>
#include <math.h>
#include <stdlib.h>
#include <unistd.h>
#include <dksf.h>
#include <dkmem.h>
#include <dkstr.h>
#include <dkstream.h>
#include <dkma.h>
#include "dkfigw.h"

Defines

#define DKFIGW_C   1
 Inside the dkfigw module.
#define TO_RANGE(x, min, max)   ((x > max) ? max : ((x < min) ? min : x))
 Return corrected value fitting in range.

Functions

static int my_str_array_index (char **a, char *t, int c, unsigned char ver)
 Find index of text.
static double d_to_fig_d (dk_fig_writer_t *fwp, double x)
 Convert Distance to Fig units.
static long d_to_fig_l (dk_fig_writer_t *fwp, double x)
 Convert distance to Fig units.
static double x_to_fig_d (dk_fig_writer_t *fwp, double x)
 Convert x position to Fig units.
static long x_to_fig_l (dk_fig_writer_t *fwp, double x)
 Convert x position to Fig units.
static double y_to_fig_d (dk_fig_writer_t *fwp, double y)
 Convert y position to Fig units.
static long y_to_fig_l (dk_fig_writer_t *fwp, double y)
 Convert y position to Fig units.
static int uc_to_int (unsigned char uc)
 Convert unsigned char to integer.
static void put_unsigned (dk_stream_t *os, unsigned u)
 Write unsigned number to output stream.
static void put_int (dk_stream_t *os, int i)
 Put integer value to output stream.
static void put_int_range (dk_stream_t *os, int i, int min, int max)
 Put integer value to output stream, correct value if necessary.
static void put_long (dk_stream_t *os, long l)
 Put long value to output stream.
static void put_double (dk_stream_t *os, double d)
 Put double value to output stream.
static void put_long_double (dk_stream_t *os, double d)
 Put double value to output stream, use large number of decimal digits.
static void init_arrowhead (dk_fig_ah_t *ahp)
 Initialize arrowhead.
static void init_style (dk_fig_style_t *stp)
 Initialize style information structure.
int dkfigw_compare_pl_points (void *l, void *r, int c)
 Compare two polyline/polygon points by number.
int dkfigw_compare_sp_points (void *l, void *r, int c)
 Compare two spline points by number.
int dkfigw_compare_color_cells (void *l, void *r, int c)
 Compare two color cells.
int dkfigw_compare_objects (void *l, void *r, int c)
 Compare two objects.
static void object_delete (dk_fig_object_t *obj)
 Release memory for Fig object.
static dk_fig_object_tobject_new (dk_fig_writer_t *fwp, unsigned char ot, unsigned char st)
 Create structure for Fig object.
static void cc_delete (dk_fig_cc_t *ccp)
 Release memory for color cell.
void dkfigw_delete (dk_fig_writer_t *fwp)
 Remove writer structure, release memory.
dk_fig_writer_tdkfigw_new (void)
 Create new writer structure.
void dkfigw_set_image_origin (dk_fig_writer_t *fwp, int olt)
 Set image origin.
int dkfigw_set_image_size (dk_fig_writer_t *fwp, int uni, double w, double h)
 Set image size.
unsigned long dkfigw_rectangle (dk_fig_writer_t *fwp, double x0, double y0, double x1, double y1)
 Add rectangle.
unsigned long dkfigw_arc_box (dk_fig_writer_t *fwp, double x0, double y0, double x1, double y1, double r)
 Add arc box.
unsigned long dkfigw_image (dk_fig_writer_t *fwp, double x0, double y0, double x1, double y1, char *fn)
 Add image.
unsigned long dkfigw_polygon (dk_fig_writer_t *fwp)
 Add polygon.
unsigned long dkfigw_polyline (dk_fig_writer_t *fwp)
 Add polyline.
unsigned long dkfigw_point (dk_fig_writer_t *fwp, double x, double y)
 Add point to the current polygon or polyline object.
unsigned long dkfigw_open_spline (dk_fig_writer_t *fwp)
 Add open spline.
unsigned long dkfigw_closed_spline (dk_fig_writer_t *fwp)
 Add closed spline.
unsigned long dkfigw_spline_point (dk_fig_writer_t *fwp, double x, double y, double s)
 Add point to current spline object.
unsigned long dkfigw_open_arc (dk_fig_writer_t *fwp, double x, double y, double r, double a0, double a1)
 Add open arc.
unsigned long dkfigw_closed_arc (dk_fig_writer_t *fwp, double x, double y, double r, double a0, double a1)
 Add closed arc (pie wedge).
unsigned long dkfigw_circle (dk_fig_writer_t *fwp, double x, double y, double r)
 Add circle.
unsigned long dkfigw_ellipse (dk_fig_writer_t *fwp, double x, double y, double rx, double ry, double rot)
 Add ellipse.
unsigned long dkfigw_text (dk_fig_writer_t *fwp, double x, double y, char *t, double a)
 Add text.
void dkfigw_set_text_align (dk_fig_writer_t *fwp, unsigned char tal)
 Set text alignment for all following texts added.
void dkfigw_set_text_rigid (dk_fig_writer_t *fwp, int fl)
 Set/reset rigid flag for all following texts added.
void dkfigw_set_text_special (dk_fig_writer_t *fwp, int fl)
 Set/reset special flag for all following texts added.
void dkfigw_set_text_psfont (dk_fig_writer_t *fwp, unsigned char fno)
 Set PS font index for all following texts added.
void dkfigw_set_text_psfont_by_name (dk_fig_writer_t *fwp, char *n)
 Set PS font for all following texts added, choose font by name.
void dkfigw_set_text_latexfont (dk_fig_writer_t *fwp, unsigned char fno)
 Set LaTeX font index for all following texts added.
void dkfigw_set_text_size (dk_fig_writer_t *fwp, double fsz)
 Set text size fo all following texts added.
void dkfigw_set_layer (dk_fig_writer_t *fwp, unsigned short lay)
 Set layer for all following objects.
int dkfigw_layer_up (dk_fig_writer_t *fwp)
 Move one layer upwards.
void dkfigw_set_pen_color (dk_fig_writer_t *fwp, short col)
 Set pen color for all following objects.
void dkfigw_set_pen_color_by_name (dk_fig_writer_t *fwp, char *n)
 Set pen color for all following objects by color name.
void dkfigw_set_fill_color (dk_fig_writer_t *fwp, short col)
 Set fill color for all following objects.
void dkfigw_set_fill_color_by_name (dk_fig_writer_t *fwp, char *n)
 Set fill color for all following objects by color name.
void dkfigw_set_transparent_color (dk_fig_writer_t *fwp, short col)
 Set transparent color.
void dkfigw_set_fill_style (dk_fig_writer_t *fwp, unsigned char fil)
 Set fill style for all following objects.
void dkfigw_set_line_style (dk_fig_writer_t *fwp, unsigned char lst)
 Set line style for all following objects.
void dkfigw_set_line_width (dk_fig_writer_t *fwp, short lw)
 Set line width for all following objects.
void dkfigw_set_angle_degree (dk_fig_writer_t *fwp, int fl)
 Set "angle-in-degree" flag in writer.
void dkfigw_set_line_join (dk_fig_writer_t *fwp, unsigned char ljn)
 Set line join style for all following objects.
void dkfigw_set_line_cap (dk_fig_writer_t *fwp, unsigned char lcp)
 Set line cap style for all following objects.
static void set_arrowhead (dk_fig_ah_t *ah, unsigned char sha, unsigned char fil, double wid, double hei)
 Set shape, fill type and lengths for one arrowhead.
void dkfigw_set_arrowhead_f (dk_fig_writer_t *fwp, unsigned char sha, unsigned char fil, double wid, double hei)
 Set shape, fill type and lengths for forward arrowhead.
void dkfigw_set_arrowhead_b (dk_fig_writer_t *fwp, unsigned char sha, unsigned char fil, double wid, double hei)
 Set shape, fill type and lengths for backward arrowhead.
void dkfigw_set_arrowheads (dk_fig_writer_t *fwp, unsigned char ahs)
 Set arrowheads directions.
static void kw_out (dk_stream_t *os, size_t n)
 Write one keyword from the.
static void put_arrow (dk_stream_t *os, dk_fig_writer_t *fwp, dk_fig_style_t *sty, dk_fig_ah_t *ah, dk_fig_object_t *o)
 Write one arrowhead line to output stream.
void dkfigw_set_suggested_arrow_settings (dk_fig_writer_t *fwp)
 Initial settings for arrowheads.
static void spline_start (dk_stream_t *os, dk_fig_writer_t *f, dk_fig_object_t *o, dk_fig_style_t *sty, unsigned long np, int afw, int abw)
 Write line to start a spline to output stream.
static void spline_points (dk_stream_t *os, dk_fig_writer_t *f, dk_fig_object_t *o)
 Write points coordinates to output stream.
static void polyline_start (dk_stream_t *os, dk_fig_writer_t *f, dk_fig_object_t *o, dk_fig_style_t *sty, unsigned long np, int afw, int abw)
 Write start-of-polyline line to output stream.
static void polyline_points (dk_stream_t *os, dk_fig_writer_t *f, dk_fig_object_t *o, int flcl)
 Write polyline points coordinates to output stream.
static void box_points (dk_stream_t *os, dk_fig_writer_t *f, dk_fig_object_t *o)
 Write points coordinates for box (rectangle, image or arc box).
static void stream_putc (dk_stream_t *os, char c)
 Put single character to stream.
static void put_text (dk_stream_t *os, char *txt)
 Write text contents to output stream, apply conversion if necessary.
static void print_object (dk_stream_t *os, dk_fig_writer_t *f, dk_fig_object_t *o)
 Print one object to output stream.
int dkfigw_write (dk_stream_t *os, dk_fig_writer_t *fwp)
 Write Fig file to stream.
int dkfigw_file (char *fn, dk_fig_writer_t *fwp)
 Write Fig file to named file.
int dkfigw_define_color (dk_fig_writer_t *fwp, int r, int g, int b)
 Define a new color.
void dkfigw_set_utf8 (dk_fig_writer_t *fwp, int fl)
 Enable/disable usage of UTF-8.
void dkfigw_set_verbose (dk_fig_writer_t *fwp, int fl)
 Enable/disable verbose mode.

Variables

static char * suffixes []
 File name suffixes used for compressed files.
static char * kw []
 Keywords used while producing a Fig file.
static char * paper_sizes []
 Paper size names.
static double cm_to_fig = 1200.0 / 2.54
 Factor for cm to Fig unit conversion.
static double in_to_fig = 1200.0
 Factor for inch to Fig unit conversion.
static char * color_names []
 Color names.
static char * font_names []
 PS font names.
static char sccs_id [] = { "@(#)dkfigw.ctr 1.3 10/15/09" }
 SCCS ID.


Detailed Description

Fig writer module.

This module contains functions to create a graphic in-memory and save that graphics to a Fig file. Programs like XFig or jFig can be used to apply modifications to the graphics file after it is written.

Fig files are text files, so you could use standard I/O operations like fprintf() to produce the file. The purpose of this module is to ease up the Fig file production by doing calculations from centimeters and inches to Fig units and the coordinates transformation from "origin in lower left corner" used by the module to "origin in upper left corner" used by the Fig file format.


Define Documentation

#define TO_RANGE ( x,
min,
max   )     ((x > max) ? max : ((x < min) ? min : x))

Return corrected value fitting in range.

Parameters:
x Value to correct.
min Range minimum.
max Range maximum.
Returns:
Corrected value.


Function Documentation

static void box_points ( dk_stream_t os,
dk_fig_writer_t f,
dk_fig_object_t o 
) [static]

Write points coordinates for box (rectangle, image or arc box).

Parameters:
os Output stream.
f Fig writer structure.
o Current object.

static void cc_delete ( dk_fig_cc_t ccp  )  [static]

Release memory for color cell.

Parameters:
ccp Color cell to release.

static double d_to_fig_d ( dk_fig_writer_t fwp,
double  x 
) [static]

Convert Distance to Fig units.

Parameters:
fwp Fig writer structure.
x Distance to convert.
Returns:
The conversion result as double value.

static long d_to_fig_l ( dk_fig_writer_t fwp,
double  x 
) [static]

Convert distance to Fig units.

Parameters:
fwp Fig writer structure.
x Distance to convert.
Returns:
The conversion result as long value.

unsigned long dkfigw_arc_box ( dk_fig_writer_t fwp,
double  x0,
double  y0,
double  x1,
double  y1,
double  r 
)

Add arc box.

Parameters:
fwp Writer structure.
x0 Point 1 x.
y0 Point 1 y.
x1 Point 2 x.
y1 Point 2 y.
r Corner radius.
Returns:
Positive number on success, 0 on error.

unsigned long dkfigw_circle ( dk_fig_writer_t fwp,
double  x,
double  y,
double  r 
)

Add circle.

Parameters:
fwp Writer structure.
x Center x.
y Center y.
r Radius.
Returns:
Positive number on success, 0 on error.

unsigned long dkfigw_closed_arc ( dk_fig_writer_t fwp,
double  x,
double  y,
double  r,
double  a0,
double  a1 
)

Add closed arc (pie wedge).

Parameters:
fwp Writer structure.
x Center x.
y Center y.
r Radius.
a0 Start angle in radians.
a1 End angle in radians.
Returns:
Positive number on success, 0 on error.

unsigned long dkfigw_closed_spline ( dk_fig_writer_t fwp  ) 

Add closed spline.

After creating the spline use dkfigw_spline_point() to add points.

Parameters:
fwp Writer structure.
Returns:
Positive number on success, 0 on error.

int dkfigw_compare_color_cells ( void *  l,
void *  r,
int  c 
)

Compare two color cells.

Parameters:
l Left color cell.
r Right color cell.
c Comparison criteria (0=cell/cell, 1=cell/number).
Returns:
Comparison result.

int dkfigw_compare_objects ( void *  l,
void *  r,
int  c 
)

Compare two objects.

Parameters:
l Left object.
r Right object.
c Comparison criteria (0=object/object, 1=object/number).
Returns:
Comparison result.

int dkfigw_compare_pl_points ( void *  l,
void *  r,
int  c 
)

Compare two polyline/polygon points by number.

Parameters:
l Left point.
r Right point.
c Comparison criteria (ignored).
Returns:
Comparison result.

int dkfigw_compare_sp_points ( void *  l,
void *  r,
int  c 
)

Compare two spline points by number.

Parameters:
l Left point.
r Right point.
c Comparison criteria (ignored).
Returns:
Comparison result.

int dkfigw_define_color ( dk_fig_writer_t fwp,
int  r,
int  g,
int  b 
)

Define a new color.

Parameters:
fwp Fig writer structure.
r Red.
g Green.
b Blue.
Returns:
The new color cell number on success, 0 on error.

void dkfigw_delete ( dk_fig_writer_t fwp  ) 

Remove writer structure, release memory.

Parameters:
fwp Pointer to structure to release.

unsigned long dkfigw_ellipse ( dk_fig_writer_t fwp,
double  x,
double  y,
double  rx,
double  ry,
double  rot 
)

Add ellipse.

Parameters:
fwp Writer structure.
x Center x.
y Center y.
rx Horizontal radius.
ry Vertical radius.
rot Rotation in radians.
Returns:
Positive number on success, 0 on error.

int dkfigw_file ( char *  fn,
dk_fig_writer_t fwp 
)

Write Fig file to named file.

Parameters:
fn File name to write to.
fwp Fig structure.
Returns:
1 on success, 0 on error.

unsigned long dkfigw_image ( dk_fig_writer_t fwp,
double  x0,
double  y0,
double  x1,
double  y1,
char *  fn 
)

Add image.

Parameters:
fwp Writer structure.
x0 Point 1 x.
y0 Point 1 y.
x1 Point 2 x.
y1 Point 2 y.
fn File name.
Returns:
Positive number on success, 0 on error.

int dkfigw_layer_up ( dk_fig_writer_t fwp  ) 

Move one layer upwards.

Parameters:
fwp Writer structure.
Returns:
Non-zero number on success, 0 on error.

dk_fig_writer_t* dkfigw_new ( void   ) 

Create new writer structure.

Returns:
Pointer to new writer structure on success, NULL on error.

unsigned long dkfigw_open_arc ( dk_fig_writer_t fwp,
double  x,
double  y,
double  r,
double  a0,
double  a1 
)

Add open arc.

Parameters:
fwp Writer structure.
x Center x.
y Center y.
r Radius.
a0 Start angle in radians.
a1 End angle in radians.
Returns:
Positive number on success, 0 on error.

unsigned long dkfigw_open_spline ( dk_fig_writer_t fwp  ) 

Add open spline.

After creating the spline use dkfigw_spline_point() to add points.

Parameters:
fwp Writer structure.
Returns:
Positive number on success, 0 on error.

unsigned long dkfigw_point ( dk_fig_writer_t fwp,
double  x,
double  y 
)

Add point to the current polygon or polyline object.

Parameters:
fwp Writer structure.
x X position.
y Y position.
Returns:
Positive number on success, 0 on error.

unsigned long dkfigw_polygon ( dk_fig_writer_t fwp  ) 

Add polygon.

After creating the polygon use dkfigw_point() to add points.

Parameters:
fwp Writer structure.
Returns:
Positive number on success, 0 on error.

unsigned long dkfigw_polyline ( dk_fig_writer_t fwp  ) 

Add polyline.

After creating the polygon use dkfigw_point() to add points.

Parameters:
fwp Writer structure.
Returns:
Positive number on success, 0 on error.

unsigned long dkfigw_rectangle ( dk_fig_writer_t fwp,
double  x0,
double  y0,
double  x1,
double  y1 
)

Add rectangle.

Parameters:
fwp Writer structure.
x0 Point 1 x.
y0 Point 1 y.
x1 Point 2 x.
y1 Point 2 y.
Returns:
Positive number on success, 0 on error.

void dkfigw_set_angle_degree ( dk_fig_writer_t fwp,
int  fl 
)

Set "angle-in-degree" flag in writer.

Parameters:
fwp Writer structure.
fl Set (non-zero value) or reset (0) the flag.

void dkfigw_set_arrowhead_b ( dk_fig_writer_t fwp,
unsigned char  sha,
unsigned char  fil,
double  wid,
double  hei 
)

Set shape, fill type and lengths for backward arrowhead.

Set backward arrowhead style for all following objects.

Parameters:
fwp Fig writer structure.
sha Shape.
fil Fill type.
wid Width.
hei Height

void dkfigw_set_arrowhead_f ( dk_fig_writer_t fwp,
unsigned char  sha,
unsigned char  fil,
double  wid,
double  hei 
)

Set shape, fill type and lengths for forward arrowhead.

Set forward arrowhead style for all following objects.

Parameters:
fwp Fig writer structure.
sha Shape.
fil Fill type.
wid Width.
hei Height

void dkfigw_set_arrowheads ( dk_fig_writer_t fwp,
unsigned char  ahs 
)

Set arrowheads directions.

Parameters:
fwp Fig writer structure.
ahs Directions (0x00=no arrowheads, 0x01=forward, 0x02=backward, 0x03=both forward and backward).

void dkfigw_set_fill_color ( dk_fig_writer_t fwp,
short  col 
)

Set fill color for all following objects.

Parameters:
fwp Writer structure.
col Color cell number, either a user defined color (32 and above) or a predefined color: FIG_COLOR_BLACK, FIG_COLOR_BLUE, FIG_COLOR_GREEN, FIG_COLOR_CYAN, FIG_COLOR_RED, FIG_COLOR_MAGENTA, FIG_COLOR_YELLOW, FIG_COLOR_WHITE, FIG_COLOR_DARKEST_BLUE, FIG_COLOR_DARK_BLUE, FIG_COLOR_LIGHT_BLUE, FIG_COLOR_LIGHTEST_BLUE, FIG_COLOR_DARK_GREEN, FIG_COLOR_NORMAL_GREEN, FIG_COLOR_LIGHT_GREEN, FIG_COLOR_DARK_CYAN, FIG_COLOR_NORMAL_CYAN, FIG_COLOR_LIGHT_CYAN, FIG_COLOR_DARK_RED, FIG_COLOR_NORMAL_RED, FIG_COLOR_LIGHT_RED, FIG_COLOR_DARK_MAGENTA, FIG_COLOR_NORMAL_MAGENTA, FIG_COLOR_LIGHT_MAGENTA, FIG_COLOR_DARK_BROWN, FIG_COLOR_NORMAL_BROWN, FIG_COLOR_LIGHT_BROWN, FIG_COLOR_DARKEST_PINK, FIG_COLOR_DARK_PINK, FIG_COLOR_LIGHT_PINK, FIG_COLOR_LIGHTEST_PINK or FIG_COLOR_GOLD.

void dkfigw_set_fill_color_by_name ( dk_fig_writer_t fwp,
char *  n 
)

Set fill color for all following objects by color name.

Parameters:
fwp Writer structure.
n Color name: One of the names in color_names.

void dkfigw_set_fill_style ( dk_fig_writer_t fwp,
unsigned char  fil 
)

Set fill style for all following objects.

Parameters:
fwp Writer structure.
fil Fill style, one from: FIG_FILL_NONE, FIG_FILL_BLACK, FIG_FILL_005, FIG_FILL_010, FIG_FILL_015, FIG_FILL_020, FIG_FILL_025, FIG_FILL_030, FIG_FILL_035, FIG_FILL_040, FIG_FILL_045, FIG_FILL_050, FIG_FILL_055, FIG_FILL_060, FIG_FILL_065, FIG_FILL_070, FIG_FILL_075, FIG_FILL_080, FIG_FILL_085, FIG_FILL_090, FIG_FILL_095, FIG_FILL_100, FIG_FILL_PURE, FIG_FILL_105, FIG_FILL_110, FIG_FILL_115, FIG_FILL_120, FIG_FILL_125, FIG_FILL_130, FIG_FILL_135, FIG_FILL_140, FIG_FILL_145, FIG_FILL_150, FIG_FILL_155, FIG_FILL_160, FIG_FILL_165, FIG_FILL_170, FIG_FILL_175, FIG_FILL_180, FIG_FILL_185, FIG_FILL_190, FIG_FILL_195, FIG_FILL_200, FIG_FILL_WHITE, FIG_FILL_LEFT_DIAGONAL_30, FIG_FILL_RIGHT_DIAGONAL_30, FIG_FILL_CROSSHATCH_30, FIG_FILL_LEFT_DIAGONAL_45, FIG_FILL_RIGHT_DIAGONAL_45, FIG_FILL_CROSSHATCH_45, FIG_FILL_BRICKS_HORIZONTAL, FIG_FILL_BRICKS_VERTICAL, FIG_FILL_HORIZONTAL_LINES, FIG_FILL_VERTICAL_LINES, FIG_FILL_CROSSHATCH, FIG_FILL_HORIZONTAL_SHINGLES_RIGHT, FIG_FILL_HORIZONTAL_SHINGLES_LEFT, FIG_FILL_VERTICAL_SHINGLES_1, FIG_FILL_VERTICAL_SHINGLES_2, FIG_FILL_LARGE_FISH_SCALES, FIG_FILL_SMALL_FISH_SCALES, FIG_FILL_CIRCLES, FIG_FILL_HEXAGONS, FIG_FILL_OCTAGONS, FIG_FILL_HORIZONTAL_TIRE_TREADS or FIG_FILL_VERTICAL_TIRE_TREADS.

void dkfigw_set_image_origin ( dk_fig_writer_t fwp,
int  olt 
)

Set image origin.

Parameters:
fwp Writer structure.
olt Flag: Origin at left top (1) or left bottom (0).

int dkfigw_set_image_size ( dk_fig_writer_t fwp,
int  uni,
double  w,
double  h 
)

Set image size.

Parameters:
fwp Writer structure.
uni Size unit (0=Fig, 1=inch, 2=cm).
w Image width.
h Image height.
Returns:
1 on success, 0 on error.

void dkfigw_set_layer ( dk_fig_writer_t fwp,
unsigned short  lay 
)

Set layer for all following objects.

Parameters:
fwp Writer structure.
lay Layer number.

void dkfigw_set_line_cap ( dk_fig_writer_t fwp,
unsigned char  lcp 
)

Set line cap style for all following objects.

Parameters:
fwp Writer structure.
lcp Line cap style, one from: FIG_CS_BUTT, FIG_CS_ROUND or FIG_CS_PROJECTING.

void dkfigw_set_line_join ( dk_fig_writer_t fwp,
unsigned char  ljn 
)

Set line join style for all following objects.

Parameters:
fwp Writer structure.
ljn Line join style, one from: FIG_LJ_MITER, FIG_LJ_ROUND, or FIG_LJ_BEVEL.

void dkfigw_set_line_style ( dk_fig_writer_t fwp,
unsigned char  lst 
)

Set line style for all following objects.

Parameters:
fwp Writer structure.
lst Line style, one from: FIG_LS_SOLID, FIG_LS_DASHED, FIG_LS_DOTTED, FIG_LS_DASH_DOTTED, FIG_LS_DASH_DOUBLE_DOTTED or FIG_LS_DASH_TRIPLE_DOTTED.

void dkfigw_set_line_width ( dk_fig_writer_t fwp,
short  lw 
)

Set line width for all following objects.

Parameters:
fwp Writer structure.
lw Line width in Fig linewidth units (1/80 inch).

void dkfigw_set_pen_color ( dk_fig_writer_t fwp,
short  col 
)

Set pen color for all following objects.

Parameters:
fwp Writer structure.
col Color cell number (0 to 31 for predefined colors, 32 and above for self-defined colors).

void dkfigw_set_pen_color_by_name ( dk_fig_writer_t fwp,
char *  n 
)

Set pen color for all following objects by color name.

Parameters:
fwp Writer structure.
n Color name: One of the names in color_names.

void dkfigw_set_suggested_arrow_settings ( dk_fig_writer_t fwp  ) 

Initial settings for arrowheads.

Parameters:
fwp Fig structure.

void dkfigw_set_text_align ( dk_fig_writer_t fwp,
unsigned char  tal 
)

Set text alignment for all following texts added.

Parameters:
fwp Writer structure.
tal Alignment (FIG_SUB_TEXT_xxx).

void dkfigw_set_text_latexfont ( dk_fig_writer_t fwp,
unsigned char  fno 
)

Set LaTeX font index for all following texts added.

Parameters:
fwp Writer structure.
fno Font index (0=default, 1=roman, 2=bold, 3=italic, 4=sans-serif, 5=typewriter).

void dkfigw_set_text_psfont ( dk_fig_writer_t fwp,
unsigned char  fno 
)

Set PS font index for all following texts added.

Parameters:
fwp Writer structure.
fno Font index (0 to 34).

void dkfigw_set_text_psfont_by_name ( dk_fig_writer_t fwp,
char *  n 
)

Set PS font for all following texts added, choose font by name.

Parameters:
fwp Writer structure.
n Font name: one of the strings in font_names.

void dkfigw_set_text_rigid ( dk_fig_writer_t fwp,
int  fl 
)

Set/reset rigid flag for all following texts added.

Parameters:
fwp Writer structure.
fl Set (non-zero) or reset (0) flag.

void dkfigw_set_text_size ( dk_fig_writer_t fwp,
double  fsz 
)

Set text size fo all following texts added.

Parameters:
fwp Writer structure.
fsz Font size in pt.

void dkfigw_set_text_special ( dk_fig_writer_t fwp,
int  fl 
)

Set/reset special flag for all following texts added.

Parameters:
fwp Writer structure.
fl Set (non-zero) or reset (0) flag.

void dkfigw_set_transparent_color ( dk_fig_writer_t fwp,
short  col 
)

Set transparent color.

Parameters:
fwp Writer structure.
col Index of the transparent color.

void dkfigw_set_utf8 ( dk_fig_writer_t fwp,
int  fl 
)

Enable/disable usage of UTF-8.

When creating a new Fig writer structure the LANG environment variable is inspected to set the default value.

Parameters:
fwp Fig writer structure.
fl Flag to enable/disable.

void dkfigw_set_verbose ( dk_fig_writer_t fwp,
int  fl 
)

Enable/disable verbose mode.

In verbose mode the module prints warnings to stderr for illegal names in dkfigw_set_xxx_by_name() functions and suggests correct value. Verbose mode is turned off by default for new Fig writer structures.

Parameters:
fwp Fig writer structure.
fl Flag to enable/disable.

unsigned long dkfigw_spline_point ( dk_fig_writer_t fwp,
double  x,
double  y,
double  s 
)

Add point to current spline object.

Parameters:
fwp Writer structure.
x X position.
y Y position.
s Approximation/interpolation parameter.
Returns:
Positive number on success, 0 on error.

unsigned long dkfigw_text ( dk_fig_writer_t fwp,
double  x,
double  y,
char *  t,
double  a 
)

Add text.

Parameters:
fwp Writer structure.
x X position.
y Y position.
t Text.
a Rotation in radians.
Returns:
Positive number on success, 0 on error.

int dkfigw_write ( dk_stream_t os,
dk_fig_writer_t fwp 
)

Write Fig file to stream.

Parameters:
os Output stream.
fwp Fig structure.
Returns:
1 on success, 0 on error.

static void init_arrowhead ( dk_fig_ah_t ahp  )  [static]

Initialize arrowhead.

Parameters:
ahp Arrowhead to initialize.

static void init_style ( dk_fig_style_t stp  )  [static]

Initialize style information structure.

Parameters:
stp Structure to initialize.

static void kw_out ( dk_stream_t os,
size_t  n 
) [static]

Write one keyword from the.

  • kw array to output stream.
    Parameters:
    os Output stream.
    n Keyword index.

static int my_str_array_index ( char **  a,
char *  t,
int  c,
unsigned char  ver 
) [static]

Find index of text.

  • t in array
  • a. When in verbose mode, print a warning and a list of allowed texts if the text is not found.
    Parameters:
    a Array of text pointers.
    t Text to find.
    c Flag: Case sensitive (nonzero) or not (0).
    ver Flag: Verbose mode on.
    Returns:
    Index on success, -1 on error.

static void object_delete ( dk_fig_object_t obj  )  [static]

Release memory for Fig object.

Parameters:
obj Object to release.

static dk_fig_object_t* object_new ( dk_fig_writer_t fwp,
unsigned char  ot,
unsigned char  st 
) [static]

Create structure for Fig object.

Parameters:
fwp Fig writer structure.
ot Fig object type.
st Object sub type.
Returns:
Pointer to new object on success, NULL on error.

static void polyline_points ( dk_stream_t os,
dk_fig_writer_t f,
dk_fig_object_t o,
int  flcl 
) [static]

Write polyline points coordinates to output stream.

Parameters:
os Output stream.
f Fig writer structure.
o Current object.
flcl Flag: Closed polygon (repeat first point at end).

static void polyline_start ( dk_stream_t os,
dk_fig_writer_t f,
dk_fig_object_t o,
dk_fig_style_t sty,
unsigned long  np,
int  afw,
int  abw 
) [static]

Write start-of-polyline line to output stream.

Parameters:
os Output stream.
f Fig writer structure.
o Current object.
sty Fig style structure.
np Number of points.
afw Flag: Arrowhead forward.
abw Flag: Arrowhead backward.

static void print_object ( dk_stream_t os,
dk_fig_writer_t f,
dk_fig_object_t o 
) [static]

Print one object to output stream.

Parameters:
os Output stream.
f Fig writer structure.
o Object to print.

static void put_arrow ( dk_stream_t os,
dk_fig_writer_t fwp,
dk_fig_style_t sty,
dk_fig_ah_t ah,
dk_fig_object_t o 
) [static]

Write one arrowhead line to output stream.

Parameters:
os Output stream.
fwp Fig writer structure.
sty Fig style structure.
ah Arrowhead structure.
o Current object.

static void put_double ( dk_stream_t os,
double  d 
) [static]

Put double value to output stream.

Parameters:
os Output stream.
d Value to put.

static void put_int ( dk_stream_t os,
int  i 
) [static]

Put integer value to output stream.

Parameters:
os Output stream.
i Value to put.

static void put_int_range ( dk_stream_t os,
int  i,
int  min,
int  max 
) [static]

Put integer value to output stream, correct value if necessary.

Parameters:
os Output stream.
i Value to put.
min Minimum value.
max Maximum value.

static void put_long ( dk_stream_t os,
long  l 
) [static]

Put long value to output stream.

Parameters:
os Output stream.
l Value to put.

static void put_long_double ( dk_stream_t os,
double  d 
) [static]

Put double value to output stream, use large number of decimal digits.

Parameters:
os Output stream.
d Value to put.

static void put_text ( dk_stream_t os,
char *  txt 
) [static]

Write text contents to output stream, apply conversion if necessary.

Parameters:
os Output stream.
txt Text to write.

static void put_unsigned ( dk_stream_t os,
unsigned  u 
) [static]

Write unsigned number to output stream.

Parameters:
os Output stream.
u Value to write.

static void set_arrowhead ( dk_fig_ah_t ah,
unsigned char  sha,
unsigned char  fil,
double  wid,
double  hei 
) [static]

Set shape, fill type and lengths for one arrowhead.

Parameters:
ah Arrowhead structure.
sha Shape.
fil Fill type.
wid Width.
hei Height

static void spline_points ( dk_stream_t os,
dk_fig_writer_t f,
dk_fig_object_t o 
) [static]

Write points coordinates to output stream.

Parameters:
os Output stream.
f Fig writer structure.
o Current object.

static void spline_start ( dk_stream_t os,
dk_fig_writer_t f,
dk_fig_object_t o,
dk_fig_style_t sty,
unsigned long  np,
int  afw,
int  abw 
) [static]

Write line to start a spline to output stream.

Parameters:
os Output stream.
f Fig writer structure.
o Current object.
sty Fig style structure.
np Number of points.
afw Flag: Arrowhead forward.
abw Flag: Arrowhead backward.

static void stream_putc ( dk_stream_t os,
char  c 
) [static]

Put single character to stream.

Parameters:
os Output stream.
c Character to write.

static int uc_to_int ( unsigned char  uc  )  [static]

Convert unsigned char to integer.

Parameters:
uc Character to convert.
Returns:
Conversion result.

static double x_to_fig_d ( dk_fig_writer_t fwp,
double  x 
) [static]

Convert x position to Fig units.

Parameters:
fwp Fig writer structure.
x X position.
Returns:
The conversion result as double value.

static long x_to_fig_l ( dk_fig_writer_t fwp,
double  x 
) [static]

Convert x position to Fig units.

Parameters:
fwp Fig writer structure.
x X position.
Returns:
The conversion result as long value.

static double y_to_fig_d ( dk_fig_writer_t fwp,
double  y 
) [static]

Convert y position to Fig units.

Parameters:
fwp Fig writer structure.
y Y position.
Returns:
The conversion result as double value.

static long y_to_fig_l ( dk_fig_writer_t fwp,
double  y 
) [static]

Convert y position to Fig units.

Parameters:
fwp Fig writer structure.
y Y position.
Returns:
The conversion result as long value.


Variable Documentation

char* kw[] [static]

Initial value:

 {
        "\n",
        " ",
        "w",
        "#FIG 3.2",
        "Portrait",
        "Landscape",
        "Center",
        "Flush Left",
        "Metric",
        "Inches",
        "100.0",
        "Single",
        "Multiple",
        "1200 2",
        "\t",
        "2 2 0 0 7 7 999 0 -1 0 0 0 0 0 0 5",
        "## *: remove background rectangle = yes",
        "## *: background rectangle color  = white",
        "\\001",
        "\\\\",
        "## *: encoding                    = utf-8",
  NULL
}
Keywords used while producing a Fig file.

char* paper_sizes[] [static]

Initial value:

 {
  "Letter", "Legal", "Ledger", "Tabloid", "A", "B", "C", "D", "E",
  "A4", "A3", "A2", "A1", "A0", "B5",
  NULL
}
Paper size names.

char sccs_id[] = { "@(#)dkfigw.ctr 1.3 10/15/09" } [static]

SCCS ID.

Examples:
stotest.c.

char* suffixes[] [static]

Initial value:

 {
  ".gz", ".bz2", NULL
}
File name suffixes used for compressed files.


Generated on Mon Jan 4 15:50:55 2010 for dklibs by  doxygen 1.5.8