Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion plot-gui-lib/plot/private/gui/lazy-snip-types.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -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%)))
Expand Down
4 changes: 2 additions & 2 deletions plot-gui-lib/plot/private/gui/lazy-snip-untyped.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -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))
9 changes: 5 additions & 4 deletions plot-gui-lib/plot/private/gui/plot3d.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -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?))]
Expand Down Expand Up @@ -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
Expand Down
22 changes: 15 additions & 7 deletions plot-gui-lib/plot/private/gui/snip3d.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)))
Expand Down Expand Up @@ -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))
Expand All @@ -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))
4 changes: 4 additions & 0 deletions plot-lib/plot/private/plot3d/plot-area.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -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

Expand Down