LineChain Derived Type

type, public :: LineChain

A chain of point buffers (see the module documentation).


Inherits

type~~linechain~~InheritsGraph type~linechain LineChain c_ptr c_ptr type~linechain->c_ptr group, image type~linechunk LineChunk type~linechain->type~linechunk chunks type~linechunk->c_ptr line type~lodlevel LodLevel type~linechunk->type~lodlevel lod

Inherited by

type~~linechain~~InheritedByGraph type~linechain LineChain type~chainartist ChainArtist type~chainartist->type~linechain chain type~customlinesegments CustomLineSegments type~customlinesegments->type~linechain chain type~markerartist MarkerArtist type~markerartist->type~linechain start_node, end_node, inter type~segmentartist SegmentArtist type~segmentartist->type~linechain chain type~curveartist CurveArtist type~curveartist->type~chainartist type~ribbonartist RibbonArtist type~ribbonartist->type~chainartist

Components

Type Visibility Attributes Name Initial
type(LineChunk), private, allocatable :: chunks(:)

(capacity): the chunks, in chain order

real(kind=c_float), private :: color(4) = 1.0_c_float

[r, g, b, a] (0 to 1)

logical, private :: colored = .false.

(lines, markers: a color per point (color_slice))

logical, private :: compile_new = .false.

chunks made from now on are compiled (the group is shown)

real(kind=wp), private :: dash_length = 0.0_wp

(2: the pattern's length, scene units; 0 from the first view)

integer, private :: dash_mode = 0

(lines: 0 anchored, 1 screen-locked, 2 fixed length)

type(c_ptr), private :: group = c_null_ptr

the group node the chunks are under (null: not built)

real(kind=c_float), private :: highlight(12) = [1.0_c_float, 1.0_c_float, 1.0_c_float, 1.0_c_float, 0.0_c_float, 40.0_c_float, 50.0_c_float, 12.0_c_float, 1.5_c_float, 0.0_c_float, 0.0_c_float, 0.0_c_float]

(lines: highlight, see vkf_line_set_highlight)

type(c_ptr), private :: image = c_null_ptr

(markers: the image (shape 10))

integer, private :: kind = CHAIN_STRIP

what is drawn: a CHAIN_* constant

logical, private :: lod = .true.

(strips: level of detail (else every point drawn))

integer, private :: n_chunks = 0

number of chunks

integer, private :: pattern = int(z'FFFF')

(lines: 16-bit dash pattern (z'FFFF': solid))

integer, private :: pattern_factor = 1

(lines: dash pattern (see line_set_pattern))

real(kind=c_float), private :: radius = 0.0_c_float

(markers: attenuation radius)

integer, private :: shape = 0

markers

real(kind=c_float), private :: trail(20) = 0.0_c_float

(strips: the trail, see vkf_line_set_trail; z = 0: none)

real(kind=c_float), private :: width = 1.0_c_float

line width, or marker size


Type-Bound Procedures

procedure, public :: chunk_bounds

  • private subroutine chunk_bounds(self, j, first, n, lo, hi)

    Chunk j's points (strips: first .. first + n - 1 of the chain) and the bounding box of them (n = 0 if none are measured yet), e.g. to skip a chunk when picking.

    Arguments

    Type IntentOptional Attributes Name
    class(LineChain), intent(in) :: self
    integer, intent(in) :: j

    the chunk

    integer, intent(out) :: first

    its first point (chain index), and points written (0: none)

    integer, intent(out) :: n

    its first point (chain index), and points written (0: none)

    real(kind=wp), intent(out) :: lo(3)

    the bounding box's corners

    real(kind=wp), intent(out) :: hi(3)

    the bounding box's corners

procedure, public :: color_slice

  • private subroutine color_slice(self, j, i1, i2, lo, hi, c)

    As slice, for the colors of a colored chain: c(rgba, point) of points lo .. hi of chunk j (null if not colored or nothing there).

    Arguments

    Type IntentOptional Attributes Name
    class(LineChain), intent(in) :: self
    integer, intent(in) :: j

    the chunk, and points i1 .. i2 (chain indices)

    integer, intent(in) :: i1

    the chunk, and points i1 .. i2 (chain indices)

    integer, intent(in) :: i2

    the chunk, and points i1 .. i2 (chain indices)

    integer, intent(out) :: lo

    chain indices (lo > hi: none)

    integer, intent(out) :: hi

    chain indices (lo > hi: none)

    real(kind=c_float), intent(out), dimension(:,:), pointer :: c

    (4, hi-lo+1): [r, g, b, a]

procedure, public :: dash_mode_of

  • private pure function dash_mode_of(self)

    The dashes' layout (set_dash_mode).

    Arguments

    Type IntentOptional Attributes Name
    class(LineChain), intent(in) :: self

    Return Value integer

procedure, public :: detach

  • private subroutine detach(self)

    Remove the chunks from the group (also while running), and release them.

    Arguments

    Type IntentOptional Attributes Name
    class(LineChain), intent(inout) :: self

procedure, public :: distance

  • private function distance(self, i) result(s)

    A strip's distance along it at point i, as written.

    Arguments

    Type IntentOptional Attributes Name
    class(LineChain), intent(in) :: self
    integer, intent(in) :: i

    chain index

    Return Value real(kind=wp)

procedure, public :: draw

  • private subroutine draw(self, k)

    Draw points 1 .. k (no upload).

    Arguments

    Type IntentOptional Attributes Name
    class(LineChain), intent(in) :: self
    integer, intent(in) :: k

    last point drawn (chain index)

procedure, public :: draw_range

  • private subroutine draw_range(self, i1, i2)

    Draw points i1 .. i2 only (chain indices; none if i2 < i1): e.g. a trace of decreasing times, its last points.

    Arguments

    Type IntentOptional Attributes Name
    class(LineChain), intent(in) :: self
    integer, intent(in) :: i1

    first and last points drawn (chain indices)

    integer, intent(in) :: i2

    first and last points drawn (chain indices)

procedure, public :: init

  • private subroutine init(self, group, kind, image, colored)

    Draw under group (a CHAIN_* kind; markers with image, a vkf_image_read handle, for the image shape). Chunks made later are compiled once set_compile says so.

    Arguments

    Type IntentOptional Attributes Name
    class(LineChain), intent(inout) :: self
    type(c_ptr), intent(in) :: group

    the group node to draw under

    integer, intent(in) :: kind

    a CHAIN_* constant

    type(c_ptr), intent(in), optional :: image

    (markers: a vkf_image_read handle)

    logical, intent(in), optional :: colored

    (lines, markers: a color per point (color_slice))

procedure, public :: is_built

  • private pure function is_built(self)

    True if the chain has a group to draw under (between init and release).

    Arguments

    Type IntentOptional Attributes Name
    class(LineChain), intent(in) :: self

    Return Value logical

procedure, public :: is_colored

  • private pure function is_colored(self)

    For lines and markers, whether each point has its own color (init's colored).

    Arguments

    Type IntentOptional Attributes Name
    class(LineChain), intent(in) :: self

    Return Value logical

procedure, public :: lod_error

  • private function lod_error(self, j) result(error)

    Chunk j's error bounds: how far the points skipped can be from the segments drawn at stride 2^k (k = 1 .. lod_levels; 0 where not known).

    Arguments

    Type IntentOptional Attributes Name
    class(LineChain), intent(in) :: self
    integer, intent(in) :: j

    the chunk (outside 1 to the chunks: zeros)

    Return Value real(kind=c_float), (lod_levels)

procedure, public :: num_chunks

  • private pure function num_chunks(self)

    Number of chunks.

    Arguments

    Type IntentOptional Attributes Name
    class(LineChain), intent(in) :: self

    Return Value integer

procedure, public :: point

  • private function point(self, i) result(v)

    Point i as written: read back from the buffers (zero if not held).

    Arguments

    Type IntentOptional Attributes Name
    class(LineChain), intent(in) :: self
    integer, intent(in) :: i

    chain index

    Return Value real(kind=wp), (3)

procedure, public :: point_color

  • private function point_color(self, i) result(rgba)

    The color of point i of a colored chain, as stored (rgba; white if not colored).

    Arguments

    Type IntentOptional Attributes Name
    class(LineChain), intent(in) :: self
    integer, intent(in) :: i

    chain index

    Return Value real(kind=wp), (4)

procedure, public :: release

  • private subroutine release(self)

    Forget the chunks (after their group was removed from the scene): init starts again.

    Arguments

    Type IntentOptional Attributes Name
    class(LineChain), intent(inout) :: self

procedure, public :: reserve

  • private subroutine reserve(self, n)

    Chunks for at least n points (at least one chunk). Separate segments and ribbons: chunks hold whole pairs (n should be even).

    Arguments

    Type IntentOptional Attributes Name
    class(LineChain), intent(inout) :: self
    integer, intent(in) :: n

    number of points to hold

procedure, public :: set_compile

  • private subroutine set_compile(self, compile)

    Compile chunks made from now on (for the windows running): once the group is shown (not while building, when they are compiled with it).

    Arguments

    Type IntentOptional Attributes Name
    class(LineChain), intent(inout) :: self
    logical, intent(in) :: compile

    true: compile new chunks (once the group is shown)

procedure, public :: set_dash_mode

  • private subroutine set_dash_mode(self, mode, length)

    For lines, how the dashes are laid out: 0 anchored to the line (the default), 1 screen-locked (a constant length in pixels, following the line on screen), 2 a fixed length of the line (strips): length scene units for the pattern, or if 0 its length on screen when first drawn.

    Arguments

    Type IntentOptional Attributes Name
    class(LineChain), intent(inout) :: self
    integer, intent(in) :: mode

    0 anchored, 1 screen-locked, 2 fixed length

    real(kind=wp), intent(in) :: length

    (2) the pattern's length (scene units; 0: from the first view)

procedure, public :: set_highlight

  • private subroutine set_highlight(self, flags, color, spacing, speed, band, period)

    For lines, the highlight (see shaders/line.vert): flags (1 pulse, 2 arrows; 0 none), its color (rgba), the arrows' spacing and speed (window units, and per second), the band's width (window units) and the pulse's period (s).

    Arguments

    Type IntentOptional Attributes Name
    class(LineChain), intent(inout) :: self
    integer, intent(in) :: flags

    1 pulse + 2 arrows (0: none)

    real(kind=wp), intent(in) :: color(4)

    [r, g, b, a] (0 to 1)

    real(kind=wp), intent(in) :: spacing

    between arrows (window units)

    real(kind=wp), intent(in) :: speed

    of the arrows (window units per second)

    real(kind=wp), intent(in) :: band

    width of the band the arrows are drawn in (window units)

    real(kind=wp), intent(in) :: period

    of the pulse (s)

procedure, public :: set_lod

  • private subroutine set_lod(self, enabled)

    Level of detail on (the default: seen from far away, a strip is drawn from fewer points, within half a pixel of all of them) or off (every point drawn).

    Arguments

    Type IntentOptional Attributes Name
    class(LineChain), intent(inout) :: self
    logical, intent(in) :: enabled

    level of detail on (false: every point drawn)

procedure, public :: set_marker_style

  • private subroutine set_marker_style(self, color, size, shape, radius)

    For markers, the color (rgba), size (window units), shape (shaders/marker.frag) and attenuation radius (scene units, 0 for none).

    Arguments

    Type IntentOptional Attributes Name
    class(LineChain), intent(inout) :: self
    real(kind=wp), intent(in) :: color(4)

    [r, g, b, a] (0 to 1)

    real(kind=wp), intent(in) :: size

    (window units)

    integer, intent(in) :: shape

    marker shape (shaders/marker.frag)

    real(kind=wp), intent(in) :: radius

    attenuation radius (scene units; 0: none)

procedure, public :: set_pattern

  • private subroutine set_pattern(self, factor, pattern)

    For lines, a dash pattern (see line_set_pattern; z'FFFF' solid).

    Arguments

    Type IntentOptional Attributes Name
    class(LineChain), intent(inout) :: self
    integer, intent(in) :: factor

    repeat count of each bit of the pattern

    integer, intent(in) :: pattern

    16-bit dash pattern (z'FFFF': solid)

procedure, public :: set_style

  • private subroutine set_style(self, color, width)

    Color (rgba) and width (window units) of the whole chain.

    Arguments

    Type IntentOptional Attributes Name
    class(LineChain), intent(inout) :: self
    real(kind=wp), intent(in) :: color(4)

    [r, g, b, a] (0 to 1)

    real(kind=wp), intent(in) :: width

    (window units)

procedure, public :: set_trail

  • private subroutine set_trail(self, values)

    For strips, the trail (see vkf_line_set_trail: 20 values; the third 0: none), given to every chunk (changed every frame the time does: a few floats per chunk uploaded).

    Arguments

    Type IntentOptional Attributes Name
    class(LineChain), intent(inout) :: self
    real(kind=c_float), intent(in) :: values(20)

    the trail (see vkf_line_set_trail)

procedure, public :: slice

  • private subroutine slice(self, j, i1, i2, lo, hi, p)

    The part lo .. hi of points i1 .. i2 that chunk j holds, and its buffer p(xyz and distance, high/low, lo:hi) (null if none).

    Arguments

    Type IntentOptional Attributes Name
    class(LineChain), intent(in) :: self
    integer, intent(in) :: j

    the chunk, and points i1 .. i2 (chain indices)

    integer, intent(in) :: i1

    the chunk, and points i1 .. i2 (chain indices)

    integer, intent(in) :: i2

    the chunk, and points i1 .. i2 (chain indices)

    integer, intent(out) :: lo

    chain indices (lo > hi: none)

    integer, intent(out) :: hi

    chain indices (lo > hi: none)

    real(kind=c_float), intent(out), dimension(:,:,:), pointer :: p

    (4, 2, hi-lo+1)

procedure, public :: style_node

  • private subroutine style_node(self, line)

    Give the chain's style to line, a node not in the chain (e.g. a curve's trace-mode tail, drawn as part of it).

    Arguments

    Type IntentOptional Attributes Name
    class(LineChain), intent(in) :: self
    type(c_ptr), intent(in) :: line

    node to style (not in the chain)

procedure, public :: written

  • private subroutine written(self, i1, i2, x)

    Points i1 .. i2 were written: measure a strip's distances along it (from the distance at point i1-1), update its level of detail, and upload the chunks holding them. x: the points in double precision, x(:, i) for chain point i (at least i1-1 .. i2), to measure from; without it, from the floats written. (i2 is the last point written in the chain.)

    Arguments

    Type IntentOptional Attributes Name
    class(LineChain), intent(inout) :: self
    integer, intent(in) :: i1

    points written (chain indices)

    integer, intent(in) :: i2

    points written (chain indices)

    real(kind=wp), intent(in), optional :: x(:,:)

    (3, at least i1-1 .. i2): the points

Source Code

    type, public :: LineChain
        private
        type(c_ptr) :: group = c_null_ptr               !! the group node the chunks are under (null: not built)
        logical :: compile_new = .false.                !! chunks made from now on are compiled (the group is shown)
        type(LineChunk), allocatable :: chunks(:)       !! (capacity): the chunks, in chain order
        integer :: n_chunks = 0                         !! number of chunks
        integer :: kind = CHAIN_STRIP                   !! what is drawn: a CHAIN_* constant
        type(c_ptr) :: image = c_null_ptr               !! (markers: the image (shape 10))
        logical :: colored = .false.                    !! (lines, markers: a color per point (color_slice))
        ! style
        real(c_float) :: color(4) = 1.0_c_float         !! [r, g, b, a] (0 to 1)
        real(c_float) :: width = 1.0_c_float            !! line width, or marker size
        integer :: shape = 0                            !! markers
        real(c_float) :: radius = 0.0_c_float           !! (markers: attenuation radius)
        integer :: pattern_factor = 1                   !! (lines: dash pattern (see line_set_pattern))
        integer :: pattern = int(z'FFFF')               !! (lines: 16-bit dash pattern (z'FFFF': solid))
        logical :: lod = .true.                         !! (strips: level of detail (else every point drawn))
        real(c_float) :: highlight(12) = [1.0_c_float, 1.0_c_float, 1.0_c_float, 1.0_c_float, &
                                          0.0_c_float, 40.0_c_float, 50.0_c_float, 12.0_c_float, &
                                          1.5_c_float, 0.0_c_float, 0.0_c_float, 0.0_c_float]
                                                        !! (lines: highlight, see vkf_line_set_highlight)
        real(c_float) :: trail(20) = 0.0_c_float        !! (strips: the trail, see vkf_line_set_trail; z = 0: none)
        integer :: dash_mode = 0                        !! (lines: 0 anchored, 1 screen-locked, 2 fixed length)
        real(wp) :: dash_length = 0.0_wp                !! (2: the pattern's length, scene units; 0 from the first view)
    contains
        procedure :: init, set_compile, is_built, is_colored, release, detach
        procedure :: reserve, slice, color_slice, written, draw, draw_range
        procedure :: set_style, set_pattern, set_marker_style, set_highlight, set_trail, set_dash_mode, style_node
        procedure :: dash_mode_of, point, point_color, distance, num_chunks
        procedure :: set_lod, lod_error, chunk_bounds
    end type LineChain