From: Jose Carlos Senciales
Subject: New problem with zoom function
Date: 
Message-ID: <3B5552D3.1EE9F1EA@lcc.uma.es>
Hi, i�m trying to make a function to do zomming and this go very well,
but
when i try to reduce a graphics produce a bad result.

the code example is the next:


(defvar *hol* nil) ;to save the inerface

;--------------------------------------------
;--------------------------------------------
(capi:define-interface foo ()
  ()
  (:panes
   (rectangle
    capi:rectangle
    :filled t
    :height 1000
    :width 1000))
  (:layouts
   (pinboard-layout
    capi:pinboard-layout
  ;  '(rectangle)
    '()
    :accessor pru1
    :background :white
    :drawing-style (:initarg :display-type)
    :vertical-scroll t
    :horizontal-scroll t
    :min-width 500
    :min-height 500))
  (:default-initargs
   :best-height 500
   :best-width 500
   :layout 'pinboard-layout
   :title "hol1"))

;-------------------------------------
;Definici�n De La Funci�n De Zoom
;-------------------------------------
(Defun Zoom (&key (ventana *hol*) Escalax Escalay)
 (setf (gp:graphics-port-transform  (pru1 ventana))
       (list escalax 0 0 escalay 0 0))
 (capi:redraw-pinboard-layout (pru1 ventana) 0 0 10000 10000))

;;----------------------------------------------------------------------------

;; Define an ellipse pinboard object
;;----------------------------------------------------------------------------

(defclass ellipse (capi:pinboard-object)
  ((foreground :accessor foreground :initform nil :initarg :foreground)
   (filled :accessor filled :initform T :initarg :filled))
  (:default-initargs
   :min-width 300
   :min-height 300))

(defmethod capi:draw-pinboard-object (pinboard (ellipse ellipse) &key)
  (capi:with-geometry ellipse
    (let ((x-radius (floor (1- capi:%width%) 2))
          (y-radius (floor (1- capi:%height%) 2)))
      (gp:draw-ellipse pinboard
         (+ capi:%x% x-radius)
                       (+ capi:%y% y-radius)
                       x-radius
                       y-radius
         :foreground  (foreground ellipse)
                       :filled (filled ellipse)))))

;here  make a instance of foo

(setf *hol* (make-instance 'foo :display-type :local-pixmap))

(capi:display *hol*)


;insert a first ellipse

(setf (capi:layout-description (pru1 *hol*))
                    (list
                     (make-instance 'ellipse :x 3000 :y 3000)))

;insert a second ellipse

 (setf (capi:layout-description (pru1 *hol*))
                    (append(list
                     (make-instance 'ellipse :x 30 :y
30))(capi:layout-description (pru1 *hol*))))

;call a my funtion zoom to reduce scale

(zoom :escalax 0.1 :escalay 0.1)

;redraw full window.

(capi:redraw-pinboard-layout (pru1 *hol*) 0 0 5000000 5000000)

;And then i view four ellipses and the scroll don�t function properly. I
don�t know what to think about.

If you know what is the problem, i would be very grateful you tell me

thanks

--
*

          *                *

*
-------------------------------------------------------
              Jos� Carlos Senciales Chaves
(reverse (concatenate 'string ···········@" "nescoj"))
                   ······@lcc.uma.es
-------------------------------------------------------

From: Clive Tong
Subject: Re: New problem with zoom function
Date: 
Message-ID: <upuay343f.fsf@scientia.com>
Jose Carlos Senciales <······@lcc.uma.es> writes:

> ....
> (setf *hol* (make-instance 'foo :display-type :local-pixmap))

I'd remove the :local-pixmap; this tells the layout to double-buffer
using an pixmap (and is AFAIK undocumented). This is just confusing
the issue. 

> ...
> 
> If you know what is the problem, i would be very grateful you tell me

To determine if a redraw is required, the CAPI is using the
coordinates of the damaged area, and the coordinates of the ellipses
(as accessed using the with-geometry macro inside the
draw-pinboard-object method). This is using the UNSCALED coordinates.
(You can see this if you trace draw-pinboard-object and then right
scroll the pane by clicking the scroll bar horizontal right arrow 10
times, and then left arrow ten times. The drawing function
is only called for the first 6 left clicks which do not cover the area
where the zoomed ellipse is found, but which do cover the damage area
of the unzoomed ellipse).

The answer is therefore that the graphics ports scale affects the
drawing operations, but not the geomtery of an individual pinboard
object. 
From: Jose Carlos Senciales
Subject: Re: New problem with zoom function
Date: 
Message-ID: <3B5571C2.64A827B3@lcc.uma.es>
Thanks.

If i remove the :local-pixmap the function zoom functions ok but
only can see the first ellipse :-((

Where is the second ellipse, it�s losed i don�t anderstand this behaviour..

Clive Tong wrote:

> Jose Carlos Senciales <······@lcc.uma.es> writes:
>
> > ....
> > (setf *hol* (make-instance 'foo :display-type :local-pixmap))
>
> I'd remove the :local-pixmap; this tells the layout to double-buffer
> using an pixmap (and is AFAIK undocumented). This is just confusing
> the issue.
>
> > ...
> >
> > If you know what is the problem, i would be very grateful you tell me
>
> To determine if a redraw is required, the CAPI is using the
> coordinates of the damaged area, and the coordinates of the ellipses
> (as accessed using the with-geometry macro inside the
> draw-pinboard-object method). This is using the UNSCALED coordinates.
> (You can see this if you trace draw-pinboard-object and then right
> scroll the pane by clicking the scroll bar horizontal right arrow 10
> times, and then left arrow ten times. The drawing function
> is only called for the first 6 left clicks which do not cover the area
> where the zoomed ellipse is found, but which do cover the damage area
> of the unzoomed ellipse).
>
> The answer is therefore that the graphics ports scale affects the
> drawing operations, but not the geomtery of an individual pinboard
> object.

--
=============================================
Jos� Carlos Senciales Chaves - ······@lcc.uma.es

El arte de la vida consiste en hacer de la
vida una obra de arte.(Voltaire)
=============================================
From: Clive Tong
Subject: Re: New problem with zoom function
Date: 
Message-ID: <un1622x2m.fsf@scientia.com>
Jose Carlos Senciales <······@lcc.uma.es> writes:

> Thanks.
> 
> If i remove the :local-pixmap the function zoom functions ok but
> only can see the first ellipse :-((
> 
> Where is the second ellipse, it�s losed i don�t anderstand this behaviour..

The Capi is using the scaling of coordinates only for the drawing. For
hit detection, and determining when an area needs to be redrawn, it is
using the unscaled coordinates; when scaling is in effect, your
objects are drawing themselves outside the bounded area that the Capi
associates with them. 

Add the following function

(defun test-position (self x y)
  (if (some #'(lambda (item)
                  (capi:over-pinboard-object-p item x y))
              (capi:layout-description self))
      (print "over")
    (print "not over")))

and add the following input model to the pinboard-layout

  :input-model '(((:motion) test-position))

Make the interface, and zoom it. Move the mouse over the
interface. Look in the output tab of the editor pane, and notice that
the text "over" is printed when the mouse is over the position of the
unzoomed ellipse, and not when it is over the position where the
scaled ellipse is drawn. [ie it supplies the 'right' answer when the
drawing is not scaling, and always supplies the right answer relative
to the unscaled coordinates.]

Hope that helps.
From: Jose Carlos Senciales
Subject: Re: New problem with zoom function
Date: 
Message-ID: <3B559D36.5DC9D6D8@lcc.uma.es>
Ok , thanks.

Now, i�m wondering if there is some way to say to Capi that all objects in the
pinboard must be always redrawn.
So i can see all the object scaled in the pinboard.

Clive Tong wrote:

> Jose Carlos Senciales <······@lcc.uma.es> writes:
>
> > Thanks.
> >
> > If i remove the :local-pixmap the function zoom functions ok but
> > only can see the first ellipse :-((
> >
> > Where is the second ellipse, it�s losed i don�t anderstand this behaviour..
>
> The Capi is using the scaling of coordinates only for the drawing. For
> hit detection, and determining when an area needs to be redrawn, it is
> using the unscaled coordinates; when scaling is in effect, your
> objects are drawing themselves outside the bounded area that the Capi
> associates with them.
>
> Add the following function
>
> (defun test-position (self x y)
>   (if (some #'(lambda (item)
>                   (capi:over-pinboard-object-p item x y))
>               (capi:layout-description self))
>       (print "over")
>     (print "not over")))
>
> and add the following input model to the pinboard-layout
>
>   :input-model '(((:motion) test-position))
>
> Make the interface, and zoom it. Move the mouse over the
> interface. Look in the output tab of the editor pane, and notice that
> the text "over" is printed when the mouse is over the position of the
> unzoomed ellipse, and not when it is over the position where the
> scaled ellipse is drawn. [ie it supplies the 'right' answer when the
> drawing is not scaling, and always supplies the right answer relative
> to the unscaled coordinates.]
>
> Hope that helps.

--
=============================================
Jos� Carlos Senciales Chaves - ······@lcc.uma.es

El arte de la vida consiste en hacer de la
vida una obra de arte.(Voltaire)
=============================================