foresight_scene3d
foresight_scene3d, the scene of a 3D view for the HTML viewer's mouse rotation.
A 3D panel of an HTML page carries its scene: the lines, filled polygons, points and texts of the view in the box's normalized coordinates (-1..1 over the box, gnuplot's map3d_xyz before its transform), with the view's rotation, scale and frame. The viewer re-projects them with the same transform when the mouse turns the view (a painter's algorithm, farthest first); the page itself is foresight's static drawing of the script's view. Coordinates are written with 4 decimals (a tenth of a pixel on a 1000 px plot), as JSON: {"v":[rot_x,rot_z,scale,azimuth],"f":[xmiddle,ymiddle,xscaler,yscaler,height],"keep":"title", "l":[[color,width,dash,[x,y,z,...]],...],"q":[[fill,stroke,[x,y,z,...]],...],"p":[[color,radius,[x,y,z,...]],...], "t":[[text,x,y,z,anchor,color],...]}.
Source: src/lib/foresight_scene3d.F90
Dependencies
Contents
Derived Types
scene3d_object
The scene of a 3D view: its parts as JSON arrays, being written, as bytes (nvfortran 26.9 corrupts the heap growing a deferred-length character component by move_alloc).
Components
| Name | Type | Attributes | Description |
|---|---|---|---|
lines | integer(kind=I1P) | allocatable | Polylines. |
nl | integer(kind=I4P) | Bytes of lines used. | |
quads | integer(kind=I1P) | allocatable | Filled polygons. |
nq | integer(kind=I4P) | Bytes of quads used. | |
points | integer(kind=I1P) | allocatable | Points. |
np | integer(kind=I4P) | Bytes of points used. | |
texts | integer(kind=I1P) | allocatable | Texts. |
nt | integer(kind=I4P) | Bytes of texts used. |
Type-Bound Procedures
| Name | Attributes | Description |
|---|---|---|
add_line | pass(self) | A polyline (axis values; breaks at undefined points). |
add_poly | pass(self) | A filled polygon (axis values). |
add_point | pass(self) | A point. |
add_text | pass(self) | A text at a point. |
json | pass(self) | The scene as JSON. |
Subroutines
put
piece appended to the bytes buffer(1:used), a comma before it unless first, doubling the buffer as needed.
Attributes: pure
subroutine put(buffer, used, piece)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
buffer | integer(kind=I1P) | inout | allocatable | Bytes. |
used | integer(kind=I4P) | inout | Bytes used. | |
piece | character(len=*) | in | Piece. |
Call graph
add_line
A polyline through the points (x, y, z) (axis values), broken at the undefined ones and out of the box.
Attributes: pure
subroutine add_line(self, f, x, y, z, color, width, dash)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(scene3d_object) | inout | Scene. | |
f | type(view3d_frame) | in | The view. | |
x | real(kind=R8P) | in | Abscissae. | |
y | real(kind=R8P) | in | Ordinates. | |
z | real(kind=R8P) | in | Heights. | |
color | character(len=*) | in | Color. | |
width | real(kind=R8P) | in | Width [px]. | |
dash | character(len=*) | in | SVG dash array, empty for solid. |
Call graph
add_poly
A filled polygon of corners (x, y, z) (axis values), dropped if a corner is undefined.
Attributes: pure
subroutine add_poly(self, f, x, y, z, fill, stroke)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(scene3d_object) | inout | Scene. | |
f | type(view3d_frame) | in | The view. | |
x | real(kind=R8P) | in | Abscissae. | |
y | real(kind=R8P) | in | Ordinates. | |
z | real(kind=R8P) | in | Heights. | |
fill | character(len=*) | in | Fill color. | |
stroke | character(len=*) | in | Border color, empty for none. |
Call graph
add_point
A round point at (x, y, z) (axis values), if in the box.
Attributes: pure
subroutine add_point(self, f, x, y, z, color, radius)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(scene3d_object) | inout | Scene. | |
f | type(view3d_frame) | in | The view. | |
x | real(kind=R8P) | in | Abscissa. | |
y | real(kind=R8P) | in | Ordinate. | |
z | real(kind=R8P) | in | Height. | |
color | character(len=*) | in | Color. | |
radius | real(kind=R8P) | in | Radius [px]. |
Call graph
add_text
The text anchored (start, middle, end) at (x, y, z) (axis values; z in the z axis's linear space as the box heights are).
Attributes: pure
subroutine add_text(self, f, text, x, y, z, anchor, color)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(scene3d_object) | inout | Scene. | |
f | type(view3d_frame) | in | The view. | |
text | character(len=*) | in | Text. | |
x | real(kind=R8P) | in | Abscissa. | |
y | real(kind=R8P) | in | Ordinate. | |
z | real(kind=R8P) | in | Height. | |
anchor | character(len=*) | in | Anchor. | |
color | character(len=*) | in | Color, empty for the default. |
Call graph
Functions
cube
The box coordinates (-1..1 over the box) of the point (x, y, z) in axis values (view3d_xyz before the transform).
Attributes: pure
Returns: real(kind=R8P)
function cube(f, x, y, z) result(p)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
f | type(view3d_frame) | in | The view. | |
x | real(kind=R8P) | in | Abscissa. | |
y | real(kind=R8P) | in | Ordinate. | |
z | real(kind=R8P) | in | Height. |
Call graph
num
v with 4 decimals, no trailing zeros (JSON).
Attributes: pure
Returns: character(len=:)
function num(v) result(s)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
v | real(kind=R8P) | in | Value. |
Call graph
str
text as a JSON string, &, < and > as their \u escapes: the scene goes into the page's XML as it is.
Attributes: pure
Returns: character(len=:)
function str(text) result(s)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
text | character(len=*) | in | Text. |
Call graph
coords
The box coordinates of the points (x, y, z), as a JSON array of x, y, z triples.
Attributes: pure
Returns: character(len=:)
function coords(f, x, y, z) result(s)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
f | type(view3d_frame) | in | The view. | |
x | real(kind=R8P) | in | Abscissae. | |
y | real(kind=R8P) | in | Ordinates. | |
z | real(kind=R8P) | in | Heights. |
Call graph
json
The scene as JSON, with the view (rot_x, rot_z, the scale gnuplot's surface_scale, azimuth), its frame and the text of the panel's static drawing kept while turning (its title).
Attributes: pure
Returns: character(len=:)
function json(self, f, rot_x, rot_z, scale, azimuth, keep) result(s)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(scene3d_object) | in | Scene. | |
f | type(view3d_frame) | in | The view. | |
rot_x | real(kind=R8P) | in | Rotation about x [deg]. | |
rot_z | real(kind=R8P) | in | Rotation about z [deg]. | |
scale | real(kind=R8P) | in | View scale. | |
azimuth | real(kind=R8P) | in | Azimuth [deg]. | |
keep | character(len=*) | in | Text kept (the title), empty for none. |
Call graph
part
The used bytes of a scene part as text, empty if none.
Attributes: pure
Returns: character(len=:)
function part(buffer, used) result(t)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
buffer | integer(kind=I1P) | in | allocatable | Part. |
used | integer(kind=I4P) | in | Bytes used. |
Call graph
finite3
Whether the three values are finite (not NaN nor infinite).
Attributes: pure
Returns: logical
function finite3(x, y, z) result(yes)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
x | real(kind=R8P) | in | Values. | |
y | real(kind=R8P) | in | Values. | |
z | real(kind=R8P) | in | Values. |
Call graph
inside
Whether the point (x, y, z) is defined and within the box (in the linear spaces of the axes, a tolerance).
Attributes: pure
Returns: logical
function inside(f, x, y, z) result(yes)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
f | type(view3d_frame) | in | The view. | |
x | real(kind=R8P) | in | Abscissa. | |
y | real(kind=R8P) | in | Ordinate. | |
z | real(kind=R8P) | in | Height. |
Call graph
within
Whether v lies between the ends (either order, a relative tolerance of 1e-9 of their span).
Attributes: pure
Returns: logical
function within(v, ends) result(yes)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
v | real(kind=R8P) | in | Value. | |
ends | real(kind=R8P) | in | Ends. |
Call graph