CompositeTransform.st
author Claus Gittinger <cg@exept.de>
Sat, 12 May 2018 14:23:45 +0200
changeset 4088 bbf9b58f99c8
parent 3930 1d08dbcfcbf1
permissions -rw-r--r--
#FEATURE by cg class: MIMETypes class changed: #initializeFileInfoMappings class: MIMETypes::MIMEType added: #asMimeType #isCHeaderType #isCPPSourceType #isCSourceType
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3930
1d08dbcfcbf1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
     1
"
1d08dbcfcbf1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
     2
 COPYRIGHT (c) 1999 by Claus Gittinger
1d08dbcfcbf1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
     3
              All Rights Reserved
1d08dbcfcbf1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
     4
1d08dbcfcbf1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
     5
 This software is furnished under a license and may be used
1d08dbcfcbf1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
     6
 only in accordance with the terms of that license and with the
1d08dbcfcbf1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
1d08dbcfcbf1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
     8
 be provided or otherwise made available to, or used by, any
1d08dbcfcbf1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
     9
 other person.  No title to or ownership of the software is
1d08dbcfcbf1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
    10
 hereby transferred.
1d08dbcfcbf1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
    11
"
1d08dbcfcbf1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
    12
"{ Package: 'stx:libview2' }"
1d08dbcfcbf1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
    13
1d08dbcfcbf1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
    14
"{ NameSpace: Smalltalk }"
1d08dbcfcbf1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
    15
1250
76824ea90b46 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
DisplayTransform subclass:#CompositeTransform
76824ea90b46 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
	instanceVariableNames:'globalTransform localTransform'
76824ea90b46 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
	classVariableNames:''
76824ea90b46 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
	poolDictionaries:''
76824ea90b46 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
	category:'Graphics-Transformations'
76824ea90b46 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
!
76824ea90b46 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
3930
1d08dbcfcbf1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
    23
CompositeTransform comment:'A composite transform provides the effect of several levels of coordinate transformations.'
1d08dbcfcbf1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
    24
!
1d08dbcfcbf1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
    25
1d08dbcfcbf1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
    26
!CompositeTransform class methodsFor:'documentation'!
1250
76824ea90b46 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
3930
1d08dbcfcbf1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
    28
copyright
1d08dbcfcbf1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
    29
"
1d08dbcfcbf1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
    30
 COPYRIGHT (c) 1999 by Claus Gittinger
1d08dbcfcbf1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
    31
              All Rights Reserved
1d08dbcfcbf1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
    32
1d08dbcfcbf1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
    33
 This software is furnished under a license and may be used
1d08dbcfcbf1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
    34
 only in accordance with the terms of that license and with the
1d08dbcfcbf1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
    35
 inclusion of the above copyright notice.   This software may not
1d08dbcfcbf1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
    36
 be provided or otherwise made available to, or used by, any
1d08dbcfcbf1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
    37
 other person.  No title to or ownership of the software is
1d08dbcfcbf1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
    38
 hereby transferred.
1d08dbcfcbf1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
    39
"
1d08dbcfcbf1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
    40
! !
1250
76824ea90b46 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
76824ea90b46 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
!CompositeTransform methodsFor:'accessing'!
76824ea90b46 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
76824ea90b46 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
inverseTransformation
76824ea90b46 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
	"Return the inverse transformation of the receiver"
76824ea90b46 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    46
	^self species new
76824ea90b46 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    47
		globalTransform: localTransform inverseTransformation
3930
1d08dbcfcbf1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
    48
		localTransform: globalTransform inverseTransformation
1d08dbcfcbf1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
    49
! !
1250
76824ea90b46 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
76824ea90b46 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
!CompositeTransform methodsFor:'converting'!
76824ea90b46 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
76824ea90b46 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
asCompositeTransform
3930
1d08dbcfcbf1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
    54
	^self
1d08dbcfcbf1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
    55
!
1250
76824ea90b46 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
76824ea90b46 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
asMatrixTransform2x3
76824ea90b46 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
	^globalTransform asMatrixTransform2x3
3930
1d08dbcfcbf1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
    59
		composedWithLocal: localTransform asMatrixTransform2x3
1d08dbcfcbf1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
    60
! !
1250
76824ea90b46 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
76824ea90b46 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
!CompositeTransform methodsFor:'initialization'!
76824ea90b46 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
76824ea90b46 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
globalTransform: gt localTransform: lt
76824ea90b46 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
	globalTransform _ gt.
3930
1d08dbcfcbf1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
    66
	localTransform _ lt
1d08dbcfcbf1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
    67
! !
1250
76824ea90b46 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
76824ea90b46 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
!CompositeTransform methodsFor:'testing'!
76824ea90b46 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
76824ea90b46 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
isCompositeTransform
3930
1d08dbcfcbf1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
    72
	^true
1d08dbcfcbf1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
    73
!
1250
76824ea90b46 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    74
76824ea90b46 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
isIdentity
3930
1d08dbcfcbf1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
    76
	^ globalTransform isIdentity and: [localTransform isIdentity]
1d08dbcfcbf1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
    77
!
1250
76824ea90b46 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    78
76824ea90b46 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    79
isPureTranslation
3930
1d08dbcfcbf1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
    80
	^ globalTransform isPureTranslation and: [localTransform isPureTranslation]
1d08dbcfcbf1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
    81
! !
1250
76824ea90b46 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    82
76824ea90b46 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    83
!CompositeTransform methodsFor:'transformations'!
76824ea90b46 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    84
76824ea90b46 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    85
invert: aPoint
3930
1d08dbcfcbf1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
    86
	^ globalTransform invert: (localTransform invert: aPoint)
1d08dbcfcbf1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
    87
!
1250
76824ea90b46 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    88
76824ea90b46 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    89
scale
3930
1d08dbcfcbf1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
    90
	^ localTransform scale * globalTransform scale
1d08dbcfcbf1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
    91
!
1250
76824ea90b46 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
76824ea90b46 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    93
transform: aPoint
3930
1d08dbcfcbf1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
    94
	^ localTransform transform: (globalTransform transform: aPoint)
1d08dbcfcbf1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
    95
! !
1250
76824ea90b46 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
76824ea90b46 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
!CompositeTransform methodsFor:'transforming points'!
76824ea90b46 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
76824ea90b46 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    99
globalPointToLocal: aPoint
76824ea90b46 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   100
	"Transform aPoint from global coordinates into local coordinates"
76824ea90b46 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
	^localTransform globalPointToLocal:
3930
1d08dbcfcbf1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
   102
		(globalTransform globalPointToLocal: aPoint)
1d08dbcfcbf1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
   103
!
1250
76824ea90b46 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   104
76824ea90b46 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   105
localPointToGlobal: aPoint
76824ea90b46 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   106
	"Transform aPoint from global coordinates into local coordinates"
76824ea90b46 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   107
	^globalTransform localPointToGlobal:
3930
1d08dbcfcbf1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
   108
		(localTransform localPointToGlobal: aPoint)
1d08dbcfcbf1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
   109
! !
1250
76824ea90b46 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   110
76824ea90b46 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   111
!CompositeTransform class methodsFor:'documentation'!
76824ea90b46 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   112
76824ea90b46 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   113
version
3930
1d08dbcfcbf1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
   114
    ^ '$Header$'
1250
76824ea90b46 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   115
! !
3930
1d08dbcfcbf1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 1250
diff changeset
   116