2
2
# Licensed under the MIT License. See LICENSE in the project root.
3
3
# ------------------------------------------------------------------
4
4
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)
31
6
32
7
const ObservableVector{T} = Makie. Observable{<: AbstractVector{T} }
33
8
@@ -52,14 +27,20 @@ function vizgset!(plot, ::Type{<:𝔼}, ::Val{0}, ::Val, geoms::ObservableVector
52
27
end
53
28
54
29
function vizgset! (plot, :: Type{<:𝔼} , :: Val{1} , :: Val , geoms, colorant)
30
+ showpoints = plot[:showpoints ]
31
+
55
32
meshes = Makie. @lift discretize .($ geoms)
56
33
vizmany! (plot, meshes, colorant)
57
- showfacets1D! (plot, geoms)
34
+
35
+ if showpoints[]
36
+ vizfacets! (plot, geoms)
37
+ end
58
38
end
59
39
60
40
function vizgset! (plot, :: Type{<:𝔼} , :: Val{1} , :: Val , geoms:: ObservableVector{<:Ray} , colorant)
61
41
rset = plot[:object ]
62
42
segmentsize = plot[:segmentsize ]
43
+ showpoints = plot[:showpoints ]
63
44
64
45
Dim = embeddim (rset[])
65
46
@@ -71,13 +52,20 @@ function vizgset!(plot, ::Type{<:𝔼}, ::Val{1}, ::Val, geoms::ObservableVector
71
52
size = Makie. @lift 0.1 * $ segmentsize
72
53
Makie. arrows! (plot, orig, dirs, color= colorant, arrowsize= size)
73
54
74
- showfacets1D! (plot, geoms)
55
+ if showpoints[]
56
+ vizfacets! (plot, geoms)
57
+ end
75
58
end
76
59
77
60
function vizgset! (plot, :: Type{<:𝔼} , :: Val{2} , :: Val , geoms, colorant)
61
+ showsegments = plot[:showsegments ]
62
+
78
63
meshes = Makie. @lift discretize .($ geoms)
79
64
vizmany! (plot, meshes, colorant)
80
- showfacets2D! (plot, geoms)
65
+
66
+ if showsegments[]
67
+ vizfacets! (plot, geoms)
68
+ end
81
69
end
82
70
83
71
const PolygonLike = Union{Polygon,MultiPolygon}
@@ -104,29 +92,63 @@ function vizgset!(plot, ::Type{<:𝔼}, ::Val{3}, ::Val, geoms, colorant)
104
92
vizmany! (plot, meshes, colorant)
105
93
end
106
94
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)
109
105
pointmarker = plot[:pointmarker ]
110
106
pointcolor = plot[:pointcolor ]
111
107
pointsize = plot[:pointsize ]
112
108
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)
119
113
end
120
114
121
- function showfacets2D! (plot, geoms)
122
- showsegments = plot[:showsegments ]
115
+ function vizgsetfacets! (plot, :: Type , :: Val{2} , :: Val , geoms)
123
116
segmentcolor = plot[:segmentcolor ]
124
117
segmentsize = plot[:segmentsize ]
125
118
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
131
153
end
132
154
end
0 commit comments