diff --git a/plot-gui-lib/plot/private/gui/lazy-snip-types.rkt b/plot-gui-lib/plot/private/gui/lazy-snip-types.rkt index a42d59f6..5f6c37a3 100644 --- a/plot-gui-lib/plot/private/gui/lazy-snip-types.rkt +++ b/plot-gui-lib/plot/private/gui/lazy-snip-types.rkt @@ -19,9 +19,11 @@ (define-type Make-3D-Plot-Snip (-> (Instance Bitmap%) Plot-Parameters - (-> Boolean Real Real Positive-Integer Positive-Integer (Instance Bitmap%)) + (-> Boolean Real Real Positive-Integer Positive-Integer + (Values (Instance Bitmap%) (U #f (Instance 3D-Plot-Area%)))) Real Real + (U #f (Instance 3D-Plot-Area%)) Positive-Integer Positive-Integer (Instance Snip%))) diff --git a/plot-gui-lib/plot/private/gui/lazy-snip-untyped.rkt b/plot-gui-lib/plot/private/gui/lazy-snip-untyped.rkt index 809322ba..3e2dbf4d 100644 --- a/plot-gui-lib/plot/private/gui/lazy-snip-untyped.rkt +++ b/plot-gui-lib/plot/private/gui/lazy-snip-untyped.rkt @@ -20,10 +20,10 @@ (define (-make-3d-plot-snip init-bm saved-plot-parameters - make-bm angle altitude width height) + make-bm angle altitude area width height) (make-3d-plot-snip init-bm saved-plot-parameters - make-bm angle altitude width height)) + make-bm angle altitude area width height)) (define (-make-snip-frame snip width height label) (make-snip-frame snip width height label)) diff --git a/plot-gui-lib/plot/private/gui/plot3d.rkt b/plot-gui-lib/plot/private/gui/plot3d.rkt index 1c2494d6..7df274d6 100644 --- a/plot-gui-lib/plot/private/gui/plot3d.rkt +++ b/plot-gui-lib/plot/private/gui/plot3d.rkt @@ -93,7 +93,7 @@ ;; For 3D legend can be calculated once since we don't change the bounding box (define legend (get-legend-entry-list renderer-list bounds-rect)) - (: make-bm (-> Boolean Real Real Positive-Integer Positive-Integer (Instance Bitmap%))) + (: make-bm (-> Boolean Real Real Positive-Integer Positive-Integer (Values (Instance Bitmap%) (U #f (Instance 3D-Plot-Area%))))) (define (make-bm anim? angle altitude width height) (parameterize/group ([plot-parameters saved-plot-parameters] [plot-animating? (if anim? #t (plot-animating?))] @@ -124,11 +124,12 @@ (send area end-renderers) (send area end-plot) - bm)) + (values bm area))) + (define-values (bm area) (make-bm #f angle altitude width height)) (make-3d-plot-snip - (make-bm #f angle altitude width height) saved-plot-parameters - make-bm angle altitude width height))) + bm saved-plot-parameters + make-bm angle altitude area width height))) ;; =================================================================================================== ;; Plot to a frame diff --git a/plot-gui-lib/plot/private/gui/snip3d.rkt b/plot-gui-lib/plot/private/gui/snip3d.rkt index 6a5d93aa..324a05e8 100644 --- a/plot-gui-lib/plot/private/gui/snip3d.rkt +++ b/plot-gui-lib/plot/private/gui/snip3d.rkt @@ -17,20 +17,26 @@ (define 3d-plot-snip% (class plot-snip% (init init-bm saved-plot-parameters) - (init-field make-bm angle altitude width height) + (init-field make-bm angle altitude area width height) (inherit set-bitmap get-bitmap get-saved-plot-parameters - set-message stop-message set-message-center reset-message-timeout + set-message stop-message reset-message-timeout update-thread-running? set-update get-left-down-here?) (super-make-object init-bm saved-plot-parameters) + (define (set-message-center) + (match-define (vector x-mid y-mid) (rect-center (send area get-area-bounds-rect))) + (send this set-message-center x-mid y-mid)) + + (set-message-center) + (define/override (copy) (make-object this% (get-bitmap) (get-saved-plot-parameters) - make-bm angle altitude width height)) + make-bm angle altitude area width height)) (define mouse-x 0) (define mouse-y 0) @@ -58,8 +64,10 @@ (make-bm animating? angle altitude width height)]))) (λ (animating?) (draw-command animating? angle altitude width height)) (λ (rth) - (define new-bm (worker-thread-try-get rth)) + (define-values (new-bm new-area) + (worker-thread-try-get rth (λ () (values #f #f)))) (cond [(is-a? new-bm bitmap%) + (set! area new-area) (set-bitmap new-bm) (when (not (and (= last-angle angle) (= last-altitude altitude))) @@ -126,7 +134,7 @@ (when (not (and (= w width) (= h height))) (set! width w) (set! height h) - (set-message-center (* 1/2 w) (* 1/2 h)) + (set-message-center) (stop-message) (when (not (update-thread-running?)) (start-update-thread #t)) @@ -136,7 +144,7 @@ (define (make-3d-plot-snip init-bm saved-plot-parameters - make-bm angle altitude width height) + make-bm angle altitude area width height) (make-object 3d-plot-snip% init-bm saved-plot-parameters - make-bm angle altitude width height)) + make-bm angle altitude area width height)) diff --git a/plot-lib/plot/private/plot3d/plot-area.rkt b/plot-lib/plot/private/plot3d/plot-area.rkt index 550277d5..c480c13d 100644 --- a/plot-lib/plot/private/plot3d/plot-area.rkt +++ b/plot-lib/plot/private/plot3d/plot-area.rkt @@ -114,6 +114,7 @@ [get-z-far-ticks (-> (Listof tick))] [get-bounds-rect (-> Rect)] [get-clip-rect (-> Rect)] + [get-area-bounds-rect (-> Rect)] [get-render-tasks (-> render-tasks)] [set-render-tasks (-> render-tasks Void)] [start-plot (-> Void)] @@ -969,6 +970,9 @@ (define area-y-min top) (define area-y-max (- dc-y-size bottom)) + (define/public (get-area-bounds-rect) + (vector (ivl area-x-min area-x-max) (ivl area-y-min area-y-max))) + ;; =============================================================================================== ;; Plot decoration