# TwoDimensionalViewport¶

view2D.spad line 397 [edit on github]

TwoDimensionalViewport creates viewports to display graphs.

- axes: (%, PositiveInteger, Palette) -> Void
`axes(v, n, c)`

displays the axes of the graph in field`n`

of the given two-dimensional viewport,`v`

, which is of domain TwoDimensionalViewport, with the axes color set to the given palette color`c`

.

- axes: (%, PositiveInteger, String) -> Void
`axes(v, n, s)`

displays the axes of the graph in field`n`

of the given two-dimensional viewport,`v`

, which is of domain TwoDimensionalViewport, if`s`

is “on”, or does not display the axes if`s`

is “off”.

- close: % -> Void
`close(v)`

closes the viewport window of the given two-dimensional viewport,`v`

, which is of domain TwoDimensionalViewport, and terminates the corresponding process ID.

- coerce: % -> OutputForm
`coerce(v)`

returns the given two-dimensional viewport,`v`

, which is of domain TwoDimensionalViewport as output of the domain OutputForm.

- connect: (%, PositiveInteger, String) -> Void
`connect(v, n, s)`

displays the lines connecting the graph points in field`n`

of the given two-dimensional viewport,`v`

, which is of domain TwoDimensionalViewport, if`s`

is “on”, or does not display the lines if`s`

is “off”.

- controlPanel: (%, String) -> Void
`controlPanel(v, s)`

displays the control panel of the given two-dimensional viewport,`v`

, which is of domain TwoDimensionalViewport, if`s`

is “on”, or hides the control panel if`s`

is “off”.

- dimensions: (%, NonNegativeInteger, NonNegativeInteger, PositiveInteger, PositiveInteger) -> Void
`dimensions(v, x, y, width, height)`

sets the position of the upper left-hand corner of the two-dimensional viewport,`v`

, which is of domain TwoDimensionalViewport, to the window coordinate`x`

,`y`

, and sets the dimensions of the window to that of`width`

,`height`

. The new dimensions are not displayed until the function makeViewport2D is executed again for`v`

.

- getGraph: (%, PositiveInteger) -> GraphImage
`getGraph(v, n)`

returns the graph which is of the domain GraphImage which is located in graph field`n`

of the given two-dimensional viewport,`v`

, which is of the domain TwoDimensionalViewport.

- getPickedPoints: % -> List Point DoubleFloat
`getPickedPoints(x)`

returns a list of small floats for the points the user interactively picked on the viewport for full integration into the system, some design issues need to be addressed: e.g. how to go through the GraphImage interface, how to default to graphs, etc.

- graphs: % -> Vector Union(GraphImage, undefined)
`graphs(v)`

returns a vector, or list, which is a union of all the graphs, of the domain GraphImage, which are allocated for the two-dimensional viewport,`v`

, of domain TwoDimensionalViewport. Those graphs which have no data are labeled “undefined”, otherwise their contents are shown.

- graphState: (%, PositiveInteger, DoubleFloat, DoubleFloat, DoubleFloat, DoubleFloat, Integer, Integer, Integer, Integer, Palette, Integer, Palette, Integer) -> Void
`graphState(v, num, sX, sY, dX, dY, pts, lns, box, axes, axesC, un, unC, cP)`

sets the state of the characteristics for the graph indicated by`num`

in the given two-dimensional viewport`v`

, of domain TwoDimensionalViewport, to the values given as parameters. The scaling of the graph in the`x`

and`y`

component directions is set to be`sX`

and`sY`

; the window translation in the`x`

and`y`

component directions is set to be`dX`

and`dY`

; The graph points, lines, bounding`box`

,`axes`

, or units will be shown in the viewport if their given parameters`pts`

,`lns`

,`box`

,`axes`

or`un`

are set to be`1`

, but will not be shown if they are set to`0`

. The color of the`axes`

and the color of the units are indicated by the palette colors`axesC`

and`unC`

respectively. To display the control panel when the viewport window is displayed, set`cP`

to`1`

, otherwise set it to`0`

.

- graphStates: % -> Vector Record(scaleX: DoubleFloat, scaleY: DoubleFloat, deltaX: DoubleFloat, deltaY: DoubleFloat, points: Integer, connect: Integer, spline: Integer, axes: Integer, axesColor: Palette, units: Integer, unitsColor: Palette, showing: Integer)
`graphStates(v)`

returns and shows a listing of a record containing the current state of the characteristics of each of the ten graph records in the given two-dimensional viewport,`v`

, which is of domain TwoDimensionalViewport.

- key: % -> Integer
`key(v)`

returns the process ID number of the given two-dimensional viewport,`v`

, which is of domain TwoDimensionalViewport.

- latex: % -> String
from SetCategory

- makeViewport2D: % -> %
`makeViewport2D(v)`

takes the given two-dimensional viewport,`v`

, of the domain TwoDimensionalViewport and displays a viewport window on the screen which contains the contents of`v`

.

- makeViewport2D: (GraphImage, List DrawOption) -> %
`makeViewport2D(gi, lopt)`

creates and displays a viewport window of the domain TwoDimensionalViewport whose graph field is assigned to be the given graph,`gi`

, of domain GraphImage, and whose options field is set to be the list of options,`lopt`

of domain DrawOption.

- move: (%, NonNegativeInteger, NonNegativeInteger) -> Void
`move(v, x, y)`

displays the two-dimensional viewport,`v`

, which is of domain TwoDimensionalViewport, with the upper left-hand corner of the viewport window at the screen coordinate position`x`

,`y`

.

- options: % -> List DrawOption
`options(v)`

takes the given two-dimensional viewport,`v`

, of the domain TwoDimensionalViewport and returns a list containing the draw options from the domain DrawOption for`v`

.

- options: (%, List DrawOption) -> %
`options(v, lopt)`

takes the given two-dimensional viewport,`v`

, of the domain TwoDimensionalViewport and returns`v`

with it`'s`

draw options modified to be those which are indicated in the given list,`lopt`

of domain DrawOption.

- points: (%, PositiveInteger, String) -> Void
`points(v, n, s)`

displays the points of the graph in field`n`

of the given two-dimensional viewport,`v`

, which is of domain TwoDimensionalViewport, if`s`

is “on”, or does not display the points if`s`

is “off”.

- putGraph: (%, GraphImage, PositiveInteger) -> Void
`putGraph(v, gi, n)`

sets the graph field indicated by`n`

, of the indicated two-dimensional viewport,`v`

, which is of domain TwoDimensionalViewport, to be the graph,`gi`

of domain GraphImage. The contents of viewport,`v`

, will contain`gi`

when the function makeViewport2D is called to create the an updated viewport`v`

.

- region: (%, PositiveInteger, String) -> Void
`region(v, n, s)`

displays the bounding box of the graph in field`n`

of the given two-dimensional viewport,`v`

, which is of domain TwoDimensionalViewport, if`s`

is “on”, or does not display the bounding box if`s`

is “off”.

- reset: % -> Void
`reset(v)`

sets the current state of the graph characteristics of the given two-dimensional viewport,`v`

, which is of domain TwoDimensionalViewport, back to their initial settings.

- resize: (%, PositiveInteger, PositiveInteger) -> Void
`resize(v, w, h)`

displays the two-dimensional viewport,`v`

, which is of domain TwoDimensionalViewport, with a width of`w`

and a height of`h`

, keeping the upper left-hand corner position unchanged.

- scale: (%, PositiveInteger, Float, Float) -> Void
`scale(v, n, sx, sy)`

displays the graph in field`n`

of the given two-dimensional viewport,`v`

, which is of domain TwoDimensionalViewport, scaled by the factor`sx`

in the`x`

-coordinate direction and by the factor`sy`

in the`y`

-coordinate direction.

- show: (%, PositiveInteger, String) -> Void
`show(v, n, s)`

displays the graph in field`n`

of the given two-dimensional viewport,`v`

, which is of domain TwoDimensionalViewport, if`s`

is “on”, or does not display the graph if`s`

is “off”.

- title: (%, String) -> Void
`title(v, s)`

changes the title which is shown in the two-dimensional viewport window,`v`

of domain TwoDimensionalViewport.

- translate: (%, PositiveInteger, Float, Float) -> Void
`translate(v, n, dx, dy)`

displays the graph in field`n`

of the given two-dimensional viewport,`v`

, which is of domain TwoDimensionalViewport, translated by`dx`

in the`x`

-coordinate direction from the center of the viewport, and by`dy`

in the`y`

-coordinate direction from the center. Setting`dx`

and`dy`

to`0`

places the center of the graph at the center of the viewport.

- units: (%, PositiveInteger, Palette) -> Void
`units(v, n, c)`

displays the units of the graph in field`n`

of the given two-dimensional viewport,`v`

, which is of domain TwoDimensionalViewport, with the units color set to the given palette color`c`

.

- units: (%, PositiveInteger, String) -> Void
`units(v, n, s)`

displays the units of the graph in field`n`

of the given two-dimensional viewport,`v`

, which is of domain TwoDimensionalViewport, if`s`

is “on”, or does not display the units if`s`

is “off”.

- update: (%, GraphImage, PositiveInteger) -> Void
`update(v, gr, n)`

drops the graph`gr`

in slot`n`

of viewport`v`

. The graph`gr`

must have been transmitted already and acquired an integer key.

- viewport2D: () -> %
`viewport2D()`

returns an undefined two-dimensional viewport of the domain TwoDimensionalViewport whose contents are empty.

- write: (%, String) -> String
`write(v, s)`

takes the given two-dimensional viewport,`v`

, which is of domain TwoDimensionalViewport, and creates a directory indicated by`s`

, which contains the graph data files for`v`

.

- write: (%, String, List String) -> String
`write(v, s, lf)`

takes the given two-dimensional viewport,`v`

, which is of domain TwoDimensionalViewport, and creates a directory indicated by`s`

, which contains the graph data files for`v`

and the optional file types indicated by the list`lf`

.

- write: (%, String, String) -> String
`write(v, s, f)`

takes the given two-dimensional viewport,`v`

, which is of domain TwoDimensionalViewport, and creates a directory indicated by`s`

, which contains the graph data files for`v`

and an optional file type`f`

.