Hi *,
I'm new to CLIM and currently looking for a good (and simple) way to redisplay a rendered picture (my toy program is an mandelbrot generator).
My problem is, that the :display-function which in my case simply copies a pixmap to the application pane is less often called than actual redisplay is needed.
Given the following simple example code:
--8<---------------cut here---------------start------------->8--- (in-package :common-lisp-user)
(defpackage "APP" (:use :clim :clim-lisp) (:export "APP-MAIN"))
(in-package :app)
(define-application-frame superapp () ((gfx :initform nil :accessor gfx) (redisplay-counter :initform 0 :accessor redisplaynr)) (:pointer-documentation t) (:panes (app :application :display-function #'redraw-gfx :height 400 :width 600) (int :interactor :height 400 :width 600)) (:layouts (default (vertically () app int))))
(define-superapp-command (com-draw :name t) () (setf (gfx *application-frame*) (allocate-pixmap (frame-standard-output *application-frame*) 600 400)) (draw-line* (gfx *application-frame*) 0 0 599 399 :ink +red+))
(defun redraw-gfx (frame pane) (if (gfx frame) (progn (copy-from-pixmap (gfx frame) 0 0 600 400 pane 10 10) (format pane "Redisplay #~a" (incf (redisplaynr frame)))) (format pane "No pic yet...")))
(defun app-main () (run-frame-top-level (make-application-frame 'superapp))) --8<---------------cut here---------------end--------------->8---
Run and issue the command "Draw", ok now the pixmap is displayed. But when a part of the frame is obscured by another window after getting the CLIM frame back to front the redisplay function is _not_ called. (Can be seen, both, by not refreshing the pixmap and not incrementing the redisplay-counter).
BUT: The string "Redisplay #1" _is_ redrawn, so some more low level part of CLIM knows that a redraw is needed and does that for the text send to the standard output stream.
So two questions: 1. What do I have to do, so that the
Sascha Wilde wilde@sha-bang.de wrote:
Sorry, send the last message to early per accident, here are the missing questions:
BUT: The string "Redisplay #1" _is_ redrawn, so some more low level part of CLIM knows that a redraw is needed and does that for the text send to the standard output stream.
So two questions:
1. What do I have to do, so that the display-function is called _every time_ a redisplay is needed?
2. Is there a better way to ensure that the picture is redisplayed whenever needed, maybe even that magical es done with the text?
I know that this happens with graphics directly drawn to the pane, but as I want to draw rendered images, which basically consist of hundreds of thousands of draw-point operations this is way to slow...
cheers sascha
В сообщении от Monday 11 August 2008 13:24:19 Sascha Wilde написал(а):
Sascha Wilde wilde@sha-bang.de wrote:
Sorry, send the last message to early per accident, here are the missing
questions:
BUT: The string "Redisplay #1" _is_ redrawn, so some more low level part of CLIM knows that a redraw is needed and does that for the text send to the standard output stream.
So two questions:
What do I have to do, so that the display-function is called _every time_ a redisplay is needed?
Is there a better way to ensure that the picture is redisplayed whenever needed, maybe even that magical es done with the text?
There is a :display-time initarg for panes. It controls when the :display-function is called.
But, there is a handle-repaint method (which is a part of Sheet Repaint Protocol) that does the repaint. As I understand, :display-function is a more high-level (it's defined for stream panes), and it outputs not pixels on screen (which is a job for handle-repaint), but outputs objects onto pane.
(I myself do not have a good knowledge of CLIM, so whatever I say might be wrong).
Кальянов Дмитрий kalyanov.dmitry@gmail.com wrote:
В сообщении от Monday 11 August 2008 13:24:19 Sascha Wilde написал(а):
Sascha Wilde wilde@sha-bang.de wrote:
Sorry, send the last message to early per accident, here are the missing
questions:
BUT: The string "Redisplay #1" _is_ redrawn, so some more low level part of CLIM knows that a redraw is needed and does that for the text send to the standard output stream.
So two questions:
What do I have to do, so that the display-function is called _every time_ a redisplay is needed?
Is there a better way to ensure that the picture is redisplayed whenever needed, maybe even that magical es done with the text?
There is a :display-time initarg for panes. It controls when the :display-function is called.
I know, but I didn't find an arg to :display-time which did what I wanted (actually I had a hard time finding any useful documentation at the possible values).
But, there is a handle-repaint method (which is a part of Sheet Repaint Protocol) that does the repaint.
Indeed,
(defmethod handle-repaint ((pane application-pane) region) (redraw-gfx *application-frame* pane))
does what I want. Thanks for pushing me into the right direction!
cheers sascha