diff --git a/doc/rst/source/explain_symbols.rst_ b/doc/rst/source/explain_symbols.rst_ index cf4ea1bfe31..2da42bb6f07 100644 --- a/doc/rst/source/explain_symbols.rst_ +++ b/doc/rst/source/explain_symbols.rst_ @@ -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 @@ -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 diff --git a/doc/scripts/GMT_base_symbols7.ps b/doc/scripts/GMT_base_symbols7.ps index bbc079b5378..56c0e12faf0 100644 Binary files a/doc/scripts/GMT_base_symbols7.ps and b/doc/scripts/GMT_base_symbols7.ps differ diff --git a/doc/scripts/GMT_base_symbols7.sh b/doc/scripts/GMT_base_symbols7.sh index 444f462e2ef..7688c744166 100755 --- a/doc/scripts/GMT_base_symbols7.sh +++ b/doc/scripts/GMT_base_symbols7.sh @@ -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 diff --git a/src/gmt_init.c b/src/gmt_init.c index 761b8d09aef..b98782eca62 100644 --- a/src/gmt_init.c +++ b/src/gmt_init.c @@ -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] == '+'); @@ -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)) { diff --git a/src/gmt_plot.c b/src/gmt_plot.c index ede1afa7885..1bc15644869 100644 --- a/src/gmt_plot.c +++ b/src/gmt_plot.c @@ -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; @@ -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: diff --git a/src/gmt_plot.h b/src/gmt_plot.h index c1ede2c68a9..bb5c0b66612 100644 --- a/src/gmt_plot.h +++ b/src/gmt_plot.h @@ -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, diff --git a/src/psxy.c b/src/psxy.c index 46c23562f2e..2368a0dafec 100644 --- a/src/psxy.c +++ b/src/psxy.c @@ -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[/][+r+l][+f+t+s+c+b][+o][+p]", GMT_LINE_BULLET); + GMT_Usage (API, 2, "\n%s Front: -Sf[/][+r|l][+f|t|s|c|b|v][+o][+p]", GMT_LINE_BULLET); GMT_Usage (API, -3, "If is negative it means the number of gaps instead. " "If has a leading + then is used exactly [adjusted to fit line length]. " "If not given, defaults to 15%% of . Append various modifiers:"); @@ -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 [0]."); GMT_Usage (API, 3, "+p Append for front symbol outline; if no 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[/]", GMT_LINE_BULLET); GMT_Usage (API, -3, "Append immediately after 'k|K'; this will look for " diff --git a/test/psxy/front.ps b/test/psxy/front.ps index f478c1c0e01..811b5c0b248 100644 Binary files a/test/psxy/front.ps and b/test/psxy/front.ps differ diff --git a/test/psxy/front.sh b/test/psxy/front.sh index 1964e8795a0..13b40af37c6 100755 --- a/test/psxy/front.sh +++ b/test/psxy/front.sh @@ -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 @@ -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