GRASS GIS 7 Programmer's Manual  7.5.svn(2017)-r71759
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
iscatt_core.c File Reference

Imagery library - wx.iscatt (wx Interactive Scatter Plot Tool) backend. More...

#include <stdio.h>
#include <string.h>
#include <math.h>
#include <grass/gis.h>
#include <grass/vector.h>
#include <grass/raster.h>
#include <grass/imagery.h>
#include <grass/glocale.h>
#include "iclass_local_proto.h"
Include dependency graph for iscatt_core.c:

Go to the source code of this file.

Functions

int I_create_cat_rast (struct Cell_head *cat_rast_region, const char *cat_rast)
 Create category raster conditions file. The file is used for holding selected areas from mapwindow. The reason why the standard GRASS raster is not used is that for every modification (new area is selected) we would need to create whole new raster. Instead of this scatter plot only modifies affected region in the internal pgm file. More...
 
int I_insert_patch_to_cat_rast (const char *patch_rast, struct Cell_head *cat_rast_region, const char *cat_rast)
 Insert raster map patch into pgm file. More...
 
int I_compute_scatts (struct Cell_head *region, struct scCats *scatt_conds, const char **cats_rasts_conds, const char **bands, int n_bands, struct scCats *scatts, const char **cats_rasts)
 Compute scatter plots data. More...
 
int I_merge_arrays (unsigned char *merged_arr, unsigned char *overlay_arr, unsigned rows, unsigned cols, double alpha)
 Merge arrays according to opacity. Every pixel in array must be represented by 4 values (RGBA). More...
 
int I_apply_colormap (unsigned char *vals, unsigned char *vals_mask, unsigned nvals, unsigned char *colmap, unsigned char *col_vals)
 Apply colromap to the raster. More...
 
int I_rasterize (double *polygon, int pol_n_pts, unsigned char val, struct Cell_head *rast_region, unsigned char *rast)
 Wrapper for using of iclass perimeter rasterization by scatter plot. Warning: calls Rast_set_window. More...
 

Detailed Description

Imagery library - wx.iscatt (wx Interactive Scatter Plot Tool) backend.

Copyright (C) 2013 by 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
Stepan Turek stepa.nosp@m.n.tu.nosp@m.rek@s.nosp@m.ezna.nosp@m.m.cz (GSoC 2013, Mentor: Martin Landa)

Definition in file iscatt_core.c.

Function Documentation

int I_apply_colormap ( unsigned char *  vals,
unsigned char *  vals_mask,
unsigned  nvals,
unsigned char *  colmap,
unsigned char *  col_vals 
)

Apply colromap to the raster.

Implementd for speeding up of scatter plots rendering.

Parameters
valsarray of values for applying the colormap
vals_maskmaks of vals array
nvalsnumber of items of vals_mask and vals array
colmapcolour map to be applied
[out]col_valsoutput raster with applied color map (length is 4 * nvals (RGBA))
Returns
0

Definition at line 905 of file iscatt_core.c.

int I_compute_scatts ( struct Cell_head region,
struct scCats scatt_conds,
const char **  cats_rasts_conds,
const char **  bands,
int  n_bands,
struct scCats scatts,
const char **  cats_rasts 
)

Compute scatter plots data.

If category has not defined category raster condition file and no scatter plot exists with condition, default/full scatter plot is computed. Warning: calls Rast_set_window

Parameters
regionanalysis region, beaware that all input data must be prepared for this region (bands (their ranges), cats_rasts_conds rasters...)
regionfunction calls Rast_set_window for this region
scatt_condspointer to scScatts struct of type SC_SCATT_CONDITIONS, where are stored selected areas (conditions) in scatter plots
cats_rasts_condspaths to category raster conditions files representing selected areas from mapwindow (conditions) in rasters for every category
cats_rasts_condsindex in array represents corresponding category id
cats_rasts_condsfor manipulation with category raster conditions file see also I_id_scatt_to_bands and I_insert_patch_to_cat_rast
bandsnames of analyzed bands, order of bands is defined by their id
n_bandsnumber of bands
[out]scattspointer to scScatts struct of type SC_SCATT_DATA, where are computed scatter plots stored
[out]cats_rastsarray of raster maps names for every category where will be stored all selected pixels
Returns
0 on success
-1 on failure

Definition at line 695 of file iscatt_core.c.

References _, scCats::cats_ids, CELL_TYPE, G_debug(), G_find_raster2(), G_warning(), G_zero(), scCats::n_a_cats, scCats::n_bands, NULL, Rast_allocate_c_buf(), Rast_allocate_null_buf(), Rast_get_c_row(), Rast_get_map_type(), Rast_get_null_value_row(), Rast_open_new(), Rast_open_old(), Rast_read_range(), Rast_set_window(), and Rast_window_rows().

int I_create_cat_rast ( struct Cell_head cat_rast_region,
const char *  cat_rast 
)

Create category raster conditions file. The file is used for holding selected areas from mapwindow. The reason why the standard GRASS raster is not used is that for every modification (new area is selected) we would need to create whole new raster. Instead of this scatter plot only modifies affected region in the internal pgm file.

Parameters
cat_rast_regionregion to be file generated for
[out]cat_rastpath where the pgm raster file will be generated

Definition at line 58 of file iscatt_core.c.

References _, Cell_head::cols, fclose(), G_warning(), and Cell_head::rows.

int I_insert_patch_to_cat_rast ( const char *  patch_rast,
struct Cell_head cat_rast_region,
const char *  cat_rast 
)

Insert raster map patch into pgm file.

See Also
I_create_cat_rast

Warning: calls Rast_set_window

Parameters
patch_rastname of raster map
cat_rast_regionregion of category raster file
cat_rastpath to category raster file
Returns
0 on success
-1 on failure

Definition at line 236 of file iscatt_core.c.

References _, Cell_head::cols, Cell_head::east, fclose(), G_find_raster(), G_free(), G_warning(), Cell_head::north, NULL, Rast_allocate_null_buf(), Rast_close(), Rast_get_cellhd(), Rast_get_null_value_row(), Rast_open_old(), Rast_set_window(), Cell_head::south, and Cell_head::west.

int I_merge_arrays ( unsigned char *  merged_arr,
unsigned char *  overlay_arr,
unsigned  rows,
unsigned  cols,
double  alpha 
)

Merge arrays according to opacity. Every pixel in array must be represented by 4 values (RGBA).

Implementd for speeding up of scatter plots rendering.

Parameters
merged_arrarray which will be overlayd with overlay_arr
overlay_arrarray to be merged_arr overlaid with
rowsnumber of rows for the both arrays
colsnumber of columns for the both arrays
alphatransparency (0-1) of the overlay array for merging
Returns
0

Definition at line 862 of file iscatt_core.c.

References int.

int I_rasterize ( double *  polygon,
int  pol_n_pts,
unsigned char  val,
struct Cell_head rast_region,
unsigned char *  rast 
)

Wrapper for using of iclass perimeter rasterization by scatter plot. Warning: calls Rast_set_window.

Parameters
polygonarray of polygon coordinates [x, y, x, y...]
pol_n_ptsnumber of points in the polygon array
valvalue to be assigned to cells, which belong to plygon
rast_regionregion of raster
[out]rastraster to be pologyn rasterized in
Returns
0 on success
1 on failure

Definition at line 948 of file iscatt_core.c.

References _, Cell_head::cols, G_free(), G_warning(), make_perimeter(), Cell_head::rows, Vect_append_point(), Vect_destroy_line_struct(), Vect_new_line_struct(), and line_pnts::y.