visualdynamics.viz.pick¶
pick
¶
Finding the entity under the cursor.
Picking is done in screen space: project the geometry through the camera once, then ask which entity is nearest the cursor in pixels. That is the question the user is actually asking — "what is under my pointer" — and it answers it whether or not a ray would have hit anything, which matters for a wireframe where most of the screen is empty space between thin lines.
The projection is cached and rebuilt only when the camera moves, so a mouse move costs one vectorized distance computation.
Pure VTK and numpy: no picking hardware, no extra dependencies.
Classes:
| Name | Description |
|---|---|
ScreenProjector |
Projects a geometry's nodes to pixels, cached against camera moves. |
EntityPicker |
Which node, coordinate system, traceline or element is under a pixel. |
Classes¶
ScreenProjector
¶
Projects a geometry's nodes to pixels, cached against camera moves.
Methods:
| Name | Description |
|---|---|
screen |
(pixels (N,2), depth (N,)) for every node, from the cache. |
reference_depth |
Depth to place a new point at: that of the nearest existing node. |
place_point |
Where to put a new point clicked at (x, y). |
unproject |
The world point under a pixel, at a given (or inferred) depth. |
Source code in src/visualdynamics/viz/pick.py
Methods:¶
screen
¶
(pixels (N,2), depth (N,)) for every node, from the cache.
Source code in src/visualdynamics/viz/pick.py
reference_depth
¶
Depth to place a new point at: that of the nearest existing node.
A click gives two dimensions; the third has to come from somewhere. Borrowing the nearest node's depth puts the new point on a plane through the model near where the user clicked, which is where they are looking.
Source code in src/visualdynamics/viz/pick.py
place_point
¶
Where to put a new point clicked at (x, y).
The click gives two dimensions. The third comes from the model: the click ray is intersected with a plane through the nearest node. For a flat model — a plate, a panel — that plane is the model's own, so the new point lands on it rather than floating above; otherwise the plane faces the camera, which keeps the point near what was clicked.
Source code in src/visualdynamics/viz/pick.py
unproject
¶
The world point under a pixel, at a given (or inferred) depth.
Source code in src/visualdynamics/viz/pick.py
EntityPicker
¶
EntityPicker(
geometry: Geometry,
kind: str,
projector: ScreenProjector,
)
Which node, coordinate system, traceline or element is under a pixel.
Candidate geometry is reduced once to points or segments over node rows; a pick then projects, measures in pixels, and takes the nearest within the tolerance, breaking ties by depth so the front-most wins.
Methods:
| Name | Description |
|---|---|
pick |
The entity under (x, y) in pixels, or None. |
Source code in src/visualdynamics/viz/pick.py
Methods:¶
pick
¶
The entity under (x, y) in pixels, or None.
Returns a node id, a coordinate system id, or a traceline/element index, matching what the rest of the code uses to identify each kind.