Megatest

Check-in [04f3e0f7d5]
Login
Overview
Comment:Getting extents
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | v1.61
Files: files | file ages | folders
SHA1: 04f3e0f7d5a2043558074186674578626084d4f6
User & Date: matt on 2016-07-14 03:50:59
Other Links: branch diff | manifest | tags
Context
2016-07-14
23:31
Fixed getting extents check-in: e32e49b9ab user: matt tags: v1.61
03:50
Getting extents check-in: 04f3e0f7d5 user: matt tags: v1.61
2016-07-13
23:05
Fixed points handling for rectangles check-in: 02b5c6c31c user: matt tags: v1.61
Changes

Modified vg-test.scm from [240549bb15] to [90d7b39a30].

15
16
17
18
19
20
21
22








23
24
25
26
27
28
29

;; add the l1 lib to drawing with name firstlib
(vg:add-lib d1 "firstlib" l1)

;; instantiate firstlib/firstcomp as inst1 in drawing d1 at 0,0
(vg:instantiate d1 "firstlib" "firstcomp" "inst1" 0 0)
(vg:instantiate d1 "firstlib" "firstcomp" "inst2" 200 200)
;; (vg:drawing-scalex-set! d1 2)









(define cnv #f)
(define the-cnv (canvas 
		 #:size "500x400"
		 #:expand "YES"
		 #:scrollbar "YES"
		 #:posx "0.5"







|
>
>
>
>
>
>
>
>







15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37

;; add the l1 lib to drawing with name firstlib
(vg:add-lib d1 "firstlib" l1)

;; instantiate firstlib/firstcomp as inst1 in drawing d1 at 0,0
(vg:instantiate d1 "firstlib" "firstcomp" "inst1" 0 0)
(vg:instantiate d1 "firstlib" "firstcomp" "inst2" 200 200)
(vg:drawing-scalex-set! d1 1.1)
(vg:drawing-scaley-set! d1 0.5)

;; (define xtnts (vg:scale-offset-xy 
;; 	       (vg:component-get-extents c1)
;; 	       1.1 1.1 -2 -2))

(define xtnts (apply vg:grow-rect 10 10 (vg:components-get-extents c1)))
(vg:add-objs-to-comp c1 (apply vg:make-rect xtnts))

(define cnv #f)
(define the-cnv (canvas 
		 #:size "500x400"
		 #:expand "YES"
		 #:scrollbar "YES"
		 #:posx "0.5"

Modified vg.scm from [42cf0e9697] to [40e90c99ca].

105
106
107
108
109
110
111







112
113
114
115
116
117
118
(define (vg:obj-get-extents obj)
  (let ((type (vg:obj-type obj)))
    (case type
      ((r)(vg:rect-get-extents obj)))))

(define (vg:rect-get-extents obj)
  (vg:obj-pts obj)) ;; extents are just the points for a rectangle








;;======================================================================
;; components
;;======================================================================

;; add obj to comp
;;







>
>
>
>
>
>
>







105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
(define (vg:obj-get-extents obj)
  (let ((type (vg:obj-type obj)))
    (case type
      ((r)(vg:rect-get-extents obj)))))

(define (vg:rect-get-extents obj)
  (vg:obj-pts obj)) ;; extents are just the points for a rectangle

(define (vg:grow-rect borderx bordery x1 y1 x2 y2)
  (list
   (- x1 borderx)
   (- y1 bordery)
   (+ x2 borderx)
   (+ y2 bordery)))

;;======================================================================
;; components
;;======================================================================

;; add obj to comp
;;
137
138
139
140
141
142
143
144
145
146
147
148


149
150
151
152
153
154
155
156
157
158
159
160
161

162
163
164
165
166
167
168
169
170

;; get component from drawing (look in apropriate lib) given libname and compname
(define (vg:get-component drawing libname compname)
  (let* ((lib  (hash-table-ref (vg:drawing-libs drawing) libname))
	 (inst (hash-table-ref (vg:lib-comps lib) compname)))
    inst))

(define (vg:component-get-extents comp)
  (let ((llx #f)
	(lly #f)
	(ulx #f)
	(uly #f)


	(objs (vg:comp-objs comp)))
    (for-each
     (lambda (obj)
       (let* ((extents (vg:get-extents obj))
	      (ollx    (list-ref extents 0))
	      (olly    (list-ref extents 1))
	      (oulx    (list-ref extents 2))
	      (ouly    (list-ref extents 3)))
	 (if (or (not llx)(< ollx llx))(set! llx ollx))
	 (if (or (not lly)(< olly llx))(set! llx ollx))
	 (if (or (not ulx)(< ollx llx))(set! llx ollx))
	 (if (or (not uly)(< ollx llx))(set! llx ollx))))
     objs)

    (list llx lly ulx uly)))


;;======================================================================
;; libraries
;;======================================================================

;; register lib with drawing








|



|
>
>
|
|
|
|
|
|
|
|
|
|
|
|
|
>

<







144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172

173
174
175
176
177
178
179

;; get component from drawing (look in apropriate lib) given libname and compname
(define (vg:get-component drawing libname compname)
  (let* ((lib  (hash-table-ref (vg:drawing-libs drawing) libname))
	 (inst (hash-table-ref (vg:lib-comps lib) compname)))
    inst))

(define (vg:components-get-extents . comps)
  (let ((llx #f)
	(lly #f)
	(ulx #f)
	(uly #f))
    (for-each
     (lambda (comp)
       (let ((objs (vg:comp-objs comp)))
	 (for-each
	  (lambda (obj)
	    (let* ((extents (vg:obj-get-extents obj))
		   (ollx    (list-ref extents 0))
		   (olly    (list-ref extents 1))
		   (oulx    (list-ref extents 2))
		   (ouly    (list-ref extents 3)))
	      (if (or (not llx)(< ollx llx))(set! llx ollx))
	      (if (or (not lly)(< olly lly))(set! lly olly))
	      (if (or (not ulx)(> oulx ulx))(set! ulx oulx))
	      (if (or (not uly)(> ouly uly))(set! uly ouly))))
	  objs)))
     comps)
    (list llx lly ulx uly)))


;;======================================================================
;; libraries
;;======================================================================

;; register lib with drawing