From: Jose Carlos Senciales
Subject: Zoom  ¿¿gp:set-graphics-state??
Date: 
Message-ID: <3B4C0FC1.237942F1@lcc.uma.es>
Hello, First sorry for my so bad english

well, i�m trying to make a function to scale a graphic using LispWorks
4.1.20 on windows Nt with Capi and Gp.

i have defined a interface like this to paint in a pinboard-layout.

;--------------------------------------------------------------
(Capi:Define-Interface Interfaz-Sindi ()
  ()
  (:Panes
    (Display-Pane-1
    capi:display-pane
    :text "CoordenadaX"
    :accessor CoorX
    :min-width 100
    :background :grey)
    (display-pane-2
    capi:display-pane
    :text "CoordenadaY"
    :accessor CoorY
    :min-width 100
    :background :grey)
   (display-pane-9
    capi:display-pane
    :text "Capa Activa"
    :width 200
    :background :grey)
   (display-pane-10
    capi:display-pane
    :background :grey
    :text "...")
   (display-pane-11
    capi:display-pane
    :background :grey
    :text "..."))
  (:layouts
   (column-layout-1
    capi:column-layout
    '(pinboard-layout-1 row-layout-1))
   (pinboard-layout-1
    capi:pinboard-layout     ;;;;;;;;; i paint in this
capi:pinboard-layout Salida21
    ()
    :accessor Salida21
    :Input-Model (List (List :motion
                         #'(lambda (self x y)
                                   (actualiza-coordenadas capi:interface
self X Y)))
                       (list 'Boton1-Raton 'Func-Boton1))
    :drawing-style :local-pixmap
    :min-height 500
    :min-width 750
    :background :white
    :horizontal-scroll t
    :vertical-scroll t
    :visible-border t)
   (row-layout-1
    capi:row-layout
    '(display-pane-1 display-pane-2 display-pane-9 display-pane-10
display-pane-11)))
   (:menu-bar menu-8 menu-9 menu-15)
  (:menus
   (menu-15
    "Generador de Informes"
    ())
   (menu-12
    "Zoom"
    (("Todo" :Callback #'(Lambda (Data Interface) (Declare (Ignore
Data))  (zoom :ventana interface))) ;;;;;;;;;;;here i call to my
function to scale, the rest of code isn�t important.
     "Ventana"))
   (menu-11
     "Alzado" ())
   (menu-10
    "Elementos"
    (("Mapas" :callback #'Selecciona-Mapa-Vision)
     ("Alternativas" :Callback #'(Lambda (Data Interface) (Declare
(Ignore Data Interface))
                       (Inserta-Lineas  ( Dibuja-polylineas-Mapa
(Importa-Dxf "C:H1025neal.Dxf") 15 409300 4114100))))))
   (menu-9
    "Visualizar"
    (menu-10
     menu-12
     menu-11))
   (menu-8
    "Proyecto"
    (("Nuevo" :callback #'MenuNuevoProyecto)
     ("Edita" :callback #'Dato-Proyecto)
     ("Abrir" :callback #'MenuAbrirProyecto)
     ("Guardar" :callback #'(lambda (data interface) (declare (ignore
data interface)) (salva-proyecto)))
     ("Guardar Como"  :Callback #'MenuGuardarProyecto)
     ("Salir" :callback #'Op-cancela) )))
  (:default-initargs
   :best-height 540
   :best-width 766
   :layout 'column-layout-1
   :title "Sindi"))



;;the function zoom is the next
;-----------------------------------------------------
(Defun Zoom (&Key (Ventana *Maqueta*))
  (gp:set-graphics-state (Salida21 Ventana)
     :transform (gp:apply-scale (gp:graphics-port-transform (Salida21
Ventana)) 2 2)))

;-----------------------------------------------------------------
 (Setf *Maqueta* (Make-Instance 'Interfaz-Sindi))
 (Capi:Display *Maqueta*))


When i try to run the function zoom, this function give me a error
:Non-list argument 0 for endp. but
the window is scaled ok but also change the scale for all Lispworks
Windows (Editor,Listener....)

Do anyone know which is the problem or is a possible bug ??

Thanks in advence!

--
*

          *                *

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

From: Clive Tong
Subject: Re: Zoom  ��gp:set-graphics-state??
Date: 
Message-ID: <u1ynn68a3.fsf@scientia.com>
Jose Carlos Senciales <······@lcc.uma.es> writes:

> ....
> (gp:apply-scale (gp:graphics-port-transform (Salida21 Ventana)) 2 2)))
> ....

This destructively modifies the transform, and returns a number, not
the modified transform.

I think you need to get the transform, copy it, scale the copy, and
pass the destructively modified value into the  graphics state setting
function. 

(Defun Zoom (&Key (Ventana *Maqueta*))
  (let ((transform (gp:copy-transform 
                    (gp:graphics-port-transform (Salida21 Ventana)))))
    (gp:apply-scale transform 2 2)
    (gp:set-graphics-state (Salida21 Ventana)
                           :transform transform)))
From: Jose Carlos Senciales
Subject: Re: Zoom  ¿¿gp:set-graphics-state??
Date: 
Message-ID: <3B4DD22D.E5E3DF29@lcc.uma.es>
Clive Tong wrote:

> Jose Carlos Senciales <······@lcc.uma.es> writes:
>
> > ....
> > (gp:apply-scale (gp:graphics-port-transform (Salida21 Ventana)) 2 2)))
> > ....
>
> This destructively modifies the transform, and returns a number, not
> the modified transform.
>
> I think you need to get the transform, copy it, scale the copy, and
> pass the destructively modified value into the  graphics state setting
> function.
>
> (Defun Zoom (&Key (Ventana *Maqueta*))
>   (let ((transform (gp:copy-transform
>                     (gp:graphics-port-transform (Salida21 Ventana)))))
>     (gp:apply-scale transform 2 2)
>     (gp:set-graphics-state (Salida21 Ventana)
>                            :transform transform)))

thanks!

--
*

          *                *

*
-------------------------------------------------------
              Jos� Carlos Senciales Chaves
(reverse (concatenate 'string ···········@" "nescoj"))
                   ······@lcc.uma.es
-------------------------------------------------------
From: Wade Humeniuk
Subject: Re: Zoom  ��gp:set-graphics-state??
Date: 
Message-ID: <9iie28$2ac$1@news3.cadvision.com>
Same problems on my machine Jose.  I think it has something to do with all
the windows in LW sharing the same graphics state.  So I tried making a
state copy:

To prove that I got the listener echo-area-pane with the Window Browser.

#<CAPI:ECHO-AREA-PANE  21235B7C>
CL-USER 1 > (setf eap *)
#<CAPI:ECHO-AREA-PANE  21235B7C>

CL-USER 2 > (gp:graphics-port-transform eap)
(1 0 0 1 0 0)

CL-USER 3 > (eq (gp:graphics-port-transform eap) (gp:graphics-port-transform
(salida21 *maqueta*)))
T

CL-USER 4 >

Which means a modification to *maqueta* graphics state modifies all graphic
states

I tried to get around it with:

(defvar *maqueta* nil)

(defmethod initialize-instance :after ((sindi interfaz-sindi) &rest args)
  (setf (gp:get-graphics-state (Salida21 sindi)) (gp:make-graphics-state))
  (setf (gp:graphics-port-transform (salida21 sindi))
        (gp:copy-transform (gp:graphics-port-transform (salida21 sindi)))))

;;the function zoom is the next
;-----------------------------------------------------
(Defun Zoom (&Key (Ventana *Maqueta*))
  (gp:apply-scale (gp:graphics-port-transform (Salida21 Ventana)) 2 2))

At least it does not rescale all the windows, but I cannot tell it it
rescaled *maqueta*.  Perhaps you could try it.


Wade
From: Jose Carlos Senciales
Subject: Re: Zoom  ¿¿gp:set-graphics-state??
Date: 
Message-ID: <3B4D4CDF.A2EBAC0@lcc.uma.es>
Wade Humeniuk wrote:

> Same problems on my machine Jose.  I think it has something to do with all
> the windows in LW sharing the same graphics state.  So I tried making a
> state copy:
>
> To prove that I got the listener echo-area-pane with the Window Browser.
>
> #<CAPI:ECHO-AREA-PANE  21235B7C>
> CL-USER 1 > (setf eap *)
> #<CAPI:ECHO-AREA-PANE  21235B7C>
>
> CL-USER 2 > (gp:graphics-port-transform eap)
> (1 0 0 1 0 0)
>
> CL-USER 3 > (eq (gp:graphics-port-transform eap) (gp:graphics-port-transform
> (salida21 *maqueta*)))
> T
>
> CL-USER 4 >
>
> Which means a modification to *maqueta* graphics state modifies all graphic
> states
>
> I tried to get around it with:
>
> (defvar *maqueta* nil)
>
> (defmethod initialize-instance :after ((sindi interfaz-sindi) &rest args)
>   (setf (gp:get-graphics-state (Salida21 sindi)) (gp:make-graphics-state))
>   (setf (gp:graphics-port-transform (salida21 sindi))
>         (gp:copy-transform (gp:graphics-port-transform (salida21 sindi)))))
>
> ;;the function zoom is the next
> ;-----------------------------------------------------
> (Defun Zoom (&Key (Ventana *Maqueta*))
>   (gp:apply-scale (gp:graphics-port-transform (Salida21 Ventana)) 2 2))
>
> At least it does not rescale all the windows, but I cannot tell it it
> rescaled *maqueta*.  Perhaps you could try it.
>
> Wade

Thanks you for your answer,
yesterday i was trying with a lot of codes and i found that the problem is in
the function
(gp:apply-scale port Sx Sy) .this function has a unknown side effects in my
system. :-(.. maybe it could be a bug, i don�t know.
if i use it, always give me the same problem, then i change me zoom function
doing a simple SETF to graphics-ports:graphics-port-transform.
;--------------------------
;the new zoom function
;--------------------------
(Defun Zoom (&Key (Ventana *Maqueta*) Escalax Escalay)
(Setf (graphics-ports:graphics-port-transform (Salida21 Ventana))
         (list Escalax 0 0 Escalay 0 0))  ;this is the transform matrix
 (capi:redraw-pinboard-layout (Salida21 Ventana) 0 0 10000 10000)) ;redraw the
window to refresh it


Now all function very well and quickly.. :-)

bye and thanks!
--
*

          *                *

*
-------------------------------------------------------
              Jos� Carlos Senciales Chaves
(reverse (concatenate 'string ···········@" "nescoj"))
                   ······@lcc.uma.es
-------------------------------------------------------
From: Wade Humeniuk
Subject: Re: Zoom  ��gp:set-graphics-state??
Date: 
Message-ID: <9ik7p5$j7a$1@news3.cadvision.com>
> ;--------------------------
> ;the new zoom function
> ;--------------------------
> (Defun Zoom (&Key (Ventana *Maqueta*) Escalax Escalay)
> (Setf (graphics-ports:graphics-port-transform (Salida21 Ventana))
>          (list Escalax 0 0 Escalay 0 0))  ;this is the transform matrix
>  (capi:redraw-pinboard-layout (Salida21 Ventana) 0 0 10000 10000)) ;redraw
the
> window to refresh it

You are essentially doing a gp:copy-transform, which seems to call copy-seq.
Your function is OK, if you do not have any other transforms in place (like
rotations) or if you call zoom multiple times to keep zooming in by Escalax
Excalay.  There is no bug in gp:apply-transform, it just returns an integer,
not a transform.  It destructively modifies the transform you reference,
which seems to be shared by all windows in Lispworks IDE.

This is just the result of a side-effect, as in:

CL-USER 10 > (setf l '(1 2 3))
(1 2 3)

CL-USER 11 > (setf p l)
(1 2 3)

CL-USER 12 > (setf (second l) 10)
10

CL-USER 13 > l
(1 10 3)

CL-USER 14 > p
(1 10 3)

CL-USER 15 > (eq l p)
T

CL-USER 16 >


Wade
From: Jose Carlos Senciales
Subject: Re: Zoom  ¿¿gp:set-graphics-state??
Date: 
Message-ID: <3B4DC56B.5265F9A0@lcc.uma.es>
Wade Humeniuk wrote:

> > ;--------------------------
> > ;the new zoom function
> > ;--------------------------
> > (Defun Zoom (&Key (Ventana *Maqueta*) Escalax Escalay)
> > (Setf (graphics-ports:graphics-port-transform (Salida21 Ventana))
> >          (list Escalax 0 0 Escalay 0 0))  ;this is the transform matrix
> >  (capi:redraw-pinboard-layout (Salida21 Ventana) 0 0 10000 10000)) ;redraw
> the
> > window to refresh it
>
> You are essentially doing a gp:copy-transform, which seems to call copy-seq.
> Your function is OK, if you do not have any other transforms in place (like
> rotations) or if you call zoom multiple times to keep zooming in by Escalax
> Excalay.

yes, i have only scale transforms, Then i can use 0 to the rest of  transforms
matrix.


> There is no bug in gp:apply-transform, it just returns an integer,
> not a transform.  It destructively modifies the transform you reference,
> which seems to be shared by all windows in Lispworks IDE.
>

I agree, all windows in Lispworks IDE have shared the same transform reference,
which  i don�t seem very logical.


>
> This is just the result of a side-effect, as in:
>
> CL-USER 10 > (setf l '(1 2 3))
> (1 2 3)
>
> CL-USER 11 > (setf p l)
> (1 2 3)
>
> CL-USER 12 > (setf (second l) 10)
> 10
>
> CL-USER 13 > l
> (1 10 3)
>
> CL-USER 14 > p
> (1 10 3)
>
> CL-USER 15 > (eq l p)
> T
>
> CL-USER 16 >
>
> Wade

thanks, bye

--
*

          *                *

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