3150
|
1 |
"{ Package: 'stx:libwidg2' }"
|
|
2 |
|
4852
|
3 |
"{ NameSpace: Smalltalk }"
|
|
4 |
|
741
|
5 |
GraphColumnView subclass:#GraphColumnView3D
|
|
6 |
instanceVariableNames:'glxView showGraph rotateX rotateY rotateZ rotateXHolder
|
754
|
7 |
rotateYHolder rotateZHolder zoomZ zoomZHolder showAxis'
|
741
|
8 |
classVariableNames:''
|
|
9 |
poolDictionaries:''
|
|
10 |
category:'Views-Graphs'
|
|
11 |
!
|
|
12 |
|
|
13 |
GLXView subclass:#GLXGraph
|
815
|
14 |
instanceVariableNames:'graph colorMap maxY minY loVCols loVRefs yValues glxObjFunc
|
|
15 |
glxObjRefs glxObjGrid glxObjAxis removeFunc removeRefs removeGrid
|
|
16 |
removeAxis isInvalid lockCriticalTask criticalTask'
|
741
|
17 |
classVariableNames:''
|
|
18 |
poolDictionaries:''
|
|
19 |
privateIn:GraphColumnView3D
|
|
20 |
!
|
|
21 |
|
752
|
22 |
!GraphColumnView3D class methodsFor:'documentation'!
|
|
23 |
|
|
24 |
documentation
|
|
25 |
"
|
|
26 |
The class provides all the functionality for showing, scrolling and manipulating graphs
|
|
27 |
described through to a GraphColumn description. Each change in a graph description
|
|
28 |
immediately take affect.
|
|
29 |
|
|
30 |
|
|
31 |
[See also:]
|
3150
|
32 |
GraphColumn
|
|
33 |
GraphColumnView
|
|
34 |
GraphColumnView2D
|
752
|
35 |
|
|
36 |
[Author:]
|
3150
|
37 |
Claus Atzkern
|
752
|
38 |
"
|
|
39 |
|
|
40 |
! !
|
741
|
41 |
|
|
42 |
!GraphColumnView3D class methodsFor:'menu'!
|
|
43 |
|
|
44 |
defaultMenu
|
|
45 |
"this window spec was automatically generated by the ST/X MenuEditor"
|
|
46 |
|
|
47 |
"do not manually edit this - the builder may not be able to
|
|
48 |
handle the specification if its corrupted."
|
|
49 |
|
|
50 |
"
|
754
|
51 |
MenuEditor new openOnClass:GraphColumnView3D andSelector:#defaultMenu
|
|
52 |
(Menu new fromLiteralArrayEncoding:(GraphColumnView3D defaultMenu)) startUp
|
741
|
53 |
"
|
|
54 |
|
|
55 |
<resource: #menu>
|
|
56 |
|
|
57 |
^
|
3150
|
58 |
|
741
|
59 |
#(#Menu
|
3150
|
60 |
|
|
61 |
#(
|
|
62 |
#(#MenuItem
|
|
63 |
#'label:' 'Show Columns'
|
|
64 |
#'indication:' #'showGraph:'
|
|
65 |
)
|
|
66 |
#(#MenuItem
|
|
67 |
#'label:' 'Show Grid'
|
|
68 |
#'indication:' #'showGrid:'
|
|
69 |
)
|
|
70 |
#(#MenuItem
|
|
71 |
#'label:' 'Show Axis'
|
|
72 |
#'indication:' #'showAxis:'
|
|
73 |
)
|
|
74 |
#(#MenuItem
|
|
75 |
#'label:' 'Show References'
|
|
76 |
#'indication:' #'showReferences:'
|
|
77 |
)
|
|
78 |
#(#MenuItem
|
|
79 |
#'label:' '-'
|
|
80 |
)
|
|
81 |
#(#MenuItem
|
|
82 |
#'label:' 'Zoom Y'
|
|
83 |
#'submenuChannel:' #subMenuZoomY
|
|
84 |
)
|
|
85 |
) nil
|
|
86 |
nil
|
741
|
87 |
)
|
|
88 |
! !
|
|
89 |
|
|
90 |
!GraphColumnView3D class methodsFor:'test'!
|
|
91 |
|
|
92 |
test
|
|
93 |
"
|
|
94 |
self test
|
|
95 |
"
|
|
96 |
|top list view x|
|
|
97 |
|
|
98 |
top := StandardSystemView extent:800 @ 400.
|
|
99 |
view := GraphColumnView3D origin:0@0 extent:1.0@1.0 in:top.
|
|
100 |
list := OrderedCollection new.
|
|
101 |
|
802
|
102 |
top label:'3D-View'.
|
|
103 |
|
3150
|
104 |
#( red green yellow blue
|
802
|
105 |
) keysAndValuesDo:[:idx :aColor|
|
3150
|
106 |
|col|
|
802
|
107 |
|
3150
|
108 |
col := GraphColumn name:idx.
|
|
109 |
col foregroundColor:(Color perform:aColor).
|
802
|
110 |
|
3150
|
111 |
col functionYblock:[:start :anArray|
|
|
112 |
x := (start - 1) * 0.2.
|
|
113 |
(idx == 1 or:[idx == 3]) ifTrue:[
|
|
114 |
1 to:(anArray size) do:[:i| anArray at:i put:20 * (x sin). x := x + 0.2 ].
|
|
115 |
] ifFalse:[
|
|
116 |
1 to:(anArray size) do:[:i| anArray at:i put:20 * (x cos). x := x + 0.2 ].
|
|
117 |
].
|
|
118 |
anArray
|
|
119 |
].
|
|
120 |
list add:col
|
802
|
121 |
].
|
|
122 |
view showGrid:true.
|
|
123 |
view columns:list.
|
|
124 |
view showDefaultMenu:true.
|
|
125 |
top openAndWait.
|
|
126 |
|
803
|
127 |
[ |o i t c|
|
802
|
128 |
|
3150
|
129 |
i := 0.
|
|
130 |
t := 0.
|
|
131 |
c := 0.
|
802
|
132 |
|
3150
|
133 |
[top realized] whileTrue:[
|
|
134 |
t := t + (Time millisecondsToRun:[ view rotateY:i]).
|
|
135 |
i := i + 1.
|
|
136 |
c := c + 1.
|
|
137 |
c == 90 ifTrue:[
|
|
138 |
Transcript showCR:'Time: ', t printString.
|
|
139 |
t := 0.
|
|
140 |
c := 0.
|
|
141 |
].
|
|
142 |
Delay waitForSeconds:0.05.
|
|
143 |
]
|
802
|
144 |
|
803
|
145 |
] forkAt:8.
|
802
|
146 |
|
|
147 |
|
|
148 |
|
|
149 |
|
|
150 |
|
815
|
151 |
!
|
|
152 |
|
|
153 |
testRun
|
|
154 |
"running view
|
|
155 |
|
|
156 |
start with:
|
3150
|
157 |
self testRunX
|
815
|
158 |
"
|
|
159 |
|top list view step x offs time cbox halt xOrigin|
|
|
160 |
|
|
161 |
halt := false.
|
|
162 |
top := StandardSystemView extent:800 @ 400.
|
|
163 |
view := GraphColumnView3D origin:0@20 extent:1.0@1.0 in:top.
|
|
164 |
cbox := CheckBox origin:0@0.0 corner:50@20 in:top.
|
|
165 |
cbox label:'Stop'.
|
|
166 |
cbox action:[:v| halt := v].
|
|
167 |
xOrigin := 1 asValue.
|
|
168 |
|
|
169 |
offs := 0.
|
|
170 |
step := 2.
|
|
171 |
list := OrderedCollection new.
|
|
172 |
|
|
173 |
top label:'Testing 3D-View: Performance Test'.
|
|
174 |
|
|
175 |
#( 0.25 0.5 0.75 ) do:[:xAxis||aCol|
|
3150
|
176 |
aCol := GraphColumn new.
|
|
177 |
aCol relativeXaxis:xAxis.
|
|
178 |
xAxis ~= 0.5 ifTrue:[
|
|
179 |
xAxis < 0.5 ifTrue:[aCol foregroundColor:(Color red)]
|
|
180 |
ifFalse:[aCol foregroundColor:(Color blue)]
|
|
181 |
].
|
|
182 |
aCol hLineStyle:#dashed.
|
|
183 |
aCol hLineList:#( 0 ).
|
|
184 |
aCol scaleY:40.
|
815
|
185 |
|
3150
|
186 |
aCol functionYblock:[:start :array|
|
|
187 |
x := start * 0.2.
|
|
188 |
1 to:(array size) do:[:i| array at:i put:10 * (x sin). x := x + 0.2 ].
|
|
189 |
array
|
|
190 |
].
|
|
191 |
list add:aCol.
|
815
|
192 |
].
|
|
193 |
view windowSize:100.
|
|
194 |
view showGrid:true.
|
|
195 |
view columns:list.
|
|
196 |
view scrollUpdatesOriginX:true.
|
|
197 |
view graphOriginXHolder:xOrigin.
|
|
198 |
|
|
199 |
top openAndWait.
|
|
200 |
|
|
201 |
[ [top realized] whileTrue:[
|
3150
|
202 |
halt ifFalse:[
|
|
203 |
xOrigin value:(xOrigin value + step).
|
|
204 |
].
|
|
205 |
Delay waitForSeconds:0.05.
|
|
206 |
]
|
815
|
207 |
|
|
208 |
] forkAt:8.
|
|
209 |
|
741
|
210 |
! !
|
|
211 |
|
|
212 |
!GraphColumnView3D methodsFor:'accessing look'!
|
|
213 |
|
754
|
214 |
showAxis
|
|
215 |
"show or hide the x/y/z axis
|
|
216 |
"
|
|
217 |
^ showAxis
|
|
218 |
!
|
|
219 |
|
|
220 |
showAxis:aBool
|
|
221 |
"show or hide the x/y/z axis
|
|
222 |
"
|
|
223 |
showAxis ~~ aBool ifTrue:[
|
3150
|
224 |
showAxis := aBool.
|
|
225 |
glxView invalidate.
|
754
|
226 |
].
|
|
227 |
!
|
|
228 |
|
741
|
229 |
showGraph
|
|
230 |
"show or hide columns; if the grid is enabled, only the grid will be
|
|
231 |
shown
|
|
232 |
"
|
|
233 |
^ showGraph
|
|
234 |
!
|
|
235 |
|
|
236 |
showGraph:aBool
|
|
237 |
"show or hide columns; if the grid is enabled, only the grid will be
|
|
238 |
shown
|
|
239 |
"
|
|
240 |
showGraph ~~ aBool ifTrue:[
|
3150
|
241 |
showGraph := aBool.
|
|
242 |
glxView invalidate.
|
741
|
243 |
].
|
|
244 |
!
|
|
245 |
|
|
246 |
zoomZ
|
752
|
247 |
"returns the current zoom Z factor
|
741
|
248 |
"
|
|
249 |
^ zoomZ
|
|
250 |
!
|
|
251 |
|
|
252 |
zoomZ:aValue
|
752
|
253 |
"set the zoom Z factor; if the argument is nil or not valid, the
|
|
254 |
default zoom Z factor is set (1).
|
741
|
255 |
"
|
|
256 |
|zZ|
|
|
257 |
|
|
258 |
(zZ := self floatFrom:aValue onError:[1]) <= 0 ifTrue:[
|
3150
|
259 |
zZ := 1
|
741
|
260 |
].
|
|
261 |
|
|
262 |
zZ = zoomZ ifFalse:[
|
3150
|
263 |
zoomZ := zZ.
|
|
264 |
glxView invalidate.
|
741
|
265 |
]
|
|
266 |
! !
|
|
267 |
|
|
268 |
!GraphColumnView3D methodsFor:'accessing mvc'!
|
|
269 |
|
|
270 |
rotateXHolder
|
752
|
271 |
"returns the valueHolder, which holds the rotation X value
|
741
|
272 |
"
|
|
273 |
^ rotateXHolder
|
|
274 |
|
|
275 |
!
|
|
276 |
|
|
277 |
rotateXHolder:aHolder
|
752
|
278 |
"set the valueHolder, which holds the rotation X value
|
741
|
279 |
"
|
|
280 |
rotateXHolder == aHolder ifFalse:[
|
3150
|
281 |
rotateXHolder notNil ifTrue:[
|
|
282 |
rotateXHolder removeDependent:self
|
|
283 |
].
|
|
284 |
(rotateXHolder := aHolder) notNil ifTrue:[
|
|
285 |
rotateXHolder addDependent:self
|
|
286 |
]
|
741
|
287 |
].
|
|
288 |
self rotateX:(rotateXHolder value)
|
|
289 |
!
|
|
290 |
|
|
291 |
rotateYHolder
|
752
|
292 |
"returns the valueHolder, which holds the rotation Y value
|
741
|
293 |
"
|
|
294 |
^ rotateYHolder
|
|
295 |
|
|
296 |
!
|
|
297 |
|
|
298 |
rotateYHolder:aHolder
|
752
|
299 |
"set the valueHolder, which holds the rotation Y value
|
741
|
300 |
"
|
|
301 |
rotateYHolder == aHolder ifFalse:[
|
3150
|
302 |
rotateYHolder notNil ifTrue:[
|
|
303 |
rotateYHolder removeDependent:self
|
|
304 |
].
|
|
305 |
(rotateYHolder := aHolder) notNil ifTrue:[
|
|
306 |
rotateYHolder addDependent:self
|
|
307 |
]
|
741
|
308 |
].
|
|
309 |
self rotateY:(rotateYHolder value)
|
|
310 |
|
|
311 |
!
|
|
312 |
|
|
313 |
rotateZHolder
|
752
|
314 |
"returns the valueHolder, which holds the rotation Z value
|
741
|
315 |
"
|
|
316 |
^ rotateZHolder
|
|
317 |
|
|
318 |
!
|
|
319 |
|
|
320 |
rotateZHolder:aHolder
|
752
|
321 |
"set the valueHolder, which holds the rotation Z value
|
741
|
322 |
"
|
|
323 |
rotateZHolder == aHolder ifFalse:[
|
3150
|
324 |
rotateZHolder notNil ifTrue:[
|
|
325 |
rotateZHolder removeDependent:self
|
|
326 |
].
|
|
327 |
(rotateZHolder := aHolder) notNil ifTrue:[
|
|
328 |
rotateZHolder addDependent:self
|
|
329 |
]
|
741
|
330 |
].
|
|
331 |
self rotateZ:(rotateZHolder value)
|
|
332 |
|
|
333 |
!
|
|
334 |
|
|
335 |
zoomZHolder
|
752
|
336 |
"returns the valueHolder, which holds the zoom Z factor
|
741
|
337 |
"
|
|
338 |
^ zoomZHolder
|
|
339 |
|
|
340 |
!
|
|
341 |
|
|
342 |
zoomZHolder:aHolder
|
752
|
343 |
"set the valueHolder, which holds the zoom Z factor
|
741
|
344 |
"
|
|
345 |
zoomZHolder == aHolder ifFalse:[
|
3150
|
346 |
zoomZHolder notNil ifTrue:[
|
|
347 |
zoomZHolder removeDependent:self
|
|
348 |
].
|
|
349 |
(zoomZHolder := aHolder) notNil ifTrue:[
|
|
350 |
zoomZHolder addDependent:self
|
|
351 |
]
|
741
|
352 |
].
|
|
353 |
self zoomZ:(zoomZHolder value)
|
|
354 |
! !
|
|
355 |
|
|
356 |
!GraphColumnView3D methodsFor:'change & update'!
|
|
357 |
|
|
358 |
update:what with:aPara from:chgObj
|
|
359 |
"catch and handle a change notification of any object
|
|
360 |
"
|
|
361 |
chgObj == rotateXHolder ifTrue:[ ^ self rotateX:(rotateXHolder value) ].
|
|
362 |
chgObj == rotateYHolder ifTrue:[ ^ self rotateY:(rotateYHolder value) ].
|
|
363 |
chgObj == rotateZHolder ifTrue:[ ^ self rotateZ:(rotateZHolder value) ].
|
754
|
364 |
chgObj == zoomZHolder ifTrue:[ ^ self zoomZ:(zoomZHolder value) ].
|
741
|
365 |
|
|
366 |
super update:what with:aPara from:chgObj
|
|
367 |
! !
|
|
368 |
|
|
369 |
!GraphColumnView3D methodsFor:'converting'!
|
|
370 |
|
|
371 |
rotateValueFrom:aNumber
|
|
372 |
"converts a value to a valid rotation value
|
|
373 |
"
|
|
374 |
|r|
|
|
375 |
|
|
376 |
r := self unsignedIntegerFrom:aNumber onError:[0].
|
|
377 |
^ r < 360 ifTrue:[r] ifFalse:[r \\ 360]
|
|
378 |
! !
|
|
379 |
|
|
380 |
!GraphColumnView3D methodsFor:'initialization'!
|
|
381 |
|
|
382 |
destroy
|
|
383 |
"remove dependencies
|
|
384 |
"
|
|
385 |
super destroy.
|
|
386 |
|
|
387 |
rotateXHolder removeDependent:self.
|
|
388 |
rotateYHolder removeDependent:self.
|
|
389 |
rotateZHolder removeDependent:self.
|
|
390 |
zoomZHolder removeDependent:self.
|
|
391 |
|
|
392 |
!
|
|
393 |
|
|
394 |
initialize
|
|
395 |
"setup default values
|
|
396 |
"
|
|
397 |
super initialize.
|
|
398 |
|
|
399 |
rotateX := 45.
|
|
400 |
rotateY := 45.
|
|
401 |
rotateZ := 0.
|
|
402 |
zoomZ := 1.
|
|
403 |
|
|
404 |
showGraph := true.
|
754
|
405 |
showAxis := false.
|
752
|
406 |
|
|
407 |
glxView := GLXGraph extent:(1.0 @ 1.0) in:self.
|
|
408 |
glxView for:self.
|
741
|
409 |
|
|
410 |
! !
|
|
411 |
|
|
412 |
!GraphColumnView3D methodsFor:'protocol'!
|
|
413 |
|
754
|
414 |
doInvalidateGraph
|
|
415 |
"set graph to invalidate
|
|
416 |
"
|
803
|
417 |
glxView invalidate
|
754
|
418 |
!
|
752
|
419 |
|
754
|
420 |
doRecomputeGraph
|
|
421 |
"called to recompute drawable objects and to set the
|
|
422 |
graph to invalidate
|
741
|
423 |
"
|
754
|
424 |
glxView deleteAllObjects.
|
741
|
425 |
!
|
|
426 |
|
754
|
427 |
updateColumns:what with:oldValue from:aColumn
|
|
428 |
"called if the list of columns changed
|
3150
|
429 |
#size the size of the columns
|
|
430 |
#color: color changed
|
754
|
431 |
or a specific column:( aColumn notNil )
|
3150
|
432 |
#insert: insert a new column
|
|
433 |
#remove: remove a column
|
754
|
434 |
|
3150
|
435 |
or a specific attribute derived from the
|
|
436 |
changed column.
|
741
|
437 |
"
|
|
438 |
|
754
|
439 |
(what == #color or:[what == #foregroundColor]) ifTrue:[
|
3150
|
440 |
glxView deleteColumns.
|
803
|
441 |
^ glxView invalidate.
|
741
|
442 |
].
|
|
443 |
|
754
|
444 |
( aColumn isNil
|
|
445 |
or:[what == #shown
|
|
446 |
or:[what == #insert:
|
|
447 |
or:[what == #remove:]]]
|
|
448 |
) ifTrue:[
|
3150
|
449 |
^ self doRecomputeGraph
|
754
|
450 |
].
|
741
|
451 |
!
|
|
452 |
|
754
|
453 |
updateGrid:what
|
|
454 |
"called if the grid changed
|
|
455 |
#color the color of the grid changed
|
|
456 |
#state the visibility state of the grid changed
|
741
|
457 |
"
|
754
|
458 |
what == #color ifTrue:[
|
3150
|
459 |
glxView deleteGrid
|
754
|
460 |
].
|
803
|
461 |
glxView invalidate.
|
752
|
462 |
!
|
|
463 |
|
754
|
464 |
updateReferences:what atRelX:aPhysX
|
|
465 |
"called when the list of references changed.
|
3150
|
466 |
#remove: the reference at the relative X index is removed
|
|
467 |
#insert: a reference is inserted at the relative X index
|
|
468 |
#size the list of references changed
|
|
469 |
#state visibility state changed
|
|
470 |
#color the foreground color changed
|
752
|
471 |
"
|
|
472 |
|
754
|
473 |
what == #state ifFalse:[
|
3150
|
474 |
glxView deleteReferences
|
754
|
475 |
].
|
803
|
476 |
glxView invalidate.
|
741
|
477 |
! !
|
|
478 |
|
|
479 |
!GraphColumnView3D methodsFor:'rotation'!
|
|
480 |
|
|
481 |
rotateX
|
|
482 |
"returns the rotation X value; range: 0 .. 360
|
|
483 |
"
|
|
484 |
^ rotateX
|
|
485 |
!
|
|
486 |
|
|
487 |
rotateX:aValue
|
|
488 |
"set the rotation X value; range: 0 .. 360
|
|
489 |
"
|
|
490 |
|r|
|
|
491 |
|
|
492 |
(r := self rotateValueFrom:aValue) ~~ rotateX ifTrue:[
|
3150
|
493 |
rotateX := r.
|
|
494 |
glxView invalidate.
|
741
|
495 |
]
|
|
496 |
!
|
|
497 |
|
|
498 |
rotateY
|
|
499 |
"returns the rotation Y value; range: 0 .. 360
|
|
500 |
"
|
|
501 |
^ rotateY
|
|
502 |
|
|
503 |
!
|
|
504 |
|
|
505 |
rotateY:aValue
|
|
506 |
"set the rotation Y value; range: 0 .. 360
|
|
507 |
"
|
|
508 |
|r|
|
|
509 |
|
|
510 |
(r := self rotateValueFrom:aValue) ~~ rotateY ifTrue:[
|
3150
|
511 |
rotateY := r.
|
|
512 |
glxView invalidate.
|
741
|
513 |
]
|
|
514 |
|
|
515 |
!
|
|
516 |
|
|
517 |
rotateZ
|
|
518 |
"returns the rotation Z value; range: 0 .. 360
|
|
519 |
"
|
|
520 |
^ rotateZ
|
|
521 |
|
|
522 |
!
|
|
523 |
|
|
524 |
rotateZ:aValue
|
|
525 |
"set the rotation Z value; range: 0 .. 360
|
|
526 |
"
|
|
527 |
|r|
|
|
528 |
|
|
529 |
(r := self rotateValueFrom:aValue) ~~ rotateZ ifTrue:[
|
3150
|
530 |
rotateZ := r.
|
|
531 |
glxView invalidate.
|
741
|
532 |
]
|
|
533 |
|
|
534 |
! !
|
|
535 |
|
804
|
536 |
!GraphColumnView3D::GLXGraph class methodsFor:'constants'!
|
|
537 |
|
|
538 |
maxColors
|
|
539 |
^ 256
|
|
540 |
! !
|
|
541 |
|
803
|
542 |
!GraphColumnView3D::GLXGraph methodsFor:'event handling'!
|
741
|
543 |
|
803
|
544 |
buttonPress:button x:x y:y
|
|
545 |
"delegate button to graph
|
741
|
546 |
"
|
803
|
547 |
graph buttonPress:button x:x y:y
|
|
548 |
! !
|
|
549 |
|
|
550 |
!GraphColumnView3D::GLXGraph methodsFor:'initialization'!
|
|
551 |
|
|
552 |
destroy
|
|
553 |
"remove dependencies
|
|
554 |
"
|
|
555 |
super destroy.
|
|
556 |
self deleteAllObjects.
|
741
|
557 |
|
|
558 |
!
|
|
559 |
|
803
|
560 |
for:aGraph
|
|
561 |
graph := aGraph
|
|
562 |
!
|
|
563 |
|
|
564 |
initialize
|
|
565 |
"setup default values
|
|
566 |
"
|
|
567 |
super initialize.
|
|
568 |
|
804
|
569 |
type := #colorIndexDoubleBuffer. "/ works on any device
|
|
570 |
maxY := 1.0.
|
|
571 |
minY := -1.0.
|
803
|
572 |
|
|
573 |
removeFunc := false.
|
|
574 |
removeRefs := false.
|
|
575 |
removeGrid := false.
|
|
576 |
removeAxis := false.
|
|
577 |
isInvalid := false.
|
|
578 |
lockCriticalTask := Semaphore forMutualExclusion.
|
805
|
579 |
|
|
580 |
|
|
581 |
colorMap := Dictionary new.
|
|
582 |
colorMap at:(Color black) put:Black.
|
|
583 |
colorMap at:(Color white) put:White.
|
|
584 |
colorMap at:(Color blue) put:Blue.
|
|
585 |
colorMap at:(Color cyan) put:Cyan.
|
|
586 |
colorMap at:(Color magenta) put:Magenta.
|
|
587 |
colorMap at:(Color red) put:Red.
|
|
588 |
colorMap at:(Color yellow) put:Yellow.
|
|
589 |
colorMap at:(Color green) put:Green.
|
|
590 |
|
803
|
591 |
!
|
754
|
592 |
|
803
|
593 |
realize
|
|
594 |
"define orthogonal projection; switch to back buffer drawing
|
|
595 |
"
|
|
596 |
super realize.
|
|
597 |
device glxOrthoLeft:-1.0 right:1.0 bottom:-1.0 top:1.0 near:10.0 far:-10.0 in:drawableId.
|
|
598 |
self backBuffer.
|
|
599 |
|
|
600 |
! !
|
|
601 |
|
|
602 |
!GraphColumnView3D::GLXGraph methodsFor:'making objects'!
|
|
603 |
|
|
604 |
make:aSelector
|
|
605 |
|
|
606 |
|id|
|
|
607 |
|
815
|
608 |
self makeObject:(id := self newObjectId).
|
803
|
609 |
self perform:aSelector.
|
|
610 |
self closeObject.
|
|
611 |
^ id
|
|
612 |
!
|
|
613 |
|
|
614 |
makeAxis
|
815
|
615 |
|x z|
|
754
|
616 |
|
815
|
617 |
x := yValues first size.
|
|
618 |
z := yValues size - 1.
|
754
|
619 |
|
|
620 |
self setColor:(Color red).
|
|
621 |
|
|
622 |
device glxBeginLineIn:drawableId.
|
815
|
623 |
device glxV3fX:0 y:minY z:0 in:drawableId.
|
|
624 |
device glxV3fX:x y:minY z:0 in:drawableId.
|
754
|
625 |
device glxEndLineIn:drawableId.
|
|
626 |
|
|
627 |
device glxBeginLineIn:drawableId.
|
815
|
628 |
device glxV3fX:0 y:minY z:0 in:drawableId.
|
|
629 |
device glxV3fX:0 y:maxY z:0 in:drawableId.
|
754
|
630 |
device glxEndLineIn:drawableId.
|
|
631 |
|
|
632 |
device glxBeginLineIn:drawableId.
|
815
|
633 |
device glxV3fX:0 y:minY z:0 in:drawableId.
|
|
634 |
device glxV3fX:0 y:minY z:z in:drawableId.
|
754
|
635 |
device glxEndLineIn:drawableId.
|
|
636 |
|
|
637 |
|
|
638 |
!
|
|
639 |
|
803
|
640 |
makeFunc
|
741
|
641 |
"draw the graph and spawn the grid dependend on the enabled
|
|
642 |
attributes
|
|
643 |
"
|
815
|
644 |
|
|
|
645 |
x "{ Class:SmallInteger }"
|
|
646 |
z "{ Class:SmallInteger }"
|
741
|
647 |
|
|
815
|
648 |
|
|
649 |
z := 0.
|
741
|
650 |
|
815
|
651 |
yValues keysAndValuesDo:[:i :m|
|
3150
|
652 |
x := 0.
|
|
653 |
self setColor:((loVCols at:i) foregroundColor).
|
|
654 |
device glxBeginLineIn:drawableId.
|
741
|
655 |
|
3150
|
656 |
m do:[:y|
|
|
657 |
device glxV3fX:x y:y z:z in:drawableId.
|
|
658 |
x := x + 1.
|
|
659 |
].
|
|
660 |
device glxEndLineIn:drawableId.
|
|
661 |
z := z + 1
|
741
|
662 |
]
|
|
663 |
!
|
|
664 |
|
803
|
665 |
makeGrid
|
741
|
666 |
"draw the graph and spawn the grid dependend on the enabled
|
|
667 |
attributes
|
|
668 |
"
|
|
669 |
|
|
815
|
670 |
noRows "| Class:SmallInteger }"
|
|
671 |
x "{ Class:SmallInteger }"
|
|
672 |
z "{ Class:SmallInteger }"
|
|
673 |
|
|
741
|
674 |
|
|
675 |
self setColor:(graph gridColor).
|
815
|
676 |
noRows := graph windowSize.
|
|
677 |
x := 0.
|
741
|
678 |
|
815
|
679 |
1 to:noRows do:[:rI|
|
3150
|
680 |
z := 0.
|
|
681 |
device glxBeginLineIn:drawableId.
|
741
|
682 |
|
3150
|
683 |
yValues do:[:m|
|
|
684 |
device glxV3fX:x y:(m at:rI) z:z in:drawableId.
|
|
685 |
z := z + 1
|
|
686 |
].
|
|
687 |
device glxEndLineIn:drawableId.
|
|
688 |
x := x + 1
|
741
|
689 |
].
|
|
690 |
|
|
691 |
|
|
692 |
|
|
693 |
|
|
694 |
!
|
|
695 |
|
803
|
696 |
makeRefs
|
|
697 |
"redraw current visible references
|
|
698 |
"
|
815
|
699 |
|z0 z1
|
|
700 |
noCols "{ Class:SmallInteger }"
|
|
701 |
|
|
|
702 |
noCols := yValues size.
|
803
|
703 |
z0 := -0.1.
|
815
|
704 |
z1 := noCols - 0.9.
|
803
|
705 |
|
|
706 |
self setColor:(graph referenceColor).
|
|
707 |
|
815
|
708 |
loVRefs do:[:x0|
|
3150
|
709 |
device glxBeginLineIn:drawableId.
|
|
710 |
device glxV3fX:x0 y:maxY z:z0 in:drawableId.
|
|
711 |
device glxV3fX:x0 y:minY z:z0 in:drawableId.
|
|
712 |
device glxEndLineIn:drawableId.
|
803
|
713 |
|
3150
|
714 |
device glxBeginLineIn:drawableId.
|
|
715 |
device glxV3fX:x0 y:maxY z:z1 in:drawableId.
|
|
716 |
device glxV3fX:x0 y:minY z:z1 in:drawableId.
|
|
717 |
device glxEndLineIn:drawableId.
|
803
|
718 |
|
3150
|
719 |
1 to:noCols do:[:j||y|
|
|
720 |
y := (yValues at:j) at:(x0 + 1).
|
|
721 |
device glxBeginLineIn:drawableId.
|
|
722 |
device glxV3fX:x0 y:y z:z0 in:drawableId.
|
|
723 |
device glxV3fX:x0 y:y z:z1 in:drawableId.
|
|
724 |
device glxEndLineIn:drawableId.
|
|
725 |
]
|
803
|
726 |
]
|
3150
|
727 |
|
803
|
728 |
! !
|
|
729 |
|
|
730 |
!GraphColumnView3D::GLXGraph methodsFor:'private redraw'!
|
|
731 |
|
|
732 |
criticalRedrawRoutine
|
|
733 |
"update all critical resources
|
|
734 |
"
|
|
735 |
removeFunc ifTrue:[
|
3150
|
736 |
loVCols := nil.
|
|
737 |
loVRefs := nil.
|
|
738 |
yValues := nil.
|
803
|
739 |
|
3150
|
740 |
glxObjFunc notNil ifTrue:[
|
|
741 |
self deleteObject:glxObjFunc.
|
|
742 |
glxObjFunc := nil
|
|
743 |
].
|
|
744 |
removeFunc := false.
|
803
|
745 |
].
|
|
746 |
|
|
747 |
removeRefs ifTrue:[
|
3150
|
748 |
loVRefs := nil.
|
803
|
749 |
|
3150
|
750 |
glxObjRefs notNil ifTrue:[
|
|
751 |
self deleteObject:glxObjRefs.
|
|
752 |
glxObjRefs := nil.
|
|
753 |
].
|
|
754 |
removeRefs := false.
|
803
|
755 |
].
|
|
756 |
|
|
757 |
removeGrid ifTrue:[
|
3150
|
758 |
glxObjGrid notNil ifTrue:[
|
|
759 |
self deleteObject:glxObjGrid.
|
|
760 |
glxObjGrid := nil.
|
|
761 |
].
|
|
762 |
removeGrid := false.
|
803
|
763 |
].
|
|
764 |
|
|
765 |
removeAxis ifTrue:[
|
3150
|
766 |
glxObjAxis notNil ifTrue:[
|
|
767 |
self deleteObject:glxObjAxis.
|
|
768 |
glxObjAxis := nil.
|
|
769 |
].
|
|
770 |
removeAxis := false.
|
803
|
771 |
].
|
|
772 |
|
|
773 |
shown ifTrue:[
|
3150
|
774 |
self redrawInBackBuffer.
|
|
775 |
self swapBuffers.
|
805
|
776 |
]
|
803
|
777 |
|
804
|
778 |
|
|
779 |
!
|
|
780 |
|
741
|
781 |
redrawInBackBuffer
|
|
782 |
"redraw in back
|
|
783 |
"
|
815
|
784 |
|sY sX sZ noCols dY winSize w2 showRefs showGrid showFunc showAxis gpOrgX|
|
741
|
785 |
|
|
786 |
self setColor:(graph backgroundColor).
|
|
787 |
self clear.
|
|
788 |
|
815
|
789 |
winSize := graph windowSize.
|
|
790 |
|
803
|
791 |
loVCols isNil ifTrue:[
|
3150
|
792 |
(loVCols := graph listOfVisibleColumns) isEmpty ifTrue:[
|
|
793 |
^ self
|
|
794 |
].
|
|
795 |
gpOrgX := graph graphOriginX.
|
|
796 |
yValues := loVCols collect:[:c| c yValuesStartAt:gpOrgX into:(Array new:winSize)].
|
|
797 |
maxY := minY := (yValues at:1) at:1.
|
815
|
798 |
|
3150
|
799 |
yValues do:[:m|
|
|
800 |
m do:[:y|
|
|
801 |
maxY := maxY max:y.
|
|
802 |
minY := minY min:y.
|
|
803 |
]
|
|
804 |
]
|
803
|
805 |
].
|
|
806 |
|
|
807 |
(noCols := loVCols size) == 0 ifTrue:[
|
3150
|
808 |
^ self
|
741
|
809 |
].
|
|
810 |
|
803
|
811 |
((showGrid := graph showGrid) and:[glxObjGrid isNil]) ifTrue:[
|
3150
|
812 |
noCols > 1 ifTrue:[glxObjGrid := self make:#makeGrid]
|
|
813 |
ifFalse:[showGrid := false]
|
741
|
814 |
].
|
|
815 |
|
803
|
816 |
((showFunc := graph showGraph) and:[glxObjFunc isNil]) ifTrue:[
|
3150
|
817 |
glxObjFunc := self make:#makeFunc
|
754
|
818 |
].
|
|
819 |
|
803
|
820 |
((showAxis := graph showAxis) and:[glxObjAxis isNil]) ifTrue:[
|
3150
|
821 |
glxObjAxis := self make:#makeAxis
|
741
|
822 |
].
|
|
823 |
|
803
|
824 |
((showRefs := graph showReferences) and:[glxObjRefs isNil]) ifTrue:[
|
3150
|
825 |
loVRefs isNil ifTrue:[
|
|
826 |
loVRefs := graph listOfVisibleRefIndices
|
|
827 |
].
|
|
828 |
loVRefs notEmpty ifTrue:[
|
|
829 |
glxObjRefs := self make:#makeRefs
|
|
830 |
] ifFalse:[
|
|
831 |
showRefs := false
|
|
832 |
]
|
754
|
833 |
].
|
|
834 |
|
|
835 |
sZ := graph zoomZ * (1.0 / noCols).
|
|
836 |
w2 := width // 2.
|
|
837 |
|
|
838 |
"/ calculate scaleX dependent on height and scaleZ
|
|
839 |
"/ and:#glxOrthoLeft:right:bottom:top:near:10.0 far:-10.0
|
|
840 |
|
|
841 |
sX := height // 2 * noCols * graph zoomZ / (20.0 sqrt).
|
|
842 |
sX := (((w2 * w2) + (sX raisedTo:2)) sqrt) - w2.
|
|
843 |
sX := sX / (width / winSize).
|
|
844 |
sX := 2.0 / (winSize + sX).
|
|
845 |
|
741
|
846 |
dY := (maxY - minY) / 2.
|
|
847 |
sY := ((0.5 / (dY max:2.0)) min:sX) * graph zoomY.
|
|
848 |
|
|
849 |
self pushMatrix.
|
|
850 |
|
|
851 |
self rotateX:(graph rotateX) y:(graph rotateY) z:(graph rotateZ).
|
754
|
852 |
self scaleX:sX y:sY z:sZ.
|
741
|
853 |
|
|
854 |
self translateX:(winSize / -2.0) "/ rotate center line
|
3150
|
855 |
y:(dY - maxY) "/ translate to center
|
|
856 |
z:(noCols - 1 / -2.0). "/ rotate center line
|
741
|
857 |
|
803
|
858 |
showGrid ifTrue:[ self callObject:glxObjGrid ].
|
|
859 |
showFunc ifTrue:[ self callObject:glxObjFunc ].
|
|
860 |
showAxis ifTrue:[ self callObject:glxObjAxis ].
|
|
861 |
showRefs ifTrue:[ self callObject:glxObjRefs ].
|
754
|
862 |
|
741
|
863 |
self popMatrix.
|
802
|
864 |
|
|
865 |
!
|
|
866 |
|
741
|
867 |
setColor:aColor
|
|
868 |
|index useCol|
|
|
869 |
|
|
870 |
useCol := aColor ? graph foregroundColor.
|
804
|
871 |
index := colorMap at:useCol ifAbsent:nil.
|
741
|
872 |
|
|
873 |
index isNil ifTrue:[
|
4852
|
874 |
index := colorMap size + self class numberOfStandardColors.
|
741
|
875 |
|
4852
|
876 |
( (index > self class maxColors)
|
|
877 |
or:[(useCol := useCol onDevice:device) colorId isNil]
|
|
878 |
) ifTrue:[
|
|
879 |
Transcript showCR:'cannot allocate more colors'.
|
|
880 |
index := (useCol brightness > 0.5) ifTrue:[White]
|
|
881 |
ifFalse:[Black]
|
|
882 |
] ifFalse:[
|
|
883 |
colorMap at:useCol put:index.
|
741
|
884 |
|
4852
|
885 |
self colorRed:(useCol red)
|
|
886 |
green:(useCol green)
|
|
887 |
blue:(useCol blue).
|
804
|
888 |
|
4852
|
889 |
self mapColor:index
|
|
890 |
red:(useCol redByte)
|
|
891 |
green:(useCol greenByte)
|
|
892 |
blue:(useCol blueByte)
|
|
893 |
]
|
741
|
894 |
].
|
|
895 |
self color:index.
|
803
|
896 |
! !
|
|
897 |
|
|
898 |
!GraphColumnView3D::GLXGraph methodsFor:'redraw'!
|
|
899 |
|
|
900 |
invalidate
|
|
901 |
|
|
902 |
lockCriticalTask critical:[
|
3150
|
903 |
isInvalid := true.
|
803
|
904 |
|
3150
|
905 |
criticalTask isNil ifTrue:[
|
|
906 |
criticalTask := [
|
|
907 |
[ |repeat|
|
803
|
908 |
|
3150
|
909 |
lockCriticalTask critical:[
|
|
910 |
(repeat := isInvalid) ifTrue:[isInvalid := false]
|
|
911 |
ifFalse:[criticalTask := nil]
|
|
912 |
].
|
|
913 |
repeat ifTrue:[ self criticalRedrawRoutine ].
|
|
914 |
repeat
|
803
|
915 |
|
3150
|
916 |
] whileTrue:[ Processor yield ].
|
803
|
917 |
|
3150
|
918 |
] forkAt:( Processor activePriority - 1 ).
|
|
919 |
]
|
803
|
920 |
]
|
|
921 |
|
741
|
922 |
!
|
|
923 |
|
803
|
924 |
redraw
|
|
925 |
"redraw
|
|
926 |
"
|
|
927 |
self invalidate
|
741
|
928 |
! !
|
|
929 |
|
754
|
930 |
!GraphColumnView3D::GLXGraph methodsFor:'removing'!
|
|
931 |
|
|
932 |
deleteAllObjects
|
|
933 |
"delete all graphical objects
|
|
934 |
"
|
803
|
935 |
removeGrid := removeAxis := removeFunc := removeRefs := true.
|
|
936 |
self invalidate.
|
754
|
937 |
!
|
741
|
938 |
|
754
|
939 |
deleteAxis
|
802
|
940 |
removeAxis := true.
|
754
|
941 |
!
|
|
942 |
|
|
943 |
deleteColumns
|
|
944 |
"delete the columns
|
741
|
945 |
"
|
803
|
946 |
removeFunc := true.
|
741
|
947 |
!
|
|
948 |
|
754
|
949 |
deleteGrid
|
|
950 |
"delete the grid
|
741
|
951 |
"
|
802
|
952 |
removeGrid := true.
|
741
|
953 |
!
|
|
954 |
|
754
|
955 |
deleteReferences
|
|
956 |
"delete the references
|
741
|
957 |
"
|
802
|
958 |
removeRefs := true.
|
741
|
959 |
! !
|
|
960 |
|
|
961 |
!GraphColumnView3D class methodsFor:'documentation'!
|
|
962 |
|
|
963 |
version
|
4852
|
964 |
^ '$Header$'
|
741
|
965 |
! !
|
4852
|
966 |
|