GRASS 8 Programmer's Manual 8.6.0dev(2026)-1878fdfec5
Loading...
Searching...
No Matches
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 SPDX-FileCopyrightText: 2006-2011 GRASS Development Team
7 SPDX-License-Identifier: GPL-2.0-or-later
8
9 \author Glynn Clements <glynn gclements.plus.com> (original contributor)
10 \author Huidae Cho <grass4u gmail.com>
11*/
12
13#include <string.h>
14#include <grass/gis.h>
15#include <grass/raster.h>
16#include <grass/display.h>
17
18#include "driver.h"
19
20/*!
21 \brief Graphics frame setup
22
23 This is a high level D call. It does a full setup for the current
24 graphics frame.
25
26 Note: Connection to driver must already be made.
27
28 Sets the source coordinate system to the current region, and
29 adjusts the destination coordinate system to preserve the aspect
30 ratio.
31
32 Performs a full setup for the current graphics frame:
33 - Makes sure there is a current graphics frame (will create a full-screen
34 one, if not);
35 - Sets the region coordinates so that the graphics frame and the active
36 module region agree (may change active module region to do this); and
37 - Performs graphic frame/region coordinate conversion initialization.
38
39 If <b>clear</b> is true, the frame is cleared (same as running
40 <i>d.erase</i>.) Otherwise, it is not cleared.
41
42 \param clear 1 to clear frame (visually and coordinates)
43*/
44void D_setup(int clear)
45{
46 struct Cell_head region;
47 double dt, db, dl, dr;
48
49 D_get_frame(&dt, &db, &dl, &dr);
50
51 G_get_set_window(&region);
52 Rast_set_window(&region);
53
54 D_do_conversions(&region, dt, db, dl, dr);
55
57
58 if (clear)
60
62}
63
64/*!
65 \brief Graphics frame setup
66
67 Sets the source coordinate system to match the
68 destination coordinate system, so that D_* functions use the same
69 coordinate system as R_* functions.
70
71 If <b>clear</b> is true, the frame is cleared (same as running
72 <i>d.erase</i>). Otherwise, it is not cleared.
73
74 \param clear non-zero code to clear the frame
75*/
76void D_setup_unity(int clear)
77{
78 double dt, db, dl, dr;
79
80 D_get_frame(&dt, &db, &dl, &dr);
81
82 D_set_src(dt, db, dl, dr);
83 D_set_dst(dt, db, dl, dr);
84
86
88
89 if (clear)
91
93}
94
95/*!
96 \brief Sets source coordinate system
97
98 Sets the source coordinate system to its arguments, and if
99 the <b>fit</b> argument is non-zero, adjusts the destination coordinate
100 system to preserve the aspect ratio.
101
102 If <b>clear</b> is true, the frame is cleared (same as running
103 <i>d.erase</i>). Otherwise, it is not cleared.
104
105 \param clear non-zero code to clear the frame
106 \param fit non-zero code to adjust destination coordinate system
107 \param st top
108 \param sb bottom
109 \param sl left
110 \param sr right
111*/
112void D_setup2(int clear, int fit, double st, double sb, double sl, double sr)
113{
114 double dt, db, dl, dr;
115
116 D_get_frame(&dt, &db, &dl, &dr);
117
118 D_set_src(st, sb, sl, sr);
119 D_set_dst(dt, db, dl, dr);
120
121 if (fit)
122 D_fit_d_to_u();
123
125
127
128 if (clear)
130
132}
133
134/*!
135 \brief Get driver output file
136
137 \return file name or NULL if not defined
138*/
139const char *D_get_file(void)
140{
141 return COM_Graph_get_file();
142}
void D_set_dst(double, double, double, double)
Definition cnversions.c:322
void D_set_clip_window_to_screen_window(void)
set clipping window to screen window
Definition r_raster.c:371
void D_set_clip_window_to_map_window(void)
set graphical clipping window to map window
Definition r_raster.c:356
void D_fit_d_to_u(void)
Definition cnversions.c:97
void D_erase(const char *)
void D_update_conversions(void)
Definition cnversions.c:90
void D_do_conversions(const struct Cell_head *, double, double, double, double)
initialize conversions
Definition cnversions.c:143
void D_set_src(double, double, double, double)
Definition cnversions.c:276
void D_get_frame(double *, double *, double *, double *)
get graphical window (frame)
Definition r_raster.c:320
void G_get_set_window(struct Cell_head *)
Get the current working window (region)
void Rast_set_window(struct Cell_head *)
Establishes 'window' as the current working window.
const char * D_get_file(void)
Get driver output file.
void D_setup2(int clear, int fit, double st, double sb, double sl, double sr)
Sets source coordinate system.
void D_setup_unity(int clear)
Graphics frame setup.
void D_setup(int clear)
Graphics frame setup.
const char * COM_Graph_get_file(void)
#define DEFAULT_BG_COLOR
Definition gis.h:403
struct state * st
Definition parser.c:102
2D/3D raster map header (used also for region)
Definition gis.h:443