grass  7.8.6
About: GRASS (Geographic Resources Analysis Support System) is a raster- and vector-based GIS, image processing system, graphics production system and spatial modeling system.
  Fossies Dox: grass-7.8.6.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

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.

Classes

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

const 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

◆ CAIRO_HAS_XLIB_XRENDER_SURFACE

#define CAIRO_HAS_XLIB_XRENDER_SURFACE   0

Definition at line 28 of file cairodriver.h.

◆ CAIROCOLOR

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

Definition at line 49 of file cairodriver.h.

◆ COLORSCALE

#define COLORSCALE   (1.0/255.0)

Definition at line 48 of file cairodriver.h.

◆ DEFAULT_FILE_NAME

#define DEFAULT_FILE_NAME   "map.png"

Definition at line 43 of file cairodriver.h.

◆ FTYPE_BMP

#define FTYPE_BMP   2

Definition at line 54 of file cairodriver.h.

◆ FTYPE_PDF

#define FTYPE_PDF   4

Definition at line 56 of file cairodriver.h.

◆ FTYPE_PNG

#define FTYPE_PNG   3

Definition at line 55 of file cairodriver.h.

◆ FTYPE_PPM

#define FTYPE_PPM   1

Definition at line 53 of file cairodriver.h.

◆ FTYPE_PS

#define FTYPE_PS   5

Definition at line 57 of file cairodriver.h.

◆ FTYPE_SVG

#define FTYPE_SVG   6

Definition at line 58 of file cairodriver.h.

◆ FTYPE_UNKNOWN

#define FTYPE_UNKNOWN   0

Definition at line 52 of file cairodriver.h.

◆ FTYPE_X11

#define FTYPE_X11   7

Definition at line 59 of file cairodriver.h.

◆ HEADER_SIZE

#define HEADER_SIZE   64

Definition at line 45 of file cairodriver.h.

Function Documentation

◆ Cairo_Begin()

void Cairo_Begin ( void  )

Definition at line 17 of file draw.c.

References cairo.

Referenced by Cairo_Driver().

◆ Cairo_begin_raster()

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 raster.c.

References _, ca, ca_row, d, dst_b, dst_h, dst_l, dst_r, dst_t, dst_w, G_debug(), G_fatal_error(), cairo_state::height, masked, MAX_IMAGE_SIZE, s, scale_rev_x(), src_b, src_data, src_h, src_l, src_r, src_stride, src_surf, src_t, src_w, trans, and cairo_state::width.

Referenced by Cairo_Driver().

◆ Cairo_Bitmap()

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 draw_bitmap.c.

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

Referenced by Cairo_Driver().

◆ Cairo_Box()

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 box.c.

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

Referenced by Cairo_Driver().

◆ Cairo_Client_Close()

void Cairo_Client_Close ( void  )

◆ Cairo_Close()

void Cairo_Close ( void  )

Definition at line 32 of file draw.c.

References cairo.

Referenced by Cairo_Driver().

◆ Cairo_Color()

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 color.c.

References b, cairo, CAIROCOLOR, g, G_debug(), and r.

Referenced by Cairo_Driver().

◆ Cairo_Cont()

void Cairo_Cont ( double  x,
double  y 
)

Definition at line 27 of file draw.c.

References cairo, and x.

Referenced by Cairo_Driver().

◆ Cairo_Driver()

◆ Cairo_end_raster()

void Cairo_end_raster ( void  )

Finish drawing raster.

Definition at line 180 of file raster.c.

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

Referenced by Cairo_Driver().

◆ Cairo_Erase()

void Cairo_Erase ( void  )

◆ Cairo_Fill()

void Cairo_Fill ( void  )

Definition at line 43 of file draw.c.

References ca, cairo, and cairo_state::modified.

Referenced by Cairo_Driver().

◆ Cairo_font_info()

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 341 of file text.c.

References count, and font_list_toy().

Referenced by Cairo_Driver().

◆ Cairo_font_list()

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 327 of file text.c.

References count, and font_list_toy().

Referenced by Cairo_Driver().

◆ Cairo_Graph_close()

void Cairo_Graph_close ( void  )

Close driver.

Definition at line 301 of file graph.c.

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

Referenced by Cairo_Driver().

◆ Cairo_Graph_get_file()

const char * Cairo_Graph_get_file ( void  )

Get render file.

Returns
file name

Definition at line 293 of file graph.c.

References ca, and cairo_state::file_name.

Referenced by Cairo_Driver().

◆ Cairo_Graph_set()

int Cairo_Graph_set ( void  )

Initialize driver.

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

Returns
0

Definition at line 236 of file 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(), getenv(), and init_file().

Referenced by Cairo_Driver().

◆ Cairo_Line_width()

void Cairo_Line_width ( double  width)

Set line width.

Parameters
widthline width (double precision)

Definition at line 30 of file line_width.c.

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

Referenced by Cairo_Driver().

◆ Cairo_Move()

void Cairo_Move ( double  x,
double  y 
)

Definition at line 22 of file draw.c.

References cairo, and x.

Referenced by Cairo_Driver().

◆ Cairo_Point()

void Cairo_Point ( double  x,
double  y 
)

Definition at line 49 of file draw.c.

References ca, cairo, cairo_state::modified, and x.

Referenced by Cairo_Driver().

◆ Cairo_raster()

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 raster.c.

References a, b, c, ca, ca_row, dst_l, dst_w, g, G_debug(), cairo_state::height, masked, MAX, MIN, cairo_state::modified, next_row(), r, scale_fwd_y(), src_data, src_stride, trans, cairo_state::width, x, x0, and x1.

Referenced by Cairo_Driver().

◆ cairo_read_bmp()

void cairo_read_bmp ( void  )

◆ cairo_read_image()

◆ cairo_read_ppm()

void cairo_read_ppm ( void  )

◆ cairo_read_xid()

void cairo_read_xid ( void  )

Definition at line 5 of file read_xid.c.

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

Referenced by cairo_read_image(), and init_file().

◆ Cairo_set_font()

void Cairo_set_font ( const char *  name)

Set font.

Parameters
namefont name

Definition at line 287 of file text.c.

References is_toy_font(), name, and set_font_toy().

Referenced by Cairo_Driver().

◆ Cairo_Set_window()

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 set_window.c.

References b, cairo, G_debug(), l, r, and t.

Referenced by Cairo_Driver().

◆ Cairo_Stroke()

void Cairo_Stroke ( void  )

Definition at line 37 of file draw.c.

References ca, cairo, and cairo_state::modified.

Referenced by Cairo_Driver().

◆ Cairo_Text()

void Cairo_Text ( const char *  str)

Draw text.

Parameters
strstring to be drawn

Definition at line 107 of file text.c.

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

Referenced by Cairo_Driver().

◆ Cairo_text_box()

void Cairo_text_box ( const char *  str,
double *  t,
double *  b,
double *  l,
double *  r 
)

Definition at line 130 of file text.c.

References b, cairo, convert(), cur_x, cur_y, G_free(), l, r, set_matrix(), and t.

Referenced by Cairo_Driver().

◆ cairo_write_bmp()

void cairo_write_bmp ( void  )

◆ cairo_write_image()

◆ cairo_write_ppm()

void cairo_write_ppm ( void  )

◆ cairo_write_xid()

void cairo_write_xid ( void  )

Definition at line 6 of file write_xid.c.

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

Referenced by cairo_write_image().

Variable Documentation

◆ ca

◆ cairo

◆ surface

cairo_surface_t* surface
extern

Definition at line 45 of file graph.c.

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