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

boundingbox for GlyphCollections #3860

Open
hexaeder opened this issue May 13, 2024 · 2 comments
Open

boundingbox for GlyphCollections #3860

hexaeder opened this issue May 13, 2024 · 2 comments
Labels

Comments

@hexaeder
Copy link
Contributor

In GraphMakie on Makie@0.20 we used to use

using GLMakie
fig, ax, p = text([(0,0),(0,1)]; text=["foo", "bar"])

glyphcollections = p.plots[1][1][]

boundingbox(glyphcollections[1], Quaternion((1,0,0,0))) # bouding box of text "foo"
boundingbox(glyphcollections[2], Quaternion((1,0,0,0))) # bouding box of text "bar"

to get the the bounding box of single elements within a textplot to draw node shapes around it in the correct size.

grafik

This solution (...which admittedly abused internals...) does not work anymore in Makie@0.21. Any suggestions on how to replace it?

ERROR: LoadError: LoadError: LoadError: MethodError: no method matching boundingbox(::Makie.GlyphCollection, ::Quaternion{Int64})
Closest candidates are:
  boundingbox(::Any, ::Function) at /home/runner/.julia/packages/Makie/eziUH/src/layouting/boundingbox.jl:17
  boundingbox(::Any, ::Function, ::Symbol) at /home/runner/.julia/packages/Makie/eziUH/src/layouting/boundingbox.jl:17
  boundingbox(::Any) at /home/runner/.julia/packages/Makie/eziUH/src/layouting/boundingbox.jl:17
Stacktrace:
  [1] (::GraphMakie.var"#24#50"{Int64, MakieCore.Automatic})(::Tuple{Int64, Makie.GlyphCollection})
    @ GraphMakie ~/work/GraphMakie.jl/GraphMakie.jl/src/recipes.jl:259
  [2] iterate
    @ ./generator.jl:47 [inlined]
  [3] collect(itr::Base.Generator{Base.Iterators.Enumerate{Vector{Makie.GlyphCollection}}, GraphMakie.var"#24#50"{Int64, MakieCore.Automatic}})
    @ Base ./array.jl:681
  [4] map(f::Function, A::Base.Iterators.Enumerate{Vector{Makie.GlyphCollection}})
    @ Base ./abstractarray.jl:2323
  [5] #23
    @ ~/work/GraphMakie.jl/GraphMakie.jl/src/recipes.jl:256 [inlined]
  [6] #map#13
    @ ~/.julia/packages/Observables/YdEbO/src/Observables.jl:[570](https://github.com/MakieOrg/GraphMakie.jl/actions/runs/9045902924/job/24856138523?pr=183#step:6:573) [inlined]
  [7] map(::GraphMakie.var"#23#49", ::Observable{Vector{Makie.GlyphCollection}}, ::Observable{Any}, ::Observable{Any})
    @ Observables ~/.julia/packages/Observables/YdEbO/src/Observables.jl:570
  [8] plot!(gp::Plot{GraphMakie.graphplot, Tuple{SimpleDiGraph{Int64}}})
    @ GraphMakie ~/work/GraphMakie.jl/GraphMakie.jl/src/recipes.jl:255

xref MakieOrg/GraphMakie.jl#183

@hexaeder hexaeder added the bug label May 13, 2024
@ffreyer
Copy link
Collaborator

ffreyer commented May 13, 2024

boundingbox(plot, plot.markerspace[]) will give you a bounding box for the text plot with positions included, and string_boundingbox(glyph_collection, pos, rot) = unchecked_boundingbox(glyph_collection, pos, rot) will give you one without if you set pos = Point3d(0). The former is public, the latter still internal.

@hexaeder
Copy link
Contributor Author

Thank you! For now unchecked_boundingbox is a working replacement. Of course it would be nice to go to the documented API. boundingbox(plot, plot.markerspace[]) will still give me a bounding box for the entire text plot. What I need specifically is the bounding box for each individual label. Am I missing something?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants