@@ -44,15 +44,15 @@ void gmt_barb_syntax (struct GMT_CTRL *GMT, char option, char *string, unsigned
4444 * 1 = Accepts +z (not mathangle)
4545 */
4646 struct GMTAPI_CTRL * API = GMT -> parent ;
47- GMT_Usage (API , 1 , "\n-%c<params> " , option );
47+ GMT_Usage (API , 1 , "\n-%c%s[+z] " , option , GMT_BARG_PARAMS );
4848 GMT_Usage (API , -2 , "%s Append length of wind barbs, with optional modifiers:" , string );
49- GMT_Usage (API , 3 , "+a<angle> to set angle of wind barb [120]" );
50- GMT_Usage (API , 3 , "+g<fill> to set fill or use - to turn off fill [default fill]." );
51- GMT_Usage (API , 3 , "+j<just> to justify wind barb at (b)eginning [default], (e)nd, or (c)enter." );
52- GMT_Usage (API , 3 , "+p[-][<pen>] to set pen attributes, prepend - to turn off outlines [default pen and outline]." );
53- GMT_Usage (API , 3 , "+s[scale] to set the wind speed which corresponds to a long wind barb [default 5]" );
54- GMT_Usage (API , 3 , "+w[width] to set the width of wind barbs" );
55- if (mode & 1 ) GMT_Usage (API , 3 , "+z if (u,v) wind components are given instead of (azimuth,speed) on input." );
49+ GMT_Usage (API , 3 , "+a Append angle of wind barb [120]" );
50+ GMT_Usage (API , 3 , "+g Set fill or use - to turn off fill [default fill]." );
51+ GMT_Usage (API , 3 , "+j Append b|c|e to justify wind barb at (b)eginning [default], (e)nd, or (c)enter." );
52+ GMT_Usage (API , 3 , "+p Set pen attributes, or prepend - to turn off outlines [default pen and outline]." );
53+ GMT_Usage (API , 3 , "+s Set the wind speed scale which corresponds to a long wind barb [default 5]" );
54+ GMT_Usage (API , 3 , "+w Set the width of wind barbs" );
55+ if (mode & 1 ) GMT_Usage (API , 3 , "+z Wind components (u,v) are given instead of (azimuth,speed) on input." );
5656}
5757
5858int gmt_draw_barb (struct GMT_CTRL * GMT , double x0 , double y0 , double lat , double theta , double spd , struct GMT_BARB_ATTR B , struct GMT_PEN * pen , struct GMT_FILL * fill , unsigned int outline )
@@ -169,7 +169,7 @@ int gmt_init_barb_param (struct GMT_CTRL *GMT, struct GMT_BARB_ATTR *B, bool set
169169}
170170
171171/*! Parser for -Q */
172- GMT_LOCAL int gmt_parse_barb_v5 (struct GMT_CTRL * GMT , char * text , struct GMT_BARB_ATTR * B ) {
172+ GMT_LOCAL int gmt_parse_barb_v5 (struct GMT_CTRL * GMT , char * text , struct GMT_BARB_ATTR * B , unsigned int mode ) {
173173
174174 unsigned int pos = 0 , k , error = 0 ;
175175 bool p_opt = false, g_opt = false;
@@ -191,7 +191,7 @@ GMT_LOCAL int gmt_parse_barb_v5 (struct GMT_CTRL *GMT, char *text, struct GMT_BA
191191 B -> status |= PSL_VEC_FILL ;
192192 if (p [1 ]) {
193193 if (gmt_getfill (GMT , & p [1 ], & B -> fill )) {
194- GMT_Report (GMT -> parent , GMT_MSG_NORMAL , "Bad +g<fill> modifier %c\n" , & p [1 ]);
194+ GMT_Report (GMT -> parent , GMT_MSG_NORMAL , "Option -Q: Bad +g-| <fill> modifier %c\n" , & p [1 ]);
195195 error ++ ;
196196 }
197197 B -> status |= PSL_VEC_FILL2 ;
@@ -203,7 +203,7 @@ GMT_LOCAL int gmt_parse_barb_v5 (struct GMT_CTRL *GMT, char *text, struct GMT_BA
203203 case 'c' : B -> status |= PSL_VEC_JUST_C ; break ; /* Input (x,y) refers to center point */
204204 case 'e' : B -> status |= PSL_VEC_JUST_E ; break ; /* Input (x,y) refers to end point */
205205 default : /* Bad justifier code */
206- GMT_Report (GMT -> parent , GMT_MSG_NORMAL , "Bad +j<just> modifier %c\n" , p [1 ]);
206+ GMT_Report (GMT -> parent , GMT_MSG_NORMAL , "Option -Q: Bad +j<just> modifier %c\n" , p [1 ]);
207207 error ++ ;
208208 break ;
209209 }
@@ -218,7 +218,7 @@ GMT_LOCAL int gmt_parse_barb_v5 (struct GMT_CTRL *GMT, char *text, struct GMT_BA
218218 }
219219 if (p [j ]) { /* Change default pen */
220220 if (gmt_getpen (GMT , & p [j ], & B -> pen )) {
221- GMT_Report (GMT -> parent , GMT_MSG_NORMAL , "Bad +p<pen> modifier %c\n" , & p [1 ]);
221+ GMT_Report (GMT -> parent , GMT_MSG_NORMAL , "Option -Q: Bad +p-| <pen> modifier %c\n" , & p [1 ]);
222222 error ++ ;
223223 }
224224 B -> status |= PSL_VEC_OUTLINE2 ; /* Flag that a pen specification was given */
@@ -231,10 +231,15 @@ GMT_LOCAL int gmt_parse_barb_v5 (struct GMT_CTRL *GMT, char *text, struct GMT_BA
231231 B -> width = (float )gmt_M_to_inch (GMT , & p [1 ]);
232232 break ;
233233 case 'z' : /* Input (angle,length) are vector components (dx,dy) instead */
234- B -> status |= PSL_VEC_COMPONENTS ;
234+ if (mode == 1 ) /* Only psbarb can take +z */
235+ B -> status |= PSL_VEC_COMPONENTS ;
236+ else { /* grdbarb does not take -Q+z */
237+ GMT_Report (GMT -> parent , GMT_MSG_NORMAL , "Option -Q: Bad modifier +z\n" );
238+ error ++ ;
239+ }
235240 break ;
236241 default :
237- GMT_Report (GMT -> parent , GMT_MSG_NORMAL , "Bad modifier +%c\n" , p [0 ]);
242+ GMT_Report (GMT -> parent , GMT_MSG_NORMAL , "Option -Q: Bad modifier +%c\n" , p [0 ]);
238243 error ++ ;
239244 break ;
240245 }
@@ -252,7 +257,7 @@ GMT_LOCAL int gmt_parse_barb_v5 (struct GMT_CTRL *GMT, char *text, struct GMT_BA
252257}
253258
254259/*! Parser for -Q */
255- int gmt_parse_barb (struct GMT_CTRL * GMT , char * text , struct GMT_BARB_ATTR * B ) {
260+ int gmt_parse_barb (struct GMT_CTRL * GMT , char * text , struct GMT_BARB_ATTR * B , unsigned int mode ) {
256261
257262 char txt_a [GMT_LEN256 ] = {"" }, txt_b [GMT_LEN256 ] = {"" }, txt_c [GMT_LEN256 ] = {"" }, txt_d [GMT_LEN256 ] = {"" };
258263 unsigned int error = 0 ;
@@ -276,13 +281,13 @@ int gmt_parse_barb (struct GMT_CTRL *GMT, char *text, struct GMT_BARB_ATTR *B) {
276281 }
277282 else {
278283 if (text [0 ] == '+' ) { /* No size (use default), just attributes */
279- error += gmt_parse_barb_v5 (GMT , text , B );
284+ error += gmt_parse_barb_v5 (GMT , text , B , mode );
280285 }
281286 else { /* Size, plus possible attributes */
282287 j = sscanf (text , "%[^+]%s" , txt_a , txt_b ); /* txt_a should be symbols size with any +<modifiers> in txt_b */
283288 if (j == 1 ) txt_b [0 ] = 0 ; /* No modifiers present, set txt_b to empty */
284289 if (j >= 1 ) B -> length = gmt_M_to_inch (GMT , txt_a ); /* Length of barb */
285- error += gmt_parse_barb_v5 (GMT , txt_b , B );
290+ error += gmt_parse_barb_v5 (GMT , txt_b , B , mode );
286291 }
287292 }
288293
0 commit comments