-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* MakieExt * Support plot * Add disk/circle plotting * Add 3D plots and fix plotting * start tests and Point support * Update tests * Update test_makieext.jl * Update DomainSetsMakieExt.jl * v0.7.13
- Loading branch information
1 parent
1cbe675
commit 4e36278
Showing
6 changed files
with
105 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ | |
*.jl.mem | ||
Manifest.toml | ||
/docs/build/ | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using DomainSets, StaticArrays | ||
using CairoMakie: plot, plot! | ||
using DomainSets: Sphere | ||
|
||
|
||
## | ||
# 2D | ||
## | ||
p = plot((0..1) × (1..2)) | ||
plot!(UnitDisk()) | ||
plot!(Sphere(2.0, SVector(1.0, 0.5))) | ||
plot!(Sphere(3.0, [1.0, 0.5])) | ||
plot!(Point(SVector(2,3))) | ||
p | ||
|
||
|
||
|
||
## | ||
# 3D | ||
## | ||
p = plot((0..1) × (1..2) × (3..4)) | ||
plot!(UnitBall()) | ||
plot!(Sphere(2.0, SVector(1.0, 0.5,0.5))) | ||
plot!(Sphere(3.0, [1.0, 0.5,0.5])) | ||
p |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
module DomainSetsMakieExt | ||
using DomainSets | ||
using DomainSets.StaticArrays | ||
import Makie | ||
using DomainSets: leftendpoint, rightendpoint, Rectangle, HyperRectangle, Point, DomainPoint, pointval, point | ||
import Makie: Point2f, Rect, Circle, Poly, Lines, convert_arguments, HyperSphere, Vec, Scatter, PointBased | ||
import Base: convert | ||
|
||
function convert(::Type{Makie.HyperRectangle}, r::Rectangle{<:SVector{N}}) where N | ||
l = leftendpoint(r) | ||
r = rightendpoint(r) | ||
Rect(convert(Vec{N}, l), convert(Vec{N}, r .- l)) | ||
end | ||
|
||
convert(::Type{<:HyperSphere}, r::Union{Sphere{SVector{N,T}},Ball{SVector{N,T}}}) where {N,T} = HyperSphere{N,T}(Point(center(r)), radius(r)) | ||
|
||
function convert(::Type{<:HyperSphere}, r::Union{Sphere{<:AbstractVector{T}}, Ball{<:AbstractVector{T}}}) where T | ||
N = length(center(r)) | ||
HyperSphere{N,T}(Makie.Point{N}(center(r)), radius(r)) | ||
end | ||
|
||
convert(::Type{<:Makie.Point}, r::Point) = Makie.Point(pointval(r)) | ||
convert(::Type{<:Makie.Point}, r::DomainPoint) = convert(Makie.Point, point(r)) | ||
|
||
convert_arguments(::Type{Plt}, r::HyperRectangle; kwds...) where Plt <: Poly = convert_arguments(Plt, convert(Makie.HyperRectangle, r); kwds...) | ||
convert_arguments(::Type{Plt}, r::Ball; kwds...) where Plt <: Poly = convert_arguments(Plt, convert(HyperSphere, r); kwds...) | ||
convert_arguments(::Type{Plt}, r::Sphere; kwds...) where Plt <: Lines = convert_arguments(Plt, convert(HyperSphere, r); kwds...) | ||
convert_arguments(::Type{Plt}, r::Point; kwds...) where Plt <: Scatter = convert_arguments(Plt, convert(Makie.Point, r); kwds...) | ||
|
||
|
||
|
||
Makie.plottype(a::HyperRectangle) = Poly | ||
Makie.plottype(a::Sphere) = Lines | ||
Makie.plottype(a::Ball) = Poly | ||
Makie.plottype(a::Union{DomainPoint,Point}) = Scatter | ||
|
||
end # module |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
module DomainSetsMakieTests | ||
using DomainSets, StaticArrays, Test | ||
import Makie | ||
import Makie: plot, Poly, Lines, Scatter | ||
using DomainSets: Sphere, × | ||
|
||
@testset "Plotting" begin | ||
@testset "2D" begin | ||
@test plot((0..1) × (1..2)).plot isa Poly | ||
@test plot(UnitCircle()).plot isa Lines | ||
@test plot(UnitDisk()).plot isa Poly | ||
@test plot(Sphere(2.0, SVector(1.0, 0.5))).plot isa Lines | ||
@test plot(Sphere(3.0, [1.0, 0.5])).plot isa Lines | ||
@test plot(Point(SVector(0.1,0.2))).plot isa Scatter | ||
end | ||
|
||
@testset "3D" begin | ||
@test plot((0..1) × (1..2) × (3..4)).plot isa Poly | ||
@test plot(UnitBall()).plot isa Poly | ||
@test plot(Sphere(2.0, SVector(1.0, 0.5,0.5))).plot isa Lines | ||
@test plot(Sphere(3.0, [1.0, 0.5,0.5])).plot isa Lines | ||
end | ||
end | ||
end # module |
4e36278
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JuliaRegistrator register
4e36278
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Registration pull request created: JuliaRegistries/General/105849
Tip: Release Notes
Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.
To add them here just re-invoke and the PR will be updated.
Tagging
After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.
This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via: