--- a/GraphColumnView3D.st Fri Nov 10 07:20:31 2006 +0100
+++ b/GraphColumnView3D.st Mon Nov 13 17:11:31 2006 +0100
@@ -1,3 +1,5 @@
+"{ Package: 'stx:libwidg2' }"
+
GraphColumnView subclass:#GraphColumnView3D
instanceVariableNames:'glxView showGraph rotateX rotateY rotateZ rotateXHolder
rotateYHolder rotateZHolder zoomZ zoomZHolder showAxis'
@@ -25,12 +27,12 @@
[See also:]
- GraphColumn
- GraphColumnView
- GraphColumnView2D
+ GraphColumn
+ GraphColumnView
+ GraphColumnView2D
[Author:]
- Claus Atzkern
+ Claus Atzkern
"
! !
@@ -51,35 +53,35 @@
<resource: #menu>
^
-
+
#(#Menu
-
- #(
- #(#MenuItem
- #'label:' 'Show Columns'
- #'indication:' #'showGraph:'
- )
- #(#MenuItem
- #'label:' 'Show Grid'
- #'indication:' #'showGrid:'
- )
- #(#MenuItem
- #'label:' 'Show Axis'
- #'indication:' #'showAxis:'
- )
- #(#MenuItem
- #'label:' 'Show References'
- #'indication:' #'showReferences:'
- )
- #(#MenuItem
- #'label:' '-'
- )
- #(#MenuItem
- #'label:' 'Zoom Y'
- #'submenuChannel:' #subMenuZoomY
- )
- ) nil
- nil
+
+ #(
+ #(#MenuItem
+ #'label:' 'Show Columns'
+ #'indication:' #'showGraph:'
+ )
+ #(#MenuItem
+ #'label:' 'Show Grid'
+ #'indication:' #'showGrid:'
+ )
+ #(#MenuItem
+ #'label:' 'Show Axis'
+ #'indication:' #'showAxis:'
+ )
+ #(#MenuItem
+ #'label:' 'Show References'
+ #'indication:' #'showReferences:'
+ )
+ #(#MenuItem
+ #'label:' '-'
+ )
+ #(#MenuItem
+ #'label:' 'Zoom Y'
+ #'submenuChannel:' #subMenuZoomY
+ )
+ ) nil
+ nil
)
! !
@@ -97,23 +99,23 @@
top label:'3D-View'.
- #( red green yellow blue
+ #( red green yellow blue
) keysAndValuesDo:[:idx :aColor|
- |col|
+ |col|
- col := GraphColumn name:idx.
- col foregroundColor:(Color perform:aColor).
+ col := GraphColumn name:idx.
+ col foregroundColor:(Color perform:aColor).
- col functionYblock:[:start :anArray|
- x := (start - 1) * 0.2.
- (idx == 1 or:[idx == 3]) ifTrue:[
- 1 to:(anArray size) do:[:i| anArray at:i put:20 * (x sin). x := x + 0.2 ].
- ] ifFalse:[
- 1 to:(anArray size) do:[:i| anArray at:i put:20 * (x cos). x := x + 0.2 ].
- ].
- anArray
- ].
- list add:col
+ col functionYblock:[:start :anArray|
+ x := (start - 1) * 0.2.
+ (idx == 1 or:[idx == 3]) ifTrue:[
+ 1 to:(anArray size) do:[:i| anArray at:i put:20 * (x sin). x := x + 0.2 ].
+ ] ifFalse:[
+ 1 to:(anArray size) do:[:i| anArray at:i put:20 * (x cos). x := x + 0.2 ].
+ ].
+ anArray
+ ].
+ list add:col
].
view showGrid:true.
view columns:list.
@@ -122,21 +124,21 @@
[ |o i t c|
- i := 0.
- t := 0.
- c := 0.
+ i := 0.
+ t := 0.
+ c := 0.
- [top realized] whileTrue:[
- t := t + (Time millisecondsToRun:[ view rotateY:i]).
- i := i + 1.
- c := c + 1.
- c == 90 ifTrue:[
- Transcript showCR:'Time: ', t printString.
- t := 0.
- c := 0.
- ].
- Delay waitForSeconds:0.05.
- ]
+ [top realized] whileTrue:[
+ t := t + (Time millisecondsToRun:[ view rotateY:i]).
+ i := i + 1.
+ c := c + 1.
+ c == 90 ifTrue:[
+ Transcript showCR:'Time: ', t printString.
+ t := 0.
+ c := 0.
+ ].
+ Delay waitForSeconds:0.05.
+ ]
] forkAt:8.
@@ -150,7 +152,7 @@
"running view
start with:
- self testRunX
+ self testRunX
"
|top list view step x offs time cbox halt xOrigin|
@@ -169,22 +171,22 @@
top label:'Testing 3D-View: Performance Test'.
#( 0.25 0.5 0.75 ) do:[:xAxis||aCol|
- aCol := GraphColumn new.
- aCol relativeXaxis:xAxis.
- xAxis ~= 0.5 ifTrue:[
- xAxis < 0.5 ifTrue:[aCol foregroundColor:(Color red)]
- ifFalse:[aCol foregroundColor:(Color blue)]
- ].
- aCol hLineStyle:#dashed.
- aCol hLineList:#( 0 ).
- aCol scaleY:40.
+ aCol := GraphColumn new.
+ aCol relativeXaxis:xAxis.
+ xAxis ~= 0.5 ifTrue:[
+ xAxis < 0.5 ifTrue:[aCol foregroundColor:(Color red)]
+ ifFalse:[aCol foregroundColor:(Color blue)]
+ ].
+ aCol hLineStyle:#dashed.
+ aCol hLineList:#( 0 ).
+ aCol scaleY:40.
- aCol functionYblock:[:start :array|
- x := start * 0.2.
- 1 to:(array size) do:[:i| array at:i put:10 * (x sin). x := x + 0.2 ].
- array
- ].
- list add:aCol.
+ aCol functionYblock:[:start :array|
+ x := start * 0.2.
+ 1 to:(array size) do:[:i| array at:i put:10 * (x sin). x := x + 0.2 ].
+ array
+ ].
+ list add:aCol.
].
view windowSize:100.
view showGrid:true.
@@ -195,11 +197,11 @@
top openAndWait.
[ [top realized] whileTrue:[
- halt ifFalse:[
- xOrigin value:(xOrigin value + step).
- ].
- Delay waitForSeconds:0.05.
- ]
+ halt ifFalse:[
+ xOrigin value:(xOrigin value + step).
+ ].
+ Delay waitForSeconds:0.05.
+ ]
] forkAt:8.
@@ -217,8 +219,8 @@
"show or hide the x/y/z axis
"
showAxis ~~ aBool ifTrue:[
- showAxis := aBool.
- glxView invalidate.
+ showAxis := aBool.
+ glxView invalidate.
].
!
@@ -234,8 +236,8 @@
shown
"
showGraph ~~ aBool ifTrue:[
- showGraph := aBool.
- glxView invalidate.
+ showGraph := aBool.
+ glxView invalidate.
].
!
@@ -252,12 +254,12 @@
|zZ|
(zZ := self floatFrom:aValue onError:[1]) <= 0 ifTrue:[
- zZ := 1
+ zZ := 1
].
zZ = zoomZ ifFalse:[
- zoomZ := zZ.
- glxView invalidate.
+ zoomZ := zZ.
+ glxView invalidate.
]
! !
@@ -274,12 +276,12 @@
"set the valueHolder, which holds the rotation X value
"
rotateXHolder == aHolder ifFalse:[
- rotateXHolder notNil ifTrue:[
- rotateXHolder removeDependent:self
- ].
- (rotateXHolder := aHolder) notNil ifTrue:[
- rotateXHolder addDependent:self
- ]
+ rotateXHolder notNil ifTrue:[
+ rotateXHolder removeDependent:self
+ ].
+ (rotateXHolder := aHolder) notNil ifTrue:[
+ rotateXHolder addDependent:self
+ ]
].
self rotateX:(rotateXHolder value)
!
@@ -295,12 +297,12 @@
"set the valueHolder, which holds the rotation Y value
"
rotateYHolder == aHolder ifFalse:[
- rotateYHolder notNil ifTrue:[
- rotateYHolder removeDependent:self
- ].
- (rotateYHolder := aHolder) notNil ifTrue:[
- rotateYHolder addDependent:self
- ]
+ rotateYHolder notNil ifTrue:[
+ rotateYHolder removeDependent:self
+ ].
+ (rotateYHolder := aHolder) notNil ifTrue:[
+ rotateYHolder addDependent:self
+ ]
].
self rotateY:(rotateYHolder value)
@@ -317,12 +319,12 @@
"set the valueHolder, which holds the rotation Z value
"
rotateZHolder == aHolder ifFalse:[
- rotateZHolder notNil ifTrue:[
- rotateZHolder removeDependent:self
- ].
- (rotateZHolder := aHolder) notNil ifTrue:[
- rotateZHolder addDependent:self
- ]
+ rotateZHolder notNil ifTrue:[
+ rotateZHolder removeDependent:self
+ ].
+ (rotateZHolder := aHolder) notNil ifTrue:[
+ rotateZHolder addDependent:self
+ ]
].
self rotateZ:(rotateZHolder value)
@@ -339,12 +341,12 @@
"set the valueHolder, which holds the zoom Z factor
"
zoomZHolder == aHolder ifFalse:[
- zoomZHolder notNil ifTrue:[
- zoomZHolder removeDependent:self
- ].
- (zoomZHolder := aHolder) notNil ifTrue:[
- zoomZHolder addDependent:self
- ]
+ zoomZHolder notNil ifTrue:[
+ zoomZHolder removeDependent:self
+ ].
+ (zoomZHolder := aHolder) notNil ifTrue:[
+ zoomZHolder addDependent:self
+ ]
].
self zoomZ:(zoomZHolder value)
! !
@@ -422,18 +424,18 @@
updateColumns:what with:oldValue from:aColumn
"called if the list of columns changed
- #size the size of the columns
- #color: color changed
+ #size the size of the columns
+ #color: color changed
or a specific column:( aColumn notNil )
- #insert: insert a new column
- #remove: remove a column
+ #insert: insert a new column
+ #remove: remove a column
- or a specific attribute derived from the
- changed column.
+ or a specific attribute derived from the
+ changed column.
"
(what == #color or:[what == #foregroundColor]) ifTrue:[
- glxView deleteColumns.
+ glxView deleteColumns.
^ glxView invalidate.
].
@@ -442,7 +444,7 @@
or:[what == #insert:
or:[what == #remove:]]]
) ifTrue:[
- ^ self doRecomputeGraph
+ ^ self doRecomputeGraph
].
!
@@ -452,22 +454,22 @@
#state the visibility state of the grid changed
"
what == #color ifTrue:[
- glxView deleteGrid
+ glxView deleteGrid
].
glxView invalidate.
!
updateReferences:what atRelX:aPhysX
"called when the list of references changed.
- #remove: the reference at the relative X index is removed
- #insert: a reference is inserted at the relative X index
- #size the list of references changed
- #state visibility state changed
- #color the foreground color changed
+ #remove: the reference at the relative X index is removed
+ #insert: a reference is inserted at the relative X index
+ #size the list of references changed
+ #state visibility state changed
+ #color the foreground color changed
"
what == #state ifFalse:[
- glxView deleteReferences
+ glxView deleteReferences
].
glxView invalidate.
! !
@@ -486,8 +488,8 @@
|r|
(r := self rotateValueFrom:aValue) ~~ rotateX ifTrue:[
- rotateX := r.
- glxView invalidate.
+ rotateX := r.
+ glxView invalidate.
]
!
@@ -504,8 +506,8 @@
|r|
(r := self rotateValueFrom:aValue) ~~ rotateY ifTrue:[
- rotateY := r.
- glxView invalidate.
+ rotateY := r.
+ glxView invalidate.
]
!
@@ -523,8 +525,8 @@
|r|
(r := self rotateValueFrom:aValue) ~~ rotateZ ifTrue:[
- rotateZ := r.
- glxView invalidate.
+ rotateZ := r.
+ glxView invalidate.
]
! !
@@ -645,16 +647,16 @@
z := 0.
yValues keysAndValuesDo:[:i :m|
- x := 0.
- self setColor:((loVCols at:i) foregroundColor).
- device glxBeginLineIn:drawableId.
+ x := 0.
+ self setColor:((loVCols at:i) foregroundColor).
+ device glxBeginLineIn:drawableId.
- m do:[:y|
- device glxV3fX:x y:y z:z in:drawableId.
- x := x + 1.
- ].
- device glxEndLineIn:drawableId.
- z := z + 1
+ m do:[:y|
+ device glxV3fX:x y:y z:z in:drawableId.
+ x := x + 1.
+ ].
+ device glxEndLineIn:drawableId.
+ z := z + 1
]
!
@@ -673,15 +675,15 @@
x := 0.
1 to:noRows do:[:rI|
- z := 0.
- device glxBeginLineIn:drawableId.
+ z := 0.
+ device glxBeginLineIn:drawableId.
- yValues do:[:m|
- device glxV3fX:x y:(m at:rI) z:z in:drawableId.
- z := z + 1
- ].
- device glxEndLineIn:drawableId.
- x := x + 1
+ yValues do:[:m|
+ device glxV3fX:x y:(m at:rI) z:z in:drawableId.
+ z := z + 1
+ ].
+ device glxEndLineIn:drawableId.
+ x := x + 1
].
@@ -702,25 +704,25 @@
self setColor:(graph referenceColor).
loVRefs do:[:x0|
- device glxBeginLineIn:drawableId.
- device glxV3fX:x0 y:maxY z:z0 in:drawableId.
- device glxV3fX:x0 y:minY z:z0 in:drawableId.
- device glxEndLineIn:drawableId.
+ device glxBeginLineIn:drawableId.
+ device glxV3fX:x0 y:maxY z:z0 in:drawableId.
+ device glxV3fX:x0 y:minY z:z0 in:drawableId.
+ device glxEndLineIn:drawableId.
- device glxBeginLineIn:drawableId.
- device glxV3fX:x0 y:maxY z:z1 in:drawableId.
- device glxV3fX:x0 y:minY z:z1 in:drawableId.
- device glxEndLineIn:drawableId.
+ device glxBeginLineIn:drawableId.
+ device glxV3fX:x0 y:maxY z:z1 in:drawableId.
+ device glxV3fX:x0 y:minY z:z1 in:drawableId.
+ device glxEndLineIn:drawableId.
- 1 to:noCols do:[:j||y|
- y := (yValues at:j) at:(x0 + 1).
- device glxBeginLineIn:drawableId.
- device glxV3fX:x0 y:y z:z0 in:drawableId.
- device glxV3fX:x0 y:y z:z1 in:drawableId.
- device glxEndLineIn:drawableId.
- ]
+ 1 to:noCols do:[:j||y|
+ y := (yValues at:j) at:(x0 + 1).
+ device glxBeginLineIn:drawableId.
+ device glxV3fX:x0 y:y z:z0 in:drawableId.
+ device glxV3fX:x0 y:y z:z1 in:drawableId.
+ device glxEndLineIn:drawableId.
+ ]
]
-
+
! !
!GraphColumnView3D::GLXGraph methodsFor:'private redraw'!
@@ -729,46 +731,46 @@
"update all critical resources
"
removeFunc ifTrue:[
- loVCols := nil.
- loVRefs := nil.
- yValues := nil.
+ loVCols := nil.
+ loVRefs := nil.
+ yValues := nil.
- glxObjFunc notNil ifTrue:[
- self deleteObject:glxObjFunc.
- glxObjFunc := nil
- ].
- removeFunc := false.
+ glxObjFunc notNil ifTrue:[
+ self deleteObject:glxObjFunc.
+ glxObjFunc := nil
+ ].
+ removeFunc := false.
].
removeRefs ifTrue:[
- loVRefs := nil.
+ loVRefs := nil.
- glxObjRefs notNil ifTrue:[
- self deleteObject:glxObjRefs.
- glxObjRefs := nil.
- ].
- removeRefs := false.
+ glxObjRefs notNil ifTrue:[
+ self deleteObject:glxObjRefs.
+ glxObjRefs := nil.
+ ].
+ removeRefs := false.
].
removeGrid ifTrue:[
- glxObjGrid notNil ifTrue:[
- self deleteObject:glxObjGrid.
- glxObjGrid := nil.
- ].
- removeGrid := false.
+ glxObjGrid notNil ifTrue:[
+ self deleteObject:glxObjGrid.
+ glxObjGrid := nil.
+ ].
+ removeGrid := false.
].
removeAxis ifTrue:[
- glxObjAxis notNil ifTrue:[
- self deleteObject:glxObjAxis.
- glxObjAxis := nil.
- ].
- removeAxis := false.
+ glxObjAxis notNil ifTrue:[
+ self deleteObject:glxObjAxis.
+ glxObjAxis := nil.
+ ].
+ removeAxis := false.
].
shown ifTrue:[
- self redrawInBackBuffer.
- self swapBuffers.
+ self redrawInBackBuffer.
+ self swapBuffers.
]
@@ -785,47 +787,47 @@
winSize := graph windowSize.
loVCols isNil ifTrue:[
- (loVCols := graph listOfVisibleColumns) isEmpty ifTrue:[
- ^ self
- ].
- gpOrgX := graph graphOriginX.
- yValues := loVCols collect:[:c| c yValuesStartAt:gpOrgX into:(Array new:winSize)].
- maxY := minY := (yValues at:1) at:1.
+ (loVCols := graph listOfVisibleColumns) isEmpty ifTrue:[
+ ^ self
+ ].
+ gpOrgX := graph graphOriginX.
+ yValues := loVCols collect:[:c| c yValuesStartAt:gpOrgX into:(Array new:winSize)].
+ maxY := minY := (yValues at:1) at:1.
- yValues do:[:m|
- m do:[:y|
- maxY := maxY max:y.
- minY := minY min:y.
- ]
- ]
+ yValues do:[:m|
+ m do:[:y|
+ maxY := maxY max:y.
+ minY := minY min:y.
+ ]
+ ]
].
(noCols := loVCols size) == 0 ifTrue:[
- ^ self
+ ^ self
].
((showGrid := graph showGrid) and:[glxObjGrid isNil]) ifTrue:[
- noCols > 1 ifTrue:[glxObjGrid := self make:#makeGrid]
- ifFalse:[showGrid := false]
+ noCols > 1 ifTrue:[glxObjGrid := self make:#makeGrid]
+ ifFalse:[showGrid := false]
].
((showFunc := graph showGraph) and:[glxObjFunc isNil]) ifTrue:[
- glxObjFunc := self make:#makeFunc
+ glxObjFunc := self make:#makeFunc
].
((showAxis := graph showAxis) and:[glxObjAxis isNil]) ifTrue:[
- glxObjAxis := self make:#makeAxis
+ glxObjAxis := self make:#makeAxis
].
((showRefs := graph showReferences) and:[glxObjRefs isNil]) ifTrue:[
- loVRefs isNil ifTrue:[
- loVRefs := graph listOfVisibleRefIndices
- ].
- loVRefs notEmpty ifTrue:[
- glxObjRefs := self make:#makeRefs
- ] ifFalse:[
- showRefs := false
- ]
+ loVRefs isNil ifTrue:[
+ loVRefs := graph listOfVisibleRefIndices
+ ].
+ loVRefs notEmpty ifTrue:[
+ glxObjRefs := self make:#makeRefs
+ ] ifFalse:[
+ showRefs := false
+ ]
].
sZ := graph zoomZ * (1.0 / noCols).
@@ -848,8 +850,8 @@
self scaleX:sX y:sY z:sZ.
self translateX:(winSize / -2.0) "/ rotate center line
- y:(dY - maxY) "/ translate to center
- z:(noCols - 1 / -2.0). "/ rotate center line
+ y:(dY - maxY) "/ translate to center
+ z:(noCols - 1 / -2.0). "/ rotate center line
showGrid ifTrue:[ self callObject:glxObjGrid ].
showFunc ifTrue:[ self callObject:glxObjFunc ].
@@ -867,26 +869,26 @@
index := colorMap at:useCol ifAbsent:nil.
index isNil ifTrue:[
- index := colorMap size + self class numberOfStandardColors.
+ index := colorMap size + self class numberOfStandardColors.
- ( (index > self class maxColors)
- or:[(useCol := useCol on:device) colorId isNil]
- ) ifTrue:[
- Transcript showCR:'cannot allocate more colors'.
- index := (useCol brightness > 0.5) ifTrue:[White]
- ifFalse:[Black]
- ] ifFalse:[
- colorMap at:useCol put:index.
+ ( (index > self class maxColors)
+ or:[(useCol := useCol on:device) colorId isNil]
+ ) ifTrue:[
+ Transcript showCR:'cannot allocate more colors'.
+ index := (useCol brightness > 0.5) ifTrue:[White]
+ ifFalse:[Black]
+ ] ifFalse:[
+ colorMap at:useCol put:index.
- self colorRed:(useCol red)
- green:(useCol green)
- blue:(useCol blue).
+ self colorRed:(useCol red)
+ green:(useCol green)
+ blue:(useCol blue).
- self mapColor:index
- red:(useCol redByte)
- green:(useCol greenByte)
- blue:(useCol blueByte)
- ]
+ self mapColor:index
+ red:(useCol redByte)
+ green:(useCol greenByte)
+ blue:(useCol blueByte)
+ ]
].
self color:index.
@@ -898,23 +900,23 @@
invalidate
lockCriticalTask critical:[
- isInvalid := true.
+ isInvalid := true.
- criticalTask isNil ifTrue:[
- criticalTask := [
- [ |repeat|
+ criticalTask isNil ifTrue:[
+ criticalTask := [
+ [ |repeat|
- lockCriticalTask critical:[
- (repeat := isInvalid) ifTrue:[isInvalid := false]
- ifFalse:[criticalTask := nil]
- ].
- repeat ifTrue:[ self criticalRedrawRoutine ].
- repeat
+ lockCriticalTask critical:[
+ (repeat := isInvalid) ifTrue:[isInvalid := false]
+ ifFalse:[criticalTask := nil]
+ ].
+ repeat ifTrue:[ self criticalRedrawRoutine ].
+ repeat
- ] whileTrue:[ Processor yield ].
+ ] whileTrue:[ Processor yield ].
- ] forkAt:( Processor activePriority - 1 ).
- ]
+ ] forkAt:( Processor activePriority - 1 ).
+ ]
]
!
@@ -959,5 +961,5 @@
!GraphColumnView3D class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libwidg2/GraphColumnView3D.st,v 1.8 1998-03-09 16:10:52 ca Exp $'
+ ^ '$Header: /cvs/stx/stx/libwidg2/GraphColumnView3D.st,v 1.9 2006-11-13 16:11:30 cg Exp $'
! !