home *** CD-ROM | disk | FTP | other *** search
- ; book pp.320-321
-
- (require "functions/twobutton")
-
- (defmeth spin-proto :set-axis-rotation(v)
- (let* ((m (send self :num-variables))
- (v1 (if (= v 0) 1 0))
- (v2 (if (= v 2) 1 2))
- (trans (send self :transformation))
- (cols (column-list (if trans trans (identity-matrix m))))
- (x1 (select cols v1))
- (x2 (select cols v2))
- (angle (send self :angle)))
- (send self :rotation-type (make-rotation x1 x2 angle))))
- (defproto spin-rotate-control-proto '(v) () twobutton-control-proto)
- (defmeth spin-rotate-control-proto :isnew (v &rest args)
- (apply #'call-next-method :v v args))
- (defmeth spin-rotate-control-proto :title ()
- (send (send self :graph) :variable-label (slot-value 'v)))
- (defmeth spin-rotate-control-proto :do-action (sign mods)
- (let ((graph (send self :graph)))
- (if mods
- (let ((v (slot-value 'v))
- (angle (abs (send graph :angle))))
- (send graph :idle-on (first mods))
- (send graph :angle (if (eq sign '+) angle (- angle)))
- (send graph :set-axis-rotation v)))
- (send graph :rotate)))
-