GRASS GIS 7 Programmer's Manual  7.5.svn(2018)-r73103
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
cairodriver.h File Reference

GRASS cairo display driver - header file. More...

#include <grass/config.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <cairo.h>
#include <grass/gis.h>
#include "driver.h"
#include "driverlib.h"
Include dependency graph for cairodriver.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  cairo_state
 

Macros

#define CAIRO_HAS_XLIB_XRENDER_SURFACE   0
 
#define DEFAULT_FILE_NAME   "map.png"
 
#define HEADER_SIZE   64
 
#define COLORSCALE   (1.0/255.0)
 
#define CAIROCOLOR(a)   (((double)(a))*COLORSCALE)
 
#define FTYPE_UNKNOWN   0
 
#define FTYPE_PPM   1
 
#define FTYPE_BMP   2
 
#define FTYPE_PNG   3
 
#define FTYPE_PDF   4
 
#define FTYPE_PS   5
 
#define FTYPE_SVG   6
 
#define FTYPE_X11   7
 

Functions

struct driverCairo_Driver (void)
 Initialize display driver. More...
 
void Cairo_Client_Close (void)
 
int Cairo_Graph_set (void)
 Initialize driver. More...
 
const char * Cairo_Graph_get_file (void)
 Get render file. More...
 
void Cairo_Graph_close (void)
 Close driver. More...
 
void Cairo_Box (double, double, double, double)
 Draw a (filled) rectangle. More...
 
void Cairo_Set_window (double, double, double, double)
 Set window. More...
 
void Cairo_Bitmap (int, int, int, const unsigned char *)
 Draw bitmap. More...
 
void Cairo_Color (int, int, int)
 Set source color (opaque) More...
 
void Cairo_Erase (void)
 Erase screen. More...
 
void Cairo_begin_raster (int, int[2][2], double[2][2])
 Start drawing raster. More...
 
int Cairo_raster (int, int, const unsigned char *, const unsigned char *, const unsigned char *, const unsigned char *)
 Draw raster row. More...
 
void Cairo_end_raster (void)
 Finish drawing raster. More...
 
void Cairo_Begin (void)
 
void Cairo_Move (double, double)
 
void Cairo_Cont (double, double)
 
void Cairo_Close (void)
 
void Cairo_Stroke (void)
 
void Cairo_Fill (void)
 
void Cairo_Point (double, double)
 
void Cairo_Line_width (double)
 Set line width. More...
 
void Cairo_Text (const char *)
 Draw text. More...
 
void Cairo_text_box (const char *, double *, double *, double *, double *)
 
void Cairo_set_font (const char *)
 Set font. More...
 
void Cairo_font_list (char ***, int *)
 Get list of fonts. More...
 
void Cairo_font_info (char ***, int *)
 Get fonts into. More...
 
void cairo_read_image (void)
 
void cairo_read_ppm (void)
 
void cairo_read_bmp (void)
 
void cairo_read_xid (void)
 
void cairo_write_image (void)
 
void cairo_write_ppm (void)
 
void cairo_write_bmp (void)
 
void cairo_write_xid (void)
 

Variables

cairo_surface_t * surface
 
cairo_t * cairo
 
struct cairo_state ca
 

Detailed Description

GRASS cairo display driver - header file.

(C) 2007-2008 by Lars Ahlzen and the GRASS Development Team

This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS for details.

Author
Lars Ahlzen <lars ahlzen.com> (original contibutor)
Glynn Clements

Definition in file cairodriver.h.

Macro Definition Documentation

#define CAIRO_HAS_XLIB_XRENDER_SURFACE   0

Definition at line 28 of file cairodriver.h.

#define CAIROCOLOR (   a)    (((double)(a))*COLORSCALE)

Definition at line 49 of file cairodriver.h.

Referenced by Cairo_Color(), and Cairo_Graph_set().

#define COLORSCALE   (1.0/255.0)

Definition at line 48 of file cairodriver.h.

#define DEFAULT_FILE_NAME   "map.png"

Definition at line 43 of file cairodriver.h.

#define FTYPE_BMP   2

Definition at line 54 of file cairodriver.h.

Referenced by cairo_read_image(), and cairo_write_image().

#define FTYPE_PDF   4

Definition at line 56 of file cairodriver.h.

#define FTYPE_PNG   3

Definition at line 55 of file cairodriver.h.

Referenced by cairo_read_image(), and cairo_write_image().

#define FTYPE_PPM   1

Definition at line 53 of file cairodriver.h.

Referenced by cairo_read_image(), and cairo_write_image().

#define FTYPE_PS   5

Definition at line 57 of file cairodriver.h.

#define FTYPE_SVG   6

Definition at line 58 of file cairodriver.h.

#define FTYPE_UNKNOWN   0

Definition at line 52 of file cairodriver.h.

#define FTYPE_X11   7

Definition at line 59 of file cairodriver.h.

Referenced by Cairo_Graph_close(), cairo_read_image(), and cairo_write_image().

#define HEADER_SIZE   64

Definition at line 45 of file cairodriver.h.

Referenced by cairo_read_bmp(), cairo_write_bmp(), read_bmp(), and write_bmp().

Function Documentation

void Cairo_Begin ( void  )

Definition at line 17 of file cairodriver/draw.c.

References cairo.

Referenced by Cairo_Driver().

void Cairo_begin_raster ( int  mask,
int  s[2][2],
double  d[2][2] 
)

Start drawing raster.

Todo:
are top and left swapped?
Parameters
masknon-zero int for mask
ssource (map) extent (left, right, top, bottom)
ddestination (image) extent (left, right, top, bottom)

Definition at line 76 of file cairodriver/raster.c.

References _, ca, G_debug(), G_fatal_error(), cairo_state::height, int, MAX_IMAGE_SIZE, and cairo_state::width.

Referenced by Cairo_Driver().

void Cairo_Bitmap ( int  ncols,
int  nrows,
int  threshold,
const unsigned char *  buf 
)

Draw bitmap.

Parameters
ncols,nrowsnumber of columns and rows
thresholdthreshold value
bufdata buffer

Definition at line 26 of file cairodriver/draw_bitmap.c.

References _, ca, cairo, cur_x, cur_y, G_debug(), G_fatal_error(), malloc(), and cairo_state::modified.

Referenced by Cairo_Driver().

void Cairo_Box ( double  x1,
double  y1,
double  x2,
double  y2 
)

Draw a (filled) rectangle.

Parameters
x1,y1,x2,y2rectangle coordinates

Definition at line 22 of file cairodriver/box.c.

References ca, cairo, G_debug(), and cairo_state::modified.

Referenced by Cairo_Driver().

void Cairo_Client_Close ( void  )
void Cairo_Close ( void  )

Definition at line 32 of file cairodriver/draw.c.

References cairo.

Referenced by Cairo_Driver().

void Cairo_Color ( int  r,
int  g,
int  b 
)

Set source color (opaque)

This color will then be used for any subsequent drawing operation until a new source pattern is set.

Parameters
rred color value
ggreen color value
bblue color value

Definition at line 27 of file cairodriver/color.c.

References cairo, CAIROCOLOR, and G_debug().

Referenced by Cairo_Driver().

void Cairo_Cont ( double  ,
double   
)

Definition at line 27 of file cairodriver/draw.c.

References cairo.

Referenced by Cairo_Driver().

void Cairo_end_raster ( void  )

Finish drawing raster.

Definition at line 180 of file cairodriver/raster.c.

References ca, cairo, G_debug(), G_free(), and cairo_state::modified.

Referenced by Cairo_Driver().

void Cairo_Erase ( void  )
void Cairo_Fill ( void  )

Definition at line 43 of file cairodriver/draw.c.

References ca, cairo, and cairo_state::modified.

Referenced by Cairo_Driver().

void Cairo_font_info ( char ***  list,
int count 
)

Get fonts into.

Parameters
[out]listfont list
[out]countnumber of items in the list

Definition at line 336 of file cairodriver/text.c.

Referenced by Cairo_Driver().

void Cairo_font_list ( char ***  list,
int count 
)

Get list of fonts.

Parameters
[out]listfont list
[out]countnumber of items in the list

Definition at line 322 of file cairodriver/text.c.

Referenced by Cairo_Driver().

void Cairo_Graph_close ( void  )

Close driver.

Definition at line 301 of file cairodriver/graph.c.

References ca, cairo, cairo_write_image(), cairo_state::file_type, FTYPE_X11, G_debug(), cairo_state::mapped, NULL, and surface.

Referenced by Cairo_Driver().

const char* Cairo_Graph_get_file ( void  )

Get render file.

Returns
file name

Definition at line 293 of file cairodriver/graph.c.

References ca, and cairo_state::file_name.

Referenced by Cairo_Driver().

int Cairo_Graph_set ( void  )

Initialize driver.

Set background color, transparency, drawable, antialias mode, etc.

Returns
0

Definition at line 236 of file cairodriver/graph.c.

References cairo_state::bgcolor_a, cairo_state::bgcolor_b, cairo_state::bgcolor_g, cairo_state::bgcolor_r, ca, cairo, CAIROCOLOR, G_debug(), G_fatal_error(), G_gisinit, G_str_to_color(), G_strcasecmp(), and getenv().

Referenced by Cairo_Driver().

void Cairo_Line_width ( double  width)

Set line width.

Parameters
widthline width (double precision)

Definition at line 30 of file cairodriver/line_width.c.

References cairo, G_debug(), MAX, and MIN_WIDTH.

Referenced by Cairo_Driver().

void Cairo_Move ( double  ,
double   
)

Definition at line 22 of file cairodriver/draw.c.

References cairo.

Referenced by Cairo_Driver().

void Cairo_Point ( double  ,
double   
)

Definition at line 49 of file cairodriver/draw.c.

References ca, cairo, and cairo_state::modified.

Referenced by Cairo_Driver().

int Cairo_raster ( int  n,
int  row,
const unsigned char *  red,
const unsigned char *  grn,
const unsigned char *  blu,
const unsigned char *  nul 
)

Draw raster row.

Parameters
nnumber of cells
rowraster row (starting at 0)
red,grn,blu,nulred,green,blue and null value
Returns
next row

Definition at line 132 of file cairodriver/raster.c.

References b, ca, g, G_debug(), cairo_state::height, MAX, MIN, cairo_state::modified, r, cairo_state::width, and x.

Referenced by Cairo_Driver().

void cairo_read_bmp ( void  )
void cairo_read_ppm ( void  )
void cairo_read_xid ( void  )

Definition at line 5 of file read_xid.c.

References _, ca, fclose(), cairo_state::file_name, and G_fatal_error().

Referenced by cairo_read_image().

void Cairo_set_font ( const char *  name)

Set font.

Parameters
namefont name

Definition at line 282 of file cairodriver/text.c.

Referenced by Cairo_Driver().

void Cairo_Set_window ( double  t,
double  b,
double  l,
double  r 
)

Set window.

Parameters
t,b,l,rtop, bottom, left, right

Definition at line 22 of file cairodriver/set_window.c.

References cairo, and G_debug().

Referenced by Cairo_Driver().

void Cairo_Stroke ( void  )

Definition at line 37 of file cairodriver/draw.c.

References ca, cairo, and cairo_state::modified.

Referenced by Cairo_Driver().

void Cairo_Text ( const char *  str)

Draw text.

Parameters
strstring to be drawn

Definition at line 102 of file cairodriver/text.c.

References ca, cairo, cur_x, cur_y, G_free(), and cairo_state::modified.

Referenced by Cairo_Driver().

void Cairo_text_box ( const char *  ,
double *  ,
double *  ,
double *  ,
double *   
)

Definition at line 125 of file cairodriver/text.c.

References cairo, cur_x, cur_y, and G_free().

Referenced by Cairo_Driver().

void cairo_write_bmp ( void  )
void cairo_write_xid ( void  )

Definition at line 6 of file write_xid.c.

References _, ca, fclose(), cairo_state::file_name, and G_fatal_error().

Referenced by cairo_write_image().

Variable Documentation

cairo_surface_t* surface

Definition at line 45 of file cairodriver/graph.c.

Referenced by Cairo_Graph_close(), cairo_read_image(), and cairo_write_image().