Skip to content

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

NameTypeAttributesDescription
linesinteger(kind=I1P)allocatablePolylines.
nlinteger(kind=I4P)Bytes of lines used.
quadsinteger(kind=I1P)allocatableFilled polygons.
nqinteger(kind=I4P)Bytes of quads used.
pointsinteger(kind=I1P)allocatablePoints.
npinteger(kind=I4P)Bytes of points used.
textsinteger(kind=I1P)allocatableTexts.
ntinteger(kind=I4P)Bytes of texts used.

Type-Bound Procedures

NameAttributesDescription
add_linepass(self)A polyline (axis values; breaks at undefined points).
add_polypass(self)A filled polygon (axis values).
add_pointpass(self)A point.
add_textpass(self)A text at a point.
jsonpass(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

fortran
subroutine put(buffer, used, piece)

Arguments

NameTypeIntentAttributesDescription
bufferinteger(kind=I1P)inoutallocatableBytes.
usedinteger(kind=I4P)inoutBytes used.
piececharacter(len=*)inPiece.

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

fortran
subroutine add_line(self, f, x, y, z, color, width, dash)

Arguments

NameTypeIntentAttributesDescription
selfclass(scene3d_object)inoutScene.
ftype(view3d_frame)inThe view.
xreal(kind=R8P)inAbscissae.
yreal(kind=R8P)inOrdinates.
zreal(kind=R8P)inHeights.
colorcharacter(len=*)inColor.
widthreal(kind=R8P)inWidth [px].
dashcharacter(len=*)inSVG 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

fortran
subroutine add_poly(self, f, x, y, z, fill, stroke)

Arguments

NameTypeIntentAttributesDescription
selfclass(scene3d_object)inoutScene.
ftype(view3d_frame)inThe view.
xreal(kind=R8P)inAbscissae.
yreal(kind=R8P)inOrdinates.
zreal(kind=R8P)inHeights.
fillcharacter(len=*)inFill color.
strokecharacter(len=*)inBorder color, empty for none.

Call graph

add_point ​

A round point at (x, y, z) (axis values), if in the box.

Attributes: pure

fortran
subroutine add_point(self, f, x, y, z, color, radius)

Arguments

NameTypeIntentAttributesDescription
selfclass(scene3d_object)inoutScene.
ftype(view3d_frame)inThe view.
xreal(kind=R8P)inAbscissa.
yreal(kind=R8P)inOrdinate.
zreal(kind=R8P)inHeight.
colorcharacter(len=*)inColor.
radiusreal(kind=R8P)inRadius [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

fortran
subroutine add_text(self, f, text, x, y, z, anchor, color)

Arguments

NameTypeIntentAttributesDescription
selfclass(scene3d_object)inoutScene.
ftype(view3d_frame)inThe view.
textcharacter(len=*)inText.
xreal(kind=R8P)inAbscissa.
yreal(kind=R8P)inOrdinate.
zreal(kind=R8P)inHeight.
anchorcharacter(len=*)inAnchor.
colorcharacter(len=*)inColor, 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)

fortran
function cube(f, x, y, z) result(p)

Arguments

NameTypeIntentAttributesDescription
ftype(view3d_frame)inThe view.
xreal(kind=R8P)inAbscissa.
yreal(kind=R8P)inOrdinate.
zreal(kind=R8P)inHeight.

Call graph

num ​

v with 4 decimals, no trailing zeros (JSON).

Attributes: pure

Returns: character(len=:)

fortran
function num(v) result(s)

Arguments

NameTypeIntentAttributesDescription
vreal(kind=R8P)inValue.

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=:)

fortran
function str(text) result(s)

Arguments

NameTypeIntentAttributesDescription
textcharacter(len=*)inText.

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=:)

fortran
function coords(f, x, y, z) result(s)

Arguments

NameTypeIntentAttributesDescription
ftype(view3d_frame)inThe view.
xreal(kind=R8P)inAbscissae.
yreal(kind=R8P)inOrdinates.
zreal(kind=R8P)inHeights.

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=:)

fortran
function json(self, f, rot_x, rot_z, scale, azimuth, keep) result(s)

Arguments

NameTypeIntentAttributesDescription
selfclass(scene3d_object)inScene.
ftype(view3d_frame)inThe view.
rot_xreal(kind=R8P)inRotation about x [deg].
rot_zreal(kind=R8P)inRotation about z [deg].
scalereal(kind=R8P)inView scale.
azimuthreal(kind=R8P)inAzimuth [deg].
keepcharacter(len=*)inText 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=:)

fortran
function part(buffer, used) result(t)

Arguments

NameTypeIntentAttributesDescription
bufferinteger(kind=I1P)inallocatablePart.
usedinteger(kind=I4P)inBytes used.

Call graph

finite3 ​

Whether the three values are finite (not NaN nor infinite).

Attributes: pure

Returns: logical

fortran
function finite3(x, y, z) result(yes)

Arguments

NameTypeIntentAttributesDescription
xreal(kind=R8P)inValues.
yreal(kind=R8P)inValues.
zreal(kind=R8P)inValues.

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

fortran
function inside(f, x, y, z) result(yes)

Arguments

NameTypeIntentAttributesDescription
ftype(view3d_frame)inThe view.
xreal(kind=R8P)inAbscissa.
yreal(kind=R8P)inOrdinate.
zreal(kind=R8P)inHeight.

Call graph

within ​

Whether v lies between the ends (either order, a relative tolerance of 1e-9 of their span).

Attributes: pure

Returns: logical

fortran
function within(v, ends) result(yes)

Arguments

NameTypeIntentAttributesDescription
vreal(kind=R8P)inValue.
endsreal(kind=R8P)inEnds.

Call graph

Released under the GPL v3, BSD 2-Clause, BSD 3-Clause or MIT License.