MarkerArtist Derived Type

type, public, extends(TrajectoryArtist) :: MarkerArtist

Draws markers at a trajectory's points (OpenFrames' MarkerArtist): at its start and end, and intermediate markers spaced by time, arc length or data points, counted from the start or from the end. Markers keep their size on screen (window units), or with auto-attenuation shrink when the camera is farther than the trajectory's size. In trace mode (an addition), the markers passed are drawn: the end marker (at the trajectory's end) only once the time reaches the end. Point colors (an addition, off by default: set_point_colors): each marker in the trajectory's color there (see set_point_colors).


Inherits

type~~markerartist~~InheritsGraph type~markerartist MarkerArtist c_ptr c_ptr type~markerartist->c_ptr image, group type~datasource DataSource type~markerartist->type~datasource sources_ type~linechain LineChain type~markerartist->type~linechain start_node, end_node, inter type~trajectoryartist TrajectoryArtist type~markerartist->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 :: arc = 0.0_wp

arc length (INTERMEDIATE_DISTANCE): so far, at prev_point, and of the next marker; the last point

logical, private :: attenuate = .true.

auto-attenuation (see set_auto_attenuate; on by default)

logical, private :: default_data = .true.

sources not set: the positions, per the DOF

integer, private :: direction_ = MARKER_START

intermediate markers counted from MARKER_START or MARKER_END

logical, private :: drawn = .false.

drawn at least once since built

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

end marker color (red)

type(LineChain), private :: end_node

start, end and intermediate marker buffers

logical, private :: end_shown = .false.

the start and end markers are drawn

type(c_ptr), private :: group = c_null_ptr

the artist's group (null until built)

real(kind=wp), private :: hi(3) = 0.0_wp

bounds of the points seen

type(c_ptr), private :: image = c_null_ptr

the image read from it (owned; null: none)

character(len=:), private, allocatable :: image_file

the marker image file ('': none)

type(LineChain), private :: inter

start, end and intermediate marker buffers

integer, private :: inter_first = 1

the first intermediate marker drawn (trace, decreasing times: later)

real(kind=wp), private, allocatable :: inter_rgba(:,:)

(4, :) their colors (with point colors)

real(kind=wp), private, allocatable :: inter_t(:)

intermediate markers' points and times (1:n_inter)

real(kind=wp), private, allocatable :: inter_xyz(:,:)

intermediate markers' points and times (1:n_inter)

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

intermediate marker color (white)

integer, private :: intermediate_type_ = INTERMEDIATE_DATA

INTERMEDIATE_TIME, _DISTANCE or _DATA

real(kind=wp), private :: lo(3) = 0.0_wp

bounds of the points seen

integer, private :: markers_ = ior(MARKER_START, MARKER_END)

markers drawn (an ior of MARKER_* flags)

integer, private :: n_colors_seen = 0

the trajectory's colors when the markers were written

integer, private :: n_inter = 0

intermediate markers computed, written, drawn

integer, private :: n_inter_drawn = 0

intermediate markers computed, written, drawn

integer, private :: n_inter_written = 0

intermediate markers computed, written, drawn

integer, private :: n_seen = 0

points seen (for the bounds)

integer, private :: next_index = 0

where to continue (0: not started)

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

time of the next marker (INTERMEDIATE_TIME)

logical, private :: point_colors_ = .false.

the trajectory's colors, if any (see set_point_colors)

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

arc length (INTERMEDIATE_DISTANCE): so far, at prev_point, and of the next marker; the last point

real(kind=wp), private :: prev_point(3) = 0.0_wp

arc length (INTERMEDIATE_DISTANCE): so far, at prev_point, and of the next marker; the last point

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

attenuation radius applied

integer, private :: shape_ = MARKER_DISK

marker shape: a MARKER_* shape constant

logical, private :: shown = .false.

built for a window (marker nodes made later are compiled)

real(kind=wp), private :: size_ = 10.0_wp

marker size (window units)

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

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

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

intermediate spacing: time units, arc length or data points

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

start marker color [r, g, b, a] (red)

type(LineChain), private :: start_node

start, end and intermediate marker buffers

logical, private :: start_shown = .false.

the start and end markers are drawn

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

arc length (INTERMEDIATE_DISTANCE): so far, at prev_point, and of the next marker; the last point


Constructor

public interface MarkerArtist

The MarkerArtist constructor: MarkerArtist(...) makes one (see new_marker_artist for its arguments).

  • private function new_marker_artist(traj, markers, size, color) result(a)

    A marker artist for traj (optional; without one, or with all data sources zero, a start marker at the origin: in a DrawableTrajectory that follows a trajectory, or is a child of a frame that does, it marks the current position, as in OpenFrames), drawing markers (an ior of MARKER_START, MARKER_INTERMEDIATE, MARKER_END; default start and end) of size window units (default 10) in color (all markers; default red start and end, white intermediate).

    Arguments

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

    the trajectory to draw (not owned)

    integer, intent(in), optional :: markers

    an ior of MARKER_* flags (default start and end)

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

    window units (default 10); [r, g, b] or [r, g, b, a]

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

    window units (default 10); [r, g, b] or [r, g, b, a]

    Return Value type(MarkerArtist)


Type-Bound Procedures

procedure, public :: auto_attenuate

  • private pure function auto_attenuate(self)

    Whether the markers are auto-attenuated.

    Arguments

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

    Return Value logical

procedure, public :: build => marker_build

  • private subroutine marker_build(self, viewer, group)

    Create the marker nodes under group (see artist_build).

    Arguments

    Type IntentOptional Attributes Name
    class(MarkerArtist), 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 :: data_sources => marker_data_sources

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

    The x, y and z data sources.

    Arguments

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

    Return Value type(DataSource), (3)

procedure, public :: drawn_color => marker_drawn_color

  • private function marker_drawn_color(self, which, k) result(rgba)

    The color marker k of which (one MARKER_* flag; k: the intermediate marker's number) is drawn in: read back from its buffer with point colors, else the marker's own color.

    Arguments

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

    MARKER_START, MARKER_INTERMEDIATE or MARKER_END

    integer, intent(in), optional :: k

    the intermediate marker's number (default 1)

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

procedure, public :: drawn_marker

  • private function drawn_marker(self, which, v, i) result(shown)

    Where marker which (MARKER_START, MARKER_END, or MARKER_INTERMEDIATE number i) is drawn, read back from its buffer; false if not drawn.

    Arguments

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

    MARKER_START, MARKER_END or MARKER_INTERMEDIATE

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

    where it is drawn (frame coordinates)

    integer, intent(in), optional :: i

    the intermediate marker's number (1 to num_intermediate)

    Return Value logical

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 :: intermediate_direction

  • private pure function intermediate_direction(self)

    Where intermediate markers are counted from (MARKER_START or MARKER_END).

    Arguments

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

    Return Value integer

procedure, public :: intermediate_spacing

  • private pure function intermediate_spacing(self)

    Spacing of intermediate markers.

    Arguments

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

    Return Value real(kind=wp)

procedure, public :: intermediate_type

  • private pure function intermediate_type(self)

    How intermediate markers are spaced (INTERMEDIATE_*).

    Arguments

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

    Return Value integer

procedure, public :: marker_color

  • private pure function marker_color(self, which) result(c)

    The color of the start, intermediate or end markers (which: one MARKER_* flag).

    Arguments

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

    MARKER_START, MARKER_INTERMEDIATE or MARKER_END

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

procedure, public :: marker_image_file

  • private function marker_image_file(self) result(file)

    The marker image file ('' for none).

    Arguments

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

    Return Value character(len=:), allocatable

procedure, public :: marker_shape

  • private pure function marker_shape(self)

    Marker shape (a MARKER_* shape constant).

    Arguments

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

    Return Value integer

procedure, public :: marker_size

  • private pure function marker_size(self)

    Marker size (window units).

    Arguments

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

    Return Value real(kind=wp)

procedure, public :: markers

  • private pure function markers(self)

    Which markers are drawn (an ior of MARKER_* flags).

    Arguments

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

    Return Value integer

procedure, public :: num_intermediate

  • private pure function num_intermediate(self)

    Number of intermediate markers drawn now.

    Arguments

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

    Return Value integer

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

  • private pure function marker_point_colors(self)

    Whether the trajectory's colors are drawn (set_point_colors).

    Arguments

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

    Return Value logical

procedure, public :: release => marker_release

  • private subroutine marker_release(self)

    Forget the render nodes (see artist_release).

    Arguments

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

procedure, public :: set_auto_attenuate

  • private subroutine set_auto_attenuate(self, attenuate)

    Shrink markers farther from the camera than the trajectory's size (OpenFrames' auto-attenuation; see shaders/marker.vert). On by default (OpenFrames': off).

    Arguments

    Type IntentOptional Attributes Name
    class(MarkerArtist), intent(inout) :: self
    logical, intent(in) :: attenuate

    true: auto-attenuation on (default)

procedure, public :: set_intermediate_direction

  • private subroutine set_intermediate_direction(self, direction)

    Count intermediate markers from the start (MARKER_START, default) or from the end (MARKER_END; recomputed whenever points are added).

    Arguments

    Type IntentOptional Attributes Name
    class(MarkerArtist), intent(inout) :: self
    integer, intent(in) :: direction

    MARKER_START or MARKER_END

procedure, public :: set_intermediate_spacing

  • private subroutine set_intermediate_spacing(self, spacing)

    Spacing of intermediate markers (> 0): time units, arc length, or a number of data points (rounded down, at least 1).

    Arguments

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

    time units, arc length or data points (> 0)

procedure, public :: set_intermediate_type

  • private subroutine set_intermediate_type(self, type)

    Arguments

    Type IntentOptional Attributes Name
    class(MarkerArtist), intent(inout) :: self
    integer, intent(in) :: type

    INTERMEDIATE_TIME, _DISTANCE or _DATA

procedure, public :: set_marker_color

  • private subroutine set_marker_color(self, which, color)

    The color of the markers in which (an ior of MARKER_* flags): [r, g, b] (alpha unchanged) or [r, g, b, a].

    Arguments

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

    the markers (an ior of MARKER_* flags)

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

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

procedure, public :: set_marker_image

  • private function set_marker_image(self, file) result(ok)

    Draw the markers as an image file (tinted by the marker color; its transparent parts left out), or as a disk again with ''. Returns false if the image cannot be read (the markers are then unchanged).

    Arguments

    Type IntentOptional Attributes Name
    class(MarkerArtist), intent(inout) :: self
    character(len=*), intent(in) :: file

    the image file ('': a disk again)

    Return Value logical

procedure, public :: set_marker_shape

  • private subroutine set_marker_shape(self, shape)

    Marker shape: a MARKER_ shape constant (MARKER_DISK to MARKER_SPIRAL; MARKER_IMAGE after set_marker_image). These are OpenFrames' disk and its marker shaders (Demos/Shaders/Marker_.frag), built in.

    Arguments

    Type IntentOptional Attributes Name
    class(MarkerArtist), intent(inout) :: self
    integer, intent(in) :: shape

    a MARKER_* shape constant

procedure, public :: set_marker_size

  • private subroutine set_marker_size(self, size)

    Marker size in window units (logical pixels; > 0).

    Arguments

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

    window units (> 0; else ignored)

procedure, public :: set_markers

  • private subroutine set_markers(self, markers)

    Which markers to draw: an ior of MARKER_START, MARKER_INTERMEDIATE and MARKER_END (0 for none).

    Arguments

    Type IntentOptional Attributes Name
    class(MarkerArtist), intent(inout) :: self
    integer, intent(in) :: markers

    an ior of MARKER_* flags (0: none)

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

  • private subroutine marker_set_point_colors(self, enabled)

    How intermediate markers are spaced: INTERMEDIATE_TIME, _DISTANCE or _DATA. Point colors (default off): with the trajectory's colors (Trajectory% add_color, or add's color), each marker is drawn in the color at its point (intermediate markers between points: blended between theirs, by time), points without a color yet in the marker's own color (set_marker_color). Off, or without colors: the markers' own colors.

    Arguments

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

    true: the trajectory's colors (default false)

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

  • private subroutine marker_set_trajectory(self, traj)

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

    Arguments

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

    the trajectory to draw (not owned)

procedure, public :: set_x_data => marker_set_x_data

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

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

    Arguments

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

    the x data source

    Return Value logical

procedure, public :: set_y_data => marker_set_y_data

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

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

    Arguments

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

    the y data source

    Return Value logical

procedure, public :: set_z_data => marker_set_z_data

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

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

    Arguments

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

    the z data source

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

  • private subroutine marker_update(self, t)

    Write the start, end and new intermediate markers if the trajectory changed, and draw them all or, in trace mode, those passed at time t.

    Arguments

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

    the current time

Source Code

    type, extends(TrajectoryArtist), public :: MarkerArtist
        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
        integer :: markers_ = ior(MARKER_START, MARKER_END)  !! markers drawn (an ior of MARKER_* flags)
        integer :: intermediate_type_ = INTERMEDIATE_DATA  !! INTERMEDIATE_TIME, _DISTANCE or _DATA
        real(wp) :: spacing_ = 1.0_wp               !! intermediate spacing: time units, arc length or data points
        integer :: direction_ = MARKER_START        !! intermediate markers counted from MARKER_START or MARKER_END
        real(wp) :: start_color(4) = [1.0_wp, 0.0_wp, 0.0_wp, 1.0_wp]  !! start marker color [r, g, b, a] (red)
        real(wp) :: end_color(4) = [1.0_wp, 0.0_wp, 0.0_wp, 1.0_wp]  !! end marker color (red)
        real(wp) :: intermediate_color(4) = [1.0_wp, 1.0_wp, 1.0_wp, 1.0_wp]  !! intermediate marker color (white)
        real(wp) :: size_ = 10.0_wp                 !! marker size (window units)
        integer :: shape_ = MARKER_DISK             !! marker shape: a MARKER_* shape constant
        character(len=:), allocatable :: image_file  !! the marker image file ('': none)
        type(c_ptr) :: image = c_null_ptr           !! the image read from it (owned; null: none)
        logical :: attenuate = .true.               !! auto-attenuation (see set_auto_attenuate; on by default)
        logical :: point_colors_ = .false.          !! the trajectory's colors, if any (see set_point_colors)
        ! rendering
        type(c_ptr) :: group = c_null_ptr           !! the artist's group (null until built)
        logical :: shown = .false.                  !! built for a window (marker nodes made later are compiled)
        integer :: n_colors_seen = 0                !! the trajectory's colors when the markers were written
        type(LineChain) :: start_node, end_node, inter  !! start, end and intermediate marker buffers
        logical :: drawn = .false.                  !! drawn at least once since built
        integer :: n_seen = 0                       !! points seen (for the bounds)
        real(wp) :: lo(3) = 0.0_wp, hi(3) = 0.0_wp  !! bounds of the points seen
        real(wp) :: radius = 0.0_wp                 !! attenuation radius applied
        ! intermediate markers: in trajectory order, and where to continue
        real(wp), allocatable :: inter_xyz(:,:), inter_t(:)  !! intermediate markers' points and times (1:n_inter)
        real(wp), allocatable :: inter_rgba(:,:)    !! (4, :) their colors (with point colors)
        integer :: n_inter = 0, n_inter_written = 0, n_inter_drawn = 0  !! intermediate markers computed, written, drawn
        integer :: inter_first = 1                  !! the first intermediate marker drawn (trace, decreasing times: later)
        real(wp) :: next_time = 0.0_wp              !! time of the next marker (INTERMEDIATE_TIME)
        integer :: next_index = 0                   !! where to continue (0: not started)
        real(wp) :: arc = 0.0_wp, prev_arc = 0.0_wp, target = 0.0_wp, prev_point(3) = 0.0_wp
        !! arc length (INTERMEDIATE_DISTANCE): so far, at prev_point, and of the next marker; the last point
        logical :: start_shown = .false., end_shown = .false.  !! the start and end markers are drawn
    contains
        procedure :: set_trajectory => marker_set_trajectory
        procedure :: set_x_data => marker_set_x_data, set_y_data => marker_set_y_data
        procedure :: set_z_data => marker_set_z_data, data_sources => marker_data_sources
        procedure :: set_markers, markers
        procedure :: set_marker_color, marker_color
        procedure :: set_marker_size, marker_size
        procedure :: set_marker_shape, marker_shape
        procedure :: set_marker_image, marker_image_file
        procedure :: set_auto_attenuate, auto_attenuate
        procedure :: set_point_colors => marker_set_point_colors, point_colors => marker_point_colors
        procedure :: drawn_color => marker_drawn_color
        procedure :: set_intermediate_type, intermediate_type
        procedure :: set_intermediate_spacing, intermediate_spacing
        procedure :: set_intermediate_direction, intermediate_direction
        procedure :: build => marker_build
        procedure :: update => marker_update
        procedure :: release => marker_release
        procedure :: num_intermediate, drawn_marker
    end type MarkerArtist