0
|
1 |
"
|
|
2 |
COPYRIGHT (c) 1992 by Claus Gittinger
|
72
|
3 |
All Rights Reserved
|
0
|
4 |
|
|
5 |
This software is furnished under a license and may be used
|
|
6 |
only in accordance with the terms of that license and with the
|
|
7 |
inclusion of the above copyright notice. This software may not
|
|
8 |
be provided or otherwise made available to, or used by, any
|
|
9 |
other person. No title to or ownership of the software is
|
|
10 |
hereby transferred.
|
|
11 |
"
|
|
12 |
|
601
|
13 |
Object subclass:#WindowingTransformation
|
|
14 |
instanceVariableNames:'scale translation'
|
|
15 |
classVariableNames:''
|
|
16 |
poolDictionaries:''
|
|
17 |
category:'Graphics-Support'
|
|
18 |
!
|
|
19 |
|
|
20 |
!WindowingTransformation class methodsFor:'instance creation'!
|
|
21 |
|
|
22 |
identity
|
|
23 |
"returns a windowing transformation with no scaling (1@1)
|
|
24 |
and no translation (0@0)."
|
|
25 |
|
1148
|
26 |
^ self basicNew "/ scale:nil translation:nil
|
|
27 |
|
|
28 |
"
|
|
29 |
WindowingTransformation identity
|
|
30 |
"
|
|
31 |
|
|
32 |
"Modified: 30.12.1996 / 16:59:27 / cg"
|
601
|
33 |
!
|
|
34 |
|
|
35 |
scale:aScale translation:aTranslation
|
|
36 |
"returns a windowing transformation with a scale factor of
|
|
37 |
aScale and a translation offset of aTranslation."
|
|
38 |
|
|
39 |
^ self basicNew scale:aScale translation:aTranslation
|
|
40 |
|
|
41 |
"
|
|
42 |
|v|
|
|
43 |
|
|
44 |
v := View new realize.
|
|
45 |
(Delay forSeconds:3) wait.
|
|
46 |
v transformation:(WindowingTransformation scale:2 translation:0).
|
|
47 |
'now, everything is magnfied by 2'.
|
|
48 |
v displayLineFrom:10@10 to:30@30
|
|
49 |
"
|
|
50 |
"
|
|
51 |
|v|
|
|
52 |
|
|
53 |
v := View new realize.
|
|
54 |
(Delay forSeconds:3) wait.
|
|
55 |
v transformation:(WindowingTransformation scale:0.5 translation:0).
|
|
56 |
'now, everything is shrunk by 2'.
|
|
57 |
v displayLineFrom:10@10 to:30@30
|
|
58 |
"
|
|
59 |
!
|
|
60 |
|
|
61 |
unit:unitSymbol on:device
|
|
62 |
"returns a windowing transformation with scaling
|
|
63 |
for unitSymbol and no translation (0@0).
|
|
64 |
With such a transformation, you can draw in your preferred
|
|
65 |
units.
|
|
66 |
UnitSymbol may be #mm, #cm, #inch, #point, #twip or #pixel (default).
|
|
67 |
Twip is 1/20th of a point, point is 1/72th of an inch
|
|
68 |
(i.e. the print-unit which is also used for font sizes etc.)
|
|
69 |
- not to confuse with device pixels."
|
|
70 |
|
1148
|
71 |
|ppmm ppi scale|
|
|
72 |
|
|
73 |
ppmm := device pixelPerMillimeter.
|
|
74 |
ppi := device pixelPerInch.
|
72
|
75 |
|
601
|
76 |
unitSymbol == #mm ifTrue:[
|
1148
|
77 |
scale := ppmm.
|
601
|
78 |
] ifFalse:[
|
1148
|
79 |
unitSymbol == #cm ifTrue:[
|
|
80 |
scale := ppmm * 10.
|
|
81 |
] ifFalse:[
|
|
82 |
unitSymbol == #twip ifTrue:[
|
|
83 |
scale := ppi / 1440.
|
|
84 |
] ifFalse:[
|
|
85 |
unitSymbol == #point ifTrue:[
|
|
86 |
scale := ppi / 72.
|
|
87 |
] ifFalse:[
|
|
88 |
unitSymbol == #inch ifTrue:[
|
|
89 |
scale := ppi.
|
|
90 |
] ifFalse:[
|
|
91 |
"sorry: unknown unit is taken as pixel"
|
|
92 |
^ self new scale:nil translation:nil
|
|
93 |
]
|
|
94 |
]
|
|
95 |
]
|
|
96 |
]
|
601
|
97 |
].
|
1148
|
98 |
^ self basicNew scale:scale translation:nil
|
601
|
99 |
|
|
100 |
"
|
|
101 |
|v|
|
|
102 |
|
1148
|
103 |
v := View new openAndWait.
|
601
|
104 |
(Delay forSeconds:3) wait.
|
|
105 |
v transformation:(WindowingTransformation unit:#inch on:Display).
|
|
106 |
'now, we can think of drawing in inches ...'.
|
|
107 |
v displayLineFrom:0.5@0.5 to:1@1
|
|
108 |
"
|
1148
|
109 |
"
|
|
110 |
|v|
|
|
111 |
|
|
112 |
v := View new openAndWait.
|
|
113 |
(Delay forSeconds:3) wait.
|
|
114 |
v transformation:(WindowingTransformation unit:#mm on:Display).
|
|
115 |
'now, we can think of drawing in millimeters ...'.
|
|
116 |
v displayLineFrom:2@2 to:10@10
|
|
117 |
"
|
|
118 |
|
|
119 |
"Modified: 30.12.1996 / 16:57:59 / cg"
|
72
|
120 |
!
|
0
|
121 |
|
601
|
122 |
window:sourceRectangle viewport:destinationRectangle
|
|
123 |
"returns a windowing transformation with a scale and
|
|
124 |
translation computed from sourceRectangle and destinationRectangle.
|
|
125 |
The scale and transformation are computed such that sourceRectangle
|
|
126 |
is transformed to destinationRectangle. Typically sourceRectangle
|
|
127 |
represents the logical coordinateSpace while destinationRectangle
|
|
128 |
represents the device coordinateSpace."
|
|
129 |
|
|
130 |
|sX sY tX tY newScale newTranslation|
|
|
131 |
|
|
132 |
sX := destinationRectangle width / sourceRectangle width.
|
|
133 |
sY := destinationRectangle height / sourceRectangle height.
|
|
134 |
tX := destinationRectangle left - sourceRectangle left.
|
|
135 |
tY := destinationRectangle top - sourceRectangle top.
|
|
136 |
((tX = 1.0) and:[tY = 1.0]) ifTrue:[
|
|
137 |
newTranslation := nil
|
|
138 |
] ifFalse:[
|
|
139 |
newTranslation := tX @ tY
|
|
140 |
].
|
|
141 |
((sX = 1.0) and:[sY = 1.0]) ifTrue:[
|
|
142 |
newScale := nil
|
|
143 |
] ifFalse:[
|
|
144 |
newScale := sX @ sY
|
|
145 |
].
|
|
146 |
^ self basicNew scale:newScale translation:newTranslation
|
|
147 |
|
|
148 |
"
|
|
149 |
|v|
|
|
150 |
|
|
151 |
v := View new realize.
|
|
152 |
(Delay forSeconds:3) wait.
|
|
153 |
v transformation:(WindowingTransformation
|
|
154 |
window:(0@0 corner:1@1)
|
|
155 |
viewport:(0@0 corner:100@100)).
|
|
156 |
'now, we can think of drawing in 0..1/0..1 coordinates'.
|
|
157 |
v displayLineFrom:0.1@0.1 to:0.9@0.9
|
|
158 |
"
|
|
159 |
! !
|
|
160 |
|
78
|
161 |
!WindowingTransformation class methodsFor:'documentation '!
|
|
162 |
|
|
163 |
copyright
|
|
164 |
"
|
|
165 |
COPYRIGHT (c) 1992 by Claus Gittinger
|
|
166 |
All Rights Reserved
|
|
167 |
|
|
168 |
This software is furnished under a license and may be used
|
|
169 |
only in accordance with the terms of that license and with the
|
|
170 |
inclusion of the above copyright notice. This software may not
|
|
171 |
be provided or otherwise made available to, or used by, any
|
|
172 |
other person. No title to or ownership of the software is
|
|
173 |
hereby transferred.
|
|
174 |
"
|
|
175 |
!
|
|
176 |
|
|
177 |
documentation
|
|
178 |
"
|
|
179 |
instances of WindowingTransformation can be used to scale, translate or
|
|
180 |
generally transform other objects in 2D space.
|
|
181 |
They can also be set as the translation in a graphic context,
|
|
182 |
which will then apply this to all of its drawing operations
|
|
183 |
(see GraphicContext>>transformation:).
|
|
184 |
|
|
185 |
All 2-D objects are supposed to be able to be transformed using
|
|
186 |
instances of me. Multiple instances of me can also be combined to form a
|
|
187 |
single composite transformation.
|
|
188 |
|
611
|
189 |
[Instance variables:]
|
|
190 |
scale <Number> or <Point> representing a linear scaling factor.
|
|
191 |
nil is interpreted as 1@1
|
|
192 |
|
|
193 |
translation <Number> or <Point> representing a translation in 2-D.
|
|
194 |
nil is interpreted as 0@0
|
78
|
195 |
|
|
196 |
|
611
|
197 |
[author:]
|
|
198 |
Claus Gittinger
|
81
|
199 |
"
|
611
|
200 |
|
|
201 |
"Modified: 25.4.1996 / 16:53:07 / cg"
|
81
|
202 |
!
|
78
|
203 |
|
81
|
204 |
examples
|
|
205 |
"
|
78
|
206 |
example (drawing in inches):
|
619
|
207 |
[exBegin]
|
78
|
208 |
|v|
|
|
209 |
|
|
210 |
v := View new realize.
|
|
211 |
(Delay forSeconds:3) wait.
|
|
212 |
v transformation:(WindowingTransformation unit:#inch on:Display).
|
|
213 |
'now, we can think of drawing in inches ...'.
|
|
214 |
v displayLineFrom:0.5@0.5 to:1@1
|
619
|
215 |
[exEnd]
|
78
|
216 |
|
|
217 |
|
|
218 |
example (drawing in millimeters):
|
619
|
219 |
[exBegin]
|
78
|
220 |
|v|
|
|
221 |
|
|
222 |
v := View new realize.
|
|
223 |
(Delay forSeconds:3) wait.
|
|
224 |
v transformation:(WindowingTransformation unit:#mm on:Display).
|
|
225 |
'now, we can think of drawing in millimeters ...'.
|
|
226 |
v displayLineFrom:5@5 to:20@5
|
619
|
227 |
[exEnd]
|
78
|
228 |
|
|
229 |
|
|
230 |
example (drawing magnified):
|
619
|
231 |
[exBegin]
|
78
|
232 |
|v|
|
|
233 |
|
|
234 |
v := View new realize.
|
|
235 |
(Delay forSeconds:3) wait.
|
|
236 |
v transformation:(WindowingTransformation scale:2 translation:0).
|
|
237 |
'now, everything is magnfied by 2'.
|
|
238 |
v displayLineFrom:10@10 to:30@30
|
619
|
239 |
[exEnd]
|
78
|
240 |
|
|
241 |
example (drawing shrunk):
|
619
|
242 |
[exBegin]
|
78
|
243 |
|v|
|
|
244 |
|
|
245 |
v := View new realize.
|
|
246 |
(Delay forSeconds:3) wait.
|
|
247 |
v transformation:(WindowingTransformation scale:0.5 translation:0).
|
|
248 |
'now, everything is shrunk by 2'.
|
|
249 |
v displayLineFrom:10@10 to:30@30
|
619
|
250 |
[exEnd]
|
|
251 |
"
|
78
|
252 |
|
619
|
253 |
"Modified: 27.4.1996 / 19:45:43 / cg"
|
601
|
254 |
!
|
|
255 |
|
|
256 |
version
|
2147
|
257 |
^ '$Header: /cvs/stx/stx/libview/WindowingTransformation.st,v 1.16 1998-06-13 11:59:43 cg Exp $'
|
78
|
258 |
! !
|
|
259 |
|
601
|
260 |
!WindowingTransformation methodsFor:'accessing'!
|
|
261 |
|
|
262 |
scale
|
|
263 |
"return a copy of the Point that represents the
|
|
264 |
current scale of the receiver."
|
72
|
265 |
|
601
|
266 |
scale isNil ifTrue:[^ (1@1) copy].
|
|
267 |
^ scale copy
|
|
268 |
!
|
72
|
269 |
|
601
|
270 |
scale:aScale
|
|
271 |
"Set the receiver's scale to aScale, a Point or Number."
|
72
|
272 |
|
2147
|
273 |
(scale := aScale) notNil ifTrue:[
|
|
274 |
scale := aScale asPoint.
|
72
|
275 |
].
|
2147
|
276 |
|
|
277 |
"Modified: / 13.6.1998 / 13:56:12 / cg"
|
72
|
278 |
!
|
|
279 |
|
601
|
280 |
scale:aScale translation:aTranslation
|
|
281 |
"sets the scale to aScale and the translation to aTranslation."
|
78
|
282 |
|
2147
|
283 |
(scale := aScale) notNil ifTrue:[
|
|
284 |
scale := aScale asPoint.
|
601
|
285 |
].
|
2147
|
286 |
(translation := aTranslation) notNil ifTrue:[
|
|
287 |
translation := aTranslation asPoint
|
601
|
288 |
]
|
2147
|
289 |
|
|
290 |
"Modified: / 13.6.1998 / 13:55:51 / cg"
|
72
|
291 |
!
|
|
292 |
|
601
|
293 |
scaleOfOne
|
|
294 |
"Set the scale of the receiver to the identity scale"
|
72
|
295 |
|
601
|
296 |
scale := nil
|
72
|
297 |
!
|
|
298 |
|
705
|
299 |
scaleX
|
|
300 |
"return the current x-scale of the receiver."
|
|
301 |
|
|
302 |
scale isNil ifTrue:[^ 1].
|
|
303 |
^ scale x
|
|
304 |
|
|
305 |
"Created: 21.5.1996 / 21:13:49 / cg"
|
|
306 |
!
|
|
307 |
|
|
308 |
scaleY
|
|
309 |
"return the current x-scale of the receiver."
|
|
310 |
|
|
311 |
scale isNil ifTrue:[^ 1].
|
|
312 |
^ scale y
|
|
313 |
|
|
314 |
"Created: 21.5.1996 / 21:13:59 / cg"
|
|
315 |
!
|
|
316 |
|
601
|
317 |
translation
|
|
318 |
"return a copy of the receiver's translation."
|
|
319 |
|
|
320 |
translation isNil ifTrue:[^ (0@0) copy].
|
|
321 |
^ translation copy
|
|
322 |
!
|
72
|
323 |
|
601
|
324 |
translation:aTranslation
|
|
325 |
"Set the receiver's translation to aTranslation, a Point or Number."
|
|
326 |
|
2147
|
327 |
(translation := aTranslation) notNil ifTrue:[
|
|
328 |
translation := aTranslation asPoint
|
601
|
329 |
]
|
2147
|
330 |
|
|
331 |
"Modified: / 13.6.1998 / 13:56:02 / cg"
|
705
|
332 |
!
|
|
333 |
|
|
334 |
translationX
|
|
335 |
"return the receiver's x-translation."
|
|
336 |
|
|
337 |
translation isNil ifTrue:[^ 0].
|
|
338 |
^ translation x
|
|
339 |
|
|
340 |
"Created: 21.5.1996 / 21:13:10 / cg"
|
|
341 |
!
|
|
342 |
|
|
343 |
translationY
|
|
344 |
"return the receiver's x-translation."
|
|
345 |
|
|
346 |
translation isNil ifTrue:[^ 0].
|
|
347 |
^ translation y
|
|
348 |
|
|
349 |
"Created: 21.5.1996 / 21:13:21 / cg"
|
46
|
350 |
! !
|
0
|
351 |
|
72
|
352 |
!WindowingTransformation methodsFor:'applying transform'!
|
0
|
353 |
|
78
|
354 |
applyInverseScaleX:aNumber
|
|
355 |
"apply the scale only (if widths are to be transformed)"
|
|
356 |
|
|
357 |
scale isNil ifTrue:[^ aNumber].
|
|
358 |
^ aNumber / scale x
|
|
359 |
!
|
|
360 |
|
|
361 |
applyInverseScaleY:aNumber
|
|
362 |
"apply the scale only (if heights are to be transformed)"
|
|
363 |
|
|
364 |
scale isNil ifTrue:[^ aNumber].
|
|
365 |
^ aNumber / scale y
|
|
366 |
!
|
|
367 |
|
|
368 |
applyInverseTo:anObject
|
|
369 |
"Apply the inverse of the receiver to anObject
|
|
370 |
and return the result. This can be used to map back from logical
|
|
371 |
to physical coordinates, for example."
|
|
372 |
|
|
373 |
|transformedObject|
|
|
374 |
|
|
375 |
translation isNil ifTrue:[
|
|
376 |
scale isNil ifTrue:[
|
|
377 |
^ anObject
|
|
378 |
].
|
|
379 |
^ anObject scaledBy:self inverseScale
|
|
380 |
].
|
|
381 |
transformedObject := anObject translatedBy:(self inverseTranslation).
|
|
382 |
scale notNil ifTrue:[
|
|
383 |
transformedObject scaleBy:(self inverseScale).
|
|
384 |
].
|
|
385 |
^ transformedObject
|
|
386 |
!
|
|
387 |
|
601
|
388 |
applyInverseToX:aNumber
|
|
389 |
"Apply the receiver to a number representing an x-coordinate
|
|
390 |
and return the result."
|
|
391 |
|
|
392 |
|t s|
|
|
393 |
|
|
394 |
scale isNil ifTrue:[s := 1] ifFalse:[s := scale x].
|
|
395 |
translation isNil ifTrue:[t := 0] ifFalse:[t := translation x].
|
|
396 |
^ (aNumber - t) / s
|
|
397 |
!
|
|
398 |
|
|
399 |
applyInverseToY:aNumber
|
|
400 |
"Apply the receiver to a number representing an y-coordinate
|
|
401 |
and return the result."
|
|
402 |
|
|
403 |
|t s|
|
|
404 |
|
|
405 |
scale isNil ifTrue:[s := 1] ifFalse:[s := scale y].
|
|
406 |
translation isNil ifTrue:[t := 0] ifFalse:[t := translation y].
|
|
407 |
^ (aNumber - t) / s
|
|
408 |
!
|
|
409 |
|
|
410 |
applyScaleX:aNumber
|
|
411 |
"apply the scale only (if widths are to be transformed)"
|
|
412 |
|
|
413 |
scale isNil ifTrue:[^ aNumber].
|
|
414 |
^ aNumber * scale x
|
|
415 |
!
|
|
416 |
|
|
417 |
applyScaleY:aNumber
|
|
418 |
"apply the scale only (if heights are to be transformed)"
|
|
419 |
|
|
420 |
scale isNil ifTrue:[^ aNumber].
|
|
421 |
^ aNumber * scale y
|
|
422 |
!
|
|
423 |
|
|
424 |
applyTo:anObject
|
|
425 |
"Apply the receiver to anObject and return the result."
|
|
426 |
|
|
427 |
|transformedObject|
|
78
|
428 |
|
|
429 |
scale isNil ifTrue:[
|
|
430 |
translation isNil ifTrue:[
|
601
|
431 |
^ anObject
|
78
|
432 |
].
|
601
|
433 |
^ anObject translatedBy:translation
|
|
434 |
].
|
|
435 |
transformedObject := anObject scaledBy:scale.
|
|
436 |
translation notNil ifTrue:[
|
|
437 |
transformedObject translateBy:translation.
|
78
|
438 |
].
|
601
|
439 |
^ transformedObject
|
|
440 |
!
|
|
441 |
|
|
442 |
applyToX:aNumber
|
|
443 |
"Apply the receiver to a number representing an x-coordinate
|
|
444 |
and return the result."
|
|
445 |
|
|
446 |
|t s|
|
|
447 |
|
|
448 |
scale isNil ifTrue:[s := 1] ifFalse:[s := scale x].
|
|
449 |
translation isNil ifTrue:[t := 0] ifFalse:[t := translation x].
|
|
450 |
^ aNumber * s + t
|
|
451 |
!
|
|
452 |
|
|
453 |
applyToY:aNumber
|
|
454 |
"Apply the receiver to a number representing an y-coordinate
|
|
455 |
and return the result."
|
|
456 |
|
|
457 |
|t s|
|
|
458 |
|
|
459 |
scale isNil ifTrue:[s := 1] ifFalse:[s := scale y].
|
|
460 |
translation isNil ifTrue:[t := 0] ifFalse:[t := translation y].
|
|
461 |
^ aNumber * s + t
|
78
|
462 |
!
|
|
463 |
|
0
|
464 |
compose:aTransformation
|
|
465 |
"return a new WindowingTransformation that is the
|
|
466 |
composition of the receiver and aTransformation.
|
|
467 |
The effect of applying the resulting WindowingTransformation
|
|
468 |
to an object is the same as that of first applying
|
|
469 |
aTransformation to the object and then applying the
|
|
470 |
receiver to its result."
|
|
471 |
|
|
472 |
|aTransformationScale newScale newTranslation|
|
|
473 |
|
|
474 |
aTransformationScale := aTransformation scale.
|
78
|
475 |
scale isNil ifTrue:[
|
72
|
476 |
aTransformation noScale ifTrue:[
|
|
477 |
newScale := nil
|
|
478 |
] ifFalse:[
|
|
479 |
newScale := aTransformationScale
|
|
480 |
].
|
|
481 |
newTranslation := translation + aTransformation translation
|
0
|
482 |
] ifFalse:[
|
72
|
483 |
aTransformation noScale ifTrue:[
|
|
484 |
newScale := scale
|
|
485 |
] ifFalse:[
|
|
486 |
newScale := scale * aTransformationScale
|
|
487 |
].
|
|
488 |
newTranslation := translation
|
|
489 |
+ (scale * aTransformation translation)
|
0
|
490 |
].
|
72
|
491 |
^ (self class)
|
|
492 |
scale:newScale
|
|
493 |
translation:newTranslation
|
|
494 |
!
|
|
495 |
|
601
|
496 |
transformPoint:p
|
|
497 |
"Apply the receiver to a point.
|
|
498 |
This is destructive in that the point is being modified,
|
|
499 |
not a copy."
|
0
|
500 |
|
601
|
501 |
scale isNil ifTrue:[
|
|
502 |
translation isNil ifTrue:[
|
|
503 |
^ p
|
72
|
504 |
].
|
601
|
505 |
^ p + translation
|
|
506 |
].
|
|
507 |
translation isNil ifTrue:[
|
|
508 |
^ p * scale
|
0
|
509 |
].
|
601
|
510 |
^ (p * scale + translation)
|
|
511 |
! !
|
|
512 |
|
|
513 |
!WindowingTransformation methodsFor:'printing'!
|
0
|
514 |
|
601
|
515 |
printOn:aStream
|
|
516 |
aStream nextPutAll:self class name.
|
|
517 |
aStream nextPutAll:' scale: '.
|
|
518 |
scale printOn:aStream.
|
|
519 |
aStream nextPutAll:' translation: '.
|
|
520 |
translation printOn:aStream
|
0
|
521 |
! !
|
|
522 |
|
72
|
523 |
!WindowingTransformation methodsFor:'private'!
|
0
|
524 |
|
|
525 |
checkScale:aScale
|
|
526 |
"Converts aScale to the internal format of a floating-point Point."
|
|
527 |
|
|
528 |
|checkedScale|
|
|
529 |
|
|
530 |
checkedScale := aScale asPoint.
|
|
531 |
^ Point x:checkedScale x asFloat
|
72
|
532 |
y:checkedScale y asFloat
|
0
|
533 |
!
|
|
534 |
|
|
535 |
inverseScale
|
|
536 |
"return with a Point representing the inverse of my
|
|
537 |
scale."
|
|
538 |
|
|
539 |
|newScale|
|
|
540 |
|
|
541 |
newScale := self checkScale:scale.
|
|
542 |
^ Point x:(1.0 / newScale x)
|
72
|
543 |
y:(1.0 / newScale y)
|
0
|
544 |
!
|
|
545 |
|
|
546 |
inverseTranslation
|
|
547 |
"return with a Point representing the inverse of my
|
|
548 |
translation."
|
|
549 |
|
|
550 |
|trans|
|
|
551 |
|
|
552 |
trans := translation asPoint.
|
|
553 |
^ Point x:trans x negated
|
72
|
554 |
y:trans y negated
|
|
555 |
! !
|
|
556 |
|
|
557 |
!WindowingTransformation methodsFor:'testing'!
|
|
558 |
|
|
559 |
noScale
|
|
560 |
"return true if the identity scale is in effect;
|
|
561 |
return false, otherwise."
|
0
|
562 |
|
705
|
563 |
scale isNil ifTrue:[^ true].
|
|
564 |
^ scale x = 1 and:[scale y = 1]
|
|
565 |
|
|
566 |
"Modified: 21.5.1996 / 21:15:21 / cg"
|
0
|
567 |
! !
|
72
|
568 |
|
601
|
569 |
!WindowingTransformation methodsFor:'transforming'!
|
|
570 |
|
|
571 |
scaleBy:aScale
|
|
572 |
"scale the receiver.
|
|
573 |
This is a destructive operation, modifying the transformation
|
|
574 |
represented by the receiver"
|
|
575 |
|
|
576 |
|newScale|
|
|
577 |
|
|
578 |
aScale isNil ifTrue:[^ self].
|
|
579 |
|
|
580 |
scale isNil ifTrue:[
|
|
581 |
newScale := aScale asPoint
|
|
582 |
] ifFalse:[
|
|
583 |
newScale := scale * aScale
|
|
584 |
].
|
|
585 |
translation notNil ifTrue:[
|
|
586 |
translation := translation * aScale.
|
|
587 |
].
|
|
588 |
scale := newScale.
|
|
589 |
!
|
|
590 |
|
|
591 |
scaledBy:aScale
|
|
592 |
"return a new WindowingTransformation with the scale and translation of
|
|
593 |
the receiver both scaled by aScale."
|
|
594 |
|
|
595 |
|checkedScale newScale newTranslation|
|
72
|
596 |
|
601
|
597 |
aScale isNil ifTrue:[
|
|
598 |
newScale := scale.
|
|
599 |
newTranslation := translation
|
|
600 |
] ifFalse:[
|
|
601 |
checkedScale := self checkScale:aScale.
|
|
602 |
scale isNil ifTrue:[
|
|
603 |
newScale := checkedScale
|
|
604 |
] ifFalse:[
|
|
605 |
newScale := scale * checkedScale
|
|
606 |
].
|
|
607 |
translation notNil ifTrue:[
|
|
608 |
newTranslation := checkedScale * translation
|
|
609 |
]
|
|
610 |
].
|
|
611 |
^ (self class)
|
|
612 |
scale:newScale
|
|
613 |
translation:newTranslation
|
|
614 |
!
|
|
615 |
|
|
616 |
translateBy:aTranslation
|
|
617 |
"translate the receiver.
|
|
618 |
This is a destructive operation, modifying the transformation
|
|
619 |
represented by the receiver"
|
|
620 |
|
|
621 |
aTranslation isNil ifTrue:[^ self].
|
|
622 |
|
|
623 |
translation isNil ifTrue:[
|
|
624 |
translation := 0@0
|
|
625 |
].
|
|
626 |
scale isNil ifTrue:[
|
|
627 |
translation := translation + aTranslation asPoint
|
|
628 |
] ifFalse:[
|
|
629 |
translation := translation + (scale * aTranslation)
|
|
630 |
].
|
|
631 |
!
|
|
632 |
|
|
633 |
translatedBy:aPoint
|
|
634 |
"return a new WindowingTransformation with the same scale and
|
|
635 |
rotations as the receiver and with a translation of the current
|
|
636 |
translation plus aPoint."
|
|
637 |
|
|
638 |
^ (self class)
|
|
639 |
scale:scale
|
|
640 |
translation:(translation + aPoint)
|
72
|
641 |
! !
|
|
642 |
|