MeVisLab Scripting Reference
SoView2DWrapper Class Reference

Inherits QObject.

Public Slots

QVariant mapVoxelToDevice (float x, float y, float z) const
 
QVariant mapVoxelToDevice (const SbVec3f &voxelCoord) const
 
QVariant mapWorldToDevice (float x, float y, float z) const
 
QVariant mapWorldToDevice (const SbVec3f &voxelCoord) const
 
int getSliceAtDevicePosition (int x, int y) const
 
QVariant mapDeviceToWorld (int x, int y)
 
QVariant mapDeviceToVoxel (int x, int y)
 
void updateLayout (int viewportX, int viewportY, int viewportWidth, int viewportHeight, float pixelScaleFactor=1.0f)
 

Detailed Description

A class that wraps SoView2D modules for use in Python.

Its main purpose is to get at the mapping between voxel/world and device coordinates.

Note
You get this wrapper by calling .object() on a SoView2D module:
wrapper = ctx.module("SoView2D").object()
The mapping is always for the last view the SoView2D was rendered on, so the mapping might not be the correct one if the SoView2D is used on several views simultaneous, or while the view is resized. You can use the updateLayout() method to update the mapping to the required view.
These methods are only relevant for 2D display. SoView2D also allows to display slices in 3D, but mapping coordinates can only be done during OpenInventor event processing, because the current 3D camera parameters must be known.

Member Function Documentation

◆ getSliceAtDevicePosition

int SoView2DWrapper::getSliceAtDevicePosition ( int  x,
int  y 
) const
slot

Returns z index of slice whose visible rect is hit, or -1 if no slice is hit.

◆ mapDeviceToVoxel

QVariant SoView2DWrapper::mapDeviceToVoxel ( int  x,
int  y 
)
slot

Map device coordinate to voxel coordinate, returns either a SbVec3f or None if the device coordinate doesn't map to a visible slice.

◆ mapDeviceToWorld

QVariant SoView2DWrapper::mapDeviceToWorld ( int  x,
int  y 
)
slot

Map device coordinate to world coordinate, returns either a SbVec3f or None if the device coordinate doesn't map to a visible slice.

◆ mapVoxelToDevice [1/2]

QVariant SoView2DWrapper::mapVoxelToDevice ( const SbVec3f &  voxelCoord) const
slot

Map voxel coordinate to device coordinate, returns either a SbVec2f or None if the coordinate is not visible.

◆ mapVoxelToDevice [2/2]

QVariant SoView2DWrapper::mapVoxelToDevice ( float  x,
float  y,
float  z 
) const
slot

Map voxel coordinate to device coordinate, returns either a tuple of values or None if the coordinate is not visible.

◆ mapWorldToDevice [1/2]

QVariant SoView2DWrapper::mapWorldToDevice ( const SbVec3f &  voxelCoord) const
slot

Map world coordinate to device coordinate, returns either a SbVec2f or None if the coordinate is not visible.

◆ mapWorldToDevice [2/2]

QVariant SoView2DWrapper::mapWorldToDevice ( float  x,
float  y,
float  z 
) const
slot

Map world coordinate to device coordinate, returns either a tuple of values or None if the coordinate is not visible.

◆ updateLayout

void SoView2DWrapper::updateLayout ( int  viewportX,
int  viewportY,
int  viewportWidth,
int  viewportHeight,
float  pixelScaleFactor = 1.0f 
)
slot

Immediately after the input image has changed (or before any event has been processed/before the image has been displayed) the image layout has not been updated and the mapping of coordinates will use wrong values.

This can be fixed with this call, but the user must provide the position and size of the viewport.

Parameters
pixelScaleFactorthe pixel scale factor for the view. For a scene rendered with an OffscreenRenderer, the pixelScale parameter of that module should be used. If the scene is displayed directly in MeVisLab, one should call .scaleFactor() from scripting on the window (or a control) to get the value.