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

checks: Clang-Format, part 2 #2710

Merged
merged 3 commits into from
Dec 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
179 changes: 72 additions & 107 deletions display/d.barscale/draw_scale.c

Large diffs are not rendered by default.

67 changes: 28 additions & 39 deletions display/d.barscale/main.c
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@

/****************************************************************************
*
* MODULE: d.barscale
*
* AUTHOR(S): unknown but from CERL code (original contributor)
* Markus Neteler <neteler itc.it>,
* Bernhard Reiter <bernhard intevation.de>,
* Cedric Shock <cedricgrass shockfamily.net>,
* Huidae Cho <grass4u gmail.com>,
* Eric G. Miller <egm2 jps.net>,
* Glynn Clements <glynn gclements.plus.com>,
* Hamish Bowman <hamish_b yahoo.com>,
* Markus Neteler <neteler itc.it>,
* Bernhard Reiter <bernhard intevation.de>,
* Cedric Shock <cedricgrass shockfamily.net>,
* Huidae Cho <grass4u gmail.com>,
* Eric G. Miller <egm2 jps.net>,
* Glynn Clements <glynn gclements.plus.com>,
* Hamish Bowman <hamish_b yahoo.com>,
* Jan-Oliver Wagner <jan intevation.de>
* Major rewrite for GRASS 7 by Hamish Bowman, June 2013
* Adam Laza <ad.laza32@gmail.com>, GSoC 2016
Expand Down Expand Up @@ -82,43 +81,37 @@ int main(int argc, char **argv)
barstyle->key = "style";
barstyle->description = _("Type of barscale to draw");
barstyle->options =
"classic,line,solid,hollow,full_checker,part_checker,mixed_checker,tail_checker,up_ticks,down_ticks,both_ticks,arrow_ends";
"classic,line,solid,hollow,full_checker,part_checker,mixed_checker,"
"tail_checker,up_ticks,down_ticks,both_ticks,arrow_ends";
barstyle->answer = "classic";
barstyle->gisprompt = "old,barscale,barscale";
barstyle->guisection = _("Style");
G_asprintf((char **)&(barstyle->descriptions),
"classic;%s;"
"line;%s;"
"solid;%s;"
"hollow;%s;"
"full_checker;%s;"
"part_checker;%s;"
"mixed_checker;%s;"
"tail_checker;%s;"
"up_ticks;%s;"
"down_ticks;%s;"
"both_ticks;%s;"
"arrow_ends;%s",
_("Classic style"),
_("Line style"),
_("Solid style"),
_("Hollow style"),
_("Full checker style"),
_("Part checker style"),
_("Mixed checker style"),
_("Tail checker style"),
_("Up ticks style"),
_("Down ticks style"),
_("Both ticks style"), _("Arrow ends style"));
G_asprintf(
(char **)&(barstyle->descriptions),
"classic;%s;"
"line;%s;"
"solid;%s;"
"hollow;%s;"
"full_checker;%s;"
"part_checker;%s;"
"mixed_checker;%s;"
"tail_checker;%s;"
"up_ticks;%s;"
"down_ticks;%s;"
"both_ticks;%s;"
"arrow_ends;%s",
_("Classic style"), _("Line style"), _("Solid style"),
_("Hollow style"), _("Full checker style"), _("Part checker style"),
_("Mixed checker style"), _("Tail checker style"), _("Up ticks style"),
_("Down ticks style"), _("Both ticks style"), _("Arrow ends style"));

coords = G_define_option();
coords->key = "at";
coords->key_desc = "x,y";
coords->type = TYPE_DOUBLE;
coords->answer = "0.0,10.0";
coords->options = "0-100";
coords->label =
_("Screen coordinates of the rectangle's top-left corner");
coords->label = _("Screen coordinates of the rectangle's top-left corner");
coords->description = _("(0,0) is lower-left of the display frame");

length_opt = G_define_option();
Expand Down Expand Up @@ -209,13 +202,11 @@ int main(int argc, char **argv)
if (G_parser(argc, argv))
exit(EXIT_FAILURE);


G_get_window(&W);
if (W.proj == PROJECTION_LL)
G_fatal_error(_("%s does not work with a latitude-longitude location"),
argv[0]);


north_arrow = n_symbol->answer ? TRUE : FALSE;

switch (barstyle->answer[0]) {
Expand Down Expand Up @@ -279,7 +270,6 @@ int main(int argc, char **argv)
sscanf(coords->answers[0], "%lf", &east);
sscanf(coords->answers[1], "%lf", &north);


length = atof(length_opt->answer);
sscanf(segm_opt->answer, "%d", &segm);

Expand Down Expand Up @@ -336,7 +326,6 @@ int main(int argc, char **argv)
if (bg_color == 0)
do_background = FALSE;


D_open_driver();

if (font->answer)
Expand Down
12 changes: 5 additions & 7 deletions display/d.barscale/options.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/* barscale types */
#define STYLE_NONE 0
#define STYLE_CLASSIC_BAR 1
Expand All @@ -15,10 +14,10 @@
#define STYLE_ARROW_ENDS 12

/* text placement */
#define TEXT_UNDER 0
#define TEXT_OVER 1
#define TEXT_LEFT 2
#define TEXT_RIGHT 3
#define TEXT_UNDER 0
#define TEXT_OVER 1
#define TEXT_LEFT 2
#define TEXT_RIGHT 3

/* globals */
extern int fg_color;
Expand All @@ -28,5 +27,4 @@ extern int do_background;
extern int north_arrow;

/* draw_scale.c */
int draw_scale(double, double, int, int, int, char *, int, int, double,
double);
int draw_scale(double, double, int, int, int, char *, int, int, double, double);
8 changes: 3 additions & 5 deletions display/d.colorlist/main.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
/*
****************************************************************************
/*****************************************************************************
*
* MODULE: d.colorlist
* AUTHOR(S): Andreas Lange - andreas.lange@rhein-main.de
* PURPOSE: Output a list of all available colors with a configurable
* separator (default is comma).
* separator (default is comma).
* Used for scripting and tcl/tk-scripts to
* build a list of available options.
* COPYRIGHT: (C) 2000 by the GRASS Development Team
Expand Down Expand Up @@ -35,8 +34,7 @@ int main(int argc, char **argv)
G_add_keyword(_("display"));
G_add_keyword(_("settings"));
G_add_keyword(_("colors"));
module->description =
_("Outputs a list of all available display colors.");
module->description = _("Outputs a list of all available display colors.");

/* set up option */
sep = G_define_standard_option(G_OPT_F_SEP);
Expand Down
27 changes: 11 additions & 16 deletions display/d.colortable/main.c
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@

/****************************************************************************
*
* MODULE: d.colortable
* AUTHOR(S): James Westervelt, CERL (original contributor)
* Markus Neteler <neteler itc.it>,
* Bernhard Reiter <bernhard intevation.de>,
* Eric G. Miller <egm2 jps.net>,
* Glynn Clements <glynn gclements.plus.com>,
* Hamish Bowman <hamish_b yahoo.com>,
* Bernhard Reiter <bernhard intevation.de>,
* Eric G. Miller <egm2 jps.net>,
* Glynn Clements <glynn gclements.plus.com>,
* Hamish Bowman <hamish_b yahoo.com>,
* Jan-Oliver Wagner <jan intevation.de>
* PURPOSE: display the color table associated with a raster map layer in
* the active frame on the graphics monitor
Expand All @@ -19,7 +18,6 @@
*
*****************************************************************************/


#include <stdlib.h>
#include <math.h>
#include <grass/display.h>
Expand Down Expand Up @@ -69,8 +67,7 @@ int main(int argc, char **argv)

opt2 = G_define_standard_option(G_OPT_C);
opt2->answer = DEFAULT_BG_COLOR;
opt2->label =
_("Color of lines separating the colors of the color table");
opt2->label = _("Color of lines separating the colors of the color table");

opt3 = G_define_option();
opt3->key = "lines";
Expand All @@ -93,7 +90,6 @@ int main(int argc, char **argv)
if (G_parser(argc, argv))
exit(EXIT_FAILURE);


map_name = opt1->answer;
fp = Rast_map_is_fp(map_name, "");

Expand Down Expand Up @@ -212,7 +208,7 @@ int main(int argc, char **argv)
D_end();
D_stroke();
/* Color box */
D_color((CELL) atcat, &colors);
D_color((CELL)atcat, &colors);
D_pos_abs(cur_dot_col + 4, (cur_dot_row - 3));
D_polygon_rel(x_box, y_box, 5);

Expand All @@ -225,8 +221,8 @@ int main(int argc, char **argv)
}
if (atcat > (int)dmax)
break;
} /* col loop */
} /* int map */
} /* col loop */
} /* int map */

else {

Expand Down Expand Up @@ -263,8 +259,8 @@ int main(int argc, char **argv)
x_box[2] = (dots_per_col - 6);
x_box[4] = (6 - dots_per_col);

G_debug(1, "dots_per_line: %d dmin=%.2f dmax=%.2f",
dots_per_line, dmin, dmax);
G_debug(1, "dots_per_line: %d dmin=%.2f dmax=%.2f", dots_per_line,
dmin, dmax);

if (skip_null->answer)
offset = 1;
Expand All @@ -275,8 +271,7 @@ int main(int argc, char **argv)
if ((r <= 4) && !skip_null->answer)
Rast_set_d_null_value(&dval, 1);
else
dval =
dmin + r * (dmax - dmin) / (dots_per_line - 6 - offset);
dval = dmin + r * (dmax - dmin) / (dots_per_line - 6 - offset);

D_d_color(dval, &colors);
D_pos_abs(cur_dot_col + 3, (cur_dot_row - 3) - r);
Expand Down
7 changes: 3 additions & 4 deletions display/d.erase/main.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/*
****************************************************************************
/*****************************************************************************
*
* MODULE: d.erase
* AUTHOR(S): James Westervelt - USA CERL
Expand Down Expand Up @@ -29,8 +28,8 @@ int main(int argc, char *argv[])
G_add_keyword(_("display"));
G_add_keyword(_("graphics"));
G_add_keyword(_("monitors"));
module->description =
_("Erases the contents of the active graphics display frame with user defined color.");
module->description = _("Erases the contents of the active graphics "
"display frame with user defined color.");

color = G_define_standard_option(G_OPT_C);
color->key = "bgcolor";
Expand Down
15 changes: 8 additions & 7 deletions display/d.extract/extract.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <grass/vector.h>
#include <grass/glocale.h>

#define WDTH 5
#define WDTH 5

#define M_START 1
#define M_ADD 2
Expand Down Expand Up @@ -42,7 +42,8 @@ int extract(struct Map_info *In, struct Map_info *Out, int type,
mode = M_START;
G_message(_("Select vector(s) with mouse"));
G_message(_(" - L: draw box with left mouse button to select"));
G_message(_(" - M: draw box with middle mouse button to remove from display"));
G_message(
_(" - M: draw box with middle mouse button to remove from display"));
G_message(_(" - R: quit and save selected vectors to new map\n"));
while (1) {
G_message(_("L: add M: remove R: quit and save\n"));
Expand Down Expand Up @@ -80,7 +81,8 @@ int extract(struct Map_info *In, struct Map_info *Out, int type,
box.W);
}

/* TODO: check if line really intersects box, not only box intersects box */
/* TODO: check if line really intersects box, not only box intersects
* box */
switch (button) {
case 1:
if (mode == M_START) {
Expand Down Expand Up @@ -123,15 +125,14 @@ int extract(struct Map_info *In, struct Map_info *Out, int type,
return 1;
}

int
display(struct Map_info *Map, struct boxlist *List,
const struct color_rgb *color)
int display(struct Map_info *Map, struct boxlist *List,
const struct color_rgb *color)
{
int i, j, line, type;
struct line_pnts *Points;
double msize;

msize = 10 * (D_d_to_u_col(2) - D_d_to_u_col(1)); /* do it better */
msize = 10 * (D_d_to_u_col(2) - D_d_to_u_col(1)); /* do it better */
G_debug(1, "msize = %f\n", msize);

Points = Vect_new_line_struct();
Expand Down
29 changes: 13 additions & 16 deletions display/d.extract/main.c
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@

/****************************************************************
*
* MODULE: d.extract
*
*
* AUTHOR(S): Radim Blazek, Markus Neteler
*
*
* PURPOSE: A graphical vector extractor
*
*
* COPYRIGHT: (C) 2002 by the GRASS Development Team
*
* This program is free software under the
* GNU General Public License (>=v2).
* This program is free software under the
* GNU General Public License (>=v2).
* Read the file COPYING that comes with GRASS
* for details.
*
Expand All @@ -25,8 +24,8 @@
#include <grass/dbmi.h>
#include <grass/glocale.h>

int extract(struct Map_info *, struct Map_info *, int,
const struct color_rgb *, const struct color_rgb *);
int extract(struct Map_info *, struct Map_info *, int, const struct color_rgb *,
const struct color_rgb *);

int main(int argc, char **argv)
{
Expand All @@ -41,7 +40,6 @@ int main(int argc, char **argv)
struct field_info *Fi, *Fin;
int i, n, tbtype, ret;


/* Initialize the GIS calls */
G_gisinit(argv[0]);

Expand Down Expand Up @@ -131,20 +129,19 @@ int main(int argc, char **argv)
continue;
}
Fin = Vect_default_field_info(&Out, Fi->number, Fi->name, tbtype);
G_debug(3, "Copy drv:db:table '%s:%s:%s' to '%s:%s:%s'",
Fi->driver, Fi->database, Fi->table, Fin->driver,
Fin->database, Fin->table);
G_debug(3, "Copy drv:db:table '%s:%s:%s' to '%s:%s:%s'", Fi->driver,
Fi->database, Fi->table, Fin->driver, Fin->database,
Fin->table);
Vect_map_add_dblink(&Out, Fi->number, Fi->name, Fin->table, Fi->key,
Fin->database, Fin->driver);

ret = db_copy_table(Fi->driver, Fi->database, Fi->table,
Fin->driver, Vect_subst_var(Fin->database, &Out),
Fin->table);
ret = db_copy_table(Fi->driver, Fi->database, Fi->table, Fin->driver,
Vect_subst_var(Fin->database, &Out), Fin->table);
if (ret == DB_FAILED) {
G_warning("Unable to copy table");
continue;
}
} /* for of copy table */
} /* for of copy table */

Vect_build(&Out, stdout);
Vect_close(&In);
Expand Down
Loading