map

map — Describe how to handle and draw coloured map on a plane from a density field.

Synopsis

                    VisuMap;
enum                VisuMapExportFormat;
void                visu_map_compute                    (VisuMap *map);
void                visu_map_draw                       (VisuMap *map,
                                                         float prec,
                                                         ToolShade *shade,
                                                         float *rgb,
                                                         gboolean alpha);
gboolean            visu_map_export                     (VisuMap *map,
                                                         ToolShade *shade,
                                                         float *rgb,
                                                         float precision,
                                                         gchar *filename,
                                                         VisuMapExportFormat format,
                                                         GError **error);
void                visu_map_free                       (VisuMap *map);
float *             visu_map_getFieldMinMax             (VisuMap *map);
VisuPlane *         visu_map_getPlane                   (VisuMap *map);
float *             visu_map_getScaledMinMax            (VisuMap *map);
void                visu_map_init                       ();
VisuMap *           visu_map_new                        ();
VisuMap *           visu_map_newFromPlane               (VisuPlane *plane);
VisuMap *           visu_map_ref                        (VisuMap *map);
gboolean            visu_map_setField                   (VisuMap *map,
                                                         VisuScalarField *field,
                                                         ToolMatrixScalingFlag scale,
                                                         float *inputMinMax);
gboolean            visu_map_setLevel                   (VisuMap *map,
                                                         float glPrec,
                                                         float gross,
                                                         float refLength);
gboolean            visu_map_setLines                   (VisuMap *map,
                                                         guint nIsoLines,
                                                         float minmax[2]);
gboolean            visu_map_setPlane                   (VisuMap *map,
                                                         VisuPlane *plane);
void                visu_map_unref                      (VisuMap *map);

Object Hierarchy

  GBoxed
   +----VisuMap

Description

A map is a coloured representation of a scalar field on a plane. To define a new map, use visu_map_newFromPlane() and use visu_map_setField() to associate a scalarfield to it.

The representation of the map is done by an adaptive mesh of triangles. One can adjust the size of the smaller resolution by using visu_map_setLevel(). Finally the level of adaptiveness is chosen at rendering time by choosing a more or less crude precision argument to visu_map_draw().

In adition to the colour representation, isolines can be drawn at given iso-values, see visu_map_setLines().

An additionnal capability allows to export VisuMap into SVG or PDF vector files.

Details

VisuMap

typedef struct _VisuMap VisuMap;

All fields are private.

Since 3.6


enum VisuMapExportFormat

typedef enum {
    VISU_MAP_EXPORT_SVG,
    VISU_MAP_EXPORT_PDF
} VisuMapExportFormat;

Possible export for the map, see visu_map_export().

VISU_MAP_EXPORT_SVG

SVG export ;

VISU_MAP_EXPORT_PDF

PDF export.

Since 3.6


visu_map_compute ()

void                visu_map_compute                    (VisuMap *map);

After a VisuPlane and a VisuScalarField has been defined (see visu_map_newFromPlane() and visu_map_setField()), the map is computed by refining a triangle approximation up to level defined by visu_map_setLevel(). The evaluation is lazy and calculation is indeed done, only if required level is lower than actual level. Calculation is done only for missing levels anyway.

map :

a VisuMap object.

Since 3.6


visu_map_draw ()

void                visu_map_draw                       (VisuMap *map,
                                                         float prec,
                                                         ToolShade *shade,
                                                         float *rgb,
                                                         gboolean alpha);

It draws the map with the given shade. prec give the level of refinement used to draw the map, 100 means normal and 200 means twice smaller level. If rgb is present, this colour is used for possible isolines. If alpha is TRUE, an alpha channel is added as a linear variation of the value of each vertex.

map :

a VisuMap object.

prec :

a pourcentage value.

shade :

a ToolShade object.

rgb :

a colour or NULL.

alpha :

a boolean.

Since 3.6


visu_map_export ()

gboolean            visu_map_export                     (VisuMap *map,
                                                         ToolShade *shade,
                                                         float *rgb,
                                                         float precision,
                                                         gchar *filename,
                                                         VisuMapExportFormat format,
                                                         GError **error);

Export the given map to the format, using the shade color. If rgb is provided and map has some isolines, they will be drawn with this colour, otherwise an inverse colour is used.

map :

a VisuMap object.

shade :

a ToolShade object.

rgb :

a colour (can be NULL).

precision :

a pourcentage for rendering quality.

filename :

the location to export to.

format :

the kind of format.

error :

a location to store an error.

Returns :

TRUE if no error.

Since 3.6


visu_map_free ()

void                visu_map_free                       (VisuMap *map);

Deallocate all memory related to map.

map :

a VisuMap object.

Since 3.6


visu_map_getFieldMinMax ()

float *             visu_map_getFieldMinMax             (VisuMap *map);

After map has been computed by visu_map_compute(), one can access the min and max values of the field as represented in the map. For scaled values, see visu_map_getScaledMinMax().

map :

a VisuMap object.

Returns :

two floats being the min and the max.

Since 3.6


visu_map_getPlane ()

VisuPlane *         visu_map_getPlane                   (VisuMap *map);

Retrieves the plane map is based on.

map :

a VisuMap object.

Returns :

a VisuPlane or NULL. [transfer none][allow-none]

Since 3.7


visu_map_getScaledMinMax ()

float *             visu_map_getScaledMinMax            (VisuMap *map);

After map has been computed by visu_map_compute(), one can access the scaled min and max values represented in the map. For field values, see visu_map_getFieldMinMax().

map :

a VisuMap object.

Returns :

two floats being the min and the max in [0;1].

Since 3.6


visu_map_init ()

void                visu_map_init                       ();

Initialise the map routines. Should not be called except at initialisation time.

Since 3.7


visu_map_new ()

VisuMap *           visu_map_new                        ();

Creates a new VisuMap object.

Returns :

a newly created VisuMap object. [transfer full]

Since 3.6


visu_map_newFromPlane ()

VisuMap *           visu_map_newFromPlane               (VisuPlane *plane);

Creates a new VisuMap object, projected on plane.

plane :

a VisuPlane object.

Returns :

a newly created VisuMap object.

Since 3.6


visu_map_ref ()

VisuMap *           visu_map_ref                        (VisuMap *map);

Increase the ref counter.

map :

a VisuMap object.

Returns :

itself.

Since 3.7


visu_map_setField ()

gboolean            visu_map_setField                   (VisuMap *map,
                                                         VisuScalarField *field,
                                                         ToolMatrixScalingFlag scale,
                                                         float *inputMinMax);

It associates the values of field to map. The calculation is not directly done, and a call to visu_map_compute() is necessary. If inputMinMax is provided, these values are used to scale the values of field to [0;1], otherwise the minMax values of the field itself are used. The scaling algorithm is defined by scale.

map :

a VisuMap object.

field :

a VisuScalarField object.

scale :

a flag.

inputMinMax :

two floats or NULL.

Returns :

TRUE if field is changed.

Since 3.6


visu_map_setLevel ()

gboolean            visu_map_setLevel                   (VisuMap *map,
                                                         float glPrec,
                                                         float gross,
                                                         float refLength);

Setup the level of recursivity in triangle calculation, depending on the current zoom level.

map :

a VisuMap object.

glPrec :

the global OpenGL precision for drawing (default is 1.).

gross :

current zoom level.

refLength :

a reference length (see visu_gl_camera_getRefLength()).

Returns :

TRUE if the level is actually changed.

Since 3.6


visu_map_setLines ()

gboolean            visu_map_setLines                   (VisuMap *map,
                                                         guint nIsoLines,
                                                         float minmax[2]);

Calculate nIsoLines equally distributed in minmax.

map :

a VisuMap object.

nIsoLines :

number of required isolines.

minmax :

span for isoline values.

Returns :

TRUE if lines are successfully calculated.

Since 3.6


visu_map_setPlane ()

gboolean            visu_map_setPlane                   (VisuMap *map,
                                                         VisuPlane *plane);

Set the internal VisuPlane of map to plane. All changed to plane will be automatically propagated to map. Use visu_map_setField() to choose the field to take values from, set the level precision with visu_map_setLevel() and finally call visu_map_compute() to get the map.

map :

a VisuMap object.

plane :

a VisuPlane object. [transfer full][allow-none]

Returns :

TRUE if internal plane is changed.

Since 3.7


visu_map_unref ()

void                visu_map_unref                      (VisuMap *map);

Decrease the ref counter, free all memory if counter reachs zero.

map :

a VisuMap object.

Since 3.7