GRASS GIS 8 Programmer's Manual  8.5.0dev(2024)-d6dec75dd4
gsd_objs.c File Reference
#include <stdlib.h>
#include <string.h>
#include <grass/gis.h>
#include <grass/ogsf.h>
#include "gsget.h"
#include "math.h"
#include "rowcol.h"
Include dependency graph for gsd_objs.c:

Go to the source code of this file.

Macros

#define ONORM   .57445626
 
#define UP_NORM   Octo[2]
 
#define DOWN_NORM   Octo[5]
 
#define ORIGIN   origin
 

Functions

void gsd_plus (float *center, int colr, float siz)
 ADD. More...
 
void gsd_line_onsurf (geosurf *gs, float *v1, float *v2)
 Line on surface, fix z-values. More...
 
int gsd_nline_onsurf (geosurf *gs, float *v1, float *v2, float *pt, int n)
 Multiline on surface, fix z-values. More...
 
void gsd_x (geosurf *gs, float *center, int colr, float siz)
 Draw X symbol. More...
 
void gsd_diamond (float *center, unsigned long colr, float siz)
 Draw diamond symbol. More...
 
void gsd_cube (float *center, unsigned long colr, float siz)
 Draw cube. More...
 
void gsd_draw_box (float *center, unsigned long colr, float siz)
 Draw box. More...
 
void gsd_drawsphere (float *center, unsigned long colr, float siz)
 Draw sphere. More...
 
void gsd_diamond_lines (void)
 Draw diamond lines. More...
 
void gsd_draw_asterisk (float *center, unsigned long colr, float siz)
 Draw asterisk. More...
 
void gsd_draw_gyro (float *center, unsigned long colr, float siz)
 Draw gyro. More...
 
void gsd_3dcursor (float *pt)
 Draw 3d cursor. More...
 
void dir_to_slope_aspect (float *dir, float *slope, float *aspect, int degrees)
 ADD. More...
 
int gsd_north_arrow (float *pos2, float len, GLuint fontbase, unsigned long arw_clr, unsigned long text_clr)
 Draw North Arrow takes OpenGL coords and size. More...
 
int gsd_arrow (float *center, unsigned long colr, float siz, float *dir, float sz, geosurf *onsurf)
 ADD. More...
 
int gsd_arrow_onsurf (float *base, float *tip, unsigned long colr, int wid, geosurf *gs)
 Draw north arrow on surface. More...
 
void gsd_3darrow (float *center, unsigned long colr, float siz1, float siz2, float *dir, float sz)
 Draw 3d north arrow. More...
 
int gsd_scalebar (float *pos2, float len, GLuint fontbase, unsigned long bar_clr, unsigned long text_clr)
 Draw Scalebar takes OpenGL coords and size. More...
 
int gsd_scalebar_v2 (float *pos, float len, GLuint fontbase UNUSED, unsigned long bar_clr, unsigned long text_clr UNUSED)
 Draw Scalebar (as lines) More...
 
void primitive_cone (unsigned long col)
 Primitives only called after transforms. More...
 
void primitive_cylinder (unsigned long col, int caps)
 Primitives only called after transforms. More...
 
void gsd_box (float *center, int colr, float *siz)
 Draw box. More...
 

Variables

float Octo [6][3]
 vertices for octahedron More...
 
float OctoN [8][3]
 normals for flat-shaded octahedron More...
 
float CubeNormals [3][3] = {{0, -ONORM, 0}, {0, 0, ONORM}, {ONORM, 0, 0}}
 
float CubeVertices [8][3]
 
float origin [3] = {0.0, 0.0, 0.0}
 
float ogverts [8][3]
 vertices & normals for octagon in xy plane More...
 
float ogvertsplus [8][3]
 vertices for octagon in xy plane, z=1 More...
 
float Pi
 
float Box [8][3]
 Vertices for box. More...
 
float BoxN [6][3]
 

Macro Definition Documentation

◆ DOWN_NORM

#define DOWN_NORM   Octo[5]

Definition at line 69 of file gsd_objs.c.

◆ ONORM

#define ONORM   .57445626

Definition at line 37 of file gsd_objs.c.

◆ ORIGIN

#define ORIGIN   origin

Definition at line 70 of file gsd_objs.c.

◆ UP_NORM

#define UP_NORM   Octo[2]

Definition at line 68 of file gsd_objs.c.

Function Documentation

◆ dir_to_slope_aspect()

void dir_to_slope_aspect ( float *  dir,
float *  slope,
float *  aspect,
int  degrees 
)

ADD.

Parameters
dir
slope
ascpect
degrees

Definition at line 732 of file gsd_objs.c.

References Pi, X, Y, and Z.

◆ gsd_3darrow()

void gsd_3darrow ( float *  center,
unsigned long  colr,
float  siz1,
float  siz2,
float *  dir,
float  sz 
)

Draw 3d north arrow.

Parameters
centercenter point
colrcolor value
siz1height
siz2is diameter
dir
sz

Definition at line 1057 of file gsd_objs.c.

◆ gsd_3dcursor()

void gsd_3dcursor ( float *  pt)

Draw 3d cursor.

Parameters
ptpoint

Definition at line 688 of file gsd_objs.c.

References gsd_bgnline(), gsd_endline(), gsd_vert_func(), X, Y, and Z.

◆ gsd_arrow()

int gsd_arrow ( float *  center,
unsigned long  colr,
float  siz,
float *  dir,
float  sz,
geosurf onsurf 
)

ADD.

siz is height, sz is global exag to correct for.

If onsurf in non-null, z component of dir is dropped and line-on-suf is used, resulting in length of arrow being proportional to slope

Parameters
centercenter point
colrcolor value
sizsize value
dir
sz
onsurfsurface (geosurf)
Returns
1 no surface given
0 on surface

Definition at line 898 of file gsd_objs.c.

Referenced by gsd_wire_arrows().

◆ gsd_arrow_onsurf()

int gsd_arrow_onsurf ( float *  base,
float *  tip,
unsigned long  colr,
int  wid,
geosurf gs 
)

Draw north arrow on surface.

Parameters
base
tip
colr
wid
gssurface (geosurf)
Returns
0

Definition at line 970 of file gsd_objs.c.

◆ gsd_box()

void gsd_box ( float *  center,
int  colr,
float *  siz 
)

Draw box.

Warning siz is an array (we need it for scale only Z in histograms)

Parameters
centercenter point
colrcolor value
sizsize value

Definition at line 1411 of file gsd_objs.c.

References Box, BoxN, gsd_bgnpolygon(), gsd_endpolygon(), gsd_getshademodel(), gsd_litvert_func(), gsd_popmatrix(), gsd_pushmatrix(), gsd_scale(), gsd_shademodel(), gsd_translate(), X, Y, and Z.

Referenced by gpd_obj().

◆ gsd_cube()

void gsd_cube ( float *  center,
unsigned long  colr,
float  siz 
)

Draw cube.

Added by Hamish Bowman Nov 2005

Parameters
centercenter point
colrcolor value
sizsize value

Definition at line 407 of file gsd_objs.c.

References CubeNormals, CubeVertices, gsd_bgnpolygon(), gsd_endpolygon(), gsd_getshademodel(), gsd_litvert_func(), gsd_popmatrix(), gsd_pushmatrix(), gsd_scale(), gsd_shademodel(), gsd_translate(), X, Y, and Z.

Referenced by gpd_obj().

◆ gsd_diamond()

void gsd_diamond ( float *  center,
unsigned long  colr,
float  siz 
)

Draw diamond symbol.

Parameters
centercenter point
colrcolor value
sizesize value

Definition at line 305 of file gsd_objs.c.

References gsd_bgnpolygon(), gsd_bgntmesh(), gsd_endpolygon(), gsd_endtmesh(), gsd_getshademodel(), gsd_litvert_func(), gsd_popmatrix(), gsd_pushmatrix(), gsd_scale(), gsd_shademodel(), gsd_swaptmesh(), gsd_translate(), Octo, OctoN, X, Y, and Z.

Referenced by gpd_obj().

◆ gsd_diamond_lines()

void gsd_diamond_lines ( void  )

Draw diamond lines.

Definition at line 554 of file gsd_objs.c.

References gsd_bgnline(), gsd_endline(), gsd_vert_func(), and Octo.

Referenced by gsd_draw_asterisk().

◆ gsd_draw_asterisk()

void gsd_draw_asterisk ( float *  center,
unsigned long  colr,
float  siz 
)

Draw asterisk.

Parameters
centercenter point
colrcolor value
sizsize value

Definition at line 581 of file gsd_objs.c.

References gsd_color_func(), gsd_diamond_lines(), gsd_popmatrix(), gsd_pushmatrix(), gsd_rot(), gsd_scale(), gsd_translate(), X, Y, and Z.

Referenced by gpd_obj().

◆ gsd_draw_box()

void gsd_draw_box ( float *  center,
unsigned long  colr,
float  siz 
)

Draw box.

Added by Hamish Bowman Nov 2005

Parameters
centercenter point
colrcolor value
sizsize value

Definition at line 483 of file gsd_objs.c.

References CubeVertices, gsd_bgnline(), gsd_color_func(), gsd_endline(), gsd_popmatrix(), gsd_pushmatrix(), gsd_scale(), gsd_translate(), gsd_vert_func(), X, Y, and Z.

Referenced by gpd_obj().

◆ gsd_draw_gyro()

void gsd_draw_gyro ( float *  center,
unsigned long  colr,
float  siz 
)

Draw gyro.

Parameters
centercenter point
colrcolor value
sizsize value

Definition at line 636 of file gsd_objs.c.

References gsd_bgnline(), gsd_circ(), gsd_color_func(), gsd_endline(), gsd_popmatrix(), gsd_pushmatrix(), gsd_rot(), gsd_scale(), gsd_translate(), gsd_vert_func(), Octo, X, Y, and Z.

Referenced by gpd_obj().

◆ gsd_drawsphere()

void gsd_drawsphere ( float *  center,
unsigned long  colr,
float  siz 
)

Draw sphere.

Parameters
centercenter point
colrcolor value
sizesize value

Definition at line 542 of file gsd_objs.c.

References gsd_color_func(), and gsd_sphere().

◆ gsd_line_onsurf()

void gsd_line_onsurf ( geosurf gs,
float *  v1,
float *  v2 
)

Line on surface, fix z-values.

Todo:
remove fudge, instead fudge the Z buffer
Parameters
gssurface (geosurf)
v1first point
v2second point

Definition at line 167 of file gsd_objs.c.

References FUDGE, gsd_bgnline(), gsd_endline(), gsd_vert_func(), gsdrape_get_segments(), and Z.

Referenced by gsd_x().

◆ gsd_nline_onsurf()

int gsd_nline_onsurf ( geosurf gs,
float *  v1,
float *  v2,
float *  pt,
int  n 
)

Multiline on surface, fix z-values.

Todo:
remove fudge, instead fudge the Z buffer

Like above, except only draws first n points of line, or np, whichever is less. Returns number of points used. Fills pt with last pt drawn.

Parameters
gssurface (geosurf)
v1first point
v2second point
pt
nnumber of segments
numberof vertices

Definition at line 213 of file gsd_objs.c.

References FUDGE, gsd_bgnline(), gsd_endline(), gsd_vert_func(), gsdrape_get_segments(), X, Y, and Z.

◆ gsd_north_arrow()

int gsd_north_arrow ( float *  pos2,
float  len,
GLuint  fontbase,
unsigned long  arw_clr,
unsigned long  text_clr 
)

Draw North Arrow takes OpenGL coords and size.

Parameters
pos2
len
fontbase
arw_clrnorth arrow color
text_clrtext color
Returns
1

Definition at line 803 of file gsd_objs.c.

References GS_done_draw(), GS_set_draw(), gsd_bgnpolygon(), gsd_color_func(), gsd_do_scale(), gsd_endpolygon(), gsd_flush(), GSD_FRONT, gsd_get_txtheight(), gsd_get_txtwidth(), gsd_popmatrix(), gsd_pushmatrix(), Ntop, X, Y, and Z.

◆ gsd_plus()

void gsd_plus ( float *  center,
int  colr,
float  siz 
)

ADD.

Parameters
centercenter point
colrcolor value
sizsize value

Definition at line 130 of file gsd_objs.c.

References gsd_bgnline(), gsd_color_func(), gsd_endline(), gsd_vert_func(), X, Y, and Z.

◆ gsd_scalebar()

int gsd_scalebar ( float *  pos2,
float  len,
GLuint  fontbase,
unsigned long  bar_clr,
unsigned long  text_clr 
)

Draw Scalebar takes OpenGL coords and size.

Adapted from gsd_north_arrow Hamish Bowman Dec 2006

Parameters
pos2
fontbasefont-base
bar_clrbarscale color
text_clrtext color
Returns
1

Definition at line 1136 of file gsd_objs.c.

References G_database_unit_name(), GS_done_draw(), GS_set_draw(), gsd_bgnpolygon(), gsd_color_func(), gsd_do_scale(), gsd_endpolygon(), gsd_flush(), GSD_FRONT, gsd_get_txtheight(), gsd_get_txtwidth(), gsd_popmatrix(), gsd_pushmatrix(), Ntop, TRUE, X, Y, and Z.

◆ gsd_scalebar_v2()

int gsd_scalebar_v2 ( float *  pos,
float  len,
GLuint fontbase  UNUSED,
unsigned long  bar_clr,
unsigned long text_clr  UNUSED 
)

Draw Scalebar (as lines)

Adapted from gsd_scalebar A.Kratochvilova 2011

Parameters
pos2scalebar position
fontbasefont-base (unused)
bar_clrbarscale color
text_clrtext color (unused)
Returns
1

Definition at line 1222 of file gsd_objs.c.

References GS_done_draw(), GS_set_draw(), gsd_bgnline(), gsd_color_func(), gsd_do_scale(), gsd_endline(), gsd_flush(), GSD_FRONT, gsd_linewidth(), gsd_popmatrix(), gsd_pushmatrix(), gsd_vert_func(), Ntop, X, Y, and Z.

◆ gsd_x()

void gsd_x ( geosurf gs,
float *  center,
int  colr,
float  siz 
)

Draw X symbol.

Note gs: NULL if flat

Parameters
gssurface (geosurf)
center
colrcolor value
sizsize value

Definition at line 256 of file gsd_objs.c.

References gsd_bgnline(), gsd_color_func(), gsd_endline(), gsd_line_onsurf(), gsd_vert_func(), X, Y, and Z.

Referenced by gpd_obj().

◆ primitive_cone()

void primitive_cone ( unsigned long  col)

Primitives only called after transforms.

Center is actually center at base of 8 sided cone

Parameters
colcolor value

Definition at line 1285 of file gsd_objs.c.

◆ primitive_cylinder()

void primitive_cylinder ( unsigned long  col,
int  caps 
)

Primitives only called after transforms.

Center is actually center at base of 8 sided cylinder

Parameters
colcolor value
caps

Definition at line 1322 of file gsd_objs.c.

Variable Documentation

◆ Box

float Box[8][3]
Initial value:
= {{1.0, 1.0, -1.0}, {-1.0, 1.0, -1.0}, {-1.0, 1.0, 1.0},
{1.0, 1.0, 1.0}, {1.0, -1.0, -1.0}, {-1.0, -1.0, -1.0},
{-1.0, -1.0, 1.0}, {1.0, -1.0, 1.0}}

Vertices for box.

Definition at line 1395 of file gsd_objs.c.

Referenced by gsd_box(), Vect_box_clip(), Vect_get_area_box(), Vect_get_constraint_box(), Vect_get_isle_box(), Vect_get_map_box(), Vect_point_in_box(), Vect_point_in_box_2d(), Vect_region_box(), Vect_select_isles_by_box(), and Vect_select_nodes_by_box().

◆ BoxN

float BoxN[6][3]
Initial value:
= {{0, 0, -ONORM}, {0, 0, ONORM}, {0, ONORM, 0},
{0, -ONORM, 0}, {ONORM, 0, 0}, {-ONORM, 0, 0}}
#define ONORM
Definition: gsd_objs.c:37

Definition at line 1399 of file gsd_objs.c.

Referenced by gsd_box().

◆ CubeNormals

float CubeNormals[3][3] = {{0, -ONORM, 0}, {0, 0, ONORM}, {ONORM, 0, 0}}

???? not sure if any of these are needed for correct lighting. float CubeNormals[6][3] = { {ONORM, 0, 0}, {-ONORM, 0, 0}, {0, ONORM, 0}, {0, -ONORM, 0}, {0, 0, ONORM}, {0, 0, -ONORM} };

Definition at line 60 of file gsd_objs.c.

Referenced by gsd_cube().

◆ CubeVertices

float CubeVertices[8][3]
Initial value:
= {
{-1.0, -1.0, -1.0}, {1.0, -1.0, -1.0}, {1.0, 1.0, -1.0}, {-1.0, 1.0, -1.0},
{-1.0, -1.0, 1.0}, {1.0, -1.0, 1.0}, {1.0, 1.0, 1.0}, {-1.0, 1.0, 1.0}}

Definition at line 62 of file gsd_objs.c.

Referenced by gsd_cube(), and gsd_draw_box().

◆ Octo

float Octo[6][3]
Initial value:
= {{1.0, 0.0, 0.0}, {0.0, 1.0, 0.0}, {0.0, 0.0, 1.0},
{-1.0, 0.0, 0.0}, {0.0, -1.0, 0.0}, {0.0, 0.0, -1.0}}

vertices for octahedron

Definition at line 34 of file gsd_objs.c.

Referenced by gsd_diamond(), gsd_diamond_lines(), and gsd_draw_gyro().

◆ OctoN

float OctoN[8][3]
Initial value:
= {
{ONORM, -ONORM, -ONORM}, {-ONORM, -ONORM, -ONORM},
}

normals for flat-shaded octahedron

Definition at line 42 of file gsd_objs.c.

Referenced by gsd_diamond().

◆ ogverts

float ogverts[8][3]

vertices & normals for octagon in xy plane

Definition at line 75 of file gsd_objs.c.

◆ ogvertsplus

float ogvertsplus[8][3]

vertices for octagon in xy plane, z=1

Definition at line 80 of file gsd_objs.c.

◆ origin

float origin[3] = {0.0, 0.0, 0.0}

Definition at line 66 of file gsd_objs.c.

◆ Pi

float Pi

Definition at line 82 of file gsd_objs.c.

Referenced by dir_to_slope_aspect().