diff --git a/BaselineOfGeoView/BaselineOfGeoView.class.st b/BaselineOfGeoView/BaselineOfGeoView.class.st index 4a26628..5a8f7da 100644 --- a/BaselineOfGeoView/BaselineOfGeoView.class.st +++ b/BaselineOfGeoView/BaselineOfGeoView.class.st @@ -44,20 +44,35 @@ BaselineOfGeoView >> coreDependencies: spec [ { #category : #packages } BaselineOfGeoView >> corePackages: spec [ + "Core and graphical backend packages" spec package: 'GeoView' with:[ spec requires: #('OpenSmock' 'GeoTools') ]; package: 'GeoView-GeoObjects' with:[ spec requires: #('GeoView') ]; package: 'GeoView-Bloc' with:[ spec requires: #('GeoView') ]; package: 'GeoView-Bloc-Alexandrie' with:[ spec requires: #('GeoView-Bloc') ]. + "Molecule integration packages" + spec + package: 'GeoView-Molecule' with:[ spec requires: #('GeoView' 'GeoView-GeoObjects') ]; + package: 'GeoView-Bloc-Alexandrie-Molecule' with:[ spec requires: #('GeoView-Bloc-Alexandrie') ]. + "examples packages" spec - package: 'GeoView-Examples' with:[ spec requires: #('GeoView' 'GeoView-GeoObjects') ]; - package: 'GeoView-Examples-Bloc' with:[ spec requires: #('GeoView-Examples') ]. + package: 'GeoView-Examples-Bloc' with:[ spec requires: #('GeoView-Bloc' 'GeoView-GeoObjects') ]. + + "examples with Molecule packages" + spec + package: 'GeoView-Examples-Bloc-Molecule' with:[ spec requires: #('GeoView-Molecule' 'GeoView-Bloc-Alexandrie-Molecule') ]. "Tests packages" spec - package: 'GeoView-Tests' with: [ spec requires: #('GeoView' 'GeoView-GeoObjects') ]. + package: 'GeoView-Tests' with: [ spec requires: #('GeoView' 'GeoView-GeoObjects') ]; + package: 'GeoView-Bloc-Tests' with: [ spec requires: #('GeoView-Bloc') ]. + + "Tests with Molecule packages" + spec + package: 'GeoView-Molecule-Tests' with: [ spec requires: #('GeoView-Molecule') ]. + ] { #category : #baselines } diff --git a/GeoView-Bloc-Alexandrie-Molecule/GeoViewManagerBlocAeImpl.class.st b/GeoView-Bloc-Alexandrie-Molecule/GeoViewManagerBlocAeImpl.class.st new file mode 100644 index 0000000..c5dcd80 --- /dev/null +++ b/GeoView-Bloc-Alexandrie-Molecule/GeoViewManagerBlocAeImpl.class.st @@ -0,0 +1,38 @@ +Class { + #name : #GeoViewManagerBlocAeImpl, + #superclass : #GeoViewManagerImpl, + #category : #'GeoView-Bloc-Alexandrie-Molecule' +} + +{ #category : #'layer creation' } +GeoViewManagerBlocAeImpl >> createGeoObjectsLayer: aName [ + + | layer | + layer := GeoViewGeoObjectsLayer new. + layer name: aName. + layer displayModel indexAccessor: self getObjectIndexAccessor. + + ^ layer +] + +{ #category : #initialization } +GeoViewManagerBlocAeImpl >> createView [ + + | element | + element := BlGeoViewAeElement new. + self installEventHandlers: element. + + self view: element. +] + +{ #category : #initialization } +GeoViewManagerBlocAeImpl >> installEventHandlers: aBlElement [ + + aBlElement addEventHandlerOn: GeoViewLayerProcessDataChanged do: [ :e | self layerHasBeenUpdated: e layerName ] +] + +{ #category : #'services - drawing' } +GeoViewManagerBlocAeImpl >> requestViewUpdate [ + + self view requestRepaint +] diff --git a/GeoView-Bloc-Alexandrie-Molecule/package.st b/GeoView-Bloc-Alexandrie-Molecule/package.st new file mode 100644 index 0000000..e11351b --- /dev/null +++ b/GeoView-Bloc-Alexandrie-Molecule/package.st @@ -0,0 +1 @@ +Package { #name : #'GeoView-Bloc-Alexandrie-Molecule' } diff --git a/GeoView-Bloc-Alexandrie/BlElementAeGeoView.class.st b/GeoView-Bloc-Alexandrie/BlElementAeGeoView.class.st deleted file mode 100644 index 6990195..0000000 --- a/GeoView-Bloc-Alexandrie/BlElementAeGeoView.class.st +++ /dev/null @@ -1,202 +0,0 @@ -Class { - #name : #BlElementAeGeoView, - #superclass : #BlElement, - #traits : 'TGeoView', - #classTraits : 'TGeoView classTrait', - #instVars : [ - 'layers', - 'displayToGraphicProjection', - 'isMarkedForSortDatas' - ], - #category : #'GeoView-Bloc-Alexandrie-Core' -} - -{ #category : #'API -- layers management' } -BlElementAeGeoView >> addLayer: aLayer [ - - (self layers includes: aLayer) ifTrue: [ ^ self ]. - self configureLayer: aLayer. - self layers add: aLayer -] - -{ #category : #'API -- objects management' } -BlElementAeGeoView >> addObject: anUserObject [ - - self enqueueBlockAsTask: [ - self layers do: [ :e | e addObject: anUserObject ]. - self requestSortDatas. - self requestRepaint ] -] - -{ #category : #'API -- objects management' } -BlElementAeGeoView >> addObjects: anUserObjectList [ - - self enqueueBlockAsTask: [ - self layers do: [ :e | e addObjects: anUserObjectList ]. - self requestSortDatas. - self requestRepaint ] -] - -{ #category : #drawing } -BlElementAeGeoView >> aeDrawOn: aeCanvas [ - "drawing native bloc elements" - - | sort | - super aeDrawOn: aeCanvas. - - sort := self isMarkedForSortDatas. - self layers do: [ :l | - sort ifTrue: [ l sortDatas ]. - l aeDrawOn: aeCanvas ]. - - isMarkedForSortDatas := false -] - -{ #category : #private } -BlElementAeGeoView >> configureLayer: aLayer [ - - "Setup the 2D projection of the layer" - aLayer graphicModel projection: self displayToGraphicProjection. - - "add alexandrie process datas" - aLayer graphicModel setProcessData: DCompositeShapeGeoViewProcessData new for: SmockDCompositeShape. - aLayer graphicModel setProcessData: DSymbolGeoViewProcessData new for: SmockDSymbol. - aLayer graphicModel setProcessData: DCircleGeoViewProcessData new for: SmockDCircle. - aLayer graphicModel setProcessData: DTextGeoViewProcessData new for: SmockDText. - aLayer graphicModel setProcessData: DPolygonGeoViewProcessData new for: SmockDPolygon. - aLayer graphicModel setProcessData: DPolylineGeoViewProcessData new for: SmockDPolyline. - - "aLayer displayToGraphicModel defaultProcessData: DShapeAeProcessData new." -] - -{ #category : #accessing } -BlElementAeGeoView >> displayToGraphicProjection [ - - ^ displayToGraphicProjection -] - -{ #category : #accessing } -BlElementAeGeoView >> displayToGraphicProjection: anObject [ - - displayToGraphicProjection := anObject -] - -{ #category : #private } -BlElementAeGeoView >> enqueueBlockAsTask: aBlockClosure [ - - | task | - task := BlTaskAction new. - task action: aBlockClosure. - self enqueueTask: task -] - -{ #category : #'API -- size' } -BlElementAeGeoView >> getBounds [ - - ^ self bounds -] - -{ #category : #'API -- size' } -BlElementAeGeoView >> getExtent [ - - ^ self extent -] - -{ #category : #'API -- layers management' } -BlElementAeGeoView >> getLayers [ - - ^ self layers -] - -{ #category : #'API -- objects management' } -BlElementAeGeoView >> haveObjectIndex: anIndex [ - "Pay attention before using it because graphical model is out of sync real user model due to usage of BlTask (asynchronous)" - - ^ self layers anySatisfy: [ :l | l haveObjectIndex: anIndex ] -] - -{ #category : #accessing } -BlElementAeGeoView >> isMarkedForSortDatas [ - - ^ isMarkedForSortDatas ifNil: [ isMarkedForSortDatas := false ] -] - -{ #category : #accessing } -BlElementAeGeoView >> layers [ - - ^ layers ifNil: [ layers := OrderedCollection new ] -] - -{ #category : #'API -- objects management' } -BlElementAeGeoView >> removeObject: anUserObject [ - - self enqueueBlockAsTask: [ - self layers do: [ :e | e removeObject: anUserObject ]. - self requestRepaint ] -] - -{ #category : #'API -- objects management' } -BlElementAeGeoView >> removeObjects: anUserObjectList [ - - self enqueueBlockAsTask: [ - self layers do: [ :e | e removeObjects: anUserObjectList ]. - self requestRepaint ] -] - -{ #category : #private } -BlElementAeGeoView >> requestRepaint [ - - self invalidate. -] - -{ #category : #private } -BlElementAeGeoView >> requestSortDatas [ - - isMarkedForSortDatas := true. -] - -{ #category : #'API -- selection' } -BlElementAeGeoView >> selectedObjectIndexes: anIndexList [ - - self enqueueBlockAsTask: [ - self layers do: [ :l | l updateState: #selected withIndexes: anIndexList ]. - self requestSortDatas. - self requestRepaint ] -] - -{ #category : #'API -- drawing' } -BlElementAeGeoView >> updateGraphicModel [ - "Update the graphic model with the Display model" - - self enqueueBlockAsTask: [ - self layers do: [ :e | e updateGraphicModel ]. - self requestRepaint ] -] - -{ #category : #'API -- objects management' } -BlElementAeGeoView >> updateObject: anUserObject [ - - self enqueueBlockAsTask: [ - self layers do: [ :e | e updateObject: anUserObject ]. - self requestSortDatas. - self requestRepaint ] -] - -{ #category : #'API -- objects management' } -BlElementAeGeoView >> updateObjects: anUserObjectList [ - - self enqueueBlockAsTask: [ - self layers do: [ :e | e updateObjects: anUserObjectList ]. - self requestSortDatas. - self requestRepaint ] -] - -{ #category : #private } -BlElementAeGeoView >> updateState: aStateSymbol withIndexes: aKeyList [ - - self enqueueBlockAsTask: [ - self layers do: [ :l | l updateState: aStateSymbol withIndexes: aKeyList ]. - self requestSortDatas. - self requestRepaint - ] -] diff --git a/GeoView-Bloc-Alexandrie/BlGeoViewAeElement.class.st b/GeoView-Bloc-Alexandrie/BlGeoViewAeElement.class.st new file mode 100644 index 0000000..04ede9f --- /dev/null +++ b/GeoView-Bloc-Alexandrie/BlGeoViewAeElement.class.st @@ -0,0 +1,64 @@ +" +I am a BlElement which display a GeoViewWidget using Alexandrie backend drawing. +" +Class { + #name : #BlGeoViewAeElement, + #superclass : #BlAbstractGeoViewElement, + #instVars : [ + 'inputContext' + ], + #category : #'GeoView-Bloc-Alexandrie-Core' +} + +{ #category : #drawing } +BlGeoViewAeElement >> aeDrawOn: aeCanvas [ + "drawing native bloc elements" + + | sort | + super aeDrawOn: aeCanvas. + + sort := self isMarkedForSortDatas. + self layers do: [ :l | + sort ifTrue: [ l sortDatas ]. + l aeDrawOn: aeCanvas ]. + + isMarkedForSortDatas := false +] + +{ #category : #'API -- picking' } +BlGeoViewAeElement >> pickAt: aGlobalPoint radius: aRadiusInPixels [ + "prepare the picking result" + + | pickingResult distanceBlock radius | + pickingResult := (super pickAt: aGlobalPoint radius: aRadiusInPixels) ifNil:[ ^ nil ]. + + "labordep: prepare to be setup with others blocks" + distanceBlock := [ :gShape :point | gShape distanceTo: point ]. + radius := aRadiusInPixels ifNil:[ 0 ]. + + "Collect all picked elements" + self getLayers do:[ :l | + l graphicModel datas keysAndValuesDo:[ :key :gShape | | distanceInPixels pickingElement | + + "Way to detect if the gShape is picked" + distanceInPixels := distanceBlock value: gShape value: pickingResult localPoint. + distanceInPixels <= radius ifTrue:[ + + "Store the element into the result" + pickingElement := GeoViewPickingElement new. + pickingElement layerName: l name. + pickingElement layerLevel: nil. self flag:'labordep: put the level of the layer'. + pickingElement distanceInPixels: distanceInPixels. + pickingElement objectKey: key. + pickingElement dShape: (l displayModel getData: key). + pickingElement gShape: gShape. + + pickingResult addPickingElement: pickingElement. + + ]. + ]. + ]. + + pickingResult applyOrder: [ :a :b | a distanceInPixels < b distanceInPixels ]. + ^ pickingResult +] diff --git a/GeoView-Bloc-Alexandrie/GeoViewUserToDisplayToGraphicLayer.extension.st b/GeoView-Bloc-Alexandrie/GeoViewGeoObjectsLayer.extension.st similarity index 58% rename from GeoView-Bloc-Alexandrie/GeoViewUserToDisplayToGraphicLayer.extension.st rename to GeoView-Bloc-Alexandrie/GeoViewGeoObjectsLayer.extension.st index 3de9c3e..66cd835 100644 --- a/GeoView-Bloc-Alexandrie/GeoViewUserToDisplayToGraphicLayer.extension.st +++ b/GeoView-Bloc-Alexandrie/GeoViewGeoObjectsLayer.extension.st @@ -1,7 +1,7 @@ -Extension { #name : #GeoViewUserToDisplayToGraphicLayer } +Extension { #name : #GeoViewGeoObjectsLayer } { #category : #'*GeoView-Bloc-Alexandrie' } -GeoViewUserToDisplayToGraphicLayer >> aeDrawOn: aeCanvas [ +GeoViewGeoObjectsLayer >> aeDrawOn: aeCanvas [ self isVisible ifFalse: [ ^ self ]. sortedDatas ifNil: [ ^ self ]. diff --git a/GeoView-Bloc-Alexandrie/GeoViewManagerBlocAeImpl.class.st b/GeoView-Bloc-Alexandrie/GeoViewManagerBlocAeImpl.class.st deleted file mode 100644 index 20f7346..0000000 --- a/GeoView-Bloc-Alexandrie/GeoViewManagerBlocAeImpl.class.st +++ /dev/null @@ -1,184 +0,0 @@ -Class { - #name : #GeoViewManagerBlocAeImpl, - #superclass : #GeoViewManagerImpl, - #category : #'GeoView-Bloc-Alexandrie-Core' -} - -{ #category : #'layer creation' } -GeoViewManagerBlocAeImpl >> createLayer: aKey [ - - | layer | - layer := GeoViewUserToDisplayToGraphicLayer new. - layer layerName: aKey. - layer displayModel indexAccessor: self getObjectIndexAccessor. - - ^ layer -] - -{ #category : #initialization } -GeoViewManagerBlocAeImpl >> createView [ - - | aeView | - aeView := BlElementAeGeoView new. - aeView background: Color black. - aeView displayToGraphicProjection: GeoView2DProjection new. - self installEventHandlers: aeView. - - self view: aeView. -] - -{ #category : #'projection center' } -GeoViewManagerBlocAeImpl >> getAbsoluteCoordinatesFromGlobalPoint: aGlobalPoint [ - - | localPoint | - localPoint := self getLocalPointFromGlobalPoint: aGlobalPoint. - ^ self getAbsoluteCoordinatesFromLocalPoint: localPoint -] - -{ #category : #'projection center' } -GeoViewManagerBlocAeImpl >> getAbsoluteCoordinatesFromLocalPoint: aLocalPoint [ - - | cartesianCoordinates absoluteCoordinates projection | - projection := self getMapProjectionManagerServicesProvider getProjection. - projection ifNil:[ ^ nil ]. - - cartesianCoordinates := view displayToGraphicProjection projPixelToCart: aLocalPoint. - absoluteCoordinates := projection projCartToLatLon: cartesianCoordinates. - ^ absoluteCoordinates -] - -{ #category : #'projection center' } -GeoViewManagerBlocAeImpl >> getGlobalPointFromAbsoluteCoordinates: anAbsoluteCoordinates [ - - | localPoint | - localPoint := self getLocalPointFromAbsoluteCoordinates: - anAbsoluteCoordinates. - ^ self getGlobalPointFromLocalPoint: localPoint -] - -{ #category : #'projection center' } -GeoViewManagerBlocAeImpl >> getGlobalPointFromLocalPoint: aLocalPoint [ - - aLocalPoint ifNil:[ ^ nil ]. - ^ self view localPointToGlobal: aLocalPoint -] - -{ #category : #'projection center' } -GeoViewManagerBlocAeImpl >> getLocalPointFromAbsoluteCoordinates: anAbsoluteCoordinates [ - - | projection | - projection := self getMapProjectionManagerServicesProvider getProjection. - projection ifNil:[ ^ nil ]. - - ^ self view displayToGraphicProjection projCartToPixel: - (projection projLatLonToCart: anAbsoluteCoordinates) -] - -{ #category : #'projection center' } -GeoViewManagerBlocAeImpl >> getLocalPointFromGlobalPoint: aGlobalPoint [ - - ^ self view globalPointToLocal: aGlobalPoint -] - -{ #category : #initialization } -GeoViewManagerBlocAeImpl >> handleExtentChangedEvent: anEvent [ - - self viewExtentHasChanged: anEvent source extent -] - -{ #category : #initialization } -GeoViewManagerBlocAeImpl >> initializeInputContext [ - - super initializeInputContext. - inputContext addStrategy: GeoViewNavigationBlocStrategy new. - inputContext addStrategy: GeoViewCursorInformationBlocStrategy new. -] - -{ #category : #initialization } -GeoViewManagerBlocAeImpl >> installEventHandlers: aBlElement [ - "Properties events" - - aBlElement addEventHandler: (BlEventHandler - on: BlElementExtentChangedEvent - do: [ :e | self handleExtentChangedEvent: e ]). - - "Interaction events" - aBlElement addEventHandler: (BlEventHandler - on: BlUIEvent - do: [ :e | self handleUIEvent: e ]) -] - -{ #category : #initialization } -GeoViewManagerBlocAeImpl >> pickAt: aGlobalPoint radius: aRadiusInPixels [ - - "prepare the picking result" - | pickingResult distanceBlock radius | - pickingResult := (super pickAt: aGlobalPoint radius: aRadiusInPixels) ifNil:[ ^ nil ]. - - "labordep: prepare to be setup with others blocks" - distanceBlock := [ :gShape :point | gShape distanceTo: point ]. - radius := aRadiusInPixels ifNil:[ 0 ]. - - "Collect all picked elements" - self getLayers do:[ :l | - l graphicModel datas keysAndValuesDo:[ :key :gShape | | distanceInPixels pickingElement | - - "Way to detect if the gShape is picked" - distanceInPixels := distanceBlock value: gShape value: pickingResult localPoint. - distanceInPixels <= radius ifTrue:[ - - "Store the element into the result" - pickingElement := GeoViewPickingElement new. - pickingElement layerName: l layerName. - pickingElement layerLevel: nil. self flag:'labordep: mettre le level'. - pickingElement distanceInPixels: distanceInPixels. - pickingElement objectKey: key. - pickingElement dShape: (l displayModel getData: key). - pickingElement gShape: gShape. - - pickingResult addPickingElement: pickingElement. - - ]. - ]. - ]. - - pickingResult applyOrder: [ :a :b | a distanceInPixels < b distanceInPixels ]. - ^ pickingResult -] - -{ #category : #'services - drawing' } -GeoViewManagerBlocAeImpl >> requestViewUpdate [ - - self view requestRepaint -] - -{ #category : #'projection center' } -GeoViewManagerBlocAeImpl >> setGeoCenter: anAbsoluteCoordinates [ - | cartesianCoordinates | - super setGeoCenter: anAbsoluteCoordinates. - cartesianCoordinates := self getMapProjectionManagerServicesProvider getProjection projLatLonToCart: self geoCenter. - - self view displayToGraphicProjection cartesianCenter: cartesianCoordinates. - self view updateGraphicModel. -] - -{ #category : #scale } -GeoViewManagerBlocAeImpl >> setScaleInMeters: aNumber [ - - super setScaleInMeters: aNumber. - self view displayToGraphicProjection altitudeInMeters: self scaleInMeters. - self view displayToGraphicProjection updateResolution: self view getBounds extent. - self view updateGraphicModel -] - -{ #category : #'private - events' } -GeoViewManagerBlocAeImpl >> viewExtentHasChanged: anExtent [ - - anExtent ifNil:[ ^ self ]. - - "configure view projection" - self view displayToGraphicProjection offsetInPIxels: anExtent / 2. - self view displayToGraphicProjection updateResolution: anExtent. - - self view updateGraphicModel -] diff --git a/GeoView-Bloc-Tests/BlAbstractGeoViewElementTest.class.st b/GeoView-Bloc-Tests/BlAbstractGeoViewElementTest.class.st new file mode 100644 index 0000000..9fd3501 --- /dev/null +++ b/GeoView-Bloc-Tests/BlAbstractGeoViewElementTest.class.st @@ -0,0 +1,74 @@ +" +A BlAbstractGeoViewElementTest is a test class for testing the behavior of BlAbstractGeoViewElement +" +Class { + #name : #BlAbstractGeoViewElementTest, + #superclass : #TestCase, + #category : #'GeoView-Bloc-Tests-Core' +} + +{ #category : #tests } +BlAbstractGeoViewElementTest >> testGeoViewLayerProcessDataChanged [ + + | element tag layer | + "initialize geoview and event handler" + element := BlAbstractGeoViewElement new. + tag := false. + element addEventHandlerOn: GeoViewLayerProcessDataChanged do: [ :e | tag := true ]. + self deny: tag. + + "create and add the layer" + layer := GeoViewGeoObjectsLayer new name: #myLayer. + element addLayer: layer. + self deny: tag. + + "change layer process datas" + layer setProcessData: GeoCircleProcessData for: GeoCircle. + + self assert: tag. +] + +{ #category : #tests } +BlAbstractGeoViewElementTest >> testInteractionsStrategy [ + + | element | + element := BlAbstractGeoViewElement new. + self assert: element interactionsStrategy class equals: GeoViewDefaultInteractionsStrategy +] + +{ #category : #tests } +BlAbstractGeoViewElementTest >> testNewInteractionsStrategy [ + + | element | + element := BlAbstractGeoViewElement new. + self assert: element newInteractionsStrategy class equals: GeoViewDefaultInteractionsStrategy. +] + +{ #category : #tests } +BlAbstractGeoViewElementTest >> testObjectIndexAccessor [ + + | element | + element := BlAbstractGeoViewElement new. + self assert: element objectIndexAccessor equals: #key. + + element objectIndexAccessor: #id. + self assert: element objectIndexAccessor equals: #id. +] + +{ #category : #tests } +BlAbstractGeoViewElementTest >> testRemoveInteractionsStrategy [ + + | element | + element := BlAbstractGeoViewElement new. + element removeInteractionsStrategy. + self assert: element interactionsStrategy isNil +] + +{ #category : #tests } +BlAbstractGeoViewElementTest >> testSetInteractionsStrategy [ + + | element | + element := BlAbstractGeoViewElement new. + element setInteractionsStrategy: nil. + self assert: element interactionsStrategy isNil +] diff --git a/GeoView-Bloc-Tests/package.st b/GeoView-Bloc-Tests/package.st new file mode 100644 index 0000000..048647b --- /dev/null +++ b/GeoView-Bloc-Tests/package.st @@ -0,0 +1 @@ +Package { #name : #'GeoView-Bloc-Tests' } diff --git a/GeoView-Bloc/BlAbstractGeoViewElement.class.st b/GeoView-Bloc/BlAbstractGeoViewElement.class.st new file mode 100644 index 0000000..5bf9057 --- /dev/null +++ b/GeoView-Bloc/BlAbstractGeoViewElement.class.st @@ -0,0 +1,386 @@ +" +I am an abstract BlElement which contains GeoViewWidget behavior. Not possible to use directly, to use a GeoViewWidget select a subclass element with the targeted backend. +" +Class { + #name : #BlAbstractGeoViewElement, + #superclass : #BlElement, + #traits : 'TGeoViewWidget', + #classTraits : 'TGeoViewWidget classTrait', + #instVars : [ + 'layers', + 'displayToGraphicProjection', + 'isMarkedForSortDatas', + 'mapProjection', + 'interactionsStrategy' + ], + #category : #'GeoView-Bloc-Core' +} + +{ #category : #testing } +BlAbstractGeoViewElement class >> isAbstract [ + + ^ self = BlAbstractGeoViewElement +] + +{ #category : #'API -- coordinates transformations' } +BlAbstractGeoViewElement >> absoluteCoordinatesFromLocalPoint: aLocalPoint [ + + | cartesianCoordinates absoluteCoordinates projection | + projection := self mapProjection. + projection ifNil: [ ^ nil ]. + + cartesianCoordinates := self displayToGraphicProjection + projPixelToCart: aLocalPoint. + absoluteCoordinates := projection projCartToLatLon: + cartesianCoordinates. + ^ absoluteCoordinates +] + +{ #category : #'API -- layers management' } +BlAbstractGeoViewElement >> addLayer: aLayer [ + + | geoViewEvent | + (self layers includes: aLayer) ifTrue: [ ^ self ]. + self configureLayer: aLayer. + self layers add: aLayer. + + "Send layer added event" + geoViewEvent := GeoViewLayerAddedEvent new. + geoViewEvent layerName: aLayer name. + self dispatchEvent: geoViewEvent +] + +{ #category : #'API -- objects management' } +BlAbstractGeoViewElement >> addObject: anUserObject [ + + self enqueueBlockAsTask: [ + self layers do: [ :e | e addObject: anUserObject ]. + self requestSortDatas. + self requestRepaint ] +] + +{ #category : #'API -- objects management' } +BlAbstractGeoViewElement >> addObjects: anUserObjectList [ + + (anUserObjectList isNil or: [ anUserObjectList isEmpty ]) ifTrue: [ ^ self ]. + + self enqueueBlockAsTask: [ + self layers do: [ :e | e addObjects: anUserObjectList ]. + self requestSortDatas. + self requestRepaint ] +] + +{ #category : #private } +BlAbstractGeoViewElement >> configureLayer: aLayer [ + + "Setup the map projection (from a cartographic point of view) of the layer" + aLayer displayModel projection: self mapProjection. + + "Setup the graphic projection (from a device point of view) of the layer" + aLayer graphicModel projection: self displayToGraphicProjection. + + "add Alexandrie process datas" + aLayer graphicModel setProcessData: DCompositeShapeGeoViewProcessData new for: SmockDCompositeShape. + aLayer graphicModel setProcessData: DSymbolGeoViewProcessData new for: SmockDSymbol. + aLayer graphicModel setProcessData: DCircleGeoViewProcessData new for: SmockDCircle. + aLayer graphicModel setProcessData: DTextGeoViewProcessData new for: SmockDText. + aLayer graphicModel setProcessData: DPolygonGeoViewProcessData new for: SmockDPolygon. + aLayer graphicModel setProcessData: DPolylineGeoViewProcessData new for: SmockDPolyline. + + "specify default process data" + "aLayer displayToGraphicModel defaultProcessData: DShapeAeProcessData new." + + "notify when process datas changed internaly" + aLayer announcer when: GeoViewLayerProcessDataChanged send: #layerProcessDataChanged: to: self. +] + +{ #category : #accessing } +BlAbstractGeoViewElement >> displayToGraphicProjection [ + + ^ displayToGraphicProjection +] + +{ #category : #accessing } +BlAbstractGeoViewElement >> displayToGraphicProjection: anObject [ + + | extent | + displayToGraphicProjection := anObject. + displayToGraphicProjection ifNil: [ ^ self ]. + + extent := self extent. + displayToGraphicProjection offsetInPixels: extent / 2. + displayToGraphicProjection updateResolution: extent. + self updateGraphicModel +] + +{ #category : #private } +BlAbstractGeoViewElement >> enqueueBlockAsTask: aBlockClosure [ + + | task | + task := BlTaskAction new. + task action: aBlockClosure. + self enqueueTask: task +] + +{ #category : #'API -- scale and center' } +BlAbstractGeoViewElement >> geoCenter: anAbsoluteCoordinates [ + + | cartesianCoordinates geoViewEvent | + geoCenter := anAbsoluteCoordinates copy. + + cartesianCoordinates := self mapProjection projLatLonToCart: self geoCenter. + self displayToGraphicProjection cartesianCenter: cartesianCoordinates. + self updateGraphicModel. + + "Send center event" + geoViewEvent := GeoViewCenterChangedEvent new. + geoViewEvent absoluteCoordinates: anAbsoluteCoordinates. + self dispatchEvent: geoViewEvent +] + +{ #category : #'API -- layers management' } +BlAbstractGeoViewElement >> getLayer: aKey [ + self explicitRequirement +] + +{ #category : #'API -- layers management' } +BlAbstractGeoViewElement >> getLayers [ + + ^ self layers +] + +{ #category : #'API -- coordinates transformations' } +BlAbstractGeoViewElement >> globalPointFromLocalPoint: aLocalPoint [ + + aLocalPoint ifNil: [ ^ nil ]. + ^ self localPointToGlobal: aLocalPoint +] + +{ #category : #'API -- objects management' } +BlAbstractGeoViewElement >> haveObjectIndex: anIndex [ + "Pay attention before using it because graphical model is out of sync real user model due to usage of BlTask (asynchronous)" + + ^ self layers anySatisfy: [ :l | l haveObjectIndex: anIndex ] +] + +{ #category : #initialization } +BlAbstractGeoViewElement >> initialize [ + + super initialize. + + self mapProjection: GeoViewMercatorProjection new. + self background: Color black. + self displayToGraphicProjection: GeoView2DProjection new. + self initializeEventHandlers. +] + +{ #category : #initialization } +BlAbstractGeoViewElement >> initializeEventHandlers [ + + "Add listeners to process Bloc UI events interactions" + self setInteractionsStrategy: self newInteractionsStrategy. + + "Add listener to compute things when extents changed" + self addEventHandler: (BlEventHandler + on: BlElementExtentChangedEvent + do: [ :e | self processExtentChangedEvent: e ]) +] + +{ #category : #'strategy management' } +BlAbstractGeoViewElement >> interactionsStrategy [ + + ^ interactionsStrategy +] + +{ #category : #accessing } +BlAbstractGeoViewElement >> isMarkedForSortDatas [ + + ^ isMarkedForSortDatas ifNil: [ isMarkedForSortDatas := false ] +] + +{ #category : #private } +BlAbstractGeoViewElement >> layerProcessDataChanged: anEvent [ + + "Send scale event" + | geoViewEvent | + geoViewEvent := GeoViewLayerProcessDataChanged new. + geoViewEvent layerName: anEvent layerName. + self dispatchEvent: geoViewEvent +] + +{ #category : #accessing } +BlAbstractGeoViewElement >> layers [ + + ^ layers ifNil: [ layers := OrderedCollection new ] +] + +{ #category : #'API -- coordinates transformations' } +BlAbstractGeoViewElement >> localPointFromAbsoluteCoordinates: anAbsoluteCoordinates [ + + | projection | + projection := self mapProjection. + projection ifNil: [ ^ nil ]. + + ^ self displayToGraphicProjection projCartToPixel: + (projection projLatLonToCart: anAbsoluteCoordinates) +] + +{ #category : #'API -- coordinates transformations' } +BlAbstractGeoViewElement >> localPointFromGlobalPoint: aGlobalPoint [ + + ^ self globalPointToLocal: aGlobalPoint +] + +{ #category : #'API -- map projection' } +BlAbstractGeoViewElement >> mapProjection [ + "Return the map projection of the object: Mercator, etc." + + ^ mapProjection +] + +{ #category : #'API -- map projection' } +BlAbstractGeoViewElement >> mapProjection: aMapProjection [ + "Setup the map projection of the object: Mercator, etc." + + mapProjection := aMapProjection +] + +{ #category : #'strategy management' } +BlAbstractGeoViewElement >> newInteractionsStrategy [ + + ^ GeoViewDefaultInteractionsStrategy new +] + +{ #category : #private } +BlAbstractGeoViewElement >> processExtentChangedEvent: anEvent [ + + | extent | + extent := anEvent source extent ifNil:[ ^ self ]. + + "configure view projection" + self displayToGraphicProjection offsetInPixels: extent / 2. + self displayToGraphicProjection updateResolution: extent. + + self updateGraphicModel +] + +{ #category : #'strategy management' } +BlAbstractGeoViewElement >> removeInteractionsStrategy [ + + interactionsStrategy ifNil:[ ^ self ]. + self removeEventHandler: interactionsStrategy. + interactionsStrategy := nil. +] + +{ #category : #'API -- layers management' } +BlAbstractGeoViewElement >> removeLayer: aLayer [ + + | geoViewEvent | + self flag:'todo'. + + "Send layer added event" + geoViewEvent := GeoViewLayerRemovedEvent new. + geoViewEvent layerName: aLayer name. + self dispatchEvent: geoViewEvent +] + +{ #category : #'API -- objects management' } +BlAbstractGeoViewElement >> removeObject: anUserObject [ + + self enqueueBlockAsTask: [ + self layers do: [ :e | e removeObject: anUserObject ]. + self requestRepaint ] +] + +{ #category : #'API -- objects management' } +BlAbstractGeoViewElement >> removeObjects: anUserObjectList [ + + self enqueueBlockAsTask: [ + self layers do: [ :e | e removeObjects: anUserObjectList ]. + self requestRepaint ] +] + +{ #category : #private } +BlAbstractGeoViewElement >> requestRepaint [ + + self invalidate. +] + +{ #category : #private } +BlAbstractGeoViewElement >> requestSortDatas [ + + isMarkedForSortDatas := true. +] + +{ #category : #'API -- scale and center' } +BlAbstractGeoViewElement >> scaleInMeters: aNumber [ + + | scale geoViewEvent | + scale := self evaluateScale: aNumber. + scaleInMeters := scale. + + self displayToGraphicProjection altitudeInMeters: self scaleInMeters. + self displayToGraphicProjection updateResolution: self extent. + self updateGraphicModel. + + "Send scale event" + geoViewEvent := GeoViewScaleChangedEvent new. + geoViewEvent scaleInMeters: self scaleInMeters. + self dispatchEvent: geoViewEvent. +] + +{ #category : #'API -- selection' } +BlAbstractGeoViewElement >> selectedObjectIndexes: anIndexList [ + + self enqueueBlockAsTask: [ + self layers do: [ :l | l updateState: #selected withIndexes: anIndexList ]. + self requestSortDatas. + self requestRepaint ] +] + +{ #category : #'strategy management' } +BlAbstractGeoViewElement >> setInteractionsStrategy: aBlEventListener [ + + self removeInteractionsStrategy. + + aBlEventListener ifNil:[ ^ self ]. + interactionsStrategy := aBlEventListener. + self addEventHandler: aBlEventListener. +] + +{ #category : #'API -- drawing' } +BlAbstractGeoViewElement >> updateGraphicModel [ + "Update the graphic model with the Display model" + + self enqueueBlockAsTask: [ + self layers do: [ :e | e updateGraphicModel ]. + self requestRepaint ] +] + +{ #category : #'API -- objects management' } +BlAbstractGeoViewElement >> updateObject: anUserObject [ + + self enqueueBlockAsTask: [ + self layers do: [ :e | e updateObject: anUserObject ]. + self requestSortDatas. + self requestRepaint ] +] + +{ #category : #'API -- objects management' } +BlAbstractGeoViewElement >> updateObjects: anUserObjectList [ + + self enqueueBlockAsTask: [ + self layers do: [ :e | e updateObjects: anUserObjectList ]. + self requestSortDatas. + self requestRepaint ] +] + +{ #category : #private } +BlAbstractGeoViewElement >> updateState: aStateSymbol withIndexes: aKeyList [ + + self enqueueBlockAsTask: [ + self layers do: [ :l | l updateState: aStateSymbol withIndexes: aKeyList ]. + self requestSortDatas. + self requestRepaint + ] +] diff --git a/GeoView-Bloc/GeoViewBlocInputStrategy.class.st b/GeoView-Bloc/GeoViewBlocInputStrategy.class.st index 7d6ce11..0bcd8c9 100644 --- a/GeoView-Bloc/GeoViewBlocInputStrategy.class.st +++ b/GeoView-Bloc/GeoViewBlocInputStrategy.class.st @@ -3,3 +3,8 @@ Class { #superclass : #SmockInputStrategy, #category : #'GeoView-Bloc-Events' } + +{ #category : #deprecation } +GeoViewBlocInputStrategy class >> isDeprecated [ + ^ true +] diff --git a/GeoView-Bloc/GeoViewCenterChangedEvent.class.st b/GeoView-Bloc/GeoViewCenterChangedEvent.class.st new file mode 100644 index 0000000..194b87a --- /dev/null +++ b/GeoView-Bloc/GeoViewCenterChangedEvent.class.st @@ -0,0 +1,26 @@ +Class { + #name : #GeoViewCenterChangedEvent, + #superclass : #GeoViewEvent, + #instVars : [ + 'absoluteCoordinates' + ], + #category : #'GeoView-Bloc-Events' +} + +{ #category : #accessing } +GeoViewCenterChangedEvent >> absoluteCoordinates [ + + ^ absoluteCoordinates +] + +{ #category : #accessing } +GeoViewCenterChangedEvent >> absoluteCoordinates: anObject [ + + absoluteCoordinates := anObject +] + +{ #category : #sending } +GeoViewCenterChangedEvent >> sendTo: anObject [ + + anObject geoViewCenterChangedEvent: self +] diff --git a/GeoView-Bloc/GeoViewCursorCoordinatesChangedEvent.class.st b/GeoView-Bloc/GeoViewCursorCoordinatesChangedEvent.class.st new file mode 100644 index 0000000..ddaf7ba --- /dev/null +++ b/GeoView-Bloc/GeoViewCursorCoordinatesChangedEvent.class.st @@ -0,0 +1,26 @@ +Class { + #name : #GeoViewCursorCoordinatesChangedEvent, + #superclass : #GeoViewEvent, + #instVars : [ + 'absoluteCoordinates' + ], + #category : #'GeoView-Bloc-Events' +} + +{ #category : #accessing } +GeoViewCursorCoordinatesChangedEvent >> absoluteCoordinates [ + + ^ absoluteCoordinates +] + +{ #category : #accessing } +GeoViewCursorCoordinatesChangedEvent >> absoluteCoordinates: anObject [ + + absoluteCoordinates := anObject +] + +{ #category : #sending } +GeoViewCursorCoordinatesChangedEvent >> sendTo: anObject [ + + anObject geoViewCursorCoordinatesChangedEvent: self +] diff --git a/GeoView-Bloc/GeoViewCursorInformationBlocStrategy.class.st b/GeoView-Bloc/GeoViewCursorInformationBlocStrategy.class.st index 04602f6..24292ac 100644 --- a/GeoView-Bloc/GeoViewCursorInformationBlocStrategy.class.st +++ b/GeoView-Bloc/GeoViewCursorInformationBlocStrategy.class.st @@ -4,7 +4,7 @@ Class { #category : #'GeoView-Bloc-Events' } -{ #category : #'event handling' } +{ #category : #'as yet unclassified' } GeoViewCursorInformationBlocStrategy >> processEvent: aSmockEventWrapper context: aSmockInputContext [ | event coordinates geoViewMng | @@ -13,8 +13,11 @@ GeoViewCursorInformationBlocStrategy >> processEvent: aSmockEventWrapper context event isMouseMove ifFalse: [ ^ self ]. geoViewMng := aSmockInputContext controller ifNil:[ ^ self ]. - coordinates := geoViewMng getAbsoluteCoordinatesFromGlobalPoint: event position. - coordinates ifNotNil:[ geoViewMng mouseCursorCoordinatesChanged: coordinates ]. + coordinates := geoViewMng absoluteCoordinatesFromGlobalPoint: event position. + coordinates ifNotNil:[ + self flag:'labordep : faire une notification GeoView (avec event handler) ici pour savoir que le curseur a changé'. + (geoViewMng isKindOf: GeoViewManager) ifTrue:[ geoViewMng mouseCursorCoordinatesChanged: coordinates ]. + ]. aSmockEventWrapper isConsumed: true ] diff --git a/GeoView-Bloc/GeoViewDefaultInteractionsStrategy.class.st b/GeoView-Bloc/GeoViewDefaultInteractionsStrategy.class.st new file mode 100644 index 0000000..3ee90a3 --- /dev/null +++ b/GeoView-Bloc/GeoViewDefaultInteractionsStrategy.class.st @@ -0,0 +1,122 @@ +Class { + #name : #GeoViewDefaultInteractionsStrategy, + #superclass : #BlEventListener, + #instVars : [ + 'isMapMoving', + 'mouseDownPosition' + ], + #category : #'GeoView-Bloc-Events' +} + +{ #category : #accessing } +GeoViewDefaultInteractionsStrategy >> isMapMoving [ + + ^ isMapMoving ifNil: [ isMapMoving := false ] +] + +{ #category : #accessing } +GeoViewDefaultInteractionsStrategy >> isMapMoving: aBoolean [ + + isMapMoving := aBoolean +] + +{ #category : #'mouse handlers' } +GeoViewDefaultInteractionsStrategy >> mouseDownEvent: anEvent [ + + self mouseDownPosition: anEvent position. + self isMapMoving: true +] + +{ #category : #accessing } +GeoViewDefaultInteractionsStrategy >> mouseDownPosition [ + + ^ mouseDownPosition +] + +{ #category : #accessing } +GeoViewDefaultInteractionsStrategy >> mouseDownPosition: aPoint [ + + mouseDownPosition := aPoint +] + +{ #category : #'mouse handlers' } +GeoViewDefaultInteractionsStrategy >> mouseMoveEvent: anEvent [ + + self sendMouseCoordinatesChanged: anEvent. + + "Process mouse map moving" + self isMapMoving ifTrue:[ self moveMap: anEvent ]. + +] + +{ #category : #'mouse handlers' } +GeoViewDefaultInteractionsStrategy >> mouseUpEvent: anEvent [ + + self isMapMoving: false +] + +{ #category : #'mouse handlers' } +GeoViewDefaultInteractionsStrategy >> mouseWheelEvent: anEvent [ + "Scale the map(zoom in or zoom out) but stay centered behind the mouse position" + + | element point mapProjection graphicProjection geoPoint geoPointPx geoCenterPx difPx geoPointPxNew newPointPx geoPointFinal | + + element := anEvent currentTarget. + point := anEvent position. + + mapProjection := element mapProjection ifNil:[ ^ self ]. + graphicProjection := element displayToGraphicProjection ifNil:[ ^ self ]. + + geoPoint := element absoluteCoordinatesFromGlobalPoint: point. + geoPointPx := graphicProjection projCartToPixel: (mapProjection projLatLonToCart: geoPoint). + geoCenterPx := graphicProjection projCartToPixel: (mapProjection projLatLonToCart: element geoCenter). + "Compute diff from mouse position to view center in pixel before scale" + difPx := geoCenterPx - geoPointPx. + + "Scale" + anEvent isScrollDown + ifTrue: [ element scaleDown ] + ifFalse:[ anEvent isScrollUp ifTrue: [ element scaleUp ] ifFalse:[ ^ self ] ]. + + "compute new position in pixel for the mouse position before zoom" + geoPointPxNew := graphicProjection projCartToPixel: (mapProjection projLatLonToCart: geoPoint). + "add the previous diff in pixels to get new center in pixel" + newPointPx := geoPointPxNew + difPx. + "Compute new position in cartesian for new center" + geoPointFinal := element absoluteCoordinatesFromGlobalPoint: newPointPx. + element geoCenter: geoPointFinal. +] + +{ #category : #'events - processing' } +GeoViewDefaultInteractionsStrategy >> moveMap: anEvent [ + + | point difPx geoCenterPx element | + element := anEvent currentTarget ifNil: [ ^ self ]. + + point := anEvent position. + difPx := self mouseDownPosition - point. + difPx := difPx x @ difPx y negated. + geoCenterPx := element globalPointFromAbsoluteCoordinates: element geoCenter. + geoCenterPx ifNil: [ ^ self ]. + geoCenterPx := geoCenterPx + difPx. + + "Update mouse down position with this event" + self mouseDownPosition: point copy. + + element centerOnGlobalPoint: geoCenterPx. +] + +{ #category : #'events - processing' } +GeoViewDefaultInteractionsStrategy >> sendMouseCoordinatesChanged: anEvent [ + + | element coordinates geoViewEvent | + element := anEvent currentTarget. + + "Calculate the absolute coordinates (lat/lon) under the mouse cursor" + coordinates := element absoluteCoordinatesFromGlobalPoint: anEvent position. + coordinates ifNil:[ ^ self ]. + + geoViewEvent := GeoViewCursorCoordinatesChangedEvent new. + geoViewEvent absoluteCoordinates: coordinates. + element dispatchEvent: geoViewEvent. +] diff --git a/GeoView-Bloc/GeoViewEvent.class.st b/GeoView-Bloc/GeoViewEvent.class.st new file mode 100644 index 0000000..0dbd150 --- /dev/null +++ b/GeoView-Bloc/GeoViewEvent.class.st @@ -0,0 +1,5 @@ +Class { + #name : #GeoViewEvent, + #superclass : #BlEvent, + #category : #'GeoView-Bloc-Events' +} diff --git a/GeoView-Bloc/GeoViewEventLogger.class.st b/GeoView-Bloc/GeoViewEventLogger.class.st new file mode 100644 index 0000000..2acc688 --- /dev/null +++ b/GeoView-Bloc/GeoViewEventLogger.class.st @@ -0,0 +1,50 @@ +Class { + #name : #GeoViewEventLogger, + #superclass : #BlCustomEventHandler, + #category : #'GeoView-Bloc-Events' +} + +{ #category : #'api - accessing' } +GeoViewEventLogger >> eventsToHandle [ + + ^ { + GeoViewCursorCoordinatesChangedEvent. + GeoViewCenterChangedEvent. + GeoViewScaleChangedEvent } +] + +{ #category : #events } +GeoViewEventLogger >> geoViewCenterChangedEvent: anEvent [ + + anEvent traceCr. +] + +{ #category : #events } +GeoViewEventLogger >> geoViewCursorCoordinatesChangedEvent: anEvent [ + + anEvent traceCr. +] + +{ #category : #events } +GeoViewEventLogger >> geoViewLayerAddedEvent: anEvent [ + + anEvent traceCr. +] + +{ #category : #events } +GeoViewEventLogger >> geoViewLayerRemovedEvent: anEvent [ + + anEvent traceCr. +] + +{ #category : #events } +GeoViewEventLogger >> geoViewProcessDataChanged: anEvent [ + + anEvent traceCr. +] + +{ #category : #events } +GeoViewEventLogger >> geoViewScaleChangedEvent: anEvent [ + + anEvent traceCr. +] diff --git a/GeoView-Bloc/GeoViewLayerAddedEvent.class.st b/GeoView-Bloc/GeoViewLayerAddedEvent.class.st new file mode 100644 index 0000000..1fb3507 --- /dev/null +++ b/GeoView-Bloc/GeoViewLayerAddedEvent.class.st @@ -0,0 +1,11 @@ +Class { + #name : #GeoViewLayerAddedEvent, + #superclass : #GeoViewLayerEvent, + #category : #'GeoView-Bloc-Events' +} + +{ #category : #sending } +GeoViewLayerAddedEvent >> sendTo: anObject [ + + anObject geoViewLayerAddedEvent: self +] diff --git a/GeoView-Bloc/GeoViewLayerEvent.class.st b/GeoView-Bloc/GeoViewLayerEvent.class.st new file mode 100644 index 0000000..be51562 --- /dev/null +++ b/GeoView-Bloc/GeoViewLayerEvent.class.st @@ -0,0 +1,20 @@ +Class { + #name : #GeoViewLayerEvent, + #superclass : #GeoViewEvent, + #instVars : [ + 'layerName' + ], + #category : #'GeoView-Bloc-Events' +} + +{ #category : #'as yet unclassified' } +GeoViewLayerEvent >> layerName [ + + ^ layerName +] + +{ #category : #'as yet unclassified' } +GeoViewLayerEvent >> layerName: anObject [ + + layerName := anObject +] diff --git a/GeoView-Bloc/GeoViewLayerProcessDataChanged.class.st b/GeoView-Bloc/GeoViewLayerProcessDataChanged.class.st new file mode 100644 index 0000000..e84a98f --- /dev/null +++ b/GeoView-Bloc/GeoViewLayerProcessDataChanged.class.st @@ -0,0 +1,11 @@ +Class { + #name : #GeoViewLayerProcessDataChanged, + #superclass : #GeoViewLayerEvent, + #category : #'GeoView-Bloc-Events' +} + +{ #category : #sending } +GeoViewLayerProcessDataChanged >> sendTo: anObject [ + + anObject geoViewProcessDataChanged: self +] diff --git a/GeoView-Bloc/GeoViewLayerRemovedEvent.class.st b/GeoView-Bloc/GeoViewLayerRemovedEvent.class.st new file mode 100644 index 0000000..7931007 --- /dev/null +++ b/GeoView-Bloc/GeoViewLayerRemovedEvent.class.st @@ -0,0 +1,11 @@ +Class { + #name : #GeoViewLayerRemovedEvent, + #superclass : #GeoViewLayerEvent, + #category : #'GeoView-Bloc-Events' +} + +{ #category : #sending } +GeoViewLayerRemovedEvent >> sendTo: anObject [ + + anObject geoViewLayerRemovedEvent: self +] diff --git a/GeoView-Bloc/GeoViewNavigationBlocStrategy.class.st b/GeoView-Bloc/GeoViewNavigationBlocStrategy.class.st index 1491150..d74221b 100644 --- a/GeoView-Bloc/GeoViewNavigationBlocStrategy.class.st +++ b/GeoView-Bloc/GeoViewNavigationBlocStrategy.class.st @@ -11,7 +11,7 @@ Class { { #category : #accessing } GeoViewNavigationBlocStrategy >> isMapMoving [ - ^ isMapMoving ifNil:[ isMapMoving := false ] + ^ isMapMoving ifNil: [ isMapMoving := false ] ] { #category : #accessing } @@ -34,21 +34,21 @@ GeoViewNavigationBlocStrategy >> keyUp: aSmockEventWrapper context: aSmockInputC { #category : #'event handling' } GeoViewNavigationBlocStrategy >> moveMap: aSmockEventWrapper context: aSmockInputContext [ - | point difPx geoCenterPx geoViewMng | - - geoViewMng := aSmockInputContext controller ifNil:[ ^ self ]. - + + | point difPx geoCenterPx element | + element := aSmockInputContext controller ifNil: [ ^ self ]. + point := aSmockEventWrapper event position. difPx := self previousPoint - point. - difPx := (difPx x) @ (difPx y negated). - geoCenterPx := geoViewMng getGlobalPointFromAbsoluteCoordinates: geoViewMng getGeoCenter. - geoCenterPx ifNil:[ ^ self ]. - + difPx := difPx x @ difPx y negated. + geoCenterPx := element globalPointFromAbsoluteCoordinates: element geoCenter. + geoCenterPx ifNil: [ ^ self ]. + geoCenterPx := geoCenterPx + difPx. - geoViewMng centerOnPoint: geoCenterPx. - + element centerOnGlobalPoint: geoCenterPx. + self previousPoint: point copy. - aSmockEventWrapper isConsumed: true. + aSmockEventWrapper isConsumed: true ] { #category : #accessing } @@ -105,64 +105,60 @@ GeoViewNavigationBlocStrategy >> processEvent: aSmockEventWrapper context: aSmoc { #category : #'event handling' } GeoViewNavigationBlocStrategy >> scrollDown: aSmockEventWrapper context: aSmockInputContext [ - | point geoPoint projection projection2D geoPointPx geoPointPxNew geoCenterPx difPx newPointPx geoPointFinal geoViewMng | + | point geoPoint mapProjection graphicProjection geoPointPx geoPointPxNew geoCenterPx difPx newPointPx geoPointFinal element | - geoViewMng := aSmockInputContext controller ifNil:[ ^ self ]. + element := aSmockInputContext controller ifNil:[ ^ self ]. point := aSmockEventWrapper event position. - projection := geoViewMng getMapProjectionManagerServicesProvider getProjection. - projection ifNil:[ ^ self ]. - - projection2D := geoViewMng view displayToGraphicProjection. + mapProjection := element mapProjection ifNil:[ ^ self ]. + graphicProjection := element displayToGraphicProjection ifNil:[ ^ self ]. - geoPoint := geoViewMng getAbsoluteCoordinatesFromGlobalPoint: point. - geoPointPx := projection2D projCartToPixel: (projection projLatLonToCart: geoPoint). - geoCenterPx := projection2D projCartToPixel: (projection projLatLonToCart: geoViewMng getGeoCenter). + geoPoint := element absoluteCoordinatesFromGlobalPoint: point. + geoPointPx := graphicProjection projCartToPixel: (mapProjection projLatLonToCart: geoPoint). + geoCenterPx := graphicProjection projCartToPixel: (mapProjection projLatLonToCart: element geoCenter). "Compute diff from mouse position to view center in pixel before scale" difPx := geoCenterPx - geoPointPx. "Scale" - geoViewMng scaleDown. + element scaleDown. "compute new position in pixel for the mouse position before zoom" - geoPointPxNew := projection2D projCartToPixel: (projection projLatLonToCart: geoPoint). + geoPointPxNew := graphicProjection projCartToPixel: (mapProjection projLatLonToCart: geoPoint). "add the previous diff in pixels to get new center in pixel" newPointPx := geoPointPxNew + difPx. "Compute new position in cartesian for new center" - geoPointFinal := geoViewMng getAbsoluteCoordinatesFromGlobalPoint: newPointPx. - geoViewMng setGeoCenter: geoPointFinal. + geoPointFinal := element absoluteCoordinatesFromGlobalPoint: newPointPx. + element geoCenter: geoPointFinal. aSmockEventWrapper isConsumed: true. ] { #category : #'event handling' } GeoViewNavigationBlocStrategy >> scrollUp: aSmockEventWrapper context: aSmockInputContext [ - | point geoPoint projection projection2D geoPointPx geoPointPxNew geoCenterPx difPx newPointPx geoPointFinal geoViewMng | + | point geoPoint mapProjection graphicProjection geoPointPx geoPointPxNew geoCenterPx difPx newPointPx geoPointFinal element | - geoViewMng := aSmockInputContext controller ifNil:[ ^ self ]. + element := aSmockInputContext controller ifNil:[ ^ self ]. point := aSmockEventWrapper event position. - projection := geoViewMng getMapProjectionManagerServicesProvider getProjection. - projection ifNil:[ ^ self ]. - - projection2D := geoViewMng view displayToGraphicProjection. + mapProjection := element mapProjection ifNil:[ ^ self ]. + graphicProjection := element displayToGraphicProjection ifNil:[ ^ self ]. - geoPoint := geoViewMng getAbsoluteCoordinatesFromGlobalPoint: point. - geoPointPx := projection2D projCartToPixel: (projection projLatLonToCart: geoPoint). - geoCenterPx := projection2D projCartToPixel: (projection projLatLonToCart: geoViewMng getGeoCenter). + geoPoint := element absoluteCoordinatesFromGlobalPoint: point. + geoPointPx := graphicProjection projCartToPixel: (mapProjection projLatLonToCart: geoPoint). + geoCenterPx := graphicProjection projCartToPixel: (mapProjection projLatLonToCart: element geoCenter). "Compute diff from mouse position to view center in pixel before scale" difPx := geoCenterPx - geoPointPx. "Scale" - geoViewMng scaleUp. + element scaleUp. "compute new position in pixel for the mouse position before zoom" - geoPointPxNew := projection2D projCartToPixel: (projection projLatLonToCart: geoPoint). + geoPointPxNew := graphicProjection projCartToPixel: (mapProjection projLatLonToCart: geoPoint). "add the previous diff in pixels to get new center in pixel" newPointPx := geoPointPxNew + difPx. "Compute new position in cartesian for new center" - geoPointFinal := geoViewMng getAbsoluteCoordinatesFromGlobalPoint: newPointPx. - geoViewMng setGeoCenter: geoPointFinal. + geoPointFinal := element absoluteCoordinatesFromGlobalPoint: newPointPx. + element geoCenter: geoPointFinal. aSmockEventWrapper isConsumed: true. ] diff --git a/GeoView-Bloc/GeoViewScaleChangedEvent.class.st b/GeoView-Bloc/GeoViewScaleChangedEvent.class.st new file mode 100644 index 0000000..2aeeb38 --- /dev/null +++ b/GeoView-Bloc/GeoViewScaleChangedEvent.class.st @@ -0,0 +1,26 @@ +Class { + #name : #GeoViewScaleChangedEvent, + #superclass : #GeoViewEvent, + #instVars : [ + 'scaleInMeters' + ], + #category : #'GeoView-Bloc-Events' +} + +{ #category : #accessing } +GeoViewScaleChangedEvent >> scaleInMeters [ + + ^ scaleInMeters +] + +{ #category : #accessing } +GeoViewScaleChangedEvent >> scaleInMeters: anObject [ + + scaleInMeters := anObject +] + +{ #category : #sending } +GeoViewScaleChangedEvent >> sendTo: anObject [ + + anObject geoViewScaleChangedEvent: self +] diff --git a/GeoView-Examples-Bloc-Molecule/GeoViewExamplesBlocMolecule.class.st b/GeoView-Examples-Bloc-Molecule/GeoViewExamplesBlocMolecule.class.st new file mode 100644 index 0000000..70dcdc2 --- /dev/null +++ b/GeoView-Examples-Bloc-Molecule/GeoViewExamplesBlocMolecule.class.st @@ -0,0 +1,103 @@ +Class { + #name : #GeoViewExamplesBlocMolecule, + #superclass : #Object, + #category : #'GeoView-Examples-Bloc-Molecule' +} + +{ #category : #private } +GeoViewExamplesBlocMolecule class >> createGeoObjects [ + + | list random nb | + list := OrderedCollection new. + random := Random new. + nb := 1000. + + 1 to: nb do:[ :i | | object | + object := GeoCircle new. + object key: i. + object fillStyle: (Color random asSmockFillStyle). + object strokeStyle: (Color random asSmockStrokeStyle). + object absoluteCoordinates: AbsoluteCoordinates random. + object radiusInMeters: (random next * 100000). + list add: object. + ]. + + ^ list +] + +{ #category : #examples } +GeoViewExamplesBlocMolecule class >> exampleWithGeoObjects [ + "This example use ready-to-use geo-object classes (GeoObject and processData) to represent a static (no updates) geographical view with a lot of data." + + | geoViewManager layer objects | + geoViewManager := GeoViewManagerBlocAeImpl start: #GeoViewManager , Random new next printString. + + layer := GeoViewUtils createGeoObjectsLayer: #layer1. + layer := geoViewManager addLayer: layer. + + "create sample datas" + objects := self createGeoObjects. + geoViewManager addObjects: objects. + + ^ self openViewInWindow: geoViewManager +] + +{ #category : #examples } +GeoViewExamplesBlocMolecule class >> exampleWithGeoObjectsUpdated [ + "This example use ready-to-use geo-object classes (GeoObject and processData) to represent updated geographical view with a lot of data." + + | geoViewManager layer objects space thread | + geoViewManager := GeoViewManagerBlocAeImpl start: #GeoViewManager , Random new next printString. + + layer := GeoViewUtils createGeoObjectsLayer: #layer1. + layer := geoViewManager addLayer: layer. + + "create sample datas" + objects := self createGeoObjects. + geoViewManager addObjects: objects. + + space := self openViewInWindow: geoViewManager. + + "Objet update thread" + thread := [ | random | + random := Random new. + [ true ] whileTrue:[ + 1 second wait. + objects do:[ :o | + o radiusInMeters: (random next * 200000). + geoViewManager updateObject: o. + ]. + ]. + ] forkAt: Processor userBackgroundPriority named: 'GeoView objects update example'. + + "Stop thread when window is closed" + space addEventHandler: (BlEventHandler + on: BlSpaceCloseRequest + do: [ :event | thread terminate. ]). + + ^ space +] + +{ #category : #private } +GeoViewExamplesBlocMolecule class >> openViewInWindow: aGeoViewManager [ + "open the view in a window" + + | blElement space | + blElement := aGeoViewManager getView. + blElement constraintsDo: [ :c | + c vertical matchParent. + c horizontal matchParent ]. + space := blElement openInSpace. + space title: 'GeoView Molecule example'. + + space addEventHandler: (BlEventHandler + on: BlSpaceCloseRequest + do: [ :event | + aGeoViewManager class stop: aGeoViewManager componentName ]). + + ^ space +] + +{ #category : #'see class side' } +GeoViewExamplesBlocMolecule >> seeClassSide [ +] diff --git a/GeoView-Examples-Bloc-Molecule/package.st b/GeoView-Examples-Bloc-Molecule/package.st new file mode 100644 index 0000000..7325520 --- /dev/null +++ b/GeoView-Examples-Bloc-Molecule/package.st @@ -0,0 +1 @@ +Package { #name : #'GeoView-Examples-Bloc-Molecule' } diff --git a/GeoView-Examples-Bloc/GeoViewExamplesBloc.class.st b/GeoView-Examples-Bloc/GeoViewExamplesBloc.class.st index 04d01cc..627d3b6 100644 --- a/GeoView-Examples-Bloc/GeoViewExamplesBloc.class.st +++ b/GeoView-Examples-Bloc/GeoViewExamplesBloc.class.st @@ -29,54 +29,44 @@ GeoViewExamplesBloc class >> createGeoObjects [ GeoViewExamplesBloc class >> exampleWithGeoObjects [ "This example use ready-to-use geo-object classes (GeoObject and processData) to represent a static (no updates) geographical view with a lot of data." - | geoViewManager layer objects | - geoViewManager := GeoViewManagerBlocAeImpl start: #GeoViewManager , Random new next printString. + | element layer objects | + element := BlGeoViewAeElement new. - "parameters" - "geoViewManager setObjectIndexAccessor: #key." - - "setup projection example" - "geoViewManager getMapProjectionManagerServicesProvider setProjection: MercatorProjection new." - "configure layers and process datas : objects that can be displayed and how" - layer := geoViewManager createAndAddLayer: #layer1. - layer setProcessData: GeoCircleProcessData new for: GeoCircle. - layer setProcessData: GeoEllipseProcessData new for: GeoEllipse. - layer setProcessData: GeoPolygonProcessData new for: GeoPolygon. - layer setProcessData: GeoPolylineProcessData new for: GeoPolyline. - layer setProcessData: GeoRectangleProcessData new for: GeoRectangle. - layer setProcessData: GeoTextProcessData new for: GeoText. - layer setProcessData: GeoArcBandProcessData new for: GeoArcBand. + layer := GeoViewUtils createGeoObjectsLayer: #layer1. + element addLayer: layer. "create sample datas" objects := self createGeoObjects. - geoViewManager addObjects: objects. - - ^ self openViewInWindow: geoViewManager + element addObjects: objects. + + "Example of event handler behavior on geoView domain event" + element addEventHandlerOn: GeoViewCursorCoordinatesChangedEvent do: [ :event | + event absoluteCoordinates printString traceCr. + ]. + + "Example of custom EventHandler, here a logger" + element addEventHandler: (GeoViewEventLogger new). + + ^ self openViewInWindow: element ] { #category : #examples } GeoViewExamplesBloc class >> exampleWithGeoObjectsUpdated [ "This example use ready-to-use geo-object classes (GeoObject and processData) to represent updated geographical view with a lot of data." - | geoViewManager layer objects space thread | - geoViewManager := GeoViewManagerBlocAeImpl start: #GeoViewManager , Random new next printString. + | element layer objects space thread | + element := BlGeoViewAeElement new. "configure layers and process datas : objects that can be displayed and how" - layer := geoViewManager createAndAddLayer: #layer1. - layer setProcessData: GeoCircleProcessData new for: GeoCircle. - layer setProcessData: GeoEllipseProcessData new for: GeoEllipse. - layer setProcessData: GeoPolygonProcessData new for: GeoPolygon. - layer setProcessData: GeoPolylineProcessData new for: GeoPolyline. - layer setProcessData: GeoRectangleProcessData new for: GeoRectangle. - layer setProcessData: GeoTextProcessData new for: GeoText. - layer setProcessData: GeoArcBandProcessData new for: GeoArcBand. + layer := GeoViewUtils createGeoObjectsLayer: #layer1. + element addLayer: layer. "create sample datas" objects := self createGeoObjects. - geoViewManager addObjects: objects. + element addObjects: objects. - space := self openViewInWindow: geoViewManager. + space := self openViewInWindow: element. "Objet update thread" thread := [ | random | @@ -85,7 +75,7 @@ GeoViewExamplesBloc class >> exampleWithGeoObjectsUpdated [ 1 second wait. objects do:[ :o | o radiusInMeters: (random next * 200000). - geoViewManager updateObject: o. + element updateObject: o. ]. ]. ] forkAt: Processor userBackgroundPriority named: 'GeoView objects update example'. @@ -99,22 +89,16 @@ GeoViewExamplesBloc class >> exampleWithGeoObjectsUpdated [ ] { #category : #private } -GeoViewExamplesBloc class >> openViewInWindow: aGeoViewManager [ - +GeoViewExamplesBloc class >> openViewInWindow: aBlGeoViewElement [ "open the view in a window" - | blElement space | - blElement := aGeoViewManager getView. - blElement constraintsDo: [ :c | + + | space | + aBlGeoViewElement constraintsDo: [ :c | c vertical matchParent. c horizontal matchParent ]. - space := blElement openInSpace. + space := aBlGeoViewElement openInSpace. space title: 'GeoView example'. - - space addEventHandler: (BlEventHandler - on: BlSpaceCloseRequest - do: [ :event | - aGeoViewManager class stop: aGeoViewManager componentName ]). - + ^ space ] diff --git a/GeoView-Examples/GeoRocket.class.st b/GeoView-Examples/GeoRocket.class.st deleted file mode 100644 index fafe06f..0000000 --- a/GeoView-Examples/GeoRocket.class.st +++ /dev/null @@ -1,40 +0,0 @@ -" -I am a rocket. -I am used for Geoplot Examples of rich object. -" -Class { - #name : #GeoRocket, - #superclass : #GeoObject, - #instVars : [ - 'kinematics', - 'name' - ], - #category : #'GeoView-Examples' -} - -{ #category : #accessing } -GeoRocket >> kinematics [ - ^ kinematics -] - -{ #category : #accessing } -GeoRocket >> kinematics: aKinematics [ - kinematics := aKinematics -] - -{ #category : #accessing } -GeoRocket >> name [ - ^ name -] - -{ #category : #accessing } -GeoRocket >> name: anObject [ - name := anObject -] - -{ #category : #updating } -GeoRocket >> updateWith: aGeoRocket [ - super updateWith: aGeoRocket. - self name: aGeoRocket name copy. - self kinematics: aGeoRocket kinematics copy. -] diff --git a/GeoView-Examples/GeoRocketProcessData.class.st b/GeoView-Examples/GeoRocketProcessData.class.st deleted file mode 100644 index b0e5462..0000000 --- a/GeoView-Examples/GeoRocketProcessData.class.st +++ /dev/null @@ -1,55 +0,0 @@ -Class { - #name : #GeoRocketProcessData, - #superclass : #GeoObjectProcessData, - #category : #'GeoView-Examples' -} - -{ #category : #processing } -GeoRocketProcessData >> processCreatedData: aKey incoming: aGeoRocket with: aDCompositeShape context: aContext [ - | dCompositeShape dCircle dLabel | - dCompositeShape := aDCompositeShape ifNil:[SmockDCompositeShape new]. - super processCreatedData: aKey incoming: aGeoRocket with: dCompositeShape context: aContext. - dCompositeShape key: aKey. - - "create a symbol as a circle" - dCircle := SmockDCircle new. - dCircle key: #symbol. - dCircle radius: 1000000. - dCircle fillColor: Color black. - dCompositeShape addDShape: dCircle. - - "create a label" - dLabel := SmockDText new. - dLabel key: #label. - dLabel fillColor: Color black. - dLabel fontSize: 11. - dLabel text: 'Rocket A'. - dCompositeShape addDShape: dLabel. - - ^dCompositeShape -] - -{ #category : #processing } -GeoRocketProcessData >> processDeletedData: aKey incoming: aGeoRocket with: aDCompositeShape context: aContext [ - ^aDCompositeShape -] - -{ #category : #processing } -GeoRocketProcessData >> processUpdatedData: aKey incoming: aGeoRocket with: aDCompositeShape context: aContext [ - | dCompositeShape dCircle dLabel | - dCompositeShape := aDCompositeShape. - super processUpdatedData: aKey incoming: aGeoRocket with: dCompositeShape context: aContext. - - "update symbol" - dCircle := dCompositeShape getDShape: #symbol. - dCircle radius: 1000000. - dCircle fillColor: Color random. - dCompositeShape updateDShape: dCircle. - - "update label" - dLabel := dCompositeShape getDShape: #label. - dLabel text: 'Rocket A'. - dCompositeShape updateDShape: dLabel. - - ^dCompositeShape -] diff --git a/GeoView-Examples/ShapeFileReader.class.st b/GeoView-Examples/ShapeFileReader.class.st deleted file mode 100644 index 7f38fc8..0000000 --- a/GeoView-Examples/ShapeFileReader.class.st +++ /dev/null @@ -1,49 +0,0 @@ -Class { - #name : #ShapeFileReader, - #superclass : #Object, - #category : #'GeoView-Examples' -} - -{ #category : #'instance creation' } -ShapeFileReader class >> fromShapeMap: aShapeMap [ - - aShapeMap hasPolygons ifTrue: [ ^ self fromShapeMapPolygons: aShapeMap ]. - aShapeMap hasLines ifTrue: [ ^ self fromShapeMapLines: aShapeMap ]. - aShapeMap hasPoints ifTrue: [ ^ self fromShapeMapPoints: aShapeMap ]. -] - -{ #category : #'instance creation' } -ShapeFileReader class >> fromShapeMapLines: aShapeMap [ - - ^ (1 to: aShapeMap numberOfShapes) collect: [ :i | - (aShapeMap vertices2DByPartsForShapeIndex: i) collect: [ :part | | polyline | - polyline := GeoPolyline new. - polyline absolutePositions: (part collect: - [ :point | AbsoluteCoordinates latitudeInDegrees: point y longitudeInDegrees: point x]). - polyline strokeColor: aShapeMap arcColor. - polyline strokeColor ifNotNil: [ polyline strokeWidth: 1 ]. - polyline]]. - -] - -{ #category : #'instance creation' } -ShapeFileReader class >> fromShapeMapPoints: aShapeMap [ - - self notYetImplemented -] - -{ #category : #'instance creation' } -ShapeFileReader class >> fromShapeMapPolygons: aShapeMap [ - - ^ (1 to: aShapeMap numberOfShapes) collect: [ :i | - (aShapeMap vertices2DByPartsForShapeIndex: i) collect: [ :part | | polygon | - polygon := GeoPolygon new. - polygon absolutePositions: (part collect: - [ :point | AbsoluteCoordinates latitudeInDegrees: point y longitudeInDegrees: point x]). - polygon fillColor: aShapeMap polygonColor. - polygon strokeColor: aShapeMap arcColor. - polygon strokeColor ifNotNil: [ polygon strokeWidth: 1 ]. - polygon]]. - - -] diff --git a/GeoView-Examples/package.st b/GeoView-Examples/package.st deleted file mode 100644 index e3d99e3..0000000 --- a/GeoView-Examples/package.st +++ /dev/null @@ -1 +0,0 @@ -Package { #name : #'GeoView-Examples' } diff --git a/GeoView-Tests/GeoViewManagerImplTests.class.st b/GeoView-Molecule-Tests/GeoViewManagerImplTests.class.st similarity index 82% rename from GeoView-Tests/GeoViewManagerImplTests.class.st rename to GeoView-Molecule-Tests/GeoViewManagerImplTests.class.st index 39a608a..332ce68 100644 --- a/GeoView-Tests/GeoViewManagerImplTests.class.st +++ b/GeoView-Molecule-Tests/GeoViewManagerImplTests.class.st @@ -5,7 +5,7 @@ Class { 'geoViewManagerName', 'geoViewManager' ], - #category : #'GeoView-Tests-Cases - GeoViewManager' + #category : #'GeoView-Molecule-Tests-Cases' } { #category : #running } @@ -32,24 +32,23 @@ GeoViewManagerImplTests >> tearDown [ { #category : #tests } GeoViewManagerImplTests >> testAggregatedComponentsStart [ - self assert: geoViewManager getMapProjectionManagerServicesProvider isNotFoundServices equals: false. self assert: geoViewManager getSmockSymbologyManagerServicesProvider isNotFoundServices equals: false. self assert: geoViewManager getSmockSelectionManagerServicesProvider isNotFoundServices equals: false. ] { #category : #tests } -GeoViewManagerImplTests >> testCreateAndAddLayer [ +GeoViewManagerImplTests >> testCreateAndAddGeoObjectsLayer [ "Warning : default implementation of GeoViewManager is an abtract engine implementation, all created objets are nil" | layer | - layer := geoViewManager createAndAddLayer: #layerA. + layer := geoViewManager createAndAddGeoObjectsLayer: #layerA. self assert: layer notNil. ] { #category : #tests } GeoViewManagerImplTests >> testLayerServices [ | layer | - geoViewManager addLayer: (GeoViewTestLayer new layerName: #layer1). + geoViewManager addLayer: (GeoViewTestLayer new name: #layer1). self assert: geoViewManager getLayers size equals: 1. layer := geoViewManager getLayer: #layer1. @@ -58,7 +57,7 @@ GeoViewManagerImplTests >> testLayerServices [ geoViewManager removeLayer: #layer1. self assert: geoViewManager getLayers isEmpty. - geoViewManager addLayer: (GeoViewTestLayer new layerName: #layer1). + geoViewManager addLayer: (GeoViewTestLayer new name: #layer1). self assert: geoViewManager getLayers size equals: 1. geoViewManager removeAllLayers. diff --git a/GeoView-Molecule-Tests/GeoViewManagerTestImpl.class.st b/GeoView-Molecule-Tests/GeoViewManagerTestImpl.class.st new file mode 100644 index 0000000..755f306 --- /dev/null +++ b/GeoView-Molecule-Tests/GeoViewManagerTestImpl.class.st @@ -0,0 +1,21 @@ +Class { + #name : #GeoViewManagerTestImpl, + #superclass : #GeoViewManagerImpl, + #category : #'GeoView-Molecule-Tests-Utils' +} + +{ #category : #'layer creation' } +GeoViewManagerTestImpl >> createGeoObjectsLayer: aName [ + + ^ GeoViewObjectTestLayer new +] + +{ #category : #initialization } +GeoViewManagerTestImpl >> createView [ + + self view: GeoViewTestWidget new +] + +{ #category : #'services - map projection' } +GeoViewManagerTestImpl >> getMapProjection [ +] diff --git a/GeoView-Tests/GeoViewUserTest.trait.st b/GeoView-Molecule-Tests/GeoViewUserTest.trait.st similarity index 86% rename from GeoView-Tests/GeoViewUserTest.trait.st rename to GeoView-Molecule-Tests/GeoViewUserTest.trait.st index 4266b28..da3ef9e 100644 --- a/GeoView-Tests/GeoViewUserTest.trait.st +++ b/GeoView-Molecule-Tests/GeoViewUserTest.trait.st @@ -2,7 +2,7 @@ Trait { #name : #GeoViewUserTest, #traits : 'MolComponentType', #classTraits : 'MolComponentType classTrait', - #category : #'GeoView-Tests-Utils' + #category : #'GeoView-Molecule-Tests-Utils' } { #category : #'accessing - events' } diff --git a/GeoView-Tests/GeoViewUserTestImpl.class.st b/GeoView-Molecule-Tests/GeoViewUserTestImpl.class.st similarity index 97% rename from GeoView-Tests/GeoViewUserTestImpl.class.st rename to GeoView-Molecule-Tests/GeoViewUserTestImpl.class.st index 7caaecf..688804f 100644 --- a/GeoView-Tests/GeoViewUserTestImpl.class.st +++ b/GeoView-Molecule-Tests/GeoViewUserTestImpl.class.st @@ -6,7 +6,7 @@ Class { #instVars : [ 'receivedGeoViewLayerEvents' ], - #category : #'GeoView-Tests-Utils' + #category : #'GeoView-Molecule-Tests-Utils' } { #category : #events } diff --git a/GeoView-Molecule-Tests/package.st b/GeoView-Molecule-Tests/package.st new file mode 100644 index 0000000..d92ee6c --- /dev/null +++ b/GeoView-Molecule-Tests/package.st @@ -0,0 +1 @@ +Package { #name : #'GeoView-Molecule-Tests' } diff --git a/GeoView/GeoViewManager.trait.st b/GeoView-Molecule/GeoViewManager.trait.st similarity index 58% rename from GeoView/GeoViewManager.trait.st rename to GeoView-Molecule/GeoViewManager.trait.st index f51e8b5..b4b39cf 100644 --- a/GeoView/GeoViewManager.trait.st +++ b/GeoView-Molecule/GeoViewManager.trait.st @@ -6,38 +6,51 @@ Trait { #name : #GeoViewManager, #traits : 'MolComponentType', #classTraits : 'MolComponentType classTrait', - #category : #'GeoView-Core' + #category : #'GeoView-Molecule' } { #category : #'accessing - events' } GeoViewManager classSide >> consumedComponentEvents [ + ^ { SmockSelectionManagerEvents } ] { #category : #'accessing - events' } GeoViewManager classSide >> producedComponentEvents [ - - ^{ GeoViewManagerEvents . GeoViewManagerLayerEvents . GeoViewManagerCursorEvents } + + + ^ { + GeoViewManagerEvents. + GeoViewManagerLayerEvents. + GeoViewManagerCursorEvents } ] { #category : #'accessing - parameters' } GeoViewManager classSide >> providedComponentParameters [ - - ^{ GeoViewManagerParameters . GeoViewManagerGeoObjectsParameters } + + + ^ { + GeoViewManagerParameters. + GeoViewManagerGeoObjectsParameters } ] { #category : #'accessing - services' } GeoViewManager classSide >> providedComponentServices [ - - ^{ GeoViewManagerServices. - GeoViewManagerLayerServices. - GeoViewManagerObjectsServices. - GeoViewManagerPickingServices } + + + ^ { + GeoViewManagerServices. + GeoViewManagerLayerServices. + GeoViewManagerObjectsServices. + GeoViewManagerPickingServices } ] { #category : #'accessing - services' } GeoViewManager classSide >> usedComponentServices [ - - ^{MapProjectionManagerServices . SmockSymbologyManagerServices . SmockSelectionManagerServices } + + + ^ { + SmockSymbologyManagerServices. + SmockSelectionManagerServices } ] diff --git a/GeoView/GeoViewManagerCursorEvents.trait.st b/GeoView-Molecule/GeoViewManagerCursorEvents.trait.st similarity index 86% rename from GeoView/GeoViewManagerCursorEvents.trait.st rename to GeoView-Molecule/GeoViewManagerCursorEvents.trait.st index 26cbf70..3c023b0 100644 --- a/GeoView/GeoViewManagerCursorEvents.trait.st +++ b/GeoView-Molecule/GeoViewManagerCursorEvents.trait.st @@ -2,7 +2,7 @@ Trait { #name : #GeoViewManagerCursorEvents, #traits : 'MolComponentEvents', #classTraits : 'MolComponentEvents classTrait', - #category : #'GeoView-Core' + #category : #'GeoView-Molecule' } { #category : #events } diff --git a/GeoView-Molecule/GeoViewManagerEvents.trait.st b/GeoView-Molecule/GeoViewManagerEvents.trait.st new file mode 100644 index 0000000..c5a6881 --- /dev/null +++ b/GeoView-Molecule/GeoViewManagerEvents.trait.st @@ -0,0 +1,17 @@ +" +I am geoplot manager events +" +Trait { + #name : #GeoViewManagerEvents, + #traits : 'MolComponentEvents', + #classTraits : 'MolComponentEvents classTrait', + #category : #'GeoView-Molecule' +} + +{ #category : #'events - map projection' } +GeoViewManagerEvents >> mapProjectionHasChanged: aMapProjection [ +] + +{ #category : #'events - map projection' } +GeoViewManagerEvents >> mapProjectionUpdated: aMapProjection [ +] diff --git a/GeoView/GeoViewManagerGeoObjectsParameters.trait.st b/GeoView-Molecule/GeoViewManagerGeoObjectsParameters.trait.st similarity index 91% rename from GeoView/GeoViewManagerGeoObjectsParameters.trait.st rename to GeoView-Molecule/GeoViewManagerGeoObjectsParameters.trait.st index 2d3a211..d6a7a7b 100644 --- a/GeoView/GeoViewManagerGeoObjectsParameters.trait.st +++ b/GeoView-Molecule/GeoViewManagerGeoObjectsParameters.trait.st @@ -2,7 +2,7 @@ Trait { #name : #GeoViewManagerGeoObjectsParameters, #traits : 'MolComponentParameters', #classTraits : 'MolComponentParameters classTrait', - #category : #'GeoView-Core' + #category : #'GeoView-Molecule' } { #category : #initialization } diff --git a/GeoView/GeoViewManagerImpl.class.st b/GeoView-Molecule/GeoViewManagerImpl.class.st similarity index 72% rename from GeoView/GeoViewManagerImpl.class.st rename to GeoView-Molecule/GeoViewManagerImpl.class.st index 1de5274..470fe9e 100644 --- a/GeoView/GeoViewManagerImpl.class.st +++ b/GeoView-Molecule/GeoViewManagerImpl.class.st @@ -12,17 +12,15 @@ Class { 'scaleInMeters', 'minScaleInMeters', 'maxScaleInMeters', - 'scaleFactor', - 'inputContext', - 'objectIndexAccessor' + 'scaleFactor' ], - #category : #'GeoView-Core-Impl' + #category : #'GeoView-Molecule' } { #category : #'aggregated components' } GeoViewManagerImpl >> activateComponents [ - MapProjectionManagerImpl activate: self componentName. + "MapProjectionManagerImpl activate: self componentName." (MolComponentManager default homeServices isWaitingForActivation: SmockSymbologyProvider named: self componentName) ifTrue:[ SmockSymbologyProvider activate: self componentName. ]. @@ -33,16 +31,13 @@ GeoViewManagerImpl >> activateComponents [ { #category : #'services - layer creation' } GeoViewManagerImpl >> addLayer: aLayer [ - "(aLayer class traitComposition allTraits includes: GeoViewLayer) ifFalse:[^nil]." - self flag:'labordep : regarder les traits dans lheritage pour être sûr que cest une layer ?'. - aLayer layerName ifNil:[^nil]. - aLayer projection: self getMapProjectionManagerServicesProvider getProjection. + aLayer name ifNil:[ ^ nil ]. aLayer symbologyProvider: self getSmockSymbologyManagerServicesProvider. - aLayer whenProcessDatasChangedDo: [ :l | self layerHasBeenUpdated: l ]. self view addLayer: aLayer. - self getGeoViewManagerLayerEventsNotifier geoViewLayerAdded: aLayer layerName in: self componentName + self flag:'call this event from GeoView layer Added event'. + self getGeoViewManagerLayerEventsNotifier geoViewLayerAdded: aLayer name in: self componentName ] { #category : #'geobjects aur' } @@ -54,7 +49,6 @@ GeoViewManagerImpl >> addObject: aGeoObject [ { #category : #'geobjects aur' } GeoViewManagerImpl >> addObjects: aGeoObjectList [ - (aGeoObjectList isNil or: [ aGeoObjectList isEmpty ]) ifTrue: [ ^ self ]. self view addObjects: aGeoObjectList ] @@ -78,15 +72,13 @@ GeoViewManagerImpl >> componentInitialize [ super componentInitialize. - self forServices: MapProjectionManagerServices useProvider: self componentName. + "self forServices: MapProjectionManagerServices useProvider: self componentName." - self initializeProjectionManager. + "self initializeProjectionManager." self initializeSelectionManager. self initializeSymbologyManager. - self createView. - self initializeInputContext. - self initializeView. + self createView ] { #category : #'life cycle' } @@ -102,60 +94,27 @@ GeoViewManagerImpl >> componentRemove [ self removeComponents ] -{ #category : #private } -GeoViewManagerImpl >> correctedScale: aNumberInMeters [ -"Enlarge view on Mercator projection near the poles : used for decrease zoom effect when projection changes" - self getMapProjectionManagerServicesProvider getProjection key = #MercatorProjection - ifTrue: [ | angle latitudeMaxAngle | - latitudeMaxAngle := 89 * (Float pi / 180). - angle := self getGeoCenter latitudeInRadians. - angle abs > latitudeMaxAngle ifTrue: [ angle := latitudeMaxAngle ]. - ^ aNumberInMeters / angle cos ] - ifFalse: [ ^ aNumberInMeters ] -] - { #category : #'services - layer creation' } -GeoViewManagerImpl >> createAndAddGeoObjectLayer: aKey [ - "add a layer to the geoplot" - - | existingLayer layer | - self deprecated:'use createAndAddLayer:'. - aKey ifNil:[ SmockNoIdError signal: 'Cannot add layer with nil key.'. ^ nil ]. - - existingLayer := self getLayer: aKey. - existingLayer ifNotNil:[ SmockDuplicateIdError signal: 'Cannot add layer with already existing key.'. ^ nil ]. - - layer := self createLayer: aKey. - ^self addLayer: layer -] - -{ #category : #'services - layer creation' } -GeoViewManagerImpl >> createAndAddLayer: aKey [ +GeoViewManagerImpl >> createAndAddGeoObjectsLayer: aKey [ | layer | - layer := self createLayer: aKey. + layer := self createGeoObjectsLayer: aKey. layer ifNil:[ ^ nil ]. self addLayer: layer. ^ layer ] -{ #category : #'layer creation' } -GeoViewManagerImpl >> createLayer: aKey [ +{ #category : #'services - layer creation' } +GeoViewManagerImpl >> createGeoObjectsLayer: aName [ + self subclassResponsibility ] { #category : #initialization } GeoViewManagerImpl >> createView [ - self subclassResponsibility -] - -{ #category : #'private - events' } -GeoViewManagerImpl >> dispatchUIEvent: aSmockEventWrapper [ - "Transfert event in input strategy stack to each behavior processors" - inputContext ifNil: [ ^ self ]. - inputContext handleEvent: aSmockEventWrapper + self subclassResponsibility ] { #category : #private } @@ -201,7 +160,7 @@ GeoViewManagerImpl >> getLayer: aKey [ | layer | layer := self view getLayers - detect: [ :l | l layerName = aKey ] + detect: [ :l | l name = aKey ] ifNone: [ nil ]. ^ layer ] @@ -211,22 +170,10 @@ GeoViewManagerImpl >> getLayers [ ^self view getLayers ] -{ #category : #'component accessing' } -GeoViewManagerImpl >> getMapProjectionManagerServicesProvider [ - | servicesSymbol servicesProvider itf | - - itf := MapProjectionManagerServices. - servicesSymbol := self servicesProviders at: itf ifAbsent: [nil]. - (servicesSymbol isNil or:[servicesSymbol isSymbol not]) ifTrue: [ ^ MolNotFoundServicesProvider new interface: itf name: nil ]. - - servicesProvider := MolComponentManager default locatorServices searchServicesProviderFor: MapProjectionManagerServices named: servicesSymbol. - ^servicesProvider -] - -{ #category : #'parameters - objects' } -GeoViewManagerImpl >> getObjectIndexAccessor [ +{ #category : #'services - map projection' } +GeoViewManagerImpl >> getMapProjection [ - ^ objectIndexAccessor ifNil:[ objectIndexAccessor := #key ] + ^ self view mapProjection ] { #category : #services } @@ -282,34 +229,12 @@ GeoViewManagerImpl >> getView [ ^ self view ] -{ #category : #'private - events' } -GeoViewManagerImpl >> handleUIEvent: anEvent [ - - | wrapper | - wrapper := SmockEventWrapper wrap: anEvent. - self dispatchUIEvent: wrapper. -] - { #category : #'geobjects aur' } GeoViewManagerImpl >> haveObjectIndex: anIndex [ ^ self view haveObjectIndex: anIndex ] -{ #category : #initialization } -GeoViewManagerImpl >> initializeInputContext [ - - inputContext := SmockInputContext new. - inputContext controller: self. -] - -{ #category : #'aggregated components' } -GeoViewManagerImpl >> initializeProjectionManager [ - - MolComponentManager default deploymentServices deployComponentImplementation: MapProjectionManagerImpl. - MolComponentManager default homeServices instantiateComponent: MapProjectionManagerImpl named: self componentName -] - { #category : #'aggregated components' } GeoViewManagerImpl >> initializeSelectionManager [ @@ -332,19 +257,10 @@ GeoViewManagerImpl >> initializeSymbologyManager [ self setSymbologyManagerName: self componentName. ] -{ #category : #initialization } -GeoViewManagerImpl >> initializeView [ - - self setGeoCenter: AbsoluteCoordinates zero. - self minScaleInMeters: 1852.0. - self maxScaleInMeters: 1.5171584e7. - self setScaleInMeters: 1.4816e7. -] - { #category : #'private - events' } -GeoViewManagerImpl >> layerHasBeenUpdated: aLayer [ +GeoViewManagerImpl >> layerHasBeenUpdated: aLayerName [ - self getGeoViewManagerLayerEventsNotifier geoViewLayerUpdated: (aLayer layerName) in: (self componentName). + self getGeoViewManagerLayerEventsNotifier geoViewLayerUpdated: aLayerName in: (self componentName). ] { #category : #accessing } @@ -382,7 +298,7 @@ GeoViewManagerImpl >> mouseCursorCoordinatesChanged: anAbsoluteCoordinates [ { #category : #'aggregated components' } GeoViewManagerImpl >> passivateComponents [ - MapProjectionManagerImpl passivate: self componentName. + "MapProjectionManagerImpl passivate: self componentName. " (MolComponentManager default homeServices instanceOf: SmockSymbologyProvider named: self componentName) ifNotNil:[ SmockSymbologyProvider passivate: self componentName. ]. @@ -393,38 +309,23 @@ GeoViewManagerImpl >> passivateComponents [ { #category : #'services - picking' } GeoViewManagerImpl >> pickAt: aGlobalPoint radius: aRadiusInPixels [ - "Return all geo objects under aPoint with a radius in pixels" + "Return all objects under a global point inside a radius in pixels" - | pickingResult absoluteCoordinates localPoint radius | - absoluteCoordinates := (self getAbsoluteCoordinatesFromGlobalPoint: aGlobalPoint) ifNil:[ ^ nil ]. - localPoint := (self getLocalPointFromGlobalPoint: aGlobalPoint) ifNil:[ ^ nil ]. - radius := aRadiusInPixels ifNil:[ 0 ]. - - "create picking result" - pickingResult := GeoViewPickingResult new - timestamp: DateAndTime now; - globalPoint: aGlobalPoint; - localPoint: localPoint; - cartesianCoordinates: (self getMapProjectionManagerServicesProvider getProjection projLatLonToCart: absoluteCoordinates); - absoluteCoordinates: absoluteCoordinates; - radiusInPixels: radius; - yourself. - - ^ pickingResult + ^ self view pickAt: aGlobalPoint radius: aRadiusInPixels ] { #category : #'services - layer deletion' } GeoViewManagerImpl >> removeAllLayers [ | layers | layers := self view getLayers. - layers do:[ :l | (self view removeLayer: l) ifNotNil:[ self getGeoViewManagerLayerEventsNotifier geoViewLayerRemoved: l layerName in: self componentName ]]. + layers do:[ :l | (self view removeLayer: l) ifNotNil:[ self getGeoViewManagerLayerEventsNotifier geoViewLayerRemoved: l name in: self componentName ]]. ^layers ] { #category : #'aggregated components' } GeoViewManagerImpl >> removeComponents [ - MapProjectionManagerImpl remove: self componentName. + "MapProjectionManagerImpl remove: self componentName." (MolComponentManager default homeServices instanceOf: SmockSymbologyProvider named: self componentName) ifNotNil:[ SmockSymbologyProvider remove: self componentName. ]. @@ -440,6 +341,7 @@ GeoViewManagerImpl >> removeLayer: aKey [ layer := self getLayer: aKey. layer ifNil:[^nil]. layer := self view removeLayer: layer. + self flag:'call this event from GeoView layer removed event'. layer ifNotNil:[self getGeoViewManagerLayerEventsNotifier geoViewLayerRemoved: aKey in: self componentName]. ^layer ] @@ -507,12 +409,18 @@ GeoViewManagerImpl >> setGeoCenter: anAbsoluteCoordinates [ self geoCenter: anAbsoluteCoordinates copy ] -{ #category : #'parameters - objects' } -GeoViewManagerImpl >> setObjectIndexAccessor: aSymbol [ +{ #category : #'services - map projection' } +GeoViewManagerImpl >> setMapProjection: aMapProjection [ - objectIndexAccessor = aSymbol ifTrue:[ ^ self ]. - objectIndexAccessor := aSymbol. - self flag:'labordep : update the model when changed ?'. + | previousProjection | + aMapProjection ifNil:[ ^ self ]. + previousProjection := self view mapProjection. + self view mapProjection: aMapProjection copy. + + self flag:'use GeoViewWidget events to notify these component events'. + (previousProjection class == aMapProjection class) + ifTrue:[ self getGeoViewManagerEventsNotifier mapProjectionUpdated: aMapProjection ] + ifFalse:[ self getGeoViewManagerEventsNotifier mapProjectionHasChanged: aMapProjection ] ] { #category : #services } @@ -583,10 +491,12 @@ GeoViewManagerImpl >> updateObjects: aGeoObjectList [ { #category : #accessing } GeoViewManagerImpl >> view [ + ^ view ] { #category : #accessing } GeoViewManagerImpl >> view: anObject [ + view := anObject ] diff --git a/GeoView/GeoViewManagerLayerEvents.trait.st b/GeoView-Molecule/GeoViewManagerLayerEvents.trait.st similarity index 93% rename from GeoView/GeoViewManagerLayerEvents.trait.st rename to GeoView-Molecule/GeoViewManagerLayerEvents.trait.st index db728fd..ff4ea48 100644 --- a/GeoView/GeoViewManagerLayerEvents.trait.st +++ b/GeoView-Molecule/GeoViewManagerLayerEvents.trait.st @@ -5,7 +5,7 @@ Trait { #name : #GeoViewManagerLayerEvents, #traits : 'MolComponentEvents', #classTraits : 'MolComponentEvents classTrait', - #category : #'GeoView-Core' + #category : #'GeoView-Molecule' } { #category : #events } diff --git a/GeoView/GeoViewManagerLayerServices.trait.st b/GeoView-Molecule/GeoViewManagerLayerServices.trait.st similarity index 67% rename from GeoView/GeoViewManagerLayerServices.trait.st rename to GeoView-Molecule/GeoViewManagerLayerServices.trait.st index c6fe84f..c88992f 100644 --- a/GeoView/GeoViewManagerLayerServices.trait.st +++ b/GeoView-Molecule/GeoViewManagerLayerServices.trait.st @@ -5,7 +5,7 @@ Trait { #name : #GeoViewManagerLayerServices, #traits : 'MolComponentServices', #classTraits : 'MolComponentServices classTrait', - #category : #'GeoView-Core' + #category : #'GeoView-Molecule' } { #category : #'services - layer creation' } @@ -13,17 +13,7 @@ GeoViewManagerLayerServices >> addLayer: aLayer [ ] { #category : #'services - layer creation' } -GeoViewManagerLayerServices >> createAndAddGeoObjectLayer: aKey [ - self deprecated:'use createAndAddLayer:'. -] - -{ #category : #'services - layer creation' } -GeoViewManagerLayerServices >> createAndAddGeoObjectLayer: aKey level: anInteger [ - self deprecated:'use createAndAddLayer: and setLevel:forLayer:'. -] - -{ #category : #'services - layer creation' } -GeoViewManagerLayerServices >> createAndAddLayer: aKey [ +GeoViewManagerLayerServices >> createAndAddGeoObjectsLayer: aKey [ ] { #category : #'services - layer accessing' } diff --git a/GeoView/GeoViewManagerObjectsServices.trait.st b/GeoView-Molecule/GeoViewManagerObjectsServices.trait.st similarity index 96% rename from GeoView/GeoViewManagerObjectsServices.trait.st rename to GeoView-Molecule/GeoViewManagerObjectsServices.trait.st index 89a3f21..8a87dc6 100644 --- a/GeoView/GeoViewManagerObjectsServices.trait.st +++ b/GeoView-Molecule/GeoViewManagerObjectsServices.trait.st @@ -5,7 +5,7 @@ Trait { #name : #GeoViewManagerObjectsServices, #traits : 'MolComponentServices', #classTraits : 'MolComponentServices classTrait', - #category : #'GeoView-Core' + #category : #'GeoView-Molecule' } { #category : #'geobjects aur' } diff --git a/GeoView/GeoViewManagerParameters.trait.st b/GeoView-Molecule/GeoViewManagerParameters.trait.st similarity index 88% rename from GeoView/GeoViewManagerParameters.trait.st rename to GeoView-Molecule/GeoViewManagerParameters.trait.st index 6bba93a..f0a34f9 100644 --- a/GeoView/GeoViewManagerParameters.trait.st +++ b/GeoView-Molecule/GeoViewManagerParameters.trait.st @@ -5,15 +5,19 @@ Trait { #name : #GeoViewManagerParameters, #traits : 'MolComponentParameters', #classTraits : 'MolComponentParameters classTrait', - #category : #'GeoView-Core' + #category : #'GeoView-Molecule' } { #category : #'parameters - objects' } GeoViewManagerParameters >> getObjectIndexAccessor [ + + ^ self getView objectIndexAccessor ] { #category : #'parameters - objects' } GeoViewManagerParameters >> setObjectIndexAccessor: aSymbol [ + + self getView objectIndexAccessor: aSymbol ] { #category : #'parameters - selection manager' } diff --git a/GeoView/GeoViewManagerPickingServices.trait.st b/GeoView-Molecule/GeoViewManagerPickingServices.trait.st similarity index 87% rename from GeoView/GeoViewManagerPickingServices.trait.st rename to GeoView-Molecule/GeoViewManagerPickingServices.trait.st index c1524b1..5b22b71 100644 --- a/GeoView/GeoViewManagerPickingServices.trait.st +++ b/GeoView-Molecule/GeoViewManagerPickingServices.trait.st @@ -2,14 +2,14 @@ Trait { #name : #GeoViewManagerPickingServices, #traits : 'MolComponentServices', #classTraits : 'MolComponentServices classTrait', - #category : #'GeoView-Core' + #category : #'GeoView-Molecule' } { #category : #'services - picking' } GeoViewManagerPickingServices >> pickAt: aGlobalPoint [ "Return all objects under a global point" - ^ self pickAt: aGlobalPoint radius: 0 + ^ self view pickAt: aGlobalPoint ] { #category : #'services - picking' } diff --git a/GeoView/GeoViewManagerServices.trait.st b/GeoView-Molecule/GeoViewManagerServices.trait.st similarity index 74% rename from GeoView/GeoViewManagerServices.trait.st rename to GeoView-Molecule/GeoViewManagerServices.trait.st index 11c5935..222ce88 100644 --- a/GeoView/GeoViewManagerServices.trait.st +++ b/GeoView-Molecule/GeoViewManagerServices.trait.st @@ -5,7 +5,7 @@ Trait { #name : #GeoViewManagerServices, #traits : 'MolComponentServices', #classTraits : 'MolComponentServices classTrait', - #category : #'GeoView-Core' + #category : #'GeoView-Molecule' } { #category : #services } @@ -14,30 +14,48 @@ GeoViewManagerServices >> centerOnPoint: aGlobalPoint [ { #category : #services } GeoViewManagerServices >> getAbsoluteCoordinatesFromGlobalPoint: aGlobalPoint [ + + ^ self getView absoluteCoordinatesFromGlobalPoint: aGlobalPoint ] { #category : #services } GeoViewManagerServices >> getAbsoluteCoordinatesFromLocalPoint: aLocalPoint [ + + ^ self getView absoluteCoordinatesFromLocalPoint: aLocalPoint ] { #category : #services } GeoViewManagerServices >> getGeoCenter [ + + ^ self getView geoCenter ] { #category : #services } GeoViewManagerServices >> getGlobalPointFromAbsoluteCoordinates: anAbsoluteCoordinates [ + + ^ self getView globalPointFromAbsoluteCoordinates: anAbsoluteCoordinates ] { #category : #services } GeoViewManagerServices >> getGlobalPointFromLocalPoint: aLocalPoint [ + + ^ self getView globalPointFromLocalPoint: aLocalPoint ] { #category : #services } GeoViewManagerServices >> getLocalPointFromAbsoluteCoordinates: anAbsoluteCoordinates [ + + ^ self getView localPointFromAbsoluteCoordinates: anAbsoluteCoordinates ] { #category : #services } GeoViewManagerServices >> getLocalPointFromGlobalPoint: aGlobalPoint [ + + ^ self getView localPointFromGlobalPoint: aGlobalPoint +] + +{ #category : #'services - map projection' } +GeoViewManagerServices >> getMapProjection [ ] { #category : #services } @@ -68,6 +86,10 @@ GeoViewManagerServices >> scaleUp [ GeoViewManagerServices >> setGeoCenter: anAbsoluteCoordinates [ ] +{ #category : #'services - map projection' } +GeoViewManagerServices >> setMapProjection: aMapProjection [ +] + { #category : #services } GeoViewManagerServices >> setScaleFactor: aNumber [ ] diff --git a/GeoView-Molecule/package.st b/GeoView-Molecule/package.st new file mode 100644 index 0000000..3ba1019 --- /dev/null +++ b/GeoView-Molecule/package.st @@ -0,0 +1 @@ +Package { #name : #'GeoView-Molecule' } diff --git a/GeoView-Tests/GeoViewGeoObjectsLayerTest.class.st b/GeoView-Tests/GeoViewGeoObjectsLayerTest.class.st new file mode 100644 index 0000000..7c9b7e7 --- /dev/null +++ b/GeoView-Tests/GeoViewGeoObjectsLayerTest.class.st @@ -0,0 +1,16 @@ +" +A GeoViewGeoObjectsLayerTest is a test class for testing the behavior of GeoViewGeoObjectsLayer +" +Class { + #name : #GeoViewGeoObjectsLayerTest, + #superclass : #TestCase, + #category : #'GeoView-Tests-Core' +} + +{ #category : #tests } +GeoViewGeoObjectsLayerTest >> testHaveGeoObjects [ + + | layer | + layer := GeoViewGeoObjectsLayer new. + self assert: layer haveGeoObjects +] diff --git a/GeoView-Tests/GeoViewLayerTest.class.st b/GeoView-Tests/GeoViewLayerTest.class.st new file mode 100644 index 0000000..82d7856 --- /dev/null +++ b/GeoView-Tests/GeoViewLayerTest.class.st @@ -0,0 +1,16 @@ +" +A GeoViewLayerTest is a test class for testing the behavior of GeoViewLayer +" +Class { + #name : #GeoViewLayerTest, + #superclass : #TestCase, + #category : #'GeoView-Tests-Core' +} + +{ #category : #tests } +GeoViewLayerTest >> testHaveGeoObjects [ + + | layer | + layer := GeoViewLayer new. + self deny: layer haveGeoObjects. +] diff --git a/GeoView-Tests/GeoViewManagerTestImpl.class.st b/GeoView-Tests/GeoViewManagerTestImpl.class.st deleted file mode 100644 index 41693eb..0000000 --- a/GeoView-Tests/GeoViewManagerTestImpl.class.st +++ /dev/null @@ -1,17 +0,0 @@ -Class { - #name : #GeoViewManagerTestImpl, - #superclass : #GeoViewManagerImpl, - #category : #'GeoView-Tests-Utils' -} - -{ #category : #'layer creation' } -GeoViewManagerTestImpl >> createLayer: aKey [ - - ^ GeoViewObjectTestLayer new -] - -{ #category : #initialization } -GeoViewManagerTestImpl >> createView [ - - self view: GeoViewTest new -] diff --git a/GeoView-Tests/GeoViewMercatorProjectionTest.class.st b/GeoView-Tests/GeoViewMercatorProjectionTest.class.st index e21c652..93fdc9a 100644 --- a/GeoView-Tests/GeoViewMercatorProjectionTest.class.st +++ b/GeoView-Tests/GeoViewMercatorProjectionTest.class.st @@ -10,7 +10,7 @@ Class { { #category : #'tests-accessing' } GeoViewMercatorProjectionTest >> testReverseProj [ | projection absoluteCoordinates cartesianCoordinates absoluteCoordinatesRes random precision | - projection := MercatorProjection new. + projection := GeoViewMercatorProjection new. random := Random seed: 42. precision := 1e-12. "Precision at 1e-12 degree" diff --git a/GeoView-Tests/GeoViewObjectTestLayer.class.st b/GeoView-Tests/GeoViewObjectTestLayer.class.st index dc1ad45..8dbc87c 100644 --- a/GeoView-Tests/GeoViewObjectTestLayer.class.st +++ b/GeoView-Tests/GeoViewObjectTestLayer.class.st @@ -1,7 +1,5 @@ Class { #name : #GeoViewObjectTestLayer, - #superclass : #GeoViewTestLayer, - #traits : 'TGeoViewLayer', - #classTraits : 'TGeoViewLayer classTrait', + #superclass : #GeoViewGeoObjectsLayer, #category : #'GeoView-Tests-Utils' } diff --git a/GeoView-Tests/GeoViewTestLayer.class.st b/GeoView-Tests/GeoViewTestLayer.class.st index 4cd70c9..300d127 100644 --- a/GeoView-Tests/GeoViewTestLayer.class.st +++ b/GeoView-Tests/GeoViewTestLayer.class.st @@ -1,30 +1,10 @@ Class { #name : #GeoViewTestLayer, - #superclass : #Object, - #traits : 'TGeoViewLayer', - #classTraits : 'TGeoViewLayer classTrait', - #instVars : [ - 'layerName' - ], + #superclass : #GeoViewLayer, #category : #'GeoView-Tests-Utils' } -{ #category : #accessing } -GeoViewTestLayer >> layerName [ - ^layerName -] - -{ #category : #accessing } -GeoViewTestLayer >> layerName: aName [ - layerName := aName -] - -{ #category : #'as yet unclassified' } -GeoViewTestLayer >> projection: aProjection [ - "do nothing" -] - -{ #category : #accessing } +{ #category : #'API -- symbology' } GeoViewTestLayer >> symbologyProvider: aSymbologyProvider [ "do nothing" ] diff --git a/GeoView-Tests/GeoViewTest.class.st b/GeoView-Tests/GeoViewTestWidget.class.st similarity index 60% rename from GeoView-Tests/GeoViewTest.class.st rename to GeoView-Tests/GeoViewTestWidget.class.st index 4235037..048ea0f 100644 --- a/GeoView-Tests/GeoViewTest.class.st +++ b/GeoView-Tests/GeoViewTestWidget.class.st @@ -1,8 +1,8 @@ Class { - #name : #GeoViewTest, + #name : #GeoViewTestWidget, #superclass : #Object, - #traits : 'TGeoView', - #classTraits : 'TGeoView classTrait', + #traits : 'TGeoViewWidget', + #classTraits : 'TGeoViewWidget classTrait', #instVars : [ 'layers' ], @@ -10,37 +10,37 @@ Class { } { #category : #'API -- layers management' } -GeoViewTest >> addLayer: aLayer [ +GeoViewTestWidget >> addLayer: aLayer [ self layers add: aLayer ] { #category : #'as yet unclassified' } -GeoViewTest >> addObjects: aGeoObjectList [ +GeoViewTestWidget >> addObjects: aGeoObjectList [ "do nothing : only for testing" ] { #category : #accessing } -GeoViewTest >> getBounds [ +GeoViewTestWidget >> getBounds [ ^0@0 extent: 0@0 ] { #category : #'API -- layers management' } -GeoViewTest >> getLayers [ +GeoViewTestWidget >> getLayers [ ^self layers ] { #category : #accessing } -GeoViewTest >> layers [ +GeoViewTestWidget >> layers [ ^ layers ifNil: [ layers := OrderedCollection new ] ] { #category : #accessing } -GeoViewTest >> layers: anObject [ +GeoViewTestWidget >> layers: anObject [ layers := anObject ] { #category : #'API -- layers management' } -GeoViewTest >> removeLayer: aLayer [ +GeoViewTestWidget >> removeLayer: aLayer [ self layers remove: aLayer ] diff --git a/GeoView-Tests/GeoViewUTMProjectionTest.class.st b/GeoView-Tests/GeoViewUTMProjectionTest.class.st index ea0b2ad..58c6359 100644 --- a/GeoView-Tests/GeoViewUTMProjectionTest.class.st +++ b/GeoView-Tests/GeoViewUTMProjectionTest.class.st @@ -18,7 +18,7 @@ GeoViewUTMProjectionTest >> testProjLatLonToCart [ e := 723.80393e3. n := 5004.57704e3. - projection := UTMProjection new parallel: 3 degreesToRadians. + projection := GeoViewUTMProjection new parallel: 3 degreesToRadians. cartesianCoordinates := projection projLatLonToCart: absoluteCoordinates. "Precision at centimeter" self assert: (cartesianCoordinates xInMeters closeTo: e precision: 1e-2). diff --git a/GeoView/GeoFontAttributes.class.st b/GeoView/GeoFontAttributes.class.st index c58399e..0eb088b 100644 --- a/GeoView/GeoFontAttributes.class.st +++ b/GeoView/GeoFontAttributes.class.st @@ -4,7 +4,7 @@ Font attributes for configure Text display Class { #name : #GeoFontAttributes, #superclass : #Object, - #category : #'GeoView-Model' + #category : #'GeoView-Core' } { #category : #'font-emphasis' } diff --git a/GeoView/GeoView2DProjection.class.st b/GeoView/GeoView2DProjection.class.st index a2f0bbc..195b973 100644 --- a/GeoView/GeoView2DProjection.class.st +++ b/GeoView/GeoView2DProjection.class.st @@ -5,82 +5,99 @@ This projection use the altitude in meters to determine the resolution in meters Class { #name : #GeoView2DProjection, #superclass : #Object, - #traits : 'GeoViewProjection', - #classTraits : 'GeoViewProjection classTrait', + #traits : 'TGeoViewGraphicProjection', + #classTraits : 'TGeoViewGraphicProjection classTrait', #instVars : [ 'cartesianCenter', 'altitudeInMeters', 'metersByPixel', - 'offsetInPIxels' + 'offsetInPixels' ], - #category : #'GeoView-ViewProjection' + #category : #'GeoView-Projection' } { #category : #accessing } GeoView2DProjection >> altitudeInMeters [ - ^ altitudeInMeters + + ^ altitudeInMeters ifNil: [ altitudeInMeters := 1.4816e7 ] ] { #category : #accessing } GeoView2DProjection >> altitudeInMeters: aNumber [ + altitudeInMeters := aNumber ] { #category : #accessing } GeoView2DProjection >> cartesianCenter [ - ^ cartesianCenter + + ^ cartesianCenter ifNil: [ + cartesianCenter := AbsoluteCoordinates zero ] ] { #category : #accessing } GeoView2DProjection >> cartesianCenter: aCartesianCoordinates [ + cartesianCenter := aCartesianCoordinates ] +{ #category : #accessing } +GeoView2DProjection >> initialize [ + + super initialize. +] + { #category : #accessing } GeoView2DProjection >> key [ - ^#GeoView2DProjection + + ^ #GeoView2DProjection ] { #category : #accessing } GeoView2DProjection >> metersByPixel [ + ^ metersByPixel ] { #category : #accessing } GeoView2DProjection >> metersByPixel: aNumber [ + metersByPixel := aNumber ] { #category : #accessing } -GeoView2DProjection >> offsetInPIxels [ - offsetInPIxels ifNil: [ offsetInPIxels := 0 @ 0 ]. - ^ offsetInPIxels +GeoView2DProjection >> offsetInPixels [ + + ^ offsetInPixels ifNil: [ offsetInPixels := 0 @ 0 ] ] { #category : #accessing } -GeoView2DProjection >> offsetInPIxels: aPoint [ - offsetInPIxels := aPoint +GeoView2DProjection >> offsetInPixels: aPoint [ + + offsetInPixels := aPoint ] { #category : #accessing } GeoView2DProjection >> projCartToPixel: aCartesianCoordinates [ + | point pixel geoCenter | point := aCartesianCoordinates asPoint. geoCenter := self cartesianCenter asPoint. pixel := ((point x @ point y negated) - (geoCenter x @ geoCenter y negated)) * self metersByPixel - + self offsetInPIxels. + + self offsetInPixels. ^ pixel ] { #category : #accessing } GeoView2DProjection >> projPixelToCart: aPoint [ + | point geoCenter | geoCenter := self cartesianCenter asPoint. point := self metersByPixel = 0 - ifTrue:[ (aPoint - self offsetInPIxels) + geoCenter] - ifFalse:[ (aPoint - self offsetInPIxels) / self metersByPixel + geoCenter ]. + ifTrue:[ (aPoint - self offsetInPixels) + geoCenter] + ifFalse:[ (aPoint - self offsetInPixels) / self metersByPixel + geoCenter ]. ^ CartesianCoordinates xInMeters: point x yInMeters: point y ] @@ -88,6 +105,7 @@ GeoView2DProjection >> projPixelToCart: aPoint [ { #category : #accessing } GeoView2DProjection >> updateResolution: aViewSize [ | viewHeight mapHeight | + self assert: [aViewSize isNotNil] description: ['[View2DProjection] View size cannot be nil.']. viewHeight := aViewSize y. mapHeight := 2 * self altitudeInMeters. diff --git a/GeoView/GeoViewEvent.class.st b/GeoView/GeoViewEvent.class.st deleted file mode 100644 index 9f94509..0000000 --- a/GeoView/GeoViewEvent.class.st +++ /dev/null @@ -1,5 +0,0 @@ -Class { - #name : #GeoViewEvent, - #superclass : #Announcement, - #category : #'GeoView-Events' -} diff --git a/GeoView/GeoViewUserToDisplayToGraphicLayer.class.st b/GeoView/GeoViewGeoObjectsLayer.class.st similarity index 62% rename from GeoView/GeoViewUserToDisplayToGraphicLayer.class.st rename to GeoView/GeoViewGeoObjectsLayer.class.st index 0f96e61..9113bb6 100644 --- a/GeoView/GeoViewUserToDisplayToGraphicLayer.class.st +++ b/GeoView/GeoViewGeoObjectsLayer.class.st @@ -1,19 +1,19 @@ Class { - #name : #GeoViewUserToDisplayToGraphicLayer, - #superclass : #Object, - #traits : 'TGeoViewLayer', - #classTraits : 'TGeoViewLayer classTrait', + #name : #GeoViewGeoObjectsLayer, + #superclass : #GeoViewLayer, + #traits : 'TGeoViewHandleProcessDatas + TGeoViewHandleObjects', + #classTraits : 'TGeoViewHandleProcessDatas classTrait + TGeoViewHandleObjects classTrait', #instVars : [ 'graphicModel', 'displayModel', 'sortedDatas', 'graphicalOrderSortBlock' ], - #category : #'GeoView-View' + #category : #'GeoView-Core' } { #category : #'API -- objects management' } -GeoViewUserToDisplayToGraphicLayer >> addObject: anObject [ +GeoViewGeoObjectsLayer >> addObject: anObject [ | dObject | dObject := self displayModel created: anObject. @@ -25,37 +25,37 @@ GeoViewUserToDisplayToGraphicLayer >> addObject: anObject [ ] { #category : #'API -- objects management' } -GeoViewUserToDisplayToGraphicLayer >> addObjects: anObjectList [ +GeoViewGeoObjectsLayer >> addObjects: anObjectList [ anObjectList do: [ :e | self addObject: e ] ] { #category : #accessing } -GeoViewUserToDisplayToGraphicLayer >> displayModel [ +GeoViewGeoObjectsLayer >> displayModel [ ^ displayModel ] { #category : #accessing } -GeoViewUserToDisplayToGraphicLayer >> displayModel: anObject [ +GeoViewGeoObjectsLayer >> displayModel: anObject [ displayModel := anObject ] { #category : #accessing } -GeoViewUserToDisplayToGraphicLayer >> graphicModel [ +GeoViewGeoObjectsLayer >> graphicModel [ ^ graphicModel ] { #category : #accessing } -GeoViewUserToDisplayToGraphicLayer >> graphicModel: anObject [ +GeoViewGeoObjectsLayer >> graphicModel: anObject [ graphicModel := anObject ] { #category : #'API -- drawing' } -GeoViewUserToDisplayToGraphicLayer >> graphicalOrderSortBlock [ +GeoViewGeoObjectsLayer >> graphicalOrderSortBlock [ "Setup a sort block to change the order of graphic element stack" ^ graphicalOrderSortBlock ifNil: [ @@ -65,7 +65,7 @@ GeoViewUserToDisplayToGraphicLayer >> graphicalOrderSortBlock [ ] { #category : #'API -- drawing' } -GeoViewUserToDisplayToGraphicLayer >> graphicalOrderSortBlock: aBlockClosure [ +GeoViewGeoObjectsLayer >> graphicalOrderSortBlock: aBlockClosure [ "Setup a sort block to change the order of graphic element stack" graphicalOrderSortBlock := aBlockClosure. @@ -75,14 +75,20 @@ GeoViewUserToDisplayToGraphicLayer >> graphicalOrderSortBlock: aBlockClosure [ ] ] +{ #category : #testing } +GeoViewGeoObjectsLayer >> haveGeoObjects [ + + ^ true +] + { #category : #'API -- objects management' } -GeoViewUserToDisplayToGraphicLayer >> haveObjectIndex: anIndex [ +GeoViewGeoObjectsLayer >> haveObjectIndex: anIndex [ ^ self displayModel haveDataIndex: anIndex ] { #category : #initialize } -GeoViewUserToDisplayToGraphicLayer >> initialize [ +GeoViewGeoObjectsLayer >> initialize [ super initialize. self initializeUserToDisplayModel. @@ -91,13 +97,13 @@ GeoViewUserToDisplayToGraphicLayer >> initialize [ ] { #category : #initialize } -GeoViewUserToDisplayToGraphicLayer >> initializeDisplayToGraphicModel [ +GeoViewGeoObjectsLayer >> initializeDisplayToGraphicModel [ self graphicModel: GeoViewModel new ] { #category : #initialize } -GeoViewUserToDisplayToGraphicLayer >> initializeSortedDatas [ +GeoViewGeoObjectsLayer >> initializeSortedDatas [ sortedDatas := SortedCollection new: self graphicModel capacity. @@ -106,20 +112,33 @@ GeoViewUserToDisplayToGraphicLayer >> initializeSortedDatas [ ] { #category : #initialize } -GeoViewUserToDisplayToGraphicLayer >> initializeUserToDisplayModel [ +GeoViewGeoObjectsLayer >> initializeUserToDisplayModel [ self displayModel: GeoViewModel new ] +{ #category : #private } +GeoViewGeoObjectsLayer >> processDatasChanged [ + + "Notify internaly that process datas changed" + "self triggerEvent: #processDatasChanged" + + | announcement | + announcement := GeoViewLayerProcessDataChanged new. + announcement layerName: self name. + self announcer announce: announcement +] + { #category : #accessing } -GeoViewUserToDisplayToGraphicLayer >> projection: aMapProjection [ +GeoViewGeoObjectsLayer >> projection: aMapProjection [ "Setup the map projection of the layer: Mercator, etc." + self deprecated: 'not used internaly'. self displayModel projection: aMapProjection ] { #category : #'API -- objects management' } -GeoViewUserToDisplayToGraphicLayer >> removeObject: anObject [ +GeoViewGeoObjectsLayer >> removeObject: anObject [ | dObject | dObject := self displayModel deleted: anObject. @@ -131,20 +150,20 @@ GeoViewUserToDisplayToGraphicLayer >> removeObject: anObject [ ] { #category : #'API -- objects management' } -GeoViewUserToDisplayToGraphicLayer >> removeObjects: anObjectList [ +GeoViewGeoObjectsLayer >> removeObjects: anObjectList [ anObjectList do: [ :e | self removeObject: e ] ] { #category : #'API -- process datas' } -GeoViewUserToDisplayToGraphicLayer >> setDefaultProcessData: aDataProcessor [ +GeoViewGeoObjectsLayer >> setDefaultProcessData: aDataProcessor [ self displayModel defaultProcessData: aDataProcessor. self processDatasChanged ] { #category : #'API -- process datas' } -GeoViewUserToDisplayToGraphicLayer >> setProcessData: aProcessData for: anUserObjectClass [ +GeoViewGeoObjectsLayer >> setProcessData: aProcessData for: anUserObjectClass [ | dModel | dModel := self displayModel. @@ -153,20 +172,20 @@ GeoViewUserToDisplayToGraphicLayer >> setProcessData: aProcessData for: anUserOb ] { #category : #initialize } -GeoViewUserToDisplayToGraphicLayer >> sortDatas [ +GeoViewGeoObjectsLayer >> sortDatas [ sortedDatas removeAll. sortedDatas addAll: self graphicModel getDatas ] -{ #category : #accessing } -GeoViewUserToDisplayToGraphicLayer >> symbologyProvider: aSymbologyProvider [ +{ #category : #'API -- symbology' } +GeoViewGeoObjectsLayer >> symbologyProvider: aSymbologyProvider [ self graphicModel symbologyProvider: aSymbologyProvider ] { #category : #'API -- drawing' } -GeoViewUserToDisplayToGraphicLayer >> updateGraphicModel [ +GeoViewGeoObjectsLayer >> updateGraphicModel [ "Update the graphic model with the Display model" | model | @@ -175,7 +194,7 @@ GeoViewUserToDisplayToGraphicLayer >> updateGraphicModel [ ] { #category : #'API -- objects management' } -GeoViewUserToDisplayToGraphicLayer >> updateObject: anObject [ +GeoViewGeoObjectsLayer >> updateObject: anObject [ | dObject | dObject := self displayModel updated: anObject. @@ -187,13 +206,13 @@ GeoViewUserToDisplayToGraphicLayer >> updateObject: anObject [ ] { #category : #'API -- objects management' } -GeoViewUserToDisplayToGraphicLayer >> updateObjects: anObjectList [ +GeoViewGeoObjectsLayer >> updateObjects: anObjectList [ anObjectList do: [ :e | self updateObject: e ] ] { #category : #private } -GeoViewUserToDisplayToGraphicLayer >> updateState: aStateSymbol withIndexes: aKeyList [ +GeoViewGeoObjectsLayer >> updateState: aStateSymbol withIndexes: aKeyList [ | dModel dObjectList | dModel := self displayModel. diff --git a/GeoView/GeoViewInputStrategy.class.st b/GeoView/GeoViewInputStrategy.class.st index 8912f84..6dc1631 100644 --- a/GeoView/GeoViewInputStrategy.class.st +++ b/GeoView/GeoViewInputStrategy.class.st @@ -1,7 +1,7 @@ Class { #name : #GeoViewInputStrategy, #superclass : #SmockInputStrategy, - #category : #'GeoView-Events' + #category : #'GeoView-Core' } { #category : #testing } @@ -9,3 +9,8 @@ GeoViewInputStrategy class >> isAbstract [ ^ self = GeoViewInputStrategy ] + +{ #category : #deprecation } +GeoViewInputStrategy class >> isDeprecated [ + ^ true +] diff --git a/GeoView/GeoViewLayer.class.st b/GeoView/GeoViewLayer.class.st new file mode 100644 index 0000000..27047c7 --- /dev/null +++ b/GeoView/GeoViewLayer.class.st @@ -0,0 +1,65 @@ +Class { + #name : #GeoViewLayer, + #superclass : #Object, + #instVars : [ + 'isVisible', + 'processDataChangedBlock', + 'name', + 'announcer' + ], + #category : #'GeoView-Core' +} + +{ #category : #testing } +GeoViewLayer class >> isAbstract [ + + ^ self == GeoViewLayer +] + +{ #category : #accessing } +GeoViewLayer >> announcer [ + + ^ announcer ifNil:[ announcer := Announcer new ] +] + +{ #category : #testing } +GeoViewLayer >> haveGeoObjects [ + + ^ false +] + +{ #category : #'API -- drawing' } +GeoViewLayer >> isVisible [ + + ^ isVisible ifNil:[ isVisible := true ] +] + +{ #category : #'API -- drawing' } +GeoViewLayer >> isVisible: aBoolean [ + + isVisible := false +] + +{ #category : #accessing } +GeoViewLayer >> name [ + + ^ name +] + +{ #category : #accessing } +GeoViewLayer >> name: anObject [ + + name := anObject +] + +{ #category : #'API -- symbology' } +GeoViewLayer >> symbologyProvider: aSymbologyProvider [ + + self explicitRequirement +] + +{ #category : #'API -- drawing' } +GeoViewLayer >> updateGraphicModel [ + + self explicitRequirement +] diff --git a/GeoView/GeoViewManagerEvents.trait.st b/GeoView/GeoViewManagerEvents.trait.st deleted file mode 100644 index d43c1b4..0000000 --- a/GeoView/GeoViewManagerEvents.trait.st +++ /dev/null @@ -1,9 +0,0 @@ -" -I am geoplot manager events -" -Trait { - #name : #GeoViewManagerEvents, - #traits : 'MolComponentEvents', - #classTraits : 'MolComponentEvents classTrait', - #category : #'GeoView-Core' -} diff --git a/GeoView/MercatorProjection.class.st b/GeoView/GeoViewMercatorProjection.class.st similarity index 71% rename from GeoView/MercatorProjection.class.st rename to GeoView/GeoViewMercatorProjection.class.st index 1852ad5..c5b9def 100644 --- a/GeoView/MercatorProjection.class.st +++ b/GeoView/GeoViewMercatorProjection.class.st @@ -2,20 +2,20 @@ I am a Mercator projection. It is a cylindrical map projection. " Class { - #name : #MercatorProjection, + #name : #GeoViewMercatorProjection, #superclass : #Object, - #traits : 'MapProjection', - #classTraits : 'MapProjection classTrait', - #category : #'GeoView-MapProjection' + #traits : 'TGeoViewMapProjection', + #classTraits : 'TGeoViewMapProjection classTrait', + #category : #'GeoView-Projection' } { #category : #accessing } -MercatorProjection >> key [ - ^#MercatorProjection +GeoViewMercatorProjection >> key [ + ^#GeoViewMercatorProjection ] { #category : #accessing } -MercatorProjection >> projCartToLatLon: aCartesianCoordinates [ +GeoViewMercatorProjection >> projCartToLatLon: aCartesianCoordinates [ | lat lon | lat := (2 * (aCartesianCoordinates yInMeters / WGS84 semiMinorAxisInMeters) exp arcTan) @@ -29,7 +29,7 @@ MercatorProjection >> projCartToLatLon: aCartesianCoordinates [ ] { #category : #accessing } -MercatorProjection >> projLatLonToCart: anAbsoluteCoordinates [ +GeoViewMercatorProjection >> projLatLonToCart: anAbsoluteCoordinates [ | x y | (anAbsoluteCoordinates isEmpty or:[anAbsoluteCoordinates isValid not]) ifTrue:[^nil]. diff --git a/GeoView/GeoViewModel.class.st b/GeoView/GeoViewModel.class.st index 5766a6d..74dace9 100644 --- a/GeoView/GeoViewModel.class.st +++ b/GeoView/GeoViewModel.class.st @@ -7,7 +7,7 @@ Class { #instVars : [ 'projection' ], - #category : #'GeoView-Model' + #category : #'GeoView-Core' } { #category : #accessing } diff --git a/GeoView/GeoViewPickingElement.class.st b/GeoView/GeoViewPickingElement.class.st index fb78da5..6552b66 100644 --- a/GeoView/GeoViewPickingElement.class.st +++ b/GeoView/GeoViewPickingElement.class.st @@ -4,7 +4,7 @@ Class { #instVars : [ 'geodesicDistanceInM' ], - #category : #'GeoView-Events' + #category : #'GeoView-Core' } { #category : #accessing } diff --git a/GeoView/GeoViewPickingResult.class.st b/GeoView/GeoViewPickingResult.class.st index 71ddc32..19f9dfc 100644 --- a/GeoView/GeoViewPickingResult.class.st +++ b/GeoView/GeoViewPickingResult.class.st @@ -5,7 +5,7 @@ Class { 'cartesianCoordinates', 'absoluteCoordinates' ], - #category : #'GeoView-Events' + #category : #'GeoView-Core' } { #category : #accessing } diff --git a/GeoView/GeoViewProjection.trait.st b/GeoView/GeoViewProjection.trait.st deleted file mode 100644 index 9dbe2f8..0000000 --- a/GeoView/GeoViewProjection.trait.st +++ /dev/null @@ -1,35 +0,0 @@ -" -I am a view Projection, convert cartesian coordinates to graphic device coordinates. -" -Trait { - #name : #GeoViewProjection, - #category : #'GeoView-ViewProjection' -} - -{ #category : #accessing } -GeoViewProjection >> altitudeInMeters [ -] - -{ #category : #accessing } -GeoViewProjection >> altitudeInMeters: aNumber [ -] - -{ #category : #accessing } -GeoViewProjection >> cartesianCenter: aCartesianCoordinates [ -] - -{ #category : #accessing } -GeoViewProjection >> key [ -] - -{ #category : #accessing } -GeoViewProjection >> projCartToPixel: aCartesianCoordinates [ -] - -{ #category : #accessing } -GeoViewProjection >> projPixelToCart: aPoint [ -] - -{ #category : #accessing } -GeoViewProjection >> updateResolution: aViewSize [ -] diff --git a/GeoView/UTMProjection.class.st b/GeoView/GeoViewUTMProjection.class.st similarity index 81% rename from GeoView/UTMProjection.class.st rename to GeoView/GeoViewUTMProjection.class.st index 2d355a2..00c1ac3 100644 --- a/GeoView/UTMProjection.class.st +++ b/GeoView/GeoViewUTMProjection.class.st @@ -2,10 +2,10 @@ I am a transverse Mercator projection. " Class { - #name : #UTMProjection, + #name : #GeoViewUTMProjection, #superclass : #Object, - #traits : 'MapProjection', - #classTraits : 'MapProjection classTrait', + #traits : 'TGeoViewMapProjection', + #classTraits : 'TGeoViewMapProjection classTrait', #instVars : [ 'parallel', 's1', @@ -18,11 +18,11 @@ Class { 'e6', 'k0' ], - #category : #'GeoView-MapProjection' + #category : #'GeoView-Projection' } { #category : #initialization } -UTMProjection >> initialize [ +GeoViewUTMProjection >> initialize [ self parallel: 0. @@ -39,22 +39,22 @@ UTMProjection >> initialize [ ] { #category : #accessing } -UTMProjection >> key [ - ^#UTMProjection +GeoViewUTMProjection >> key [ + ^#GeoViewUTMProjection ] { #category : #accessing } -UTMProjection >> parallel [ +GeoViewUTMProjection >> parallel [ ^ parallel ] { #category : #accessing } -UTMProjection >> parallel: aNumber [ +GeoViewUTMProjection >> parallel: aNumber [ parallel := aNumber ] { #category : #accessing } -UTMProjection >> projCartToLatLon: aCartesianCoordinates [ +GeoViewUTMProjection >> projCartToLatLon: aCartesianCoordinates [ "Spherical formulas" | x y | x := aCartesianCoordinates xInMeters. @@ -70,7 +70,7 @@ UTMProjection >> projCartToLatLon: aCartesianCoordinates [ ] { #category : #accessing } -UTMProjection >> projLatLonToCart: anAbsoluteCoordinates [ +GeoViewUTMProjection >> projLatLonToCart: anAbsoluteCoordinates [ "Spherical formulas" | lat lon v a t c n0 x y s | lat := anAbsoluteCoordinates latitudeInRadians. diff --git a/GeoView/GeoViewUtils.class.st b/GeoView/GeoViewUtils.class.st new file mode 100644 index 0000000..4eb16a7 --- /dev/null +++ b/GeoView/GeoViewUtils.class.st @@ -0,0 +1,23 @@ +Class { + #name : #GeoViewUtils, + #superclass : #Object, + #category : #'GeoView-Core' +} + +{ #category : #'layer creation' } +GeoViewUtils class >> createGeoObjectsLayer: aName [ + "Create a layer to display GeoObjects" + + | layer | + layer := GeoViewGeoObjectsLayer new name: aName. + + layer setProcessData: GeoCircleProcessData new for: GeoCircle. + layer setProcessData: GeoEllipseProcessData new for: GeoEllipse. + layer setProcessData: GeoPolygonProcessData new for: GeoPolygon. + layer setProcessData: GeoPolylineProcessData new for: GeoPolyline. + layer setProcessData: GeoRectangleProcessData new for: GeoRectangle. + layer setProcessData: GeoArcBandProcessData new for: GeoArcBand. + layer setProcessData: GeoTextProcessData new for: GeoText. + + ^ layer +] diff --git a/GeoView/MapProjection.trait.st b/GeoView/MapProjection.trait.st deleted file mode 100644 index 861120b..0000000 --- a/GeoView/MapProjection.trait.st +++ /dev/null @@ -1,19 +0,0 @@ -" -I am Map Projection, convert absolute coordinates to cartesian coordinates. -" -Trait { - #name : #MapProjection, - #category : #'GeoView-MapProjection' -} - -{ #category : #accessing } -MapProjection >> key [ -] - -{ #category : #accessing } -MapProjection >> projCartToLatLon: aCartesianCoordinates [ -] - -{ #category : #accessing } -MapProjection >> projLatLonToCart: anAbsoluteCoordinates [ -] diff --git a/GeoView/MapProjectionManager.trait.st b/GeoView/MapProjectionManager.trait.st deleted file mode 100644 index 56ce83f..0000000 --- a/GeoView/MapProjectionManager.trait.st +++ /dev/null @@ -1,27 +0,0 @@ -" -I am the ProjectionManager. -" -Trait { - #name : #MapProjectionManager, - #traits : 'MolComponentType', - #classTraits : 'MolComponentType classTrait', - #category : #'GeoView-MapProjection' -} - -{ #category : #'accessing - events' } -MapProjectionManager classSide >> producedComponentEvents [ - - ^{ MapProjectionManagerEvents } -] - -{ #category : #'accessing - parameters' } -MapProjectionManager classSide >> providedComponentParameters [ - - ^{ MapProjectionManagerParameters } -] - -{ #category : #'accessing - services' } -MapProjectionManager classSide >> providedComponentServices [ - - ^{ MapProjectionManagerServices } -] diff --git a/GeoView/MapProjectionManagerEvents.trait.st b/GeoView/MapProjectionManagerEvents.trait.st deleted file mode 100644 index 13f08e5..0000000 --- a/GeoView/MapProjectionManagerEvents.trait.st +++ /dev/null @@ -1,17 +0,0 @@ -" -I am the ProjectionManager Events. -" -Trait { - #name : #MapProjectionManagerEvents, - #traits : 'MolComponentEvents', - #classTraits : 'MolComponentEvents classTrait', - #category : #'GeoView-MapProjection' -} - -{ #category : #projection } -MapProjectionManagerEvents >> projectionHasChanged: aProjection [ -] - -{ #category : #projection } -MapProjectionManagerEvents >> projectionUpdated: aProjection [ -] diff --git a/GeoView/MapProjectionManagerImpl.class.st b/GeoView/MapProjectionManagerImpl.class.st deleted file mode 100644 index e17e48c..0000000 --- a/GeoView/MapProjectionManagerImpl.class.st +++ /dev/null @@ -1,84 +0,0 @@ -" -I am the default ProjectionManager implementation. -" -Class { - #name : #MapProjectionManagerImpl, - #superclass : #MolAbstractComponentImpl, - #traits : 'MapProjectionManager + MapProjectionManagerServices + MapProjectionManagerParameters', - #classTraits : 'MapProjectionManager classTrait + MapProjectionManagerServices classTrait + MapProjectionManagerParameters classTrait', - #instVars : [ - 'projection' - ], - #category : #'GeoView-MapProjection' -} - -{ #category : #'life cycle' } -MapProjectionManagerImpl >> componentActivate [ - - -] - -{ #category : #'life cycle' } -MapProjectionManagerImpl >> componentInitialize [ - self createProjection -] - -{ #category : #'life cycle' } -MapProjectionManagerImpl >> componentPassivate [ - - -] - -{ #category : #'life cycle' } -MapProjectionManagerImpl >> componentRemove [ - -] - -{ #category : #'initalize-release' } -MapProjectionManagerImpl >> createProjection [ - "default projection is Mercator" - - self projection: MercatorProjection new -] - -{ #category : #'component accessing' } -MapProjectionManagerImpl >> getMapProjectionManagerEventsNotifier [ - ^self eventsNotifiers at: MapProjectionManagerEvents ifAbsent: [^MolNotFoundEventsNotifier new interface: MapProjectionManagerEvents name: nil]. -] - -{ #category : #projection } -MapProjectionManagerImpl >> getProjection [ - ^self projection copy -] - -{ #category : #accessing } -MapProjectionManagerImpl >> projection [ - ^ projection -] - -{ #category : #accessing } -MapProjectionManagerImpl >> projection: anObject [ - projection := anObject -] - -{ #category : #projection } -MapProjectionManagerImpl >> setProjection: aProjection [ - self assert: [ aProjection isNotNil ] description: [ '[Geoplot] Projection can not be nil.' ]. - self projection ~= aProjection - ifTrue: [ self projection: aProjection copy. - "self view projection: aProjection." - self getMapProjectionManagerEventsNotifier projectionHasChanged: aProjection ] -] - -{ #category : #projection } -MapProjectionManagerImpl >> updateProjection: aProjection [ - self - assert: [ aProjection isNotNil ] - description: [ '[Geoplot] Projection can not be nil.' ]. - - "if the projection is the same we can update parameters of the projection" - self projection key = aProjection key ifTrue:[ - self projection: aProjection copy. - self getMapProjectionManagerEventsNotifier projectionUpdated: aProjection - ]. -] diff --git a/GeoView/MapProjectionManagerParameters.trait.st b/GeoView/MapProjectionManagerParameters.trait.st deleted file mode 100644 index 3dba8fd..0000000 --- a/GeoView/MapProjectionManagerParameters.trait.st +++ /dev/null @@ -1,9 +0,0 @@ -" -I am the ProjectionManager Parameters. -" -Trait { - #name : #MapProjectionManagerParameters, - #traits : 'MolComponentParameters', - #classTraits : 'MolComponentParameters classTrait', - #category : #'GeoView-MapProjection' -} diff --git a/GeoView/MapProjectionManagerServices.trait.st b/GeoView/MapProjectionManagerServices.trait.st deleted file mode 100644 index cd0bd82..0000000 --- a/GeoView/MapProjectionManagerServices.trait.st +++ /dev/null @@ -1,21 +0,0 @@ -" -I am the ProjectionManager Services. -" -Trait { - #name : #MapProjectionManagerServices, - #traits : 'MolComponentServices', - #classTraits : 'MolComponentServices classTrait', - #category : #'GeoView-MapProjection' -} - -{ #category : #projection } -MapProjectionManagerServices >> getProjection [ -] - -{ #category : #projection } -MapProjectionManagerServices >> setProjection: aProjection [ -] - -{ #category : #projection } -MapProjectionManagerServices >> updateProjection: aProjection [ -] diff --git a/GeoView/TGeoView.trait.st b/GeoView/TGeoView.trait.st deleted file mode 100644 index 280a0de..0000000 --- a/GeoView/TGeoView.trait.st +++ /dev/null @@ -1,52 +0,0 @@ -" -I am trait for geoplot view -" -Trait { - #name : #TGeoView, - #instVars : [ - 'geoViewBounds' - ], - #traits : 'TGeoViewHandleObjects', - #classTraits : 'TGeoViewHandleObjects classTrait', - #category : #'GeoView-View' -} - -{ #category : #'API -- layers management' } -TGeoView >> addLayer: aLayer [ - self explicitRequirement -] - -{ #category : #'API -- size' } -TGeoView >> getBounds [ - self explicitRequirement -] - -{ #category : #'API -- layers management' } -TGeoView >> getLayer: aKey [ - self explicitRequirement -] - -{ #category : #'API -- layers management' } -TGeoView >> getLayers [ - self explicitRequirement -] - -{ #category : #'API -- layers management' } -TGeoView >> removeLayer: aLayer [ - self explicitRequirement -] - -{ #category : #'API -- drawing' } -TGeoView >> requestRepaint [ - self explicitRequirement -] - -{ #category : #'API -- selection' } -TGeoView >> selectedObjectIndexes: aCollection [ - self explicitRequirement -] - -{ #category : #'API -- drawing' } -TGeoView >> updateGraphicModel [ - self explicitRequirement -] diff --git a/GeoView/TGeoViewGraphicProjection.trait.st b/GeoView/TGeoViewGraphicProjection.trait.st new file mode 100644 index 0000000..22f264b --- /dev/null +++ b/GeoView/TGeoViewGraphicProjection.trait.st @@ -0,0 +1,35 @@ +" +I am a view Projection, convert cartesian coordinates to graphic device coordinates. +" +Trait { + #name : #TGeoViewGraphicProjection, + #category : #'GeoView-Projection' +} + +{ #category : #accessing } +TGeoViewGraphicProjection >> altitudeInMeters [ +] + +{ #category : #accessing } +TGeoViewGraphicProjection >> altitudeInMeters: aNumber [ +] + +{ #category : #accessing } +TGeoViewGraphicProjection >> cartesianCenter: aCartesianCoordinates [ +] + +{ #category : #accessing } +TGeoViewGraphicProjection >> key [ +] + +{ #category : #accessing } +TGeoViewGraphicProjection >> projCartToPixel: aCartesianCoordinates [ +] + +{ #category : #accessing } +TGeoViewGraphicProjection >> projPixelToCart: aPoint [ +] + +{ #category : #accessing } +TGeoViewGraphicProjection >> updateResolution: aViewSize [ +] diff --git a/GeoView/TGeoViewHandleObjects.trait.st b/GeoView/TGeoViewHandleObjects.trait.st index 021c7fa..2ac8803 100644 --- a/GeoView/TGeoViewHandleObjects.trait.st +++ b/GeoView/TGeoViewHandleObjects.trait.st @@ -1,39 +1,46 @@ Trait { #name : #TGeoViewHandleObjects, - #category : #'GeoView-View' + #category : #'GeoView-Core' } { #category : #'API -- objects management' } TGeoViewHandleObjects >> addObject: aObject [ + self explicitRequirement ] { #category : #'API -- objects management' } TGeoViewHandleObjects >> addObjects: anObjectList [ + self explicitRequirement ] { #category : #'API -- objects management' } TGeoViewHandleObjects >> haveObjectIndex: anIndex [ + self explicitRequirement ] { #category : #'API -- objects management' } TGeoViewHandleObjects >> removeObject: aObject [ + self explicitRequirement ] { #category : #'API -- objects management' } TGeoViewHandleObjects >> removeObjects: anObjectList [ + self explicitRequirement ] { #category : #'API -- objects management' } TGeoViewHandleObjects >> updateObject: aObject [ + self explicitRequirement ] { #category : #'API -- objects management' } TGeoViewHandleObjects >> updateObjects: anObjectList [ + self explicitRequirement ] diff --git a/GeoView/TGeoViewHandleProcessDatas.trait.st b/GeoView/TGeoViewHandleProcessDatas.trait.st new file mode 100644 index 0000000..78e5ae1 --- /dev/null +++ b/GeoView/TGeoViewHandleProcessDatas.trait.st @@ -0,0 +1,34 @@ +Trait { + #name : #TGeoViewHandleProcessDatas, + #category : #'GeoView-Core' +} + +{ #category : #'API -- process datas' } +TGeoViewHandleProcessDatas >> getAllProcessData [ + + self explicitRequirement +] + +{ #category : #'API -- process datas' } +TGeoViewHandleProcessDatas >> getProcessDataFor: aGeoObjectClass [ + + self explicitRequirement +] + +{ #category : #'API -- process datas' } +TGeoViewHandleProcessDatas >> removeProcessDataFor: aGeoObjectClass [ + + self explicitRequirement +] + +{ #category : #'API -- process datas' } +TGeoViewHandleProcessDatas >> setDefaultProcessData: aDataProcessor [ + + self explicitRequirement +] + +{ #category : #'API -- process datas' } +TGeoViewHandleProcessDatas >> setProcessData: aProcessData for: aGeoObjectClass [ + + self explicitRequirement +] diff --git a/GeoView/TGeoViewLayer.trait.st b/GeoView/TGeoViewLayer.trait.st deleted file mode 100644 index 819dc00..0000000 --- a/GeoView/TGeoViewLayer.trait.st +++ /dev/null @@ -1,91 +0,0 @@ -" -I am Geoplot layer. -" -Trait { - #name : #TGeoViewLayer, - #instVars : [ - 'isVisible', - 'layerName', - 'processDataChangedBlock' - ], - #traits : 'TGeoViewHandleObjects', - #classTraits : 'TGeoViewHandleObjects classTrait', - #category : #'GeoView-View' -} - -{ #category : #'API -- process datas' } -TGeoViewLayer >> getAllProcessData [ - self explicitRequirement -] - -{ #category : #'API -- process datas' } -TGeoViewLayer >> getProcessDataFor: aGeoObjectClass [ - self explicitRequirement -] - -{ #category : #'API -- drawing' } -TGeoViewLayer >> isVisible [ - - ^ isVisible ifNil:[ isVisible := true ] -] - -{ #category : #'API -- drawing' } -TGeoViewLayer >> isVisible: aBoolean [ - - isVisible := false -] - -{ #category : #accessing } -TGeoViewLayer >> layerName [ - - ^ layerName -] - -{ #category : #accessing } -TGeoViewLayer >> layerName: anObject [ - - layerName := anObject -] - -{ #category : #private } -TGeoViewLayer >> processDatasChanged [ - - processDataChangedBlock ifNotNil:[ :e | e value: self ] -] - -{ #category : #accessing } -TGeoViewLayer >> projection: aProjection [ - self explicitRequirement -] - -{ #category : #'API -- process datas' } -TGeoViewLayer >> removeProcessDataFor: aGeoObjectClass [ - self explicitRequirement -] - -{ #category : #'API -- process datas' } -TGeoViewLayer >> setDefaultProcessData: aDataProcessor [ - self explicitRequirement -] - -{ #category : #'API -- process datas' } -TGeoViewLayer >> setProcessData: aProcessData for: aGeoObjectClass [ - self explicitRequirement - -] - -{ #category : #accessing } -TGeoViewLayer >> symbologyProvider: aSymbologyProvider [ - self explicitRequirement -] - -{ #category : #'API -- drawing' } -TGeoViewLayer >> updateGraphicModel [ - self explicitRequirement -] - -{ #category : #'API -- process datas' } -TGeoViewLayer >> whenProcessDatasChangedDo: aBlock [ - - processDataChangedBlock := aBlock -] diff --git a/GeoView/TGeoViewMapProjection.trait.st b/GeoView/TGeoViewMapProjection.trait.st new file mode 100644 index 0000000..26ed3fe --- /dev/null +++ b/GeoView/TGeoViewMapProjection.trait.st @@ -0,0 +1,19 @@ +" +I am Map Projection, convert absolute coordinates to cartesian coordinates. +" +Trait { + #name : #TGeoViewMapProjection, + #category : #'GeoView-Projection' +} + +{ #category : #accessing } +TGeoViewMapProjection >> key [ +] + +{ #category : #accessing } +TGeoViewMapProjection >> projCartToLatLon: aCartesianCoordinates [ +] + +{ #category : #accessing } +TGeoViewMapProjection >> projLatLonToCart: anAbsoluteCoordinates [ +] diff --git a/GeoView/TGeoViewWidget.trait.st b/GeoView/TGeoViewWidget.trait.st new file mode 100644 index 0000000..17de8f3 --- /dev/null +++ b/GeoView/TGeoViewWidget.trait.st @@ -0,0 +1,239 @@ +" +I am trait for geoplot view +" +Trait { + #name : #TGeoViewWidget, + #instVars : [ + 'geoCenter', + 'scaleFactor', + 'maxScaleInMeters', + 'minScaleInMeters', + 'scaleInMeters', + 'objectIndexAccessor' + ], + #traits : 'TGeoViewHandleObjects', + #classTraits : 'TGeoViewHandleObjects classTrait', + #category : #'GeoView-Core' +} + +{ #category : #'API -- coordinates transformations' } +TGeoViewWidget >> absoluteCoordinatesFromGlobalPoint: aGlobalPoint [ + + | localPoint | + localPoint := self localPointFromGlobalPoint: aGlobalPoint. + ^ self absoluteCoordinatesFromLocalPoint: localPoint +] + +{ #category : #'API -- coordinates transformations' } +TGeoViewWidget >> absoluteCoordinatesFromLocalPoint: aLocalPoint [ + + self explicitRequirement +] + +{ #category : #'API -- layers management' } +TGeoViewWidget >> addLayer: aLayer [ + self explicitRequirement +] + +{ #category : #'API -- scale and center' } +TGeoViewWidget >> centerOnGlobalPoint: aGlobalPoint [ + "Center the map on a global point" + | absoluteCoordinates | + absoluteCoordinates := self absoluteCoordinatesFromGlobalPoint: aGlobalPoint. + self geoCenter: absoluteCoordinates. +] + +{ #category : #private } +TGeoViewWidget >> evaluateScale: aNumberInMeters [ + + aNumberInMeters < self minScaleInMeters ifTrue: [ ^ self minScaleInMeters ]. + aNumberInMeters > self maxScaleInMeters ifTrue: [ ^ self maxScaleInMeters ]. + ^ aNumberInMeters +] + +{ #category : #'API -- scale and center' } +TGeoViewWidget >> geoCenter [ + + geoCenter ifNil: [ geoCenter := AbsoluteCoordinates zero ]. + ^ geoCenter +] + +{ #category : #'API -- scale and center' } +TGeoViewWidget >> geoCenter: anAbsoluteCoordinates [ + + geoCenter := anAbsoluteCoordinates copy +] + +{ #category : #'API -- layers management' } +TGeoViewWidget >> getLayer: aKey [ + self explicitRequirement +] + +{ #category : #'API -- layers management' } +TGeoViewWidget >> getLayers [ + self explicitRequirement +] + +{ #category : #'API -- coordinates transformations' } +TGeoViewWidget >> globalPointFromAbsoluteCoordinates: anAbsoluteCoordinates [ + + | localPoint | + localPoint := self localPointFromAbsoluteCoordinates: + anAbsoluteCoordinates. + ^ self globalPointFromLocalPoint: localPoint +] + +{ #category : #'API -- coordinates transformations' } +TGeoViewWidget >> globalPointFromLocalPoint: aLocalPoint [ + + self explicitRequirement +] + +{ #category : #'API -- coordinates transformations' } +TGeoViewWidget >> localPointFromAbsoluteCoordinates: anAbsoluteCoordinates [ + + self explicitRequirement +] + +{ #category : #'API -- coordinates transformations' } +TGeoViewWidget >> localPointFromGlobalPoint: aGlobalPoint [ + + self explicitRequirement +] + +{ #category : #'API -- map projection' } +TGeoViewWidget >> mapProjection [ + "Return the map projection of the object: Mercator, etc." + + self explicitRequirement +] + +{ #category : #'API -- map projection' } +TGeoViewWidget >> mapProjection: aMapProjection [ + "Setup the map projection of the object: Mercator, etc." + + self explicitRequirement +] + +{ #category : #'API -- scale and center' } +TGeoViewWidget >> maxScaleInMeters [ + + ^ maxScaleInMeters ifNil: [ maxScaleInMeters := 1.5171584e7 ] +] + +{ #category : #'API -- scale and center' } +TGeoViewWidget >> maxScaleInMeters: anObject [ + + maxScaleInMeters := anObject +] + +{ #category : #'API -- scale and center' } +TGeoViewWidget >> minScaleInMeters [ + + ^ minScaleInMeters ifNil: [ minScaleInMeters := 1852.0 ] +] + +{ #category : #'API -- scale and center' } +TGeoViewWidget >> minScaleInMeters: anObject [ + + minScaleInMeters := anObject +] + +{ #category : #'API -- objects parameters' } +TGeoViewWidget >> objectIndexAccessor [ + + ^ objectIndexAccessor ifNil: [ objectIndexAccessor := #key ] +] + +{ #category : #'API -- objects parameters' } +TGeoViewWidget >> objectIndexAccessor: aSymbol [ + + objectIndexAccessor := aSymbol +] + +{ #category : #'API -- picking' } +TGeoViewWidget >> pickAt: aGlobalPoint [ + "Return all objects under a global point" + + ^ self pickAt: aGlobalPoint radius: 0 +] + +{ #category : #'API -- picking' } +TGeoViewWidget >> pickAt: aGlobalPoint radius: aRadiusInPixels [ + "Return all objects under a global point inside a radius in pixels" + + | pickingResult localPoint absoluteCoordinates radius | + absoluteCoordinates := (self absoluteCoordinatesFromGlobalPoint: aGlobalPoint) ifNil:[ ^ nil ]. + localPoint := (self localPointFromGlobalPoint: aGlobalPoint) ifNil:[ ^ nil ]. + radius := aRadiusInPixels ifNil:[ 0 ]. + + "create picking result" + pickingResult := GeoViewPickingResult new + timestamp: DateAndTime now; + globalPoint: aGlobalPoint; + localPoint: localPoint; + cartesianCoordinates: (self mapProjection projLatLonToCart: absoluteCoordinates); + absoluteCoordinates: absoluteCoordinates; + radiusInPixels: radius; + yourself. + + ^ pickingResult +] + +{ #category : #'API -- layers management' } +TGeoViewWidget >> removeLayer: aLayer [ + self explicitRequirement +] + +{ #category : #'API -- drawing' } +TGeoViewWidget >> requestRepaint [ + self explicitRequirement +] + +{ #category : #'API -- scale and center' } +TGeoViewWidget >> scaleDown [ + + self scaleInMeters: self scaleInMeters * self scaleFactor +] + +{ #category : #'API -- scale and center' } +TGeoViewWidget >> scaleFactor [ + + ^ scaleFactor ifNil: [ scaleFactor := 2 ] +] + +{ #category : #'API -- scale and center' } +TGeoViewWidget >> scaleFactor: aNumber [ + + scaleFactor := aNumber +] + +{ #category : #'API -- scale and center' } +TGeoViewWidget >> scaleInMeters [ + + ^ scaleInMeters ifNil: [ scaleInMeters := 1.4816e7 ] +] + +{ #category : #'API -- scale and center' } +TGeoViewWidget >> scaleInMeters: aNumber [ + + | scale | + scale := self evaluateScale: aNumber. + scaleInMeters := scale +] + +{ #category : #'API -- scale and center' } +TGeoViewWidget >> scaleUp [ + + self scaleInMeters: self scaleInMeters / self scaleFactor +] + +{ #category : #'API -- selection' } +TGeoViewWidget >> selectedObjectIndexes: aCollection [ + self explicitRequirement +] + +{ #category : #'API -- drawing' } +TGeoViewWidget >> updateGraphicModel [ + self explicitRequirement +]