~ubuntu-branches/ubuntu/vivid/grass/vivid-proposed

« back to all changes in this revision

Viewing changes to imagery/i.points/graphics.c

  • Committer: Package Import Robot
  • Author(s): Bas Couwenberg
  • Date: 2015-02-20 23:12:08 UTC
  • mfrom: (8.2.6 experimental)
  • Revision ID: package-import@ubuntu.com-20150220231208-1u6qvqm84v430b10
Tags: 7.0.0-1~exp1
* New upstream release.
* Update python-ctypes-ternary.patch to use if/else instead of and/or.
* Drop check4dev patch, rely on upstream check.
* Add build dependency on libpq-dev to grass-dev for libpq-fe.h.
* Drop patches applied upstream, refresh remaining patches.
* Update symlinks for images switched from jpg to png.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#include "globals.h"
2
 
#include "local_proto.h"
3
 
#include <grass/display.h>
4
 
#include <grass/raster.h>
5
 
 
6
 
static View *makeview(double bottom, double top, double left, double right)
7
 
{
8
 
    View *view;
9
 
 
10
 
    view = (View *) G_malloc(sizeof(View));
11
 
 
12
 
    top = 100 - top;
13
 
    bottom = 100 - bottom;
14
 
 
15
 
    view->top = SCREEN_TOP + (SCREEN_BOTTOM - SCREEN_TOP) * top / 100.0;
16
 
    view->bottom = SCREEN_TOP + (SCREEN_BOTTOM - SCREEN_TOP) * bottom / 100.0;
17
 
    view->left = SCREEN_LEFT + (SCREEN_RIGHT - SCREEN_LEFT) * left / 100.0;
18
 
    view->right = SCREEN_LEFT + (SCREEN_RIGHT - SCREEN_LEFT) * right / 100.0;
19
 
 
20
 
    if (view->top < SCREEN_TOP)
21
 
        view->top = SCREEN_TOP;
22
 
    if (view->bottom > SCREEN_BOTTOM)
23
 
        view->bottom = SCREEN_BOTTOM;
24
 
    if (view->left < SCREEN_LEFT)
25
 
        view->left = SCREEN_LEFT;
26
 
    if (view->right > SCREEN_RIGHT)
27
 
        view->right = SCREEN_RIGHT;
28
 
 
29
 
    Outline_box(view->top, view->bottom, view->left, view->right);
30
 
 
31
 
    view->top++;
32
 
    view->bottom--;
33
 
    view->left++;
34
 
    view->right--;
35
 
 
36
 
    view->nrows = view->bottom - view->top + 1;
37
 
    view->ncols = view->right - view->left + 1;
38
 
    view->cell.configured = 0;
39
 
 
40
 
    return view;
41
 
}
42
 
 
43
 
int Init_graphics(void)
44
 
{
45
 
    D_full_screen();
46
 
 
47
 
 
48
 
    SCREEN_TOP = R_screen_top();
49
 
    SCREEN_BOTTOM = R_screen_bot();
50
 
    SCREEN_LEFT = R_screen_left();
51
 
    SCREEN_RIGHT = R_screen_rite();
52
 
 
53
 
 
54
 
    BLACK = D_translate_color("black");
55
 
    BLUE = D_translate_color("blue");
56
 
    BROWN = D_translate_color("brown");
57
 
    GREEN = D_translate_color("green");
58
 
    GREY = D_translate_color("grey");
59
 
    ORANGE = D_translate_color("orange");
60
 
    PURPLE = D_translate_color("purple");
61
 
    RED = D_translate_color("red");
62
 
    WHITE = D_translate_color("white");
63
 
    YELLOW = D_translate_color("yellow");
64
 
 
65
 
    R_standard_color(WHITE);
66
 
 
67
 
    VIEW_TITLE1 = makeview(97.5, 100.0, 0.0, 50.0);
68
 
    VIEW_TITLE2 = makeview(97.5, 100.0, 50.0, 100.0);
69
 
    VIEW_MAP1 = makeview(51.0, 97.5, 0.0, 50.0);
70
 
    VIEW_MAP2 = makeview(51.0, 97.5, 50.0, 100.0);
71
 
    VIEW_TITLE1_ZOOM = makeview(47.5, 51.0, 0.0, 50.0);
72
 
    VIEW_TITLE2_ZOOM = makeview(47.5, 51.0, 50.0, 100.0);
73
 
    VIEW_MAP1_ZOOM = makeview(2.5, 47.5, 0.0, 50.0);
74
 
    VIEW_MAP2_ZOOM = makeview(2.5, 47.5, 50.0, 100.0);
75
 
    VIEW_MENU = makeview(0.0, 2.5, 0.0, 100.0);
76
 
 
77
 
    G_init_colors(&VIEW_MAP1->cell.colors);
78
 
    G_init_colors(&VIEW_MAP2->cell.colors);
79
 
 
80
 
    return 0;
81
 
}
82
 
 
83
 
int Outline_box(int top, int bottom, int left, int right)
84
 
{
85
 
    R_move_abs(left, top);
86
 
    R_cont_abs(left, bottom);
87
 
    R_cont_abs(right, bottom);
88
 
    R_cont_abs(right, top);
89
 
    R_cont_abs(left, top);
90
 
 
91
 
    return 0;
92
 
}
93
 
 
94
 
 
95
 
int Text_width(char *text)
96
 
{
97
 
    int top, bottom, left, right;
98
 
 
99
 
    R_get_text_box(text, &top, &bottom, &left, &right);
100
 
 
101
 
    if (right > left)
102
 
        return right - left + 1;
103
 
    else
104
 
        return left - right + 1;
105
 
}
106
 
 
107
 
int Text(char *text, int top, int bottom, int left, int right, int edge)
108
 
{
109
 
    R_set_window(top, bottom, left, right);
110
 
    R_move_abs(left + edge, bottom - edge);
111
 
    R_text(text);
112
 
    R_set_window(SCREEN_TOP, SCREEN_BOTTOM, SCREEN_LEFT, SCREEN_RIGHT);
113
 
 
114
 
    return 0;
115
 
}
116
 
 
117
 
int Uparrow(int top, int bottom, int left, int right)
118
 
{
119
 
    R_move_abs((left + right) / 2, bottom);
120
 
    R_cont_abs((left + right) / 2, top);
121
 
    R_cont_rel((left - right) / 2, (bottom - top) / 2);
122
 
    R_move_abs((left + right) / 2, top);
123
 
    R_cont_rel((right - left) / 2, (bottom - top) / 2);
124
 
 
125
 
    return 0;
126
 
}
127
 
 
128
 
int Downarrow(int top, int bottom, int left, int right)
129
 
{
130
 
    R_move_abs((left + right) / 2, top);
131
 
    R_cont_abs((left + right) / 2, bottom);
132
 
    R_cont_rel((left - right) / 2, (top - bottom) / 2);
133
 
    R_move_abs((left + right) / 2, bottom);
134
 
    R_cont_rel((right - left) / 2, (top - bottom) / 2);
135
 
 
136
 
    return 0;
137
 
}