IGLViewer

Module: graphics

Interactive OpenGL viewer widget for 3D mesh and FEA visualization. Manages camera interaction, rendering of the display context, selection, zoom region, axis triad overlays, and input handling for mouse-driven navigation and selection.

__init__

method
__init__(self, parent)
Initialize the viewer widget and default interaction state.

Args

Name Type Description
parent (QObject, optional) Parent Qt widget.

SetDeveloperKey

method
SetDeveloperKey(self, key: str)

CreateActions

method
CreateActions(self)

Reset

method
Reset(self)
Reset box selection state.

SetContext

method
SetContext(self, theContext: IGLDisplayContext)
Attach a display context to the viewer.

Args

Name Type Description
theContext (IGLDisplayContext) Context responsible for scene rendering and selection operations.

GetContext

method
GetContext(self)
Return the current display context.

Returns

IGLDisplayContext: The active display context.

initializeGL

method
initializeGL(self)
Initialize OpenGL state, shaders, and overlay triads.

GetWindowSize

method
GetWindowSize(self)
Return the current widget size.

Returns

tuple[int, int]: Width and height of the viewer in pixels.

SetLights

method
SetLights(self, enable: bool)
Enable or disable lighting for the rendered scene.

Args

Name Type Description
enable (bool) True to enable lighting, False to disable.

UpdateViewer

method
UpdateViewer(self)
Trigger a redraw of the viewer.

AddOverlayWidget

method
AddOverlayWidget(self, olwd)

GetScalarBar

method
GetScalarBar(self)

GetShader

method
GetShader(self)
Return the shader manager instance.

Returns

IGLShaders: Shader manager for rendering passes.

get_mvp

method
get_mvp(self)
Compute the current model-view-projection matrix.

Returns

Matrix: Projection matrix multiplied by view matrix.

GetCamera

method
GetCamera(self)
Return the camera controller.

Returns

IGLCamera: Camera used for view transforms and projection.

PreRender

method
PreRender(self)
Perform pre-render operations such as clearing buffers and drawing the origin triad.

Render

method
Render(self)
Render the attached display context.

PostRender

method
PostRender(self)
Render overlay elements such as the viewport triad.

SetBackground

method
SetBackground(self, r: float, g: float, b: float)
Set the viewer background color.

Args

Name Type Description
r (float) Red channel in [0.0, 1.0].
g (float) Green channel in [0.0, 1.0].
b (float) Blue channel in [0.0, 1.0].

SetGradientBackground

method
SetGradientBackground(self, bOn)

SetTopGradientColor

method
SetTopGradientColor(self, r, g, b)

SetBottomGradientColor

method
SetBottomGradientColor(self, r, g, b)

resizeGL

method
resizeGL(self, w, h)
Handle Qt resize events and update the camera viewport.

Args

Name Type Description
w (int) New width in pixels.
h (int) New height in pixels.

paintGL

method
paintGL(self)
Main Qt paint event for rendering the scene and overlays.

DrawRect

method
DrawRect(self, painter)
Draw the rubber-band zoom rectangle.

Args

Name Type Description
painter (QPainter) Painter used for 2D overlay rendering.

ResetCamera

method
ResetCamera(self)
Placeholder for camera reset functionality.

mousePressEvent

method
mousePressEvent(self, e)
Handle mouse press events for interaction state tracking.

mouseReleaseEvent

method
mouseReleaseEvent(self, e)
Handle mouse release events to finalize interaction modes.

mouseMoveEvent

method
mouseMoveEvent(self, e)
Handle mouse move events for camera manipulation and selection feedback.

wheelEvent

method
wheelEvent(self, e)
Handle mouse wheel events for zooming.

glLButtonDown

method
glLButtonDown(self, flags, point)
Track left mouse button press for rotation, panning, or zooming.

glLButtonUp

method
glLButtonUp(self, flags, point)
Handle left button release and perform picking if no drag mode is active.

glMButtonDown

method
glMButtonDown(self, flags, point)
Track middle mouse button press for camera panning or orbiting.

glMButtonUp

method
glMButtonUp(self, flags, point)
Handle middle mouse button release.

glRButtonDown

method
glRButtonDown(self, flags, point)
Start a rubber-band zoom selection with the right mouse button.

glRButtonUp

method
glRButtonUp(self, flags, point)
Complete the rubber-band zoom selection and execute zoom-to-region.

glMouseMove

method
glMouseMove(self, flags, point)
Update camera transformation or selection rectangle during mouse motion.

Args

Name Type Description
flags (Qt.KeyboardModifiers) Modifier keys state.
point (QPoint) Current mouse position.

glMouseWheel

method
glMouseWheel(self, flags, delta, pos)
Zoom the camera toward the current cursor position.

Args

Name Type Description
flags (Qt.KeyboardModifiers) Modifier keys state.
delta (int) Wheel delta from the event.
pos (QPoint) Cursor position.

pick

method
pick(self, posX, posY)
Perform object selection at the given viewport coordinates.

For single selection mode: OnViewerMsg is emitted with the selected body/Face/edge ID or -1 if selection is cleared. res is object id if self.theContext.GetActiveFilterMode() == IGLFilterMode.F_WGLBODY: self.OnViewerMsg.emit(res, 'BodyId') elif self.theContext.GetActiveFilterMode() == IGLFilterMode.F_WGLFACE: self.OnViewerMsg.emit(res, 'FaceId') elif self.theContext.GetActiveFilterMode() == IGLFilterMode.F_WGLEDGE: self.OnViewerMsg.emit(res, 'EdgeId') For multiple selection mode: only -1 is emitted when selection is cleared, otherwise the context manages the selection state. self.OnViewerMsg.emit(-1, 'Clear')

Args

Name Type Description
posX (int) X coordinate in widget space.
posY (int) Y coordinate in widget space.

FrontView

method
FrontView(self)
Switch the camera to the front orthographic view.

BackView

method
BackView(self)
Switch the camera to the back orthographic view.

TopView

method
TopView(self)
Switch the camera to the top orthographic view.

BottomView

method
BottomView(self)
Switch the camera to the bottom orthographic view.

RightView

method
RightView(self)
Switch the camera to the right orthographic view.

LeftView

method
LeftView(self)
Switch the camera to the left orthographic view.

IsometricView

method
IsometricView(self)
Switch the camera to an isometric view.

OnZoom

method
OnZoom(self)
Set the current interaction mode to zoom.

OnPan

method
OnPan(self)
Set the current interaction mode to pan.

OnRotate

method
OnRotate(self)
Set the current interaction mode to rotate.

OnZoomFit

method
OnZoomFit(self)
Fit the camera to the bounding box of the current scene.

OnShaded

method
OnShaded(self)
Switch the display mode to shaded rendering.

OnShadedEdges

method
OnShadedEdges(self)
Switch the display mode to shaded with edges rendering.

OnWireFrame

method
OnWireFrame(self)
Switch the display mode to wireframe rendering.

SelectBody

method
SelectBody(self)
Set the selection filter to body-level selection.

SelectFace

method
SelectFace(self)
Set the selection filter to face-level selection.

SelectEdge

method
SelectEdge(self)
Set the selection filter to edge-level selection.

ZoomWindow

method
ZoomWindow(self)
Zoom the camera to the current rubber-band selection region.

ShowOrigin

method
ShowOrigin(self)
Toggle rendering of the origin axis triad.

ShowContextMenu

method
ShowContextMenu(self)

OnHideBody

method
OnHideBody(self)
Hide the currently selected objects in the display context. OnViewerMsg is emitted with the message 'STATECHANGED' to indicate that the display state has been modified. self.OnViewerMsg.emit(0, 'STATECHANGED')

OnShowAllBodies

method
OnShowAllBodies(self)
Show all objects in the display context. OnViewerMsg is emitted with the message 'STATECHANGED' to indicate that the display state has been modified. self.OnViewerMsg.emit(0, 'STATECHANGED')

IsClipping

method
IsClipping(self)

SetClipping

method
SetClipping(self, bOn: bool)

SetClipPlane

method
SetClipPlane(self, origin: list, normal: list)

_uploadClipUniforms

method
_uploadClipUniforms(self)

renderClipPlane

method
renderClipPlane(self)