CLIM mail archive

[Prev][Next][Index][Thread]

DRAW-CIRCLE* bug inside WITH-ROTATION



    Date: Fri, 4 Dec 1992 17:48 EST
    From: Brent Reeves <brentr@sigi.cs.colorado.edu>

     [ Genera 8.1 Clim 1.1 ]

     This is probably an old problem, but DRAW-CIRCLE has trouble
     within WITH-ROTATION.  Evidently some functions that need
     integers are getting floats instead.

For what it's worth, this works correctly in CLIM 2.0

    (define-indy-command (com-test-circle :name t :menu nil)
	()
      (let ((stream (get-frame-pane *af* 'work-area)))
	(clim:window-clear stream)
	;;
	;; ok
	;;
	(with-scaling (stream .5 .5)
	  (draw-circle*  stream 40 40 20
			      :line-thickness 1
			      :filled nil))
	;;
	;; not ok
	;;
	(with-rotation (stream .5)
	  (with-scaling (stream .5 .5)
	  (draw-circle*  stream 40 40 20
				:line-thickness 1
				:filled nil)))))


     The first circle draws just fine... the second one provides me
     with an opportunity to explore the debugger:

    Trap: The second subscript given to the ZL:AR-2 instruction,
    35.29563, was not a fixnum.

    The following specials have been rebound; use :Show Standard
    Value Warnings for details:
      *PRINT-CASE* and *PACKAGE*

    TV:%DRAW-POINT
       Arg 0 (TV:X): 35.29563
       Arg 1 (TV:Y): 30
       Arg 2 (TV:ALU): 15
       Arg 3 (TV:RASTER): #<SHEET-RASTER 574x570x1b for Clim Sheet 11
       232657051>
       --Defaulted args:--
       Arg 4 (TV:VALUE):    Return to Indy command level

You can insert the appropriate calls to FLOOR or ROUND in the following function:

(in-package :clim)
(defmethod draw-ellipse-internal ((stream sheet-implementation-mixin) x-offset y-offset
				  center-x center-y
				  radius-1-dx radius-1-dy radius-2-dx radius-2-dy
				  start-angle end-angle ink line-style)
  (when (window-drawing-possible stream)
    (round-points center-x center-y radius-1-dx radius-1-dy radius-2-dx radius-2-dy)
    (translate-positions x-offset y-offset center-x center-y)
    (when (and start-angle
	       (= start-angle 0.0)
	       (= end-angle 2pi))
      ;; GRAPHICS:DRAW-CIRCLE draws nothing when given single-precision 2PI
      (setq end-angle graphics:2pi))
    (multiple-value-bind (pre-stretch-angle x-radius y-radius axis-rotate-angle)
	(2x2-singular-value-decomposition radius-1-dx radius-2-dx
					  radius-1-dy radius-2-dy)
      (declare (ignore pre-stretch-angle))
      (setq x-radius (abs x-radius) y-radius (abs y-radius))
      (if (and (= x-radius y-radius) (null start-angle))
	  ;; It's a complete circle
	  (with-appropriate-drawing-state stream ink line-style
	    #'(lambda (window alu)
		(declare (sys:downward-function))
		(if (null line-style)
		    (funcall window :draw-filled-in-circle center-x center-y x-radius alu)
		    (funcall window :draw-circle center-x center-y x-radius alu)))
	    #'(lambda (window)
		(declare (sys:downward-function))
		(funcall (flavor:generic graphics:draw-ellipse) window
			 center-x center-y x-radius y-radius
			 :filled (null line-style))))
	;; For general ellipse, let Genera do all the work
	(with-appropriate-drawing-state stream ink line-style
	  nil
	  #'(lambda (window)
	      (declare (sys:downward-function))
	      (graphics:saving-graphics-transform (window)
		(graphics:graphics-translate center-x center-y :stream window)
		(when (/= axis-rotate-angle 0)
		  (graphics:graphics-rotate axis-rotate-angle :stream window))
		(funcall (flavor:generic graphics:draw-ellipse) window
			 0 0 x-radius y-radius
			 :start-angle (or start-angle 0)
			 :end-angle (or end-angle graphics:2pi)
			 :filled (null line-style)))))))))

0,,

References:

Main Index | Thread Index