vector_pick Subroutine

private subroutine vector_pick(self, cam, to_root, hits, n)

Picked at its tip and along its head (within the tolerance, plus a few pixels), as PICK_HANDLE; else the frame's origin.

Type Bound

VectorHandle

Arguments

Type IntentOptional Attributes Name
class(VectorHandle), intent(in), target :: self
type(PickCamera), intent(in) :: cam

the camera and cursor of the pick

real(kind=wp), intent(in) :: to_root(4,4)

the frame's transform to the root frame

type(PickHit), intent(inout), allocatable :: hits(:)

hits so far, in hits(1:n); added to

integer, intent(inout) :: n

number of hits


Calls

proc~~vector_pick~~CallsGraph proc~vector_pick VectorHandle%vector_pick proc~add_pick_hit add_pick_hit proc~vector_pick->proc~add_pick_hit proc~arrow_sizes arrow_sizes proc~vector_pick->proc~arrow_sizes proc~contents_shown ReferenceFrame%contents_shown proc~vector_pick->proc~contents_shown proc~draggable DragHandle%draggable proc~vector_pick->proc~draggable proc~pick ReferenceFrame%pick proc~vector_pick->proc~pick proc~point_pick point_pick proc~vector_pick->proc~point_pick proc~segment_pick segment_pick proc~vector_pick->proc~segment_pick proc~tip VectorHandle%tip proc~vector_pick->proc~tip proc~wants wants proc~vector_pick->proc~wants proc~arrow_sizes->proc~tip proc~pick->proc~add_pick_hit proc~pick->proc~point_pick proc~pick->proc~wants proc~project project proc~point_pick->proc~project proc~segment_pick->proc~project

Source Code

    subroutine vector_pick(self, cam, to_root, hits, n)
        class(VectorHandle), intent(in), target :: self
        type(PickCamera), intent(in) :: cam                 !! the camera and cursor of the pick
        real(wp), intent(in) :: to_root(4,4)                !! the frame's transform to the root frame
        type(PickHit), allocatable, intent(inout) :: hits(:)  !! hits so far, in hits(1:n); added to
        integer, intent(inout) :: n                         !! number of hits
        type(PickHit) :: h
        real(wp) :: p(3), base(3), len, head_len, radius, pixels, depth, s, head_pixels, head_depth
        logical :: at_tip, on_head
        call self%ReferenceFrame%pick(cam, to_root, hits, n)
        if (.not. (self%draggable() .and. self%contents_shown() .and. wants(cam, PICK_HANDLE))) return
        call arrow_sizes(self, len, head_len, radius)
        if (len <= 0.0_wp) return
        p = matmul(to_root(1:3, 1:3), self%tip()) + to_root(1:3, 4)
        base = matmul(to_root(1:3, 1:3), self%tip() * (1.0_wp - head_len / len)) + to_root(1:3, 4)
        at_tip = point_pick(cam, p, pixels, depth, extra=6.0_wp * cam%pixel_ratio)
        on_head = segment_pick(cam, base, p, head_pixels, s, head_depth, extra=4.0_wp * cam%pixel_ratio)
        if (.not. (at_tip .or. on_head)) return
        if (on_head .and. (.not. at_tip .or. head_pixels < pixels)) then
            pixels = head_pixels
            depth = head_depth
        end if
        h%kind = PICK_HANDLE
        h%frame => self
        h%position = p
        h%local = self%tip()
        h%distance = depth
        h%pixels = pixels
        call add_pick_hit(hits, n, h)
    end subroutine vector_pick