Skip to content

Commit 3040a1a

Browse files
authored
Merge pull request #623 from knorth55/write-to-png
add write-to-png in irtgraph
2 parents 1d16d77 + c4c9dbb commit 3040a1a

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

irteus/irtgraph.l

+16-1
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,22 @@ Args:
351351
;; fname finished with '.pdf', remove it
352352
(setq fname (subseq str 0 (1- (length str))))
353353
)))
354-
(send self :write-to-file fname result-path title))
354+
(send self :write-to-file fname result-path title "pdf"))
355+
(:write-to-png (fname &optional result-path
356+
(title (string-right-trim ".png" fname)))
357+
"write graph structure to png
358+
Args:
359+
fname: filename for output
360+
result-path: list of solver-node, it's result of (send solver :solve graph)
361+
title: title of graph
362+
"
363+
(when (substringp ".png" fname)
364+
(let ((str (string-right-trim "png" fname)))
365+
(when (= (elt str (1- (length str))) #\.)
366+
;; fname finished with '.png', remove it
367+
(setq fname (subseq str 0 (1- (length str))))
368+
)))
369+
(send self :write-to-file fname result-path title "png"))
355370
(:original-draw-mode ()
356371
"change draw-mode to original mode"
357372
(send self :draw-both-arc nil)

irteus/test/graph.l

+4
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,10 @@
267267
;; write graph to pdf file
268268
(warning-message 2 "write to /tmp/robots_in_jsk.pdf~%")
269269
(send g :write-to-pdf "/tmp/robots_in_jsk.pdf" nil "robots_in_jsk")
270+
271+
;; write graph to png file
272+
(warning-message 2 "write to /tmp/robots_in_jsk.png~%")
273+
(send g :write-to-png "/tmp/robots_in_jsk.png" nil "robots_in_jsk")
270274
g))
271275

272276
(eval-when (load eval)

0 commit comments

Comments
 (0)