22 #include <grass/gis.h>
23 #include <grass/ogsf_proto.h>
24 #include <grass/gstypes.h>
30 static void init_stuff(
void);
44 #define ONORM .57445626
91 #define UP_NORM Octo[2]
92 #define DOWN_NORM Octo[5]
107 static void init_stuff(
void)
111 static int first = 1;
116 cos45 = cos(atan(1.0));
118 for (i = 0; i < 8; i++) {
140 Pi = 4.0 * atan(1.0);
160 v1[Z] = v2[Z] = center[Z];
162 v1[
X] = v2[
X] = center[
X];
163 v1[
Y] = center[
Y] - siz;
164 v2[
Y] = center[
Y] + siz;
170 v1[
Y] = v2[
Y] = center[
Y];
171 v1[
X] = center[
X] - siz;
172 v2[
X] = center[
X] + siz;
201 for (i = 0; i < np; i++) {
213 v2[Z] = pts[np - 1][Z];
245 pdraw = n < np ? n : np;
249 for (i = 0; i < pdraw; i++) {
256 pt[
X] = pts[i - 1][
X];
257 pt[
Y] = pts[i - 1][
Y];
261 v2[Z] = pts[np - 1][Z];
279 void gsd_x(geosurf * gs,
float *center,
int colr,
float siz)
286 v1[Z] = v2[Z] = center[Z];
288 v1[
X] = center[
X] - siz;
289 v2[
X] = center[
X] + siz;
290 v1[
Y] = center[
Y] - siz;
291 v2[
Y] = center[
Y] + siz;
303 v1[
X] = center[
X] - siz;
304 v2[
X] = center[
X] + siz;
305 v1[
Y] = center[
Y] + siz;
306 v2[
Y] = center[
Y] - siz;
430 void gsd_cube(
float *center,
unsigned long colr,
float siz)
678 for (i = 0; i < 6; i++) {
759 float costheta, theta, adjacent;
767 if (dx == 0 && dy == 0) {
775 costheta = dx / sqrt(dx * dx + dy * dy);
776 theta = acos(costheta);
780 theta = (2 *
Pi) - theta;
791 else if (dx == 0 && dy == 0) {
795 adjacent = sqrt(dx * dx + dy * dy);
796 costheta = adjacent / sqrt(adjacent * adjacent + dz * dz);
797 theta = acos(costheta);
807 *aspect = *aspect * (180. /
Pi);
808 *slope = *slope * (180. /
Pi);
827 unsigned long arw_clr,
unsigned long text_clr)
832 float Ntop[] = { 0.0, 0.0, 1.0 };
834 base[0][Z] = base[1][Z] = base[2][Z] = pos2[Z];
835 v[0][Z] = v[1][Z] = v[2][Z] = v[3][Z] = pos2[Z];
837 base[0][
X] = pos2[
X] - len / 16.;
838 base[1][
X] = pos2[
X] + len / 16.;
839 base[0][
Y] = base[1][
Y] = pos2[
Y] - len / 2.;
840 base[2][
X] = pos2[
X];
841 base[2][
Y] = pos2[
Y] + .45 * len;
843 v[0][
X] = v[2][
X] = pos2[
X];
844 v[1][
X] = pos2[
X] + len / 8.;
845 v[3][
X] = pos2[
X] - len / 8.;
846 v[0][
Y] = pos2[
Y] + .2 * len;
847 v[1][
Y] = v[3][
Y] = pos2[
Y] + .1 * len;
848 v[2][
Y] = pos2[
Y] + .5 * len;
860 glVertex3fv(base[0]);
861 glVertex3fv(base[1]);
862 glVertex3fv(base[2]);
891 glRasterPos3fv(base[0]);
892 glListBase(fontbase);
893 glCallLists(strlen(txt), GL_UNSIGNED_BYTE, (
const GLvoid *)txt);
922 int gsd_arrow(
float *center,
unsigned long colr,
float siz,
float *dir,
923 float sz, geosurf * onsurf)
927 static int first = 1;
938 if (
NULL != onsurf) {
939 float base[3], tip[3], len;
946 tip[
X] = center[
X] + dir[
X] * len * siz;
947 tip[
Y] = center[
Y] + dir[
Y] * len * siz;
997 static int first = 1;
1007 G_debug(3,
"gsd_arrow_onsurf");
1008 G_debug(3,
" %f %f -> %f %f", base[
X], base[
Y], tip[X], tip[Y]);
1012 #ifdef DO_SPHERE_BASE
1016 gsd_disc(base[X], base[Y], len / 10.);
1022 base[Z] = tip[Z] = 0.0;
1025 G_debug(3,
" dir0: %f %f %f", dir0[X], dir0[Y], dir0[Z]);
1033 G_debug(3,
" a-dir1: %f %f %f", dir1[X], dir1[Y], dir1[Z]);
1034 G_debug(3,
" a-dir2: %f %f %f", dir2[X], dir2[Y], dir2[Z]);
1041 G_debug(3,
" b-dir1: %f %f %f", dir1[X], dir1[Y], dir1[Z]);
1042 G_debug(3,
" b-dir2: %f %f %f", dir2[X], dir2[Y], dir2[Z]);
1048 G_debug(3,
" %f %f -> ", tmp[X], tmp[Y]);
1056 G_debug(3,
" dir1: %f %f %f", dir1[X], dir1[Y], dir1[Z]);
1057 G_debug(3,
" dir2: %f %f %f", dir2[X], dir2[Y], dir2[Z]);
1062 G_debug(3,
" %f %f", tmp[X], tmp[Y]);
1081 void gsd_3darrow(
float *center,
unsigned long colr,
float siz1,
float siz2,
1082 float *dir,
float sz)
1084 float slope, aspect;
1086 static int first = 1;
1088 static int debugint = 1;
1095 if (debugint > 100) {
1097 G_debug(3,
" pt: %f,%f,%f dir: %f,%f,%f slope: %f aspect: %f",
1098 center[
X], center[
Y], center[Z], dir[X], dir[Y], dir[Z],
1161 unsigned long bar_clr,
unsigned long text_clr)
1165 float Ntop[] = { 0.0, 0.0, 1.0 };
1168 base[0][Z] = base[1][Z] = base[2][Z] = base[3][Z] = pos2[Z];
1171 base[0][
X] = base[1][
X] = pos2[
X] - len / 2.;
1172 base[2][
X] = base[3][
X] = pos2[
X] + len / 2.;
1174 base[0][
Y] = base[3][
Y] = pos2[
Y] - len / 16.;
1175 base[1][
Y] = base[2][
Y] = pos2[
Y] + len / 16.;
1188 glVertex3fv(base[0]);
1189 glVertex3fv(base[1]);
1190 glVertex3fv(base[2]);
1191 glVertex3fv(base[3]);
1192 glVertex3fv(base[0]);
1204 sprintf(txt,
"%g km", len / 1000);
1206 sprintf(txt,
"%g meters", len);
1210 sprintf(txt,
"%g miles", len / 5280);
1211 else if (len == 5280)
1225 glRasterPos3fv(base[0]);
1226 glListBase(fontbase);
1227 glCallLists(strlen(txt), GL_BYTE, (GLubyte *) txt);
1249 unsigned long bar_clr,
unsigned long text_clr)
1252 float Ntop[] = { 0.0, 0.0, 1.0 };
1254 base[0][Z] = base[1][Z] = base[2][Z] = pos[Z];
1255 base[3][Z] = base[4][Z] = base[5][Z] = pos[Z];
1258 base[0][
X] = base[2][
X] = base[3][
X] = pos[
X] - len / 2.;
1259 base[1][
X] = base[4][
X] = base[5][
X] = pos[
X] + len / 2.;
1260 base[0][
Y] = base[1][
Y] = pos[
Y];
1261 base[2][
Y] = base[4][
Y] = pos[
Y] - len / 12;
1262 base[3][
Y] = base[5][
Y] = pos[
Y] + len / 12;
1314 static int first = 1;
1321 tip[
X] = tip[
Y] = 0.0;
1350 static int first = 1;
1421 { {1.0, 1.0, -1.0}, {-1.0, 1.0, -1.0}, {-1.0, 1.0, 1.0}, {1.0, 1.0, 1.0},
1422 {1.0, -1.0, -1.0}, {-1.0, -1.0, -1.0}, {-1.0, -1.0, 1.0}, {1.0, -1.0, 1.0}
1426 { {0, 0, -
ONORM}, {0, 0,
ONORM}, {0,
ONORM, 0}, {0, -
ONORM, 0}, {
ONORM, 0,
void gsd_3dcursor(float *pt)
Draw 3d cursor.
sprintf(buf2,"%s", G3D_CATS_ELEMENT)
void gsd_calllist(int listno)
ADD.
float Octo[6][3]
vertices for octohedron
void gsd_endlist(void)
End list.
void gsd_diamond_lines(void)
Draw diamond lines.
void gsd_endqstrip(void)
ADD.
void gsd_bgntmesh(void)
ADD.
void gsd_circ(float x, float y, float rad)
ADD.
float ogverts[8][3]
vertices & normals for octagon in xy plane
float Box[8][3]
Vertices for box.
void gsd_do_scale(int doexag)
Set current scale.
int GS_v3norm(float *v1)
Change v1 so that it is a unit vector (2D)
void gsd_sphere(float *center, float siz)
ADD.
int gsd_makelist(void)
ADD.
void GS_done_draw(void)
Draw done, swap buffers.
void gsd_bgnpolygon(void)
Delimit the vertices of a primitive or a group of like primitives.
void gsd_draw_box(float *center, unsigned long colr, float siz)
Draw box.
void GS_v3add(float *v1, float *v2)
Sum vectors.
int GS_v3dir(float *v1, float *v2, float *v3)
Get a normalized direction from v1 to v2, store in v3.
char * G_database_unit_name(int plural)
database units
void gsd_color_func(unsigned int col)
Set current color.
void GS_v3cross(float *v1, float *v2, float *v3)
Get the cross product v3 = v1 cross v2.
void gsd_endtmesh(void)
ADD.
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.
void gsd_translate(float dx, float dy, float dz)
Multiply the current matrix by a translation matrix.
void gsd_litvert_func(float *norm, unsigned long col, float *pt)
Set the current normal vector & specify vertex.
void gsd_shademodel(int bool)
Set shaded model.
void gsd_plus(float *center, int colr, float siz)
ADD.
void gsd_x(geosurf *gs, float *center, int colr, float siz)
ADD.
void gsd_swaptmesh(void)
ADD.
void gsd_bgntfan(void)
ADD.
int gsd_arrow_onsurf(float *base, float *tip, unsigned long colr, int wid, geosurf *gs)
Draw north arrow on surface.
void gsd_pushmatrix(void)
Push the current matrix stack.
void gsd_bgnqstrip(void)
ADD.
void gsd_backface(int n)
ADD.
int gsd_get_txtheight(int size)
Get text height.
void gsd_cube(float *center, unsigned long colr, float siz)
Draw cube.
void GS_v3mult(float *v1, float k)
Multiple vectors.
void gsd_bgnlist(int listno, int do_draw)
ADD.
void gsd_diamond(float *center, unsigned long colr, float siz)
Draw diamond symbol.
float OctoN[8][3]
normals for flat-shaded octohedron
void gsd_endline(void)
End line.
void dir_to_slope_aspect(float *dir, float *slope, float *aspect, int degrees)
ADD.
void gsd_endtfan(void)
ADD.
void gsd_disc(float x, float y, float z, float rad)
ADD.
void gsd_rot(float angle, char axis)
ADD.
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_nline_onsurf(geosurf *gs, float *v1, float *v2, float *pt, int n)
Multiline on surface, fix z-values.
void primitive_cylinder(unsigned long col, int caps)
Primitives only called after transforms.
void gsd_litvert_func2(float *norm, unsigned long col, float *pt)
ADD.
void gsd_vert_func(float *pt)
ADD.
void gsd_draw_asterisk(float *center, unsigned long colr, float siz)
Draw asterisk.
float ogvertsplus[8][3]
vertices for octagon in xy plane, z=1
void gsd_line_onsurf(geosurf *gs, float *v1, float *v2)
Line on surface, fix z-values.
Point3 * gsdrape_get_segments(geosurf *gs, float *bgn, float *end, int *num)
ADD.
void GS_v3eq(float *v1, float *v2)
Copy vector values.
void gsd_endpolygon(void)
Delimit the vertices of a primitive or a group of like primitives.
int G_debug(int level, const char *msg,...)
Print debugging message.
void gsd_linewidth(short n)
Set width of rasterized lines.
void gsd_flush(void)
Mostly for flushing drawing commands accross a network.
void gsd_popmatrix(void)
Pop the current matrix stack.
void gsd_box(float *center, int colr, float *siz)
Draw box.
int gsd_getshademodel(void)
Get shaded model.
int gsd_scalebar_v2(float *pos, float len, GLuint fontbase, unsigned long bar_clr, unsigned long text_clr)
Draw Scalebar (as lines)
void gsd_draw_gyro(float *center, unsigned long colr, float siz)
Draw gyro.
float GS_P2distance(float *from, float *to)
Calculate distance in plane.
void primitive_cone(unsigned long col)
Primitives only called after transforms.
void gsd_scale(float xs, float ys, float zs)
Multiply the current matrix by a general scaling matrix.
void gsd_bgnline(void)
Begin line.
void gsd_3darrow(float *center, unsigned long colr, float siz1, float siz2, float *dir, float sz)
Draw 3d north arrow.
int gsd_get_txtwidth(const char *s, int size)
Get text width.
void GS_set_draw(int where)
Sets which buffer to draw to.
void gsd_drawsphere(float *center, unsigned long colr, float siz)
Draw sphere.
int gsd_arrow(float *center, unsigned long colr, float siz, float *dir, float sz, geosurf *onsurf)
ADD.
void GS_v3mag(float *v1, float *mag)
Magnitude of vector.