From c9c290dd139941dfc72826b6854607c0c304f7ca Mon Sep 17 00:00:00 2001 From: "attila.lendvai" Date: Wed, 22 Feb 2006 17:10:26 -0500 Subject: [PATCH] Some graphviz related changes darcs-hash:20060222221026-6b9e8-cca3d7e3855a6df4f6eb7b37da544dc8a5c8b829.gz --- dev/graphviz/graphviz-support-optional.lisp | 2 +- dev/graphviz/graphviz-support.lisp | 22 +++++++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/dev/graphviz/graphviz-support-optional.lisp b/dev/graphviz/graphviz-support-optional.lisp index cdc1626..9b4c2f1 100644 --- a/dev/graphviz/graphviz-support-optional.lisp +++ b/dev/graphviz/graphviz-support-optional.lisp @@ -31,7 +31,7 @@ loaded when cl-graphviz is available. :graph-visitor (lambda (dot-graph) (setf (dot-attribute-value :bb g) - (graphviz:graph-bounding-box dot-graph))) + (graphviz:graph-bounding-box dot-graph))) :node-visitor (lambda (node) diff --git a/dev/graphviz/graphviz-support.lisp b/dev/graphviz/graphviz-support.lisp index a974d64..99b8f7b 100644 --- a/dev/graphviz/graphviz-support.lisp +++ b/dev/graphviz/graphviz-support.lisp @@ -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,6 +265,7 @@ B--D [] '((:pos coordinate) (:height float) (:width float) + (:margin float) (:fixed-size boolean) (:label text) (:shape (:record :plaintext :ellipse :circle :egg :triangle :box @@ -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" -- 1.7.10.4