~ubuntu-branches/ubuntu/wily/grass/wily

« back to all changes in this revision

Viewing changes to display/d.mapgraph/main.c

Tags: 7.0.0~rc1+ds1-1~exp1
* New upstream release candidate.
* Repack upstream tarball, remove precompiled Python objects.
* Add upstream metadata.
* Update gbp.conf and Vcs-Git URL to use the experimental branch.
* Update watch file for GRASS 7.0.
* Drop build dependencies for Tcl/Tk, add build dependencies:
  python-numpy, libnetcdf-dev, netcdf-bin, libblas-dev, liblapack-dev
* Update Vcs-Browser URL to use cgit instead of gitweb.
* Update paths to use grass70.
* Add configure options: --with-netcdf, --with-blas, --with-lapack,
  remove --with-tcltk-includes.
* Update patches for GRASS 7.
* Update copyright file, changes:
  - Update copyright years
  - Group files by license
  - Remove unused license sections
* Add patches for various typos.
* Fix desktop file with patch instead of d/rules.
* Use minimal dh rules.
* Bump Standards-Version to 3.9.6, no changes.
* Use dpkg-maintscript-helper to replace directories with symlinks.
  (closes: #776349)
* Update my email to use @debian.org address.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
 
2
 
/****************************************************************************
3
 
 *
4
 
 * MODULE:       d.mapgraph
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
17
 
 *
18
 
 *               This program is free software under the GNU General Public
19
 
 *               License (>=v2). Read the file COPYING that comes with GRASS
20
 
 *               for details.
21
 
 *
22
 
 *****************************************************************************/
23
 
#include <stdlib.h>
24
 
#include <unistd.h>
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>
30
 
 
31
 
#define MAIN
32
 
#include "options.h"
33
 
#include "local_proto.h"
34
 
 
35
 
 
36
 
struct Cell_head window;
37
 
 
38
 
int main(int argc, char **argv)
39
 
{
40
 
    struct GModule *module;
41
 
    struct Option *opt1, *opt2 /*, *opt3, *opt4 */ ;
42
 
    int R, G, B, color = 0;
43
 
 
44
 
    /* Initialize the GIS calls */
45
 
    G_gisinit(argv[0]);
46
 
 
47
 
    module = G_define_module();
48
 
    module->keywords = _("display");
49
 
    module->description =
50
 
        _("Generates and displays simple graphics on map "
51
 
          "layers drawn in the active graphics monitor display frame.");
52
 
 
53
 
    opt1 = G_define_option();
54
 
    opt1->key = "input";
55
 
    opt1->type = TYPE_STRING;
56
 
    opt1->required = NO;
57
 
    opt1->description = _("Unix file containg graphing instructions, "
58
 
                          "if not given reads from standard input");
59
 
    opt1->gisprompt = "old_file,file,input";
60
 
 
61
 
    opt2 = G_define_option();
62
 
    opt2->key = "color";
63
 
    opt2->type = TYPE_STRING;
64
 
    opt2->required = NO;
65
 
    opt2->answer = DEFAULT_FG_COLOR;
66
 
 
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;
70
 
 
71
 
    /*
72
 
       opt3 = G_define_option() ;
73
 
       opt3->key        = "vsize" ;
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" ;
78
 
 
79
 
       opt4 = G_define_option() ;
80
 
       opt4->key        = "hsize" ;
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" ;
85
 
     */
86
 
 
87
 
    /* Check command line */
88
 
    if (G_parser(argc, argv))
89
 
        exit(1);
90
 
 
91
 
    G_warning("This module is superseded. Please use 'd.graph -m' instead.");
92
 
 
93
 
    if (opt1->answer != NULL) {
94
 
        /* 1/4/91  jmoorman
95
 
           mapset = G_find_file ("mapgraph", opt1->answer, "");
96
 
           if (mapset == NULL)
97
 
           {
98
 
           G_usage() ;
99
 
           G_fatal_error("Mapgraph file [%s] not available", opt1->answer);
100
 
           }
101
 
           Infile = G_fopen_old ("mapgraph", opt1->answer, mapset);
102
 
           if (Infile == NULL)
103
 
           {
104
 
           G_usage() ;
105
 
           G_fatal_error ("Graph file <%s> not available", opt1->answer);
106
 
           }
107
 
         */
108
 
        /* using fopen instead to facilitate finding the file */
109
 
        if ((Infile = fopen(opt1->answer, "r")) == NULL) {
110
 
            G_usage();
111
 
            G_fatal_error("Mapgraph file [%s] not available", opt1->answer);
112
 
        }
113
 
    }
114
 
    else {
115
 
        Infile = stdin;
116
 
        if (isatty(0))
117
 
            fprintf(stdout,
118
 
                    "\nEnter mapgraph commands; terminate with a ^D\n\n");
119
 
    }
120
 
 
121
 
 
122
 
    /* Parse and select color */
123
 
    if (opt2->answer != NULL) {
124
 
        color = G_str_to_color(opt2->answer, &R, &G, &B);
125
 
        if (color == 0)
126
 
            G_fatal_error("[%s]: No such color", opt2->answer);
127
 
        if (color == 1)
128
 
            R_RGB_color(R, G, B);
129
 
 
130
 
        /* (color==2) is "none", noop */
131
 
    }
132
 
 
133
 
    /*
134
 
       sscanf(opt3->answer,"%lf",&temp);
135
 
       vsize = temp ;
136
 
 
137
 
       sscanf(opt4->answer,"%lf",&temp);
138
 
       hsize = temp ;
139
 
     */
140
 
 
141
 
    vsize = hsize = 5.0;
142
 
 
143
 
    if (R_open_driver() != 0)
144
 
        G_fatal_error("No graphics device selected");
145
 
 
146
 
    D_setup(0);
147
 
 
148
 
    G_get_set_window(&window);
149
 
 
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));
152
 
    set_text_size();
153
 
 
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);
157
 
 
158
 
    graphics();
159
 
 
160
 
    /* Add this command to list */
161
 
    /*
162
 
       if(argc > 1)
163
 
       {
164
 
       D_add_to_list(G_recreate_command()) ;
165
 
       }
166
 
     */
167
 
 
168
 
    R_close_driver();
169
 
    exit(0);
170
 
}