X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=dev%2Fgraphviz%2Fgraphviz-support.lisp;h=1ea586a6f170b13fe09249605a91adeb232395af;hb=7090c13854c379b6eb139bea25d873fe2a5eb668;hp=0bc981e40c3decb225fe365b6a0feb531a3ec9f1;hpb=9caae8213191b49474654a15d4c69cfec459c2e5;p=cl-graph.git diff --git a/dev/graphviz/graphviz-support.lisp b/dev/graphviz/graphviz-support.lisp index 0bc981e..1ea586a 100644 --- a/dev/graphviz/graphviz-support.lisp +++ b/dev/graphviz/graphviz-support.lisp @@ -2,9 +2,7 @@ #| simple-header -$Id: graphviz-support.lisp,v 1.7 2005/06/21 20:51:51 moody Exp $ - -Author: Gary King, Levente Mészáros, Attila Lendvai +Author: Gary King, Levente Mészáros, Attila Lendvai DISCUSSION @@ -20,15 +18,16 @@ This file contains the stuff that does not depend on cl-graphviz. ; "GRAPHVIZ". ; (defmethod graph->dot ((g basic-graph) (stream stream) - &key + &key (graph-formatter 'graph->dot-properties) (vertex-key 'vertex-id) (vertex-labeler nil) (vertex-formatter 'vertex->dot) - (edge-key nil) (edge-labeler 'princ) - (edge-formatter 'edge->dot)) - (format stream "~A G {~%graph " (if (contains-undirected-edge-p g) "graph" "digraph")) + (edge-formatter 'edge->dot) + &allow-other-keys) + (format stream "~A G {~%graph " + (if (contains-undirected-edge-p g) "graph" "digraph")) (format stream "[") (funcall graph-formatter g stream) (format stream "];") @@ -250,6 +249,7 @@ B--D [] (:nodesep float) (:ranksep float) (:ordering (:out)) + (:overlap text) (:rankdir ("LR" "RL" "BT")) (:pagedir text) (:rank (:same :min :max)) @@ -259,14 +259,15 @@ B--D [] (:mclimit float) (:layers text) (:color text) - (:bgcolor text))) + (:bgcolor text) + (:fontname text))) (defparameter *dot-vertex-attributes* '((:pos coordinate) (:height float) (:width float) (:margin float) - (:fixedsize boolean) + (:fixed-size boolean) (:label text) (:shape (:record :plaintext :ellipse :circle :egg :triangle :box :diamond :trapezium :parallelogram :house :hexagon :octagon @@ -278,7 +279,8 @@ B--D [] (:fillcolor text) (:style (:filled :solid :dashed :dotted :bold :invis)) (:layer text) - (:url text))) + (:url text) + (:peripheries integer))) (defparameter *dot-edge-attributes* '((:pos spline) @@ -339,27 +341,30 @@ B--D [] (:export-p t)) -(defmethod (setf dot-attribute-value) :before (value (attr symbol) (thing dot-attributes-mixin)) +(defmethod (setf dot-attribute-value) + :before (value (attr symbol) (thing dot-attributes-mixin)) (declare (ignore value)) (ensure-valid-dot-attribute attr thing)) -(defmethod (setf dot-attribute-value) (value (attr symbol) (thing dot-attributes-mixin)) +(defmethod (setf dot-attribute-value) + (value (attr symbol) (thing dot-attributes-mixin)) (setf (getf (dot-attributes thing) attr) value)) (defmethod dot-attribute-value ((attr symbol) (thing dot-attributes-mixin)) (getf (dot-attributes thing) attr)) (defmacro defpixel-inch-accessors (name attr type) - (bind ((actual-name (form-symbol name "-IN-PIXELS"))) + (let ((actual-name (form-symbol name (symbol-name '-in-pixels)))) `(progn - (export ',actual-name) + (eval-always (export ',actual-name)) (defmethod ,actual-name ((thing ,type)) "Return the attribute in pixels assuming 72 dpi" - (awhen (dot-attribute-value ,attr thing) - (* 72 it))) + (when (dot-attribute-value ,attr thing) + (* 72 (dot-attribute-value ,attr thing)))) (defmethod (setf ,actual-name) (value (thing ,type)) "Set the attribute in pixels assuming 72 dpi" - (setf (dot-attribute-value ,attr thing) (coerce (/ value 72) 'double-float)))))) + (setf (dot-attribute-value ,attr thing) + (coerce (/ value 72) 'double-float)))))) (defpixel-inch-accessors width :width dot-vertex-mixin) (defpixel-inch-accessors height :height dot-vertex-mixin) @@ -494,8 +499,10 @@ B--D [] (defmethod graph->dot-external ((g basic-graph) file-name &key (type :ps)) "Generate an external represenation of a graph to a file, by running the program in *dot-path*." + (declare (ignorable file-name)) (let ((dot-string (graph->dot g nil)) (dot-type (concatenate 'string "-T" (string-downcase (symbol-name type))))) + (declare (ignorable dot-string dot-type)) #+lispworks (with-open-stream (s (sys:open-pipe (concatenate 'string *dot-path* " -Tpng -o" file-name) :direction :input)) @@ -510,10 +517,10 @@ the program in *dot-path*." #-(or sbcl lispworks) (error "Don't know how to execute a program on this platform"))) -;;; --------------------------------------------------------------------------- -; +;;; ; Test dot external -; + +#+test (defun test-dot-external () (let* ((g (make-graph 'dot-graph)) (v1 (add-vertex g 'a :dot-attributes '(:shape :box