CurveArtist Derived Type

type, public, extends(ChainArtist) :: CurveArtist

Draws a trajectory's points connected by a line (OpenFrames' CurveArtist). The x, y and z of the points come from data sources (default: the trajectory's positions). The line is in the artist's color, or in the trajectory's point colors if it has any (see the module documentation).


Inherits

type~~curveartist~~InheritsGraph type~curveartist CurveArtist type~chainartist ChainArtist type~curveartist->type~chainartist type~datasource DataSource type~curveartist->type~datasource sources_ type~highlightstyle HighlightStyle type~curveartist->type~highlightstyle highlight_ type~trailstyle TrailStyle type~curveartist->type~trailstyle trail_ c_ptr c_ptr type~chainartist->c_ptr group, tail type~linechain LineChain type~chainartist->type~linechain chain type~trajectoryartist TrajectoryArtist type~chainartist->type~trajectoryartist type~linechain->c_ptr group, image type~linechunk LineChunk type~linechain->type~linechunk chunks type~referenceframe ReferenceFrame type~trajectoryartist->type~referenceframe shown_in, data_frame, seen_data_frame type~trajectory Trajectory type~trajectoryartist->type~trajectory traj type~linechunk->c_ptr line type~lodlevel LodLevel type~linechunk->type~lodlevel lod type~referenceframe->c_ptr light_node, light_switch, node_, contents_node, axis_node, axis_label_node, axis_arrow, axis_text, name_label_node, name_text type~referenceframe->type~referenceframe follow_frame_ type~framepointer FramePointer type~referenceframe->type~framepointer children, parents type~trajectoryfollower TrajectoryFollower type~referenceframe->type~trajectoryfollower follower_ type~framepointer->type~referenceframe p type~trajectoryfollower->type~datasource sources_ type~trajectorypointer TrajectoryPointer type~trajectoryfollower->type~trajectorypointer trajs type~trajectorypointer->type~trajectory p

Components

Type Visibility Attributes Name Initial
real(kind=wp), private :: color_(4) = [1.0_wp, 1.0_wp, 1.0_wp, 1.0_wp]

line color [r, g, b, a] (default white)

logical, private :: default_data = .true.

sources not set: the positions, per the DOF

type(HighlightStyle), private :: highlight_

(see set_highlight)

logical, private :: lod_ = .true.

level of detail (see set_level_of_detail)

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

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

integer, private :: pattern_factor = 1

window units per pattern bit (>= 1)

type(DataSource), private :: sources_(3)

x, y, z data sources (default: the positions)

integer, private :: tail_from = 0

the tail: from point tail_from toward tail_to

integer, private :: tail_to = 0

the tail: from point tail_from toward tail_to

type(TrailStyle), private :: trail_

(see set_trail)

real(kind=wp), private :: width_ = 1.0_wp

line width (window units)


Constructor

public interface CurveArtist

The CurveArtist constructor: CurveArtist(...) makes one (see new_curve_artist for its arguments).

  • private function new_curve_artist(traj, color, width) result(a)

    A curve artist for traj (optional), drawn in color color ([r, g, b] or [r, g, b, a]; default white) and width (window units; default 1).

    Arguments

    Type IntentOptional Attributes Name
    type(Trajectory), intent(in), optional, target :: traj

    the trajectory to draw (not owned)

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

    [r, g, b] or [r, g, b, a] (0 to 1); width (window units, default 1)

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

    [r, g, b] or [r, g, b, a] (0 to 1); width (window units, default 1)

    Return Value type(CurveArtist)


Type-Bound Procedures

procedure, public :: apply_style => curve_style

  • private subroutine curve_style(self)

    The style: the artist's color, or white if the points' colors are drawn (the shader multiplies them by it).

    Arguments

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

procedure, public :: build => chain_build

  • private subroutine chain_build(self, viewer, group)

    Create the chain of buffers (sized for the points now) and the trace tail under group.

    Arguments

    Type IntentOptional Attributes Name
    class(ChainArtist), intent(inout) :: self
    type(c_ptr), intent(in) :: viewer

    compiles what is made later (null: nothing to)

    type(c_ptr), intent(in) :: group

    the artist's group

procedure, public :: chain_kind => curve_chain_kind

  • private pure function curve_chain_kind(self)

    The chain: a line strip.

    Arguments

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

    Return Value integer

procedure, public :: color => curve_color

  • private pure function curve_color(self) result(c)

    The line's color [r, g, b, a].

    Arguments

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

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

procedure, public :: dash_mode => curve_dash_mode

  • private pure function curve_dash_mode(self) result(mode)

    The dash pattern's layout: DASH_SCENE, DASH_SCREEN or DASH_FIXED.

    Arguments

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

    Return Value integer

procedure, public :: data_sources

  • private pure function data_sources(self) result(s)

    The x, y and z data sources.

    Arguments

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

    Return Value type(DataSource), (3)

procedure, public :: draw_tail => update_tail

  • private subroutine update_tail(self, t, k, k2)

    The tail: from point k (the latest passed) to the point interpolated at time t toward point k2 (the next in time: k + 1, or k - 1 for decreasing times); none if either isn't a point written (before the start, or everything passed).

    Arguments

    Type IntentOptional Attributes Name
    class(CurveArtist), intent(inout) :: self
    real(kind=wp), intent(in) :: t

    the current time

    integer, intent(in) :: k

    the tail's ends (0: none)

    integer, intent(in) :: k2

    the tail's ends (0: none)

procedure, public :: drawn_color

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

    The color of point i (1 to num_drawn) as drawn: read back from the line buffers.

    Arguments

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

    the point (1 to num_drawn)

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

procedure, public :: drawn_distance

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

    The distance along the curve at point i (1 to num_drawn), as drawn (for the dash pattern): read back from the line buffers.

    Arguments

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

    the point (1 to num_drawn)

    Return Value real(kind=wp)

procedure, public :: drawn_point

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

    Point i (of the trajectory's: first_drawn to first_drawn + num_drawn - 1 drawn) as written: read back from the line buffers.

    Arguments

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

    the trajectory point

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

procedure, public :: first_drawn

  • private pure function first_drawn(self)

    The first point drawn (1, or in trace mode of decreasing times the earliest point passed): points first_drawn .. first_drawn + num_drawn - 1.

    Arguments

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

    Return Value integer

procedure, public :: get_trajectory

  • private function get_trajectory(self) result(traj)

    The trajectory drawn (null if none).

    Arguments

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

    Return Value type(Trajectory), pointer

procedure, public :: has_trail

  • private pure function has_trail(self)

    Whether the curve has a trail (set_trail).

    Arguments

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

    Return Value logical

procedure, public :: highlight => curve_highlight

  • private pure function curve_highlight(self) result(mode)

    The curve's highlight: HIGHLIGHT_* (added; HIGHLIGHT_NONE: not highlighted).

    Arguments

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

    Return Value integer

procedure, public :: init_chain => curve_init_chain

  • private subroutine curve_init_chain(self)

    The chain (ChainArtist's), with the curve's level of detail.

    Arguments

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

procedure, public :: level_of_detail

  • private pure function level_of_detail(self)

    Whether level of detail is on.

    Arguments

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

    Return Value logical

procedure, public :: lod_error

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

    The error bounds of chunk j of the curve's points (for checks): how far the points skipped can be from the segments drawn at stride 2^k, k = 1, 2, ... (scene units).

    Arguments

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

    the chunk (1 to num_chunks)

    Return Value real(kind=wp), allocatable, (:)

procedure, public :: new_tail => curve_new_tail

  • private function curve_new_tail(self) result(node)

    The trace tail: a line of two points (white unless the points' colors are drawn).

    Arguments

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

    Return Value type(c_ptr)

procedure, public :: num_chunks

  • private pure function num_chunks(self)

    Number of buffers the artist is drawn with (0 until built).

    Arguments

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

    Return Value integer

procedure, public :: num_drawn

  • private pure function num_drawn(self)

    Number of trajectory points drawn now (all of them, or in trace mode those passed).

    Arguments

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

    Return Value integer

procedure, public :: pattern => curve_pattern

  • private pure subroutine curve_pattern(self, factor, bits)

    The dash pattern: its factor and 16 pattern bits.

    Arguments

    Type IntentOptional Attributes Name
    class(CurveArtist), intent(in) :: self
    integer, intent(out) :: factor

    window units per bit, 16 bits

    integer, intent(out) :: bits

    window units per bit, 16 bits

procedure, public :: pickable => artist_pickable

  • private pure function artist_pickable(self)

    Whether pick tests what this artist draws.

    Arguments

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

    Return Value logical

procedure, public :: point_colors

  • private pure function point_colors(self)

    Whether a trajectory's colors are drawn.

    Arguments

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

    Return Value logical

procedure, public :: points => curve_points

  • private function curve_points(self) result(n)

    Number of points to draw (1 if all sources are zero: a point at the origin).

    Arguments

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

    Return Value integer

procedure, public :: release => chain_release

  • private subroutine chain_release(self)

    Forget the render nodes: the chain and the tail (see artist_release).

    Arguments

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

procedure, public :: remove_trail

  • private subroutine remove_trail(self)

    No trail: the whole curve (or trace mode, if set) again.

    Arguments

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

procedure, public :: set_color => curve_set_color

  • private subroutine curve_set_color(self, color)

    The line's color: [r, g, b] (alpha unchanged) or [r, g, b, a], 0 to 1 (with the trajectory's point colors drawn: for points without one).

    Arguments

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

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

procedure, public :: set_dash_mode => curve_set_dash_mode

  • private subroutine curve_set_dash_mode(self, mode, length)

    How the dash pattern (and a trail's) is laid out: DASH_SCENE (the default) anchored to the line: a dash stays put on it as the view changes, its size in scene units (one per line and view, from 0.7 to 1.4 times the pattern's on screen, changing by doubling as it zooms); DASH_SCREEN screen-locked, as OpenGL's line stipple (OpenFrames'): every dash the pattern's length in pixels, at any zoom and depth, sliding along the line as the view changes; DASH_FIXED a fixed length of the line, as paint on it: never changing, so zooming in the dashes grow on screen, and out they shrink (under a pixel, blending into a fainter solid line); length (scene units, for the whole pattern: the other patterns, a trail's future's and the arrows', in proportion), else the pattern's length on screen where the line is first drawn. DASH_SCREEN and DASH_FIXED cost projecting the points drawn on the CPU, per view and frame.

    Arguments

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

    DASH_SCENE, DASH_SCREEN or DASH_FIXED

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

    (DASH_FIXED) the pattern's length, scene units

procedure, public :: set_highlight => curve_set_highlight

  • private subroutine curve_set_highlight(self, mode, color, arrow_spacing, arrow_speed, band_width, pulse_period)

    Highlight the curve (see the module documentation): mode a sum of HIGHLIGHT_PULSE and HIGHLIGHT_ARROWS (HIGHLIGHT_NONE: not highlighted), in color ([r, g, b] or [r, g, b, a]; default white). The other settings are kept when not given.

    Arguments

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

    HIGHLIGHT_* (added)

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

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

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

    between arrows (window units; default 40)

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

    (window units per second; default 50)

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

    of the arrows' band (window units; default 12)

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

    (s; default 1.5)

procedure, public :: set_level_of_detail

  • private subroutine set_level_of_detail(self, enabled)

    Level of detail (default on): seen from far away, the curve is drawn from every 2nd, 4th, ... point (and its last), as many as can be skipped while staying within half a pixel of all of them, chosen per view and per chunk of points. Off: every point is drawn.

    Arguments

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

    true: level of detail on (default)

procedure, public :: set_pattern => curve_set_pattern

  • private subroutine curve_set_pattern(self, factor, pattern)

    A dash pattern, as OpenGL's line stipple (OpenFrames' setPattern): each bit of the 16-bit pattern (bit 0 first; z'FFFF', the default, is solid) covers factor window units, along the whole curve (the dashes run on across its points). The dashes' length on screen is kept within 0.7 to 1.4 times the pattern's (see shaders/line.vert).

    Arguments

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

    window units per bit (>= 1), 16 bits (z'FFFF': solid)

    integer, intent(in) :: pattern

    window units per bit (>= 1), 16 bits (z'FFFF': solid)

procedure, public :: set_pickable => artist_set_pickable

  • private subroutine artist_set_pickable(self, pickable)

    Whether pick tests what this artist draws (default true; e.g. false for a spacecraft's marker beside its orbit's curve).

    Arguments

    Type IntentOptional Attributes Name
    class(TrajectoryArtist), intent(inout) :: self
    logical, intent(in) :: pickable

    true: picked (default)

procedure, public :: set_point_colors

  • private subroutine set_point_colors(self, enabled)

    Whether a trajectory with colors is drawn in them (default true); points without a color yet (colors arriving after positions) in the artist's color. A curve: each segment blended from its first point's color to its second's (with level of detail, a color lasting fewer points than are skipped may not show from far away); a surface: each point's pair in its color, times the artist's alpha. False: all in the artist's color.

    Arguments

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

    true: the trajectory's colors

procedure, public :: set_trace_mode

  • private subroutine set_trace_mode(self, enabled)

    Draw only the part up to the current time (see the module documentation).

    Arguments

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

    true: draw only up to the current time

procedure, public :: set_trail

  • private subroutine set_trail(self, past, future, fade)

    A trail (see the module documentation): only the part within past before the current time and future after it (s, >= 0; 0: none of it; huge(1.0_wp): no limit), each fading out over the last fade (0 to 1, default 0.25) of its window toward its cutoff. Replaces trace mode while set.

    Arguments

    Type IntentOptional Attributes Name
    class(CurveArtist), intent(inout) :: self
    real(kind=wp), intent(in) :: past

    s before and after the current time

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

    s before and after the current time

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

    of each part's window (default 0.25)

procedure, public :: set_trail_style

  • private subroutine set_trail_style(self, which, color, opacity, factor, pattern)

    The style of a trail's part, which TRAIL_PAST or TRAIL_FUTURE: color ([r, g, b] or [r, g, b, a]: drawn in it instead of the line's colors), opacity (its alpha multiplied by it: translucency, default 1), a dash pattern (factor and 16 pattern bits, as set_pattern; default solid). Settings not given are kept.

    Arguments

    Type IntentOptional Attributes Name
    class(CurveArtist), intent(inout) :: self
    integer, intent(in) :: which

    TRAIL_PAST or TRAIL_FUTURE

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

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

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

    0 to 1

    integer, intent(in), optional :: factor

    window units per bit (>= 1), 16 bits

    integer, intent(in), optional :: pattern

    window units per bit (>= 1), 16 bits

procedure, public :: set_trajectory => curve_set_trajectory

  • private subroutine curve_set_trajectory(self, traj)

    Draw traj; with the default data sources, its positions (per its DOF).

    Arguments

    Type IntentOptional Attributes Name
    class(CurveArtist), intent(inout) :: self
    type(Trajectory), intent(in), target :: traj

    the trajectory to draw (not owned)

procedure, public :: set_width => curve_set_width

  • private subroutine curve_set_width(self, width)

    The line's width in window units (logical pixels).

    Arguments

    Type IntentOptional Attributes Name
    class(CurveArtist), intent(inout) :: self
    real(kind=wp), intent(in) :: width

    window units

procedure, public :: set_x_data

  • private function set_x_data(self, src) result(valid)

    Where the x (y, z) of the points come from. Returns whether the trajectory has those data.

    Arguments

    Type IntentOptional Attributes Name
    class(CurveArtist), intent(inout) :: self
    type(DataSource), intent(in) :: src

    the x data source

    Return Value logical

procedure, public :: set_y_data

  • private function set_y_data(self, src) result(valid)

    Where the y of the points come from (see set_x_data).

    Arguments

    Type IntentOptional Attributes Name
    class(CurveArtist), intent(inout) :: self
    type(DataSource), intent(in) :: src

    the y data source

    Return Value logical

procedure, public :: set_z_data

  • private function set_z_data(self, src) result(valid)

    Where the z of the points come from (see set_x_data).

    Arguments

    Type IntentOptional Attributes Name
    class(CurveArtist), intent(inout) :: self
    type(DataSource), intent(in) :: src

    the z data source

    Return Value logical

procedure, public :: trace_end

  • private function trace_end(self, v)

    In trace mode, the end of the line (the point at the current time) as drawn; false if no tail is drawn.

    Arguments

    Type IntentOptional Attributes Name
    class(CurveArtist), intent(in) :: self
    real(kind=wp), intent(out) :: v(3)

    the tail's end (frame coordinates)

    Return Value logical

procedure, public :: trace_mode

  • private pure function trace_mode(self)

    Whether only the part up to the current time is drawn.

    Arguments

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

    Return Value logical

procedure, public :: update => curve_update

  • private subroutine curve_update(self, t)

    Write the points added (all of them on a redraw), and draw them all, or in trace mode those passed and the tail to the point at time t, or with a trail the window about time t.

    Arguments

    Type IntentOptional Attributes Name
    class(CurveArtist), intent(inout) :: self
    real(kind=wp), intent(in) :: t

    the current time

procedure, public :: width => curve_width

  • private pure function curve_width(self)

    The line's width (window units).

    Arguments

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

    Return Value real(kind=wp)

procedure, public :: write_points => write_curve

  • private subroutine write_curve(self, i1, i2)

    Write points i1 .. i2 into the chain (and upload the chunks written to).

    Arguments

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

    the trajectory points

    integer, intent(in) :: i2

    the trajectory points

Source Code

    type, extends(ChainArtist), public :: CurveArtist
        private
        type(DataSource) :: sources_(3)             !! x, y, z data sources (default: the positions)
        logical :: default_data = .true.            !! sources not set: the positions, per the DOF
        real(wp) :: color_(4) = [1.0_wp, 1.0_wp, 1.0_wp, 1.0_wp]  !! line color [r, g, b, a] (default white)
        real(wp) :: width_ = 1.0_wp                 !! line width (window units)
        integer :: pattern_factor = 1               !! window units per pattern bit (>= 1)
        integer :: pattern_ = int(z'FFFF')          !! 16-bit dash pattern (z'FFFF': solid)
        logical :: lod_ = .true.                    !! level of detail (see set_level_of_detail)
        type(HighlightStyle) :: highlight_          !! (see set_highlight)
        type(TrailStyle) :: trail_                  !! (see set_trail)
        ! rendering (the chain: a line strip; the tail: a line of two points)
        integer :: tail_from = 0, tail_to = 0       !! the tail: from point tail_from toward tail_to
    contains
        procedure :: set_trajectory => curve_set_trajectory
        procedure :: set_x_data, set_y_data, set_z_data, data_sources
        procedure :: set_color => curve_set_color, color => curve_color
        procedure :: set_width => curve_set_width, width => curve_width
        procedure :: set_pattern => curve_set_pattern, pattern => curve_pattern
        procedure :: set_highlight => curve_set_highlight, highlight => curve_highlight
        procedure :: set_trail, remove_trail, has_trail, set_trail_style
        procedure :: set_dash_mode => curve_set_dash_mode, dash_mode => curve_dash_mode
        procedure :: set_level_of_detail, level_of_detail, lod_error
        procedure :: drawn_color
        procedure :: update => curve_update
        procedure :: drawn_point, drawn_distance, trace_end
        procedure :: init_chain => curve_init_chain
        procedure :: chain_kind => curve_chain_kind
        procedure :: points => curve_points
        procedure :: new_tail => curve_new_tail
        procedure :: apply_style => curve_style
        procedure :: write_points => write_curve
        procedure :: draw_tail => update_tail
    end type CurveArtist