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

« back to all changes in this revision

Viewing changes to visualization/ximgview/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:
16
16
#include <stdlib.h>
17
17
#include <unistd.h>
18
18
#include <string.h>
 
19
#include <signal.h>
 
20
#include <errno.h>
19
21
 
20
22
#include <unistd.h>
21
23
#include <fcntl.h>
30
32
#include <grass/gis.h>
31
33
#include <grass/glocale.h>
32
34
 
33
 
#define HEADER_SIZE 54
 
35
#define HEADER_SIZE 64
34
36
 
35
37
Display *dpy;
36
38
int scrn;
97
99
    XFlush(dpy);
98
100
}
99
101
 
100
 
static void redraw(void)
 
102
static void draw(void)
101
103
{
102
104
    int x0 = (w_width - i_width) / 2;
103
105
    int y0 = (w_height - i_height) / 2;
104
106
    const unsigned char *p = imgbuf;
105
 
    struct timeval tv0, tv1;
106
107
    int row, col;
107
108
 
108
 
    gettimeofday(&tv0, NULL);
109
 
 
110
109
    for (row = 0; row < i_height; row++) {
111
110
        for (col = 0; col < i_width; col++) {
112
111
            unsigned char b = *p++;
121
120
 
122
121
    XPutImage(dpy, grwin, gc, ximg, 0, 0, x0, y0, i_width, i_height);
123
122
    XSync(dpy, False);
 
123
}
 
124
 
 
125
static void redraw(void)
 
126
{
 
127
    struct timeval tv0, tv1;
 
128
 
 
129
    gettimeofday(&tv0, NULL);
 
130
 
 
131
    draw();
124
132
 
125
133
    gettimeofday(&tv1, NULL);
126
134
    last = (tv1.tv_sec - tv0.tv_sec) * 1000000L + (tv1.tv_usec - tv0.tv_usec);
127
135
}
128
136
 
 
137
static void dummy_handler(int sig)
 
138
{
 
139
}
 
140
 
129
141
static void main_loop(void)
130
142
{
131
143
    int xfd = ConnectionNumber(dpy);
 
144
    struct sigaction act;
 
145
 
 
146
    act.sa_handler = &dummy_handler;
 
147
    sigemptyset(&act.sa_mask);
 
148
    act.sa_flags = 0;
 
149
    sigaction(SIGUSR1, &act, NULL);
132
150
 
133
151
    for (;;) {
134
152
        fd_set waitset;
142
160
 
143
161
            switch (event.type) {
144
162
            case Expose:
145
 
                redraw();
 
163
                draw();
146
164
                break;
147
165
            case ConfigureNotify:
148
166
                w_width = event.xconfigure.width;
151
169
            }
152
170
        }
153
171
 
154
 
        delay = (unsigned long)(last / fraction);
 
172
        if (fraction > 0.001)
 
173
            delay = (unsigned long)(last / fraction);
155
174
 
156
175
        tv.tv_sec = delay / 1000000;
157
176
        tv.tv_usec = delay % 1000000;
158
177
 
159
178
        FD_ZERO(&waitset);
160
179
        FD_SET(xfd, &waitset);
161
 
        if (select(FD_SETSIZE, &waitset, NULL, NULL, &tv) < 0)
 
180
        errno = 0;
 
181
        if (select(FD_SETSIZE, &waitset, NULL, NULL, &tv) < 0 && errno != EINTR)
162
182
            continue;
163
183
 
164
 
        if (!FD_ISSET(xfd, &waitset))
 
184
        if (!FD_ISSET(xfd, &waitset) || errno == EINTR)
165
185
            redraw();
166
186
    }
167
187
}
267
287
    G_gisinit(argv[0]);
268
288
 
269
289
    module = G_define_module();
270
 
    module->keywords = _("display");
 
290
    G_add_keyword(_("display"));
 
291
    G_add_keyword(_("graphics"));
 
292
    G_add_keyword(_("raster"));
 
293
    G_add_keyword(_("vector"));
 
294
    G_add_keyword(_("visualization"));
271
295
    module->description = _("View BMP images from the PNG driver.");
272
296
 
273
 
    opt.image = G_define_option();
 
297
    opt.image = G_define_standard_option(G_OPT_F_INPUT);
274
298
    opt.image->key = "image";
275
 
    opt.image->type = TYPE_STRING;
276
299
    opt.image->required = YES;
277
 
    opt.image->multiple = NO;
278
 
    opt.image->gisprompt = "old_file,file,input";
 
300
    opt.image->gisprompt = "old_file,file,file";
279
301
    opt.image->description = _("Image file");
280
302
 
281
303
    opt.percent = G_define_option();