Skip to content

Commit 1d1e7e5

Browse files
authored
Add inverted triangle to front symbol choices (#5983)
* 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_
1 parent 3b20567 commit 1d1e7e5

File tree

9 files changed

+59
-14
lines changed

9 files changed

+59
-14
lines changed

doc/rst/source/explain_symbols.rst_

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@
318318
plotted centered or as a half-symbols on one side. Special options exist for indicating
319319
motion (e.g., faults) along a line.
320320

321-
**-Sf**\ [±]\ *gap*\ [/*size*][**+l**\|\ **+r**][**+b**\|\ **+c**\|\ **+f**\|\ **+s**\ [*angle*]\ \|\ **+t**][**+o**\ *offset*][**+p**\ [*pen*]].
321+
**-Sf**\ [±]\ *gap*\ [/*size*][**+l**\|\ **+r**][**+b**\|\ **c**\|\ **f**\|\ **s**\ [*angle*]\ \|\ **t**\ \|\ **v**][**+o**\ *offset*][**+p**\ [*pen*]].
322322
Draw a **f**\ ront. Supply distance *gap* between symbols and symbol *size*.
323323
If *gap* is negative, it is interpreted to mean the *number* of symbols along the
324324
front instead. If *gap* has a leading + then we use the value exactly as given
@@ -327,7 +327,7 @@
327327
and *size* is thus required. Append **+l** or **+r** to plot symbols on the left or
328328
right side of the front [Default is centered]. Append **+**\ *type* to
329329
specify which symbol to plot: **b**\ ox, **c**\ ircle, **f**\ ault,
330-
**s**\ lip, or **t**\ riangle. [Default is **f**\ ault]. Slip means
330+
**s**\ lip, **t**\ riangle or in\ **v**\ erted triangle. [Default is **f**\ ault]. Slip means
331331
left-lateral or right-lateral strike-slip arrows (centered is not an
332332
option). The **+s** modifier optionally accepts the angle used to draw
333333
the vector [20]. Alternatively, use **+S** which draws arcuate arrow

doc/scripts/GMT_base_symbols7.ps

1.72 KB
Binary file not shown.

doc/scripts/GMT_base_symbols7.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,5 @@ gmt psxy -R -J -O -K -W1p -Gred -Sf-1/0.1i+b -X0.6i t.txt >> $ps
1818
gmt psxy -R -J -O -K -W1p -Gred -Sf-1/0.1i+c -X0.6i t.txt >> $ps
1919
gmt psxy -R -J -O -K -W1p -Gred -Sf-1/0.1i+f -X0.6i t.txt >> $ps
2020
gmt psxy -R -J -O -K -W1p -Sf-1/0.4i+S+l -X0.6i t.txt >> $ps
21-
gmt psxy -R -J -O -W1p -Glightorange -Sf-1/0.1i+t -X0.6i t.txt >> $ps
21+
gmt psxy -R -J -O -K -W1p -Glightorange -Sf-1/0.1i+t -X0.6i t.txt >> $ps
22+
gmt psxy -R -J -O -W1p -Glightgreen -Sf-1/0.1i+v -X0.6i t.txt >> $ps

src/gmt_init.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5761,7 +5761,7 @@ GMT_LOCAL int gmtinit_parse_front (struct GMT_CTRL *GMT, char *text, struct GMT_
57615761
char p[GMT_BUFSIZ] = {""}, txt_a[GMT_LEN256] = {""}, txt_b[GMT_LEN256] = {""};
57625762

57635763
/* text[0] is the leading 'f' for front */
5764-
if (text[1] == '+' && !strchr ("bcfilrsStop", text[2])) S->f.f_exact = true, k0 = 2; /* Special leading + to be skipped when looking for modifiers */
5764+
if (text[1] == '+' && !strchr ("bcfilrsStopv", text[2])) S->f.f_exact = true, k0 = 2; /* Special leading + to be skipped when looking for modifiers */
57655765
for (k = k0; text[k] && text[k] != '+'; k++); /* Either find the first plus or run out or chars */
57665766
strncpy (p, text, k); p[k] = 0;
57675767
mods = (text[k] == '+');
@@ -5794,6 +5794,7 @@ GMT_LOCAL int gmtinit_parse_front (struct GMT_CTRL *GMT, char *text, struct GMT_
57945794
S->f.f_angle = (p[1]) ? atof (&p[1]) : 40.0; /* Set curved slip arrow angle [40] */
57955795
break;
57965796
case 't': S->f.f_symbol = GMT_FRONT_TRIANGLE; break; /* Triangle front */
5797+
case 'v': S->f.f_symbol = GMT_FRONT_ITRIANGLE; break; /* Inverted triangle front */
57975798
case 'o': S->f.f_off = gmt_M_to_inch (GMT, &p[1]); break; /* Symbol offset along line */
57985799
case 'p': if (p[1]) { /* Get alternate pen for front-symbol outline [-W] */
57995800
if (gmt_getpen (GMT, &p[1], &S->f.pen)) {

src/gmt_plot.c

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9845,12 +9845,15 @@ void gmt_geo_rectangle (struct GMT_CTRL *GMT, double lon, double lat, double wid
98459845
PSL_plotsymbol (PSL, xp, yp, dim, PSL_ROTRECT);
98469846
}
98479847

9848+
#define M_PI_3 1.047197551196598 /* 60 degrees in radians */
9849+
98489850
void gmt_draw_front (struct GMT_CTRL *GMT, double x[], double y[], uint64_t n, struct GMT_FRONTLINE *f) {
98499851
int ngap, tmp_join = 0, tmp_limit = 0;
98509852
bool skip;
98519853
uint64_t i;
9852-
double *s = NULL, xx[4], yy[4], dist = 0.0, w, frac, dx, dy, angle, dir1, dir2;
9854+
double *s = NULL, xx[6], yy[6], dist = 0.0, w, frac, dx, dy, angle, dir1, dir2;
98539855
double gap, x0, y0, xp, yp, len2, len3, len4, cosa, sina, sa, ca, offx, offy, dim[PSL_MAX_DIMS];
9856+
double a1, a2, sina1, sina2, cosa1, cosa2;
98549857
struct PSL_CTRL *PSL= GMT->PSL;
98559858

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

9966+
case GMT_FRONT_ITRIANGLE: /* Inverted triangle */
9967+
a1 = angle + M_PI_3; a2 = a1 + M_PI_3;
9968+
sincos (a1, &sina1, &cosa1);
9969+
sincos (a2, &sina2, &cosa2);
9970+
switch (f->f_sense) {
9971+
case GMT_FRONT_CENTERED:
9972+
xx[0] = x0 + f->f_len * cosa1; /* UR */
9973+
yy[0] = y0 + f->f_len * sina1;
9974+
xx[1] = x0 + f->f_len * cosa2; /* UL */
9975+
yy[1] = y0 + f->f_len * sina2;
9976+
xx[2] = x0; yy[2] = y0; /* MC */
9977+
xx[3] = x0 - f->f_len * cosa1; /* LR */
9978+
yy[3] = y0 - f->f_len * sina1;
9979+
xx[4] = x0 - f->f_len * cosa2; /* LL */
9980+
yy[4] = y0 - f->f_len * sina2;
9981+
xx[5] = x0; yy[5] = y0; /* MC */
9982+
PSL_plotpolygon (PSL, xx, yy, 6);
9983+
break;
9984+
case GMT_FRONT_RIGHT:
9985+
sina1 = -sina1; cosa1 = -cosa1; sina2 = -sina2; cosa2 = -cosa2;
9986+
/* Intentionally fall through - after changing the angle */
9987+
case GMT_FRONT_LEFT:
9988+
xx[0] = x0 + f->f_len * cosa1; /* UR */
9989+
yy[0] = y0 + f->f_len * sina1;
9990+
xx[1] = x0 + f->f_len * cosa2; /* UL */
9991+
yy[1] = y0 + f->f_len * sina2;
9992+
xx[2] = x0; yy[2] = y0; /* MC */
9993+
PSL_plotpolygon (PSL, xx, yy, 3);
9994+
break;
9995+
}
9996+
break;
9997+
99639998
case GMT_FRONT_CIRCLE: /* Circles */
99649999
switch (f->f_sense) {
996510000
case GMT_FRONT_CENTERED:

src/gmt_plot.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
/*! FRONT symbols */
6565

6666
enum GMT_enum_front {GMT_FRONT_FAULT = 0,
67+
GMT_FRONT_ITRIANGLE,
6768
GMT_FRONT_TRIANGLE,
6869
GMT_FRONT_SLIP,
6970
GMT_FRONT_SLIPC,

src/psxy.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ static int usage (struct GMTAPI_CTRL *API, int level) {
619619
"Append any of the units in %s to the dimensions [Default is k]. "
620620
"For linear projection and -SJ we scale dimensions by the map scale.", GMT_LINE_BULLET, mod_name, GMT_LEN_UNITS_DISPLAY);
621621

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

639640
GMT_Usage (API, 2, "\n%s Kustom: -Sk|K<symbolname>[/<size>]", GMT_LINE_BULLET);
640641
GMT_Usage (API, -3, "Append <symbolname> immediately after 'k|K'; this will look for "

test/psxy/front.ps

5.9 KB
Binary file not shown.

test/psxy/front.sh

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
ps=front.ps
66

7-
gmt psbasemap -R0/6/0/8 -Jx1i -P -B0 -K -Xc > $ps
7+
gmt psbasemap -R0/7/0/8 -Jx1i -P -B0 -K -X0.5i > $ps
88
cat << EOF > t.txt
99
0 0
1010
10 20
@@ -15,30 +15,36 @@ gmt psxy -R -J -O -K -W1p -Gred -Sf0.4i/0.1i+c -X0.5i t.txt >> $ps
1515
gmt psxy -R -J -O -K -W1p -Gred -Sf0.4i/0.1i+f -X0.5i t.txt >> $ps
1616
gmt psxy -R -J -O -K -W1p -Sf0.6i/0.3i+S+r -X0.5i t.txt >> $ps
1717
gmt psxy -R -J -O -K -W1p -Gred -Sf0.4i/0.1i+t -X0.5i t.txt >> $ps
18+
gmt psxy -R -J -O -K -W1p -Gred -Sf0.4i/0.1i+v -X0.5i t.txt >> $ps
1819
gmt psxy -R -J -O -K -W1p -Gred -Sf-1/0.1i+b -X0.5i t.txt >> $ps
1920
gmt psxy -R -J -O -K -W1p -Gred -Sf-1/0.1i+c -X0.5i t.txt >> $ps
2021
gmt psxy -R -J -O -K -W1p -Gred -Sf-1/0.1i+f -X0.5i t.txt >> $ps
2122
gmt psxy -R -J -O -K -W1p -Sf-1/0.4i+S+l -X0.5i t.txt >> $ps
2223
gmt psxy -R -J -O -K -W1p -Gred -Sf-1/0.1i+t -X0.5i t.txt >> $ps
23-
# Right symbols using fixed interval, then same with just 1 centered symbol
24-
gmt psxy -R -J -O -K -W1p -Gblue -Sf0.4i/0.1i+b+r -X-4.5i -Y2.5i t.txt >> $ps
24+
gmt psxy -R -J -O -K -W1p -Gred -Sf-1/0.1i+v -X0.5i t.txt >> $ps
25+
# Right symbols using fixed interval, then same with just 1 right-side symbol
26+
gmt psxy -R -J -O -K -W1p -Gblue -Sf0.4i/0.1i+b+r -X-5.5i -Y2.5i t.txt >> $ps
2527
gmt psxy -R -J -O -K -W1p -Gblue -Sf0.4i/0.1i+c+r -X0.5i t.txt >> $ps
2628
gmt psxy -R -J -O -K -W1p -Gblue -Sf0.4i/0.1i+f+r -X0.5i t.txt >> $ps
2729
gmt psxy -R -J -O -K -W1p -Gblue -Sf0.6i/0.3i+s+r -X0.5i t.txt >> $ps
2830
gmt psxy -R -J -O -K -W1p -Gblue -Sf0.4i/0.1i+t+r -X0.5i t.txt >> $ps
31+
gmt psxy -R -J -O -K -W1p -Gblue -Sf0.4i/0.1i+v+r -X0.5i t.txt >> $ps
2932
gmt psxy -R -J -O -K -W1p -Gblue -Sf-1/0.1i+b+r -X0.5i t.txt >> $ps
3033
gmt psxy -R -J -O -K -W1p -Gblue -Sf-1/0.1i+c+r -X0.5i t.txt >> $ps
3134
gmt psxy -R -J -O -K -W1p -Gblue -Sf-1/0.1i+f+r -X0.5i t.txt >> $ps
3235
gmt psxy -R -J -O -K -W1p -Gblue -Sf-1/0.4i+s+r -X0.5i t.txt >> $ps
3336
gmt psxy -R -J -O -K -W1p -Gblue -Sf-1/0.1i+t+r -X0.5i t.txt >> $ps
34-
# Left symbols using fixed interval, then same with just 1 centered symbol
35-
gmt psxy -R -J -O -K -W1p -Gyellow -Sf0.4i/0.1i+b+l -X-4.5i -Y2.5i t.txt >> $ps
37+
gmt psxy -R -J -O -K -W1p -Gblue -Sf-1/0.1i+v+r -X0.5i t.txt >> $ps
38+
# Left symbols using fixed interval, then same with just 1 left-side symbol
39+
gmt psxy -R -J -O -K -W1p -Gyellow -Sf0.4i/0.1i+b+l -X-5.5i -Y2.5i t.txt >> $ps
3640
gmt psxy -R -J -O -K -W1p -Gyellow -Sf0.4i/0.1i+c+l -X0.5i t.txt >> $ps
3741
gmt psxy -R -J -O -K -W1p -Gyellow -Sf0.4i/0.1i+f+l -X0.5i t.txt >> $ps
3842
gmt psxy -R -J -O -K -W1p -Gyellow -Sf0.6i/0.3i+s+l -X0.5i t.txt >> $ps
3943
gmt psxy -R -J -O -K -W1p -Gyellow -Sf0.4i/0.1i+t+l -X0.5i t.txt >> $ps
44+
gmt psxy -R -J -O -K -W1p -Gyellow -Sf0.4i/0.1i+v+l -X0.5i t.txt >> $ps
4045
gmt psxy -R -J -O -K -W1p -Gyellow -Sf-1/0.1i+b+l -X0.5i t.txt >> $ps
4146
gmt psxy -R -J -O -K -W1p -Gyellow -Sf-1/0.1i+c+l -X0.5i t.txt >> $ps
4247
gmt psxy -R -J -O -K -W1p -Gyellow -Sf-1/0.1i+f+l -X0.5i t.txt >> $ps
4348
gmt psxy -R -J -O -K -W1p -Gyellow -Sf-1/0.4i+s+l -X0.5i t.txt >> $ps
44-
gmt psxy -R -J -O -W1p -Gyellow -Sf-1/0.1i+t+l -X0.5i t.txt >> $ps
49+
gmt psxy -R -J -O -K -W1p -Gyellow -Sf-1/0.1i+t+l -X0.5i t.txt >> $ps
50+
gmt psxy -R -J -O -W1p -Gyellow -Sf-1/0.1i+v+l -X0.5i t.txt >> $ps

0 commit comments

Comments
 (0)