|
GRASS 8 Programmer's Manual 8.6.0dev(2026)-0f6a7341fc
|
OGSF library - objects management (lower level functions) More...
#include <stdlib.h>#include <string.h>#include <grass/gis.h>#include <grass/ogsf.h>#include "gsget.h"#include "math.h"#include "rowcol.h"
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) |
| Draws a plus sign symbol at the specified center location. | |
| void | gsd_line_onsurf (geosurf *gs, float *v1, float *v2) |
| Line on surface, fix z-values. | |
| int | gsd_nline_onsurf (geosurf *gs, float *v1, float *v2, float *pt, int n) |
| Multiline on surface, fix z-values. | |
| void | gsd_x (geosurf *gs, float *center, int colr, float siz) |
| Draws a X symbol at the specified center location. | |
| void | gsd_diamond (float *center, unsigned long colr, float siz) |
| Draws a diamond symbol at the specified center location. | |
| void | gsd_cube (float *center, unsigned long colr, float siz) |
| Draws a cube symbol at the specified center location. | |
| void | gsd_draw_box (float *center, unsigned long colr, float siz) |
| Draws a box symbol at the specified center location. | |
| void | gsd_drawsphere (float *center, unsigned long colr, float siz) |
| Draws a sphere at the specified center location. | |
| void | gsd_diamond_lines (void) |
| Draw diamond lines. | |
| void | gsd_draw_asterisk (float *center, unsigned long colr, float siz) |
| Draws an asterisk symbol at the specified center location. | |
| void | gsd_draw_gyro (float *center, unsigned long colr, float siz) |
| Draws a gyro symbol at the specified center location. | |
| void | gsd_3dcursor (float *pt) |
| Draw 3d cursor. | |
| void | dir_to_slope_aspect (float *dir, float *slope, float *aspect, int degrees) |
| Converts a direction vector to slope and aspect angles. | |
| int | gsd_north_arrow (float *pos2, float len, GLuint fontbase, unsigned long arw_clr, unsigned long text_clr) |
| Draw North Arrow. | |
| int | gsd_arrow (float *center, unsigned long colr, float siz, float *dir, float sz, geosurf *onsurf) |
| Draws an arrow. | |
| int | gsd_arrow_onsurf (float *base, float *tip, unsigned long colr, int wid, geosurf *gs) |
| Draw north arrow on surface. | |
| void | gsd_3darrow (float *center, unsigned long colr, float siz1, float siz2, float *dir, float sz) |
| Draw 3d north arrow. | |
| int | gsd_scalebar (float *pos2, float len, GLuint fontbase, unsigned long bar_clr, unsigned long text_clr) |
| Draw Scalebar takes OpenGL coords and size. | |
| int | gsd_scalebar_v2 (float *pos, float len, GLuint fontbase, unsigned long bar_clr, unsigned long text_clr) |
| Draw Scalebar (as lines) | |
| void | primitive_cone (unsigned long colr) |
| Primitives only called after transforms. | |
| void | primitive_cylinder (unsigned long colr, int caps) |
| Primitives only called after transforms. | |
| void | gsd_box (float *center, int colr, float *siz) |
| Draws a box at the specified center location. | |
Variables | |
| float | Octo [6][3] |
| vertices for octahedron | |
| float | OctoN [8][3] |
| normals for flat-shaded octahedron | |
| float | CubeNormals [3][3] = {{0, - .57445626 , 0}, {0, 0, .57445626 }, { .57445626 , 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 | |
| float | ogvertsplus [8][3] |
| vertices for octagon in xy plane, z=1 | |
| float | Pi |
| float | Box [8][3] |
| Vertices for box. | |
| float | BoxN [6][3] |
OGSF library - objects management (lower level functions)
GRASS OpenGL gsurf OGSF Library
SPDX-FileCopyrightText: 1999-2008 GRASS Development Team SPDX-License-Identifier: GPL-2.0-or-later
Definition in file gsd_objs.c.
Definition at line 65 of file gsd_objs.c.
| #define ONORM .57445626 |
Definition at line 33 of file gsd_objs.c.
Definition at line 66 of file gsd_objs.c.
Definition at line 64 of file gsd_objs.c.
Converts a direction vector to slope and aspect angles.
Given a 3D direction vector, this function computes the slope and aspect angles corresponding to the vector. The aspect is the compass direction (azimuth) of the projection of the vector onto the XY plane, and the slope is the angle between the vector and the vertical axis (Z).
| [in] | dir | Pointer to an array of 3 floats representing the direction vector [dx, dy, dz]. |
| [out] | slope | Pointer to a float where the computed slope angle will be stored (in radians or degrees). |
| [out] | aspect | Pointer to a float where the computed aspect angle will be stored (in radians or degrees). |
| [in] | degrees | If non-zero, the output angles are converted to degrees; otherwise, they are in radians. |
The function handles edge cases where the direction vector is vertical or horizontal. Aspect is set to 0 if the vector has no horizontal component. Slope is negative for upward-pointing vectors, positive for downward.
Definition at line 772 of file gsd_objs.c.
Referenced by gsd_3darrow(), and gsd_arrow().
| void gsd_3darrow | ( | float * | center, |
| unsigned long | colr, | ||
| float | siz1, | ||
| float | siz2, | ||
| float * | dir, | ||
| float | sz | ||
| ) |
Draw 3d north arrow.
| center | Pointer to a float array representing the (x, y, z) coordinates of the center point. |
| colr | Integer representing the color to use for drawing the arrow. |
| siz1 | size |
| siz2 | size |
| dir | Direction of the arrow. Pointer to a float array representing the 3D vector (X,Y,Z). |
| sz | height |
Definition at line 1107 of file gsd_objs.c.
References dir_to_slope_aspect(), G_debug(), GS_v3norm(), gsd_backface(), gsd_bgnlist(), gsd_calllist(), gsd_color_func(), gsd_endlist(), gsd_getshademodel(), gsd_makelist(), gsd_popmatrix(), gsd_pushmatrix(), gsd_rot(), gsd_scale(), gsd_shademodel(), gsd_translate(), primitive_cone(), primitive_cylinder(), X, Y, and Z.
Referenced by gsd_norm_arrows().
Draw 3d cursor.
| [in] | pt | point |
Definition at line 715 of file gsd_objs.c.
References gsd_bgnline(), gsd_endline(), gsd_vert_func(), X, Y, and Z.
| int gsd_arrow | ( | float * | center, |
| unsigned long | colr, | ||
| float | siz, | ||
| float * | dir, | ||
| float | sz, | ||
| geosurf * | onsurf | ||
| ) |
Draws an arrow.
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.
| center | Pointer to a float array representing the (x, y, z) coordinates of the center point. |
| colr | Integer representing the color to use for drawing the arrow. |
| siz | Size of the arrow. |
| dir | Direction of the arrow. Pointer to a float array representing the 3D vector (X,Y,Z). |
| sz | height, sz is global exag to correct for. |
| onsurf | surface (geosurf). |
Definition at line 944 of file gsd_objs.c.
References dir_to_slope_aspect(), GS_P2distance(), GS_v3norm(), gsd_arrow_onsurf(), gsd_bgnline(), gsd_color_func(), gsd_endline(), gsd_popmatrix(), gsd_pushmatrix(), gsd_rot(), gsd_scale(), gsd_translate(), gsd_vert_func(), NULL, ORIGIN, UP_NORM, X, Y, and Z.
Referenced by gsd_norm_arrows(), and gsd_wire_arrows().
Draw north arrow on surface.
| base | Pointer to a float array representing the base as a 2D vector (X,Y). |
| tip | Pointer to a float array representing the tip as a 2D vector (X,Y). |
| colr | Integer representing the color to use for drawing the arrow. |
| wid | Line width (see gsd_linewidth) |
| gs | surface (geosurf) |
Definition at line 1018 of file gsd_objs.c.
References DOWN_NORM, G_debug(), GS_v3add(), GS_v3cross(), GS_v3dir(), GS_v3eq(), GS_v3mag(), GS_v3mult(), gsd_color_func(), gsd_disc(), gsd_line_onsurf(), gsd_linewidth(), UP_NORM, X, Y, and Z.
Referenced by gsd_arrow().
Draws a box at the specified center location.
This function renders a box at the given center coordinates with the specified color and size.
| center | Pointer to a float array representing the (x, y, z) coordinates of the center point. |
| colr | Integer representing the color to use for drawing the symbol. |
| siz | Size of the symbol. |
Definition at line 1471 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().
Draws a cube symbol at the specified center location.
This function renders a cube symbol at the given center coordinates with the specified color and size.
Added by Hamish Bowman Nov 2005
| center | Pointer to a float array representing the (x, y, z) coordinates of the center point. |
| colr | Integer representing the color to use for drawing the symbol. |
| siz | Size of the symbol. |
Definition at line 418 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().
Draws a diamond symbol at the specified center location.
This function renders a diamond symbol at the given center coordinates with the specified color and size.
| center | Pointer to a float array representing the (x, y, z) coordinates of the center point. |
| colr | Integer representing the color to use for drawing the symbol. |
| siz | Size of the symbol. |
Definition at line 312 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().
Draw diamond lines.
Definition at line 573 of file gsd_objs.c.
References gsd_bgnline(), gsd_endline(), gsd_vert_func(), and Octo.
Referenced by gsd_draw_asterisk().
Draws an asterisk symbol at the specified center location.
This function renders an asterisk symbol at the given center coordinates with the specified color and size.
| center | Pointer to a float array representing the (x, y, z) coordinates of the center point. |
| colr | Integer representing the color to use for drawing the symbol. |
| siz | Size of the symbol. |
Definition at line 604 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().
Draws a box symbol at the specified center location.
This function renders a box symbol at the given center coordinates with the specified color and size.
Added by Hamish Bowman Nov 2005
| center | Pointer to a float array representing the (x, y, z) coordinates of the center point. |
| colr | Integer representing the color to use for drawing the symbol. |
| siz | Size of the symbol. |
Definition at line 498 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().
Draws a gyro symbol at the specified center location.
This function renders a gyro symbol at the given center coordinates with the specified color and size.
| center | Pointer to a float array representing the (x, y, z) coordinates of the center point. |
| colr | Integer representing the color to use for drawing the symbol. |
| siz | Size of the symbol. |
Definition at line 663 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().
Draws a sphere at the specified center location.
This function renders a sphere at the given center coordinates with the specified color and size.
| center | Pointer to a float array representing the (x, y, z) coordinates of the center point. |
| colr | Integer representing the color to use for drawing the sphere. |
| siz | Size of the sphere. |
Definition at line 561 of file gsd_objs.c.
References gsd_color_func(), and gsd_sphere().
Referenced by GS_draw_lighting_model(), and GS_draw_lighting_model1().
Line on surface, fix z-values.
| gs | surface (geosurf) |
| v1 | first point (X,Y) |
| v2 | second point (X,Y) |
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 GS_draw_line_onsurf(), gsd_arrow_onsurf(), and gsd_x().
Multiline on surface, fix z-values.
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.
| gs | surface (geosurf) | |
| v1 | Pointer to a float array representing the first point as a vector. | |
| v2 | Pointer to a float array representing the second point as a vector. | |
| [out] | pt | |
| [in] | n | number of segments |
Definition at line 212 of file gsd_objs.c.
References FUDGE, gsd_bgnline(), gsd_endline(), gsd_vert_func(), gsdrape_get_segments(), X, Y, and Z.
Referenced by GS_draw_nline_onsurf().
| 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
| pos2 | Pointer to a float array representing the position as a 3D vector (X,Y,Z). |
| len | |
| fontbase | |
| arw_clr | north arrow color |
| text_clr | text color |
Store arrow somewhere to enable it's removal/change.
Add option to specify north text and font.
Definition at line 847 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.
Referenced by Nviz_draw_all(), and Nviz_draw_arrow().
Draws a plus sign symbol at the specified center location.
This function renders a plus sign ('+') symbol at the given center coordinates with the specified color and size.
| center | Pointer to a float array representing the (x, y, z) coordinates of the center point. |
| colr | Integer representing the color to use for drawing the symbol. |
| siz | Size of the symbol. |
Definition at line 130 of file gsd_objs.c.
References gsd_bgnline(), gsd_color_func(), gsd_endline(), gsd_vert_func(), X, Y, and Z.
| 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
| pos2 | Pointer to a float array representing the scalebar position as a 3D vector (X,Y,Z). |
| len | |
| fontbase | font-base |
| bar_clr | barscale color. Integer representing the color to use for the barscale. |
| text_clr | test color. Integer representing the color to use for the text. |
Definition at line 1189 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.
| int gsd_scalebar_v2 | ( | float * | pos, |
| float | len, | ||
| GLuint | fontbase, | ||
| unsigned long | bar_clr, | ||
| unsigned long | text_clr | ||
| ) |
Draw Scalebar (as lines)
Adapted from gsd_scalebar A.Kratochvilova 2011
| pos | Pointer to a float array representing the scalebar position as a 3D vector (X,Y,Z). |
| len | |
| fontbase | font-base (unused) |
| bar_clr | barscale color. Integer representing the color to use for the barscale. |
| text_clr | Text color (unused). Integer representing the color to use for the text. |
Definition at line 1278 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.
Referenced by Nviz_draw_all(), and Nviz_draw_scalebar().
Draws a X symbol at the specified center location.
This function renders a x ('X') symbol at the given center coordinates with the specified color and size.
Note gs: NULL if flat
| gs | surface (geosurf) |
| center | Pointer to a float array representing the (x, y, z) coordinates of the center point. |
| colr | Integer representing the color to use for drawing the symbol. |
| siz | Size of the symbol. |
Definition at line 259 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 gk_draw_path(), and gpd_obj().
Primitives only called after transforms.
Center is actually center at base of 8 sided cone
| colr | Integer representing the color to use for drawing the cone. |
Definition at line 1341 of file gsd_objs.c.
References gsd_bgntfan(), gsd_endtfan(), gsd_litvert_func2(), ogverts, UP_NORM, X, Y, and Z.
Referenced by gsd_3darrow().
Primitives only called after transforms.
Center is actually center at base of 8 sided cylinder
| colr | Integer representing the color to use for drawing the cylinder. |
| caps | If non zero, draw caps at the bottom and top of the cylinder. |
Definition at line 1378 of file gsd_objs.c.
References DOWN_NORM, gsd_bgnqstrip(), gsd_bgntfan(), gsd_endqstrip(), gsd_endtfan(), gsd_litvert_func2(), ogverts, ogvertsplus, ORIGIN, and UP_NORM.
Referenced by gsd_3darrow().
| float Box[8][3] |
Vertices for box.
Definition at line 1451 of file gsd_objs.c.
Referenced by dig_line_box(), gsd_box(), Vect_box_clip(), Vect_get_area_box(), Vect_get_constraint_box(), Vect_get_isle_box(), Vect_get_line_box(), Vect_get_map_box(), Vect_get_map_box1(), Vect_line_box(), Vect_point_in_box(), Vect_point_in_box_2d(), Vect_region_box(), Vect_select_areas_by_box(), Vect_select_isles_by_box(), Vect_select_lines_by_box(), and Vect_select_nodes_by_box().
| float BoxN[6][3] |
Definition at line 1455 of file gsd_objs.c.
Referenced by gsd_box().
| float CubeNormals[3][3] = {{0, - .57445626 , 0}, {0, 0, .57445626 }, { .57445626 , 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 56 of file gsd_objs.c.
Referenced by gsd_cube().
| float CubeVertices[8][3] |
Definition at line 58 of file gsd_objs.c.
Referenced by gsd_cube(), and gsd_draw_box().
| float Octo[6][3] |
vertices for octahedron
Definition at line 30 of file gsd_objs.c.
Referenced by gsd_diamond(), gsd_diamond_lines(), and gsd_draw_gyro().
| float OctoN[8][3] |
normals for flat-shaded octahedron
Definition at line 38 of file gsd_objs.c.
Referenced by gsd_diamond().
| float ogverts[8][3] |
vertices & normals for octagon in xy plane
Definition at line 71 of file gsd_objs.c.
Referenced by primitive_cone(), and primitive_cylinder().
| float ogvertsplus[8][3] |
vertices for octagon in xy plane, z=1
Definition at line 76 of file gsd_objs.c.
Referenced by primitive_cylinder().
| float origin[3] = {0.0, 0.0, 0.0} |
Definition at line 62 of file gsd_objs.c.
| float Pi |
Definition at line 78 of file gsd_objs.c.
Referenced by dir_to_slope_aspect().