GRASS GIS 8 Programmer's Manual  8.2.2dev(2023)-3d2c704037
display/setup.c
Go to the documentation of this file.
1 /*!
2  \file lib/display/setup.c
3 
4  \brief Display Driver - setup
5 
6  (C) 2006-2011 by the GRASS Development Team
7 
8  This program is free software under the GNU General Public License
9  (>=v2). Read the file COPYING that comes with GRASS for details.
10 
11  \author Glynn Clements <glynn gclements.plus.com> (original contributor)
12  \author Huidae Cho <grass4u gmail.com>
13 */
14 
15 #include <string.h>
16 #include <grass/gis.h>
17 #include <grass/raster.h>
18 #include <grass/display.h>
19 
20 #include "driver.h"
21 
22 /*!
23  \brief Graphics frame setup
24 
25  This is a high level D call. It does a full setup for the current
26  graphics frame.
27 
28  Note: Connection to driver must already be made.
29 
30  Sets the source coordinate system to the current region, and
31  adjusts the destination coordinate system to preserve the aspect
32  ratio.
33 
34  Performs a full setup for the current graphics frame:
35  - Makes sure there is a current graphics frame (will create a full-screen
36  one, if not);
37  - Sets the region coordinates so that the graphics frame and the active
38  module region agree (may change active module region to do this); and
39  - Performs graphic frame/region coordinate conversion initialization.
40 
41  If <b>clear</b> is true, the frame is cleared (same as running
42  <i>d.erase</i>.) Otherwise, it is not cleared.
43 
44  \param clear 1 to clear frame (visually and coordinates)
45 */
46 void D_setup(int clear)
47 {
48  struct Cell_head region;
49  double dt, db, dl, dr;
50 
51  D_get_frame(&dt, &db, &dl, &dr);
52 
53  G_get_set_window(&region);
54  Rast_set_window(&region);
55 
56  D_do_conversions(&region, dt, db, dl, dr);
57 
59 
60  if (clear)
62 
64 }
65 
66 /*!
67  \brief Graphics frame setup
68 
69  Sets the source coordinate system to match the
70  destination coordinate system, so that D_* functions use the same
71  coordinate system as R_* functions.
72 
73  If <b>clear</b> is true, the frame is cleared (same as running
74  <i>d.erase</i>). Otherwise, it is not cleared.
75 
76  \param clear non-zero code to clear the frame
77 */
78 void D_setup_unity(int clear)
79 {
80  double dt, db, dl, dr;
81 
82  D_get_frame(&dt, &db, &dl, &dr);
83 
84  D_set_src(dt, db, dl, dr);
85  D_set_dst(dt, db, dl, dr);
86 
88 
90 
91  if (clear)
93 
95 }
96 
97 /*!
98  \brief Sets source coordinate system
99 
100  Sets the source coordinate system to its arguments, and if
101  the <b>fit</b> argument is non-zero, adjusts the destination coordinate
102  system to preserve the aspect ratio.
103 
104  If <b>clear</b> is true, the frame is cleared (same as running
105  <i>d.erase</i>). Otherwise, it is not cleared.
106 
107  \param clear non-zero code to clear the frame
108  \param fit non-zero code to adjust destination coordinate system
109  \param s_top
110  \param s_bottom
111  \param s_left
112  \param s_right
113 */
114 void D_setup2(int clear, int fit, double st, double sb, double sl, double sr)
115 {
116  double dt, db, dl, dr;
117 
118  D_get_frame(&dt, &db, &dl, &dr);
119 
120  D_set_src(st, sb, sl, sr);
121  D_set_dst(dt, db, dl, dr);
122 
123  if (fit)
124  D_fit_d_to_u();
125 
127 
129 
130  if (clear)
132 
134 }
135 
136 /*!
137  \brief Get driver output file
138 
139  \return file name or NULL if not defined
140 */
141 const char *D_get_file(void)
142 {
143  return COM_Graph_get_file();
144 }
void D_fit_d_to_u(void)
Definition: cnversions.c:100
2D/3D raster map header (used also for region)
Definition: gis.h:423
const char * COM_Graph_get_file(void)
Definition: driver/graph.c:18
#define DEFAULT_BG_COLOR
Definition: gis.h:382
void D_get_frame(double *, double *, double *, double *)
get graphical window (frame)
Definition: r_raster.c:322
void Rast_set_window(struct Cell_head *)
Establishes &#39;window&#39; as the current working window.
const char * D_get_file(void)
Get driver output file.
void D_update_conversions(void)
Definition: cnversions.c:93
void D_set_clip_window_to_screen_window(void)
set clipping window to screen window
Definition: r_raster.c:377
struct state * st
Definition: parser.c:104
void D_setup(int clear)
Graphics frame setup.
Definition: display/setup.c:46
void G_get_set_window(struct Cell_head *)
Get the current working window (region)
void D_erase(const char *)
void D_setup_unity(int clear)
Graphics frame setup.
Definition: display/setup.c:78
void D_set_clip_window_to_map_window(void)
set graphical clipping window to map window
Definition: r_raster.c:360
void D_setup2(int clear, int fit, double st, double sb, double sl, double sr)
Sets source coordinate system.
void D_set_src(double, double, double, double)
Definition: cnversions.c:205
void D_do_conversions(const struct Cell_head *, double, double, double, double)
initialize conversions
Definition: cnversions.c:152
void D_set_dst(double, double, double, double)
Definition: cnversions.c:251