WindowingTransformation.st
changeset 1148 d53113a7cd47
parent 705 e8acdd90a071
child 2147 c25e441abbcd
--- a/WindowingTransformation.st	Mon Dec 23 13:59:08 1996 +0100
+++ b/WindowingTransformation.st	Mon Dec 30 16:59:34 1996 +0100
@@ -23,7 +23,13 @@
     "returns a windowing transformation with no scaling (1@1) 
      and no translation (0@0)."
 
-    ^ self basicNew scale:nil translation:nil 
+    ^ self basicNew "/ scale:nil translation:nil 
+
+    "
+     WindowingTransformation identity
+    "
+
+    "Modified: 30.12.1996 / 16:59:27 / cg"
 !
 
 scale:aScale translation:aTranslation 
@@ -62,46 +68,55 @@
      (i.e. the print-unit which is also used for font sizes etc.) 
      - not to confuse with device pixels."
 
-    |pixelPerUnitV pixelPerUnitH|
+    |ppmm ppi scale|
+
+    ppmm := device pixelPerMillimeter.
+    ppi := device pixelPerInch.
 
     unitSymbol == #mm ifTrue:[
-	pixelPerUnitV := device verticalPixelPerMillimeter.
-	pixelPerUnitH := device horizontalPixelPerMillimeter 
+        scale := ppmm.
     ] ifFalse:[
-	unitSymbol == #cm ifTrue:[
-	    pixelPerUnitV := device verticalPixelPerMillimeter * 10.
-	    pixelPerUnitH := device horizontalPixelPerMillimeter * 10 
-	] ifFalse:[
-	    unitSymbol == #twip ifTrue:[
-		pixelPerUnitV := device verticalPixelPerInch / 1440.
-		pixelPerUnitH := device horizontalPixelPerInch / 1440 
-	    ] ifFalse:[
-		unitSymbol == #point ifTrue:[
-		    pixelPerUnitV := device verticalPixelPerInch / 72.
-		    pixelPerUnitH := device horizontalPixelPerInch / 72 
-		] ifFalse:[
-		    unitSymbol == #inch ifTrue:[
-			pixelPerUnitV := device verticalPixelPerInch.
-			pixelPerUnitH := device horizontalPixelPerInch 
-		    ] ifFalse:[
-			"sorry: unknown unit is taken as pixel"
-			^ self new scale:nil translation:nil
-		    ]
-		]
-	    ]
-	]
+        unitSymbol == #cm ifTrue:[
+            scale := ppmm * 10.
+        ] ifFalse:[
+            unitSymbol == #twip ifTrue:[
+                scale := ppi / 1440.
+            ] ifFalse:[
+                unitSymbol == #point ifTrue:[
+                    scale := ppi / 72.
+                ] ifFalse:[
+                    unitSymbol == #inch ifTrue:[
+                        scale := ppi.
+                    ] ifFalse:[
+                        "sorry: unknown unit is taken as pixel"
+                        ^ self new scale:nil translation:nil
+                    ]
+                ]
+            ]
+        ]
     ].
-    ^ self basicNew scale:(pixelPerUnitH @ pixelPerUnitV) translation:nil
+    ^ self basicNew scale:scale translation:nil
 
     "
      |v|
 
-     v := View new realize.
+     v := View new openAndWait.
      (Delay forSeconds:3) wait.
      v transformation:(WindowingTransformation unit:#inch on:Display).
      'now, we can think of drawing in inches ...'.
      v displayLineFrom:0.5@0.5 to:1@1 
     "
+    "
+     |v|
+
+     v := View new openAndWait.
+     (Delay forSeconds:3) wait.
+     v transformation:(WindowingTransformation unit:#mm on:Display).
+     'now, we can think of drawing in millimeters ...'.
+     v displayLineFrom:2@2 to:10@10 
+    "
+
+    "Modified: 30.12.1996 / 16:57:59 / cg"
 !
 
 window:sourceRectangle viewport:destinationRectangle 
@@ -239,7 +254,7 @@
 !
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/WindowingTransformation.st,v 1.14 1996-05-21 19:20:36 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/WindowingTransformation.st,v 1.15 1996-12-30 15:59:34 cg Exp $'
 ! !
 
 !WindowingTransformation methodsFor:'accessing'!