GwyGraphBasics

GwyGraphBasics — Common graph functions and utilities

Functions

Types and Values

Includes

#include <libgwydgets/gwydgets.h>

Description

Functions

gwy_graph_get_preset_color()

const GwyRGBA *
gwy_graph_get_preset_color (guint i);

Gets a preset graph colour.

Preset colours are a set of selected colours one can use to distingush graph curves when there is no reason to prefer a particular colour. Note that the preset colours are not guaranteed to never change (including their total number), although it happens rarely.

Parameters

i

Colour number, starting from 0 which is always black. It can be any number but colours start to repeat after gwy_graph_get_n_preset_colors() colours.

 

Returns

A constant colour that must not be neither modified nor freed.


gwy_graph_get_n_preset_colors()

guint
gwy_graph_get_n_preset_colors (void);

Gets the number of distinct colors gwy_graph_get_preset_color() can return.

Returns

The number of distinct colors.


gwy_graph_draw_point()

void
gwy_graph_draw_point (cairo_t *cr,
                      gdouble x,
                      gdouble y,
                      GwyGraphPointType type,
                      gdouble size,
                      const GwyRGBA *color);

Draws a point on a drawable.

Parameters

cr

Cairo context.

 

x

X coordinate of the point.

 

y

Y coordinate of the point.

 

type

graph point type

 

size

point size

 

color

point color

 

gwy_graph_draw_line()

void
gwy_graph_draw_line (cairo_t *cr,
                     gdouble x_from,
                     gdouble y_from,
                     gdouble x_to,
                     gdouble y_to,
                     GwyGraphLineStyle line_style,
                     gdouble line_width,
                     const GwyRGBA *color);

Draws a line segment on a drawable.

Parameters

cr

Cairo context.

 

x_from

x coordinate of the start point of the line

 

y_from

y coordinate of the start point of the line

 

x_to

x coordinate of the end point of the line

 

y_to

y coordinate of the end point of the line

 

line_style

graph line style

 

size

point size

 

color

point color

 

gwy_graph_draw_curve()

void
gwy_graph_draw_curve (cairo_t *cr,
                      GwyGraphActiveAreaSpecs *specs,
                      GwyGraphCurveModel *gcmodel);

Draws a single graph curve on a drawable.

Parameters

cr

Cairo context.

 

specs

Specifications (boundaries) of the active area of the graph.

 

gcmodel

Curve model of the curve to draw.

 

gwy_graph_draw_selection_points()

void
gwy_graph_draw_selection_points (cairo_t *cr,
                                 GwyGraphActiveAreaSpecs *specs,
                                 GwySelectionPoint *selection);

Draws selection points on a drawable.

Parameters

cr

Cairo context.

 

specs

Specifications (boundaries) of the active area of the graph.

 

selection

A selection of type GwySelectionPoint.

 

gwy_graph_draw_selection_areas()

void
gwy_graph_draw_selection_areas (cairo_t *cr,
                                GwyGraphActiveAreaSpecs *specs,
                                GwySelectionRectangle *selection);

Draws selected area on a drawable.

Parameters

cr

Cairo context.

 

specs

Specifications (boundaries) of the active area of the graph.

 

selection

A selection of type GwySelectionRectangle.

 

gwy_graph_draw_selection_lines()

void
gwy_graph_draw_selection_lines (cairo_t *cr,
                                GwyGraphActiveAreaSpecs *specs,
                                GwySelectionAxis *selection,
                                GtkOrientation orientation);

Draws selected lines on a drawable.

Parameters

cr

Cairo context.

 

specs

Specifications (boundaries) of the active area of the graph.

 

selection

a GwySelectionAxis structure

 

orientation

horizontal or vertical orientation

 

gwy_graph_draw_selection_xareas()

void
gwy_graph_draw_selection_xareas (cairo_t *cr,
                                 GwyGraphActiveAreaSpecs *specs,
                                 GwySelectionRange *selection);

Draws selected x-area on a drawable.

Parameters

cr

Cairo context.

 

specs

Specifications (boundaries) of the active area of the graph.

 

selection

A selection of type GwySelectionRange.

 

gwy_graph_draw_selection_yareas()

void
gwy_graph_draw_selection_yareas (cairo_t *cr,
                                 GwyGraphActiveAreaSpecs *specs,
                                 GwySelectionRange *selection);

Drawss selected y-area on a drawable.

Parameters

cr

Cairo context.

 

specs

Specifications (boundaries) of the active area of the graph.

 

selection

A selection of type GwySelectionRange.

 

gwy_graph_draw_grid()

void
gwy_graph_draw_grid (cairo_t *cr,
                     GwyGraphActiveAreaSpecs *specs,
                     const gdouble *x_grid_data,
                     guint nxdata,
                     const gdouble *y_grid_data,
                     guint nydata);

Draws an array of grid lines on a drawable.

Parameters

cr

Cairo context.

 

specs

Specifications (boundaries) of the active area of the graph.

 

x_grid_data

Array of grid data for the x-axis, it can be NULL if nxdata is zero.

 

nxdata

Number of x grid positions.

 

y_grid_data

Array of grid data for the y-axis, it can be NULL if nydata is zero.

 

nydata

Number of y grid positions.

 

Types and Values

GwyGraphActiveAreaSpecs

typedef struct {
    GdkRectangle area;
    gdouble real_xmin;
    gdouble real_ymin;
    /* FIXME: This is weird for non-linear mapping. Just store the bloody endpoints! */
    gdouble real_height;
    gdouble real_width;
    gboolean log_x;
    gboolean log_y;
} GwyGraphActiveAreaSpecs;

Graph area specification (for graph drawing primitives).

Members

GdkRectangle area;

   

gdouble real_xmin;

Minimum x value in real units.

 

gdouble real_ymin;

Minimum y value in real units.

 

gdouble real_height;

Area height in real units.

 

gdouble real_width;

Area width in real units.

 

gboolean log_x;

TRUE if x-axis is logarithmic.

 

gboolean log_y;

TRUE if y-axis is logarithmic.