SegmentArtist Derived Type

type, public, extends(TrajectoryArtist) :: SegmentArtist

Draws a line segment at every stride-th point of a trajectory (OpenFrames' SegmentArtist), from the point given by the start data sources to the one given by the end data sources: e.g. radius vectors (the origin to the positions), or from the positions to points stored as an optional (a target). Default (an addition to OpenFrames, which draws nothing until the sources are set): from the frame's origin to the trajectory's positions.

Relative ends (set_end_relative, not in OpenFrames): the end sources give an offset from the start, so a vector stored per point (a thrust, a velocity) is drawn from each position, at a length set by the end sources' scale (set_end_scale), which can be changed without touching the trajectory (only this artist's segments are written again). Where the vector is zero (no thrust) nothing is drawn.


Inherits

type~~segmentartist~~InheritsGraph type~segmentartist SegmentArtist type~datasource DataSource type~segmentartist->type~datasource start_, end_ type~highlightstyle HighlightStyle type~segmentartist->type~highlightstyle highlight_ type~linechain LineChain type~segmentartist->type~linechain chain type~trajectoryartist TrajectoryArtist type~segmentartist->type~trajectoryartist c_ptr c_ptr 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
type(LineChain), private :: chain

the line buffers (a pair of points per segment)

real(kind=wp), private :: color_(4) = [1.0_wp, 1.0_wp, 1.0_wp, 1.0_wp]

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

logical, private :: default_data = .true.

sources not set: the origin to the positions, per the DOF

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

start and end points' x, y, z data sources

logical, private :: end_relative_ = .false.

the end sources: an offset from the start

integer, private :: first_drawn_ = 1

the first of them (trace mode, decreasing times: later)

type(HighlightStyle), private :: highlight_

(see set_highlight)

integer, private :: n_drawn = 0

segments drawn from it

integer, private :: n_written = 0

segments written to the chain

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 :: start_(3)

start and end points' x, y, z data sources

integer, private :: stride_ = 1

a segment at every stride_-th point (>= 1)

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

segment width (window units)


Constructor

public interface SegmentArtist

The SegmentArtist constructor: SegmentArtist(...) makes one (see new_segment_artist for its arguments).

  • private function new_segment_artist(traj, color, width, stride) result(a)

    A segment artist for traj (optional), drawn in color color ([r, g, b] or [r, g, b, a]; default white) and width (window units; default 1), at every stride-th point (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)

    integer, intent(in), optional :: stride

    a segment at every stride-th point (default 1)

    Return Value type(SegmentArtist)


Type-Bound Procedures

procedure, public :: build => segment_build

  • private subroutine segment_build(self, viewer, group)

    Create the chain of line buffers (sized for the segments now) under group.

    Arguments

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

    compiles nodes made later (may be null); the parent group

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

    compiles nodes made later (may be null); the parent group

procedure, public :: color => segment_color

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

    The segments' color [r, g, b, a].

    Arguments

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

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

procedure, public :: dash_mode => segment_dash_mode

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

    The dash pattern's layout: DASH_SCENE or DASH_SCREEN.

    Arguments

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

    Return Value integer

procedure, public :: drawn_segment

  • private subroutine drawn_segment(self, s, a, b)

    Segment s (at point 1 + (s-1) stride; first_drawn to first_drawn + num_drawn - 1 drawn) as written: read back from the line buffers.

    Arguments

    Type IntentOptional Attributes Name
    class(SegmentArtist), intent(in) :: self
    integer, intent(in) :: s

    the segment (first_drawn to first_drawn + num_drawn - 1)

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

    the segment's start (frame coordinates)

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

    its end

procedure, public :: end_data_sources

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

    The x, y and z data sources of the segments' end points.

    Arguments

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

    Return Value type(DataSource), (3)

procedure, public :: end_relative

  • private pure function end_relative(self)

    Whether the ends are relative (see set_end_relative).

    Arguments

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

    Return Value logical

procedure, public :: first_drawn => segment_first_drawn

  • private pure function segment_first_drawn(self)

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

    Arguments

    Type IntentOptional Attributes Name
    class(SegmentArtist), 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 :: highlight => segment_highlight

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

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

    Arguments

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

    Return Value integer

procedure, public :: num_chunks => segment_num_chunks

  • private pure function segment_num_chunks(self)

    Number of line buffers the segments are drawn with (0 until built).

    Arguments

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

    Return Value integer

procedure, public :: num_drawn => segment_num_drawn

  • private pure function segment_num_drawn(self)

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

    Arguments

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

    Return Value integer

procedure, public :: pattern => segment_pattern

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

    The dash pattern: its factor and 16 pattern bits.

    Arguments

    Type IntentOptional Attributes Name
    class(SegmentArtist), 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 :: release => segment_release

  • private subroutine segment_release(self)

    Forget the render nodes (see artist_release).

    Arguments

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

procedure, public :: set_color => segment_set_color

  • private subroutine segment_set_color(self, color)

    The segments' color: [r, g, b] (alpha unchanged) or [r, g, b, a], 0 to 1.

    Arguments

    Type IntentOptional Attributes Name
    class(SegmentArtist), 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 => segment_set_dash_mode

  • private subroutine segment_set_dash_mode(self, mode)

    The dash pattern's layout (see set_dash_mode): screen-locked dashes start again at each segment's start, as GL_LINES; DASH_FIXED (strips only) is taken as DASH_SCENE.

    Arguments

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

    DASH_SCENE or DASH_SCREEN

procedure, public :: set_end_data

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

    All three end sources at once (see set_start_data).

    Arguments

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

    the end points' x, y, z data sources

    Return Value logical

procedure, public :: set_end_relative

  • private subroutine set_end_relative(self, relative)

    Relative ends (default false): each segment ends at its start plus the end sources' values (a vector drawn from each point), not at them.

    Arguments

    Type IntentOptional Attributes Name
    class(SegmentArtist), intent(inout) :: self
    logical, intent(in) :: relative

    true: the ends are offsets from the starts

procedure, public :: set_end_scale

  • private subroutine set_end_scale(self, scale)

    Set the scale of all three end sources (with relative ends: the length drawn per unit of the stored vector, e.g. km per newton). Only this artist's segments are written again.

    Arguments

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

    the end sources' scale (e.g. km per newton)

procedure, public :: set_end_x_data

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

    Where the x of the segments' end points come from (see set_start_x_data).

    Arguments

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

    the end points' x data source

    Return Value logical

procedure, public :: set_end_y_data

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

    Where the y of the segments' end points come from (see set_start_x_data).

    Arguments

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

    the end points' y data source

    Return Value logical

procedure, public :: set_end_z_data

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

    Where the z of the segments' end points come from (see set_start_x_data).

    Arguments

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

    the end points' z data source

    Return Value logical

procedure, public :: set_highlight => segment_set_highlight

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

    Highlight the segments (see set_highlight): the arrows run along each segment from its start to its end.

    Arguments

    Type IntentOptional Attributes Name
    class(SegmentArtist), 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_pattern => segment_set_pattern

  • private subroutine segment_set_pattern(self, factor, pattern)

    A dash pattern (see set_pattern), starting again at the start of each segment.

    Arguments

    Type IntentOptional Attributes Name
    class(SegmentArtist), 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_start_data

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

    All three start (end) sources at once, e.g. position_sources(3) or optional_sources(1). Returns whether the trajectory has their data.

    Arguments

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

    the start points' x, y, z data sources

    Return Value logical

procedure, public :: set_start_x_data

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

    Where the x (y, z) of the segments' start (end) points come from. Returns whether the trajectory has the data of all sources.

    Arguments

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

    the start points' x data source

    Return Value logical

procedure, public :: set_start_y_data

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

    Where the y of the segments' start points come from (see set_start_x_data).

    Arguments

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

    the start points' y data source

    Return Value logical

procedure, public :: set_start_z_data

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

    Where the z of the segments' start points come from (see set_start_x_data).

    Arguments

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

    the start points' z data source

    Return Value logical

procedure, public :: set_stride

  • private subroutine set_stride(self, stride)

    Draw a segment at points 1, 1 + stride, 1 + 2 stride, ... (stride >= 1).

    Arguments

    Type IntentOptional Attributes Name
    class(SegmentArtist), intent(inout) :: self
    integer, intent(in) :: stride

    a segment at every stride-th point (>= 1)

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_trajectory => segment_set_trajectory

  • private subroutine segment_set_trajectory(self, traj)

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

    Arguments

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

    the trajectory to draw (not owned)

procedure, public :: set_width => segment_set_width

  • private subroutine segment_set_width(self, width)

    The segments' width in window units (logical pixels).

    Arguments

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

    window units

procedure, public :: start_data_sources

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

    The x, y and z data sources of the segments' start points.

    Arguments

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

    Return Value type(DataSource), (3)

procedure, public :: stride

  • private pure function stride(self)

    The stride: a segment at every stride-th point.

    Arguments

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

    Return Value integer

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 => segment_update

  • private subroutine segment_update(self, t)

    Write the segments added (all of them on a redraw), and draw them all or, in trace mode, those at the points passed at time t.

    Arguments

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

    the current time

procedure, public :: width => segment_width

  • private pure function segment_width(self)

    The segments' width (window units).

    Arguments

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

    Return Value real(kind=wp)

Source Code

    type, extends(TrajectoryArtist), public :: SegmentArtist
        private
        type(DataSource) :: start_(3), end_(3)      !! start and end points' x, y, z data sources
        logical :: default_data = .true.            !! sources not set: the origin to the positions, per the DOF
        logical :: end_relative_ = .false.          !! the end sources: an offset from the start
        integer :: stride_ = 1                      !! a segment at every stride_-th point (>= 1)
        real(wp) :: color_(4) = [1.0_wp, 1.0_wp, 1.0_wp, 1.0_wp]  !! segment color [r, g, b, a] (default white)
        real(wp) :: width_ = 1.0_wp                 !! segment 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)
        type(HighlightStyle) :: highlight_          !! (see set_highlight)
        ! rendering
        type(LineChain) :: chain                    !! the line buffers (a pair of points per segment)
        integer :: n_written = 0                    !! segments written to the chain
        integer :: n_drawn = 0                      !! segments drawn from it
        integer :: first_drawn_ = 1                 !! the first of them (trace mode, decreasing times: later)
    contains
        procedure :: set_trajectory => segment_set_trajectory
        procedure :: set_start_x_data, set_start_y_data, set_start_z_data
        procedure :: set_end_x_data, set_end_y_data, set_end_z_data
        procedure :: set_start_data, set_end_data
        procedure :: start_data_sources, end_data_sources
        procedure :: set_end_relative, end_relative, set_end_scale
        procedure :: set_stride, stride
        procedure :: set_color => segment_set_color, color => segment_color
        procedure :: set_width => segment_set_width, width => segment_width
        procedure :: set_pattern => segment_set_pattern, pattern => segment_pattern
        procedure :: set_highlight => segment_set_highlight, highlight => segment_highlight
        procedure :: set_dash_mode => segment_set_dash_mode, dash_mode => segment_dash_mode
        procedure :: build => segment_build
        procedure :: update => segment_update
        procedure :: release => segment_release
        procedure :: num_chunks => segment_num_chunks, num_drawn => segment_num_drawn
        procedure :: first_drawn => segment_first_drawn
        procedure :: drawn_segment
    end type SegmentArtist