Skip to content

Commit a04c149

Browse files
authored
Merge pull request #461 from JuliaRobotics/feature/20Q2/showplot
html DFG plotting on display
2 parents d967711 + 526c45d commit a04c149

File tree

3 files changed

+44
-2
lines changed

3 files changed

+44
-2
lines changed

src/CloudGraphsDFG/entities/CloudGraphsDFG.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ function CloudGraphsDFG{T}(host::String,
5757
end
5858

5959

60-
function show(io::IO, c::CloudGraphsDFG)
60+
function show(io::IO, ::MIME"text/plain", c::CloudGraphsDFG)
6161
println(io, "CloudGraphsDFG:")
6262
println(io, " - Neo4J instance: $(c.neo4jInstance.connection.host)")
6363
println(io, " - Session: $(c.userId):$(c.robotId):$(c.sessionId)")

src/DFGPlots/DFGPlots.jl

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,4 +96,46 @@ function gplot(dfg::LightDFG; keyargs...)
9696
gplot(dfg.g; keyargs...)
9797
end
9898

99+
100+
function Base.show(io::IO, ::MIME"application/prs.juno.plotpane+html", dfg::AbstractDFG)
101+
size = get(io, :juno_plotsize, [100, 100])
102+
103+
plot_output = IOBuffer()
104+
draw(SVGJS(plot_output, GraphPlot.Compose.default_graphic_width,
105+
GraphPlot.Compose.default_graphic_width, false), dfgplot(dfg))
106+
plotsvg = String(take!(plot_output))
107+
108+
print(io,
109+
"""
110+
<div style="
111+
background-color: #eee;
112+
color: #222;
113+
width: $(size[1]-40)px;
114+
height: $(size[2]-40)px;
115+
position: absolute;
116+
top: 0;
117+
left: 0;
118+
padding: 20px;
119+
margin: 0;
120+
">
121+
$(typeof(dfg))
122+
<ul>
123+
<li>$(dfg.userId)</li>
124+
<li>$(dfg.robotId)</li>
125+
<li>$(dfg.sessionId)</li>
126+
<li>$(dfg.description)</li>
127+
</ul>
128+
<script charset="utf-8">
129+
$(read(Compose.snapsvgjs, String))
130+
</script>
131+
<script charset="utf-8">
132+
$(read(GraphPlot.gadflyjs, String))
133+
</script>
134+
$(plotsvg)
135+
</div>
136+
""")
137+
138+
end
139+
140+
99141
end

src/LightDFG/FactorGraphs/FactorGraphs.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ FactorGraph() = FactorGraph{Int, AbstractVariableType, AbstractFactorType}()
6464
# FactorGraph{V,F}() where {V <: AbstractVariableType, F <: AbstractFactorType} = FactorGraph{Int, V, F}()
6565

6666

67-
function show(io::IO, g::FactorGraph)
67+
function show(io::IO, ::MIME"text/plain", g::FactorGraph)
6868
dir = is_directed(g) ? "directed" : "undirected"
6969
print(io, "{$(nv(g)), $(ne(g))} $dir $(eltype(g)) $(typeof(g))")
7070
end

0 commit comments

Comments
 (0)