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