Skip to content

Commit

Permalink
Add inverted triangle to front symbol choices (#5983)
Browse files Browse the repository at this point in the history
* Add inverted triangle to front options

This adds +v for inverted triangle as a new symbol.

* Update front.ps

* Update docs

* Update explain_symbols.rst_
  • Loading branch information
PaulWessel authored Nov 12, 2021
1 parent 3b20567 commit 1d1e7e5
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 14 deletions.
4 changes: 2 additions & 2 deletions doc/rst/source/explain_symbols.rst_
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@
plotted centered or as a half-symbols on one side. Special options exist for indicating
motion (e.g., faults) along a line.

**-Sf**\ [±]\ *gap*\ [/*size*][**+l**\|\ **+r**][**+b**\|\ **+c**\|\ **+f**\|\ **+s**\ [*angle*]\ \|\ **+t**][**+o**\ *offset*][**+p**\ [*pen*]].
**-Sf**\ [±]\ *gap*\ [/*size*][**+l**\|\ **+r**][**+b**\|\ **c**\|\ **f**\|\ **s**\ [*angle*]\ \|\ **t**\ \|\ **v**][**+o**\ *offset*][**+p**\ [*pen*]].
Draw a **f**\ ront. Supply distance *gap* between symbols and symbol *size*.
If *gap* is negative, it is interpreted to mean the *number* of symbols along the
front instead. If *gap* has a leading + then we use the value exactly as given
Expand All @@ -327,7 +327,7 @@
and *size* is thus required. Append **+l** or **+r** to plot symbols on the left or
right side of the front [Default is centered]. Append **+**\ *type* to
specify which symbol to plot: **b**\ ox, **c**\ ircle, **f**\ ault,
**s**\ lip, or **t**\ riangle. [Default is **f**\ ault]. Slip means
**s**\ lip, **t**\ riangle or in\ **v**\ erted triangle. [Default is **f**\ ault]. Slip means
left-lateral or right-lateral strike-slip arrows (centered is not an
option). The **+s** modifier optionally accepts the angle used to draw
the vector [20]. Alternatively, use **+S** which draws arcuate arrow
Expand Down
Binary file modified doc/scripts/GMT_base_symbols7.ps
Binary file not shown.
3 changes: 2 additions & 1 deletion doc/scripts/GMT_base_symbols7.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ gmt psxy -R -J -O -K -W1p -Gred -Sf-1/0.1i+b -X0.6i t.txt >> $ps
gmt psxy -R -J -O -K -W1p -Gred -Sf-1/0.1i+c -X0.6i t.txt >> $ps
gmt psxy -R -J -O -K -W1p -Gred -Sf-1/0.1i+f -X0.6i t.txt >> $ps
gmt psxy -R -J -O -K -W1p -Sf-1/0.4i+S+l -X0.6i t.txt >> $ps
gmt psxy -R -J -O -W1p -Glightorange -Sf-1/0.1i+t -X0.6i t.txt >> $ps
gmt psxy -R -J -O -K -W1p -Glightorange -Sf-1/0.1i+t -X0.6i t.txt >> $ps
gmt psxy -R -J -O -W1p -Glightgreen -Sf-1/0.1i+v -X0.6i t.txt >> $ps
3 changes: 2 additions & 1 deletion src/gmt_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -5761,7 +5761,7 @@ GMT_LOCAL int gmtinit_parse_front (struct GMT_CTRL *GMT, char *text, struct GMT_
char p[GMT_BUFSIZ] = {""}, txt_a[GMT_LEN256] = {""}, txt_b[GMT_LEN256] = {""};

/* text[0] is the leading 'f' for front */
if (text[1] == '+' && !strchr ("bcfilrsStop", text[2])) S->f.f_exact = true, k0 = 2; /* Special leading + to be skipped when looking for modifiers */
if (text[1] == '+' && !strchr ("bcfilrsStopv", text[2])) S->f.f_exact = true, k0 = 2; /* Special leading + to be skipped when looking for modifiers */
for (k = k0; text[k] && text[k] != '+'; k++); /* Either find the first plus or run out or chars */
strncpy (p, text, k); p[k] = 0;
mods = (text[k] == '+');
Expand Down Expand Up @@ -5794,6 +5794,7 @@ GMT_LOCAL int gmtinit_parse_front (struct GMT_CTRL *GMT, char *text, struct GMT_
S->f.f_angle = (p[1]) ? atof (&p[1]) : 40.0; /* Set curved slip arrow angle [40] */
break;
case 't': S->f.f_symbol = GMT_FRONT_TRIANGLE; break; /* Triangle front */
case 'v': S->f.f_symbol = GMT_FRONT_ITRIANGLE; break; /* Inverted triangle front */
case 'o': S->f.f_off = gmt_M_to_inch (GMT, &p[1]); break; /* Symbol offset along line */
case 'p': if (p[1]) { /* Get alternate pen for front-symbol outline [-W] */
if (gmt_getpen (GMT, &p[1], &S->f.pen)) {
Expand Down
37 changes: 36 additions & 1 deletion src/gmt_plot.c
Original file line number Diff line number Diff line change
Expand Up @@ -9845,12 +9845,15 @@ void gmt_geo_rectangle (struct GMT_CTRL *GMT, double lon, double lat, double wid
PSL_plotsymbol (PSL, xp, yp, dim, PSL_ROTRECT);
}

#define M_PI_3 1.047197551196598 /* 60 degrees in radians */

void gmt_draw_front (struct GMT_CTRL *GMT, double x[], double y[], uint64_t n, struct GMT_FRONTLINE *f) {
int ngap, tmp_join = 0, tmp_limit = 0;
bool skip;
uint64_t i;
double *s = NULL, xx[4], yy[4], dist = 0.0, w, frac, dx, dy, angle, dir1, dir2;
double *s = NULL, xx[6], yy[6], dist = 0.0, w, frac, dx, dy, angle, dir1, dir2;
double gap, x0, y0, xp, yp, len2, len3, len4, cosa, sina, sa, ca, offx, offy, dim[PSL_MAX_DIMS];
double a1, a2, sina1, sina2, cosa1, cosa2;
struct PSL_CTRL *PSL= GMT->PSL;

if (n < 2) return;
Expand Down Expand Up @@ -9960,6 +9963,38 @@ void gmt_draw_front (struct GMT_CTRL *GMT, double x[], double y[], uint64_t n, s
}
break;

case GMT_FRONT_ITRIANGLE: /* Inverted triangle */
a1 = angle + M_PI_3; a2 = a1 + M_PI_3;
sincos (a1, &sina1, &cosa1);
sincos (a2, &sina2, &cosa2);
switch (f->f_sense) {
case GMT_FRONT_CENTERED:
xx[0] = x0 + f->f_len * cosa1; /* UR */
yy[0] = y0 + f->f_len * sina1;
xx[1] = x0 + f->f_len * cosa2; /* UL */
yy[1] = y0 + f->f_len * sina2;
xx[2] = x0; yy[2] = y0; /* MC */
xx[3] = x0 - f->f_len * cosa1; /* LR */
yy[3] = y0 - f->f_len * sina1;
xx[4] = x0 - f->f_len * cosa2; /* LL */
yy[4] = y0 - f->f_len * sina2;
xx[5] = x0; yy[5] = y0; /* MC */
PSL_plotpolygon (PSL, xx, yy, 6);
break;
case GMT_FRONT_RIGHT:
sina1 = -sina1; cosa1 = -cosa1; sina2 = -sina2; cosa2 = -cosa2;
/* Intentionally fall through - after changing the angle */
case GMT_FRONT_LEFT:
xx[0] = x0 + f->f_len * cosa1; /* UR */
yy[0] = y0 + f->f_len * sina1;
xx[1] = x0 + f->f_len * cosa2; /* UL */
yy[1] = y0 + f->f_len * sina2;
xx[2] = x0; yy[2] = y0; /* MC */
PSL_plotpolygon (PSL, xx, yy, 3);
break;
}
break;

case GMT_FRONT_CIRCLE: /* Circles */
switch (f->f_sense) {
case GMT_FRONT_CENTERED:
Expand Down
1 change: 1 addition & 0 deletions src/gmt_plot.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
/*! FRONT symbols */

enum GMT_enum_front {GMT_FRONT_FAULT = 0,
GMT_FRONT_ITRIANGLE,
GMT_FRONT_TRIANGLE,
GMT_FRONT_SLIP,
GMT_FRONT_SLIPC,
Expand Down
7 changes: 4 additions & 3 deletions src/psxy.c
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ static int usage (struct GMTAPI_CTRL *API, int level) {
"Append any of the units in %s to the dimensions [Default is k]. "
"For linear projection and -SJ we scale dimensions by the map scale.", GMT_LINE_BULLET, mod_name, GMT_LEN_UNITS_DISPLAY);

GMT_Usage (API, 2, "\n%s Front: -Sf<spacing>[/<ticklen>][+r+l][+f+t+s+c+b][+o<offset>][+p<pen>]", GMT_LINE_BULLET);
GMT_Usage (API, 2, "\n%s Front: -Sf<spacing>[/<ticklen>][+r|l][+f|t|s|c|b|v][+o<offset>][+p<pen>]", GMT_LINE_BULLET);
GMT_Usage (API, -3, "If <spacing> is negative it means the number of gaps instead. "
"If <spacing> has a leading + then <spacing> is used exactly [adjusted to fit line length]. "
"If not given, <ticklen> defaults to 15%% of <spacing>. Append various modifiers:");
Expand All @@ -631,10 +631,11 @@ static int usage (struct GMTAPI_CTRL *API, int level) {
GMT_Usage (API, 3, "+f Plot centered cross-tick or tick only in specified direction [Default].");
GMT_Usage (API, 3, "+s Plot left-or right-lateral strike-slip arrows. Optionally append the arrow angle [20].");
GMT_Usage (API, 3, "+S Same as +s but with curved arrow-heads.");
GMT_Usage (API, 3, "+t diagonal square when centered, directed triangle otherwise.");
GMT_Usage (API, 3, "+t Plot diagonal square when centered, directed triangle otherwise.");
GMT_Usage (API, 3, "+o Plot first symbol when along-front distance is <offset> [0].");
GMT_Usage (API, 3, "+p Append <pen> for front symbol outline; if no <pen> then no outline [Outline with -W pen].");
GMT_Usage (API, -3, "Only one of +b|c|f|i|s|S|t may be selected.");
GMT_Usage (API, 3, "+v Plot two inverted triangles, directed inverted triangle otherwise.");
GMT_Usage (API, -3, "Only one of +b|c|f|i|s|S|t|v may be selected.");

GMT_Usage (API, 2, "\n%s Kustom: -Sk|K<symbolname>[/<size>]", GMT_LINE_BULLET);
GMT_Usage (API, -3, "Append <symbolname> immediately after 'k|K'; this will look for "
Expand Down
Binary file modified test/psxy/front.ps
Binary file not shown.
18 changes: 12 additions & 6 deletions test/psxy/front.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

ps=front.ps

gmt psbasemap -R0/6/0/8 -Jx1i -P -B0 -K -Xc > $ps
gmt psbasemap -R0/7/0/8 -Jx1i -P -B0 -K -X0.5i > $ps
cat << EOF > t.txt
0 0
10 20
Expand All @@ -15,30 +15,36 @@ gmt psxy -R -J -O -K -W1p -Gred -Sf0.4i/0.1i+c -X0.5i t.txt >> $ps
gmt psxy -R -J -O -K -W1p -Gred -Sf0.4i/0.1i+f -X0.5i t.txt >> $ps
gmt psxy -R -J -O -K -W1p -Sf0.6i/0.3i+S+r -X0.5i t.txt >> $ps
gmt psxy -R -J -O -K -W1p -Gred -Sf0.4i/0.1i+t -X0.5i t.txt >> $ps
gmt psxy -R -J -O -K -W1p -Gred -Sf0.4i/0.1i+v -X0.5i t.txt >> $ps
gmt psxy -R -J -O -K -W1p -Gred -Sf-1/0.1i+b -X0.5i t.txt >> $ps
gmt psxy -R -J -O -K -W1p -Gred -Sf-1/0.1i+c -X0.5i t.txt >> $ps
gmt psxy -R -J -O -K -W1p -Gred -Sf-1/0.1i+f -X0.5i t.txt >> $ps
gmt psxy -R -J -O -K -W1p -Sf-1/0.4i+S+l -X0.5i t.txt >> $ps
gmt psxy -R -J -O -K -W1p -Gred -Sf-1/0.1i+t -X0.5i t.txt >> $ps
# Right symbols using fixed interval, then same with just 1 centered symbol
gmt psxy -R -J -O -K -W1p -Gblue -Sf0.4i/0.1i+b+r -X-4.5i -Y2.5i t.txt >> $ps
gmt psxy -R -J -O -K -W1p -Gred -Sf-1/0.1i+v -X0.5i t.txt >> $ps
# Right symbols using fixed interval, then same with just 1 right-side symbol
gmt psxy -R -J -O -K -W1p -Gblue -Sf0.4i/0.1i+b+r -X-5.5i -Y2.5i t.txt >> $ps
gmt psxy -R -J -O -K -W1p -Gblue -Sf0.4i/0.1i+c+r -X0.5i t.txt >> $ps
gmt psxy -R -J -O -K -W1p -Gblue -Sf0.4i/0.1i+f+r -X0.5i t.txt >> $ps
gmt psxy -R -J -O -K -W1p -Gblue -Sf0.6i/0.3i+s+r -X0.5i t.txt >> $ps
gmt psxy -R -J -O -K -W1p -Gblue -Sf0.4i/0.1i+t+r -X0.5i t.txt >> $ps
gmt psxy -R -J -O -K -W1p -Gblue -Sf0.4i/0.1i+v+r -X0.5i t.txt >> $ps
gmt psxy -R -J -O -K -W1p -Gblue -Sf-1/0.1i+b+r -X0.5i t.txt >> $ps
gmt psxy -R -J -O -K -W1p -Gblue -Sf-1/0.1i+c+r -X0.5i t.txt >> $ps
gmt psxy -R -J -O -K -W1p -Gblue -Sf-1/0.1i+f+r -X0.5i t.txt >> $ps
gmt psxy -R -J -O -K -W1p -Gblue -Sf-1/0.4i+s+r -X0.5i t.txt >> $ps
gmt psxy -R -J -O -K -W1p -Gblue -Sf-1/0.1i+t+r -X0.5i t.txt >> $ps
# Left symbols using fixed interval, then same with just 1 centered symbol
gmt psxy -R -J -O -K -W1p -Gyellow -Sf0.4i/0.1i+b+l -X-4.5i -Y2.5i t.txt >> $ps
gmt psxy -R -J -O -K -W1p -Gblue -Sf-1/0.1i+v+r -X0.5i t.txt >> $ps
# Left symbols using fixed interval, then same with just 1 left-side symbol
gmt psxy -R -J -O -K -W1p -Gyellow -Sf0.4i/0.1i+b+l -X-5.5i -Y2.5i t.txt >> $ps
gmt psxy -R -J -O -K -W1p -Gyellow -Sf0.4i/0.1i+c+l -X0.5i t.txt >> $ps
gmt psxy -R -J -O -K -W1p -Gyellow -Sf0.4i/0.1i+f+l -X0.5i t.txt >> $ps
gmt psxy -R -J -O -K -W1p -Gyellow -Sf0.6i/0.3i+s+l -X0.5i t.txt >> $ps
gmt psxy -R -J -O -K -W1p -Gyellow -Sf0.4i/0.1i+t+l -X0.5i t.txt >> $ps
gmt psxy -R -J -O -K -W1p -Gyellow -Sf0.4i/0.1i+v+l -X0.5i t.txt >> $ps
gmt psxy -R -J -O -K -W1p -Gyellow -Sf-1/0.1i+b+l -X0.5i t.txt >> $ps
gmt psxy -R -J -O -K -W1p -Gyellow -Sf-1/0.1i+c+l -X0.5i t.txt >> $ps
gmt psxy -R -J -O -K -W1p -Gyellow -Sf-1/0.1i+f+l -X0.5i t.txt >> $ps
gmt psxy -R -J -O -K -W1p -Gyellow -Sf-1/0.4i+s+l -X0.5i t.txt >> $ps
gmt psxy -R -J -O -W1p -Gyellow -Sf-1/0.1i+t+l -X0.5i t.txt >> $ps
gmt psxy -R -J -O -K -W1p -Gyellow -Sf-1/0.1i+t+l -X0.5i t.txt >> $ps
gmt psxy -R -J -O -W1p -Gyellow -Sf-1/0.1i+v+l -X0.5i t.txt >> $ps

0 comments on commit 1d1e7e5

Please sign in to comment.