[GRASS-SVN] r31345 - grass/branches/develbranch_6/lib/ogsf

svn_grass at osgeo.org svn_grass at osgeo.org
Wed May 14 12:04:41 EDT 2008


Author: martinl
Date: 2008-05-14 12:04:40 -0400 (Wed, 14 May 2008)
New Revision: 31345

Modified:
   grass/branches/develbranch_6/lib/ogsf/gs_norms.c
   grass/branches/develbranch_6/lib/ogsf/gsd_objs.c
   grass/branches/develbranch_6/lib/ogsf/gsd_prim.c
   grass/branches/develbranch_6/lib/ogsf/gsd_views.c
Log:
ogsflib: initial doxygen strings added
fprintf -> G_d/w/e/m


Modified: grass/branches/develbranch_6/lib/ogsf/gs_norms.c
===================================================================
--- grass/branches/develbranch_6/lib/ogsf/gs_norms.c	2008-05-14 07:08:41 UTC (rev 31344)
+++ grass/branches/develbranch_6/lib/ogsf/gs_norms.c	2008-05-14 16:04:40 UTC (rev 31345)
@@ -1,7 +1,7 @@
 /*!
   \file gs_norms.c
  
-  \brief OGSF library - 
+  \brief OGSF library - calculation normals (lower level functions)
  
   GRASS OpenGL gsurf OGSF Library 
 
@@ -13,15 +13,17 @@
   for details.
   
   \author Bill Brown USACERL
+  \author Doxygenized by Martin Landa <landa.martin gmail.com> (May 2008)
 */
 
+#include <math.h>
+#include <stdio.h>
+
 #include <grass/gstypes.h>
 #include "gsget.h"
+
 #include "rowcol.h"
-#include <math.h>
-#include <stdio.h>
 
-
 #define NTOP 0x00001000
 #define NBOT 0x00000100
 #define NLFT 0x00000010
@@ -34,7 +36,9 @@
 #define NBL  0x00000110
 #define NBR  0x00000101
 
-/* This macro is only used in the function calc_norm() */
+/*!
+  \brief This macro is only used in the function calc_norm()
+*/
 #define SET_NORM(i) \
        dz1 = z1 - z2; \
        dz2 = z3 - z4; \
@@ -55,10 +59,16 @@
 static unsigned long *norm;
 
 /*
-#define USE_GL_NORMALIZE
+  #define USE_GL_NORMALIZE
 */
 
-/* for optimization */
+/*!
+  \brief Init variables
+
+  for optimization
+
+  \param gs surface (geosurf)
+*/
 void init_vars(geosurf * gs)
 {
     /* optimized - these are static - global to this file */
@@ -89,16 +99,27 @@
     return;
 }
 
-/* OPTIMIZED for constant dy & dx
- * The norm array is always the same size, but diff resolutions
- * force resampled data points to have their normals recalculated,
- * then only those norms are passed to n3f during drawing.
- * Norms are converted to a packed unsigned int for storage,
- * must be converted back at time of use.
- * TODO: fix to correctly calculate norms when mapped to sphere!
- */
-/* Uses the previous and next cells (when available) for normal 
-calculations to produce smoother normals */
+/*!
+  \brief Calculate normals
+
+  OPTIMIZED for constant dy & dx
+  
+  The norm array is always the same size, but diff resolutions
+  force resampled data points to have their normals recalculated,
+  then only those norms are passed to n3f during drawing.
+  Norms are converted to a packed unsigned int for storage,
+  must be converted back at time of use.
+  
+  \todo fix to correctly calculate norms when mapped to sphere!
+
+  Uses the previous and next cells (when available) for normal 
+  calculations to produce smoother normals
+
+  \param gs surface (geosurf)
+
+  \return 1 on success
+  \return 0 on failure
+*/
 int gs_calc_normals(geosurf * gs)
 {
     int row, col;
@@ -120,7 +141,7 @@
 
     init_vars(gs);
 
-    Gs_status("recalculating normals...");
+    G_debug (3, "recalculating normals...");
 
     /* first row - just use single cell */
     /* first col - use bottom & right neighbors */
@@ -137,7 +158,7 @@
     /* now use four neighboring points for rows 1 - (n-1) */
     for (row = 1; row < ycnt; row++) {
 	if (!(row % 100)) 
-		fprintf(stderr, "Row %d\r", row);
+	    G_debug (4, "  row %d", row);
 
 	/* turn off left neighbor for first col */
 	calc_norm(gs, row * ymod, 0, ~NLFT);
@@ -166,10 +187,21 @@
     return (1);
 }
 
-/****************************************************************/
-/* need either four neighbors or two non-linear neighbors */
-/* passed initial state of neighbors known from array position */
-/* and data row & col */
+/*!
+  \brief Calculate normals
+
+  Need either four neighbors or two non-linear neighbors
+  passed initial state of neighbors known from array position
+  and data row & col
+
+  \param gs surface (geosurf)
+  \param drow
+  \param dcol
+  \param neighbors
+
+  \return 0 no normals
+  \return 1 on success
+*/
 int calc_norm(geosurf * gs, int drow, int dcol, unsigned int neighbors)
 {
     long noffset;

Modified: grass/branches/develbranch_6/lib/ogsf/gsd_objs.c
===================================================================
--- grass/branches/develbranch_6/lib/ogsf/gsd_objs.c	2008-05-14 07:08:41 UTC (rev 31344)
+++ grass/branches/develbranch_6/lib/ogsf/gsd_objs.c	2008-05-14 16:04:40 UTC (rev 31345)
@@ -1,7 +1,7 @@
 /*!
   \file gsd_label.c
  
-  \brief OGSF library - objects management
+  \brief OGSF library - objects management (lower level functions)
  
   GRASS OpenGL gsurf OGSF Library 
  
@@ -13,6 +13,7 @@
   for details.
   
   \author Bill Brown USACERL (October 1993)
+  \author Doxygenized by Martin Landa <landa.martin gmail.com> (May 2008)
 */
 
 #include <stdio.h>
@@ -25,13 +26,11 @@
 #include "math.h"
 #include "rowcol.h"
 
-/*
-#define TRACE_DFUNCS
-*/
-
 static void init_stuff(void);
 
-/* vertices for octohedron */
+/*!
+  \brief vertices for octohedron
+*/
 float Octo[6][3] = {
     {1.0, 0.0, 0.0},
     {0.0, 1.0, 0.0},
@@ -43,7 +42,9 @@
 
 #define ONORM .57445626
 
-/* normals for flat-shaded octohedron */
+/*!
+  \brief normals for flat-shaded octohedron
+*/
 float OctoN[8][3] = {
     {ONORM, ONORM, ONORM},
     {-ONORM, ONORM, ONORM},
@@ -55,7 +56,8 @@
     {-ONORM, -ONORM, -ONORM},
 };
 
-/* ???? not sure if any of these are needed for correct lighting.
+/*!
+  ???? not sure if any of these are needed for correct lighting.
 float CubeNormals[6][3] = {
     {ONORM, 0, 0},
     {-ONORM, 0, 0},
@@ -89,10 +91,14 @@
 #define DOWN_NORM Octo[5]
 #define ORIGIN origin
 
-/* vertices & normals for octagon in xy plane */
+/*!
+  \brief vertices & normals for octagon in xy plane
+*/
 float ogverts[8][3];
 
-/* vertices for octagon in xy plane, z=1 */
+/*!
+  \brief vertices for octagon in xy plane, z=1
+*/
 float ogvertsplus[8][3];
 
 float Pi;
@@ -136,6 +142,13 @@
     return;
 }
 
+/*!
+  \brief ADD
+  
+  \param center center point
+  \param colr color value
+  \param siz size value
+*/
 void gsd_plus(float *center, int colr, float siz)
 {
     float v1[3], v2[3];
@@ -164,7 +177,15 @@
     return;
 }
 
-/* TODO: remove fudge, instead fudge the Z buffer */
+/*!
+  \brief Line on surface, fix z-values
+  
+  \todo remove fudge, instead fudge the Z buffer
+
+  \param gs surface (geosurf)
+  \param v1 first point
+  \param v2 second point
+*/
 void gsd_line_onsurf(geosurf * gs, float *v1, float *v2)
 {
     int i, np;
@@ -193,10 +214,22 @@
     return;
 }
 
-/* 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.
+/*!
+  \brief 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.
+
+  \param gs surface (geosurf)
+  \param v1 first point
+  \param v2 second point
+  \param pt
+  \param n number of segments
+
+  \param number of vertices
 */
 int gsd_nline_onsurf(geosurf * gs, float *v1, float *v2, float *pt, int n)
 {
@@ -231,7 +264,16 @@
     return (0);
 }
 
-/* Note gs: NULL if flat */
+/*!
+  \brief ADD
+
+  Note gs: NULL if flat
+
+  \param gs surface (geosurf)
+  \param center
+  \param colr color value
+  \param siz size value
+*/
 void gsd_x(geosurf * gs, float *center, int colr, float siz)
 {
     float v1[3], v2[3];
@@ -274,6 +316,13 @@
     return;
 }
 
+/*!
+  \brief Draw diamond symbol
+
+  \param center center point
+  \param colr color value
+  \param size size value
+*/
 void gsd_diamond(float *center, unsigned long colr, float siz)
 {
     int preshade;
@@ -367,8 +416,17 @@
     return;
 }
 
+/*!
+  \brief Draw cube
+
+  Added by Hamish Bowman Nov 2005
+
+  \param center center point
+  \param colr color value
+  \param siz size value
+*/
 void gsd_cube(float *center, unsigned long colr, float siz)
-{  /* added by Hamish Bowman Nov 2005 */
+{ 
     int preshade;
 
     /* see gsd_diamond() "seems right, but isn't" */
@@ -435,8 +493,17 @@
     return;
 }
 
+/*!
+  \brief Draw box
+
+  Added by Hamish Bowman Nov 2005
+
+  \param center center point
+  \param colr color value
+  \param siz size value
+*/
 void gsd_draw_box(float *center, unsigned long colr, float siz)
-{  /* added by Hamish Bowman Nov 2005 */
+{  
 
     /* see gsd_diamond() "seems right, but isn't" */
     siz *= .5;
@@ -486,6 +553,14 @@
 
     return;
 }
+
+/*!
+  \brief Draw sphere
+
+  \param center center point
+  \param colr color value
+  \param size size value
+*/
 void gsd_drawsphere(float *center, unsigned long colr, float siz)
 {
     siz *= .5;			/* siz is diameter, gsd_sphere uses radius */
@@ -495,6 +570,9 @@
     return;
 }
 
+/*!
+  \brief Draw diamond lines
+*/
 void gsd_diamond_lines(void)
 {
     gsd_bgnline();
@@ -515,6 +593,13 @@
     return;
 }
 
+/*!
+  \brief Draw asterisk
+
+  \param center center point
+  \param colr color value
+  \param siz size value
+*/
 void gsd_draw_asterisk(float *center, unsigned long colr, float siz)
 {
     float angle;
@@ -563,6 +648,13 @@
     return;
 }
 
+/*!
+  \brief Draw gyro
+
+  \param center center point
+  \param colr color value
+  \param siz size value
+ */
 void gsd_draw_gyro(float *center, unsigned long colr, float siz)
 {
     int i;
@@ -610,6 +702,11 @@
     return;
 }
 
+/*!
+  \brief Draw 3d cursor
+
+  \param pt point
+ */
 void gsd_3dcursor(float *pt)
 {
     float big, vert[3];
@@ -646,6 +743,14 @@
     return;
 }
 
+/*!
+  \brief ADD
+  
+  \param dir
+  \param slope
+  \param ascpect
+  \param degrees
+*/
 void dir_to_slope_aspect(float *dir, float *slope, float *aspect, int degrees)
 {
     float dx, dy, dz;
@@ -705,11 +810,19 @@
 }
 
 
-/**************************************************************
- * Function to draw North Arrow takes OpenGL coords and size
- *************************************************************/
+/*!
+  \brief Draw North Arrow takes OpenGL coords and size
+
+  \param pos2
+  \param len
+  \param fontbase
+  \param arw_clr north arrow color
+  \param text_clr text color
+
+  \return 1
+*/
 int gsd_north_arrow (float *pos2, float len, GLuint fontbase,
-	unsigned long arw_clr, unsigned long text_clr)
+		     unsigned long arw_clr, unsigned long text_clr)
 {
     char *txt;
     float v[4][3];
@@ -761,11 +874,11 @@
     glVertex3fv(v[0]);
     gsd_endpolygon();
 
-/* draw N for North */
-/* Need to pick a nice generic font */
-/* TODO -- project text position off arrow
- * bottom along azimuth
- */
+    /* draw N for North */
+    /* Need to pick a nice generic font */
+    /* TODO -- project text position off arrow
+     * bottom along azimuth
+     */
 
     gsd_color_func(text_clr);
     txt = "North";
@@ -785,14 +898,24 @@
 
 }
 
+/*!
+  \brief 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 
 
-
-/**************************************************************/
-/* 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 
+  \param center center point
+  \param colr color value
+  \param siz size value
+  \param dir
+  \param sz
+  \param onsurf surface (geosurf)
+  
+  \return 1 no surface given
+  \return 0 on surface
 */
 int gsd_arrow(float *center, unsigned long colr, float siz, float *dir,
 	      float sz, geosurf * onsurf)
@@ -855,7 +978,17 @@
     return (1);
 }
 
-/**************************************************************/
+/*!
+  \brief Draw north arrow on surface
+
+  \param base
+  \param tip
+  \param colr
+  \param wid
+  \param gs surface (geosurf)
+
+  \return 0
+*/
 int gsd_arrow_onsurf(float *base, float *tip, unsigned long colr, int wid,
 		     geosurf * gs)
 {
@@ -869,10 +1002,9 @@
     gsd_linewidth(wid);
     gsd_color_func(colr);
 
-    /* DEBUG
-       fprintf(stderr,"%f %f -> ", base[X], base[Y]);
-       fprintf(stderr,"%f %f\n", tip[X], tip[Y]);
-     */
+    G_debug (3, "gsd_arrow_onsurf");
+    G_debug (3, "  %f %f -> %f %f", base[X], base[Y], tip[X], tip[Y]);
+    
     gsd_line_onsurf(gs, base, tip);
 
 #ifdef DO_SPHERE_BASE
@@ -888,52 +1020,45 @@
 	base[Z] = tip[Z] = 0.0;
 	GS_v3dir(tip, base, dir0);
 
-	/* DEBUG
-	   fprintf(stderr,"dir0: %f %f %f\n", dir0[X], dir0[Y], dir0[Z]);
-	 */
+	G_debug (3, "  dir0: %f %f %f", dir0[X], dir0[Y], dir0[Z]);
 
 	/* rotate this direction 90 degrees */
 	GS_v3cross(dir0, UP_NORM, dir2);
 	GS_v3mag(dir0, &len);
 	GS_v3eq(dir1, dir0);
 
-	/* DEBUG
-	   fprintf(stderr,"len: %f\n", len);
-	   fprintf(stderr,"a-dir1: %f %f %f\n", dir1[X], dir1[Y], dir1[Z]);
-	   fprintf(stderr,"a-dir2: %f %f %f\n", dir2[X], dir2[Y], dir2[Z]);
-	 */
+	G_debug (3, "  len: %f", len);
+	G_debug (3, "  a-dir1: %f %f %f", dir1[X], dir1[Y], dir1[Z]);
+	G_debug (3, "  a-dir2: %f %f %f", dir2[X], dir2[Y], dir2[Z]);
+
 	dim1 = len * .7;
 	dim2 = len * .2;
 	GS_v3mult(dir1, dim1);
 	GS_v3mult(dir2, dim2);
 
-	/* DEBUG
-	   fprintf(stderr,"b-dir1: %f %f %f\n", dir1[X], dir1[Y], dir1[Z]);
-	   fprintf(stderr,"b-dir2: %f %f %f\n", dir2[X], dir2[Y], dir2[Z]);
-	 */
+	G_debug (3, "  b-dir1: %f %f %f", dir1[X], dir1[Y], dir1[Z]);
+	G_debug (3, "  b-dir2: %f %f %f", dir2[X], dir2[Y], dir2[Z]);
+
 	GS_v3eq(tmp, base);
 	GS_v3add(tmp, dir1);
 	GS_v3add(tmp, dir2);
 
-	/* DEBUG
-	   fprintf(stderr,"%f %f -> ", tmp[X], tmp[Y]);
-	 */
+	G_debug (3, "  %f %f -> ", tmp[X], tmp[Y]);
+
 	gsd_line_onsurf(gs, tmp, tip);
 
 	GS_v3cross(dir0, DOWN_NORM, dir2);
 	GS_v3mult(dir2, dim2);
 	GS_v3eq(tmp, base);
 
-	/* DEBUG
-	   fprintf(stderr,"dir1: %f %f %f\n", dir1[X], dir1[Y], dir1[Z]);
-	   fprintf(stderr,"dir2: %f %f %f\n", dir2[X], dir2[Y], dir2[Z]);
-	 */
+	G_debug (3, "  dir1: %f %f %f", dir1[X], dir1[Y], dir1[Z]);
+	G_debug (3, "  dir2: %f %f %f", dir2[X], dir2[Y], dir2[Z]);
+
 	GS_v3add(tmp, dir1);
 	GS_v3add(tmp, dir2);
 
-	/* DEBUG
-	   fprintf(stderr,"%f %f\n", tmp[X], tmp[Y]);
-	 */
+	G_debug (3, "  %f %f", tmp[X], tmp[Y]);
+
 	gsd_line_onsurf(gs, tip, tmp);
     }
 #endif
@@ -941,9 +1066,16 @@
     return (0);
 }
 
+/*!
+  \brief Draw 3d north arrow
 
-/**************************************************************/
-/* siz1 is height, siz2 is diameter */
+  \param center center point
+  \param colr color value
+  \param siz1 height
+  \param siz2 is diameter
+  \param dir
+  \param sz
+*/
 void gsd_3darrow(float *center, unsigned long colr, float siz1, float siz2,
 		 float *dir, float sz)
 {
@@ -951,26 +1083,21 @@
     int preshade;
     static int first = 1;
     static int list;
+    static int debugint = 1;
 
     dir[Z] /= sz;
 
     GS_v3norm(dir);
     dir_to_slope_aspect(dir, &slope, &aspect, 1);
 
-#ifdef DEBUG
-    {
-	static int debugint = 1;
-
-	if (debugint > 100) {
-	    fprintf(stderr,
-		    "pt: %f,%f,%f dir: %f,%f,%f slope: %f aspect: %f\n",
-		    center[X], center[Y], center[Z], dir[X], dir[Y], dir[Z],
-		    slope, aspect);
-	    debugint = 1;
-	}
-	debugint++;
+    if (debugint > 100) {
+	G_debug (3, "gsd_3darrow()");
+	G_debug (3, "  pt: %f,%f,%f dir: %f,%f,%f slope: %f aspect: %f",
+		 center[X], center[Y], center[Z], dir[X], dir[Y], dir[Z],
+		 slope, aspect);
+	debugint = 1;
     }
-#endif
+    debugint++;
 
     preshade = gsd_getshademodel();
 
@@ -1016,11 +1143,18 @@
     return;
 }
 
-
-/**************************************************************
- * Function to draw Scalebar takes OpenGL coords and size
- *  adapted from gsd_north_arrow Hamish Bowman Dec 2006
- *************************************************************/
+/*!
+  \brief Draw Scalebar takes OpenGL coords and size
+  
+  Adapted from gsd_north_arrow Hamish Bowman Dec 2006
+  
+  \param pos2
+  \param fontbase font-base
+  \param bar_clr barscale color
+  \param text_clr text color
+  
+  \return 1
+*/
 int gsd_scalebar (float *pos2, float len, GLuint fontbase,
 	unsigned long bar_clr, unsigned long text_clr)
 {
@@ -1097,10 +1231,13 @@
     return (1);
 }
 
+/*!
+  \brief Primitives only called after transforms
 
+  Center is actually center at base of 8 sided cone
 
-/* primitives only called after transforms */
-/* center is actually center at base of 8 sided cone */
+  \param col color value
+*/
 void primitive_cone(unsigned long col)
 {
     float tip[3];
@@ -1130,8 +1267,14 @@
     return;
 }
 
-/* primitives only called after transforms */
-/* center is actually center at base of 8 sided cylinder */
+/*!
+  \brief Primitives only called after transforms
+
+  Center is actually center at base of 8 sided cylinder
+
+  \param col color value
+  \param caps
+*/
 void primitive_cylinder(unsigned long col, int caps)
 {
     static int first = 1;
@@ -1197,22 +1340,32 @@
 
 /*** ACS_MODIFY_BEGIN - sites_attribute management ********************************/
 /*
- Draws boxes that are used for histograms by gpd_obj function in gpd.c
- for site_attribute management
+  Draws boxes that are used for histograms by gpd_obj function in gpd.c
+  for site_attribute management
 */
 
- /* vertices for box */
+/*!
+  \brief Vertices for box
+*/
 float Box[8][3] = {{ 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}};
+		   { 1.0, -1.0, -1.0},{-1.0, -1.0, -1.0},{-1.0, -1.0,  1.0},{ 1.0, -1.0,  1.0}};
 
 float BoxN[6][3] = {{0, 0, -ONORM},{0, 0, ONORM},{0, ONORM, 0},{0, -ONORM, 0},{ONORM, 0, 0},{-ONORM, 0, 0}};
 
-/* Warning siz is an array (we need it for scale only Z in histograms) */
+/*!
+  \brief Draw box
+
+  Warning siz is an array (we need it for scale only Z in histograms)
+
+  \param center center point
+  \param colr color value
+  \param siz size value
+*/
 void gsd_box(float *center, int colr, float *siz)
 {
     int preshade;
 
-	gsd_pushmatrix();
+    gsd_pushmatrix();
     gsd_translate(center[X], center[Y], center[Z] + siz[2]);
     gsd_scale(siz[0], siz[1], siz[2]);
     preshade = gsd_getshademodel();

Modified: grass/branches/develbranch_6/lib/ogsf/gsd_prim.c
===================================================================
--- grass/branches/develbranch_6/lib/ogsf/gsd_prim.c	2008-05-14 07:08:41 UTC (rev 31344)
+++ grass/branches/develbranch_6/lib/ogsf/gsd_prim.c	2008-05-14 16:04:40 UTC (rev 31345)
@@ -1,7 +1,7 @@
 /*!
   \file gsd_prim.c
  
-  \brief OGSF library - primitive drawing functions
+  \brief OGSF library - primitive drawing functions (lower level functions)
  
   GRASS OpenGL gsurf OGSF Library 
  
@@ -13,10 +13,9 @@
   for details.
   
   \author Bill Brown USACERL (January 1993)
+  \author Doxygenized by Martin Landa <landa.martin gmail.com> (May 2008)
 */
 
-/* DEBUG */
-#include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 
@@ -32,6 +31,7 @@
 
 #include <grass/gis.h>
 #include <grass/gstypes.h>
+#include <grass/glocale.h>
 
 #define USE_GL_NORMALIZE
 
@@ -66,9 +66,10 @@
 static float ogl_mat_emis[4];
 static float ogl_mat_shin;
 
-/************************************************************************/
-/* Mostly for flushing drawing commands accross a network - glFlush
-*  doesn't block, so if blocking is desired use glFinish.
+/*!
+  \brief Mostly for flushing drawing commands accross a network
+
+  glFlush doesn't block, so if blocking is desired use glFinish.
 */
 void gsd_flush(void)
 {
@@ -77,8 +78,13 @@
     return;
 }
 
-/************************************************************************/
-/* Call glColorMaterial before enabling the GL_COLOR_MATERIAL */
+/*!
+  \brief ADD
+
+  Call glColorMaterial before enabling the GL_COLOR_MATERIAL
+
+  \param cm
+*/
 void gsd_colormode(int cm)
 {
     switch (cm) {
@@ -129,18 +135,25 @@
     return;
 }
 
-/************************************************************************/
+/*!
+  \brief Print color mode to stderr
+*/
 void show_colormode(void)
 {
     GLint mat;
 
     glGetIntegerv(GL_COLOR_MATERIAL_PARAMETER, &mat);
-    fprintf(stderr, "Color Material: %d\n", mat);
+    G_message (_("Color Material: %d"), mat);
 
     return;
 }
 
-/************************************************************************/
+/*!
+  \brief ADD
+  
+  \param x,y
+  \param rad
+*/
 void gsd_circ(float x, float y, float rad)
 {
     GLUquadricObj *qobj = gluNewQuadric();
@@ -154,7 +167,12 @@
     return;
 }
 
-/************************************************************************/
+/*!
+  \brief ADD
+
+  \param x,y,z
+  \param rad
+*/
 void gsd_disc(float x, float y, float z, float rad)
 {
     GLUquadricObj *qobj = gluNewQuadric();
@@ -168,7 +186,12 @@
     return;
 }
 
-/************************************************************************/
+/*!
+  \brief ADD
+
+  \param center center-point
+  \param siz size value
+*/
 void gsd_sphere(float *center, float siz)
 {
     static int first = 1;
@@ -195,7 +218,11 @@
     return;
 }
 
-/************************************************************************/
+/*!
+  \brief Write out z-mask
+
+  \param n
+*/
 void gsd_zwritemask(unsigned long n)
 {
     /* OGLXXX glDepthMask is boolean only */
@@ -204,7 +231,11 @@
     return;
 }
 
-/************************************************************************/
+/*!
+  \brief ADD
+
+  \param n
+*/
 void gsd_backface(int n)
 {
     glCullFace(GL_BACK);
@@ -213,7 +244,11 @@
     return;
 }
 
-/************************************************************************/
+/*!
+  \brief ADD
+
+  \param n line width
+*/
 void gsd_linewidth(short n)
 {
     glLineWidth((GLfloat) (n));
@@ -221,7 +256,9 @@
     return;
 }
 
-/************************************************************************/
+/*!
+  \brief ADD
+*/
 void gsd_bgnqstrip(void)
 {
     glBegin(GL_QUAD_STRIP);
@@ -229,7 +266,9 @@
     return;
 }
 
-/************************************************************************/
+/*!
+  \brief ADD
+*/
 void gsd_endqstrip(void)
 {
     glEnd();
@@ -237,7 +276,9 @@
     return;
 }
 
-/************************************************************************/
+/*!
+  \brief ADD
+*/
 void gsd_bgntmesh(void)
 {
     glBegin(GL_TRIANGLE_STRIP);
@@ -245,7 +286,9 @@
     return;
 }
 
-/************************************************************************/
+/*!
+  \brief ADD
+*/
 void gsd_endtmesh(void)
 {
     glEnd();
@@ -253,7 +296,9 @@
     return;
 }
 
-/************************************************************************/
+/*!
+  \brief ADD
+*/
 void gsd_bgntstrip(void)
 {
     glBegin(GL_TRIANGLE_STRIP);
@@ -261,7 +306,9 @@
     return;
 }
 
-/************************************************************************/
+/*!
+  \brief ADD
+*/
 void gsd_endtstrip(void)
 {
     glEnd();
@@ -269,7 +316,9 @@
     return;
 }
 
-/************************************************************************/
+/*!
+  \brief ADD
+*/
 void gsd_bgntfan(void)
 {
     glBegin(GL_TRIANGLE_FAN);
@@ -277,7 +326,9 @@
     return;
 }
 
-/************************************************************************/
+/*!
+  \brief ADD
+*/
 void gsd_endtfan(void)
 {
     glEnd();
@@ -285,7 +336,9 @@
     return;
 }
 
-/************************************************************************/
+/*!
+  \brief ADD
+*/
 void gsd_swaptmesh(void)
 {
     /* OGLXXX
@@ -298,7 +351,9 @@
     return;
 }
 
-/************************************************************************/
+/*!
+  \brief ADD
+*/
 void gsd_bgnpolygon(void)
 {
     /* OGLXXX
@@ -311,7 +366,9 @@
     return;
 }
 
-/************************************************************************/
+/*!
+  \brief ADD
+*/
 void gsd_endpolygon(void)
 {
     glEnd();
@@ -319,7 +376,9 @@
     return;
 }
 
-/************************************************************************/
+/*!
+  \brief Begin line
+*/
 void gsd_bgnline(void)
 {
     /* OGLXXX for multiple, independent line segments: use GL_LINES */
@@ -327,7 +386,9 @@
     return;
 }
 
-/************************************************************************/
+/*!
+  \brief End line
+*/
 void gsd_endline(void)
 {
     glEnd();
@@ -335,7 +396,11 @@
     return;
 }
 
-/************************************************************************/
+/*!
+  \brief Shaded model
+
+  \param bool type
+*/
 void gsd_shademodel(int bool)
 {
     Shade = bool;
@@ -350,13 +415,19 @@
     return;
 }
 
-/************************************************************************/
+/*!
+  \brief Get shaded model
+
+  \return shade
+*/
 int gsd_getshademodel(void)
 {
     return (Shade);
 }
 
-/************************************************************************/
+/*!
+  \brief ADD
+*/
 void gsd_bothbuffer(void)
 {
     /* OGLXXX frontbuffer: other possibilities include GL_FRONT_AND_BACK */
@@ -365,7 +436,9 @@
     return;
 }
 
-/************************************************************************/
+/*!
+  \brief ADD
+*/
 void gsd_frontbuffer(int bool)
 {
     /* OGLXXX frontbuffer: other possibilities include GL_FRONT_AND_BACK */
@@ -374,7 +447,11 @@
     return;
 }
 
-/************************************************************************/
+/*!
+  \brief ADD
+
+  \param bool
+*/
 void gsd_backbuffer(int bool)
 {
     /* OGLXXX backbuffer: other possibilities include GL_FRONT_AND_BACK */
@@ -382,7 +459,9 @@
     return;
 }
 
-/************************************************************************/
+/*!
+  \brief ADD
+*/
 void gsd_swapbuffers(void)
 {
     /* OGLXXX swapbuffers: 
@@ -394,7 +473,9 @@
     return;
 }
 
-/************************************************************************/
+/*!
+  \brief ADD
+*/
 void gsd_popmatrix(void)
 {
     glPopMatrix();
@@ -402,7 +483,9 @@
     return;
 }
 
-/************************************************************************/
+/*!
+  \brief ADD
+*/
 void gsd_pushmatrix(void)
 {
     glPushMatrix();
@@ -410,7 +493,9 @@
     return;
 }
 
-/************************************************************************/
+/*!
+  \brief ADD
+*/
 void gsd_scale(float xs, float ys, float zs)
 {
     glScalef(xs, ys, zs);
@@ -418,7 +503,9 @@
     return;
 }
 
-/************************************************************************/
+/*!
+  \brief ADD
+*/
 void gsd_translate(float dx, float dy, float dz)
 {
     glTranslatef(dx, dy, dz);
@@ -426,7 +513,14 @@
     return;
 }
 
-/************************************************************************/
+/*!
+  \brief ADD
+
+  \param window
+  \param viewport
+  \param modelMatrix
+  \param projMatrix
+*/
 void gsd_getwindow(int *window, int *viewport, double *modelMatrix,
 		   double *projMatrix)
 {
@@ -447,7 +541,18 @@
 
 }
 
-/************************************************************************/
+/*!
+  \brief ADD
+
+  \param pt
+  \param widnow
+  \param viewport
+  \param doubleMatrix
+  \param projMatrix
+
+  \return 0
+  \return 1
+*/
 int gsd_checkpoint(float pt[4],
 		   int window[4],
 		   int viewport[4],
@@ -466,13 +571,17 @@
 
 }
 
-/************************************************************************/
+/*!
+  \brief ADD
+  
+  \param angle
+  \param axis
+*/
 void gsd_rot(float angle, char axis)
 {
     GLfloat x;
     GLfloat y;
     GLfloat z;
-    char wrnMsg[512];
 
     switch (axis) {
     case 'x':
@@ -501,11 +610,10 @@
 	break;
     default:
 
-	sprintf(wrnMsg, "gsd_rot(): %c is an invalid axis ", axis);
-	strcat(wrnMsg, "specification. Rotation ignored\n");
-	strcat(wrnMsg, "Please advise GRASS developers of this error.\n");
-
-	G_warning(wrnMsg);
+	G_warning (_("gsd_rot(): %c is an invalid axis "
+		     "specification. Rotation ignored. "
+		     "Please advise GRASS developers of this error"),
+		     axis);
 	return;
     }
 
@@ -514,7 +622,13 @@
     return;
 }
 
-/************************************************************************/
+/*!
+  \brief ADD
+
+  \param norm
+  \param col
+  \param pt
+*/
 void gsd_litvert_func(float *norm, unsigned long col, float *pt)
 {
     glNormal3fv(norm);
@@ -524,7 +638,13 @@
     return;
 }
 
-/************************************************************************/
+/*!
+  \brief ADD
+  
+  \param norm
+  \param col
+  \param pt
+*/
 void gsd_litvert_func2(float *norm, unsigned long col, float *pt)
 {
     glNormal3fv(norm);
@@ -533,7 +653,11 @@
     return;
 }
 
-/************************************************************************/
+/*!
+  \brief ADD
+
+  \param pt
+*/
 void gsd_vert_func(float *pt)
 {
     glVertex3fv(pt);
@@ -541,7 +665,11 @@
     return;
 }
 
-/************************************************************************/
+/*!
+  \brief ADD
+
+  \param col
+*/
 void gsd_color_func(unsigned int col)
 {
     GLbyte r, g, b, a;
@@ -560,7 +688,9 @@
     return;
 }
 
-/************************************************************************/
+/*!
+  \brief ADD
+*/
 void gsd_init_lightmodel(void)
 {
 
@@ -635,14 +765,16 @@
      if(1) {glCallList(1); glEnable(GL_FRONT);} else glDisable(GL_FRONT);
      */
 
-
     return;
 }
 
-/************************************************************************/
-/* set_shin, set_emis  flags */
-/* sh, em    sh & em should be 0. - 1. */
-/* emcolor   packed colors to use for emission */
+/*!
+  \brief Set material
+  
+  \param set_shin,set_emis  flags
+  \param sh,em should be 0. - 1. 
+  \param emcolor packed colors to use for emission
+*/
 void gsd_set_material(int set_shin, int set_emis, float sh, float em,
 		      int emcolor)
 {
@@ -670,7 +802,12 @@
     return;
 }
 
-/************************************************************************/
+/*!
+  \brief Define light
+
+  \param num
+  \param vals
+*/
 void gsd_deflight(int num, struct lightdefs *vals)
 {
     if (num > 0 && num <= MAX_LIGHTS) {
@@ -706,8 +843,12 @@
     return;
 }
 
-/************************************************************************/
-/* on = 0 turns them off */
+/*!
+  \brief Switch light on/off
+
+  \param num
+  \param on 1 for 'on', 0 turns them off
+*/
 void gsd_switchlight(int num, int on)
 {
     short defin;
@@ -724,7 +865,15 @@
     return;
 }
 
-/************************************************************************/
+/*!
+  \brief Get image
+
+  \param pixbuf data buffer
+  \param[out] xsize,ysize picture dimension
+
+  \return 0 on failure
+  \return 1 on success
+*/
 int gsd_getimage(unsigned char **pixbuf, unsigned int *xsize,
 		 unsigned int *ysize)
 {
@@ -745,7 +894,7 @@
     *xsize = r - l + 1;
     *ysize = t - b + 1;
 
-    *pixbuf = malloc(*xsize * *ysize * 4);
+    *pixbuf = (unsigned char *) G_malloc((*xsize) * (*ysize) * 4); /* G_fatal_error */
 
     if (!*pixbuf)
 	return (0);
@@ -755,10 +904,18 @@
     /* OGLXXX lrectread: see man page for glReadPixels */
     glReadPixels(l, b, (r) - (l) + 1, (t) - (b) + 1, GL_RGBA,
 		 GL_UNSIGNED_BYTE, *pixbuf);
+
     return (1);
 }
 
-/************************************************************************/
+/*!
+  \brief Get viewpoint
+
+  \param tmp
+  \param num
+
+  \return 1
+*/
 int gsd_getViewport(GLint tmp[4], GLint num[2])
 {
 
@@ -769,16 +926,19 @@
     return (1);
 }
 
+/*!
+  \brief Write view
 
-/************************************************************************/
+  \param pixbuf data buffer
+  \param xsize,ysize picture dimension
+*/
 int gsd_writeView(unsigned char **pixbuf, unsigned int xsize,
 		  unsigned int ysize)
 {
 
     /* Malloc Buffer for image */
-    *pixbuf = malloc(xsize * ysize * 4);
+    *pixbuf = (unsigned char *) G_malloc(xsize * ysize * 4); /* G_fatal_error */
     if (!*pixbuf) {
-	fprintf(stderr, "MALLOC Failed\n");
 	return (0);
     }
 
@@ -790,7 +950,11 @@
     return (1);
 }
 
-/************************************************************************/
+/*!
+  \brief ADD
+
+  \param yesno turn on/off
+*/
 void gsd_blend(int yesno)
 {
     if (yesno) {
@@ -805,7 +969,12 @@
     return;
 }
 
-/************************************************************************/
+/*!
+  \brief Define clip plane
+
+  \param num
+  \param params
+*/
 void gsd_def_clipplane(int num, double *params)
 {
     int wason = 0;
@@ -827,7 +996,12 @@
     return;
 }
 
-/************************************************************************/
+/*!
+  \brief Set clip plane
+
+  \param num
+  \param able
+*/
 void gsd_set_clipplane(int num, int able)
 {
     /* OGLXXX see man page for glClipPlane equation */
@@ -841,15 +1015,24 @@
     return;
 }
 
-/************************************************************************/
-/* does nothing */
-/* only called from src.contrib/GMSL/NVIZ2.2/src/glwrappers.c */
+/*!
+  \brief Finish
+
+  Does nothing, only called from src.contrib/GMSL/NVIZ2.2/src/glwrappers.c
+*/
 void gsd_finish(void)
 {
     return;
 }
 
-/************************************************************************/
+/*!
+  \brief ADD
+  
+  \param l
+  \param r
+  \param b
+  \param t
+*/
 void gsd_viewport(int l, int r, int b, int t)
 {
     /* Screencoord */
@@ -858,9 +1041,14 @@
     return;
 }
 
-/************************************************************************/
-/* first time called, gets a bunch of objects, then hands them back
- * when needed
+/*!
+  \brief ADD
+
+  First time called, gets a bunch of objects, then hands them back
+  when needed
+
+  \return -1 on failure
+  \return number of objects
 */
 int gsd_makelist(void)
 {
@@ -888,7 +1076,12 @@
 
 }
 
-/************************************************************************/
+/*!
+  \brief ADD
+  
+  \param listno
+  \param do_draw
+*/
 void gsd_bgnlist(int listno, int do_draw)
 {
     if (do_draw) {
@@ -901,7 +1094,9 @@
     return;
 }
 
-/************************************************************************/
+/*!
+  \brief End list
+*/
 void gsd_endlist(void)
 {
     glEndList();
@@ -909,10 +1104,15 @@
     return;
 }
 
-/*****************************************************************/
+/*!
+  \brief Delete list
+
+  \param listno
+  \param range
+*/
 void gsd_deletelist(GLuint listno, int range)
 {
-    int i;
+    unsigned int i;
 
     for (i = 1; i < MAX_OBJS; i++) {
 	if (i == listno) {
@@ -925,7 +1125,11 @@
     }
 }
 
-/************************************************************************/
+/*!
+  \brief ADD
+
+  \param listno
+*/
 void gsd_calllist(int listno)
 {
     glCallList(ObjList[listno]);
@@ -934,7 +1138,11 @@
 }
 
 
-/************************************************************************/
+/*!
+  \brief ADD
+
+  \param listno
+*/
 void gsd_calllists(int listno)
 {
     int i;
@@ -947,5 +1155,6 @@
     gsd_popmatrix();
 
     gsd_call_label();
+
     return;
 }

Modified: grass/branches/develbranch_6/lib/ogsf/gsd_views.c
===================================================================
--- grass/branches/develbranch_6/lib/ogsf/gsd_views.c	2008-05-14 07:08:41 UTC (rev 31344)
+++ grass/branches/develbranch_6/lib/ogsf/gsd_views.c	2008-05-14 16:04:40 UTC (rev 31345)
@@ -1,7 +1,7 @@
 /*!
   \file gsd_views.c
  
-  \brief OGSF library - manipulating views
+  \brief OGSF library - manipulating views (lower level functions)
  
   GRASS OpenGL gsurf OGSF Library 
 
@@ -13,6 +13,7 @@
   for details.
   
   \author Bill Brown USACERL (January 1993)
+  \author Doxygenized by Martin Landa <landa.martin gmail.com> (May 2008)
 */
 
 /* DEBUG */
@@ -31,12 +32,14 @@
 #include <grass/gstypes.h>
 #include "math.h"
 
-/*
-#define TRACE_DFUNCS
+/*!
+  \brief ADD
+
+  \param vect
+  \param sx, sy  screen coordinates
+
+  \return 1
 */
-
-/************************************************************************/
-/* sx, sy  screen coordinates */
 int gsd_get_los(float (*vect)[3], short sx, short sy)
 {
     double fx, fy, fz, tx, ty, tz;
@@ -89,8 +92,14 @@
 }
 
 
-/************************************************************************/
-/* establishes viewing & projection matrices */
+/*!
+  \brief Set view
+  
+  Establishes viewing & projection matrices
+
+  \param gv view (geoview)
+  \param dp display (geodisplay)
+*/
 void gsd_set_view(geoview * gv, geodisplay * gd)
 {
     double up[3];
@@ -129,7 +138,11 @@
     return;
 }
 
-/************************************************************************/
+/*!
+  \brief Check focus
+
+  \param gv view (geoview)
+*/
 void gsd_check_focus(geoview * gv)
 {
     float zmax, zmin;
@@ -148,7 +161,12 @@
     return;
 }
 
-/************************************************************************/
+/*!
+  \brief ADD
+
+  \param gv view (geoview)
+  \param up
+*/
 void gsd_get_zup(geoview * gv, double *up)
 {
     float alpha;
@@ -177,7 +195,13 @@
     return;
 }
 
-/************************************************************************/
+/*!
+  \brief ADD
+
+  \param gv view (geoview)
+
+  \return ?
+*/
 int gsd_zup_twist(geoview * gv)
 {
     float fr_to[2][4];
@@ -251,11 +275,14 @@
 	}
     }
 
-
     return ((int) (gv->twist + 1800 + look_theta));
 }
 
-/************************************************************************/
+/*!
+  \brief ADD
+
+  \param doexag
+*/
 void gsd_do_scale(int doexag)
 {
     float sx, sy, sz;
@@ -269,7 +296,11 @@
     return;
 }
 
-/************************************************************************/
+/*!
+  \brief Convert real to model coordinates
+
+  \param point[in,out] 3d point (Point3)
+*/
 void gsd_real2model(Point3 point)
 {
     float sx, sy, sz;
@@ -285,7 +316,11 @@
     return;
 }
 
-/************************************************************************/
+/*!
+  \brief Convert model to real coordinates
+
+  \param point[in,out] 3d point (Point3)
+*/
 void gsd_model2real(Point3 point)
 {
     float sx, sy, sz;
@@ -301,7 +336,12 @@
     return;
 }
 
-/************************************************************************/
+/*!
+  \brief Convert model to surface coordinates
+
+  \param gs surface (geosurf)
+  \param point 3d point (Point3)
+*/
 void gsd_model2surf(geosurf * gs, Point3 point)
 {
     float min, max, sx, sy, sz;
@@ -309,7 +349,7 @@
     /* so far, only one geographic "region" allowed, so origin of
        surface is same as origin of model space, but will need to provide 
        translations here to make up the difference, so not using gs yet */
-
+    
     if (gs) {
 	/* need to undo z scaling & translate */
 	GS_get_scale(&sx, &sy, &sz, 1);
@@ -325,7 +365,12 @@
     return;
 }
 
-/************************************************************************/
+/*!
+  \brief Convert surface to real coordinates
+
+  \param gs surface (geosurf)
+  \param[in,out] point 3d point (Point3)
+*/
 void gsd_surf2real(geosurf * gs, Point3 point)
 {
     if (gs) {
@@ -336,7 +381,12 @@
     return;
 }
 
-/************************************************************************/
+/*!
+  \brief Convert real to surface coordinates
+
+  \param gs surface (geosurf)
+  \param[in,out] point 3d point (Point3)
+*/
 void gsd_real2surf(geosurf * gs, Point3 point)
 {
     if (gs) {



More information about the grass-commit mailing list