Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] New line symbol type: Hash line #9644

Merged
merged 4 commits into from
Apr 2, 2019

Conversation

nyalldawson
Copy link
Collaborator

@nyalldawson nyalldawson commented Mar 28, 2019

This line symbol type is designed to replicate the ArcGIS Hash Line
symbol layer type. It allows for a repeating line segment to be
drawn over the length of a feature, with a line-sub symbol used
to render each individual segment.

To reduce code duplication, this is heavily based off the current
line marker symbol layer, since the functionality is almost
identical (draw some sub symbol at some interval along a line).
Accordingly, I've split off QgsMarkerLineSymbolLayer to move
as much of the common functionality as possible to a new abstract
base class, so that only the actual marker/line segment rendering
occurs in the marker line/hash line subclasses.

This also gives the hash line all the existing placement options
permissible for marker lines -- e.g. first/last vertex, mid points,
regular intervals, etc.

The hash line length and angle can have data defined overrides,
which are evaluated per-line segment, allowing for the hash line
to change size and angle over the length of a single rendered
feature.

Some screenshots:

image

With data defined hash length:

image

Complex symbol, using multi-level hash sub symbol:

image

"meta" symbol, using hashed lines with hashed line sub symbols! (For reference: ArcGIS chokes on this)

image

This line symbol type is designed to replicate the ArcGIS Hash Line
symbol layer type. It allows for a repeating line segment to be
drawn over the length of a feature, with a line-sub symbol used
to render each individual segment.

To reduce code duplication, this is heavily based off the current
line marker symbol layer, since the functionality is almost
identical (draw some sub symbol at some interval along a line).
Accordingly, I've split off QgsMarkerLineSymbolLayer to move
as much of the common functionality as possible to a new abstract
base class, so that only the actual marker/line segment rendering
occurs in the marker line/hash line subclasses.

This also gives the hash line all the existing placement options
permissible for marker lines -- e.g. first/last vertex, mid points,
regular intervals, etc.

The hash line length and angle can have data defined overrides,
which are evaluated per-line segment, allowing for the hash line
to change size and angle over the length of a single rendered
feature.
This is just a direct copy of another test from this file -
the actual ring filter test is in Python
@nyalldawson nyalldawson added this to the 3.8 milestone Mar 28, 2019
@nirvn
Copy link
Contributor

nirvn commented Mar 28, 2019

Nice one.

@andreasneumann
Copy link
Member

Interesting. Just so that I understand the hashlines correctly: are those always perpendicular to the line segment or bisector angle in case when they are at a vertex?

@nyalldawson
Copy link
Collaborator Author

For now, it's the same as line marker, so bisector.

Coming after this is an option to use an average angle calculated over a set distance, to avoid ugly orientation for jagged lines.

@nyalldawson
Copy link
Collaborator Author

nyalldawson commented Mar 28, 2019

@andreasneumann

Here's some more screenshots.

Vertex placement mode:

image

Hash angle set to 30 degrees, without rotating hashes to match line direction:

image

Hash angle at 30 degrees, plus rotating to match line direction:

image

Caligraphic/texta pen effect, using a fixed 45 degree angle, with a thick, semi transparent hash line, and a small interval:

image

(or chunky highlighters:)

image

ArcGIS symbols converted using SLYR:

image

@andreasneumann
Copy link
Member

andreasneumann commented Mar 29, 2019

Thanks for sharing these! Many of the examples you provide would have been possible with the already existing marker line styles - right? But probably with more work and less elegant.

How ist the last example, the one with the perpendicular lines, alternating to the left and right, done? Can you influence that every second one changes direction?

I like the calligraphic lines, but they would have been possible already with traditional marker lines - right? I used calligraphic lines in Adobe Illustrator, Inkscape and Corel Draw and like them for certain - more artistic - styles.

How about performance, when rendering very dense repeats of markers or hashes?

@nyalldawson
Copy link
Collaborator Author

@andreasneumann

Thanks for sharing these! Many of the examples you provide would have been possible with the already existing marker line styles - right? But probably with more work and less elegant.

Right -- if the cross hatches use just a simple line type, then it's mostly possible using a marker line with the | symbol (excluding some advanced settings like line cap styles). But for complex hashed line types it's not possible to replicate. I think even for the common use types like creating rail-line style symbols, is worth having this new layer type to make creation of those symbols easier for users (especially those coming from an ESRI background). Ultimately, with the refactoring done in this PR, the vast bulk of the code is shared between both marker and hash line symbol types, so it doesn't add any significant maintenance burden either.

How ist the last example, the one with the perpendicular lines, alternating to the left and right, done? Can you influence that every second one changes direction?

It's two levels of hashed line, with the same interval but different initial offsets, and with line offsets opposite to each other. I can share a QML if you'd like?

I like the calligraphic lines, but they would have been possible already with traditional marker lines - right?

Correct.

I used calligraphic lines in Adobe Illustrator, Inkscape and Corel Draw and like them for certain - more artistic - styles.

How about performance, when rendering very dense repeats of markers or hashes?

It's fine up to a certain threshold. For me (on a slow debug build) it's acceptable down to an interval of about .01 mm, and then below that starts to chug along. I'm not too concerned about that though -- with multi-threaded rendering we still get a responsive QGIS, and someone who really has a need for denser symbols is free to do this and just have slow redraws.

Thanks for your feedback here!

@nyalldawson nyalldawson merged commit f8f319b into qgis:master Apr 2, 2019
@nyalldawson nyalldawson deleted the hash_line_type branch April 2, 2019 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants