~ubuntu-branches/ubuntu/precise/grass/precise

« back to all changes in this revision

Viewing changes to imagery/i.ortho.photo/photo.2image/graphics.c

  • Committer: Bazaar Package Importer
  • Author(s): Francesco Paolo Lovergine
  • Date: 2011-04-13 17:08:41 UTC
  • mfrom: (8.1.7 sid)
  • Revision ID: james.westby@ubuntu.com-20110413170841-ss1t9bic0d0uq0gz
Tags: 6.4.1-1
* New upstream version.
* Now build-dep on libjpeg-dev and current libreadline6-dev.
* Removed patch swig: obsolete.
* Policy bumped to 3.9.2, without changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#include <grass/gis.h>
2
 
#include <grass/display.h>
3
 
#include <grass/raster.h>
4
 
#include "globals.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
 
    /* Dclearscreen(); */
46
 
    D_full_screen();
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_MAP1 = makeview(51.0, 97.5, 0.0, 50.0);
69
 
    VIEW_TITLE1_ZOOM = makeview(97.5, 100.0, 50.0, 100.0);
70
 
    VIEW_MAP1_ZOOM = makeview(51.0, 97.5, 50.0, 100.0);
71
 
    VIEW_MENU = makeview(0.0, 2.5, 0.0, 100.0);
72
 
 
73
 
    G_init_colors(&VIEW_MAP1->cell.colors);
74
 
 
75
 
    return 0;
76
 
}
77
 
 
78
 
int Outline_box(int top, int bottom, int left, int right)
79
 
{
80
 
    R_move_abs(left, top);
81
 
    R_cont_abs(left, bottom);
82
 
    R_cont_abs(right, bottom);
83
 
    R_cont_abs(right, top);
84
 
    R_cont_abs(left, top);
85
 
 
86
 
    return 0;
87
 
}
88
 
 
89
 
 
90
 
int Text_width(char *text)
91
 
{
92
 
    int top, bottom, left, right;
93
 
 
94
 
    R_get_text_box(text, &top, &bottom, &left, &right);
95
 
 
96
 
    if (right > left)
97
 
        return right - left + 1;
98
 
    else
99
 
        return left - right + 1;
100
 
}
101
 
 
102
 
int Text(char *text, int top, int bottom, int left, int right, int the_border)
103
 
{
104
 
    R_set_window(top, bottom, left, right);
105
 
    R_move_abs(left + the_border, bottom - the_border);
106
 
    R_text(text);
107
 
    R_set_window(SCREEN_TOP, SCREEN_BOTTOM, SCREEN_LEFT, SCREEN_RIGHT);
108
 
 
109
 
    return 0;
110
 
}
111
 
 
112
 
int Uparrow(int top, int bottom, int left, int right)
113
 
{
114
 
    R_move_abs((left + right) / 2, bottom);
115
 
    R_cont_abs((left + right) / 2, top);
116
 
    R_cont_rel((left - right) / 2, (bottom - top) / 2);
117
 
    R_move_abs((left + right) / 2, top);
118
 
    R_cont_rel((right - left) / 2, (bottom - top) / 2);
119
 
 
120
 
    return 0;
121
 
}
122
 
 
123
 
int Downarrow(int top, int bottom, int left, int right)
124
 
{
125
 
    R_move_abs((left + right) / 2, top);
126
 
    R_cont_abs((left + right) / 2, bottom);
127
 
    R_cont_rel((left - right) / 2, (top - bottom) / 2);
128
 
    R_move_abs((left + right) / 2, bottom);
129
 
    R_cont_rel((right - left) / 2, (top - bottom) / 2);
130
 
 
131
 
    return 0;
132
 
}