From ahefner at gmail.com Fri Dec 5 19:26:53 2008 From: ahefner at gmail.com (Andy Hefner) Date: Fri, 5 Dec 2008 14:26:53 -0500 Subject: [mcclim-devel] mcclim-devel Digest, Vol 39, Issue 6 In-Reply-To: <492A8051.6060901@labri.fr> References: <20080331170353.C3F004E024@common-lisp.net> <47F20740.5070401@labri.fr> <492A8051.6060901@labri.fr> Message-ID: <31ffd3c40812051126j6335c568y2b6e821e5bcf494c@mail.gmail.com> This program's display function recurses infinitely (display-function -> redisplay-frame-panes -> ... -> display-function), and control is never returned to the event loop. I'm surprised it worked in the past. The only reliable technique I know to achieve animation in mcclim is to use a separate thread which loops calling sleep and sends an event to the application frame periodically. I've attached a version of your program using this technique. (defpackage :mini (:use :clim :clim-extensions :clim-lisp)) (in-package :mini) (let ((colors (list +red+ +green+))) (setf colors (nconc colors colors)) (defun display-function (frame pane) (draw-circle* pane 10 10 10 :ink (pop colors)))) (defun quit () (frame-exit *application-frame*)) (define-application-frame mini () () (:panes (display :application :display-function 'display-function :incremental-redisplay t) (quit :push-button :label "Quit" :activate-callback (lambda (x) (declare (ignore x)) (quit)))) (:layouts (defaults (vertically () display quit)))) (defun run-test (name) (run-frame-top-level (make-application-frame name))) (defun start () (run-test 'mini) 0) (defclass interrupt-event (climi::standard-event) ((fn :initarg :fn :reader fn-of)) (:default-initargs :sheet nil)) (defmethod handle-event (sheet (event interrupt-event)) (funcall (fn-of event))) (defmethod run-frame-top-level :around ((mini mini) &key) (let ((running t)) (clim-sys:make-process (lambda () (loop while running do (sleep 0.50) (climi::event-queue-append (climi::frame-event-queue mini) (make-instance 'interrupt-event :fn (lambda () (redisplay-frame-panes mini))))))) (unwind-protect (call-next-method) (setf running nil)))) From ahefner at gmail.com Sat Dec 6 13:44:41 2008 From: ahefner at gmail.com (Andy Hefner) Date: Sat, 6 Dec 2008 08:44:41 -0500 Subject: [mcclim-devel] Default text style Message-ID: <31ffd3c40812060544p74dc94cem56bd38c80815d7a1@mail.gmail.com> Does anyone have an objection to changing the default text style from :fixed to :sans-serif? I don't believe anything in the spec requires is to use :fixed for the default, and changing it makes some things (e.g. accepting-values dialogs) much more attractive. From ch-mcclim at bobobeach.com Thu Dec 18 21:47:14 2008 From: ch-mcclim at bobobeach.com (Cyrus Harmon) Date: Thu, 18 Dec 2008 13:47:14 -0800 Subject: =?iso-8859-1?q?_=5Bmcclim-devel=5D_incremental-redisplay_=19issu?= =?iso-8859-1?q?es?= Message-ID: <3ABFB943-4E9D-4362-8B92-B6EFA50456FA@bobobeach.com> I've been developing an application for generating and visualizing 2-d structures for molecules and have run into some issues with incremental-redisplay. There are two main problems that can be seen in the following screen shot: http://www2.cyrusharmon.org/incr-redisp.png 1. I see visual "detritus" in the pane (is that the right term?) if I zoom in and out. It gets things mostly right, but there are some "left- over" lines that don't get erased. Some initial tests suggest this has to do with using incremental-redisplay in panes that have been transformed with with-scaling and friends. The workaround is to manually clear the screen, which I, hackily, do after various commands. 2. The order in which things are drawn is different upon redrawing. In the screenshot, you'll see that the lines for the bonds between the atoms are drawn on top of the colored circles representing the atoms. On the first drawing, they are drawn before the atoms and therefore are not overlapped by the atoms. Incremental-redisplay seems to be changing the order in which things are drawn. For some code that illustrates these problems, I've made a standalone clim app that demonstrates the behavior and attached it below. If it gets munged by the mailing list, the code can also be found at: http://www2.cyrusharmon.org/standalone.lisp Any suggestions on how to either fix or better use McCLIM, would be greatly appreciated. thanks, Cyrus ;;; file: standalone.lisp ;;; Copyright (c) 2008 Cyrus Harmon (ch-lisp at bobobeach.com) ;;; (asdf:oos 'asdf:load-op :mcclim) (defpackage #:chemicl-draw-standalone (:use #:clim #:clim-lisp)) (in-package :chemicl-draw-standalone) (defparameter *molecule-2d-pane-foreground-color* +white+) (defparameter *molecule-2d-pane-background-color* +black+) (defclass chemicl-2d-view (view) ()) (defparameter *chemicl-2d-view* (make-instance 'chemicl-2d-view)) (defclass chemicl-info-view (view) ()) (defparameter *chemicl-info-view* (make-instance 'chemicl-info-view)) (define-application-frame chemicl-draw () () (:pointer-documentation t) (:panes (app (make-clim-stream-pane :type 'application-pane :height 600 :width 500 :incremental-redisplay t :display-function 'display-chemicl-2d :default-view *chemicl-2d-view* :background *molecule-2d-pane-background-color* :scroll-bars :both)) (info :application :height 600 :width 300 :display-function 'display-chemicl-info :default-view *chemicl-info-view* :background +white+) (int :interactor :height 160 :width 800)) (:layouts (default (vertically () (horizontally () app info) int)))) (defun draw-bond (pane x1 y1 x2 y2 bond &key (inset 5)) (draw-line* pane x1 y1 x2 y2 :ink +green+)) (defun bond-angle (x1 y1 x2 y2) (cond ((zerop (- y2 y1)) (if (minusp (- x2 x1)) pi 0)) ((zerop (- x2 x1)) (if (minusp (- y2 y1)) (/ (* 3 pi) 2) (/ pi 2))) (t (atan (/ (- y2 y1) (- x2 x1)))))) (defvar *default-scale* 25) (defvar *scale* *default-scale*) (defvar *default-rotation* 0) (defvar *rotation* *default-rotation*) (defun reset () (setf *scale* *default-scale*) (setf *rotation* *default-rotation*)) (defparameter *atom-coords* '((6.169130606358857d0 . -1.6091702292618408d0) (5.5d0 . -0.8660254037844456d0) (3.0000000000000018d0 . -9.877623892429188d-16) (4.000000000000002d0 . -3.774758283725532d-15) (4.5d0 . -0.8660254037844436d0) (3.999999999999998d0 . -1.7320508075688812d0) (2.999999999999998d0 . -1.7320508075688794d0) (2.499999999999999d0 . -0.8660254037844402d0) (0.9999999999999981d0 . -1.732050807568877d0) (1.5000000000000004d0 . 0.8660254037844385d0) (1.4999999999999993d0 . -0.866025403784439d0) (1.0d0 . 0.0d0) (0.0d0 . 0.0d0))) (defparameter *edge-coords* '(((5.5d0 . -0.8660254037844456d0) (6.169130606358857d0 . -1.6091702292618408d0)) ((1.4999999999999993d0 . -0.866025403784439d0) (0.9999999999999981d0 . -1.732050807568877d0)) ((4.5d0 . -0.8660254037844436d0) (5.5d0 . -0.8660254037844456d0)) ((2.499999999999999d0 . -0.8660254037844402d0) (3.0000000000000018d0 . -9.877623892429188d-16)) ((4.000000000000002d0 . -3.774758283725532d-15) (3.0000000000000018d0 . -9.877623892429188d-16)) ((4.5d0 . -0.8660254037844436d0) (4.000000000000002d0 . -3.774758283725532d-15)) ((3.999999999999998d0 . -1.7320508075688812d0) (4.5d0 . -0.8660254037844436d0)) ((2.999999999999998d0 . -1.7320508075688794d0) (3.999999999999998d0 . -1.7320508075688812d0)) ((2.499999999999999d0 . -0.8660254037844402d0) (2.999999999999998d0 . -1.7320508075688794d0)) ((1.4999999999999993d0 . -0.866025403784439d0) (2.499999999999999d0 . -0.8660254037844402d0)) ((1.0d0 . 0.0d0) (1.4999999999999993d0 . -0.866025403784439d0)) ((1.0d0 . 0.0d0) (1.5000000000000004d0 . 0.8660254037844385d0)) ((0.0d0 . 0.0d0) (1.0d0 . 0.0d0)))) (defun draw-molecule-2d (pane) (flet ((atom-color () +red+) (atom-size () .12)) (let ((counter 0) (xmin 0) (xmax 0) (ymin 0) (ymax 0)) (map nil (lambda (atom) (destructuring-bind (ax . ay) atom (when (< ax xmin) (setf xmin ax)) (when (> ax xmax) (setf xmax ax)) (when (< ay ymin) (setf ymin ay)) (when (> ay ymax) (setf ymax ay)))) *atom-coords*) (with-scaling (pane *scale*) (with-rotation (pane *rotation*) (with-translation (pane (1+ (- xmin)) (+ 2 (- ymin))) (map nil (lambda (edge) (updating-output (pane :unique-id edge) (destructuring-bind (a1 a2) edge (let ((x1 (car a1)) (y1 (cdr a1))) (let ((x2 (car a2)) (y2 (cdr a2))) (let ((bond-angle (bond-angle x1 y1 x2 y2))) (let ((xoffset (* .04 (cos (+ bond-angle (/ pi 2))))) (yoffset (* .04 (sin (+ bond-angle (/ pi 2)))))) (draw-line* pane (+ x1 xoffset) (+ y1 yoffset) (+ x2 xoffset) (+ y2 yoffset) :ink *molecule-2d-pane- foreground-color* :line-thickness 1)) (let ((xoffset (* .04 (cos (- bond-angle (/ pi 2))))) (yoffset (* .04 (sin (- bond-angle (/ pi 2)))))) (draw-line* pane (+ x1 xoffset) (+ y1 yoffset) (+ x2 xoffset) (+ y2 yoffset) :ink *molecule-2d-pane- foreground-color* :line-thickness 1)))))))) *edge-coords*) (map nil (lambda (atom) (destructuring-bind (x . y) atom (updating-output (pane :unique-id atom) (draw-circle* pane x y (atom-size) :ink (atom- color)) (draw-circle* pane x y (* 1.2 (atom-size)) :ink (atom-color) :filled nil)) (incf counter))) *atom-coords*))))))) (defmethod display-chemicl-2d ((frame chemicl-draw) pane) (draw-molecule-2d pane)) (defmethod display-chemicl-info ((frame chemicl-draw) pane) (princ "test" pane) (terpri) (format pane "~&Mass: ~,5F~%" 1d0) (format pane "~&Exact Mass: ~,5F~%" 2d0) (format pane "~&Formula: ~,5F~%" 3d0)) (defun run (&key new-process) (flet ((run () (let ((frame (make-application-frame 'chemicl-draw))) (run-frame-top-level frame)))) (if new-process (clim-sys:make-process #'run :name "chemicl-draw") (run)))) (define-chemicl-draw-command (com-set-scale :name t) ((scale 'number :prompt " Scale? ")) (when (plusp scale) (setf *scale* scale))) (define-chemicl-draw-command (com-zoom-in :name t) () (declare (optimize (debug 2))) (setf *scale* (* *scale* 2)) (let* ((scroller (car (sheet-children (find-pane-named *application-frame* 'app)))) (pane (car (sheet-children (caddr (sheet-children scroller)))))) #+nil (window-clear pane) #+nil (with-bounding-rectangle* (x1 y1 x2 y2) (sheet-region pane) (draw-rectangle* (sheet-medium pane) x1 y1 x2 y2 :ink +background-ink+)))) (define-chemicl-draw-command (com-zoom-out :name t) () (setf *scale* (/ *scale* 2)) (let ((pane (car (sheet-children (caddr (sheet-children (car (sheet-children (find-pane-named *application-frame* 'app))))))))) #+nil (window-clear pane) #+nil (with-bounding-rectangle* (x1 y1 x2 y2) (sheet-region pane) (draw-rectangle* (sheet-medium pane) x1 y1 x2 y2 :ink +background-ink+)))) (define-chemicl-draw-command (com-set-rotation :name t) ((rotation 'number :prompt " Rotation? ")) (setf *rotation* rotation)) (define-chemicl-draw-command (com-reset :name t) () (reset)) (define-chemicl-draw-command (com-clear :name t) () (reset)) (define-chemicl-draw-command (com-redraw :name t) ()) (define-chemicl-draw-command (com-quit :name t) () (frame-exit *application-frame*)) From ch-mcclim at bobobeach.com Fri Dec 19 15:53:47 2008 From: ch-mcclim at bobobeach.com (Cyrus Harmon) Date: Fri, 19 Dec 2008 07:53:47 -0800 Subject: [mcclim-devel] draw-pattern and transformations Message-ID: In trying to use draw-pattern to draw some images, it seems that draw- pattern, at least for image-based patterns, doesn't respect the current transformation. My very cursory reading of the spec would seem to indicate that the image should be transformed: http://bauhh.dyndns.org:8000/clim-spec/14-2.html#_735 Thoughts? thanks, Cyrus From demmeln at in.tum.de Fri Dec 19 17:40:14 2008 From: demmeln at in.tum.de (Nikolaus Demmel) Date: Fri, 19 Dec 2008 18:40:14 +0100 Subject: [mcclim-devel] Double clicks Message-ID: <0D1E6849-B757-4E1C-912A-51329D4B86E7@in.tum.de> Hi list, it seems to me mcclim doesn't implement double clicking at all. I can't find the pointer-double-click-event from the clim 2 spec except in the exported symbols list. Am I missing something? What i would actually need is support for double-clicking in gestures. The spec doesn't include a modifier ":double" in the add- gesture-name description, but this seems to be what the guys from franz do in their implementation (according to their clim 2 user guide) and also seems to be a reasonable way to realize double clicking gestures. Has there been any attempt to implement a) double clicking at all b) :double modifier for gesture definitions or is there a reason this has not been done yet / can't be done properly? I would be willing to spend some time trying to implement it, but unfortunately i have too little knowledge of the internals of mcclim to do it on my own. Best regards, Niko Demmel From o.finnendahl at mh-freiburg.de Sun Dec 28 19:33:07 2008 From: o.finnendahl at mh-freiburg.de (Orm Finnendahl) Date: Sun, 28 Dec 2008 20:33:07 +0100 Subject: [mcclim-devel] accessing objects in highlight method Message-ID: <20081228193307.GG11319@varese> Hi, I'm trying to realize a specialized browser for nested tree structures (displayed as graphics) using mcclim. I just started to learn clim and there are quite a few things still unclear to me (I read the paper of Ciccarelli and most resources I could get a hold of, though). As a starting point I use the clim-fig example in the demo package and managed to implement feedback during movement of figures (dragging) and hooking into the highlight function of the drawing pane. I need to access the data structure being presented within the context of the highlight method (invoked on mouse-over). Below is the highlight method specialized on the figure type of clim-fig. The "record" arg contains the output-record which seems to maintain a copy of the graphical representation information of the figure object, but I have no idea how to access the figure itself or the slots of its representation in the application frame. (define-presentation-method highlight-presentation ((type figure) record (stream (eql (find-pane-named *application-frame* 'canvas))) (state (eql :highlight))) ...) Can anybody help? Thanks, Orm Finnendahl From athas at sigkill.dk Sun Dec 28 19:45:38 2008 From: athas at sigkill.dk (Troels Henriksen) Date: Sun, 28 Dec 2008 20:45:38 +0100 Subject: [mcclim-devel] accessing objects in highlight method In-Reply-To: <20081228193307.GG11319@varese> (Orm Finnendahl's message of "Sun, 28 Dec 2008 20:33:07 +0100") References: <20081228193307.GG11319@varese> Message-ID: <87prjcqe1p.fsf@lambda.athas.dyndns.dk> Orm Finnendahl writes: > Hi, > > I'm trying to realize a specialized browser for nested tree structures > (displayed as graphics) using mcclim. I just started to learn clim and > there are quite a few things still unclear to me (I read the paper of > Ciccarelli and most resources I could get a hold of, though). > > As a starting point I use the clim-fig example in the demo package and > managed to implement feedback during movement of figures (dragging) > and hooking into the highlight function of the drawing pane. > > I need to access the data structure being presented within the context > of the highlight method (invoked on mouse-over). Below is the > highlight method specialized on the figure type of clim-fig. The > "record" arg contains the output-record which seems to maintain a copy > of the graphical representation information of the figure object, but > I have no idea how to access the figure itself or the slots of its > representation in the application frame. > > (define-presentation-method highlight-presentation > ((type figure) record (stream (eql (find-pane-named *application-frame* 'canvas))) (state (eql :highlight))) > > ...) > > Can anybody help? > > Thanks, > Orm Finnendahl The output record is also the presentation (a presentation is a kind of output record), so use the PRESENTATION-OBJECT function to retrieve the object associated with it. -- \ Troels /\ Henriksen From o.finnendahl at mh-freiburg.de Sun Dec 28 16:53:47 2008 From: o.finnendahl at mh-freiburg.de (Orm Finnendahl) Date: Sun, 28 Dec 2008 16:53:47 -0000 Subject: [mcclim-devel] accessing objects in highlight method Message-ID: <20081228162840.GE11319@varese> Hi, I'm trying to realize a specialized browser for nested tree structures (displayed as graphics) using mcclim. I just started to learn clim so there are quite a few things still unclear to me (I read the paper of Ciccarelli and most resources I could get a hold of, though). As a starting point I use the clim-fig example in the demo package and managed to implement feedback during movement and hooking into the highlight function of the drawing pane. I need to access the data structure being presented within the context of the highlight method (invoked on mouse-over). Below is the highlight method specialized on the figure type of clim-fig. The "record" arg contains the output-record which seems to maintain a copy of the graphical representation information of the figure object, but I have no idea how to access the figure itself or the slots of its representation in the application frame. (define-presentation-method highlight-presentation ((type figure) record (stream (eql (find-pane-named *application-frame* 'canvas))) (state (eql :highlight))) ...) Can anybody help? Thanks, Orm Finnendahl