Changeset 2755
- Timestamp:
- 03/17/08 15:53:31 (10 months ago)
- Files:
-
- trunk/projects/bos/web/image-tree.lisp (modified) (12 diffs)
- trunk/projects/bos/web/webserver.lisp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/projects/bos/web/image-tree.lisp
r2754 r2755 321 321 (geo-height :initarg :geo-height :reader geo-height) 322 322 (children :initarg :children :reader children) 323 (parent :reader parent))) 323 (parent :reader parent) 324 (depth :reader depth :initarg :depth))) 324 325 325 326 (defpersistent-class image-tree (image-tree-node) … … 338 339 339 340 (defun make-image-tree-node (image &key geo-rect children 340 (class-name 'image-tree-node)) 341 (class-name 'image-tree-node) 342 depth) 341 343 (destructuring-bind (geo-x geo-y geo-width geo-height) 342 344 geo-rect … … 348 350 :geo-width ,geo-width 349 351 :geo-height ,geo-height 350 :children ,children)))) 352 :children ,children 353 :depth ,depth)))) 351 354 352 355 (defun image-tree-node-less (a b) … … 357 360 (t nil))) 358 361 362 ;; (defmethod lod-min ((obj image-tree-node)) 363 ;; (/ (min (store-image-width obj) (store-image-height obj)) 2.0)) 364 365 ;; (defmethod lod-min ((obj image-tree)) 366 ;; 900) 367 368 ;; (defmethod lod-max ((obj image-tree-node)) 369 ;; (if (children obj) 370 ;; (* (store-image-width obj) (store-image-height obj)) 371 ;; -1)) 372 359 373 (defmethod lod-min ((obj image-tree-node)) 360 (/ (min (store-image-width obj) (store-image-height obj)) 2.0)) 361 362 (defmethod lod-min ((obj image-tree)) 363 900) 374 256) 364 375 365 376 (defmethod lod-max ((obj image-tree-node)) 366 (if (children obj) 367 (* (store-image-width obj) (store-image-height obj)) 368 -1)) 377 -1) 369 378 370 379 (defun children-sizes (width height &key (divisor 2)) … … 380 389 (divide-almost-equally height)))) 381 390 382 (defun map-children-rects (function left top width-heights )383 "Calls FUNCTION with (x y width height ) for each of the sub-rectangles391 (defun map-children-rects (function left top width-heights depth) 392 "Calls FUNCTION with (x y width height depth) for each of the sub-rectangles 384 393 specified by the start point LEFT, TOP and WIDTH-HEIGHTS of the sub-rectangles. 385 394 Collects the results into an array of dimensions corresponding to WIDTH-HEIGHTS." … … 390 399 (let ((safe-top top)) ; pretty ugly, sorry 391 400 (dolist (h heights) 392 (push (funcall function left safe-top w h ) results)401 (push (funcall function left safe-top w h depth) results) 393 402 (incf safe-top h))) 394 403 (incf left w))))) … … 418 427 (and (<= image-width output-images-size) 419 428 (<= image-height output-images-size))) 420 (%make-image-tree (image-x image-y image-width image-height )429 (%make-image-tree (image-x image-y image-width image-height depth) 421 430 (let ((class (pop classes)) 422 431 (children (unless (image-small-enough image-width image-height) … … 424 433 (map-children-rects #'%make-image-tree 425 434 image-x image-y 426 (children-sizes image-width image-height)) 435 (children-sizes image-width image-height) 436 (1+ depth)) 427 437 #'image-tree-node-less)))) 428 438 (cl-gd:with-image (image output-images-size output-images-size t) … … 441 451 (list image-x image-y image-width image-height)) 442 452 :children children 443 :class-name class))))) 453 :class-name class 454 :depth depth))))) 444 455 (with-image-tree-node-counter 445 (%make-image-tree 0 0 source-image-width source-image-height ))))))456 (%make-image-tree 0 0 source-image-width source-image-height 0)))))) 446 457 447 458 … … 481 492 (format nil "image-tree/~d" (store-object-id (parent object))))) 482 493 "go to parent")))) 483 (:p " lod-min:" (:princ (lod-min object)) "lod-max:" (:princ (lod-max object)))494 (:p "depth: " (:princ (depth object)) "lod-min:" (:princ (lod-min object)) "lod-max:" (:princ (lod-max object))) 484 495 (:table 485 496 (dolist (row (group-on (children object) :key #'geo-y :include-key nil)) … … 502 513 (kml-region rect lod) 503 514 (kml-overlay (format nil "~a:~a/image/~d" *website-url* *port* (store-object-id obj)) 504 rect 0)515 rect (depth obj)) 505 516 (dolist (child (children obj)) 506 517 (kml-network-link (format nil "~a:~a/image-tree-kml/~d" *website-url* *port* (store-object-id child)) … … 508 519 (geo-width child) (geo-height child))) 509 520 `(:min ,(lod-min child) :max ,(lod-max child)))))))) 521 522 (defclass image-tree-kml-latest-handler (redirect-handler) 523 ()) 524 525 (defmethod handle ((page-handler image-tree-kml-latest-handler)) 526 (redirect (format nil "~a:~a/image-tree-kml/~d" *website-url* *port* (store-object-id (car (last (class-instances 'image-tree))))))) 527 528 trunk/projects/bos/web/webserver.lisp
r2736 r2755 201 201 ("/edit-sponsor" edit-sponsor-handler) 202 202 ("/contract-kml" contract-kml-handler) 203 ("/image-tree-kml" image-tree-kml-handler) 203 ("/image-tree-kml-latest" image-tree-kml-latest-handler) 204 ("/image-tree-kml" image-tree-kml-handler) 204 205 ("/image-tree" image-tree-handler) 205 206 ("/contract-image" contract-image-handler)
