home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
vis-ftp.cs.umass.edu
/
vis-ftp.cs.umass.edu.tar
/
vis-ftp.cs.umass.edu
/
pub
/
Software
/
ASCENDER
/
ascendMar8.tar
/
UMass
/
Epipolar
/
rcde-display.lisp
< prev
next >
Wrap
Lisp/Scheme
|
1996-03-05
|
6KB
|
146 lines
;;; RCDE-DISPLAY.LISP
;;;
;;; Interface to RCDE graphics routines
;;;
;;; Author: Robert T. Collins
;;; Date: Mar 4, 1995
;;;
;-----------------------------------------------------------------
; (c) Copyright 1995 by The University of Massachusetts
;------------------------------------------------------------------
(in-package 'cme)
(defvar *%%tmpvec* (cme::make-coordinate-vector 3))
(defmacro inline-transform (transform position &optional to-vector)
`(let ((transform ,transform)
(position ,position)
(to-vector ,to-vector) )
(unless to-vector (setf to-vector *%%tmpvec*))
(unless (vectorp position)
(setq position (cme::position-to-vector position to-vector )))
(if (null transform)
position
(cme::transform-vector transform position to-vector))))
(defmacro with-display-context ((var pane color thickness) &body body)
`(with-window-drawing-context (%dc% ,pane)
(ic::with-drawing-context-line-width (%dc% ,thickness)
(with-drawing-context-color (%dc% ,color)
(let ((,var %dc%))
,@body)))))
;;;;****************************************************************
;;;; DISPLAYING LINE TOKENSETS
(defun display-line-tokenset (view tks &key (color "YELLOW") (thickness 1))
"Display an ISR2 line tokenset (endpts are stored in 2D-world coords)."
(let ((transform (2d-to-window-transform view)))
(with-display-context (dc (view-window view) color thickness)
(isr2::for-every-token (tok tks (x1 y1 x2 y2))
(bind-vector-elements
(u1 v1)(inline-transform transform
(list (isr2::value x1) (isr2::value y1)))
(bind-vector-elements
(u2 v2)(inline-transform transform
(list (isr2::value x2) (isr2::value y2)))
(dc-draw-line dc u1 v1 u2 v2)))))))
(defun display-line (view x1 y1 x2 y2 &key (color "YELLOW") (thickness 1)
(transform (2d-to-window-transform view)))
"Display a line segment (specified in 2D-world coords)."
(with-display-context (dc (view-window view) color thickness)
(bind-vector-elements
(u1 v1)(inline-transform transform (list x1 y1))
(bind-vector-elements
(u2 v2)(inline-transform transform (list x2 y2))
(dc-draw-line dc u1 v1 u2 v2)))))
;;;;****************************************************************
;;;; ZOOMING DISPLAY WITH RESPECT TO A BOUNDING BOX
(defun zoom-in-around-pixel (view pixelx pixely)
"Zoom in using pixelx, pixely as zoom center point."
(cme::bind-vector-elements (xcenter ycenter)
(cme::inline-transform
(cme::inverse-transform (cme::image-to-2d-transform view))
(list pixelx pixely))
(ic::zoom-in view :x xcenter :y ycenter)))
(defun zoom-out-around-pixel (view pixelx pixely)
"Zoom out using pixelx, pixely as zoom center point."
(cme::bind-vector-elements (xcenter ycenter)
(cme::inline-transform
(cme::inverse-transform (cme::image-to-2d-transform view))
(list pixelx pixely))
(ic::zoom-out view :x xcenter :y ycenter)))
(defun center-around-pixel (view pixelx pixely)
"Center the view at pixelx, pixely."
(cme::bind-vector-elements (xcenter ycenter)
(cme::inline-transform
(cme::inverse-transform (cme::image-to-2d-transform view))
(list pixelx pixely))
(ic::set-image-position-at-window-center
view xcenter ycenter (cme::view-window view))))
(defun zoom-to-bounding-box (view minx miny maxx maxy &optional (pixel-border 0))
"Focus in on a particular bounding box (given in 2D-world coords)."
(setf minx (- minx pixel-border) miny (- miny pixel-border)
maxx (+ maxx pixel-border) maxy (+ maxy pixel-border))
(let* ((dx (- maxx minx))
(dy (- maxy miny))
(cx (+ minx (/ dx 2)))
(cy (+ miny (/ dy 2))))
(let* ((zoomfac (truncate (log (cme::view-zoom-factor view) 2)))
(pane (cme::view-window view))
(paneheight (ic::inside-height pane))
(panewidth (ic::inside-width pane))
(newzoom (min (floor (log (/ panewidth dx) 2))
(floor (log (/ paneheight dy) 2)))))
(cond
((= zoomfac newzoom) ;;just recenter
(center-around-pixel view cx cy))
((< zoomfac newzoom) ;;zoom in
(dotimes (i (- newzoom zoomfac))
(zoom-in-around-pixel view cx cy)))
(t ;;zoom out
(dotimes (i (- zoomfac newzoom))
(zoom-out-around-pixel view cx cy))))
(ic::refresh (cme::view-window view)))))
#|
(defun foo (view)
(let* ((w2i (cme::inverse-transform (cme::image-to-window-transform view)))
(w2s (cme::inverse-transform (cme::2d-to-window-transform view)))
(zoomfac (cme::view-zoom-factor view))
(pane (cme::view-window view))
(winlowleft (list 0 (ic::inside-height pane)))
(winupright (list (ic::inside-width pane) 0))
(iboxll (la::listarray (cme::inline-transform w2i winlowleft)))
(iboxur (la::listarray (cme::inline-transform w2i winupright)))
(sboxll (la::listarray (cme::inline-transform w2s winlowleft)))
(sboxur (la::listarray (cme::inline-transform w2s winupright))))
(format t "zoom factor: ~d~%" zoomfac)
(format t "pane width: ~d height: ~d~%"
(ic::inside-width pane) (ic::inside-height pane))
(format t "image window (~,2f ~,2f) to (~,2f ~,2f)~%"
(elt iboxll 0) (elt iboxll 1) (elt iboxur 0) (elt iboxur 1))
(format t "sensor window (~,2f ~,2f) to (~,2f ~,2f)~%"
(elt sboxll 0) (elt sboxll 1) (elt sboxur 0) (elt sboxur 1))
(format t " width: ~,2f height: ~,2f~%"
(- (elt sboxur 0) (elt sboxll 0))
(- (elt sboxur 1) (elt sboxll 1)))))
|#