IGLDisplayContext
Module: core
Manage rendering context, display objects, and selection state for an OpenGL viewer.
__init__
method
__init__(self, wglview: Any)
Initialize the display context with a viewer.
Args
| Name | Type | Description |
|---|---|---|
| wglview | The OpenGL viewer instance that will own this context. |
SetdisplayEnv
method
SetdisplayEnv(self, dispenv: IGLDisplayEnv)
GetdisplayEnv
method
GetdisplayEnv(self)
GetViewer
method
GetViewer(self)
Return the associated OpenGL viewer.
Returns
The viewer instance that owns this display context.
GetPicker
method
GetPicker(self)
Return the picker used for object selection and hit testing.
Returns
The IGLPicker instance managing picking operations.
SetRenderMode
method
SetRenderMode(self, mode: int)
Set the rendering mode for the viewer.
Args
| Name | Type | Description |
|---|---|---|
| mode | Render mode constant from RenderMode. |
AddAssembly
method
AddAssembly(self, assembly: Iterable[Any])
Add all bodies from an assembly to the display context.
Args
| Name | Type | Description |
|---|---|---|
| assembly | Iterable of assembly objects, each providing GetBodies(). |
AddGeo
method
AddGeo(self, wglbody: Any)
Add a geometry body to the display context.
Args
| Name | Type | Description |
|---|---|---|
| wglbody | Geometry body instance to add. |
AddShape
method
AddShape(self, obj: Union[IGLShape, IGLMesh])
Register a display object and incorporate its bounding box.
Args
| Name | Type | Description |
|---|---|---|
| obj | Shape or mesh object to add to the display dictionary. |
AddMesh
method
AddMesh(self, meshds: Any, draw_edges: bool)
Add a mesh dataset to the display context for mesh rendering.
Args
| Name | Type | Description |
|---|---|---|
| meshds | Mesh dataset used to construct an IGLMesh. | |
| draw_edges | Whether to draw edges for the mesh. |
ComputeBoundingBox
method
ComputeBoundingBox(self)
Recompute the scene bounding box from visible display objects.
GetBoundingBox
method
GetBoundingBox(self, recompute: bool)
Return the current bounding box for the display scene.
Args
| Name | Type | Description |
|---|---|---|
| recompute | If True, recompute the bounding box before returning. |
Returns
The aggregated IGLBoundingBox for all display objects.
IsVisible
method
IsVisible(self, objId: Any)
Return whether a display object is currently visible.
Args
| Name | Type | Description |
|---|---|---|
| objId | Identifier of the object to check. |
Returns
True if the object is visible, False if hidden or not found.
Show
method
Show(self, objId: Any)
Make a display object visible and update the viewer.
Args
| Name | Type | Description |
|---|---|---|
| objId | Identifier of the object to show. |
Erase
method
Erase(self, objId: Any)
Remove a display object from the scene and free GPU resources.
Args
| Name | Type | Description |
|---|---|---|
| objId | Identifier of the object to erase. |
Hide
method
Hide(self, objId: Any)
Hide a display object without removing it from the scene.
Args
| Name | Type | Description |
|---|---|---|
| objId | Identifier of the object to hide. |
HideSelectedBodies
method
HideSelectedBodies(self)
Hide all currently selected bodies in the scene.
ShowAll
method
ShowAll(self)
Show all display objects in the current context.
SetActiveFilterMode
method
SetActiveFilterMode(self, pFilter: int)
Set the active object selection filter.
Args
| Name | Type | Description |
|---|---|---|
| pFilter | Filter mode (body, face, edge) from IGLFilterMode. |
GetActiveFilterMode
method
GetActiveFilterMode(self)
Return the currently active selection filter.
Returns
The active IGLFilterMode value.
SetDisplayMode
method
SetDisplayMode(self, amode: int)
Set the rendering display mode and request a redraw.
Args
| Name | Type | Description |
|---|---|---|
| amode | Display mode constant from IGLDisplayMode. |
SetSelectionmode
method
SetSelectionmode(self, mode: int)
Set the selection mode for the context.
Args
| Name | Type | Description |
|---|---|---|
| mode | Selection mode constant from IGLSelectionmode. |
SetColor
method
SetColor(self, objId: Any, r: float, g: float, b: float)
Set the diffuse color of a display object.
Args
| Name | Type | Description |
|---|---|---|
| objId | Identifier of the object whose color is changed. | |
| r | Red component in [0, 1]. | |
| g | Green component in [0, 1]. | |
| b | Blue component in [0, 1]. |
SetTransparent
method
SetTransparent(self, objId: Any, factor: float)
Set object transparency and clear current selections.
Args
| Name | Type | Description |
|---|---|---|
| objId | Identifier of the object to make transparent. | |
| factor | Transparency factor, typically in [0, 1]. |
HilightBody
method
HilightBody(self, objId: Any)
Highlight a body in the scene for mouse-over or focus feedback.
Args
| Name | Type | Description |
|---|---|---|
| objId | Identifier of the body to highlight. |
SelectShape
method
SelectShape(self, objId: Any, faceids: List[int], edgeids: List[int], addsel: bool)
Select a shape or its sub-entities based on the active filter mode.
Args
| Name | Type | Description |
|---|---|---|
| objId | Identifier of the object to select. | |
| faceids | List of face IDs to select when in face selection mode. | |
| edgeids | List of edge IDs to select when in edge selection mode. | |
| addsel | If True, add to the existing selection; otherwise replace it. |
GetSelectedFaces
method
GetSelectedFaces(self)
Return the list of currently selected face IDs.
Returns
Selected face IDs in the current context.
GetSelectedEdges
method
GetSelectedEdges(self)
Return the list of currently selected edge IDs.
Returns
Selected edge IDs in the current context.
ClearAllSelections
method
ClearAllSelections(self)
Clear all selections across display objects and reset selection state.
ClearAllHighlights
method
ClearAllHighlights(self)
Clear all highlight feedback from display objects.
IsEmpty
method
IsEmpty(self)
Return whether there are no display objects in the context.
Returns
True if no display objects are present, False otherwise.
Clear
method
Clear(self)
Remove all display objects and reset the scene bounding box.
CurrentSelected
method
CurrentSelected(self)
Return the currently selected object ids based on active selection filter.
Returns
The selected display object ids, or None if no selection exists.
GetNumSelected
method
GetNumSelected(self)
Return the number of selected entities.
Returns
Count of currently selected objects or sub-entities.
GetGeoBodies
method
GetGeoBodies(self)
Return the list of underlying geometry bodies for rendering and picking.
Returns
List of geometry bodies or mesh datasets represented in the display.
GetGeoBody
method
GetGeoBody(self, bodyId: Any)
Return the geometric body associated with a display object.
Args
| Name | Type | Description |
|---|---|---|
| bodyId | Identifier of the display object. |
Returns
The underlying geometry body, or None if not found.
Render
method
Render(self)
Render all visible display objects using the current display mode.
MoveTo
method
MoveTo(self, posX: int, posY: int)
Handle mouse movement for hover highlighting in the scene.
Args
| Name | Type | Description |
|---|---|---|
| posX | Mouse X coordinate in window space. | |
| posY | Mouse Y coordinate in window space. |
Select
method
Select(self, posX: int, posY: int)
Perform selection at the specified window coordinates.
Args
| Name | Type | Description |
|---|---|---|
| posX | Mouse X coordinate in window space. | |
| posY | Mouse Y coordinate in window space. |
Returns
Identifier of the selected body / face / edge, or 0 if nothing was selected.
ShiftSelect
method
ShiftSelect(self, posX: int, posY: int)
Perform additive selection at the specified window coordinates.
Args
| Name | Type | Description |
|---|---|---|
| posX | Mouse X coordinate in window space. | |
| posY | Mouse Y coordinate in window space. |
Returns
Identifier of the selected body / face / edge, or 0 if nothing was selected.
ComputeTriadSize
method
ComputeTriadSize(self, scale: float)
Compute the size of the world triad based on the scene bounding box.
Args
| Name | Type | Description |
|---|---|---|
| scale | Scale factor applied to the scene diagonal length. |
Returns
Computed triad size.