GRASS Programmer's Manual
6.4.2(2012)
|
00001 00002 /**************************************************************************** 00003 * 00004 * MODULE: edit library functions 00005 * AUTHOR(S): Originally part of gis lib dir in CERL GRASS code 00006 * Subsequent (post-CVS) contributors: 00007 * Glynn Clements <glynn gclements.plus.com>, 00008 * Radim Blazek <radim.blazek gmail.com>, 00009 * Eric G. Miller <egm2 jps.net>, 00010 * Markus Neteler <neteler itc.it>, 00011 * Brad Douglas <rez touchofmadness.com>, 00012 * Bernhard Reiter <bernhard intevation.de> 00013 * PURPOSE: libraries for interactively editing raster support data 00014 * COPYRIGHT: (C) 1996-2006 by the GRASS Development Team 00015 * 00016 * This program is free software under the GNU General Public 00017 * License (>=v2). Read the file COPYING that comes with GRASS 00018 * for details. 00019 * 00020 *****************************************************************************/ 00021 /* 00022 ********************************************************************** 00023 * 00024 * E_edit_history (hist) 00025 * struct History *hist 00026 * 00027 * Interactively prompts the user for history information. 00028 * Uses screen oriented prompting through the visual_ask library. 00029 * Programs using this must be compiled with the GRASS library $(VASKLIB) 00030 * and include $(CURSES) in the compile line 00031 * 00032 * Returns: 1 ok 00033 * -1 user canceled edit 00034 * 00035 **********************************************************************/ 00036 00037 #include <grass/gis.h> 00038 #include <grass/vask.h> 00039 #include <grass/edit.h> 00040 00041 int E_edit_history(struct History *phist) 00042 { 00043 int len; 00044 int i; 00045 00046 if (!*phist->mapid) 00047 sprintf(phist->mapid, "%s : %s", G_date(), "filename"); 00048 if (!*phist->title) 00049 sprintf(phist->title, "%s", "filename"); 00050 if (!*phist->mapset) 00051 sprintf(phist->mapset, "%s", G_mapset()); 00052 if (!*phist->creator) 00053 sprintf(phist->creator, "%s", G_whoami()); 00054 if (!*phist->maptype) 00055 sprintf(phist->maptype, "raster"); 00056 00057 V_clear(); 00058 V_line(0, " ENTER/CORRECT FILE HISTORY INFORMATION"); 00059 V_line(2, "Map ID ..."); 00060 V_line(4, "Title ...."); 00061 V_line(6, "Project .."); 00062 V_line(8, "Creator .."); 00063 V_line(10, "Maptype .."); 00064 V_line(12, "Data source"); 00065 V_line(16, "Data Description"); 00066 V_line(19, "For history comments see next page"); 00067 00068 len = RECORD_LEN - 1; 00069 if (len > 65) 00070 len = 65; 00071 phist->mapid[len] = 0; 00072 phist->title[len] = 0; 00073 phist->mapset[len] = 0; 00074 phist->creator[len] = 0; 00075 phist->maptype[len] = 0; 00076 len--; 00077 00078 V_const(phist->mapid, 's', 2, 11, len); 00079 V_ques(phist->title, 's', 4, 11, len); 00080 V_const(phist->mapset, 's', 6, 11, len); 00081 V_const(phist->creator, 's', 8, 11, len); 00082 V_ques(phist->maptype, 's', 10, 11, len); 00083 00084 phist->datsrc_1[len] = 0; 00085 phist->datsrc_2[len] = 0; 00086 phist->keywrd[len] = 0; 00087 len--; 00088 00089 V_ques(phist->datsrc_1, 's', 13, 0, len); 00090 V_ques(phist->datsrc_2, 's', 14, 0, len); 00091 V_ques(phist->keywrd, 's', 17, 0, len); 00092 00093 V_intrpt_ok(); 00094 if (!V_call()) 00095 return -1; 00096 00097 G_strip(phist->title); 00098 G_strip(phist->maptype); 00099 G_strip(phist->datsrc_1); 00100 G_strip(phist->datsrc_2); 00101 G_strip(phist->keywrd); 00102 00103 V_clear(); 00104 V_line(0, " ENTER/CORRECT FILE HISTORY COMMENTS"); 00105 V_ques(phist->edhist[0], 's', 2, 0, len); 00106 V_ques(phist->edhist[1], 's', 3, 0, len); 00107 V_ques(phist->edhist[2], 's', 4, 0, len); 00108 V_ques(phist->edhist[3], 's', 5, 0, len); 00109 V_ques(phist->edhist[4], 's', 6, 0, len); 00110 V_ques(phist->edhist[5], 's', 7, 0, len); 00111 V_ques(phist->edhist[6], 's', 8, 0, len); 00112 V_ques(phist->edhist[7], 's', 9, 0, len); 00113 V_ques(phist->edhist[8], 's', 10, 0, len); 00114 V_ques(phist->edhist[9], 's', 11, 0, len); 00115 V_ques(phist->edhist[10], 's', 12, 0, len); 00116 V_ques(phist->edhist[11], 's', 13, 0, len); 00117 V_ques(phist->edhist[12], 's', 14, 0, len); 00118 V_ques(phist->edhist[13], 's', 15, 0, len); 00119 V_ques(phist->edhist[14], 's', 16, 0, len); 00120 V_ques(phist->edhist[15], 's', 17, 0, len); 00121 V_ques(phist->edhist[16], 's', 18, 0, len); 00122 V_ques(phist->edhist[17], 's', 19, 0, len); 00123 V_ques(phist->edhist[18], 's', 20, 0, len); 00124 V_ques(phist->edhist[19], 's', 21, 0, 65); 00125 00126 len++; 00127 for (i = 0; i <= 19; i++) 00128 phist->edhist[i][len] = 0; 00129 00130 V_intrpt_ok(); 00131 if (!V_call()) 00132 return -1; 00133 00134 for (i = 0; i <= 19; i++) 00135 G_strip(phist->edhist[i]); 00136 00137 for (phist->edlinecnt = 19; phist->edlinecnt > 0; phist->edlinecnt--) { 00138 if (*phist->edhist[phist->edlinecnt] != 0) 00139 break; 00140 } 00141 phist->edlinecnt++; 00142 V_clear(); 00143 00144 return (1); 00145 }