X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=dev%2Fgraphviz%2Fgraphviz-support.lisp;h=0bc981e40c3decb225fe365b6a0feb531a3ec9f1;hb=2d52d1e533a3c73bffd2dd81620cc5bd540c314a;hp=a8e7ee72398a47fb78fb085feedabbae211ca6a2;hpb=1fe64e8b966450697100fae6ec35cc5688a88bd6;p=cl-graph.git diff --git a/dev/graphviz/graphviz-support.lisp b/dev/graphviz/graphviz-support.lisp index a8e7ee7..0bc981e 100644 --- a/dev/graphviz/graphviz-support.lisp +++ b/dev/graphviz/graphviz-support.lisp @@ -61,7 +61,7 @@ This file contains the stuff that does not depend on cl-graphviz. (princ " [" stream) (when (and directed? directed-edge-tag) (princ directed-edge-tag stream)) - (when edge-key + (when edge-labeler (princ "label=\"" stream) (funcall edge-labeler e stream) (princ "\"," stream)) @@ -244,6 +244,7 @@ B--D [] '((:size coordinate) (:bb bounding-box) (:page text) + (:dpi float) (:ratio (:fill :compress :auto)) ;; Could actually be a float number too (:margin float) (:nodesep float) @@ -264,7 +265,8 @@ B--D [] '((:pos coordinate) (:height float) (:width float) - (:fixed-size boolean) + (:margin float) + (:fixedsize boolean) (:label text) (:shape (:record :plaintext :ellipse :circle :egg :triangle :box :diamond :trapezium :parallelogram :house :hexagon :octagon @@ -347,6 +349,22 @@ B--D [] (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"))) + `(progn + (export ',actual-name) + (defmethod ,actual-name ((thing ,type)) + "Return the attribute in pixels assuming 72 dpi" + (awhen (dot-attribute-value ,attr thing) + (* 72 it))) + (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)))))) + +(defpixel-inch-accessors width :width dot-vertex-mixin) +(defpixel-inch-accessors height :height dot-vertex-mixin) + + (defmethod graph->dot-properties ((graph dot-graph-mixin) (stream t)) (loop for (name value) on (dot-attributes graph) by #'cddr do @@ -429,7 +447,9 @@ B--D [] ((member text) (textify value)) ((member float) - (coerce value 'single-float)) + ;; graphviz does not support the 1.2e-3 format + (with-output-to-string (str) + (format str "~,f" (coerce value 'single-float)))) (list (unless (member value value-type :test 'equal) (error "Invalid value for ~S: ~S is not one of ~S"