Changed PDF/PS backend to use 1.0 x 1.0 scaling

This makes plotting to a file the same (well, with slight differences)
regardless of file format. Scaling and other PS options are controlled
by a `plot-ps-setup' parameter. Not sure how useful that is, yet, so
it's undocumented.
This commit is contained in:
Neil Toronto 2014-04-02 23:16:49 -06:00
parent c1550b673b
commit efc46ded6d
4 changed files with 25 additions and 14 deletions

View File

@ -3,6 +3,7 @@
;; Parameters that control the look and behavior of plots.
(require racket/contract unstable/parameter-group unstable/latent-contract/defthing
racket/class racket/draw
"contract.rkt"
"draw.rkt"
"axis-transform.rkt"
@ -107,11 +108,17 @@
;; Output
(define default-plot-ps-setup (new ps-setup%))
(send default-plot-ps-setup set-margin 0 0)
(send default-plot-ps-setup set-scaling 1 1)
(defparam plot-new-window? boolean? #f)
(defparam plot-jpeg-quality (integer-in 0 100) 100)
(defparam plot-ps/pdf-interactive? boolean? #f)
(defparam plot-ps-setup (is-a?/c ps-setup%) default-plot-ps-setup)
(define-parameter-group plot-output (plot-new-window? plot-jpeg-quality plot-ps/pdf-interactive?))
(define-parameter-group plot-output
(plot-new-window? plot-jpeg-quality plot-ps/pdf-interactive? plot-ps-setup))
;; Labels

View File

@ -28,7 +28,7 @@
plot3d-samples
plot3d-angle plot3d-altitude
plot3d-ambient-light plot3d-diffuse-light? plot3d-specular-light?
plot-new-window? plot-jpeg-quality plot-ps/pdf-interactive?
plot-new-window? plot-jpeg-quality plot-ps/pdf-interactive? plot-ps-setup
plot-title
plot-x-label plot-y-label plot-z-label
plot-x-far-label plot-y-far-label plot-z-far-label

View File

@ -112,12 +112,14 @@
[(ps pdf svg)
(define dc
(case real-kind
[(ps) (new post-script-dc%
[interactive (plot-ps/pdf-interactive?)] [parent #f] [use-paper-bbox #f]
[as-eps #t] [width width] [height height] [output output])]
[(pdf) (new pdf-dc%
[interactive (plot-ps/pdf-interactive?)] [parent #f] [use-paper-bbox #f]
[width width] [height height] [output output])]
[(ps) (parameterize ([current-ps-setup (plot-ps-setup)])
(new post-script-dc%
[interactive (plot-ps/pdf-interactive?)] [parent #f] [use-paper-bbox #f]
[as-eps #t] [width width] [height height] [output output]))]
[(pdf) (parameterize ([current-ps-setup (plot-ps-setup)])
(new pdf-dc%
[interactive (plot-ps/pdf-interactive?)] [parent #f] [use-paper-bbox #f]
[width width] [height height] [output output]))]
[(svg) (new svg-dc%
[width width] [height height] [output output] [exists 'truncate/replace])]))
(define-values (x-scale y-scale) (send dc get-device-scale))

View File

@ -129,12 +129,14 @@
[(ps pdf svg)
(define dc
(case real-kind
[(ps) (new post-script-dc%
[interactive (plot-ps/pdf-interactive?)] [parent #f] [use-paper-bbox #f]
[as-eps #t] [width width] [height height] [output output])]
[(pdf) (new pdf-dc%
[interactive (plot-ps/pdf-interactive?)] [parent #f] [use-paper-bbox #f]
[width width] [height height] [output output])]
[(ps) (parameterize ([current-ps-setup (plot-ps-setup)])
(new post-script-dc%
[interactive (plot-ps/pdf-interactive?)] [parent #f] [use-paper-bbox #f]
[as-eps #t] [width width] [height height] [output output]))]
[(pdf) (parameterize ([current-ps-setup (plot-ps-setup)])
(new pdf-dc%
[interactive (plot-ps/pdf-interactive?)] [parent #f] [use-paper-bbox #f]
[width width] [height height] [output output]))]
[(svg) (new svg-dc%
[width width] [height height] [output output] [exists 'truncate/replace])]))
(define-values (x-scale y-scale) (send dc get-device-scale))