diff options
author | Thomas White <taw@physics.org> | 2023-11-03 11:37:40 +0100 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2024-02-06 16:59:34 +0100 |
commit | 5d9308e7ded065be506f1bb32e49c073eac85686 (patch) | |
tree | 2f0ad31bac99ddbf2087da62578bc5c4d8ac5740 /julia | |
parent | a6979502fec6d886db320db36b6e4e58bfb21ebc (diff) |
Julia: show/print/display methods for RefList and SymOpList
Diffstat (limited to 'julia')
-rw-r--r-- | julia/CrystFEL/src/reflists.jl | 14 | ||||
-rw-r--r-- | julia/CrystFEL/src/symmetry.jl | 12 |
2 files changed, 21 insertions, 5 deletions
diff --git a/julia/CrystFEL/src/reflists.jl b/julia/CrystFEL/src/reflists.jl index 09e333b6..65912e32 100644 --- a/julia/CrystFEL/src/reflists.jl +++ b/julia/CrystFEL/src/reflists.jl @@ -1,17 +1,21 @@ module RefLists import ..CrystFEL: libcrystfel -import ..CrystFEL.Symmetry: SymOpList, InternalSymOpList - +import ..CrystFEL.Symmetry: SymOpList, InternalSymOpList, symmetry_name export RefList, loadreflist + +# The internal libcrystfel structure, not exposed directly mutable struct InternalRefList end + +# The Julian exposed type mutable struct RefList internalptr::Ptr{InternalRefList} symmetry::SymOpList end + function loadreflist(filename::AbstractString) psym = Ref{Cstring}() @@ -27,4 +31,10 @@ function loadreflist(filename::AbstractString) end + +function Base.show(io::IO, ::MIME"text/plain", reflist::RefList) + write(io, "Reflection list in point group ", symmetry_name(reflist.symmetry)) +end + + end # of module diff --git a/julia/CrystFEL/src/symmetry.jl b/julia/CrystFEL/src/symmetry.jl index eddf9a18..fd3ce7b2 100644 --- a/julia/CrystFEL/src/symmetry.jl +++ b/julia/CrystFEL/src/symmetry.jl @@ -2,6 +2,7 @@ module Symmetry import ..CrystFEL: libcrystfel export SymOpList, InternalSymOpList, InternalIntegerMatrix +export symmetry_name # Types for pointers returned by libcrystfel @@ -99,14 +100,19 @@ function Base.iterate(sym::SymOpList, i) end -function Base.show(io::IO, sym::SymOpList) - println(io, length(sym), "-element SymOpList (\"", symmetry_name(sym), "\")") +function Base.show(io::IO, ::MIME"text/plain", sym::SymOpList) + print(io, length(sym), "-element SymOpList (\"", symmetry_name(sym), "\")") for op in sym - println(io, hkl_op(op)) + print(io, "\n", hkl_op(op)) end end +function Base.show(io::IO, sym::SymOpList) + write(io, "SymOpList(\"", symmetry_name(sym), "\")") +end + + function Base.show(io::IO, op::SymOp) write(io, "SymOp(") write(io, "\"") |