From f3a4106854fd4fb1bcdd070236c49755029e7fff Mon Sep 17 00:00:00 2001 From: dehann Date: Wed, 8 Aug 2018 17:38:29 -0400 Subject: [PATCH] fix issue #118 --- src/FactorGraph01.jl | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/FactorGraph01.jl b/src/FactorGraph01.jl index d66489cc8..6ece91012 100644 --- a/src/FactorGraph01.jl +++ b/src/FactorGraph01.jl @@ -832,14 +832,22 @@ function drawCopyFG(fgl::FactorGraph) return fgd end -function writeGraphPdf(fgl::FactorGraph, evince::Bool=true) +function writeGraphPdf(fgl::FactorGraph; + pdfreader::Union{Void, String}="evince", + filename::AS="/tmp/fg.pdf" ) where {AS <: AbstractString} + # fgd = drawCopyFG(fgl) println("Writing factor graph file") fid = open("/tmp/fg.dot","w+") write(fid,Graphs.to_dot(fgd.g)) close(fid) - run(`dot /tmp/fg.dot -Tpdf -o /tmp/fg.pdf`) - evince ? (@async run(`evince /tmp/fg.pdf`)) : nothing + dotfile = split(filename, ".pdf")[1]*".dot" + run(`dot $(dotfile) -Tpdf -o $(filename)`) + try + pdfreader != nothing ? (@async run(`$(pdfreader) $(filename)`)) : nothing + catch e + warn("not able to show $(filename) with pdfreader=$(pdfreader).") + end nothing end