Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

d.redraw: Rewritten in C #3484

Closed
wants to merge 38 commits into from
Closed
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
c1cb89e
libdisplay: D_open_driver exits if GRASS_REGION is not defined from t…
HuidaeCho Mar 10, 2024
0e89ced
init() only once
HuidaeCho Mar 10, 2024
1a2c2d8
Remove d.redraw from render_cmd.py
HuidaeCho Mar 10, 2024
0d59f3a
Remove lines conflicting with #3482
HuidaeCho Mar 10, 2024
db5cc97
G_spawn() => G_vspawn_ex() in comment
HuidaeCho Mar 10, 2024
d1ecfc6
Add d.redraw to display Makefile
HuidaeCho Mar 10, 2024
44673e6
Remove d.redraw from scripts Makefile
HuidaeCho Mar 10, 2024
5a7ef2a
Comment about removed line for d.redraw
HuidaeCho Mar 10, 2024
ed8aeda
Use -1 return from D_open_driver() to exit
HuidaeCho Mar 11, 2024
5527fe7
putenv all GRASS_RENDER_ env vars
HuidaeCho Mar 11, 2024
7fe50b8
Count comment lines properly
HuidaeCho Mar 12, 2024
9e21f34
Merge branch 'main' into new_d_redraw_in_c
echoix Mar 13, 2024
57627d7
Run clang-format
HuidaeCho Mar 13, 2024
87924f0
Revert to current D_open_driver()
HuidaeCho Mar 14, 2024
e7b78d0
Merge remote-tracking branch 'upstream/main' into new_d_redraw_in_c
neteler May 1, 2024
65c890f
version: Replace references to 8.2 (#2969)
wenzeslaus May 1, 2024
3f75119
CI(deps): Update actions/checkout action to v4.1.4 (#3667)
renovate[bot] May 1, 2024
5dc55ba
CI(deps): Update github/codeql-action action to v3.25.3 (#3671)
renovate[bot] May 2, 2024
2f7bc61
config.guess + config.sub: updated from http://git.savannah.gnu.org/c…
github-actions[bot] May 2, 2024
3299601
wxGUI/nviz: fix showing scrollbars on the Data, Appearance, Analysis …
tmszi May 2, 2024
21ef8d0
r.in.wms: fix get region extent for WMS query, if location is 'XY loc…
tmszi May 2, 2024
a15785e
wxGUI/preferences: allow the user save/load single-window mode panes …
tmszi May 2, 2024
2638867
CI(deps): Update ubuntu:22.04 Docker digest to a6d2b38 (#3669)
renovate[bot] May 2, 2024
73b03de
CI: Use faster mold linker to reduce build time by ≈>30 sec (#3681)
echoix May 2, 2024
b2a0f3a
wxGUI/history: Add time period branching to history browser tree (#3622)
lindakarlovska May 2, 2024
7fc980d
Checks: Fix Flake8 E501 (#3541)
mshukuno May 3, 2024
0efcbad
libvector/diglib: fix memory leaks (#3617)
nilason May 3, 2024
f5846f6
grass.script: Fix missing passing of env parameter (#3684)
wenzeslaus May 3, 2024
7789cf3
wxGUI/dbmgr: fix enclosing column name with SQL standard double quote…
tmszi May 4, 2024
2a099d9
g.message: Do not require full gisinit (#3686)
wenzeslaus May 4, 2024
80f9d4f
CI(deps): Update docker/dockerfile:1.7 Docker digest to a57df69 (#3668)
renovate[bot] May 4, 2024
f345b1e
grass.script: Always use full env in create_project (#3685)
wenzeslaus May 4, 2024
cb2efad
grass.script: Get GISBASE automatically in get_commands (#3683)
wenzeslaus May 6, 2024
0ce8a07
CI: Update msys2/setup-msys2 action to v2.23.0 (#3690)
renovate[bot] May 7, 2024
ba00e43
grass.script: Automatically parse JSON and CSV in parse_command (#3687)
petrasovaa May 8, 2024
e635c59
CI(deps): Update github/codeql-action action to v3.25.4 (#3692)
renovate[bot] May 8, 2024
61bf2ae
CI(deps): Update softprops/action-gh-release action to v2.0.5 (#3691)
renovate[bot] May 8, 2024
95e9be6
Add back d.redraw because #3500 deletes it
HuidaeCho May 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions display/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ SUBDIRS = \
d.rast \
d.rast.arrow \
d.rast.num \
d.redraw \
d.rgb \
d.rhumbline \
d.text \
Expand Down
1 change: 0 additions & 1 deletion display/d.mon/render_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ def update_cmd_file(cmd_file, cmd, mapfile):
"d.info",
"d.mon",
"d.out.file",
"d.redraw",
"d.to.rast",
"d.what.rast",
"d.what.vect",
Expand Down
11 changes: 11 additions & 0 deletions display/d.redraw/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

MODULE_TOPDIR = ../..

PGM = d.redraw

LIBES = $(DISPLAYLIB) $(GISLIB)
DEPENDENCIES = $(DISPLAYDEP) $(GISDEP)

include $(MODULE_TOPDIR)/include/Make/Module.make

default: cmd
18 changes: 18 additions & 0 deletions display/d.redraw/d.redraw.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<h2>DESCRIPTION</h2>

<em>d.redraw</em> redraws the content of the currently selected monitor. The
active monitor can be selected with <em>d.mon</em>.

<h2>SEE ALSO</h2>

<em>
<a href="d.erase.html">d.erase</a>,
<a href="d.rast.html">d.rast</a>,
<a href="d.vect.html">d.vect</a>,
<a href="d.mon.html">d.mon</a>
</em>

<h2>AUTHOR</h2>

Huidae Cho, New Mexico State University<br>
Based on the <em>d.redraw</em> script by Martin Landa, Czech Republic
116 changes: 116 additions & 0 deletions display/d.redraw/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
/****************************************************************************
*
* MODULE: d.redraw
* AUTHOR(S): Huidae Cho <grass4u gmail.com>
* Based on scripts/d.redraw/d.redraw.py by Martin Landa
* PURPOSE: Redraws the content of currently selected monitor
* COPYRIGHT: (C) 2024 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.
*
*****************************************************************************/

#include <stdlib.h>
#include <string.h>
#include <grass/gis.h>
#include <grass/spawn.h>
#include <grass/display.h>
#include <grass/glocale.h>

#define LINES_SIZE_INC 1024
#define LINE_LEN 1024

int main(int argc, char **argv)
{
struct GModule *module;
const char *mon;
char element[GPATH_MAX], cmd_file[GPATH_MAX];
FILE *fp;
int lines_size, num_lines, num_comment_lines;
char **lines, line[LINE_LEN];
char **cmd_argv;
int i;

G_gisinit(argv[0]);

module = G_define_module();
G_add_keyword(_("display"));
G_add_keyword(_("graphics"));
G_add_keyword(_("monitors"));
module->description =
_("Redraws the content of currently selected monitor.");

if (G_parser(argc, argv))
exit(EXIT_FAILURE);

if (!(mon = G_getenv_nofatal("MONITOR")))
G_fatal_error(_("No graphics device selected. Use d.mon to select "
"graphics device."));

if (D_open_driver() < 0) {
/* first time it runs, add d.redraw to cmd file and exit; this module
* will be rerun by the monitor with the display extent (D_open_driver()
* will return 0 then) and use that information to constrain rendering
*/
D_close_driver();
exit(EXIT_SUCCESS);
}

D_close_driver();

G_temp_element(element);
strcat(element, "/MONITORS/");
strcat(element, mon);
G_file_name(cmd_file, element, "cmd", G_mapset());

if (!(fp = fopen(cmd_file, "r")))
G_fatal_error(_("Unable to open file '%s' for reading."), cmd_file);

lines_size = num_lines = num_comment_lines = 0;
lines = NULL;

/* read and save cmd lines; run display commands now */
while (G_getl2(line, LINE_LEN, fp)) {
/* don't add d.redraw this time */
if (strcmp(line, "d.redraw") == 0) {
/* remove its comment lines above */
num_lines -= num_comment_lines;
continue;
}
if (lines_size == num_lines) {
lines_size += LINES_SIZE_INC;
lines = G_realloc(lines, sizeof(char *) * lines_size);
}
lines[num_lines++] = G_store(line);

if (*line == '#') {
num_comment_lines++;
HuidaeCho marked this conversation as resolved.
Show resolved Hide resolved
/* render next command into the same existing file */
if (strstr(line, "# GRASS_RENDER_") == line)
putenv(G_store(line + 2));
continue;
}
num_comment_lines = 0;
HuidaeCho marked this conversation as resolved.
Show resolved Hide resolved

/* split line by space; double-quote delimiters protect spaces */
cmd_argv = G_tokenize2(line, " ", "\"");
/* run display command */
G_vspawn_ex(cmd_argv[0], (const char **)cmd_argv);
G_free_tokens(cmd_argv);
}

fclose(fp);

/* write out cmd file without d.redraw */
if (!(fp = fopen(cmd_file, "w")))
G_fatal_error(_("Unable to open file '%s' for writing."), cmd_file);

for (i = 0; i < num_lines; i++)
fprintf(fp, "%s\n", lines[i]);

fclose(fp);

exit(EXIT_SUCCESS);
}
1 change: 0 additions & 1 deletion scripts/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ SUBDIRS = \
d.polar \
d.rast.edit \
d.rast.leg \
d.redraw \
d.shade \
d.what.rast \
d.what.vect \
Expand Down
7 changes: 0 additions & 7 deletions scripts/d.redraw/Makefile

This file was deleted.

19 changes: 0 additions & 19 deletions scripts/d.redraw/d.redraw.html

This file was deleted.

72 changes: 0 additions & 72 deletions scripts/d.redraw/d.redraw.py

This file was deleted.

Loading