View Derived Type

type, public :: View

A view (see the module documentation).


Inherits

type~~view~~InheritsGraph type~view View type~referenceframe ReferenceFrame type~view->type~referenceframe root, frame, lookat type~referenceframe->type~referenceframe follow_frame_ c_ptr c_ptr 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~framepointer FramePointer type~referenceframe->type~framepointer children, parents type~trajectoryfollower TrajectoryFollower type~referenceframe->type~trajectoryfollower follower_ type~framepointer->type~referenceframe p type~datasource DataSource type~trajectoryfollower->type~datasource sources_ type~trajectorypointer TrajectoryPointer type~trajectoryfollower->type~trajectorypointer trajs type~trajectory Trajectory type~trajectorypointer->type~trajectory p

Inherited by

type~~view~~InheritedByGraph type~view View type~cameraflight CameraFlight type~cameraflight->type~view from, to type~viewpointer ViewPointer type~viewpointer->type~view p type~windowproxy WindowProxy type~windowproxy->type~view default_view, shown type~windowproxy->type~cameraflight flight type~windowproxy->type~viewpointer views

Components

Type Visibility Attributes Name Initial
logical, private :: camera_pending = .false.

true if pending is to be applied when shown

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

kept center

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

camera center after a reset (view-frame coordinates)

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

radius framed on reset (<= 0: the frame's bound)

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

camera eye after a reset (view-frame coordinates)

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

camera up after a reset (zero: no default camera)

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

kept eye

real(kind=wp), private :: fovy = 45.0_wp

vertical field of view (degrees)

class(ReferenceFrame), private, pointer :: frame => null()

the viewed frame (not owned)

integer, private :: frame_type = RELATIVE_FRAME

ABSOLUTE_FRAME or RELATIVE_FRAME

logical, private :: has_state = .false.

true if eye, center, up are kept

class(ReferenceFrame), private, pointer :: lookat => null()

the frame looked at (view between frames; not owned)

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

left, right, bottom, top

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

a camera set (eye, center, up), for when it is shown

integer, private :: projection = PERSPECTIVE

ORTHOGRAPHIC or PERSPECTIVE

logical, private :: reset_pending = .true.

true if the camera is to be reset when shown

class(ReferenceFrame), private, pointer :: root => null()

the root of the frames' tree (not owned)

integer, private :: rotation_type = VIEW_AZEL

VIEW_DIRECT or VIEW_AZEL

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

kept up direction


Constructor

public interface View

The View constructor: View(...) makes one (see new_view for its arguments).

  • private function new_view(root, frame, lookat, frame_type, rotation_type) result(v)

    A view of frame (in the tree of root), with base frame_type (default RELATIVE_FRAME); with lookat, a view from frame at lookat, turned by rotation_type (default VIEW_AZEL). Without frames, the view looks at the root frame's origin. The frames must stay alive while the view is used.

    Arguments

    Type IntentOptional Attributes Name
    class(ReferenceFrame), intent(in), optional, target :: root

    the tree's root, viewed and looked-at frames

    class(ReferenceFrame), intent(in), optional, target :: frame

    the tree's root, viewed and looked-at frames

    class(ReferenceFrame), intent(in), optional, target :: lookat

    the tree's root, viewed and looked-at frames

    integer, intent(in), optional :: frame_type

    ABSOLUTE_FRAME or RELATIVE_FRAME

    integer, intent(in), optional :: rotation_type

    VIEW_DIRECT or VIEW_AZEL

    Return Value type(View)


Type-Bound Procedures

procedure, public :: clear_default_view_parameters

procedure, public :: default_view_distance

  • private pure function default_view_distance(self)

    The radius framed when the view is reset (<= 0: the viewed frame's bound).

    Arguments

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

    Return Value real(kind=wp)

procedure, public :: default_view_parameters

  • private pure subroutine default_view_parameters(self, eye, center, up)

    The camera after a reset (view-frame coordinates; all zero if none is set).

    Arguments

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

    the camera (view-frame coordinates; zero if not set)

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

    the camera (view-frame coordinates; zero if not set)

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

    the camera (view-frame coordinates; zero if not set)

procedure, public :: field_of_view

  • private pure function field_of_view(self) result(fovy)

    The vertical field of view (degrees) of the perspective projection.

    Arguments

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

    Return Value real(kind=wp)

procedure, public :: home

  • private subroutine home(self, aspect, eye, center, up)

    The default camera (eye, center, up in view-frame coordinates) for a viewport of aspect ratio aspect (width / height): OpenFrames' resetView.

    Arguments

    Type IntentOptional Attributes Name
    class(View), intent(in) :: self
    real(kind=wp), intent(in) :: aspect

    viewport width / height

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

    the default camera (view-frame coordinates)

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

    the default camera (view-frame coordinates)

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

    the default camera (view-frame coordinates)

procedure, public :: is_valid

  • private function is_valid(self)

    True if the view has a frame to view.

    Arguments

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

    Return Value logical

procedure, public :: lookat_frame

  • private function lookat_frame(self) result(f)

    The frame looked at, for a view between frames (null if none).

    Arguments

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

    Return Value class(ReferenceFrame), pointer

procedure, public :: orthographic_bounds

  • private pure function orthographic_bounds(self) result(bounds)

    The bounds [left, right, bottom, top] of the orthographic projection.

    Arguments

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

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

procedure, public :: projection_type

  • private pure function projection_type(self)

    The projection: ORTHOGRAPHIC or PERSPECTIVE.

    Arguments

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

    Return Value integer

procedure, public :: reset_view

  • private subroutine reset_view(self)

    Put the camera back at the default position (applied at the next frame in which the view is shown).

    Arguments

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

procedure, public :: save_state

  • private subroutine save_state(self, eye, center, up)

    Keep the trackball state while another view is shown.

    Arguments

    Type IntentOptional Attributes Name
    class(View), intent(inout) :: self
    real(kind=wp), intent(in) :: eye(3)

    the trackball state (view-frame coordinates)

    real(kind=wp), intent(in) :: center(3)

    the trackball state (view-frame coordinates)

    real(kind=wp), intent(in) :: up(3)

    the trackball state (view-frame coordinates)

procedure, public :: saved_state

  • private function saved_state(self, eye, center, up)

    The kept trackball state; false if there is none.

    Arguments

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

    the kept trackball state (view-frame coordinates)

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

    the kept trackball state (view-frame coordinates)

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

    the kept trackball state (view-frame coordinates)

    Return Value logical

procedure, public :: set_camera => view_set_camera

  • private subroutine view_set_camera(self, eye, center, up)

    The camera (view-frame coordinates) to show the next time the view is drawn (at once if it is shown: the window's set_camera can also fly there). It replaces a pending reset.

    Arguments

    Type IntentOptional Attributes Name
    class(View), intent(inout) :: self
    real(kind=wp), intent(in) :: eye(3)

    the camera (view-frame coordinates)

    real(kind=wp), intent(in) :: center(3)

    the camera (view-frame coordinates)

    real(kind=wp), intent(in) :: up(3)

    the camera (view-frame coordinates)

procedure, public :: set_default_view_distance

  • private subroutine set_default_view_distance(self, distance)

    The radius to frame when the view is reset (<= 0: the viewed frame's bound, the default), as OpenFrames' default view distance.

    Arguments

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

    radius (<= 0: the frame's bound)

procedure, public :: set_default_view_parameters

  • private subroutine set_default_view_parameters(self, eye, center, up)

    The camera after a reset, in view-frame coordinates (overrides the default view distance).

    Arguments

    Type IntentOptional Attributes Name
    class(View), intent(inout) :: self
    real(kind=wp), intent(in) :: eye(3)

    the camera (view-frame coordinates)

    real(kind=wp), intent(in) :: center(3)

    the camera (view-frame coordinates)

    real(kind=wp), intent(in) :: up(3)

    the camera (view-frame coordinates)

procedure, public :: set_orthographic

  • private subroutine set_orthographic(self, left, right, bottom, top)

    An orthographic projection with the given bounds (in view units).

    Arguments

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

    bounds (view units)

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

    bounds (view units)

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

    bounds (view units)

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

    bounds (view units)

procedure, public :: set_perspective

  • private subroutine set_perspective(self, fovy)

    A perspective projection with vertical field of view fovy (degrees; default 45).

    Arguments

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

    vertical field of view (degrees)

procedure, public :: set_view_between_frames

  • private subroutine set_view_between_frames(self, root, frame, lookat, frame_type, rotation_type)

    Look from frame at lookat (both in the tree of root).

    Arguments

    Type IntentOptional Attributes Name
    class(View), intent(inout) :: self
    class(ReferenceFrame), intent(in), target :: root

    the tree's root, viewed and looked-at frames

    class(ReferenceFrame), intent(in), target :: frame

    the tree's root, viewed and looked-at frames

    class(ReferenceFrame), intent(in), target :: lookat

    the tree's root, viewed and looked-at frames

    integer, intent(in), optional :: frame_type

    ABSOLUTE_FRAME or RELATIVE_FRAME (default)

    integer, intent(in), optional :: rotation_type

    VIEW_DIRECT or VIEW_AZEL (default)

procedure, public :: set_view_frame

  • private subroutine set_view_frame(self, root, frame, frame_type)

    View frame (in the tree of root) with base frame_type (default RELATIVE_FRAME).

    Arguments

    Type IntentOptional Attributes Name
    class(View), intent(inout) :: self
    class(ReferenceFrame), intent(in), target :: root

    the tree's root; the viewed frame (not owned)

    class(ReferenceFrame), intent(in), target :: frame

    the tree's root; the viewed frame (not owned)

    integer, intent(in), optional :: frame_type

    ABSOLUTE_FRAME or RELATIVE_FRAME

procedure, public :: take_camera

  • private function take_camera(self, cam)

    True (once) if a camera was set (set_camera), and that camera.

    Arguments

    Type IntentOptional Attributes Name
    class(View), intent(inout) :: self
    real(kind=wp), intent(out) :: cam(3,3)

    (columns: eye, center, up (view-frame coordinates))

    Return Value logical

procedure, public :: take_reset

  • private function take_reset(self)

    True (once) if a reset is pending.

    Arguments

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

    Return Value logical

procedure, public :: view_frame

  • private function view_frame(self) result(f)

    The viewed frame (null if none).

    Arguments

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

    Return Value class(ReferenceFrame), pointer

procedure, public :: view_frame_type

  • private pure function view_frame_type(self)

    The base of the trackball: ABSOLUTE_FRAME or RELATIVE_FRAME.

    Arguments

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

    Return Value integer

procedure, public :: view_root

  • private function view_root(self) result(f)

    The root of the viewed frames' tree (null if none).

    Arguments

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

    Return Value class(ReferenceFrame), pointer

procedure, public :: view_rotation_type

  • private pure function view_rotation_type(self)

    How a view between frames turns: VIEW_DIRECT or VIEW_AZEL.

    Arguments

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

    Return Value integer

procedure, public :: world_to_view

  • private function world_to_view(self) result(m)

    The transform from the root frame to the view frame (4x4), from the frames' current positions and attitudes.

    Arguments

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

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

Source Code

    type, public :: View
        private
        class(ReferenceFrame), pointer :: root => null()    !! the root of the frames' tree (not owned)
        class(ReferenceFrame), pointer :: frame => null()   !! the viewed frame (not owned)
        class(ReferenceFrame), pointer :: lookat => null()  !! the frame looked at (view between frames; not owned)
        integer :: frame_type = RELATIVE_FRAME              !! ABSOLUTE_FRAME or RELATIVE_FRAME
        integer :: rotation_type = VIEW_AZEL                !! VIEW_DIRECT or VIEW_AZEL
        integer :: projection = PERSPECTIVE                 !! ORTHOGRAPHIC or PERSPECTIVE
        real(wp) :: fovy = 45.0_wp                          !! vertical field of view (degrees)
        real(wp) :: ortho(4) = [-1.0_wp, 1.0_wp, -1.0_wp, 1.0_wp]   !! left, right, bottom, top
        real(wp) :: default_distance = 0.0_wp               !! radius framed on reset (<= 0: the frame's bound)
        real(wp) :: default_eye(3) = 0.0_wp                 !! camera eye after a reset (view-frame coordinates)
        real(wp) :: default_center(3) = 0.0_wp              !! camera center after a reset (view-frame coordinates)
        real(wp) :: default_up(3) = 0.0_wp                  !! camera up after a reset (zero: no default camera)
        ! the trackball state of this view (view-frame coordinates), kept while another view is shown
        real(wp) :: eye(3) = 0.0_wp                         !! kept eye
        real(wp) :: center(3) = 0.0_wp                      !! kept center
        real(wp) :: up(3) = 0.0_wp                          !! kept up direction
        logical :: has_state = .false.                      !! true if eye, center, up are kept
        logical :: reset_pending = .true.                   !! true if the camera is to be reset when shown
        real(wp) :: pending(3,3) = 0.0_wp                  !! a camera set (eye, center, up), for when it is shown
        logical :: camera_pending = .false.                 !! true if `pending` is to be applied when shown
    contains
        procedure :: set_view_frame, set_view_between_frames
        procedure :: view_root, view_frame, lookat_frame, view_frame_type, view_rotation_type, is_valid
        procedure :: set_perspective, field_of_view, set_orthographic, orthographic_bounds, projection_type
        procedure :: set_default_view_distance, default_view_distance
        procedure :: set_default_view_parameters, default_view_parameters, clear_default_view_parameters
        procedure :: reset_view
        procedure :: world_to_view, home
        procedure :: save_state, saved_state, take_reset
        procedure :: set_camera => view_set_camera, take_camera
    end type View