Skip to content

Commit 92efb1e

Browse files
committed
consolidate printFactor
1 parent fdbf540 commit 92efb1e

File tree

2 files changed

+39
-47
lines changed

2 files changed

+39
-47
lines changed

src/services/CustomPrinting.jl

Lines changed: 38 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,3 @@
1-
##==============================================================================
2-
## Overloading show
3-
##==============================================================================
4-
# Base.show_default(io, v)
5-
Base.show(io::IO, ::MIME"text/plain", v::DFGVariable) = show(IOContext(io, :limit=>true, :compact=>true), v)
6-
7-
function Base.show(io::IO, ::MIME"text/plain", f::DFGFactor)
8-
# show(IOContext(io, :limit=>true, :compact=>true), f)
9-
fctt = getFactorType(f)
10-
println(io, "$(typeof(f))")
11-
println(io, " Name: $(f.label)")
12-
println(io, " VariableOrder: $(getVariableOrder(f))")
13-
println(io, " multihypo: $(getSolverData(f).multihypo)") # FIXME #477
14-
println(io, " nullhypo: TBD")
15-
println(io, " solvable: $(f.solvable)")
16-
println(io, " timestamp: $(f.timestamp)")
17-
println(io, " nstime: $(f.nstime)")
18-
println(io, " tags: $(f.tags)")
19-
println(io, " Type: $(typeof(fctt))")
20-
println(io, " Fields: $(fieldnames(typeof(fctt)))")
21-
show(IOContext(io, :limit=>true, :compact=>true), fctt)
22-
end
23-
24-
function Base.show(io::IO, ::MIME"text/plain", dfg::AbstractDFG)
25-
summary(io, dfg)
26-
println(io, "\n UserId: ", dfg.userId)
27-
println(io, " RobotId: ", dfg.robotId)
28-
println(io, " SessionId: ", dfg.sessionId)
29-
println(io, " Description: ", dfg.description)
30-
println(io, " Nr variables: ", length(ls(dfg)))
31-
println(io, " Nr factors: ",length(lsf(dfg)))
32-
println(io, " User Data: ", keys(dfg.userData))
33-
println(io, " Robot Data: ", keys(dfg.robotData))
34-
println(io, " Session Data: ", keys(dfg.sessionData))
35-
end
36-
37-
38-
#default for Atom/Juno
39-
Base.show(io::IO, ::MIME"application/prs.juno.inline", x::Union{AbstractDFG, DFGVariable, DFGFactor}) = x
40-
41-
421
##==============================================================================
432
## Printing Variables and Factors
443
##==============================================================================
@@ -97,12 +56,19 @@ function printFactor(io::IO, vert::DFGFactor;
9756
ioc = IOContext(io, :limit=>limit, :compact=>compact)
9857

9958
if short
59+
fctt = getFactorType(vert)
10060
printstyled(ioc, summary(vert),"\n", bold=true)
101-
println(ioc, "label: ", vert.label)
102-
println(ioc, "timestamp: ", vert.timestamp)
103-
println(ioc, "tags: ", vert.tags)
104-
println(ioc, "solvable: ", vert.solvable)
105-
println(ioc, "VariableOrder: ", vert._variableOrderSymbols)
61+
println(ioc, " label: ", vert.label)
62+
println(ioc, " solvable: ", vert.solvable)
63+
println(ioc, " VariableOrder: ", vert._variableOrderSymbols)
64+
println(ioc, " multihypo: ", getSolverData(vert).multihypo) # FIXME #477
65+
println(ioc, " nullhypo: ", "see DFG #477")
66+
println(ioc, " timestamp: ", vert.timestamp)
67+
println(ioc, " nstime: ",vert.nstime)
68+
println(ioc, " tags: ", vert.tags)
69+
println(ioc, " Type: ", typeof(fctt))
70+
println(ioc, " Fields: ", fieldnames(typeof(fctt)))
71+
show(ioc, fctt)
10672
else
10773

10874
printstyled(ioc, summary(vert),"\n", bold=true, color=:blue)
@@ -140,3 +106,29 @@ Dev Notes
140106
printVariable(dfg::AbstractDFG, sym::Symbol) = print(getVariable(dfg, sym))
141107

142108
printNode(dfg::AbstractDFG, sym::Symbol) = isVariable(dfg,sym) ? printVariable(dfg, sym) : printFactor(dfg, sym)
109+
110+
111+
##==============================================================================
112+
## Overloading show
113+
##==============================================================================
114+
# Base.show_default(io, v)
115+
Base.show(io::IO, ::MIME"text/plain", v::DFGVariable) = show(IOContext(io, :limit=>true, :compact=>true), v)
116+
117+
Base.show(io::IO, ::MIME"text/plain", f::DFGFactor) = printFactor(io, f, short=true, limit=false)
118+
119+
function Base.show(io::IO, ::MIME"text/plain", dfg::AbstractDFG)
120+
summary(io, dfg)
121+
println(io, "\n UserId: ", dfg.userId)
122+
println(io, " RobotId: ", dfg.robotId)
123+
println(io, " SessionId: ", dfg.sessionId)
124+
println(io, " Description: ", dfg.description)
125+
println(io, " Nr variables: ", length(ls(dfg)))
126+
println(io, " Nr factors: ",length(lsf(dfg)))
127+
println(io, " User Data: ", keys(dfg.userData))
128+
println(io, " Robot Data: ", keys(dfg.robotData))
129+
println(io, " Session Data: ", keys(dfg.sessionData))
130+
end
131+
132+
133+
#default for Atom/Juno
134+
Base.show(io::IO, ::MIME"application/prs.juno.inline", x::Union{AbstractDFG, DFGVariable, DFGFactor}) = x

test/fileDFGTests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ using Test
5252

5353
retDFG = loadDFG!(copyDfg, filename)
5454
# TODO REMOVE test deprecation
55-
retDFG_ = loadDFG(filename, Main, copyDfg2) #, loaddir="/tmp")
55+
retDFG_ = loadDFG(filename, Main, copyDf2) #, loaddir="/tmp")
5656

5757
@test issetequal(ls(dfg), ls(retDFG))
5858
@test issetequal(lsf(dfg), lsf(retDFG))

0 commit comments

Comments
 (0)