Skip to content

Commit

Permalink
plot to file
Browse files Browse the repository at this point in the history
  • Loading branch information
koraykv committed Apr 2, 2013
1 parent a39b936 commit c83aad0
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions utils.lua
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@

require 'qtsvg'

function graph.dot(g)
function graph.dot(g,fname)
local gv = g:todot()
local fngv = os.tmpname()
local fngv = (fname or os.tmpname()) .. '.dot'
local fgv = io.open(fngv,'w')
fgv:write(gv)
fgv:close()
local fnsvg = os.tmpname()
local fnsvg = (fname or os.tmpname()) .. '.svg'
os.execute('dot -Tsvg -o ' .. fnsvg .. ' ' .. fngv)
local qs = qt.QSvgWidget(fnsvg)
qs:show()
os.remove(fngv)
os.remove(fnsvg)
-- print(fngv,fnpng)
return qs
if not fname then
local qs = qt.QSvgWidget(fnsvg)
qs:show()
os.remove(fngv)
os.remove(fnsvg)
-- print(fngv,fnpng)
return qs
end
end

0 comments on commit c83aad0

Please sign in to comment.