Makie Basic Overloads for Composite Type

I have a simple composite type I use to keep track of a 3D vector that looks like this.

abstract type AbstractVec{T<:Number} end

" xyzVecT is the object definition to contain the cartesian information "
struct xyzVecT{T} <:AbstractVec{T}

It was one of the first custom types I made learning Julia, so I’ve gradually been trying to make it work with the more advanced packages like diffeqs and makie, etc. I thought I had it working with Makie, until I tried to Makie it also work with Symbolics and I think I’ve broken something. At the same time I started breaking things out into Package extensions, but that shouldn’t matter for this case.

So my first thought is, there is probably instruction out there that kind of tells how to do this generically, but I haven’t found it and the piece of Makie that I’m getting stuck on is convert_single_argument as there are very few words and no examples written about it in the Recipes manual for Makie.

I had tried to “overload” the Point3 function in geometry basics because I had done some things incorrectly and this is called by my convert_single_argument.

GeometryBasics.Point3(v::xyzVecT{T}) where {T<:AbstractFloat} = GeometryBasics.Point3{T}(v.x, v.y, v.z)
MakieCore.convert_single_argument(v::xyzVecT{T}) where T<:AbstractFloat = GeometryBasics.Point3{T}(v)

One thing that isn’t clear is, do I really need a version of convert_single_argument that takes a vector and not a single point or do I define the single point and it automatically can handle a vector version of it. I’m thinking I need to make it recognize a Vector case.

But I think in general I need to figure out why this doesn’t work.

    @show decompose(Point3f,x1)

MethodError: no method matching coordinates(::xyzVector.xyzVecT{Float64})

Any good guides on how to build up custom composite types to work correctly with all of these tools. I’m not quite getting it from the “recipes” tutorial in Makie.

Thanks again for the noob questions.


If you actually want a Point3D type, you probably want to subtype a FieldVector from StaticArrays:

struct Point3D{T} <: FieldVector{3,T}

and you’ll get all (most?) of what you want. But I’m not answering the other specific details, for sure.

I started all this before static arrays was really as big a deal as it is now and before fieldvectors were available, so I’m not ready to abandon what I’m doing yet. What I have is kind of backwards compatible with some pre-existing MATLAB and C++ codes and works with other libraries I have that were based on some of these conversions. I also wanted it to be as efficient as possible for this type of thing. Maybe one day I’ll swap them out if the Static Arrays is any faster.

1 Like

What am I missing?

import MakieCore
import MakieCore: convert_single_argument

MakieCore.convert_single_argument(v::xyzVecT{T}) where T<:AbstractFloat = GeometryBasics.Point3{T}(v)

WARNING: could not import MakieCore.convert_single_argument into xyzVectorMakieExt
ERROR: LoadError: UndefVarError: convert_single_argument not defined

I don’t know why I got off on decompose here. I didn’t really know what it was for in the examples. I don’t think I can decompose a vector into coordinates or faces since it is only a single point. Perhaps it needs to be an array of these xyzVecT’s to decompose.

So I went to go look to see why MakieCore didn’t have convert_single_argument like the documentation implied, and it says it is depreciated. So I switched this dependency to Makie and it appears to work fine. Not sure what the documentation is supposed to say.