args.c 44 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186
  1. /*!
  2. \file args.c
  3. \brief Parse command
  4. (C) 2008, 2010-2011 by the GRASS Development Team
  5. This program is free software under the GNU General Public
  6. License (>=v2). Read the file COPYING that comes with GRASS
  7. for details.
  8. \author Martin Landa <landa.martin gmail.com> (Google SoC 2008/2010)
  9. */
  10. #include <stdlib.h>
  11. #include <string.h>
  12. #include <grass/gis.h>
  13. #include <grass/glocale.h>
  14. #include "local_proto.h"
  15. static void print_error(int, int, int,
  16. const char *, const char *,
  17. const char *, const char *);
  18. static void args_surface(struct GParams *);
  19. static void args_vline(struct GParams *);
  20. static void args_vpoint(struct GParams *);
  21. static void args_viewpoint(struct GParams *);
  22. static void args_volume(struct GParams *);
  23. static void args_lighting(struct GParams *);
  24. static void args_fringe(struct GParams *);
  25. static void args_cplane(struct GParams *);
  26. static void args_arrow(struct GParams *);
  27. /*!
  28. \brief Parse command
  29. \param argc number of arguments
  30. \param argv arguments array
  31. \param params GRASS parameters
  32. \return 1
  33. */
  34. void parse_command(int argc, char *argv[], struct GParams *params)
  35. {
  36. params->mode_all = G_define_flag();
  37. params->mode_all->key = 'a';
  38. params->mode_all->description =
  39. _("Use draw mode for all loaded surfaces");
  40. params->mode_all->guisection = _("Surfaces");
  41. /*** surface attributes ***/
  42. args_surface(params);
  43. /*** vector lines ***/
  44. args_vline(params);
  45. /*** vector points ***/
  46. args_vpoint(params);
  47. /*** volumes ***/
  48. args_volume(params);
  49. /*** misc ***/
  50. /* background color */
  51. params->bgcolor = G_define_standard_option(G_OPT_C_BG);
  52. /*** viewpoint ***/
  53. args_viewpoint(params);
  54. /*** lighting ***/
  55. args_lighting(params);
  56. /*** fringe ***/
  57. args_fringe(params);
  58. /*** cutting plane ***/
  59. args_cplane(params);
  60. /*** north arrow ***/
  61. args_arrow(params);
  62. /*** output image ***/
  63. /* output */
  64. params->output = G_define_standard_option(G_OPT_F_OUTPUT);
  65. params->output->description =
  66. _("Name for output image file (without extension)");
  67. params->output->guisection = _("Image");
  68. /* format */
  69. params->format = G_define_option();
  70. params->format->key = "format";
  71. params->format->type = TYPE_STRING;
  72. #ifdef HAVE_TIFFIO_H
  73. params->format->options = "ppm,tif"; /* TODO: png */
  74. #else
  75. params->format->options = "ppm";
  76. #endif
  77. params->format->answer = "ppm";
  78. params->format->description = _("Graphics file format");
  79. params->format->required = YES;
  80. params->format->guisection = _("Image");
  81. /* size */
  82. params->size = G_define_option();
  83. params->size->key = "size";
  84. params->size->type = TYPE_INTEGER;
  85. params->size->key_desc = "width,height";
  86. params->size->answer = "640,480";
  87. params->size->description = _("Size (width, height) of output image");
  88. params->size->required = YES;
  89. params->size->guisection = _("Image");
  90. if (G_parser(argc, argv))
  91. exit(EXIT_FAILURE);
  92. return;
  93. }
  94. void args_surface(struct GParams *params)
  95. {
  96. /* topography */
  97. params->elev_map = G_define_standard_option(G_OPT_R_ELEV);
  98. params->elev_map->key = "elevation_map";
  99. params->elev_map->required = NO;
  100. params->elev_map->multiple = YES;
  101. params->elev_map->description = _("Name of raster map(s) for elevation");
  102. params->elev_map->guisection = _("Surfaces");
  103. params->elev_const = G_define_option();
  104. params->elev_const->key = "elevation_value";
  105. params->elev_const->key_desc = "value";
  106. params->elev_const->type = TYPE_INTEGER;
  107. params->elev_const->required = NO;
  108. params->elev_const->multiple = YES;
  109. params->elev_const->description =
  110. _("Constant elevation value(s) to use instead of a raster DEM");
  111. params->elev_const->guisection = _("Surfaces");
  112. /* color */
  113. params->color_map = G_define_standard_option(G_OPT_R_MAP);
  114. params->color_map->multiple = YES;
  115. params->color_map->required = NO;
  116. params->color_map->description = _("Name of raster map(s) for color");
  117. params->color_map->guisection = _("Surfaces");
  118. params->color_map->key = "color_map";
  119. params->color_const = G_define_standard_option(G_OPT_C_FG);
  120. params->color_const->multiple = YES;
  121. params->color_const->label = _("Color value(s)");
  122. params->color_const->guisection = _("Surfaces");
  123. params->color_const->answer = NULL;
  124. /* mask */
  125. params->mask_map = G_define_standard_option(G_OPT_R_MAP);
  126. params->mask_map->multiple = YES;
  127. params->mask_map->required = NO;
  128. params->mask_map->description = _("Name of raster map(s) for mask");
  129. params->mask_map->guisection = _("Surfaces");
  130. params->mask_map->key = "mask_map";
  131. /* transparency */
  132. params->transp_map = G_define_standard_option(G_OPT_R_MAP);
  133. params->transp_map->multiple = YES;
  134. params->transp_map->required = NO;
  135. params->transp_map->description =
  136. _("Name of raster map(s) for transparency");
  137. params->transp_map->guisection = _("Surfaces");
  138. params->transp_map->key = "transparency_map";
  139. params->transp_const = G_define_option();
  140. params->transp_const->key = "transparency_value";
  141. params->transp_const->key_desc = "value";
  142. params->transp_const->type = TYPE_INTEGER;
  143. params->transp_const->required = NO;
  144. params->transp_const->multiple = YES;
  145. params->transp_const->description = _("Transparency value(s)");
  146. params->transp_const->guisection = _("Surfaces");
  147. params->transp_const->options = "0-255";
  148. /* shininess */
  149. params->shine_map = G_define_standard_option(G_OPT_R_MAP);
  150. params->shine_map->multiple = YES;
  151. params->shine_map->required = NO;
  152. params->shine_map->description = _("Name of raster map(s) for shininess");
  153. params->shine_map->guisection = _("Surfaces");
  154. params->shine_map->key = "shininess_map";
  155. params->shine_const = G_define_option();
  156. params->shine_const->key = "shininess_value";
  157. params->shine_const->key_desc = "value";
  158. params->shine_const->type = TYPE_INTEGER;
  159. params->shine_const->required = NO;
  160. params->shine_const->multiple = YES;
  161. params->shine_const->description = _("Shininess value(s)");
  162. params->shine_const->guisection = _("Surfaces");
  163. params->shine_const->options = "0-255";
  164. /* emission */
  165. params->emit_map = G_define_standard_option(G_OPT_R_MAP);
  166. params->emit_map->multiple = YES;
  167. params->emit_map->required = NO;
  168. params->emit_map->description = _("Name of raster map(s) for emission");
  169. params->emit_map->guisection = _("Surfaces");
  170. params->emit_map->key = "emission_map";
  171. params->emit_const = G_define_option();
  172. params->emit_const->key = "emission_value";
  173. params->emit_const->key_desc = "value";
  174. params->emit_const->type = TYPE_INTEGER;
  175. params->emit_const->required = NO;
  176. params->emit_const->multiple = YES;
  177. params->emit_const->description = _("Emission value(s)");
  178. params->emit_const->guisection = _("Surfaces");
  179. params->emit_const->options = "0-255";
  180. /* draw */
  181. /* mode */
  182. params->mode = G_define_option();
  183. params->mode->key = "mode";
  184. params->mode->key_desc = "string";
  185. params->mode->type = TYPE_STRING;
  186. params->mode->required = NO;
  187. params->mode->multiple = YES;
  188. params->mode->description = _("Draw mode");
  189. params->mode->options = "coarse,fine,both";
  190. params->mode->answer = "fine";
  191. params->mode->guisection = _("Draw");
  192. /* resolution fine */
  193. params->res_fine = G_define_option();
  194. params->res_fine->key = "resolution_fine";
  195. params->res_fine->key_desc = "value";
  196. params->res_fine->type = TYPE_INTEGER;
  197. params->res_fine->required = NO;
  198. params->res_fine->multiple = YES;
  199. params->res_fine->description = _("Fine resolution");
  200. params->res_fine->answer = "6";
  201. params->res_fine->guisection = _("Draw");
  202. /* resolution coarse */
  203. params->res_coarse = G_define_option();
  204. params->res_coarse->key = "resolution_coarse";
  205. params->res_coarse->key_desc = "value";
  206. params->res_coarse->type = TYPE_INTEGER;
  207. params->res_coarse->required = NO;
  208. params->res_coarse->multiple = YES;
  209. params->res_coarse->description = _("Coarse resolution");
  210. params->res_coarse->answer = "9";
  211. params->res_coarse->guisection = _("Draw");
  212. /* style */
  213. params->style = G_define_option();
  214. params->style->key = "style";
  215. params->style->key_desc = "string";
  216. params->style->type = TYPE_STRING;
  217. params->style->required = NO;
  218. params->style->multiple = YES;
  219. params->style->description = _("Draw style");
  220. params->style->options = "wire,surface";
  221. params->style->answer = "surface";
  222. params->style->guisection = _("Draw");
  223. /* shading */
  224. params->shade = G_define_option();
  225. params->shade->key = "shading";
  226. params->shade->key_desc = "string";
  227. params->shade->type = TYPE_STRING;
  228. params->shade->required = NO;
  229. params->shade->multiple = YES;
  230. params->shade->description = _("Shading");
  231. params->shade->options = "flat,gouraud";
  232. params->shade->answer = "gouraud";
  233. params->shade->guisection = _("Draw");
  234. /* wire color */
  235. params->wire_color = G_define_standard_option(G_OPT_C_FG);
  236. params->wire_color->multiple = YES;
  237. params->wire_color->required = NO;
  238. params->wire_color->label = _("Wire color");
  239. params->wire_color->key = "wire_color";
  240. params->wire_color->answer = "136:136:136";
  241. params->wire_color->guisection = _("Draw");
  242. /* position */
  243. params->surface_pos = G_define_option();
  244. params->surface_pos->key = "surface_position";
  245. params->surface_pos->key_desc = "x,y,z";
  246. params->surface_pos->type = TYPE_INTEGER;
  247. params->surface_pos->required = NO;
  248. params->surface_pos->multiple = YES;
  249. params->surface_pos->description = _("Surface position");
  250. params->surface_pos->guisection = _("Draw");
  251. params->surface_pos->answer = "0,0,0";
  252. return;
  253. }
  254. void args_vline(struct GParams *params)
  255. {
  256. params->vlines = G_define_standard_option(G_OPT_V_MAP);
  257. params->vlines->multiple = YES;
  258. params->vlines->required = NO;
  259. params->vlines->description = _("Name of line vector overlay map(s)");
  260. params->vlines->guisection = _("Vector lines");
  261. params->vlines->key = "vline";
  262. params->vline_layer = G_define_standard_option(G_OPT_V_FIELD);
  263. params->vline_layer->multiple = YES;
  264. params->vline_layer->required = NO;
  265. params->vline_layer->description =
  266. _("Layer number or name for thematic mapping");
  267. params->vline_layer->guisection = _("Vector lines");
  268. params->vline_layer->key = "vline_layer";
  269. params->vline_layer->answer = "1";
  270. /* line width */
  271. params->vline_width = G_define_option();
  272. params->vline_width->key = "vline_width";
  273. params->vline_width->key_desc = "value";
  274. params->vline_width->type = TYPE_INTEGER;
  275. params->vline_width->required = NO;
  276. params->vline_width->multiple = YES;
  277. params->vline_width->description = _("Vector line width");
  278. params->vline_width->guisection = _("Vector lines");
  279. params->vline_width->options = "1-100";
  280. params->vline_width->answer = "2";
  281. params->vline_width_column = G_define_standard_option(G_OPT_DB_COLUMN);
  282. params->vline_width_column->multiple = YES;
  283. params->vline_width_column->required = NO;
  284. params->vline_width_column->label = _("Name of width definition column");
  285. params->vline_width_column->key = "vline_width_column";
  286. params->vline_width_column->guisection = _("Vector lines");
  287. /* line color */
  288. params->vline_color = G_define_standard_option(G_OPT_C_FG);
  289. params->vline_color->multiple = YES;
  290. params->vline_color->required = NO;
  291. params->vline_color->label = _("Vector line color");
  292. params->vline_color->key = "vline_color";
  293. params->vline_color->answer = "blue";
  294. params->vline_color->guisection = _("Vector lines");
  295. params->vline_color_column = G_define_standard_option(G_OPT_DB_COLUMN);
  296. params->vline_color_column->multiple = YES;
  297. params->vline_color_column->required = NO;
  298. params->vline_color_column->label = _("Name of color definition column");
  299. params->vline_color_column->key = "vline_color_column";
  300. params->vline_color_column->guisection = _("Vector lines");
  301. /* line mode */
  302. params->vline_mode = G_define_option();
  303. params->vline_mode->key = "vline_mode";
  304. params->vline_mode->key_desc = "string";
  305. params->vline_mode->type = TYPE_STRING;
  306. params->vline_mode->required = NO;
  307. params->vline_mode->multiple = YES;
  308. params->vline_mode->description = _("Vector line display mode");
  309. params->vline_mode->options = "surface,flat";
  310. params->vline_mode->descriptions = _("surface;drape on raster surface;"
  311. "flat;draw at constant elevation");
  312. params->vline_mode->answer = "surface";
  313. params->vline_mode->guisection = _("Vector lines");
  314. /* line height */
  315. params->vline_height = G_define_option();
  316. params->vline_height->key = "vline_height";
  317. params->vline_height->key_desc = "value";
  318. params->vline_height->type = TYPE_INTEGER;
  319. params->vline_height->required = NO;
  320. params->vline_height->multiple = YES;
  321. params->vline_height->description = _("Vector line height");
  322. params->vline_height->guisection = _("Vector lines");
  323. params->vline_height->options = "0-1000";
  324. params->vline_height->answer = "0";
  325. /* position */
  326. params->vline_pos = G_define_option();
  327. params->vline_pos->key = "vline_position";
  328. params->vline_pos->key_desc = "x,y,z";
  329. params->vline_pos->type = TYPE_INTEGER;
  330. params->vline_pos->required = NO;
  331. params->vline_pos->multiple = YES;
  332. params->vline_pos->description = _("Vector lines position");
  333. params->vline_pos->guisection = _("Vector lines");
  334. params->vline_pos->answer = "0,0,0";
  335. return;
  336. }
  337. void args_vpoint(struct GParams *params)
  338. {
  339. params->vpoints = G_define_standard_option(G_OPT_V_MAP);
  340. params->vpoints->multiple = YES;
  341. params->vpoints->required = NO;
  342. params->vpoints->description = _("Name of point vector overlay map(s)");
  343. params->vpoints->guisection = _("Vector points");
  344. params->vpoints->key = "vpoint";
  345. params->vpoint_layer = G_define_standard_option(G_OPT_V_FIELD);
  346. params->vpoint_layer->multiple = YES;
  347. params->vpoint_layer->required = NO;
  348. params->vpoint_layer->description =
  349. _("Layer number or name for thematic mapping");
  350. params->vpoint_layer->guisection = _("Vector points");
  351. params->vpoint_layer->key = "vpoint_layer";
  352. params->vpoint_layer->answer = "1";
  353. /* point size */
  354. params->vpoint_size = G_define_option();
  355. params->vpoint_size->key = "vpoint_size";
  356. params->vpoint_size->key_desc = "value";
  357. params->vpoint_size->type = TYPE_DOUBLE;
  358. params->vpoint_size->required = NO;
  359. params->vpoint_size->multiple = YES;
  360. params->vpoint_size->description = _("Icon size (map units)");
  361. params->vpoint_size->guisection = _("Vector points");
  362. params->vpoint_size->options = "0-1000";
  363. params->vpoint_size->answer = "100";
  364. params->vpoint_size_column = G_define_standard_option(G_OPT_DB_COLUMN);
  365. params->vpoint_size_column->multiple = YES;
  366. params->vpoint_size_column->required = NO;
  367. params->vpoint_size_column->label = _("Name of size definition column");
  368. params->vpoint_size_column->key = "vpoint_size_column";
  369. params->vpoint_size_column->guisection = _("Vector points");
  370. /* point width */
  371. params->vpoint_width = G_define_option();
  372. params->vpoint_width->key = "vpoint_width";
  373. params->vpoint_width->key_desc = "value";
  374. params->vpoint_width->type = TYPE_INTEGER;
  375. params->vpoint_width->required = NO;
  376. params->vpoint_width->multiple = YES;
  377. params->vpoint_width->description = _("Icon width");
  378. params->vpoint_width->guisection = _("Vector points");
  379. params->vpoint_width->options = "1-1000";
  380. params->vpoint_width->answer = "2";
  381. params->vpoint_width_column = G_define_standard_option(G_OPT_DB_COLUMN);
  382. params->vpoint_width_column->multiple = YES;
  383. params->vpoint_width_column->required = NO;
  384. params->vpoint_width_column->label = _("Name of width definition column");
  385. params->vpoint_width_column->key = "vpoint_width_column";
  386. params->vpoint_width_column->guisection = _("Vector points");
  387. /* point color */
  388. params->vpoint_color = G_define_standard_option(G_OPT_C_FG);
  389. params->vpoint_color->multiple = YES;
  390. params->vpoint_color->required = NO;
  391. params->vpoint_color->label = _("Icon color");
  392. params->vpoint_color->key = "vpoint_color";
  393. params->vpoint_color->answer = "blue";
  394. params->vpoint_color->guisection = _("Vector points");
  395. params->vpoint_color_column = G_define_standard_option(G_OPT_DB_COLUMN);
  396. params->vpoint_color_column->multiple = YES;
  397. params->vpoint_color_column->required = NO;
  398. params->vpoint_color_column->label = _("Name of color definition column");
  399. params->vpoint_color_column->key = "vpoint_color_column";
  400. params->vpoint_color_column->guisection = _("Vector points");
  401. /* point icon type */
  402. params->vpoint_marker = G_define_option();
  403. params->vpoint_marker->key = "vpoint_marker";
  404. params->vpoint_marker->key_desc = "string";
  405. params->vpoint_marker->type = TYPE_STRING;
  406. params->vpoint_marker->required = NO;
  407. params->vpoint_marker->multiple = YES;
  408. params->vpoint_marker->description = _("Icon marker");
  409. params->vpoint_marker->options =
  410. "x,box,sphere,cube,diamond,dec_tree,con_tree,aster,gyro,histogram";
  411. params->vpoint_marker->answer = "sphere";
  412. params->vpoint_marker->guisection = _("Vector points");
  413. params->vpoint_marker_column = G_define_standard_option(G_OPT_DB_COLUMN);
  414. params->vpoint_marker_column->multiple = YES;
  415. params->vpoint_marker_column->required = NO;
  416. params->vpoint_marker_column->label =
  417. _("Name of marker definition column");
  418. params->vpoint_marker_column->key = "vpoint_marker_column";
  419. params->vpoint_marker_column->guisection = _("Vector points");
  420. /* point mode */
  421. params->vpoint_mode = G_define_option();
  422. params->vpoint_mode->key = "vpoint_mode";
  423. params->vpoint_mode->key_desc = "string";
  424. params->vpoint_mode->type = TYPE_STRING;
  425. params->vpoint_mode->required = NO;
  426. params->vpoint_mode->multiple = YES;
  427. params->vpoint_mode->description = _("3D vector point display mode");
  428. params->vpoint_mode->options = "surface,3D";
  429. params->vpoint_mode->descriptions = _("surface;drape on raster surface;"
  430. "3D;place at 3D point's z-elevation");
  431. /* TODO: "flat", place at a constant elevation */
  432. params->vpoint_mode->answer = "3D";
  433. params->vpoint_mode->guisection = _("Vector points");
  434. /* position */
  435. params->vpoint_pos = G_define_option();
  436. params->vpoint_pos->key = "vpoint_position";
  437. params->vpoint_pos->key_desc = "x,y,z";
  438. params->vpoint_pos->type = TYPE_DOUBLE;
  439. params->vpoint_pos->required = NO;
  440. params->vpoint_pos->multiple = YES;
  441. params->vpoint_pos->description = _("Vector points position");
  442. params->vpoint_pos->guisection = _("Vector points");
  443. params->vpoint_pos->answer = "0,0,0";
  444. return;
  445. }
  446. void args_viewpoint(struct GParams *params)
  447. {
  448. /* position */
  449. params->pos = G_define_option();
  450. params->pos->key = "position";
  451. params->pos->key_desc = "x,y";
  452. params->pos->type = TYPE_DOUBLE;
  453. params->pos->required = NO;
  454. params->pos->multiple = NO;
  455. params->pos->description =
  456. _("Viewpoint position (x,y model coordinates)");
  457. params->pos->guisection = _("Viewpoint");
  458. params->pos->answer = "0.84,0.16";
  459. params->pos->options = "0.0-1.0";
  460. /* height */
  461. params->height = G_define_option();
  462. params->height->key = "height";
  463. params->height->key_desc = "value";
  464. params->height->type = TYPE_INTEGER;
  465. params->height->required = NO;
  466. params->height->multiple = NO;
  467. params->height->description = _("Viewpoint height (in map units)");
  468. params->height->guisection = _("Viewpoint");
  469. /* perspective */
  470. params->persp = G_define_option();
  471. params->persp->key = "perspective";
  472. params->persp->key_desc = "value";
  473. params->persp->type = TYPE_INTEGER;
  474. params->persp->required = NO;
  475. params->persp->multiple = NO;
  476. params->persp->description = _("Viewpoint field of view (in degrees)");
  477. params->persp->guisection = _("Viewpoint");
  478. params->persp->answer = "40";
  479. params->persp->options = "1-180";
  480. /* twist */
  481. params->twist = G_define_option();
  482. params->twist->key = "twist";
  483. params->twist->key_desc = "value";
  484. params->twist->type = TYPE_INTEGER;
  485. params->twist->required = NO;
  486. params->twist->multiple = NO;
  487. params->twist->description = _("Viewpoint twist angle (in degrees)");
  488. params->twist->guisection = _("Viewpoint");
  489. params->twist->answer = "0";
  490. params->twist->options = "-180-180";
  491. /* z-exag */
  492. params->exag = G_define_option();
  493. params->exag->key = "zexag";
  494. params->exag->key_desc = "value";
  495. params->exag->type = TYPE_DOUBLE;
  496. params->exag->required = NO;
  497. params->exag->multiple = NO;
  498. params->exag->description = _("Vertical exaggeration");
  499. /* focus */
  500. params->focus = G_define_option();
  501. params->focus->key = "focus";
  502. params->focus->key_desc = "x,y,z";
  503. params->focus->type = TYPE_DOUBLE;
  504. params->focus->required = NO;
  505. params->focus->multiple = NO;
  506. params->focus->description =
  507. _("Focus to point on surface (from SW corner in map units)");
  508. params->focus->guisection = _("Viewpoint");
  509. return;
  510. }
  511. void args_volume(struct GParams *params)
  512. {
  513. params->volume = G_define_standard_option(G_OPT_R3_MAPS);
  514. params->volume->required = NO;
  515. params->volume->guisection = _("Volumes");
  516. params->volume->key = "volume";
  517. /* mode */
  518. params->volume_mode = G_define_option();
  519. params->volume_mode->key = "volume_mode";
  520. params->volume_mode->key_desc = "string";
  521. params->volume_mode->type = TYPE_STRING;
  522. params->volume_mode->required = NO;
  523. params->volume_mode->multiple = YES;
  524. params->volume_mode->description = _("Volume draw mode");
  525. params->volume_mode->options = "isosurface,slice";
  526. params->volume_mode->answer = "isosurface";
  527. params->volume_mode->guisection = _("Draw");
  528. /* shading */
  529. params->volume_shade = G_define_option();
  530. params->volume_shade->key = "volume_shading";
  531. params->volume_shade->key_desc = "string";
  532. params->volume_shade->type = TYPE_STRING;
  533. params->volume_shade->required = NO;
  534. params->volume_shade->multiple = YES;
  535. params->volume_shade->description = _("Volume shading");
  536. params->volume_shade->options = "flat,gouraud";
  537. params->volume_shade->answer = "gouraud";
  538. params->volume_shade->guisection = _("Draw");
  539. /* position */
  540. params->volume_pos = G_define_option();
  541. params->volume_pos->key = "volume_position";
  542. params->volume_pos->key_desc = "x,y,z";
  543. params->volume_pos->type = TYPE_INTEGER;
  544. params->volume_pos->required = NO;
  545. params->volume_pos->multiple = YES;
  546. params->volume_pos->description = _("Volume position");
  547. params->volume_pos->guisection = _("Volumes");
  548. params->volume_pos->answer = "0,0,0";
  549. /* resolution */
  550. params->volume_res = G_define_option();
  551. params->volume_res->key = "volume_resolution";
  552. params->volume_res->key_desc = "value";
  553. params->volume_res->type = TYPE_INTEGER;
  554. params->volume_res->required = NO;
  555. params->volume_res->multiple = YES;
  556. params->volume_res->description = _("Volume resolution");
  557. params->volume_res->answer = "3";
  558. params->volume_res->guisection = _("Volumes");
  559. /* isosurface level */
  560. params->isosurf_level = G_define_option();
  561. params->isosurf_level->key = "isosurf_level";
  562. params->isosurf_level->key_desc = "volume:value";
  563. params->isosurf_level->type = TYPE_STRING;
  564. params->isosurf_level->required = NO;
  565. params->isosurf_level->multiple = YES;
  566. params->isosurf_level->description = _("Isosurface level");
  567. params->isosurf_level->guisection = _("Volumes");
  568. /* isosurface color map */
  569. params->isosurf_color_map = G_define_standard_option(G_OPT_R3_MAPS);
  570. params->isosurf_color_map->key = "isosurf_color_map";
  571. params->isosurf_color_map->required = NO;
  572. params->isosurf_color_map->multiple = YES;
  573. params->isosurf_color_map->description =
  574. _("Name of volume for isosurface color");
  575. params->isosurf_color_map->guisection = _("Volumes");
  576. /* isosurface color value */
  577. params->isosurf_color_const = G_define_standard_option(G_OPT_C_FG);
  578. params->isosurf_color_const->key = "isosurf_color_value";
  579. params->isosurf_color_const->required = NO;
  580. params->isosurf_color_const->multiple = YES;
  581. params->isosurf_color_const->label = _("Isosurface color");
  582. params->isosurf_color_const->guisection = _("Volumes");
  583. params->isosurf_color_const->answer = NULL;
  584. /* isosurface transparency */
  585. params->isosurf_transp_map = G_define_standard_option(G_OPT_R3_MAP);
  586. params->isosurf_transp_map->multiple = YES;
  587. params->isosurf_transp_map->required = NO;
  588. params->isosurf_transp_map->description =
  589. _("Name of 3D raster map(s) for isosurface transparency");
  590. params->isosurf_transp_map->guisection = _("Volumes");
  591. params->isosurf_transp_map->key = "isosurf_transparency_map";
  592. params->isosurf_transp_const = G_define_option();
  593. params->isosurf_transp_const->key = "isosurf_transparency_value";
  594. params->isosurf_transp_const->key_desc = "value";
  595. params->isosurf_transp_const->type = TYPE_INTEGER;
  596. params->isosurf_transp_const->required = NO;
  597. params->isosurf_transp_const->multiple = YES;
  598. params->isosurf_transp_const->description =
  599. _("Transparency value(s)for isosurfaces");
  600. params->isosurf_transp_const->guisection = _("Volumes");
  601. params->isosurf_transp_const->options = "0-255";
  602. /* isosurface shininess */
  603. params->isosurf_shine_map = G_define_standard_option(G_OPT_R3_MAP);
  604. params->isosurf_shine_map->multiple = YES;
  605. params->isosurf_shine_map->required = NO;
  606. params->isosurf_shine_map->description =
  607. _("Name of 3D raster map(s) for shininess");
  608. params->isosurf_shine_map->guisection = _("Volumes");
  609. params->isosurf_shine_map->key = "isosurf_shininess_map";
  610. params->isosurf_shine_const = G_define_option();
  611. params->isosurf_shine_const->key = "isosurf_shininess_value";
  612. params->isosurf_shine_const->key_desc = "value";
  613. params->isosurf_shine_const->type = TYPE_INTEGER;
  614. params->isosurf_shine_const->required = NO;
  615. params->isosurf_shine_const->multiple = YES;
  616. params->isosurf_shine_const->description =
  617. _("Shininess value(s) for isosurfaces");
  618. params->isosurf_shine_const->guisection = _("Volumes");
  619. params->isosurf_shine_const->options = "0-255";
  620. params->isosurf_toggle_norm_dir = G_define_flag();
  621. params->isosurf_toggle_norm_dir->key = 'n';
  622. params->isosurf_toggle_norm_dir->description =
  623. _("Toggles normal direction of all isosurfaces (changes light effect)");
  624. params->isosurf_toggle_norm_dir->guisection = _("Volumes");
  625. params->draw_volume_box = G_define_flag();
  626. params->draw_volume_box->key = 'b';
  627. params->draw_volume_box->description =
  628. _("Draw volume box");
  629. params->draw_volume_box->guisection = _("Volumes");
  630. /* slices */
  631. /* slice axis */
  632. params->slice = G_define_option();
  633. params->slice->key = "slice";
  634. params->slice->key_desc = "volume:axis";
  635. params->slice->type = TYPE_STRING;
  636. params->slice->required = NO;
  637. params->slice->multiple = YES;
  638. params->slice->description =
  639. _("Volume slice parallel to given axis (x, y, z)");
  640. params->slice->guisection = _("Volumes");
  641. /* slice position */
  642. params->slice_pos = G_define_option();
  643. params->slice_pos->key = "slice_position";
  644. params->slice_pos->key_desc = "x1,x2,y1,y2,z1,z2";
  645. params->slice_pos->type = TYPE_DOUBLE;
  646. params->slice_pos->required = NO;
  647. params->slice_pos->multiple = YES;
  648. params->slice_pos->description = _("Volume slice position");
  649. params->slice_pos->guisection = _("Volumes");
  650. params->slice_pos->answer = "0,1,0,1,0,1";
  651. /* slice transparency */
  652. params->slice_transp = G_define_option();
  653. params->slice_transp->key = "slice_transparency";
  654. params->slice_transp->key_desc = "value";
  655. params->slice_transp->type = TYPE_INTEGER;
  656. params->slice_transp->required = NO;
  657. params->slice_transp->multiple = YES;
  658. params->slice_transp->description = _("Volume slice transparency");
  659. params->slice_transp->guisection = _("Volumes");
  660. params->slice_transp->answer = "0";
  661. params->slice_transp->options = "0-255";
  662. return;
  663. }
  664. void args_lighting(struct GParams *params)
  665. {
  666. params->light_pos = G_define_option();
  667. params->light_pos->key = "light_position";
  668. params->light_pos->key_desc = "x,y,z";
  669. params->light_pos->type = TYPE_DOUBLE;
  670. params->light_pos->required = NO;
  671. params->light_pos->multiple = NO;
  672. params->light_pos->description =
  673. _("Light position (x,y,z model coordinates)");
  674. params->light_pos->guisection = _("Lighting");
  675. params->light_pos->answer = "0.68,-0.68,0.80";
  676. params->light_color = G_define_standard_option(G_OPT_C_FG);
  677. params->light_color->key = "light_color";
  678. params->light_color->label = _("Light color");
  679. params->light_color->guisection = _("Lighting");
  680. params->light_color->answer = "white";
  681. params->light_bright = G_define_option();
  682. params->light_bright->key = "light_brightness";
  683. params->light_bright->type = TYPE_INTEGER;
  684. params->light_bright->required = NO;
  685. params->light_bright->multiple = NO;
  686. params->light_bright->description = _("Light brightness");
  687. params->light_bright->guisection = _("Lighting");
  688. params->light_bright->answer = "80";
  689. params->light_bright->options = "0-100";
  690. params->light_ambient = G_define_option();
  691. params->light_ambient->key = "light_ambient";
  692. params->light_ambient->type = TYPE_INTEGER;
  693. params->light_ambient->required = NO;
  694. params->light_ambient->multiple = NO;
  695. params->light_ambient->description = _("Light ambient");
  696. params->light_ambient->guisection = _("Lighting");
  697. params->light_ambient->answer = "20";
  698. params->light_ambient->options = "0-100";
  699. }
  700. void args_cplane(struct GParams *params)
  701. {
  702. params->cplane = G_define_option();
  703. params->cplane->key = "cplane";
  704. params->cplane->key_desc = "value";
  705. params->cplane->type = TYPE_INTEGER;
  706. params->cplane->required = NO;
  707. params->cplane->multiple = YES;
  708. params->cplane->description = _("Cutting plane index (0-5)");
  709. params->cplane->guisection = _("Cutting planes");
  710. params->cplane_pos = G_define_option();
  711. params->cplane_pos->key = "cplane_position";
  712. params->cplane_pos->key_desc = "x,y,z";
  713. params->cplane_pos->type = TYPE_DOUBLE;
  714. params->cplane_pos->required = NO;
  715. params->cplane_pos->multiple = YES;
  716. params->cplane_pos->description = _("Cutting plane x,y,z coordinates");
  717. params->cplane_pos->guisection = _("Cutting planes");
  718. params->cplane_pos->answer = "0,0,0";
  719. params->cplane_rot = G_define_option();
  720. params->cplane_rot->key = "cplane_rotation";
  721. params->cplane_rot->key_desc = "value";
  722. params->cplane_rot->type = TYPE_DOUBLE;
  723. params->cplane_rot->multiple = YES;
  724. params->cplane_rot->required = NO;
  725. params->cplane_rot->guisection = _("Cutting planes");
  726. params->cplane_rot->description =
  727. _("Cutting plane rotation along the vertical axis");
  728. params->cplane_rot->answer = "0";
  729. params->cplane_rot->options = "0-360";
  730. params->cplane_tilt = G_define_option();
  731. params->cplane_tilt->key = "cplane_tilt";
  732. params->cplane_tilt->key_desc = "value";
  733. params->cplane_tilt->type = TYPE_DOUBLE;
  734. params->cplane_tilt->multiple = YES;
  735. params->cplane_tilt->required = NO;
  736. params->cplane_tilt->guisection = _("Cutting planes");
  737. params->cplane_tilt->description = _("Cutting plane tilt");
  738. params->cplane_tilt->answer = "0";
  739. params->cplane_tilt->options = "0-360";
  740. params->cplane_shading = G_define_option();
  741. params->cplane_shading->key = "cplane_shading";
  742. params->cplane_shading->key_desc = "string";
  743. params->cplane_shading->type = TYPE_STRING;
  744. params->cplane_shading->multiple = NO;
  745. params->cplane_shading->required = NO;
  746. params->cplane_shading->guisection = _("Cutting planes");
  747. params->cplane_shading->description =
  748. _("Cutting plane color (between two surfaces)");
  749. params->cplane_shading->answer = "clear";
  750. params->cplane_shading->options = "clear,top,bottom,blend,shaded";
  751. }
  752. void args_fringe(struct GParams *params)
  753. {
  754. char *desc;
  755. params->fringe = G_define_option();
  756. params->fringe->key = "fringe";
  757. params->fringe->type = TYPE_STRING;
  758. params->fringe->options = "nw,ne,sw,se";
  759. desc = NULL;
  760. G_asprintf(&desc,
  761. "nw;%s;ne;%s;sw;%s;se;%s",
  762. _("North-West edge"),
  763. _("North-East edge"),
  764. _("South-West edge"), _("South-East edge"));
  765. params->fringe->descriptions = desc;
  766. params->fringe->description = _("Fringe edges");
  767. params->fringe->guisection = _("Fringe");
  768. params->fringe->multiple = YES;
  769. params->fringe_color = G_define_standard_option(G_OPT_C_FG);
  770. params->fringe_color->key = "fringe_color";
  771. params->fringe_color->label = _("Fringe color");
  772. params->fringe_color->guisection = _("Fringe");
  773. params->fringe_color->answer = "grey";
  774. params->fringe_elev = G_define_option();
  775. params->fringe_elev->key = "fringe_elevation";
  776. params->fringe_elev->type = TYPE_INTEGER;
  777. params->fringe_elev->required = NO;
  778. params->fringe_elev->multiple = NO;
  779. params->fringe_elev->description = _("Fringe elevation");
  780. params->fringe_elev->guisection = _("Fringe");
  781. params->fringe_elev->answer = "55";
  782. }
  783. void args_arrow(struct GParams *params)
  784. {
  785. params->north_arrow = G_define_option();
  786. params->north_arrow->key = "arrow_position";
  787. params->north_arrow->key_desc = "x,y";
  788. params->north_arrow->type = TYPE_INTEGER;
  789. params->north_arrow->required = NO;
  790. params->north_arrow->multiple = NO;
  791. params->north_arrow->description =
  792. _("Place north arrow at given position \
  793. (in screen coordinates from bottom left corner)");
  794. params->north_arrow->guisection = _("Decoration");
  795. params->north_arrow_size = G_define_option();
  796. params->north_arrow_size->key = "arrow_size";
  797. params->north_arrow_size->key_desc = "value";
  798. params->north_arrow_size->type = TYPE_DOUBLE;
  799. params->north_arrow_size->required = NO;
  800. params->north_arrow_size->multiple = NO;
  801. params->north_arrow_size->description =
  802. _("North arrow size (in map units)");
  803. params->north_arrow_size->guisection = _("Decoration");
  804. params->north_arrow_color = G_define_standard_option(G_OPT_C_FG);
  805. params->north_arrow_color->key = "arrow_color";
  806. params->north_arrow_color->required = NO;
  807. params->north_arrow_color->multiple = NO;
  808. params->north_arrow_color->label = _("North arrow color");
  809. params->north_arrow_color->guisection = _("Decoration");
  810. params->north_arrow_color->answer = "black";
  811. }
  812. /*!
  813. \brief Get number of answers of given option
  814. \param pointer to option
  815. \return number of arguments
  816. */
  817. int opt_get_num_answers(const struct Option *opt)
  818. {
  819. int i;
  820. i = 0;
  821. if (opt->answer) {
  822. while (opt->answers[i]) {
  823. i++;
  824. }
  825. }
  826. G_debug(3, "opt_get_num_answers(): opt=%s num=%d", opt->key, i);
  827. return i;
  828. }
  829. /*!
  830. \brief Check parameters consistency
  831. \param params module parameters
  832. */
  833. void check_parameters(const struct GParams *params)
  834. {
  835. int nelev_map, nelev_const, nelevs;
  836. int nmaps, nconsts, ncoords, ncplanes;
  837. int nvlines;
  838. int nvpoints, nvpoints_pos, nvpoints_layer;
  839. int nvolumes, nisosurf, nslices;
  840. /* topography */
  841. nelev_map = opt_get_num_answers(params->elev_map);
  842. nelev_const = opt_get_num_answers(params->elev_const);
  843. nelevs = nelev_map + nelev_const;
  844. #if 0
  845. if (nelevs < 1)
  846. G_fatal_error(_("At least one <%s> or <%s> required"),
  847. params->elev_map->key, params->elev_const->key);
  848. #endif
  849. /* color */
  850. nmaps = opt_get_num_answers(params->color_map);
  851. nconsts = opt_get_num_answers(params->color_const);
  852. print_error(nmaps, nconsts, nelevs,
  853. params->elev_map->key, params->elev_const->key,
  854. params->color_map->key, params->color_const->key);
  855. /* mask */
  856. nmaps = opt_get_num_answers(params->mask_map);
  857. if (nmaps > 0 && nelevs != nmaps)
  858. G_fatal_error(_("Inconsistent number of attributes (<%s/%s>: %d vs. <%s>: %d)"),
  859. params->elev_map->key, params->elev_const->key, nelevs,
  860. params->mask_map->key, nmaps);
  861. /* transparency */
  862. nmaps = opt_get_num_answers(params->transp_map);
  863. nconsts = opt_get_num_answers(params->transp_const);
  864. print_error(nmaps, nconsts, nelevs,
  865. params->elev_map->key, params->elev_const->key,
  866. params->transp_map->key, params->transp_const->key);
  867. /* shininess */
  868. nmaps = opt_get_num_answers(params->shine_map);
  869. nconsts = opt_get_num_answers(params->shine_const);
  870. print_error(nmaps, nconsts, nelevs,
  871. params->elev_map->key, params->elev_const->key,
  872. params->shine_map->key, params->shine_const->key);
  873. /* emit */
  874. nmaps = opt_get_num_answers(params->emit_map);
  875. nconsts = opt_get_num_answers(params->emit_const);
  876. print_error(nmaps, nconsts, nelevs,
  877. params->elev_map->key, params->elev_const->key,
  878. params->emit_map->key, params->emit_const->key);
  879. /* draw mode */
  880. if (!params->mode_all->answer) { /* use one mode for all surfaces */
  881. nconsts = opt_get_num_answers(params->mode);
  882. if (nconsts > 0 && nelevs > 0 && nconsts != nelevs)
  883. G_fatal_error(_("Inconsistent number of attributes (<%s/%s>: %d vs. <%s>: %d)"),
  884. params->elev_map->key, params->elev_const->key,
  885. nelevs, params->mode->key, nconsts);
  886. nconsts = opt_get_num_answers(params->res_fine);
  887. if (nconsts > 0 && nelevs > 0 && nconsts != nelevs)
  888. G_fatal_error(_("Inconsistent number of attributes (<%s/%s>: %d vs. <%s>: %d)"),
  889. params->elev_map->key, params->elev_const->key,
  890. nelevs, params->res_fine->key, nconsts);
  891. nconsts = opt_get_num_answers(params->res_coarse);
  892. if (nconsts > 0 && nelevs > 0 && nconsts != nelevs)
  893. G_fatal_error(_("Inconsistent number of attributes (<%s/%s>: %d vs. <%s>: %d)"),
  894. params->elev_map->key, params->elev_const->key,
  895. nelevs, params->res_coarse->key, nconsts);
  896. nconsts = opt_get_num_answers(params->style);
  897. if (nconsts > 0 && nelevs > 0 && nconsts != nelevs)
  898. G_fatal_error(_("Inconsistent number of attributes (<%s/%s>: %d vs. <%s>: %d)"),
  899. params->elev_map->key, params->elev_const->key,
  900. nelevs, params->style->key, nconsts);
  901. nconsts = opt_get_num_answers(params->shade);
  902. if (nconsts > 0 && nelevs > 0 && nconsts != nelevs)
  903. G_fatal_error(_("Inconsistent number of attributes (<%s/%s>: %d vs. <%s>: %d)"),
  904. params->elev_map->key, params->elev_const->key,
  905. nelevs, params->shade->key, nconsts);
  906. nconsts = opt_get_num_answers(params->wire_color);
  907. if (nconsts > 0 && nelevs > 0 && nconsts != nelevs)
  908. G_fatal_error(_("Inconsistent number of attributes (<%s/%s>: %d vs. <%s>: %d)"),
  909. params->elev_map->key, params->elev_const->key,
  910. nelevs, params->wire_color->key, nconsts);
  911. }
  912. /*
  913. * Cutting planes
  914. */
  915. ncplanes = opt_get_num_answers(params->cplane);
  916. ncoords = opt_get_num_answers(params->cplane_pos);
  917. if (ncplanes > 0 && ncplanes * 3 != ncoords)
  918. G_fatal_error(_("Inconsistent number of attributes (<%s>: %d vs. <%s>: %d x 3)"),
  919. params->cplane->key, ncplanes, params->cplane_pos->key,
  920. ncoords / 3);
  921. nconsts = opt_get_num_answers(params->cplane_rot);
  922. if (ncplanes > 0 && ncplanes != nconsts)
  923. G_fatal_error(_("Inconsistent number of attributes (<%s>: %d vs. <%s>: %d)"),
  924. params->cplane->key, ncplanes, params->cplane_rot->key,
  925. nconsts);
  926. nconsts = opt_get_num_answers(params->cplane_tilt);
  927. if (ncplanes > 0 && ncplanes != nconsts)
  928. G_fatal_error(_("Inconsistent number of attributes (<%s>: %d vs. <%s>: %d)"),
  929. params->cplane->key, ncplanes, params->cplane_tilt->key,
  930. nconsts);
  931. /*
  932. * vector lines
  933. */
  934. nvlines = opt_get_num_answers(params->vlines);
  935. /* width */
  936. nconsts = opt_get_num_answers(params->vline_width);
  937. if (nvlines > 0 && nconsts != nvlines)
  938. G_fatal_error(_("Inconsistent number of attributes (<%s>: %d vs. <%s>: %d)"),
  939. params->vlines->key, nvlines, params->vline_width->key,
  940. nconsts);
  941. /* color */
  942. nconsts = opt_get_num_answers(params->vline_color);
  943. if (nvlines > 0 && nconsts != nvlines)
  944. G_fatal_error(_("Inconsistent number of attributes (<%s>: %d vs. <%s>: %d)"),
  945. params->vlines->key, nvlines, params->vline_color->key,
  946. nconsts);
  947. /* mode */
  948. nconsts = opt_get_num_answers(params->vline_mode);
  949. if (nvlines > 0 && nconsts != nvlines)
  950. G_fatal_error(_("Inconsistent number of attributes (<%s>: %d vs. <%s>: %d)"),
  951. params->vlines->key, nvlines, params->vline_mode->key,
  952. nconsts);
  953. /* height */
  954. nconsts = opt_get_num_answers(params->vline_height);
  955. if (nvlines > 0 && nconsts != nvlines)
  956. G_fatal_error(_("Inconsistent number of attributes (<%s>: %d vs. <%s>: %d)"),
  957. params->vlines->key, nvlines, params->vline_height->key,
  958. nconsts);
  959. /* position */
  960. nconsts = opt_get_num_answers(params->vline_pos);
  961. if (nvlines > 0 && nconsts != 3 * nvlines)
  962. G_fatal_error(_("Inconsistent number of attributes (<%s>: %d vs. <%s>: %d)"),
  963. params->vlines->key, nvlines, params->vline_pos->key,
  964. nconsts);
  965. /*
  966. * vector points
  967. */
  968. nvpoints = opt_get_num_answers(params->vpoints);
  969. nvpoints_pos = opt_get_num_answers(params->vpoint_pos);
  970. nvpoints_layer = opt_get_num_answers(params->vpoint_layer);
  971. if (nvpoints && (nvpoints * 3 != nvpoints_pos))
  972. G_fatal_error(_("Inconsistent number of attributes (<%s>: %d vs. <%s>: %d)"),
  973. params->vpoints->key, nvpoints, params->vpoint_pos->key,
  974. nvpoints_pos);
  975. if (nvpoints && (nvpoints != nvpoints_layer))
  976. G_fatal_error(_("Inconsistent number of attributes (<%s>: %d vs. <%s>: %d)"),
  977. params->vpoints->key, nvpoints,
  978. params->vpoint_layer->key, nvpoints_layer);
  979. /* TODO */
  980. /*
  981. * volumes
  982. */
  983. nvolumes = opt_get_num_answers(params->volume);
  984. nisosurf = opt_get_num_answers(params->isosurf_level);
  985. nslices = opt_get_num_answers(params->slice);
  986. /* isosurface transparency */
  987. nmaps = opt_get_num_answers(params->isosurf_transp_map);
  988. nconsts = opt_get_num_answers(params->isosurf_transp_const);
  989. if ((nmaps + nconsts > 0) && (nisosurf != nmaps + nconsts))
  990. G_fatal_error(_("Inconsistent number of attributes (<%s>: %d vs. <%s>: %d, <%s>: %d)"),
  991. params->isosurf_level->key, nisosurf,
  992. params->isosurf_transp_map->key, nmaps,
  993. params->isosurf_transp_const->key, nconsts);
  994. /* isosurface shininess */
  995. nmaps = opt_get_num_answers(params->isosurf_shine_map);
  996. nconsts = opt_get_num_answers(params->isosurf_shine_const);
  997. if ((nmaps + nconsts > 0) && (nisosurf != nmaps + nconsts))
  998. G_fatal_error(_("Inconsistent number of attributes (<%s>: %d vs. <%s>: %d, <%s>: %d)"),
  999. params->isosurf_level->key, nisosurf,
  1000. params->isosurf_shine_map->key, nmaps,
  1001. params->isosurf_shine_const->key, nconsts);
  1002. /* slice transparency */
  1003. nconsts = opt_get_num_answers(params->slice_transp);
  1004. if (nslices > 0 && nslices != nconsts)
  1005. G_fatal_error(_("Inconsistent number of attributes (<%s>: %d vs. <%s>: %d)"),
  1006. params->slice->key, nslices, params->slice_transp->key,
  1007. nconsts);
  1008. /* slice position */
  1009. ncoords = opt_get_num_answers(params->slice_pos);
  1010. if (nslices > 0 && ncoords != 6 * nslices)
  1011. G_fatal_error(_("Inconsistent number of attributes (<%s>: %d vs. <%s>: %d x 6)"),
  1012. params->slice->key, nslices, params->slice_pos->key,
  1013. ncoords / 6);
  1014. return;
  1015. }
  1016. void print_error(int nmaps, int nconsts, int nelevs,
  1017. const char *elev_map, const char *elev_const,
  1018. const char *map_name, const char *const_name)
  1019. {
  1020. if ((nmaps + nconsts > 0) && (nelevs != nmaps + nconsts))
  1021. G_fatal_error(_("Inconsistent number of attributes (<%s/%s>: %d vs. <%s>: %d, <%s>: %d)"),
  1022. elev_map, elev_const, nelevs, map_name, nmaps,
  1023. const_name, nconsts);
  1024. return;
  1025. }