Custom line segments, as OpenFrames' CustomLineSegments: a frame drawing line segments whose endpoints and colors (one per endpoint, blended along the segment) are set by the program (set_segments), or computed each frame by a callback (set_callback): e.g. lines of sight between spacecraft, or links between ground stations and satellites.
The endpoints are in the frame's own coordinates (the frame can move like
any other); position_of(other) gives another frame's origin in them. The
callback, an extension of the abstract LineSegmentsCallback (OpenFrames'
CustomLineSegments::Callback), is called once per scene update with the
simulation time, after the whole tree has been updated
(late_update), so the positions of other frames are those
for that time whatever their place in the tree; it sets the segments with
set_segments. Setting the same segments again uploads nothing.
The segments are drawn by a LineChain of separate segments (vkf_line_chain: thick lines in window units, square caps, dash patterns, points kept to double precision), with a color per point (vkf_line_create_colored). Without colors, the segments take the frame's color (set_color). (OpenFrames' custom line shader, setLineShader, isn't available: it would need GLSL compiled at run time.)
The CustomLineSegments constructor: CustomLineSegments(...) makes one (see new_custom_line_segments for its
arguments).
Line segments named name, of color (for segments set without
colors; default white) and width (window units; default 1).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | name |
the frame's name |
||
| real(kind=wp), | intent(in), | optional | :: | color(:) |
[r, g, b] or [r, g, b, a] (0 to 1) |
|
| real(kind=wp), | intent(in), | optional | :: | width |
line width (window units) |
Set segments' segments for simulation time t (with set_segments).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(LineSegmentsCallback), | intent(inout) | :: | self | |||
| class(CustomLineSegments), | intent(inout) | :: | segments |
the line segments the callback is set on |
||
| real(kind=wp), | intent(in) | :: | t |
simulation time (s) |
Line segments with a color per endpoint (see the module documentation).
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| real(kind=wp), | private, | allocatable | :: | a(:,:) |
(3, n): their endpoints (frame coordinates) |
||
| real(kind=wp), | private, | allocatable | :: | b(:,:) |
(3, n): their endpoints (frame coordinates) |
||
| class(LineSegmentsCallback), | private, | pointer | :: | callback | => | null() |
computes the segments each frame (not owned) |
| type(LineChain), | private | :: | chain |
draws the segments (separate, colored) |
|||
| logical, | private | :: | changed | = | .true. |
to write and upload at the next update |
|
| real(kind=c_float), | private, | allocatable | :: | color_a(:,:) |
(4, n), or not allocated: the frame's color |
||
| real(kind=c_float), | private, | allocatable | :: | color_b(:,:) |
(4, n), or not allocated: the frame's color |
||
| integer, | private | :: | n | = | 0 |
segments |
|
| integer, | private | :: | n_drawn | = | 0 |
segments written to the chain (drawn) |
|
| integer, | private | :: | pattern_ | = | int(z'FFFF') |
16-bit dash pattern (z'FFFF': solid) |
|
| integer, | private | :: | pattern_factor | = | 1 |
window units per bit of the dash pattern |
|
| real(kind=wp), | private | :: | width_ | = | 1.0_wp |
line width (window units) |
The CustomLineSegments constructor: CustomLineSegments(...) makes one (see new_custom_line_segments for its
arguments).
| private function new_custom_line_segments (name, color, width) | Line segments named |
| procedure, public :: add_child | |
| procedure, public :: attitude | |
| procedure, public :: axes_labels_shown | |
| procedure, public :: axes_shown | |
| procedure, public :: axis_label | |
| procedure, public :: bound => segments_bound | |
| procedure, public :: build_contents => segments_build_contents | |
| procedure, public :: child | |
| procedure, public :: child_index | |
| procedure, public :: clear_callback | |
| procedure, public :: clear_segments | |
| procedure, public :: color | |
| procedure, public :: contents_shown | |
| procedure, public :: detach | |
| procedure, public :: drawn_segment | |
| procedure, public :: follow | |
| procedure, public :: follow_frame | |
| procedure, public :: follower | |
| procedure, public :: frame_info => segments_frame_info | |
| procedure, public :: frame_string | |
| procedure, public :: has_light_source | |
| procedure, public :: is_following | |
| procedure, public :: label_alignment | |
| procedure, public :: label_font | |
| procedure, public :: label_size | |
| procedure, public :: late_update => segments_late_update | |
| procedure, public :: light_ambient | |
| procedure, public :: light_diffuse | |
| procedure, public :: light_source_enabled | |
| procedure, public :: light_specular | |
| procedure, public :: line_width | |
| procedure, public :: local_matrix | |
| procedure, public :: local_matrix_at | |
| procedure, public :: motion_key | |
| procedure, public :: move_x_axis | |
| procedure, public :: move_y_axis | |
| procedure, public :: move_z_axis | |
| procedure, public :: name | |
| procedure, public :: name_label_on_top | |
| procedure, public :: name_label_shown | |
| procedure, public :: node | |
| procedure, public :: num_children | |
| procedure, public :: num_drawn | |
| procedure, public :: num_parents | |
| procedure, public :: num_segments | |
| procedure, public :: parent | |
| procedure, public :: parent_index | |
| procedure, public :: pattern | |
| procedure, public :: pick | |
| procedure, public :: pickable | |
| procedure, public :: position | |
| procedure, public :: position_of | |
| procedure, public :: realize | |
| procedure, public :: remove_child | |
| procedure, public :: reposition_axes | |
| procedure, public :: segment | |
| procedure, public :: set_attitude | |
| procedure, public :: set_callback | |
| procedure, public :: set_color => segments_set_color | |
| procedure, public :: set_label_alignment | |
| procedure, public :: set_label_font | |
| procedure, public :: set_label_size | |
| procedure, public :: set_light_ambient | |
| procedure, public :: set_light_diffuse | |
| procedure, public :: set_light_source_enabled | |
| procedure, public :: set_light_specular | |
| procedure, public :: set_line_width | |
| procedure, public :: set_name | |
| procedure, public :: set_name_label_on_top | |
| procedure, public :: set_pattern | |
| procedure, public :: set_pickable | |
| procedure, public :: set_position | |
| procedure, public :: set_segments | |
| procedure, public :: set_x_label | |
| procedure, public :: set_y_label | |
| procedure, public :: set_z_label | |
| procedure, public :: show_axes | |
| procedure, public :: show_axes_labels | |
| procedure, public :: show_contents | |
| procedure, public :: show_decorations | |
| procedure, public :: show_name_label | |
| procedure, public :: sync | |
| procedure, public :: unfollow | |
| procedure, public :: update | |
| procedure, public :: world_matrix | |
| procedure, public :: world_matrix_at |
Computes a CustomLineSegments' segments each frame: extend it with a
compute procedure, which calls segments%set_segments (OpenFrames'
CustomLineSegments::Callback). The program owns the callback object (it
must stay alive while set).
| procedure(segments_compute), public, deferred :: compute |
Line width (window units).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(CustomLineSegments), | intent(in) | :: | self |
Line segments named name, of color (for segments set without
colors; default white) and width (window units; default 1).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | name |
the frame's name |
||
| real(kind=wp), | intent(in), | optional | :: | color(:) |
[r, g, b] or [r, g, b, a] (0 to 1) |
|
| real(kind=wp), | intent(in), | optional | :: | width |
line width (window units) |
Segments drawn now (0 until shown and updated).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(CustomLineSegments), | intent(in) | :: | self |
Number of segments set.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(CustomLineSegments), | intent(in) | :: | self |
Color i of c (color_a or color_b), or the frame's color if c is not allocated.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(CustomLineSegments), | intent(in) | :: | self | |||
| real(kind=c_float), | intent(in), | allocatable | :: | c(:,:) |
(4, n): [r, g, b, a] |
|
| integer, | intent(in) | :: | i |
1 to num_segments |
The kind of frame: 'CustomLineSegments'.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(CustomLineSegments), | intent(in) | :: | self |
Give the line width and dash pattern to the chain (if built).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(CustomLineSegments), | intent(inout) | :: | self |
Stop computing the segments with a callback (they stay as last set).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(CustomLineSegments), | intent(inout) | :: | self |
Remove all segments.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(CustomLineSegments), | intent(inout) | :: | self |
Segment i as drawn (read back from the GPU buffers, for checks): its endpoints and colors.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(CustomLineSegments), | intent(in) | :: | self | |||
| integer, | intent(in) | :: | i |
1 to num_drawn |
||
| real(kind=wp), | intent(out) | :: | a(3) |
endpoints (frame coordinates) |
||
| real(kind=wp), | intent(out) | :: | b(3) |
endpoints (frame coordinates) |
||
| real(kind=wp), | intent(out), | optional | :: | color_a(4) |
color at a: [r, g, b, a] |
|
| real(kind=wp), | intent(out), | optional | :: | color_b(4) |
color at b: [r, g, b, a] |
The dash pattern (see set_pattern).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(CustomLineSegments), | intent(in) | :: | self | |||
| integer, | intent(out) | :: | factor |
window units per bit |
||
| integer, | intent(out) | :: | bits |
16 bits, bit 0 first (65535: solid) |
Colors c (3 or 4 rows) into rgba(4, n) (alpha 1 if not given).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=wp), | intent(in) | :: | c(:,:) |
(3 or 4, n): [r, g, b(, a)] (0 to 1) |
||
| real(kind=c_float), | intent(out) | :: | out(:,:) |
(4, n): [r, g, b, a] |
Segment i: its endpoints, and their colors (rgba).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(CustomLineSegments), | intent(in) | :: | self | |||
| integer, | intent(in) | :: | i |
1 to num_segments |
||
| real(kind=wp), | intent(out) | :: | a(3) |
endpoints (frame coordinates) |
||
| real(kind=wp), | intent(out) | :: | b(3) |
endpoints (frame coordinates) |
||
| real(kind=wp), | intent(out), | optional | :: | color_a(4) |
color at a: [r, g, b, a] |
|
| real(kind=wp), | intent(out), | optional | :: | color_b(4) |
color at b: [r, g, b, a] |
The segments' bounding sphere (frame coordinates).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(CustomLineSegments), | intent(in) | :: | self | |||
| real(kind=wp), | intent(out) | :: | center(3) |
the bounding sphere, frame coordinates (scene units) |
||
| real(kind=wp), | intent(out) | :: | radius |
the bounding sphere, frame coordinates (scene units) |
The chain of separate segments with a color per point, under group.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(CustomLineSegments), | intent(inout) | :: | self | |||
| type(c_ptr), | intent(in) | :: | viewer |
a window's viewer handle (null: headless) |
||
| type(c_ptr), | intent(in) | :: | group |
the group node to draw under |
After the tree's update for time t: the callback's segments (all frames at their positions for t), written and uploaded if they changed.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(CustomLineSegments), | intent(inout) | :: | self | |||
| real(kind=wp), | intent(in) | :: | t |
simulation time (s) |
The frame's color: also that of segments set without colors.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(CustomLineSegments), | intent(inout) | :: | self | |||
| real(kind=wp), | intent(in) | :: | color(:) |
[r, g, b] or [r, g, b, a] (0 to 1) |
Compute the segments each frame with callback (see the module
documentation; it must stay alive while set).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(CustomLineSegments), | intent(inout) | :: | self | |||
| class(LineSegmentsCallback), | intent(in), | target | :: | callback |
the callback (not owned) |
Line width (window units: logical pixels).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(CustomLineSegments), | intent(inout) | :: | self | |||
| real(kind=wp), | intent(in) | :: | width |
(window units; >= 0) |
Dash pattern: OpenGL's line stipple (16 bits, bit 0 first, each factor
window units; 65535: solid), as set_pattern.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(CustomLineSegments), | intent(inout) | :: | self | |||
| integer, | intent(in) | :: | factor |
window units per bit (>= 1) |
||
| integer, | intent(in) | :: | pattern |
16 bits, bit 0 first (65535: solid) |
The segments: from a(:, i) to b(:, i) (frame coordinates), colored color_a(:, i) at a and color_b(:, i) at b ([r, g, b] or [r, g, b, a] columns; one of them for both ends; neither: the frame's color). Setting the same segments again changes nothing (no upload).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(CustomLineSegments), | intent(inout) | :: | self | |||
| real(kind=wp), | intent(in) | :: | a(:,:) |
(3, n): first endpoints (frame coordinates) |
||
| real(kind=wp), | intent(in) | :: | b(:,:) |
(3, n): second endpoints (frame coordinates) |
||
| real(kind=wp), | intent(in), | optional | :: | color_a(:,:) |
(3 or 4, n): colors at a, [r, g, b(, a)] (0 to 1) |
|
| real(kind=wp), | intent(in), | optional | :: | color_b(:,:) |
(3 or 4, n): colors at b, [r, g, b(, a)] (0 to 1) |
The segments into the chain: segment i as points 2i-1 (a) and 2i (b), with their colors; uploaded, and drawn.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(CustomLineSegments), | intent(inout) | :: | self |