Repository navigation
text: Honor vector heads on the -D+v leader line pen - #9263
Conversation
The pen given to -D...+v<pen> accepted the +v line-end modifiers but silently ignored them. Now +vb<vspecs> places a vector head at the data point, shortening the leader so the tip lands on the point. The text end is clipped in PostScript so its end point is unknown in C; +ve (or plain +v) is therefore rejected with an error. The head is skipped when longer than the leader. psxy's end-vector helper moves to gmt_plot.c as gmt_plot_end_vectors so both modules share it. Also stop the paragraph (-M) box from inheriting a stale fill/outline when only a leader line is requested, and do not share (then free) the default pen's vector heads in the -D pen. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Didn't we have nothing that does this already? And I think the arrow head should stop at circle's edge, not its center. |
|
Yes, I think a I have this implemented in GMT.jl (https://www.generic-mapping-tools.org/GMTjl_doc/documentation/utilities/annotate.html#vector-lines) but likely I implemented the arrow part separately. |
|
In these type of changes we must strictly insist with Claude that it is not allowed to reinvent solutions that GMT already has. I am thinking for example in |
+o<offset> (c|i|p) stops the leader, and its +vb head, that distance short of the data point, e.g. to clear a symbol plotted there, as plot -W does. Only the data-point end is affected (a single value also sets the text end, which is ignored), other units and negative offsets are rejected, and nothing is drawn if the offset reaches the text. Without +o the output is unchanged. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…er pen The -D pen starts as a copy of MAP_DEFAULT_PEN, so a +o or +v in that default leaked into the leader and could even trigger the new -D errors (e.g. MAP_DEFAULT_PEN=1p+o100k). Clear all line-end settings instead of only the head pointers; master never applied them to the leader. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Replace the hand-made +o handling with the existing gmt_trim_line, so +o accepts the same offsets as plot -W (plot units and map distances) and the head-length trim follows the same rules. The leader is sampled at 101 vertices because gmt_trim_line treats reaching the last vertex as trimming away the whole line. The text end is never trimmed since the box clipping is relative to it. A leader shorter than the offset plus head is not drawn, as in plot. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
With -F+c corner anchoring on maps whose bounding-box corners fall outside the projection domain (e.g. -JG), the NaN coordinates made gmt_trim_line collapse the leader to nothing. Skip the trim in that case. Also document that +o goes before +vb and which line attributes it follows. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Thanks @joa-quim. Added Tested with:
|
I feel we need an AGENTS.md file (https://agents.md/) to give AI agents clear instructions what to do and not to do. |
I'm about to make a PR about that. |
joa-quim
left a comment
There was a problem hiding this comment.
OK, seems not very intrusive with regard to what we already have.


text -D...+v<pen>accepted the pen's+vmodifiers but silently ignored them. This PR makes+vb<specs>draw a vector head at the data point, asplot -Wdoes. psxy's end-vector helper moves togmt_plot.casgmt_plot_end_vectorsso both modules share it (no change toplotoutput).Vector head at the data point
The leader is shortened by the head length so the tip lands on the point. It works with a text box (
-W/-G), rotated text and paragraph mode (-M); a head longer than the leader is skipped.Tested with:
Head at the text end: not supported (error)
A head at the text end (
+ve, or plain+vfor both ends) is rejected with an error:The leader is clipped against the text box in PostScript (
PSL_plotline_clipped_by_textbox), so C does not know where the line meets the box. Supporting it would need that intersection computed in C (e.g. a PSL function returning the text dimensions) or the head drawn in PostScript. Happy to follow up if wanted.Written with Claude Opus 5.5 (implementation and local review); draft by Claude Sonnet 5.5.