Interactive context is a global object accessible via OccViewer.interactiveContext, responsible for managing the list of displayed/hidden objects.

Interactive objects are identified by string identifiers, with assembly items prefixed by their parents' ids. Passing id of a parent node will affect all it's children.

This class has functionality close to C++ class AIS_InteractiveContext defined by OCCT.

See also subclasses of OccViewer.InteractiveObject for object-oriented interface to this functionality. See also OccViewer.UserEvents.onDisplayedObjectsChanged callback for tracking displayed objects changes.

interface InteractiveContext {
    displayedObjectList: string[];
    displayedObjects: string;
    displayMode: DisplayMode;
    erasedObjectList: string[];
    erasedObjects: string;
    insideObjectList: string[];
    insideObjects: string;
    isTransparentMode: boolean;
    transparentModeColor: string;
    areObjectsInside(theNames: string): boolean;
    areObjectsLoaded(theNames: string): boolean;
    cloneObjectList(theNames: string, theToUpdate: boolean): string;
    displayObjectList(theNames: string, theToUpdate: boolean): boolean;
    displayObjectListAsync(
        theNames: string,
        theToUpdate: boolean,
    ): Promise<boolean>;
    eraseAll(theToUpdate: boolean): boolean;
    eraseObjectList(theNames: string, theToUpdate: boolean): boolean;
    genObjectId(thePrefix: string): string;
    joinObjectIdList(theIdList: string[]): string;
    loadObjectListAsync(theNames: string): Promise<boolean>;
    removeAllObjects(theToUpdate: boolean): boolean;
    removeObjectList(theNames: string, theToUpdate: boolean): boolean;
    setTransparentMode(
        theIsTranspModeOn: boolean,
        theOpaqueIds: string,
        theToUpdate: boolean,
    ): void;
    splitObjectId(theNames: string): string[];
}

Properties

displayedObjectList: string[]

Get list of displayed objects. Wrapper around InteractiveContext.displayedObjects See also OccViewer.UserEvents.onDisplayedObjectsChanged callback for tracking displayed objects changes.

displayedObjects: string

Get list of displayed objects as single string with '\n' separator. See also OccViewer.UserEvents.onDisplayedObjectsChanged callback for tracking displayed objects changes.

displayMode: DisplayMode

Get/set current display mode

Current display mode

erasedObjectList: string[]

Get list of hidden objects. Wrapper around InteractiveContext.erasedObjects See also OccViewer.UserEvents.onDisplayedObjectsChanged callback for tracking displayed objects changes.

erasedObjects: string

Get list of hidden objects as single string with '\n' separator. See also OccViewer.UserEvents.onDisplayedObjectsChanged callback for tracking displayed objects changes.

insideObjectList: string[]

Get list of all objects in displayed and erased state. Wrapper around InteractiveContext.insideObjects

insideObjects: string

Get list of all objects in displayed and erased state as single string with '\n' separator.

isTransparentMode: boolean

Gets transparent mode status

transparentModeColor: string

Get/set semitransparent hex color string in format #rrggbbaa.

hex color string in format #rrggbbaa

viewer update flag

Methods

  • Check if object(s) with specified id(s) have been registered (opened) in the viewer.

    Parameters

    • theNames: string

      object name list

    Returns boolean

    return TRUE if object(s) with specified id(s) have been registered (opened) in the viewer. Objects might be in both erased or in displayed states. When list is specified, returns FALSE if at least one of the objects in the list couldn't be found (e.g. all objects should be registered).

  • Check if geometry of given objects already loaded.

    Parameters

    • theNames: string

      object name list

    Returns boolean

    return true if geometry of object(s) with specified id(s) have been loaded in the viewer. When list is specified, returns FALSE if at least one of the objects in the list don't have loaded geometry (e.g. geometry of all objects should be loaded).

  • Clone object(s) with specified id(s).

    Parameters

    • theNames: string

      object name list (pass '*' for any object)

    • theToUpdate: boolean

    Returns string

    the list of cloned objects

  • Display temporarily hidden objects sync.

    Parameters

    • theNames: string

      object name list

    • theToUpdate: boolean

      viewer update flag

    Returns boolean

    FALSE if object was not found

  • Display temporarily hidden objects async.

    Parameters

    • theNames: string

      object name list (pass * for any object)

    • theToUpdate: boolean

      viewer update flag

    Returns Promise<boolean>

    FALSE if object was not found

  • Temporarily hide all objects.

    Parameters

    • theToUpdate: boolean

      viewer update flag

    Returns boolean

    FALSE if object was not found

  • Temporarily hide named objects.

    Parameters

    • theNames: string

      object name list (pass "*" for any object)

    • theToUpdate: boolean

      viewer update flag

    Returns boolean

    FALSE if object was not found

  • Gen unique id.

    Parameters

    • thePrefix: string

      prefix of unique id.

    Returns string

    the unique id

  • Join string list with ids to single string. The single string of ids are using as input in several methods such as InteractiveContext.areObjectsInside

    Parameters

    • theIdList: string[]

    Returns string

    joined ids string.

  • Load object list geometry async.

    Parameters

    • theNames: string

      object name list (pass * for any object)

    Returns Promise<boolean>

    FALSE if object was not found

  • Clear all named objects from viewer.

    Parameters

    • theToUpdate: boolean

      viewer update flag

    Returns boolean

  • Remove named objects from viewer.

    Parameters

    • theNames: string

      object name list (pass '*' for any object)

    • theToUpdate: boolean

      viewer update flag

    Returns boolean

    FALSE if object was not found

  • Enable transparent mode - display selected objects opaque and unselected semitransparent.

    Parameters

    • theIsTranspModeOn: boolean

      theIsTranspModeOn flag

    • theOpaqueIds: string

      the list of opaque objects (could be empty)

    • theToUpdate: boolean

      viewer update flag

    Returns void

  • Split string which represents the list of ids to list of string ids.

    Parameters

    • theNames: string

      object name list.

    Returns string[]

    the list of string ids.