add_view Subroutine

private subroutine add_view(self, v)

Add v to the end of the window's views (it must stay alive while added).

Views of the Earth and of a spacecraft (v and V switch between them):

earth_view = View(earth, earth)                                ! the Earth, turning with it
inertial_view = View(earth, craft, frame_type=ABSOLUTE_FRAME)  ! the spacecraft, in inertial axes
craft_view = View(earth, craft)                                ! the spacecraft, in its body axes
moon_view = View(earth, craft, moon)                           ! from the spacecraft, at the Moon
call window%add_view(earth_view)
call window%add_view(inertial_view)
call window%add_view(craft_view)
call window%add_view(moon_view)
call window%select_view(1)

Type Bound

WindowProxy

Arguments

Type IntentOptional Attributes Name
class(WindowProxy), intent(inout) :: self
type(View), intent(in), target :: v

the view (not owned)


Source Code

    subroutine add_view(self, v)
        class(WindowProxy), intent(inout) :: self
        type(View), intent(in), target :: v                 !! the view (not owned)
        type(ViewPointer), allocatable :: tmp(:)
        if (.not. allocated(self%views)) allocate(self%views(4))
        if (self%n_views == size(self%views)) then
            allocate(tmp(2 * self%n_views))
            tmp(1:self%n_views) = self%views(1:self%n_views)
            call move_alloc(tmp, self%views)
        end if
        self%n_views = self%n_views + 1
        self%views(self%n_views)%p => v
        if (self%current == 0) self%current = 1
    end subroutine add_view