Skip to content

Change markers drawing in SVG/PDF/PS/TeX - #23094

Draft
linev wants to merge 13 commits into
root-project:masterfrom
linev:svg_marker
Draft

Change markers drawing in SVG/PDF/PS/TeX#23094
linev wants to merge 13 commits into
root-project:masterfrom
linev:svg_marker

Conversation

@linev

@linev linev commented Aug 18, 2026

Copy link
Copy Markdown
Member

First adjust TAttMarker::GetMarkerShape() method to support features requires by text outputs.
Main difference to X11/Cocoa/GL is how dots are handled.
For PS-based outputs one draw small circles, in X11 - several lines or small rect.
In all DrawPolyMarker implementations now TAttMarker::GetMarkerShape() is used.

In TSVG store N markers produced by TSVG::DrawPolyMarker call in single <path d="..."/> element.
This reduce size of SVG file and increase rendering speed.
Only when circles are drawn - as in previous implementation create <g> with N <circle>

In TPDF just use GetMarkerShape(), logic and implementation did not change much.

In TPostScript changes are significant. Before all markers shaped were predefined and ALWAYS stored in the beginning of the PS file. Now specific marker shape defined ONLY when it used for the first time. Marker definition generated with help of GetMarkerShape() method. So if markers are not used in the plot - PS file will be smaller than before. But if there are many different markers - size is increased while definition is not that compact as before.

In TTexDump changes similar to TPostScript. Define markers only when they are used.
Only simple default tex markers * (filled circle) and o (circle) are re-used, all other markers defined based of provided shape. While marker size is extra parameter - shape defined only once for each marker type.
As result - all existing markers now supported in TTexDump (before only half was there).

Update several test/svg_ref/*.svg files because markers implementation was changed.

Update stressGraphics.ref files while size of PS and PDF files were changed for markers

Update several other tests where PS output used for testing.

Result of this PR - all existing graphics backends using same code to generate shape of the markers!

@linev linev self-assigned this Aug 18, 2026
@linev
linev requested review from couet and dpiparo as code owners August 18, 2026 13:16
@linev
linev marked this pull request as draft August 18, 2026 13:18
@linev
linev force-pushed the svg_marker branch 2 times, most recently from 4d52160 to 8e7df11 Compare August 18, 2026 14:05
@linev
linev marked this pull request as ready for review August 18, 2026 14:07
@github-actions

github-actions Bot commented Aug 18, 2026

Copy link
Copy Markdown

Test Results

    22 files      22 suites   3d 12h 51m 6s ⏱️
 3 860 tests  3 859 ✅ 0 💤 1 ❌
74 878 runs  74 877 ✅ 0 💤 1 ❌

For more details on these failures, see this check.

Results for commit 8c1126c.

♻️ This comment has been updated with latest results.

@linev linev closed this Aug 19, 2026
@linev linev reopened this Aug 19, 2026
@linev
linev requested a review from pcanal as a code owner August 20, 2026 06:07
@linev
linev requested a review from couet August 20, 2026 06:07
@linev linev changed the title Change markers drawing in TSVG Change markers drawing in SVG/PDF/PS Aug 20, 2026
@linev
linev marked this pull request as draft August 20, 2026 06:21
@linev linev added the clean build Ask CI to do non-incremental build on PR label Aug 20, 2026
@linev linev closed this Aug 20, 2026
@linev linev reopened this Aug 20, 2026
linev added 7 commits August 20, 2026 12:37
Via unsigned flags argument let specify:
   * kPreferTriangles - return kShapeTriangles instead of kShapeFilledArea
   * kDotAsLines - convert small and medium dot into lines which are directly drawn by pixel devices
   * kDotAsCircle - automatically convert small and medium dots into circles
   * kUsePSWidthScale - use gStyle->GetLineScalePS() for marker size calculations

Depending from graphical engines one may want to handle
dots as circles or as lines or directly as sized dots.
Move prefer_triangles argument as one of such bits

Now method always return pixel size of created markers.
Such size can be used for scaling of created points.
Now there are multiple flags and for pixel devices one prefer to convert dots into lines and fill rects
Use segments instead of polyline while many PS engines makes problems to draw line over same points
Use TAttMarker::GetMarkerShape() to retrieve marker shape and
draw it with SVG `<path>` expression.
Only circles remain drawn as <g> of <circle> to have clear indication
Use integer coordinates for relative path movement
Add space between markers in path d attribute to have proper line breaks
Use TAttMarker::GetMarkerShape() to plot markers
Unify PDF output with other graphics and image engines
Increases slightly PDF file sizes while some markers like rectangle
now drawn as filled polygon - which is larger
Use GetMarkerShape for markers drawing in PS
Like in all other engines, translate marker in simple graphical commands
and then directly display them.
When many markers drawn at the same time - reduce size of PS file
Also fix direction of markers
@linev linev removed the clean build Ask CI to do non-incremental build on PR label Aug 20, 2026
While same marker can appear many times in the same document -
keep map of already created markers and define each new ones.
Name of marker include type and size of the marker.
Like "m20_sz200". Default marker size = 1 is not included and marker will
be defined as "m20".
linev added 5 commits August 20, 2026 14:08
Like in PS, define markers once when they really used

Reuse same shape for different sizes, but ensure that generated shape
does not have roundnig problems

Use GetLineScalePS() also for markers in TeX

As result, implement lot of missing markers.
Other markers like triangles looks identical with PDF/SVG/X11
Both classes were never designed to be used in I/O
Now markers stored differently in SVG
PS and PDF files are changed now while markers
created from provided shape
Now markers not automatically defined in PS file,
wherefore file size and number of lines does not match to previous values.
@linev linev changed the title Change markers drawing in SVG/PDF/PS Change markers drawing in SVG/PDF/PS/TeX Aug 20, 2026
@linev linev added the clean build Ask CI to do non-incremental build on PR label Aug 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clean build Ask CI to do non-incremental build on PR in:Graphics

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants