2
/****************************************************************************
5
* AUTHOR(S): James Westervelt (original contributor)
6
* Markus Neteler <neteler itc.it>,
7
* Roberto Flor <flor itc.it>,
8
* Bernhard Reiter <bernhard intevation.de>,
9
* Cedric Shock <cedricgrass shockfamily.net>,
10
* Huidae Cho <grass4u gmail.com>,
11
* Eric G. Miller <egm2 jps.net>,
12
* Glynn Clements <glynn gclements.plus.com>,
13
* Hamish Bowman <hamish_nospam yahoo.com>,
14
* Jan-Oliver Wagner <jan intevation.de>
15
* PURPOSE: draws graphs - now superceded by d.graph
16
* COPYRIGHT: (C) 1999-2007 by the GRASS Development Team
18
* This program is free software under the GNU General Public
19
* License (>=v2). Read the file COPYING that comes with GRASS
22
*****************************************************************************/
25
#include <grass/gis.h>
26
#include <grass/display.h>
27
#include <grass/raster.h>
28
#include <grass/colors.h>
29
#include <grass/glocale.h>
33
#include "local_proto.h"
36
struct Cell_head window;
38
int main(int argc, char **argv)
40
struct GModule *module;
41
struct Option *opt1, *opt2 /*, *opt3, *opt4 */ ;
42
int R, G, B, color = 0;
44
/* Initialize the GIS calls */
47
module = G_define_module();
48
module->keywords = _("display");
50
_("Generates and displays simple graphics on map "
51
"layers drawn in the active graphics monitor display frame.");
53
opt1 = G_define_option();
55
opt1->type = TYPE_STRING;
57
opt1->description = _("Unix file containg graphing instructions, "
58
"if not given reads from standard input");
59
opt1->gisprompt = "old_file,file,input";
61
opt2 = G_define_option();
63
opt2->type = TYPE_STRING;
65
opt2->answer = DEFAULT_FG_COLOR;
67
opt2->description = _("Color to draw with, either a standard GRASS color "
68
"or R:G:B triplet (separated by colons)");
69
opt2->gisprompt = GISPROMPT_COLOR;
72
opt3 = G_define_option() ;
74
opt3->type = TYPE_DOUBLE;
75
opt3->answer = "5.0" ;
76
opt3->options = "0-100" ;
77
opt3->description= "Vertical text height as % of display frame height" ;
79
opt4 = G_define_option() ;
81
opt4->type = TYPE_DOUBLE;
82
opt4->answer = "5.0" ;
83
opt4->options = "0-100" ;
84
opt4->description= "Horizontal text width as % of display frame width" ;
87
/* Check command line */
88
if (G_parser(argc, argv))
91
G_warning("This module is superseded. Please use 'd.graph -m' instead.");
93
if (opt1->answer != NULL) {
95
mapset = G_find_file ("mapgraph", opt1->answer, "");
99
G_fatal_error("Mapgraph file [%s] not available", opt1->answer);
101
Infile = G_fopen_old ("mapgraph", opt1->answer, mapset);
105
G_fatal_error ("Graph file <%s> not available", opt1->answer);
108
/* using fopen instead to facilitate finding the file */
109
if ((Infile = fopen(opt1->answer, "r")) == NULL) {
111
G_fatal_error("Mapgraph file [%s] not available", opt1->answer);
118
"\nEnter mapgraph commands; terminate with a ^D\n\n");
122
/* Parse and select color */
123
if (opt2->answer != NULL) {
124
color = G_str_to_color(opt2->answer, &R, &G, &B);
126
G_fatal_error("[%s]: No such color", opt2->answer);
128
R_RGB_color(R, G, B);
130
/* (color==2) is "none", noop */
134
sscanf(opt3->answer,"%lf",&temp);
137
sscanf(opt4->answer,"%lf",&temp);
143
if (R_open_driver() != 0)
144
G_fatal_error("No graphics device selected");
148
G_get_set_window(&window);
150
R_move_abs((int)(D_get_d_west() + D_get_d_east() / 2.0),
151
(int)(D_get_d_north() + D_get_d_south() / 2.0));
154
/* Do the graphics */
155
G_setup_plot(D_get_d_north(), D_get_d_south(), D_get_d_west(),
156
D_get_d_east(), D_move_abs, D_cont_abs);
160
/* Add this command to list */
164
D_add_to_list(G_recreate_command()) ;