[GRASS-SVN] r31339 - grass/trunk/lib/ogsf
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue May 13 18:02:52 EDT 2008
Author: martinl
Date: 2008-05-13 18:02:52 -0400 (Tue, 13 May 2008)
New Revision: 31339
Modified:
grass/trunk/lib/ogsf/gsd_cplane.c
grass/trunk/lib/ogsf/gsd_fonts.c
grass/trunk/lib/ogsf/gsd_fringe.c
grass/trunk/lib/ogsf/gsd_img_mpeg.c
grass/trunk/lib/ogsf/gsd_img_ppm.c
grass/trunk/lib/ogsf/gsd_img_tif.c
grass/trunk/lib/ogsf/gsd_label.c
grass/trunk/lib/ogsf/gsd_legend.c
grass/trunk/lib/ogsf/gsdiff.c
Log:
ogsf: Initial doxygenization
fprintf -> G_m/w/e
Modified: grass/trunk/lib/ogsf/gsd_cplane.c
===================================================================
--- grass/trunk/lib/ogsf/gsd_cplane.c 2008-05-13 21:57:45 UTC (rev 31338)
+++ grass/trunk/lib/ogsf/gsd_cplane.c 2008-05-13 22:02:52 UTC (rev 31339)
@@ -1,7 +1,7 @@
/*!
\file gsd_cplane.c
- \brief OGSF library - loading and manipulating surfaces
+ \brief OGSF library - manipulating surfaces (lower level functions)
GRASS OpenGL gsurf OGSF Library
@@ -13,6 +13,7 @@
for details.
\author Bill Brown USACERL, GMSL/University of Illinois (January 1993)
+ \author Doxygenized by Martin Landa <landa.martin gmail.com> (May 2008)
*/
/* DEBUG */
@@ -47,7 +48,13 @@
return;
}
-/************************************************************************/
+/*!
+ \brief Define cplace
+
+ \param num
+ \param pt
+ \param norm
+*/
void gsd_def_cplane(int num, float *pt, float *norm)
{
float sx, sy, sz, ppt[3];
@@ -74,8 +81,11 @@
return;
}
-/************************************************************************/
-/* called when viewing matrix changes */
+/*!
+ \brief Update cplaces
+
+ Called when viewing matrix changes
+*/
void gsd_update_cplanes(void)
{
int i;
@@ -89,7 +99,11 @@
return;
}
-/************************************************************************/
+/*!
+ \brief ADD
+
+ \param num
+*/
void gsd_cplane_on(int num)
{
static int first = 1;
@@ -107,7 +121,11 @@
return;
}
-/************************************************************************/
+/*!
+ \brief ADD
+
+ \param num
+*/
void gsd_cplane_off(int num)
{
@@ -117,8 +135,13 @@
return;
}
-/************************************************************************/
-/* onstate MUST be big enough to hold MAX_CPLANES ints */
+/*!
+ \brief Get cplane state
+
+ <i>onstate</i> MUST be big enough to hold MAX_CPLANES ints
+
+ \param onstate
+*/
void gsd_get_cplanes_state(int *onstate)
{
int i;
@@ -130,9 +153,15 @@
return;
}
-/************************************************************************/
-/* planes MUST be big enough to hold MAX_CPLANES Point4s */
-/* returns surface coordinates, normal pointing away from visible side */
+/*!
+ \brief Get cplaces
+
+ Planes MUST be big enough to hold MAX_CPLANES Point4s
+
+ \param places surface coordinates, normal pointing away from visible side
+
+ \return ADD
+*/
int gsd_get_cplanes(Point4 * planes)
{
int i, ons;
@@ -154,7 +183,11 @@
return (ons);
}
-/************************************************************************/
+/*!
+ \brief ADD
+
+ \param num
+*/
void gsd_update_cpnorm(int num)
{
float v[1][4];
@@ -172,7 +205,12 @@
return;
}
-/************************************************************************/
+/*!
+ \brief ADD
+
+ \param num
+ \param rx,ry,rz
+*/
void gsd_cplane_setrot(int num, float rx, float ry, float rz)
{
Cp_rot[num][X] = rx;
@@ -185,7 +223,12 @@
return;
}
-/************************************************************************/
+/*!
+ \brief ADD
+
+ \param num
+ \param tx,ty,tz
+*/
void gsd_cplane_settrans(int num, float tx, float ty, float tz)
{
Cp_trans[num][X] = tx;
@@ -197,7 +240,13 @@
return;
}
-/************************************************************************/
+/*!
+ \brief ADD
+
+ \param surf1 first surface (geosurf)
+ \param surf2 second surface (geosurf) [unused]
+ \param cpnum
+*/
void gsd_draw_cplane_fence(geosurf * surf1, geosurf * surf2, int cpnum)
{
int was_on;
@@ -242,7 +291,11 @@
return;
}
-/************************************************************************/
+/*!
+ \brief Draw cplane
+
+ \param num
+*/
void gsd_draw_cplane(int num)
{
float size, cpv[3];
Modified: grass/trunk/lib/ogsf/gsd_fonts.c
===================================================================
--- grass/trunk/lib/ogsf/gsd_fonts.c 2008-05-13 21:57:45 UTC (rev 31338)
+++ grass/trunk/lib/ogsf/gsd_fonts.c 2008-05-13 22:02:52 UTC (rev 31339)
@@ -15,17 +15,24 @@
for details.
\author Bill Brown USACERL, GMSL/University of Illinois
+ \author Doxygenized by Martin Landa <landa.martin gmail.com> (May 2008)
*/
#include <string.h>
#include <assert.h>
#include <grass/gstypes.h>
#include <grass/ogsf_proto.h>
+
#include "rgbpack.h"
+/*!
+ \brief Get text width
+ \param s text string
+ \param size size
-/****************************************/
+ \return text width
+*/
int gsd_get_txtwidth(char *s, int size)
{
int width, len;
@@ -36,8 +43,13 @@
return (width);
}
+/*!
+ \brief Get text height
-/*****************************************/
+ \param size size
+
+ \return text height
+*/
int gsd_get_txtheight(int size)
{
unsigned long height;
@@ -48,30 +60,41 @@
}
+/*!
+ \brief Get text descender
-/*****************************************/
+ yorig ??
+
+ Is this defined somewhere ?
+
+ \return 2
+*/
int get_txtdescender()
{
-
-/* yorig ??
- * Is this defined somewhere ?
- */
-
return (2);
}
-/*****************************************/
+/*!
+ \brief Get text offset
+
+ xorig ??
+
+ Is this defined somewhere ?
+
+ \return 0
+*/
int get_txtxoffset()
{
-
-/* xorig ??
- * Is this defined somewhere ?
- */
-
return (0);
}
-/*****************************************/
+/*!
+ \brief Display label
+
+ \param fontbase font-base
+ \param lab_pos label position
+ \param txt text string
+*/
void do_label_display(GLuint fontbase, float *lab_pos, char *txt)
{
glRasterPos2f(lab_pos[X], lab_pos[Y]);
Modified: grass/trunk/lib/ogsf/gsd_fringe.c
===================================================================
--- grass/trunk/lib/ogsf/gsd_fringe.c 2008-05-13 21:57:45 UTC (rev 31338)
+++ grass/trunk/lib/ogsf/gsd_fringe.c 2008-05-13 22:02:52 UTC (rev 31339)
@@ -1,7 +1,7 @@
/*!
\file gsd_fonts.c
- \brief OGSF library - loading and manipulating surfaces
+ \brief OGSF library - manipulating surfaces/fridge (lower level function)
GRASS OpenGL gsurf OGSF Library
@@ -15,6 +15,7 @@
for details.
\author Bill Brown USACERL, GMSL/University of Illinois
+ \author Doxygenized by Martin Landa <landa.martin gmail.com> (May 2008)
*/
#include <stdio.h>
@@ -23,11 +24,12 @@
#include "gsget.h"
#include "rowcol.h"
-
#define FRINGE_FORE 0x000000
#define FRINGE_WIDTH 2
-/* Normals */
+/*!
+ \brief Normals
+*/
float Nnorth[] = { 0.0, 0.8, 0.6 };
float Nsouth[] = { 0.0, -0.8, 0.6 };
float Neast[] = { 0.8, 0.0, 0.6 };
@@ -35,17 +37,20 @@
float Ntop[] = { 0.0, 0.0, 1.0 };
float Nbottom[] = { 0.0, 0.0, -1.0 };
-void
-gsd_display_fringe (geosurf * surf, unsigned long clr, float elev, int where[4])
-{
+/*!
+ \brief Display fridge
- /* TODO -- add elevation for bottom
- * -- add color option
- * -- add ruler grid lines
- */
+ \todo add elevation for bottom
+ add color option
+ add ruler grid lines
-
-
+ \param surf surface (geosurf)
+ \param clr
+ \param elev
+ \param where
+*/
+void gsd_display_fringe (geosurf * surf, unsigned long clr, float elev, int where[4])
+{
float bot, xres, yres; /* world size of view cell */
int ycnt, xcnt; /* number of view cells across */
float xmax, ymax;
@@ -58,10 +63,10 @@
xmax = surf->xmax;
ymax = surf->ymax;
-
-/*
- bot = surf->zmin - ((surf->zrange/4.) * surf->z_exag);
-*/
+
+ /*
+ bot = surf->zmin - ((surf->zrange/4.) * surf->z_exag);
+ */
bot = elev - ((surf->zrange/4.) * surf->z_exag);
@@ -125,11 +130,16 @@
return;
}
+/*!
+ \brief ADD
-void
-gsd_fringe_horiz_poly (float bot, geosurf * surf, int row, int side)
+ \param bot
+ \param surf surface (geosurf)
+ \param row
+ \param side
+*/
+void gsd_fringe_horiz_poly (float bot, geosurf * surf, int row, int side)
{
-
int col;
int cnt;
float pt[4];
@@ -148,7 +158,7 @@
gsd_bgnpolygon();
col = 0;
-/* floor left */
+ /* floor left */
pt[X] = col * (surf->x_mod * surf->xres) ;
pt[Y] = ((surf->rows - 1) * surf->yres) - ((row+side)*(surf->y_mod*surf->yres));
pt[Z] = bot;
@@ -187,9 +197,15 @@
return;
}
+/*!
+ \brief ADD
-void
-gsd_fringe_horiz_line (float bot, geosurf * surf, int row, int side)
+ \param bot
+ \param surf surface (geosurf)
+ \param row
+ \param side
+*/
+void gsd_fringe_horiz_line (float bot, geosurf * surf, int row, int side)
{
int col;
int cnt;
@@ -210,13 +226,12 @@
gsd_bgnline();
col = 0;
-/* floor left */
+ /* floor left */
pt[X] = col * (surf->x_mod * surf->xres) ;
pt[Y] = ((surf->rows - 1) * surf->yres) - ((row+side)*(surf->y_mod*surf->yres));
pt[Z] = bot;
gsd_vert_func(pt);
-
offset = (row*surf->y_mod*surf->cols) + (col*surf->x_mod) ;
GET_MAPATT(buff, offset, pt[Z]);
pt[Z] = pt[Z] * surf->z_exag;
@@ -234,7 +249,7 @@
gsd_vert_func(pt);
cnt++;
}
-
+
col--;
pt[X] = col * (surf->x_mod * surf->xres) ;
pt[Y] = ((surf->rows - 1) * surf->yres) - ((row+side)*(surf->y_mod*surf->yres));
@@ -256,9 +271,15 @@
return;
}
+/*!
+ \brief ADD
-void
-gsd_fringe_vert_poly (float bot, geosurf * surf, int col, int side)
+ \param bot
+ \param surf surface (geosurf)
+ \param col
+ \param side [unused]
+*/
+void gsd_fringe_vert_poly (float bot, geosurf * surf, int col, int side)
{
int row;
@@ -318,9 +339,15 @@
return;
}
-
-void
-gsd_fringe_vert_line (float bot, geosurf * surf, int col, int side)
+/*!
+ \brief ADD
+
+ \param bot
+ \param surf surface (geosurf)
+ \param col
+ \param side [unused]
+*/
+void gsd_fringe_vert_line (float bot, geosurf * surf, int col, int side)
{
int row;
int cnt;
@@ -385,8 +412,15 @@
return;
}
-void
-gsd_fringe_horiz_line2 (float bot, geosurf * surf, int row, int side)
+/*!
+ \brief ADD
+
+ \param bot
+ \param surf surface (geosurf)
+ \param row
+ \param side
+*/
+void gsd_fringe_horiz_line2 (float bot, geosurf * surf, int row, int side)
{
int col;
int cnt;
@@ -400,7 +434,6 @@
gsd_do_scale(1);
gsd_translate(surf->x_trans, surf->y_trans, surf->z_trans);
-
buff = gs_get_att_typbuff(surf, ATT_TOPO, 0);
xcnt = VCOLS(surf);
gsd_bgnline();
@@ -444,5 +477,3 @@
return;
}
-
-
Modified: grass/trunk/lib/ogsf/gsd_img_mpeg.c
===================================================================
--- grass/trunk/lib/ogsf/gsd_img_mpeg.c 2008-05-13 21:57:45 UTC (rev 31338)
+++ grass/trunk/lib/ogsf/gsd_img_mpeg.c 2008-05-13 22:02:52 UTC (rev 31339)
@@ -13,12 +13,15 @@
for details.
\author Bill Brown USACERL, GMSL/University of Illinois
+ \author Doxygenized by Martin Landa <landa.martin gmail.com> (May 2008)
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
+#include <grass/gis.h>
+#include <grass/glocale.h>
#include <grass/ogsf_proto.h>
#include <grass/gstypes.h>
@@ -43,8 +46,16 @@
AVFormatContext *oc;
AVStream *video_st;
+/*!
+ \brief Add a video output stream
-/* add a video output stream */
+ \param oc
+ \param codec_id
+ \param w
+ \param h
+
+ \return
+*/
static AVStream *add_video_stream(AVFormatContext *oc, int codec_id, int w, int h)
{
AVCodecContext *c;
@@ -52,7 +63,7 @@
st = av_new_stream(oc, 0);
if (!st) {
- fprintf(stderr, "Could not alloc stream\n");
+ G_warning (_("Unable to allocate stream"));
return NULL;
}
@@ -86,13 +97,23 @@
/* some formats want stream headers to be separate */
if(!strcmp(oc->oformat->name, "mp4") || !strcmp(oc->oformat->name, "mov") || !strcmp(oc->oformat->name, "3gp"))
c->flags |= CODEC_FLAG_GLOBAL_HEADER;
-
+
c->flags |= CODEC_FLAG_QSCALE;
c->global_quality = st->quality = FF_QP2LAMBDA * 10;
return st;
}
+/*!
+ \brief Allocate picture
+
+ \param pix_fmt
+ \param width picture width
+ \param height picture height
+
+ \return pointer to AVFrame struct
+ \return NULL on failure
+*/
static AVFrame *alloc_picture(int pix_fmt, int width, int height)
{
AVFrame *picture;
@@ -100,19 +121,30 @@
int size;
picture = avcodec_alloc_frame();
+
if (!picture)
return NULL;
+
size = avpicture_get_size(pix_fmt, width, height);
picture_buf = av_malloc(size);
+
if (!picture_buf) {
av_free(picture);
return NULL;
}
+
avpicture_fill((AVPicture *)picture, picture_buf,
pix_fmt, width, height);
+
return picture;
}
+/*!
+ \brief Open video
+
+ \param oc
+ \param st
+*/
static void open_video(AVFormatContext *oc, AVStream *st)
{
AVCodec *codec;
@@ -123,13 +155,13 @@
/* find the video encoder */
codec = avcodec_find_encoder(c->codec_id);
if (!codec) {
- fprintf(stderr, "video codec not found\n");
+ G_warning (_("Video codec not found"));
return;
}
/* open the codec */
if (avcodec_open(c, codec) < 0) {
- fprintf(stderr, "could not open codec\n");
+ G_warning (_("Unable to open codec"));
return;
}
@@ -148,7 +180,7 @@
/* allocate the encoded raw picture */
picture = alloc_picture(c->pix_fmt, c->width, c->height);
if (!picture) {
- fprintf(stderr, "Could not allocate picture\n");
+ G_warning (_("Unable to allocate picture"));
return;
}
@@ -159,12 +191,18 @@
if (c->pix_fmt != PIX_FMT_YUV420P) {
tmp_picture = alloc_picture(PIX_FMT_YUV420P, c->width, c->height);
if (!tmp_picture) {
- fprintf(stderr, "Could not allocate temporary picture\n");
+ G_warning (_("Unable to allocate temporary picture"));
return;
}
}
}
+/*!
+ \brief Write video frame
+
+ \param oc
+ \param st
+*/
static void write_video_frame(AVFormatContext *oc, AVStream *st)
{
int out_size, ret;
@@ -207,12 +245,18 @@
}
}
if (ret != 0) {
- fprintf(stderr, "Error while writing video frame\n");
+ G_warning (_("Error while writing video frame"));
return;
}
frame_count++;
}
+/*!
+ \brief Close video
+
+ \param oc [unused]
+ \param st
+*/
static void close_video(AVFormatContext *oc, AVStream *st)
{
avcodec_close(st->codec);
@@ -227,10 +271,14 @@
#endif
-/******************************************
- * initialize FAME setup mpeg defaults and
- * open file for writing
-******************************************/
+/*!
+ \brief Initialize FAME setup mpeg defaults and open file for writing
+
+ \param filename file name
+
+ \return -1 on failure
+ \return 0 on success
+*/
int gsd_init_mpeg(char *filename)
{
#ifdef HAVE_FFMPEG
@@ -243,7 +291,8 @@
b = tmp[1];
t = tmp[1] + tmp[3] - 1;
- fprintf(stderr, "Opening MPEG stream <%s> ...\n", filename);
+ G_verbose_message (_("Opening MPEG stream <%s>..."),
+ filename);
/* initialize libavcodec, and register all codecs and formats */
av_register_all();
@@ -251,18 +300,18 @@
/* auto detect the output format from the name. default is mpeg. */
fmt = guess_format(NULL, filename, NULL);
if (!fmt) {
- printf("Could not deduce output format from file extension: using MPEG.\n");
+ G_warning (_("Unable to deduce output format from file extension: using MPEG"));
fmt = guess_format("mpeg", NULL, NULL);
}
if (!fmt) {
- fprintf(stderr, "Could not find suitable output format\n");
+ G_warning (_("Unable to find suitable output format"));
return (-1);
}
/* allocate the output media context */
oc = av_alloc_format_context();
if (!oc) {
- fprintf(stderr, "Memory error\n");
+ G_warning (_("Out of memory"));
return(-1);
}
oc->oformat = fmt;
@@ -273,7 +322,7 @@
#ifdef USE_XVID
fmt->video_codec = CODEC_ID_XVID;
#endif
-
+
video_st = NULL;
if (fmt->video_codec != CODEC_ID_NONE) {
video_st = add_video_stream(oc, fmt->video_codec, (r - l + 1), (t - b + 1) );
@@ -281,7 +330,7 @@
/* set the output parameters (must be done even if no parameters). */
if (av_set_parameters(oc, NULL) < 0) {
- fprintf(stderr, "Invalid output format parameters\n");
+ G_warning (_("Invalid output format parameters"));
return (-1);
}
@@ -295,7 +344,8 @@
/* open the output file, if needed */
if (!(fmt->flags & AVFMT_NOFILE)) {
if (url_fopen(&oc->pb, filename, URL_WRONLY) < 0) {
- fprintf(stderr, "Could not open '%s'\n", filename);
+ G_warning (_("Unable to open <%s>"),
+ filename);
return (-1);
}
}
@@ -305,34 +355,35 @@
#else
- fprintf(stderr, "NVIZ has not been built with MPEG output support\n");
- return(-1);
+ G_warning (_("NVIZ has not been built with MPEG output support"));
+ return(-1);
#endif
+ return (0);
+}
- return (0);
+/*!
+ \brief Get RGB pixbuf and convert to YUV 4:2:0
-}
+ Image and write to mpeg stream
-/*********************************************
- * get RGB pixbuf and convert to YUV 4:2:0
- * image and write to mpeg stream
-*********************************************/
+ \return 0
+*/
int gsd_write_mpegframe(void)
{
#ifdef HAVE_FFMPEG
- unsigned int xsize, ysize;
- int x, y, xy, xy_uv;
- int yy, uu, vv;
- unsigned char *pixbuf;
-
- gsd_getimage(&pixbuf, &xsize, &ysize);
- xy = xy_uv = 0;
- for (y = ysize - 1; y >= 0; y--) {
- for (x = 0; x < xsize; x++) {
+ unsigned int xsize, ysize;
+ int x, y, xy, xy_uv;
+ int yy, uu, vv;
+ unsigned char *pixbuf;
+
+ gsd_getimage(&pixbuf, &xsize, &ysize);
+ xy = xy_uv = 0;
+ for (y = ysize - 1; y >= 0; y--) {
+ for (x = 0; x < xsize; x++) {
unsigned char r = pixbuf[(y * xsize + x) * 4 + 0];
unsigned char g = pixbuf[(y * xsize + x) * 4 + 1];
unsigned char b = pixbuf[(y * xsize + x) * 4 + 2];
-
+
yy = (0.257 * r) + (0.504 * g) + (0.098 * b) + 16;;
vv = (0.439 * r) - (0.368 * g) - (0.071 * b) + 128;
uu = -(0.148 * r) - (0.291 * g) + (0.439 * b) + 128;
@@ -341,57 +392,58 @@
if( (x % 2) && (y % 2) )
{
- picture->data[1][xy_uv] = uu;
- picture->data[2][xy_uv] = vv;
- xy_uv++;
+ picture->data[1][xy_uv] = uu;
+ picture->data[2][xy_uv] = vv;
+ xy_uv++;
}
-
+
xy++;
- }
-
+ }
+
}
- free(pixbuf);
-
- write_video_frame(oc, video_st);
-
-
+ G_free(pixbuf);
+
+ write_video_frame(oc, video_st);
+
+
#endif
+
+ return (0);
+}
- return (0);
+/*!
+ \brief Close the mpeg, free buffer, and close file
-}
-
-/****************************************
- * close the mpeg, free buffer, and close file
-****************************************/
+ \return 0
+*/
int gsd_close_mpeg(void)
{
#ifdef HAVE_FFMPEG
-int i;
-
- close_video(oc, video_st);
-
- /* write the trailer, if any */
- av_write_trailer(oc);
-
- /* free the streams */
- for(i = 0; i < oc->nb_streams; i++) {
- av_freep(&oc->streams[i]->codec);
- av_freep(&oc->streams[i]);
- }
-
+ int i;
+
+ close_video(oc, video_st);
+
+ /* write the trailer, if any */
+ av_write_trailer(oc);
+
+ /* free the streams */
+ for(i = 0; i < oc->nb_streams; i++) {
+ av_freep(&oc->streams[i]->codec);
+ av_freep(&oc->streams[i]);
+ }
+
if (!(fmt->flags & AVFMT_NOFILE)) {
/* close the output file */
url_fclose(&oc->pb);
}
-
+
/* free the stream */
av_free(oc);
-
- fprintf(stderr, "Closed MPEG stream.\n");
+
+ G_debug (3, "Closed MPEG stream");
#endif
-
- return (0);
+
+ return (0);
}
Modified: grass/trunk/lib/ogsf/gsd_img_ppm.c
===================================================================
--- grass/trunk/lib/ogsf/gsd_img_ppm.c 2008-05-13 21:57:45 UTC (rev 31338)
+++ grass/trunk/lib/ogsf/gsd_img_ppm.c 2008-05-13 22:02:52 UTC (rev 31339)
@@ -18,20 +18,32 @@
for details.
\author Bill Brown USACERL, GMSL/University of Illinois
- Markus Neteler
- Bob Covill
- Jaro Hofierka
+ \author Markus Neteler
+ \author Bob Covill
+ \author Jaro Hofierka
+ \author Doxygenized by Martin Landa <landa.martin gmail.com> (May 2008)
*/
#include <stdlib.h>
#include <stdio.h>
+#include <grass/gis.h>
+#include <grass/glocale.h>
#include <grass/ogsf_proto.h>
#include <grass/gstypes.h>
+/*!
+ \brief Write ppm file
+
+ \param name file name
+
+ \return 1 on failure
+ \return 0 on success
+*/
int GS_write_ppm(char *name)
{
- int y, x;
+ unsigned int x;
+ int y;
unsigned int xsize, ysize;
FILE *fp;
unsigned char *pixbuf;
@@ -40,7 +52,8 @@
if (NULL == (fp = fopen(name, "w"))) {
- fprintf(stderr, "Cannot open file for output.\n");
+ G_warning (_("Unable to open file <%s> for writing"),
+ name);
return(1);
}
@@ -58,22 +71,33 @@
}
}
- free(pixbuf);
+ G_free(pixbuf);
fclose(fp);
return (0);
}
+/*!
+ \brief Write zoom to file
+
+ \param name file name
+ \param xsize,ysize
+
+ \return 1 on failure
+ \return 0 on success
+*/
int GS_write_zoom(char *name, unsigned int xsize, unsigned int ysize)
{
- int y, x;
+ unsigned int x;
+ int y;
FILE *fp;
unsigned char *pixbuf;
gsd_writeView(&pixbuf, xsize, ysize);
if (NULL == (fp = fopen(name, "w"))) {
- fprintf(stderr, "Cannot open file for output.\n");
+ G_warning (_("Unable to open file <%s> for writing"),
+ name);
return(1);
}
@@ -96,4 +120,3 @@
return (0);
}
-
Modified: grass/trunk/lib/ogsf/gsd_img_tif.c
===================================================================
--- grass/trunk/lib/ogsf/gsd_img_tif.c 2008-05-13 21:57:45 UTC (rev 31338)
+++ grass/trunk/lib/ogsf/gsd_img_tif.c 2008-05-13 22:02:52 UTC (rev 31339)
@@ -18,8 +18,9 @@
for details.
\author Bill Brown USACERL, GMSL/University of Illinois
- Markus Neteler
- Jaro Hofierka
+ \author Markus Neteler
+ \author Jaro Hofierka
+ \author Doxygenized by Martin Landa <landa.martin gmail.com> (May 2008)
*/
#include <grass/config.h>
@@ -29,9 +30,11 @@
#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
+
#include <grass/gis.h>
#include <grass/gstypes.h>
#include <grass/glocale.h>
+
#include "tiffio.h"
unsigned short config = PLANARCONFIG_CONTIG;
Modified: grass/trunk/lib/ogsf/gsd_label.c
===================================================================
--- grass/trunk/lib/ogsf/gsd_label.c 2008-05-13 21:57:45 UTC (rev 31338)
+++ grass/trunk/lib/ogsf/gsd_label.c 2008-05-13 22:02:52 UTC (rev 31339)
@@ -1,7 +1,7 @@
/*!
\file gsd_label.c
- \brief OGSF library - label management
+ \brief OGSF library - label management (lower level functions)
GRASS OpenGL gsurf OGSF Library
@@ -13,19 +13,32 @@
for details.
\author Bill Brown USACERL (1991-1992)
+ \author Doxygenized by Martin Landa <landa.martin gmail.com> (May 2008)
*/
+#include <grass/glocale.h>
#include <grass/gstypes.h>
+
#include "rgbpack.h"
+
#define MAX_LIST 20
static int first = 0;
GLuint label_base;
GLuint label_id;
-void
-gs_put_label(char *text, GLuint fontbase, int size, unsigned long color,
- int*pt)
+/*!
+ \brief Put label
+
+ \todo Allocate label dynamicaly
+
+ \param fontbase fontbase settings
+ \param size font size
+ \param color font color
+ \param pt
+*/
+void gs_put_label(char *text, GLuint fontbase, int size, unsigned long color,
+ int*pt)
{
int txt_width;
GLint tmp[4];
@@ -41,17 +54,17 @@
}
if (label_id > (label_base + MAX_LIST)) {
- fprintf(stderr, "Max. number of labels reached!\n");
+ G_warning (_("Max. number of labels reached!"));
return;
}
-
+
glNewList(label_id, GL_COMPILE_AND_EXECUTE);
txt_width = gsd_get_txtwidth(text, size);
-
+
/* adjust to center text string */
labpt[X] = (float) (pt[X] - txt_width / 2.);
labpt[Y] = (float) pt[Y];
-
+
glGetIntegerv(GL_VIEWPORT, tmp);
l = tmp[0];
r = tmp[0] + tmp[2];
@@ -77,37 +90,34 @@
}
-/****************************************************************
- * Remove current label
-****************************************************************/
+/*!
+ \brief Remove current label
+*/
void gsd_remove_curr(void)
{
-
if (label_id) {
glDeleteLists(label_id - 1, 1);
label_id--;
}
return;
-
}
-/******************************************************************
- * Remove all labels from display list
-******************************************************************/
+/*!
+ \brief Remove all labels from display list
+*/
void gsd_remove_all(void)
{
-
glDeleteLists(label_base, MAX_LIST);
label_id = label_base;
return;
}
-/*************************************************************************
- * Call display list and draw defined labels -- called from gsd_prim (gsd_call_lists)
-**************************************************************************/
+/*!
+ \brief Call display list and draw defined labels -- called from gsd_prim (gsd_call_lists)
+*/
void gsd_call_label(void)
{
int i;
Modified: grass/trunk/lib/ogsf/gsd_legend.c
===================================================================
--- grass/trunk/lib/ogsf/gsd_legend.c 2008-05-13 21:57:45 UTC (rev 31338)
+++ grass/trunk/lib/ogsf/gsd_legend.c 2008-05-13 22:02:52 UTC (rev 31339)
@@ -16,6 +16,7 @@
for details.
\author Bill Brown USACERL
+ \author Doxygenized by Martin Landa <landa.martin gmail.com> (May 2008)
*/
#include <stdlib.h>
@@ -49,7 +50,14 @@
#define MAX_LEGEND 256
-/*****************************************************************/
+/*!
+ \brief ADD
+
+ \param wl
+ \param wb
+ \param wr
+ \param wt
+*/
void gsd_bgn_legend_viewport(GLint wl, GLint wb, GLint wr, GLint wt)
{
/* sets the viewport for the legend and the model matrix */
@@ -77,11 +85,12 @@
return;
}
-
-/***********************************************/
+/*!
+ \brief ADD
+*/
void gsd_end_legend_viewport(void)
{
-/* closes the legend viewport and resets matrix and buffers */
+ /* closes the legend viewport and resets matrix and buffers */
gsd_popmatrix();
glMatrixMode(GL_PROJECTION);
@@ -97,15 +106,24 @@
return;
}
+/*!
+ \brief ADD
-/*****************************************************************/
+ \param lownum
+ \param highnum
+ \param numvals
+ \param vals
+
+ \return 0 on failure
+ \return range value
+*/
int gsd_get_nice_range(float lownum, float highnum, int numvals, float *vals)
{
/* get a nice range for displaying legend */
int num = 0;
float curnum, step, start;
-
+
if (!numvals)
return (0);
@@ -116,7 +134,7 @@
start = step * (int) (1 + lownum / step);
if (start - lownum < .65 * step)
start += step;
-
+
for (curnum = start; curnum < (highnum - .65 * step); curnum += step) {
vals[num++] = curnum;
}
@@ -125,8 +143,14 @@
}
+/*!
+ \brief ADD
-/*****************************************************************/
+ \param num
+
+ \return 0 on error
+ \return 1 on success
+*/
int gsd_make_nice_number(float *num)
{
float newnum, nextnum;
@@ -163,11 +187,20 @@
return (1);
}
+/*!
+ \brief Put legend
-/*****************************************************************/
-GLuint
-gsd_put_legend(char *name, GLuint fontbase, int size, int *flags,
- float *rangef, int *pt)
+ \param name
+ \param fontbase font-base
+ \param size
+ \param flags
+ \param rangef
+ \param pt
+
+ \return
+*/
+GLuint gsd_put_legend(char *name, GLuint fontbase, int size, int *flags,
+ float *rangef, int *pt)
{
GLint sl, sr, sb, st;
GLuint legend_list;
@@ -211,13 +244,15 @@
is_fp = G_raster_map_is_fp(name, mapset);
if (G_read_colors(name, mapset, &colors) == -1) {
- fprintf(stderr, "Color file for [%s] not available\n", name);
+ G_warning (_("Unable to read color file of raster map <%s>"),
+ name);
return (-1);
}
if (cat_labs)
if (G_read_cats(name, mapset, &cats) == -1) {
- fprintf(stderr, "Category file for [%s] not available\n", name);
+ G_warning (_("Unable to read category file of raster map <%s>"),
+ name);
cat_labs = 0;
}
@@ -233,7 +268,8 @@
else {
if (is_fp) {
if (G_read_fp_range(name, mapset, &fp_range) != 1) {
- fprintf(stderr, "Range info for [%s] not available\n", name);
+ G_warning (_("Unable to read fp range of raster map <%s>"),
+ name);
return(-1);
}
G_get_fp_range_min_max(&fp_range, &fmin, &fmax);
@@ -244,7 +280,8 @@
}
else {
if (G_read_range(name, mapset, &range) == -1) {
- fprintf(stderr, "Range info for [%s] not available\n", name);
+ G_warning (_("Unable to read range of raster map <%s>"),
+ name);
return (-1);
}
G_get_range_min_max(&range, &min, &max);
@@ -306,18 +343,21 @@
/* how many labels? */
/*
-numlabs can't be = max - min + 1 any more because of floating point
-maybe shouldn't allow discrete legend for floating point maps (unless list)
-or else check number of different values in floating point map
-and use each if "reasonable"
-gs_get_values_in_range(gs, att, low, high, values, &nvals)
-the nvals sent has a max number to return, nvals returned is the actual
-number set in values, return val is 1 on success, -1 if > max vals found
+ numlabs can't be = max - min + 1 any more because of floating point
+ maybe shouldn't allow discrete legend for floating point maps (unless list)
+ or else check number of different values in floating point map
+ and use each if "reasonable"
+ gs_get_values_in_range(gs, att, low, high, values, &nvals)
+ the nvals sent has a max number to return, nvals returned is the actual
+ number set in values, return val is 1 on success, -1 if > max vals found
+
+ might need to think about doing histograms first & use same routines here
+ could also have a LT_MOST that would limit # to some N most frequent
+*/
-might need to think about doing histograms first & use same routines here
-could also have a LT_MOST that would limit # to some N most frequent
+/*!
+ ???
*/
-
{
int i, k, lleg, horiz;
int red, green, blue;
@@ -344,12 +384,11 @@
/* watch out for trying to display mega cats */
if (is_fp && !Listnum) {
discrete = 0; /* maybe later do stats & allow if few #s */
- fprintf(stderr,
- "Unable to show discrete FP range (use list)\n");
+ G_warning (_("Unable to show discrete FP range (use list"));
return (-1);
}
if (numlabs < MAX_LEGEND)
- dividers = (float *) malloc(numlabs * sizeof(float));
+ dividers = (float *) G_malloc(numlabs * sizeof(float));
}
else {
numlabs = gsd_get_nice_range(fmin, fmax, 4, labvals + 1);
@@ -461,9 +500,9 @@
if (discrete) {
if (numlabs > lleg / 5)
- G_warning("Too many categories to show as discrete!");
+ G_warning(_("Too many categories to show as discrete!"));
else if (numlabs > 1.2 * lleg / gsd_get_txtheight(size))
- G_warning("Try using smaller font!");
+ G_warning(_("Try using smaller font!"));
}
incr = do_invert ? -1 : 1;
@@ -647,22 +686,22 @@
}
}
-
if (discrete)
- free(dividers);
+ G_free(dividers);
}
if (cat_labs)
G_free_cats(&cats);
+
G_free_colors(&colors);
gsd_end_legend_viewport();
/*
- gsd_unset_font(fontbase);
+ gsd_unset_font(fontbase);
*/
-
+
gsd_endlist();
-
+
return (legend_list);
}
Modified: grass/trunk/lib/ogsf/gsdiff.c
===================================================================
--- grass/trunk/lib/ogsf/gsdiff.c 2008-05-13 21:57:45 UTC (rev 31338)
+++ grass/trunk/lib/ogsf/gsdiff.c 2008-05-13 22:02:52 UTC (rev 31339)
@@ -1,7 +1,7 @@
/*!
\file gsdiff.c
- \brief OGSF library - loading and manipulating surfaces
+ \brief OGSF library - manipulating surfaces (lower level functions)
GRASS OpenGL gsurf OGSF Library
@@ -24,6 +24,7 @@
for details.
\author Bill Brown USACERL, GMSL/University of Illinois (November 1994)
+ \author Doxygenized by Martin Landa <landa.martin gmail.com> (May 2008)
*/
#include <stdio.h>
@@ -35,7 +36,11 @@
static typbuff *Refbuff = NULL;
static float Refscale = 1.0;
-/***********************************************************************/
+/*!
+ \brief Set scale
+
+ \param scale value
+*/
void gsdiff_set_SDscale(float scale)
{
Refscale = scale;
@@ -43,13 +48,21 @@
return;
}
-/***********************************************************************/
+/*!
+ \brief Get scale
+
+ \return scale value
+*/
float gsdiff_get_SDscale(void)
{
return (Refscale);
}
-/***********************************************************************/
+/*!
+ \brief ADD
+
+ \param gsref
+*/
void gsdiff_set_SDref(geosurf * gsref)
{
Refsurf = gsref;
@@ -58,7 +71,11 @@
return;
}
-/***********************************************************************/
+/*!
+ \brief ADD
+
+ \return pointer to geosurf struct
+*/
geosurf *gsdiff_get_SDref(void)
{
if (Refsurf && Refbuff) {
@@ -68,7 +85,14 @@
return (NULL);
}
-/***********************************************************************/
+/*!
+ \brief ADD
+
+ \param val
+ \param offset
+
+ \return value
+*/
float gsdiff_do_SD(float val, int offset)
{
float ref;
More information about the grass-commit
mailing list