Index: dashboard.scm ================================================================== --- dashboard.scm +++ dashboard.scm @@ -861,11 +861,10 @@ ;; (canvas-origin-set! cnv 0 (- (/ sizey 2))) (if (hash-table-ref/default tests-draw-state 'first-time #t) (begin (hash-table-set! tests-draw-state 'first-time #f) (hash-table-set! tests-draw-state 'scalef 1) - (hash-table-set! tests-draw-state 'dotscale 10.5) (hash-table-set! tests-draw-state 'tests-info (make-hash-table)) (hash-table-set! tests-draw-state 'selected-tests (make-hash-table)) ;; set these (hash-table-set! tests-draw-state 'test-browse-xoffset 20) ;; (- 0 (* (/ sizex 2) (* 8 xadj)))) (hash-table-set! tests-draw-state 'test-browse-yoffset 20) ;; (- 0 (* (/ sizey 2) (* 8 (- 1 yadj))))))) @@ -899,11 +898,10 @@ (dashboard:update-run-command)))) (tests-draw-state (make-hash-table)) ;; use for keeping state of the test canvas (test-patterns-textbox #f)) (hash-table-set! tests-draw-state 'first-time #t) ;; (hash-table-set! tests-draw-state 'scalef 1) - ;; (hash-table-set! tests-draw-state 'dotscale 60) (tests:get-full-data test-names test-records '() all-tests-registry) (set! sorted-testnames (tests:sort-by-priority-and-waiton test-records)) ;; refer to (d:alldat-keys *alldat*), (d:alldat-dbkeys *alldat*) for keys (iup:vbox @@ -1057,26 +1055,16 @@ (set! the-cnv cnv) )) ;; Following doesn't work #:wheel-cb (lambda (obj step x y dir) ;; dir is 4 for up and 5 for down. I think. (let ((scalef (hash-table-ref tests-draw-state 'scalef))) - ;; (debug:print 0 "step=" step ", dir=" dir ", scalef=" scalef ", x=" x ", y=" y) - ;; (let (;; (xadj last-xadj) - ;; (yadj (+ last-yadj (if (> step 0) - ;; -0.01 - ;; 0.01)))) (hash-table-set! tests-draw-state 'scalef (+ scalef (if (> step 0) - 0.01 - -0.01))) - - ;; (print "step: " step " x: " x " y: " y " dir: \"" dir "\"") - ;; (print "the-cnv: " the-cnv " obj: " obj " xadj: " xadj " yadj: " yadj " dir: " dir) + (* scalef 0.01) + (* scalef -0.01)))) (if the-cnv (dashboard:draw-tests the-cnv last-xadj last-yadj tests-draw-state sorted-testnames test-records)) - ;; (set! last-xadj xadj) - ;; (set! last-yadj yadj) )) ;; #:size "50x50" #:expand "YES" #:scrollbar "YES" #:posx "0.5" @@ -1085,25 +1073,29 @@ (print "obj: " obj ", pressed " pressed ", status " status) (print "canvas-origin: " (canvas-origin the-cnv)) (let-values (((xx yy)(canvas-origin the-cnv))) (canvas-transform-set! the-cnv #f) (print "canvas-origin: " xx " " yy " click at " x " " y)) - (let ((tests-info (hash-table-ref tests-draw-state 'tests-info)) - (selected-tests (hash-table-ref tests-draw-state 'selected-tests))) + (let* ((tests-info (hash-table-ref tests-draw-state 'tests-info)) + (selected-tests (hash-table-ref tests-draw-state 'selected-tests)) + (scalef (hash-table-ref tests-draw-state 'scalef)) + (x-scaled (/ x scalef)) + (y-scaled (/ y scalef))) ;; (print "\tx\ty\tllx\tlly\turx\tury") (for-each (lambda (test-name) (let* ((rec-coords (hash-table-ref tests-info test-name)) (llx (list-ref rec-coords 0)) (urx (list-ref rec-coords 1)) (lly (list-ref rec-coords 2)) (ury (list-ref rec-coords 3))) - ;; (print "\t" x "\t" y "\t" llx "\t" lly "\t" urx "\t" ury "\t" test-name " ") + (if (eq? pressed 1) + (print "\tx=" x "\ty=" y "\t" llx "\t" lly "\t" urx "\t" ury "\t" test-name " ")) (if (and (eq? pressed 1) - (> x llx) - (> y lly) - (< x urx) - (< y ury)) + (>= x-scaled llx) + (>= y-scaled lly) + (<= x-scaled urx) + (<= y-scaled ury)) (let ((patterns (string-split (iup:attribute test-patterns-textbox "VALUE")))) (let* ((selected (not (member test-name patterns))) (newpatt-list (if selected (cons test-name patterns) (delete test-name patterns))) Index: dcommon.scm ================================================================== --- dcommon.scm +++ dcommon.scm @@ -681,23 +681,45 @@ waitons) ;; (debug:print 0 "test-box-info=" test-box-info) ;; (debug:print 0 "test-record=" test-record) )) +(define (dcommon:estimate-scale sizex sizey originx originy nodes) + (print "sizex: " sizex " sizey: " sizey " originx: " originx " originy: " originy " nodes: " nodes) + (let* ((maxx 1) + (maxy 1)) + (for-each + (lambda (node) + (if (equal? (car node) "node") + (let ((x (string->number (list-ref node 2))) + (y (string->number (list-ref node 3)))) + (if (and x (> x maxx))(set! maxx x)) + (if (and y (> y maxy))(set! maxy y))))) + nodes) + (let ((scalex (/ sizex maxx)) + (scaley (/ sizey maxy))) + (print "maxx: " maxx " maxy: " maxy " scalex: " scalex " scaley: " scaley) + (min scalex scaley)))) + +;; sizex, sizey - canvas size +;; originx, originy - canvas origin +;; (define (dcommon:initial-draw-tests cnv xadj yadj sizex sizey sizexmm sizeymm originx originy tests-draw-state sorted-testnames test-records) (let* ((dot-data ;; (map cdr (filter ;; (lambda (x)(equal? "node" (car x))) - (map string-split (tests:lazy-dot test-records "plain"))) ;; (tests:easy-dot test-records "plain"))) - (scalef (hash-table-ref tests-draw-state 'scalef)) - (dotscale (hash-table-ref tests-draw-state 'dotscale)) + (map string-split (tests:lazy-dot test-records "plain" sizex sizey))) ;; (tests:easy-dot test-records "plain"))) (test-browse-xoffset (hash-table-ref tests-draw-state 'test-browse-xoffset)) (test-browse-yoffset (hash-table-ref tests-draw-state 'test-browse-yoffset)) (xtorig (+ test-browse-xoffset (* (/ sizex 2) 1 (- 0.5 xadj)))) ;; (- xadj 1)))) (ytorig (+ test-browse-yoffset (* (/ sizey 2) 1 (- yadj 0.5)))) (boxw 10) (tests-hash (hash-table-ref tests-draw-state 'tests-info)) - (selected-tests (hash-table-ref tests-draw-state 'selected-tests ))) + (selected-tests (hash-table-ref tests-draw-state 'selected-tests )) + (scalef (dcommon:estimate-scale sizex sizey originx originy dot-data))) + + (hash-table-set! tests-draw-state 'scalef scalef) + ;; (print "dot-data=" dot-data) (hash-table-set! tests-draw-state 'xtorig xtorig) (hash-table-set! tests-draw-state 'ytorig ytorig) (let ((longest-str (if (null? sorted-testnames) " " (car (sort sorted-testnames (lambda (a b)(>= (string-length a)(string-length b)))))))) (let-values (((x-max y-max) (canvas-text-size cnv longest-str))) @@ -712,11 +734,11 @@ (equal? hed (cadr x)) #f)) dot-data))) (if (null? tmpres) ;; llx lly boxw boxh - (list "0" "1" "1" (conc (length tal)) "2" "0.5") ;; return some junk + (list "0" "1" "1" (conc (length tal)) "2" "0.5") ;; return some placeholder junk if no dat found (car tmpres)))) (edgedat (let ((edges (filter (lambda (x) ;; filter for edge (if (and (not (null? x)) (equal? (car x) "edge")) (equal? hed (cadr x)) @@ -723,22 +745,22 @@ #f)) dot-data))) (map (lambda (inlst) (dcommon:process-polyline (map (lambda (instr) - (* dotscale (string->number instr))) ;; convert to number and scale + (string->number instr)) ;; convert to number and scale (let ((il (cddddr inlst))) (take il (- (length il) 2)))) (lambda (x y) - (list (+ x xtorig) - (+ y ytorig))) + (list (+ x 0) ;; xtorig) + (+ y 0))) ;; ytorig))) #f #f)) ;; process polyline edges))) - (llx (* (string->number (list-ref nodedat 2)) dotscale)) - (lly (* (string->number (list-ref nodedat 3)) dotscale)) - (boxw (* (string->number (list-ref nodedat 4)) dotscale)) - (boxh (* (string->number (list-ref nodedat 5)) dotscale)) + (llx (string->number (list-ref nodedat 2))) + (lly (string->number (list-ref nodedat 3))) + (boxw (string->number (list-ref nodedat 4))) + (boxh (string->number (list-ref nodedat 5))) (urx (+ llx boxw)) (ury (+ lly boxh))) ; (print "hed " hed " llx " llx " lly " lly " urx " urx " ury " ury) (dcommon:draw-test cnv scalef llx lly boxw boxh hed (hash-table-ref/default selected-tests hed #f)) ;; (dcommon:draw-arrows cnv testname tests-hash test-records)) Index: http-transport.scm ================================================================== --- http-transport.scm +++ http-transport.scm @@ -89,10 +89,13 @@ (mutex-lock! *heartbeat-mutex*) (set! *last-db-access* (current-seconds)) (mutex-unlock! *heartbeat-mutex*)) ((equal? (uri-path (request-uri (current-request))) '(/ "")) + (send-response body: (http-transport:main-page))) + ((equal? (uri-path (request-uri (current-request))) + '(/ "json_api")) (send-response body: (http-transport:main-page))) ((equal? (uri-path (request-uri (current-request))) '(/ "runs")) (send-response body: (http-transport:main-page))) ((equal? (uri-path (request-uri (current-request))) Index: tests.scm ================================================================== --- tests.scm +++ tests.scm @@ -880,32 +880,33 @@ (lambda () (let ((res (read-lines))) ;; (delete-file temp-path) res)))))) -(define (tests:write-dot-file test-records fname) +(define (tests:write-dot-file test-records fname sizex sizey) (if (file-write-access? (pathname-directory fname)) (with-output-to-file fname (lambda () - (map print (tests:tests->dot test-records)))))) + (map print (tests:tests->dot test-records sizex sizey)))))) -(define (tests:tests->dot test-records) +(define (tests:tests->dot test-records sizex sizey) (let ((all-testnames (hash-table-keys test-records))) (if (null? all-testnames) '() (let loop ((hed (car all-testnames)) (tal (cdr all-testnames)) (res (list "digraph tests {" - " size=\"11,11\";" - " ratio=0.9;"))) + (conc " size=\"" (or sizex 11) "," (or sizey 11) "\";") + " ratio=0.95;" + ))) (let* ((testrec (hash-table-ref test-records hed)) (waitons (or (tests:testqueue-get-waitons testrec) '())) (newres (append res (if (null? waitons) - (list (conc " \"" hed "\";")) + (list (conc " \"" hed "\" [shape=box];")) (map (lambda (waiton) - (conc " \"" waiton "\" -> \"" hed "\";")) + (conc " \"" waiton "\" -> \"" hed "\" [shape=box];")) waitons) )))) (if (null? tal) (append newres (list "}")) (loop (car tal)(cdr tal) newres) @@ -926,14 +927,14 @@ res))) ;; read data from tmp file or create if not exists ;; if exists regen in background ;; -(define (tests:lazy-dot testrecords outtype) +(define (tests:lazy-dot testrecords outtype sizex sizey) (let ((dfile (conc "/tmp/." (current-user-name) "-" (server:mk-signature) ".dot")) (fname (conc "/tmp/." (current-user-name) "-" (server:mk-signature) ".dotdat"))) - (tests:write-dot-file testrecords dfile) + (tests:write-dot-file testrecords dfile sizex sizey) (if (file-exists? fname) (let ((res (with-input-from-file fname (lambda () (read-lines))))) (system (conc "env -i PATH=$PATH dot -T " outtype " < " dfile " > " fname "&"))