time Function

private pure function time(self)

The handle's time.

Type Bound

TimeHandle

Arguments

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

Return Value real(kind=wp)


Source Code

    function new_time_handle(name, path, time, t_min, t_max, color) result(h)
        character(len=*), intent(in) :: name                !! the frame's name
        class(TimePath), intent(in), target :: path         !! the path it moves along
        real(wp), intent(in), optional :: time              !! its time
        real(wp), intent(in), optional :: t_min, t_max      !! the times a drag may reach
        real(wp), intent(in), optional :: color(:)          !! [r, g, b] or [r, g, b, a] (0 to 1)
        type(TimeHandle) :: h
        h%ReferenceFrame = ReferenceFrame(name, color)
        call h%show_decorations(.false.)
        h%priority_ = 1                                     ! (a marker over an arrow on the same spot)
        h%path_ => path
        if (present(time)) h%time_ = time
        h%t_min = h%time_
        h%t_max = h%time_
        if (present(t_min)) h%t_min = t_min
        if (present(t_max)) h%t_max = t_max
        call h%set_time(h%time_)
    end function new_time_handle

    !> The path the handle moves along (which must stay alive while used); its
    !> time kept (the frame placed on the new path).
    subroutine set_path(self, path)
        class(TimeHandle), intent(inout) :: self
        class(TimePath), intent(in), target :: path         !! the path
        self%path_ => path
        call self%set_time(self%time_)
    end subroutine set_path

    !> The handle's time (kept within its time range): the frame placed at the
    !> path's point for it.
    subroutine set_time(self, time)
        class(TimeHandle), intent(inout) :: self
        real(wp), intent(in) :: time                        !! the time
        self%time_ = max(self%t_min, min(self%t_max, time))
        if (associated(self%path_)) call self%set_position(self%path_%position(self%time_))
    end subroutine set_time

    !> The handle's time.
    pure real(wp) function time(self)
        class(TimeHandle), intent(in) :: self
        time = self%time_
    end function time