forked from torch/graph
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
11 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |