Class: ModraUp::PickHelper
- Inherits:
-
Object
- Object
- ModraUp::PickHelper
Overview
Viewport picking. Obtain it from ModraUp::View#pick_helper. The same instance will be reused. #do_pick / #window_pick / #boundingbox_pick record the pick results; #init / #test_point / #pick_segment only test the screen aperture, unrelated to those records.
Constants # collapse
- ModraUp::PickHelper::PICK_INSIDE
#window_pick / #boundingbox_pick: The entity is completely inside the box.
- ModraUp::PickHelper::PICK_CROSSING
#window_pick / #boundingbox_pick: The element intersects with the box to be picked.
Instance Method Summary # collapse
-
#do_pick(x, y) ⇒ Integer
Picks at screen coordinates and returns the number of pick records. The aperture argument gives the side length of a square. Omit it or pass 0 to use the viewport's default click tolerance. If an edge takes priority, the results also include the face under the cursor and its path. The first record remains the native selection tool's best hit.
-
#init(x, y) ⇒ ModraUp::PickHelper
Record the screen coordinates and square aperture for subsequent multiple #test_point calls (only pass model points). The aperture is the width and height of the square in pixels; omit or use 0 for the default 5. No need to call #do_pick first.
- #test_point(point) ⇒ Boolean
- #count ⇒ Integer
-
#path_at(index) ⇒ Array<ModraUp::Drawingelement>, nil
The indexth pick path: from the current edit context group/instance to the leaf element. Out of bounds returns nil.
-
#all_picked ⇒ Array<ModraUp::Drawingelement>
The first element of each pick path in the current editing context. Nested hits will repeat groups/instances.
-
#best_picked ⇒ ModraUp::Drawingelement, nil
The frontmost hit in the current editing context (a group/instance or face/edge).
-
#view ⇒ ModraUp::View
The viewport to which this picker belongs.
-
#leaf_at(index) ⇒ ModraUp::Drawingelement, nil
The leaf geometry at the index path (typically a face or edge).
-
#element_at(index) ⇒ ModraUp::Drawingelement, nil
The indexth path in the current edit context, corresponding to the item picked by #all_picked.
-
#depth_at(index) ⇒ Integer
The depth (path length) of the path at index index. Out of bounds returns 0.
-
#transformation_at(index) ⇒ Geom::Transformation, nil
Transform the leaf geometry coordinates to the current edit context's transformation. Out-of-bounds results in nil.
- #picked_face ⇒ ModraUp::Face, nil
- #picked_edge ⇒ ModraUp::Edge, nil
-
#picked_element ⇒ ModraUp::Drawingelement, nil
The best non-face-non-edge element (usually a group or component instance). With index, it refers to the element at that position in the path.
-
#pick_segment(points) ⇒ Integer, false
Determine if a pick segment falls within the screen aperture. Returns the index starting from 0 if a point is hit; returns -1, -2, etc., if a segment is hit. Returns false if not hit.
-
#window_pick(start_point, end_point, pick_type) ⇒ Integer
Rectangle screen pick. Ignore z. pick_type is PICK_INSIDE or PICK_CROSSING. Hits are recorded, then use #all_picked to get the current context elements.
-
#boundingbox_pick(bounding_box, pick_type) ⇒ Integer
Pick using the bounding box in model space. The transformation is applied to the box. The result is also added to #all_picked.
Instance Method Details
pick_helper.do_pick(x, y) ⇒ Integerpick_helper.do_pick(x, y, aperture) ⇒ Integer
Picks at screen coordinates and returns the number of pick records. The aperture argument gives the side length of a square. Omit it or pass 0 to use the viewport's default click tolerance. If an edge takes priority, the results also include the face under the cursor and its path. The first record remains the native selection tool's best hit.
pick_helper.init(x, y) ⇒ pick_helperpick_helper.init(x, y, aperture) ⇒ pick_helper
Record the screen coordinates and square aperture for subsequent multiple #test_point calls (only pass model points). The aperture is the width and height of the square in pixels; omit or use 0 for the default 5. No need to call #do_pick first.
pick_helper.test_point(point) ⇒ Booleanpick_helper.test_point(point, x, y) ⇒ Booleanpick_helper.test_point(point, x, y, aperture) ⇒ Boolean
pick_helper.count ⇒ Integer
The number of hits from the most recent #do_pick / #window_pick / #boundingbox_pick.
pick_helper.path_at(index) ⇒ Array, nil
The indexth pick path: from the current edit context group/instance to the leaf element. Out of bounds returns nil.
pick_helper.all_picked ⇒ Array
The first element of each pick path in the current editing context. Nested hits will repeat groups/instances.
pick_helper.best_picked ⇒ ModraUp::Drawingelement, nil
The frontmost hit in the current editing context (a group/instance or face/edge).
pick_helper.view ⇒ ModraUp::View
The viewport to which this picker belongs.
pick_helper.leaf_at(index) ⇒ ModraUp::Drawingelement, nil
The leaf geometry at the index path (typically a face or edge).
pick_helper.element_at(index) ⇒ ModraUp::Drawingelement, nil
The indexth path in the current edit context, corresponding to the item picked by #all_picked.
pick_helper.depth_at(index) ⇒ Integer
The depth (path length) of the path at index index. Out of bounds returns 0.
pick_helper.transformation_at(index) ⇒ Geom::Transformation, nil
Transform the leaf geometry coordinates to the current edit context's transformation. Out-of-bounds results in nil.
pick_helper.picked_face ⇒ ModraUp::Face, nil
pick_helper.picked_edge ⇒ ModraUp::Edge, nil
pick_helper.picked_element ⇒ ModraUp::Drawingelement, nilpick_helper.picked_element(index) ⇒ ModraUp::Drawingelement, nil
The best non-face-non-edge element (usually a group or component instance). With index, it refers to the element at that position in the path.
pick_helper.pick_segment(points) ⇒ Integer, falsepick_helper.pick_segment(points, x, y) ⇒ Integer, falsepick_helper.pick_segment(points, x, y, aperture) ⇒ Integer, false
pick_helper.window_pick(start_point, end_point, pick_type) ⇒ Integer
Rectangle screen pick. Ignore z. pick_type is PICK_INSIDE or PICK_CROSSING. Hits are recorded, then use #all_picked to get the current context elements.
pick_helper.boundingbox_pick(bounding_box, pick_type) ⇒ Integerpick_helper.boundingbox_pick(bounding_box, pick_type, transformation) ⇒ Integer
Pick using the bounding box in model space. The transformation is applied to the box. The result is also added to #all_picked.