File: setup.c

package info (click to toggle)
grass 8.4.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 277,040 kB
  • sloc: ansic: 460,798; python: 227,732; cpp: 42,026; sh: 11,262; makefile: 7,007; xml: 3,637; sql: 968; lex: 520; javascript: 484; yacc: 450; asm: 387; perl: 157; sed: 25; objc: 6; ruby: 4
file content (144 lines) | stat: -rw-r--r-- 3,475 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/*!
  \file lib/display/setup.c

  \brief Display Driver - setup

  (C) 2006-2011 by the GRASS Development Team

  This program is free software under the GNU General Public License
  (>=v2). Read the file COPYING that comes with GRASS for details.

  \author Glynn Clements <glynn gclements.plus.com> (original contributor)
  \author Huidae Cho <grass4u gmail.com>
*/

#include <string.h>
#include <grass/gis.h>
#include <grass/raster.h>
#include <grass/display.h>

#include "driver.h"

/*!
  \brief Graphics frame setup

  This is a high level D call. It does a full setup for the current
  graphics frame.

  Note: Connection to driver must already be made.

  Sets the source coordinate system to the current region, and
  adjusts the destination coordinate system to preserve the aspect
  ratio.

  Performs a full setup for the current graphics frame:
  - Makes sure there is a current graphics frame (will create a full-screen
  one, if not);
  - Sets the region coordinates so that the graphics frame and the active
  module region agree (may change active module region to do this); and
  - Performs graphic frame/region coordinate conversion initialization.

  If <b>clear</b> is true, the frame is cleared (same as running
  <i>d.erase</i>.) Otherwise, it is not cleared.

  \param clear 1 to clear frame (visually and coordinates)
*/
void D_setup(int clear)
{
    struct Cell_head region;
    double dt, db, dl, dr;

    D_get_frame(&dt, &db, &dl, &dr);

    G_get_set_window(&region);
    Rast_set_window(&region);

    D_do_conversions(&region, dt, db, dl, dr);

    D_set_clip_window_to_screen_window();

    if (clear)
        D_erase(DEFAULT_BG_COLOR);

    D_set_clip_window_to_map_window();
}

/*!
  \brief Graphics frame setup

  Sets the source coordinate system to match the
  destination coordinate system, so that D_* functions use the same
  coordinate system as R_* functions.

  If <b>clear</b> is true, the frame is cleared (same as running
  <i>d.erase</i>). Otherwise, it is not cleared.

  \param clear non-zero code to clear the frame
*/
void D_setup_unity(int clear)
{
    double dt, db, dl, dr;

    D_get_frame(&dt, &db, &dl, &dr);

    D_set_src(dt, db, dl, dr);
    D_set_dst(dt, db, dl, dr);

    D_update_conversions();

    D_set_clip_window_to_screen_window();

    if (clear)
        D_erase(DEFAULT_BG_COLOR);

    D_set_clip_window_to_map_window();
}

/*!
  \brief Sets source coordinate system

  Sets the source coordinate system to its arguments, and if
  the <b>fit</b> argument is non-zero, adjusts the destination coordinate
  system to preserve the aspect ratio.

  If <b>clear</b> is true, the frame is cleared (same as running
  <i>d.erase</i>). Otherwise, it is not cleared.

  \param clear non-zero code to clear the frame
  \param fit non-zero code to adjust destination coordinate system
  \param s_top
  \param s_bottom
  \param s_left
  \param s_right
*/
void D_setup2(int clear, int fit, double st, double sb, double sl, double sr)
{
    double dt, db, dl, dr;

    D_get_frame(&dt, &db, &dl, &dr);

    D_set_src(st, sb, sl, sr);
    D_set_dst(dt, db, dl, dr);

    if (fit)
        D_fit_d_to_u();

    D_update_conversions();

    D_set_clip_window_to_screen_window();

    if (clear)
        D_erase(DEFAULT_BG_COLOR);

    D_set_clip_window_to_map_window();
}

/*!
  \brief Get driver output file

  \return file name or NULL if not defined
*/
const char *D_get_file(void)
{
    return COM_Graph_get_file();
}