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

Visitor API for style entities #30522

Merged
merged 4 commits into from
Jul 6, 2019
Merged

Visitor API for style entities #30522

merged 4 commits into from
Jul 6, 2019

Conversation

nyalldawson
Copy link
Collaborator

Adds a new visitor pattern API for creation of visitors which visit all the style entities (symbols, color ramps, text formats, and label styles) associated with different objects. Can be used on a renderer, map layer, or project wide level.

E.g. on a project wide level, allows collection of ALL the style symbols/color ramps/text settings inside a project, including those in layouts or annotations!

This opens up lots of possibilities. E.g. scripts (or processing algorithms!) which:

  • check for broken file references in symbols (e.g. missing svgs)
  • list all expressions from data defined properties in symbols, and check their validity
  • extract all symbols, color ramps, label settings from a project and saves them to a style database
  • extracts the unique colors from a project, and builds an automatic "project color scheme" from them
  • finds wherever you've used crappy fonts in a project (ms shell dlg anyone?)

...etc etc

(a nice follow up would be a visitor which allows symbols to be modified, but that's an order of magnitude more complex).

@nyalldawson nyalldawson added Feature API API improvement only, no visible user interface changes labels Jul 3, 2019
@nyalldawson nyalldawson added this to the 3.10.0 milestone Jul 3, 2019
@nyalldawson nyalldawson force-pushed the visitor branch 2 times, most recently from 6cc6baf to 808b624 Compare July 3, 2019 22:55
@m-kuhn
Copy link
Member

m-kuhn commented Jul 5, 2019

Good stuff!

One thing that I wonder is if it would be possible and useful to add nesting information / parent information to leafs and nodes, so you could see e.g. where in a nested rule structure you are which I think is currently not possible.

@nyalldawson
Copy link
Collaborator Author

@m-kuhn

One thing that I wonder is if it would be possible and useful to add nesting information / parent information to leafs and nodes, so you could see e.g. where in a nested rule structure you are which I think is currently not possible.

That was my intention with the enter/exit calls - but it's up to the visitor to utilise these and track the tree traversal if they need this info. I don't think there's a straightforward way to do this automatically. I guess we could have a built in "trackingvisitor" subclass which has a different virtual visit method which adds provides this extra info, but that's getting rather confusing!

Let's revisit this topic if/when there's a need for that.

@m-kuhn
Copy link
Member

m-kuhn commented Jul 5, 2019

I was thinking of a parent in the node and leaf structs that would always be available. But no need really.

Adds a new visitor pattern API for creation of visitors which visit
all the style entities (symbols, color ramps, text formats, and
label styles) associated with different objects. Can be used on a
renderer, map layer, or project wide level.

E.g. on a project wide level, allows collection of ALL the style
symbols/color ramps/text settings inside a project, including those
in layouts or annotations!
@nyalldawson nyalldawson merged commit f3dcd82 into qgis:master Jul 6, 2019
@nyalldawson nyalldawson deleted the visitor branch July 6, 2019 02:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API API improvement only, no visible user interface changes Feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants