|
Class: SimpleFunctionGraphView
Object
|
+--GraphicsMedium
|
+--DisplaySurface
|
+--SimpleView
|
+--View
|
+--SimpleFunctionGraphView
- Package:
- stx:libwidg3
- Category:
- Views-Graphs
- Version:
- rev:
1.9
date: 2023/07/06 14:35:56
- user: cg
- file: SimpleFunctionGraphView.st directory: libwidg3
- module: stx stc-classLibrary: libwidg3
A very quick and dirty (and simple) hack to
display a graph of a function.
TODO: grid & scale drawing.
copyrightCOPYRIGHT (c) 1997 by eXept Software AG
All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
inclusion of the above copyright notice. This software may not
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
accessing
-
autoScaleHolder: aValueHolder
-
set the value of the instance variable 'minXHolder' (automatically generated)
-
displayModeHolder
-
return the value of the instance variable 'displayModeHolder' (automatically generated)
-
displayModeHolder: aValueHolder
-
set the value of the instance variable 'displayModeHolder' (automatically generated)
-
function: aBlock
-
(comment from inherited method)
set the drawing function if it has changed.
The argument is one of:
#copy,#copyInverted,#xor,#and,#andReverse
#andInverted,#or,#orReverse,#orInverted
#invert,#clear,#set,#noop,#equiv,#nand
Notice: not all graphicMedia support all functions
-
functionHolder
-
return the value of the instance variable 'functionHolder' (automatically generated)
-
functionHolder: aValueHolder
-
set the value of the instance variable 'functionHolder' (automatically generated)
-
graphColorHolder
-
return the value of the instance variable 'graphColorHolder' (automatically generated)
-
graphColorHolder: aValueHolder
-
set the value of the instance variable 'graphColorHolder' (automatically generated)
-
gridColorHolder
-
return the value of the instance variable 'gridColorHolder' (automatically generated)
-
gridColorHolder: aValueHolder
-
set the value of the instance variable 'gridColorHolder' (automatically generated)
-
invalidColorHolder
-
return the value of the instance variable 'invalidColorHolder' (automatically generated)
-
invalidColorHolder: aValueHolder
-
set the value of the instance variable 'invalidColorHolder' (automatically generated)
-
markInvalidHolder
-
return the value of the instance variable 'markInvalidHolder' (automatically generated)
-
markInvalidHolder: aValueHolder
-
set the value of the instance variable 'markInvalidHolder' (automatically generated)
-
maxXHolder
-
return the value of the instance variable 'maxXHolder' (automatically generated)
-
maxXHolder: aValueHolder
-
set the value of the instance variable 'maxXHolder' (automatically generated)
-
maxYHolder
-
return the value of the instance variable 'maxYHolder' (automatically generated)
-
maxYHolder: aValueHolder
-
set the value of the instance variable 'maxYHolder' (automatically generated)
-
minXHolder
-
return the value of the instance variable 'minXHolder' (automatically generated)
-
minXHolder: aValueHolder
-
set the value of the instance variable 'minXHolder' (automatically generated)
-
minYHolder
-
return the value of the instance variable 'minYHolder' (automatically generated)
-
minYHolder: aValueHolder
-
set the value of the instance variable 'minYHolder' (automatically generated)
-
showGridHolder
-
return the value of the instance variable 'showGridHolder' (automatically generated)
-
showGridHolder: aValueHolder
-
set the value of the instance variable 'showGridHolder' (automatically generated)
-
showUnitsXHolder
-
return the value of the instance variable 'showUnitsXHolder' (automatically generated)
-
showUnitsXHolder: aValueHolder
-
set the value of the instance variable 'showUnitsXHolder' (automatically generated)
-
showUnitsYHolder
-
return the value of the instance variable 'showUnitsYHolder' (automatically generated)
-
showUnitsYHolder: aValueHolder
-
set the value of the instance variable 'showUnitsYHolder' (automatically generated)
-
unitColorHolder
-
return the value of the instance variable 'unitColorHolder' (automatically generated)
-
unitColorHolder: aValueHolder
-
set the value of the instance variable 'unitColorHolder' (automatically generated)
change & update
-
sizeChanged: how from: oldExtentOrNil
-
my view has changed the size (not the contents)
-
update: something with: someArgument from: changedObject
-
something changed - for now, do a full redraw
drawing
-
chooseGrid
-
for every centimeter on the display ...
-
computeGraph
-
compute the graph
-
drawAxis
-
stepX := rangeX / nSteps.
-
redrawX: x y: y width: w height: h
-
redraw the graph
-
test: arg
-
redraw the graph
Usage example(s):
|top graphView|
top := StandardSystemView extent:300@300.
graphView := SimpleFunctionGraphView origin:0.0@0.0 corner:1.0@1.0 in:top.
graphView minXHolder:(-5 asValue).
graphView maxXHolder:(5 asValue).
graphView minYHolder:(-2 asValue).
graphView maxYHolder:(2 asValue).
graphView function:[:x | x sin].
top open.
|
|top graphView|
top := StandardSystemView extent:300@300.
graphView := SimpleFunctionGraphView origin:0.0@0.0 corner:1.0@1.0 in:top.
graphView graphColorHolder:(Color white).
graphView backgroundColor:Color black.
graphView minXHolder:(-5 asValue).
graphView maxXHolder:(5 asValue).
graphView minYHolder:(-2 asValue).
graphView maxYHolder:(2 asValue).
graphView function:[:x | x sin].
top open.
|
|top graphView minX maxX|
top := StandardSystemView extent:300@300.
graphView := SimpleFunctionGraphView origin:0.0@0.0 corner:1.0@1.0 in:top.
graphView graphColorHolder:(Color white).
graphView backgroundColor:Color black.
graphView minXHolder:(minX := -5 asValue).
graphView maxXHolder:(maxX := 5 asValue).
graphView minYHolder:(-2 asValue).
graphView maxYHolder:(2 asValue).
graphView function:[:x | x sin].
top openAndWaitUntilVisible.
[
[top realized] whileTrue:[
Delay waitForSeconds:0.05.
minX value:(minX value + 0.1).
maxX value:(maxX value + 0.1).
]
] fork
|
|top graphView functionList|
functionList := OrderedCollection new.
functionList add:[:x | x].
functionList add:[:x | x * x].
functionList add:[:x | x sqrt].
functionList add:[:x | x sin].
functionList add:[:x | x cos].
functionList add:[:x | x tan].
functionList add:[:x | x log].
functionList add:[:x | x exp].
functionList add:[:x | 0].
top := StandardSystemView extent:300@300.
graphView := SimpleFunctionGraphView origin:0.0@0.0 corner:1.0@1.0 in:top.
graphView graphColorHolder:(Color white).
graphView backgroundColor:Color black.
graphView minXHolder:(-5 asValue).
graphView maxXHolder:(5 asValue).
graphView minYHolder:(-2 asValue).
graphView maxYHolder:(2 asValue).
graphView displayModeHolder:(#lineMode asValue).
graphView function:(functionList last).
top openAndWaitUntilVisible.
[
[top realized] whileTrue:[
functionList do:[:funcBlock |
Delay waitForSeconds:1.
graphView displayModeHolder value:#dotMode.
Delay waitForSeconds:1.
graphView displayModeHolder value:#lineMode.
Delay waitForSeconds:1.
graphView displayModeHolder value:#dotMode.
Delay waitForSeconds:1.
graphView displayModeHolder value:#lineMode.
graphView functionHolder value:funcBlock.
]
]
] fork
|
|