'From Pharo3.0 of 18 March 2013 [Latest update: #30852] on 31 July 2014 at 10:35:55.868824 pm'! TRObject subclass: #TRCanvas instanceVariableNames: 'canvas shapes fixedShapes extent animations morph camera announcer color session ' classVariableNames: '' poolDictionaries: '' category: 'Trachel-Core'! !TRShape methodsFor: 'accessing' stamp: 'NicolaiHess 7/31/2014 22:28'! canvas: aSurface "aCanvas is a AthensCairoSurface" canvas := aSurface. self resetPath.! ! !TRCanvas methodsFor: 'initialization' stamp: 'NicolaiHess 7/31/2014 22:29'! initialize super initialize. extent := 500 @ 500. canvas := AthensCairoSurface extent: extent. session := Smalltalk session. shapes := OrderedCollection new. fixedShapes := OrderedCollection new. animations := OrderedCollection new. camera := TRCamera forCanvas: self. color := Color white.! ! !TRCanvas methodsFor: 'session management' stamp: 'NicolaiHess 7/31/2014 22:30'! initializeForNewSession self createSurface. session := Smalltalk session. ! ! !TRCanvas methodsFor: 'session management' stamp: 'NicolaiHess 7/31/2014 22:30'! checkSession session == Smalltalk session ifFalse: [ self initializeForNewSession ]! ! !TRCanvas methodsFor: 'session management' stamp: 'NicolaiHess 7/31/2014 22:31'! createSurface canvas := AthensCairoSurface extent: self extent asIntegerPoint. self shapes do:[:s | s canvas: self]. self fixedShapes do:[:s | s canvas: self]. ! ! !TRMorph methodsFor: 'drawing' stamp: 'NicolaiHess 7/31/2014 22:32'! "protocol: drawing" drawOn: aCanvas "aCanvas is a FormCanvas" self checkSession. trachelCanvas checkSession. aCanvas fillRectangle: bounds color: trachelCanvas color. trachelCanvas playAnimations. "The drawing has to be done when a change in the shapes occured or when there is an animation." surface drawDuring: [:cs | surface clear. "We display the elements that are subject to the camera" cs pathTransform translateBy: self extent / 2; scaleBy: trachelCanvas camera scale asFloat; translateBy: trachelCanvas camera position negated. trachelCanvas shapes do: [ :trachelShape | trachelShape drawOn: cs. ]. "We display the elements that are _NOT_ subject to the camera" cs pathTransform loadIdentity. trachelCanvas fixedShapes do: [ :trachelShape | trachelShape drawOn: cs. ]. ]. "aCanvas translucentImage: surface asForm at: self bounds origin." "asForm creates a new Form, which is likely to be expensive. This can be cached" aCanvas image: surface asForm at: self bounds origin sourceRect: (0 @ 0 extent: surface extent) rule: 34! ! TRObject subclass: #TRCanvas instanceVariableNames: 'canvas shapes fixedShapes extent animations morph camera announcer color session' classVariableNames: '' poolDictionaries: '' category: 'Trachel-Core'! !TRCanvas reorganize! (#testing isFixedShape: isMovableShape:) (#animations numberOfAnimations animations hasAnimation animationsRemoveAll: playAnimations addAnimation:) (#visitor accept:) (#menu addMenu:callback: addMenuAsSVG:callback: addMenuAsSVG:scale:callback:) (#accessing numberOfShapes athensCanvas numberOfFixedShapes extent shapeWithActionForPosition: shapeForPositionInPixels: shapes topLeft camera shapeForPosition: fixedShapes extent: color: shapeWithActionForPositionInPixels: morph color) (#action pushAll:behindAll: clean firstElementOf: push:behindAll:) (#events announcer: announcer when:do: announce:) (#initialization initialize) (#'instance creation' buildMorph morphClass openInWindowSized: open openInWindowSized:titled: openTitled:) (#updating signalUpdate) (#building buildCircleFrom:to:color: addFixedShape: buildRectangle:color: buildLineFrom:to:color: privateAdd: buildArcAlphaAngle:betaAngle:innerRadius:externalRadius: removeShape: addShape:) (#'session management' initializeForNewSession checkSession createSurface) (#actions focusOnCenterScaled push:behind: setAsFixed: pushBack: pushFront: removeFixedShape:) !