SkySphere Derived Type

type, public :: SkySphere

The sky behind a scene (OpenFrames' SkySphere; see the module documentation).


Inherits

type~~skysphere~~InheritsGraph type~skysphere SkySphere c_ptr c_ptr type~skysphere->c_ptr image, root, texture_switch, star_switch, texture_node, star_node, name_node, line_switch, line_node type~constellation Constellation type~skysphere->type~constellation groups type~starname StarName type~skysphere->type~starname names

Inherited by

type~~skysphere~~InheritedByGraph type~skysphere SkySphere type~windowproxy WindowProxy type~windowproxy->type~skysphere sky_

Components

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

in the root frame (quaternion [x, y, z, w])

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

star catalog file (unallocated or '': none)

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

the file read (unallocated: none yet)

type(Constellation), private, allocatable :: groups(:)

the constellations read (n_groups of them)

type(c_ptr), private :: image = c_null_ptr

the texture image (null: none)

type(c_ptr), private :: line_node = c_null_ptr

the constellations drawing (null: none)

type(c_ptr), private :: line_switch = c_null_ptr

shows or hides the constellations (draw mode)

real(kind=c_float), private, allocatable :: lines(:,:)

(8, n): the lines' ends, directions (x, y, z, -)

real(kind=wp), private :: lines_rgba(4) = [0.35_wp, 0.5_wp, 0.8_wp, 0.45_wp]

their color (faint)

logical, private :: lines_shown = .false.

the constellations are drawn

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

window units

real(kind=wp), private :: mag_range(2) = 0.0_wp

of the stars read

real(kind=wp), private :: max_mag = 8.0_wp

OpenFrames' SkySphere defaults

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

window units

integer, private :: max_stars = 10000

the most stars drawn

real(kind=wp), private :: min_dim = 0.5_wp

the smallest stars' color scale (0 to 1)

real(kind=wp), private :: min_mag = -2.0_wp

OpenFrames' SkySphere defaults

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

window units

integer, private :: mode = SKY_TEXTURE+SKY_STARS

SKY_NONE, or a sum of SKY_TEXTURE and SKY_STARS

integer, private :: n_groups = 0

constellations read

integer, private :: n_labels = 0

names drawn

integer, private :: n_lines = 0

lines read: columns of lines used

integer, private :: n_names = 0

named stars read

integer, private :: n_stars = 0

stars read: columns of stars used

type(c_ptr), private :: name_node = c_null_ptr

the star names, a transform: the attitude (null: none)

type(StarName), private, allocatable :: names(:)

the named stars read (n_names of them)

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

font ('' or unallocated: the default)

real(kind=wp), private :: names_max_mag = huge(1.0_wp)

names of stars up to this magnitude

real(kind=wp), private :: names_rgba(4) = [0.6_wp, 0.7_wp, 0.9_wp, 1.0_wp]

color

logical, private :: names_shown = .false.

the names are drawn

real(kind=wp), private :: names_size = 12.0_wp

window units

type(c_ptr), private :: root = c_null_ptr

the sky's node, a transform (null until made)

logical, private :: shown = .false.

made for a window: nodes made later are compiled

type(c_ptr), private :: star_node = c_null_ptr

the stars drawing (null: none)

type(c_ptr), private :: star_switch = c_null_ptr

shows or hides the stars (draw mode)

real(kind=c_float), private, allocatable :: stars(:,:)

(8, n): direction, size, rgb, -

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

texture image file (unallocated or '': none)

type(c_ptr), private :: texture_node = c_null_ptr

the texture drawing (null: none)

type(c_ptr), private :: texture_switch = c_null_ptr

shows or hides the texture (draw mode)


Type-Bound Procedures

procedure, public :: attitude

  • private pure function attitude(self) result(q)

    The sky's attitude in the root frame (quaternion [x, y, z, w]).

    Arguments

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

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

procedure, public :: constellation_file_read

  • private function constellation_file_read(self) result(file)

    The constellation file read ('' for none).

    Arguments

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

    Return Value character(len=:), allocatable

procedure, public :: constellation_line

  • private pure subroutine constellation_line(self, i, a, b)

    Constellation line i (1 to num_constellation_lines): its ends' directions (unit vectors, sky frame).

    Arguments

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

    1 to num_constellation_lines

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

    unit vectors, sky frame

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

    unit vectors, sky frame

procedure, public :: constellation_lines

  • private pure subroutine constellation_lines(self, i, first, last)

    Constellation i's lines (1 to num_constellations): first .. last (see constellation_line; none if last < first).

    Arguments

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

    1 to num_constellations

    integer, intent(out) :: first

    its lines

    integer, intent(out) :: last

    its lines

procedure, public :: constellation_name

  • private function constellation_name(self, i) result(name)

    Constellation i's name (1 to num_constellations).

    Arguments

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

    1 to num_constellations

    Return Value character(len=:), allocatable

procedure, public :: constellations

  • private pure function constellations(self)

    Whether the constellations are drawn (as set).

    Arguments

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

    Return Value logical

procedure, public :: draw_mode

  • private pure function draw_mode(self)

    What is drawn: SKY_NONE, or a sum of SKY_TEXTURE and SKY_STARS.

    Arguments

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

    Return Value integer

procedure, public :: node

  • private function node(self, viewer) result(n)

    The sky's node, made on first use, for a window (set_sky). For a window's viewer (null: headless), nodes made later (a new texture or catalog) are compiled for the windows running.

    Arguments

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

    a window's viewer (null: headless)

    Return Value type(c_ptr)

procedure, public :: num_constellation_lines

  • private pure function num_constellation_lines(self)

    Number of constellation lines read (of all of them).

    Arguments

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

    Return Value integer

procedure, public :: num_constellations

  • private pure function num_constellations(self)

    Number of constellations read.

    Arguments

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

    Return Value integer

procedure, public :: num_star_names

  • private pure function num_star_names(self)

    Number of named stars read (of the stars read).

    Arguments

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

    Return Value integer

procedure, public :: num_star_names_drawn

  • private pure function num_star_names_drawn(self)

    Number of star names drawn now (0 until the sky is shown, or if the names aren't).

    Arguments

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

    Return Value integer

procedure, public :: num_stars

  • private pure function num_stars(self)

    Number of stars read.

    Arguments

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

    Return Value integer

procedure, public :: set_attitude

  • private subroutine set_attitude(self, q)

    The sky's attitude in the root frame (quaternion [x, y, z, w]): e.g. to turn an equatorial catalog into an ecliptic root frame.

    Arguments

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

    quaternion [x, y, z, w] (any length > 0)

procedure, public :: set_constellations

  • private function set_constellations(self, shown, file, rgba, width) result(ok)

    Draw the constellations: faint lines between their stars, from constellation file file (found with find_data_file; read when given, or when first shown without one: default_constellations), shown (default false), in color rgba (default a faint blue, alpha 0.45) and width window units wide (default 1). Also while shown; the settings not given are kept. Returns false if the file can't be read (the constellations read before are kept) or width isn't > 0 (nothing changed).

    Arguments

    Type IntentOptional Attributes Name
    class(SkySphere), intent(inout) :: self
    logical, intent(in) :: shown

    draw the constellations

    character(len=*), intent(in), optional :: file

    constellation file

    real(kind=wp), intent(in), optional :: rgba(4)

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

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

    window units (> 0)

    Return Value logical

procedure, public :: set_draw_mode

  • private subroutine set_draw_mode(self, mode)

    What to draw: SKY_NONE, or SKY_TEXTURE + SKY_STARS (default; each only if given).

    Arguments

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

    SKY_NONE, or a sum of SKY_TEXTURE and SKY_STARS

procedure, public :: set_star_data

  • private function set_star_data(self, catalog, min_mag, max_mag, max_stars, min_size, max_size, min_dim_ratio) result(ok)

    Draw the stars of catalog (found with find_data_file; '' for none) with magnitudes from min_mag to max_mag (default -2 to 8), at most max_stars (default 10000), sized from min_size to max_size window units (default 1 to 10) by brightness, the smallest dimmed to min_dim_ratio (0 to 1, default 0.5) of their color (OpenFrames' setSkySphereStarData). Returns false if the catalog cannot be read or the limits are invalid (min_mag > max_mag, max_stars < 1, min_size > max_size, a ratio outside 0 to 1).

    Arguments

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

    star catalog file; '' for none

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

    apparent magnitudes

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

    apparent magnitudes

    integer, intent(in), optional :: max_stars

    the most stars drawn (default 10000; >= 1)

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

    window units

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

    window units

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

    0 to 1

    Return Value logical

procedure, public :: set_star_names

  • private function set_star_names(self, shown, max_mag, size, rgba, font) result(ok)

    Draw the names of the named stars drawn (those of the catalog's last field), beside them: shown (default false), of the stars up to magnitude max_mag (default all of them), size window units tall (default 12), in color rgba (default a pale blue) and font font ('' or default: vkframes' default font). Also while shown; the settings not given are kept. Returns false (nothing changed) if size isn't > 0.

    Arguments

    Type IntentOptional Attributes Name
    class(SkySphere), intent(inout) :: self
    logical, intent(in) :: shown

    draw the names

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

    the dimmest named (apparent magnitude)

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

    height in window units (> 0)

    real(kind=wp), intent(in), optional :: rgba(4)

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

    character(len=*), intent(in), optional :: font

    font file ('' for the default)

    Return Value logical

procedure, public :: set_texture_map

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

    Draw an image file as the sky (found with find_data_file); '' for none. Returns false if it cannot be read (the sky is then unchanged).

    Arguments

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

    image file; '' for none

    Return Value logical

procedure, public :: star

  • private pure subroutine star(self, i, direction, rgb, size)

    Star i (1 to num_stars): its direction (unit vector, sky frame), color (rgb, dimmed) and size (window units).

    Arguments

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

    1 to num_stars

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

    unit vector, sky frame

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

    color, dimmed (0 to 1)

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

    window units

procedure, public :: star_catalog

  • private function star_catalog(self) result(file)

    The star catalog file ('' for none).

    Arguments

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

    Return Value character(len=:), allocatable

procedure, public :: star_magnitude_range

  • private pure function star_magnitude_range(self) result(m)

    The range of magnitudes of the stars read.

    Arguments

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

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

procedure, public :: star_magnitudes

  • private pure function star_magnitudes(self) result(m)

    The magnitude range drawn (as set).

    Arguments

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

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

procedure, public :: star_name

  • private subroutine star_name(self, i, name, mag, which)

    Named star i (1 to num_star_names): its name, apparent magnitude and star (1 to num_stars: see star).

    Arguments

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

    1 to num_star_names

    character(len=:), intent(out), allocatable :: name

    the catalog's name

    real(kind=wp), intent(out) :: mag

    apparent magnitude

    integer, intent(out) :: which

    the star (1 to num_stars)

procedure, public :: star_names

  • private pure function star_names(self)

    Whether the star names are drawn (as set).

    Arguments

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

    Return Value logical

procedure, public :: star_sizes

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

    The size range of the stars (window units).

    Arguments

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

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

procedure, public :: texture_map

  • private function texture_map(self) result(file)

    The texture file ('' for none).

    Arguments

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

    Return Value character(len=:), allocatable

Source Code

    type, public :: SkySphere
        private
        character(len=:), allocatable :: texture_file       !! texture image file (unallocated or '': none)
        character(len=:), allocatable :: catalog            !! star catalog file (unallocated or '': none)
        real(wp) :: min_mag = -2.0_wp, max_mag = 8.0_wp     !! OpenFrames' SkySphere defaults
        integer :: max_stars = 10000                        !! the most stars drawn
        real(wp) :: min_size = 1.0_wp, max_size = 10.0_wp   !! window units
        real(wp) :: min_dim = 0.5_wp                        !! the smallest stars' color scale (0 to 1)
        integer :: mode = SKY_TEXTURE + SKY_STARS           !! SKY_NONE, or a sum of SKY_TEXTURE and SKY_STARS
        real(wp) :: attitude_(4) = [0.0_wp, 0.0_wp, 0.0_wp, 1.0_wp]  !! in the root frame (quaternion [x, y, z, w])
        real(c_float), allocatable :: stars(:,:)            !! (8, n): direction, size, rgb, -
        integer :: n_stars = 0                              !! stars read: columns of stars used
        real(wp) :: mag_range(2) = 0.0_wp                   !! of the stars read
        type(StarName), allocatable :: names(:)             !! the named stars read (n_names of them)
        integer :: n_names = 0                              !! named stars read
        ! star names
        logical :: names_shown = .false.                    !! the names are drawn
        real(wp) :: names_max_mag = huge(1.0_wp)            !! names of stars up to this magnitude
        real(wp) :: names_size = 12.0_wp                    !! window units
        real(wp) :: names_rgba(4) = [0.6_wp, 0.7_wp, 0.9_wp, 1.0_wp]  !! color
        character(len=:), allocatable :: names_font         !! font ('' or unallocated: the default)
        integer :: n_labels = 0                             !! names drawn
        ! constellations
        character(len=:), allocatable :: constellation_file !! the file read (unallocated: none yet)
        real(c_float), allocatable :: lines(:,:)            !! (8, n): the lines' ends, directions (x, y, z, -)
        integer :: n_lines = 0                              !! lines read: columns of lines used
        type(Constellation), allocatable :: groups(:)       !! the constellations read (n_groups of them)
        integer :: n_groups = 0                             !! constellations read
        logical :: lines_shown = .false.                    !! the constellations are drawn
        real(wp) :: lines_rgba(4) = [0.35_wp, 0.5_wp, 0.8_wp, 0.45_wp]  !! their color (faint)
        real(wp) :: lines_width = 1.0_wp                    !! window units
        ! rendering
        type(c_ptr) :: image = c_null_ptr                   !! the texture image (null: none)
        type(c_ptr) :: root = c_null_ptr                    !! the sky's node, a transform (null until made)
        type(c_ptr) :: texture_switch = c_null_ptr          !! shows or hides the texture (draw mode)
        type(c_ptr) :: star_switch = c_null_ptr             !! shows or hides the stars (draw mode)
        type(c_ptr) :: texture_node = c_null_ptr            !! the texture drawing (null: none)
        type(c_ptr) :: star_node = c_null_ptr               !! the stars drawing (null: none)
        type(c_ptr) :: name_node = c_null_ptr               !! the star names, a transform: the attitude (null: none)
        type(c_ptr) :: line_switch = c_null_ptr             !! shows or hides the constellations (draw mode)
        type(c_ptr) :: line_node = c_null_ptr               !! the constellations drawing (null: none)
        logical :: shown = .false.                          !! made for a window: nodes made later are compiled
    contains
        procedure :: set_texture_map, texture_map
        procedure :: set_star_data, star_catalog, star_magnitudes, star_sizes
        procedure :: num_stars, star_magnitude_range, star
        procedure :: set_star_names, star_names, num_star_names, num_star_names_drawn, star_name
        procedure :: set_constellations, constellations, constellation_file_read, num_constellations
        procedure :: num_constellation_lines, constellation_name, constellation_lines, constellation_line
        procedure :: set_draw_mode, draw_mode
        procedure :: set_attitude, attitude
        procedure :: node
    end type SkySphere