22# Licensed under the MIT License. See LICENSE in the project root.
33# ------------------------------------------------------------------
44
5- function Makie. plot! (plot:: Viz{<:Tuple{GeometrySet}} )
6- gset = plot[:object ]
7- color = plot[:color ]
8- alpha = plot[:alpha ]
9- colormap = plot[:colormap ]
10- colorrange = plot[:colorrange ]
11-
12- # process color spec into colorant
13- colorant = Makie. @lift process ($ color, $ colormap, $ colorrange, $ alpha)
14-
15- # get geometries
16- geoms = Makie. @lift parent ($ gset)
17-
18- # get geometry types
19- types = Makie. @lift unique (typeof .($ geoms))
20-
21- for G in types[]
22- inds = Makie. @lift findall (g -> g isa G, $ geoms)
23- gvec = Makie. @lift collect (G, $ geoms[$ inds])
24- colors = Makie. @lift $ colorant isa AbstractVector ? $ colorant[$ inds] : $ colorant
25- M = Makie. @lift manifold (first ($ gvec))
26- pdim = Makie. @lift paramdim (first ($ gvec))
27- edim = Makie. @lift embeddim (first ($ gvec))
28- vizgset! (plot, M[], Val (pdim[]), Val (edim[]), gvec, colors)
29- end
30- end
5+ Makie. plot! (plot:: Viz{<:Tuple{GeometrySet}} ) = vizgeoms! (plot)
316
327const ObservableVector{T} = Makie. Observable{<: AbstractVector{T} }
338
@@ -52,14 +27,20 @@ function vizgset!(plot, ::Type{<:𝔼}, ::Val{0}, ::Val, geoms::ObservableVector
5227end
5328
5429function vizgset! (plot, :: Type{<:𝔼} , :: Val{1} , :: Val , geoms, colorant)
30+ showpoints = plot[:showpoints ]
31+
5532 meshes = Makie. @lift discretize .($ geoms)
5633 vizmany! (plot, meshes, colorant)
57- showfacets1D! (plot, geoms)
34+
35+ if showpoints[]
36+ vizfacets! (plot, geoms)
37+ end
5838end
5939
6040function vizgset! (plot, :: Type{<:𝔼} , :: Val{1} , :: Val , geoms:: ObservableVector{<:Ray} , colorant)
6141 rset = plot[:object ]
6242 segmentsize = plot[:segmentsize ]
43+ showpoints = plot[:showpoints ]
6344
6445 Dim = embeddim (rset[])
6546
@@ -71,13 +52,20 @@ function vizgset!(plot, ::Type{<:𝔼}, ::Val{1}, ::Val, geoms::ObservableVector
7152 size = Makie. @lift 0.1 * $ segmentsize
7253 Makie. arrows! (plot, orig, dirs, color= colorant, arrowsize= size)
7354
74- showfacets1D! (plot, geoms)
55+ if showpoints[]
56+ vizfacets! (plot, geoms)
57+ end
7558end
7659
7760function vizgset! (plot, :: Type{<:𝔼} , :: Val{2} , :: Val , geoms, colorant)
61+ showsegments = plot[:showsegments ]
62+
7863 meshes = Makie. @lift discretize .($ geoms)
7964 vizmany! (plot, meshes, colorant)
80- showfacets2D! (plot, geoms)
65+
66+ if showsegments[]
67+ vizfacets! (plot, geoms)
68+ end
8169end
8270
8371const PolygonLike = Union{Polygon,MultiPolygon}
@@ -104,29 +92,63 @@ function vizgset!(plot, ::Type{<:𝔼}, ::Val{3}, ::Val, geoms, colorant)
10492 vizmany! (plot, meshes, colorant)
10593end
10694
107- function showfacets1D! (plot, geoms)
108- showpoints = plot[:showpoints ]
95+ vizfacets! (plot:: Viz{<:Tuple{GeometrySet}} ) = vizgeoms! (plot, facets= false )
96+
97+ function vizfacets! (plot:: Viz{<:Tuple{GeometrySet}} , geoms)
98+ M = Makie. @lift manifold (first ($ geoms))
99+ pdim = Makie. @lift paramdim (first ($ geoms))
100+ edim = Makie. @lift embeddim (first ($ geoms))
101+ vizgsetfacets! (plot, M[], Val (pdim[]), Val (edim[]), geoms)
102+ end
103+
104+ function vizgsetfacets! (plot, :: Type , :: Val{1} , :: Val , geoms)
109105 pointmarker = plot[:pointmarker ]
110106 pointcolor = plot[:pointcolor ]
111107 pointsize = plot[:pointsize ]
112108
113- if showpoints[]
114- # all boundaries are points or multipoints
115- points = Makie. @lift filter (! isnothing, boundary .($ geoms))
116- pset = Makie. @lift GeometrySet ($ points)
117- viz! (plot, pset, color= pointcolor, pointmarker= pointmarker, pointsize= pointsize)
118- end
109+ # all boundaries are points or multipoints
110+ points = Makie. @lift filter (! isnothing, boundary .($ geoms))
111+ pset = Makie. @lift GeometrySet ($ points)
112+ viz! (plot, pset, color= pointcolor, pointmarker= pointmarker, pointsize= pointsize)
119113end
120114
121- function showfacets2D! (plot, geoms)
122- showsegments = plot[:showsegments ]
115+ function vizgsetfacets! (plot, :: Type , :: Val{2} , :: Val , geoms)
123116 segmentcolor = plot[:segmentcolor ]
124117 segmentsize = plot[:segmentsize ]
125118
126- if showsegments[]
127- # all boundaries are 1D geometries
128- bounds = Makie. @lift filter (! isnothing, boundary .($ geoms))
129- bset = Makie. @lift GeometrySet ($ bounds)
130- viz! (plot, bset, color= segmentcolor, segmentsize= segmentsize)
119+ # all boundaries are 1D geometries
120+ bounds = Makie. @lift filter (! isnothing, boundary .($ geoms))
121+ bset = Makie. @lift GeometrySet ($ bounds)
122+ viz! (plot, bset, color= segmentcolor, segmentsize= segmentsize)
123+ end
124+
125+ function vizgeoms! (plot; facets= false )
126+ gset = plot[:object ]
127+ color = plot[:color ]
128+ alpha = plot[:alpha ]
129+ colormap = plot[:colormap ]
130+ colorrange = plot[:colorrange ]
131+
132+ # process color spec into colorant
133+ colorant = facets ? nothing : Makie. @lift (process ($ color, $ colormap, $ colorrange, $ alpha))
134+
135+ # get geometries
136+ geoms = Makie. @lift parent ($ gset)
137+
138+ # get geometry types
139+ types = Makie. @lift unique (typeof .($ geoms))
140+
141+ for G in types[]
142+ inds = Makie. @lift findall (g -> g isa G, $ geoms)
143+ gvec = Makie. @lift collect (G, $ geoms[$ inds])
144+ M = Makie. @lift manifold (first ($ gvec))
145+ pdim = Makie. @lift paramdim (first ($ gvec))
146+ edim = Makie. @lift embeddim (first ($ gvec))
147+ if facets
148+ vizgsetfacets! (plot, M[], Val (pdim[]), Val (edim[]), gvec)
149+ else
150+ cvec = Makie. @lift $ colorant isa AbstractVector ? $ colorant[$ inds] : $ colorant
151+ vizgset! (plot, M[], Val (pdim[]), Val (edim[]), gvec, cvec)
152+ end
131153 end
132154end
0 commit comments