2
This is the domain object for DrGeo, aka the top level Model instance for one DrGeo instance
12
#category : #'DrGeoII-Core-App'
15
{ #category : #event }
16
DrGeoDomain >> actionMap [
17
actionMap ifNil: [^self createActionMap].
21
{ #category : #'user interface' }
22
DrGeoDomain >> addModelItemsToWindowMenu: aMenu [
25
add: 'About Dr. Geo...'
28
argument: DrGeo drgeoCopyright
31
{ #category : #building }
32
DrGeoDomain >> createCompositeItem: aMathItemSelection [
33
cmdManager compositeCommandFor: aMathItemSelection.
36
{ #category : #building }
37
DrGeoDomain >> createFromMathItem: aMathItem [
38
"return the mathItem (newly created or the one in the pool,
39
in case the caller want to do something with it"
40
(factory pushAsLastWhenInPool: aMathItem) ifTrue:
41
[^{factory last. false}].
42
"create a new command and execute it"
43
cmdManager buildCommandFor: aMathItem.
47
{ #category : #building }
48
DrGeoDomain >> createFromMathItemNoStack: aMathItem [
49
"return the mathItem (newly created or the one in the pool,
50
in case the caller want to do something with it, without stacking in the undo/redo stack"
51
(factory pushAsLastWhenInPool: aMathItem) ifTrue: [^factory last].
52
factory add: aMathItem.
53
self triggerEvent: #newMathItem with: aMathItem.
57
{ #category : #building }
58
DrGeoDomain >> createFromMathItemNoStackNoFactoryCheck: aMathItem [
59
"return the mathItem. we do not check in the facory pool, without stacking in the undo/redo stack"
60
factory add: aMathItem.
61
self triggerEvent: #newMathItem with: aMathItem.
65
{ #category : #building }
66
DrGeoDomain >> createMacro: aBuilder [
67
(DrGMacroFactory new pushAsLastWhenInPool: (aBuilder getItem: self)) ifFalse:
68
[ "Create macro and register it in the factory"
69
DrGMacroFactory new add: (aBuilder getItem: self) ]
72
{ #category : #building }
73
DrGeoDomain >> createMathItem: aBuilder [
74
"return the mathItem (newly created or the one in the pool,
75
in case the caller want to do something with it"
76
(factory pushAsLastWhenInPool: aBuilder getItem first) ifTrue:
77
[ ^ { (factory last). false } ].
78
"create a new command and execute it"
79
^ { (cmdManager buildCommandWith: aBuilder). true }
82
{ #category : #building }
83
DrGeoDomain >> deleteMathItem: aMathItem [
84
"create a delete command and execute it"
85
cmdManager deleteCommandFor: aMathItem
88
{ #category : #accessing }
89
DrGeoDomain >> factory [
93
{ #category : #building }
94
DrGeoDomain >> in: macroTree replaceParent: item with: newItem [
96
macroTree do: [ :anItem |
97
(anItem parents notNil and: [ (index := anItem parents indexOf: item) ~= 0 ])
98
ifTrue: [anItem parents at: index put: newItem ] ]
101
{ #category : #'initialize-release' }
102
DrGeoDomain >> initialize [
104
factory := DrGMathItemFactory new.
105
cmdManager := DrGCommandManager new domain: self
108
{ #category : #accessing }
109
DrGeoDomain >> labelString [
110
^ 'Dr. Geo -- ', Date today asString
113
{ #category : #building }
114
DrGeoDomain >> merge: aMathItem with: aTarget [
115
"create a merge command"
116
cmdManager mergeCommandFor: aMathItem with: aTarget
119
{ #category : #updating }
120
DrGeoDomain >> moveEvent: aMathItem at: aPoint [
121
aMathItem moveAt: aPoint.
122
self updateAllMathItems
125
{ #category : #updating }
126
DrGeoDomain >> moveEvent: aMathItem at: aPoint withDirty: mathItems [
127
aMathItem moveAt: aPoint.
128
self updateDirty: mathItems
131
{ #category : #updating }
132
DrGeoDomain >> moveEvent: aMathItem inDirection: aPoint [
133
aMathItem moveEvent: aPoint.
134
self updateAllMathItems
137
{ #category : #updating }
138
DrGeoDomain >> moveEvent: aMathItem inDirection: aPoint withDirty: mathItems [
139
aMathItem moveEvent: aPoint.
140
self updateDirty: mathItems
143
{ #category : #building }
144
DrGeoDomain >> moveMathItem: aMathItem with: aPoint [
145
"create a move command"
146
cmdManager moveCommandFor: aMathItem with: aPoint
149
{ #category : #updating }
150
DrGeoDomain >> mutate: aPointItem asFreeOn: aCurveItem at: aPosition [
152
item := DrGPointOncurveItem newWith: {aCurveItem . aPosition}.
153
item name: aPointItem name.
154
item actionMap: aPointItem actionMap.
155
aPointItem become: item.
156
self updateAllMathItems
159
{ #category : #updating }
160
DrGeoDomain >> mutate: aPointItem asIntersectionWith: curveA and: curveB at: aPosition [
162
item := DrGPointIntersectionItem newWith: {curveA. curveB. aPosition}.
163
item name: aPointItem name.
164
item actionMap: aPointItem actionMap.
165
aPointItem become: item.
166
self updateAllMathItems.
169
{ #category : #updating }
170
DrGeoDomain >> mutateAsFreePoint: aPointItem [
172
(aPointItem isFreePointItem and: [aPointItem isPointItemOnCurve not]) ifTrue: [^aPointItem].
173
freePointItem := DrGPointFreeItem new point: aPointItem point.
174
freePointItem name: aPointItem name.
175
freePointItem actionMap: aPointItem actionMap.
176
aPointItem become: freePointItem.
180
{ #category : #building }
181
DrGeoDomain >> playMacro: aBuilder in: app [
183
macroTree := aBuilder getItem.
185
with: aBuilder constructedNodes
188
answer := self createFromMathItem: item.
191
[ node isHiddenNode ifTrue:
192
[ (app costumeOf: item) ifNotNil:
194
aCostume style hidden: true.
195
aCostume forceVisible: false ] ] ]
197
[ "item twin in the factory, use it in the macro tree"
201
with: answer first ] ]
204
{ #category : #building }
205
DrGeoDomain >> propertyCommandFor: aMathItem with: aProperty [
206
"create a move command"
207
cmdManager propertyCommandFor: aMathItem with: aProperty
210
{ #category : #accessing }
211
DrGeoDomain >> redo [
215
{ #category : #'initialize-release' }
216
DrGeoDomain >> release [
222
{ #category : #event }
223
DrGeoDomain >> releaseActionMap [
227
{ #category : #accessing }
228
DrGeoDomain >> undo [
232
{ #category : #updating }
233
DrGeoDomain >> update: object [
234
(object class == MethodModified and: [object methodClass superclass = DrGeoUserScript])
235
ifTrue: [self updateAllMathItems]
238
{ #category : #updating }
239
DrGeoDomain >> updateAllMathItems [
240
factory updateAllMathItems.
241
self triggerEvent: #updatedItems
244
{ #category : #updating }
245
DrGeoDomain >> updateAllMathItemsButLocus [
246
factory updateAllMathItemsButLocus.
247
"We don't need to update the costumem we just want updated mathiteem'"
248
"self triggerEvent: #updatedItems"
251
{ #category : #updating }
252
DrGeoDomain >> updateDirty: mathItems [
253
mathItems do: [:item | item update].
254
self triggerEvent: #updatedDirtyItems
257
{ #category : #event }
258
DrGeoDomain >> updateableActionMap [
260
[actionMap := self createActionMap].