Class SoExtSelection

  • All Implemented Interfaces:
    SafeDisposable

    public class SoExtSelection
    extends SoSelection
    Selection node that supports lasso selection. This class extends the functionality of SoSelection to allow the user to select an object or multiple objects by drawing a lasso around the object(s) to be selected. The lasso can be represented as a rectangle between the mouse up and down positions or as a set of lines that the user draws around the objects, depending on the field lassoType. When lassoType is NOLASSO, or when the lasso is empty (the screen coordinates of the button down and button up event are the same), SoExtSelection behaves exactly like its parent class SoSelection.

    See SoSelection for more information about managing the selection list and automatically highlighting the selected shape(s).

    Objects are selected if they are surrounded by the lasso or if the lasso intersects them, depending on the field lassoPolicy, as follows:

    • FULL_BBOX: lasso selects objects whose bounding box is completely contained by the lasso
    • PART_BBOX: lasso selects objects whose bounding box intersects the lasso (or is contained by the lasso)
    • FULL: lasso selects objects whose geometry is completely contained by the lasso
    • PART: lasso selects objects whose geometry intersects the lasso (or is contained by the lasso)

    FULL and PART require more computation and are generally slower.

    A lasso mode controls whether only visible shapes (front shapes) are selectable, by controlling the selection algorithm used, either geometry-based or pixel-based. A specific lasso mode may also be preferred for performance reasons depending on the scene.

    Primitive details for selected parts of shapes can be obtained through dedicated callbacks that can be also used to filter the selection. These primitive filter callbacks can be called for each generated primitive.

    When using SoExtSelection node, the callback set by setPickFilterCallback will be called only once per selected shape. Only SoPickedPoint.getPath() makes sense for the picked point passed to the pick filter callback in this case. Other SoPickedPoint methods may return undefined results.

    Lasso selection can be also be controlled programmatically, without requiring user interaction.

    NOTE: Using the FastEdit mode:

    FastEdit mode provides the advantages of overlay mode without the overlay hardware support requirement. See SoSeparator for more information about the fast editing feature. FastEdit mode can allow the lasso geometry to be redrawn at interactive rates even when the underlying scene takes a long time to redraw. On Windows platforms, it also avoids using GDI to draw the lasso, which conflicts with the "Aero" user interface mode on Windows Vista.

    When the application uses fast editing it must call the function useFastEdit(true) first. If it doesn't call this function, operations which require fast edit will output a warning in debug mode.

    FastEdit mode also provides some powerful additional features including the option to provide custom (and dynamic) lasso geometry (see the setSelectionSceneGraph() method) and the option to set callbacks on mouse events during selection (see the methods setStartSelectionCallback(), setEndSelectionCallback(), and setMovingSelectionCallback()). The geometry in the selection scene graph can be dynamically updated by the application as the user moves the cursor, using these callbacks. This can useful to display dynamic feedback without actually doing selection. For example to display a "rubber band" line while positioning annotations or measurements. However note that the selection scene graph is always traversed, not just when the user is selecting. It is the application's responsibility to empty the selection scene graph (or hide its contents using an SoSwitch) when appropriate.

    Note: The geometry in the selection scene graph is not automatically used for selection. (It may not be appropriate.) However the application can use the select() method, if desired, to do a selection using any set of 2D points defining a "lasso".

    Finally note that since Open Inventor 8.6, SoScreenDrawer and its specialized sub-classes provide a more general mechanism for interactively drawing polylines, rectangles, ellipses, etc in screen space.

    Clipping:
    SoExtSelection avoids selecting shapes that are culled by active SoClipPlane(s) in both the ALL_SHAPES and VISIBLE Lasso modes. The user can disable this, and restore the legacy behavior of SoExtSelection before Open Inventor 9.4.0, by setting the environment variable OIV_SELECTION_USE_CLIPPLANES to 0 (see SoPreferences).

    Instancing:
    When instance nodes of a SoMultipleInstance or a SoMultipleCopy group are selected, the application can get the instance identifier using the SoPath method getInstanceIndex().

    See SoSelection for additional information about the selection list and code example.

    File format/default:

    ExtSelection {

      boundingBoxCaching AUTO
      renderCulling AUTO
      pickCulling AUTO
      policy SHIFT
      lassoType NOLASSO
      lassoPolicy FULL_BBOX
      lassoMode ALL_SHAPES
      fastEditing DISABLE
    }

    See Also:
    SoRayPickAction, SoSelection, SoWinRenderArea, SoBoxHighlightRenderAction, SoHaloHighlightRenderAction, SoLineHighlightRenderAction
    • Field Detail

      • lassoMode

        public final SoSFEnum<SoExtSelection.LassoModes> lassoMode
        Specifies the lasso mode (whether ALL_SHAPES or only VISIBLE_SHAPES can be selected). . Default is ALL_SHAPES. It applies only when the lasso policy is FULL or PART. When the lasso mode is VISIBLE_SHAPES, you will only select visible shapes. That is, if a shape is within (or partially within) the lasso volume, but is hidden by another shape, it will not be selected. VISIBLE_SHAPES mode provides faster performance than ALL_SHAPES (the default).

        The algorithm for the ALL_SHAPES mode is based on geometry projection while the VISIBLE_SHAPES mode uses offscreen rendering.

        When using VISIBLE_SHAPES, none of the primitive selection callback nodes can be called. This means that you cannot retrieve selection details using this mode.

        Unlike the ALL_SHAPES mode or the picking action, the VISIBLE_SHAPES mode does not allow you to select multiple overlapping shapes. You cannot select a shape obscured by another.

      • animateLasso

        public final SoSFBool animateLasso
        Controls lasso animation. Default is false.

        Since:
        Open Inventor 10.0

      • lassoColor

        public final SoSFColor lassoColor
        Color of lasso. Default value is red (1,0,0).

        Since:
        Open Inventor 10.0

      • lassoWidth

        public final SoSFFloat lassoWidth
        Width of lasso. The default line width is 0, meaning to use the default OpenGL value (1). Line widths greater than zero are considered to be specified in printer's points, where 1 inch = 72 printer's points. However the default pixels-per-inch value (managed by SbViewportRegion) is also 72. So effectively line width is specified in pixels unless the application sets a different pixels-per-inch value.

        Please see the notes in the class description for more information.

        Since:
        Open Inventor 10.0

      • lassoPattern

        public final SoSFUShort lassoPattern
        Stipple pattern. This specifies how dashed or dotted lasso will be drawn. The pattern is a 16-bit series of 0s and 1s and is repeated as necessary to stipple a given line. A 1 indicates that drawing occurs, and a 0 that it does not, on a pixel-by-pixel basis, starting with the low-order bits of the pattern. Values can range from 0 (invisible) to 0xffff (solid). Default is 0xe0e0, corresponding to small dashes.

        The line pattern can be stretched using the lassoPatternScaleFactor field.

        Since:
        Open Inventor 10.0

      • lassoPatternScaleFactor

        public final SoSFInt32 lassoPatternScaleFactor
        Stipple pattern scale factor. It stretches the lasso pattern (see lassoPattern) by multiplying each subseries of consecutive 1s and 0s. Scale factors are clamped to lie between 1 and 255. Default is 1.

        Since:
        Open Inventor 10.0

    • Constructor Detail

      • SoExtSelection

        public SoExtSelection()
        Constructor.
    • Method Detail

      • useFastEditing

        public void useFastEditing()
        Calls useFastEditing(true).
      • animateOverlayLasso

        @Deprecated(since="10.0.0.0")
        public void animateOverlayLasso()
        Deprecated.
        Calls animateOverlayLasso(true).
      • setOverlayLassoColorIndex

        @Deprecated(since="10.0.0.0")
        public void setOverlayLassoColorIndex​(int index)
        Deprecated.
        As of Open Inventor 10.0.0.0. No longer supported. Calling this method does nothing.
        Sets the lasso color index. Applies only if the lasso is drawn in the overlay plane.

        Warning Deprecated since Open Inventor 10000. No longer supported. Calling this method does nothing.

      • getOverlayLassoColorIndex

        @Deprecated(since="10.0.0.0")
        public int getOverlayLassoColorIndex()
        Deprecated.
        As of Open Inventor 10.0.0.0. No longer supported. Always returns 0.
        Gets the lasso color index. Applies only if the lasso is drawn in the overlay plane.

        Warning Deprecated since Open Inventor 10000. No longer supported. Always returns 0.

      • getLassoColor

        @Deprecated(since="10.0.0.0")
        public SbColor getLassoColor()
        Deprecated.
        As of Open Inventor 10.0.0.0. Use lassoColor field instead.
        Gets the lasso color. Applies only if the lasso is not drawn in the overlay plane.

        Warning Deprecated since Open Inventor 10000. Use lassoColor field instead.

      • setLassoColor

        @Deprecated(since="10.0.0.0")
        public void setLassoColor​(SbColor c)
        Deprecated.
        As of Open Inventor 10.0.0.0. Use lassoColor field instead.
        Sets the lasso color. Applies only if the lasso is not drawn in the overlay plane. This function sets the color in FastEdit mode also. Default is red (1,0,0).

        Warning Deprecated since Open Inventor 10000. Use lassoColor field instead.

      • getOverlaySceneGraph

        public SoSeparator getOverlaySceneGraph()
        Returns the scene graph that should be passed to the render area function setOverlaySceneGraph . Applies only if the lasso is drawn in the overlay plane.
      • select

        public void select​(SoNode root,
                           SbVec2f[] lassoCoord,
                           SbViewportRegion viewport,
                           boolean shiftPressed)
        Simulates interactive selection starting from the root node with the given lasso contour, updating the selection list and triggering any associated callback . Even though the selection operation may not involve a window per se, some nodes need the viewport information to determine their size and placement.

        NOTE: The root node must be the root of a scene graph that includes the camera node. For example, when using an Open Inventor viewer, use getSceneManager()->getSceneGraph().

        Setting shiftPressed true simulates the effect of pressing the shift key while selecting, consistent with the SoSelection.Shift policy.

        The lasso type can be set using the lassoType field, but the lasso will not be drawn when using this method. The lasso coordinates are given in normalized device coordinates ranging from -1 to +1 in the X and Y directions.

        Note: When the lassoType is set to LASSO the objects are selected according to the points defined by the lasso coordinates so the segments between those points are not part of the lasso!.

      • isUsingFastEditing

        public boolean isUsingFastEditing()
        Gets whether the lasso is drawn using fast editing.
      • useFastEditing

        public void useFastEditing​(boolean flg)
        Sets whether the lasso should be drawn using fast editing.
        When the application uses the FastEdit mode it must call this function first before calling any other function in this class. See also SoGLRenderAction.setFastEditSavePolicy for possible limitations. Default is false.
      • getDirectLassoCoordsWC

        public java.nio.FloatBuffer getDirectLassoCoordsWC()
        Returns the lasso coordinates in world coordinates.
      • setSelectionSceneGraph

        public void setSelectionSceneGraph​(SoNode sceneGraph)
        Sets the scenegraph to be displayed as "lasso" in fast edit mode. Note: This function is available only in FastEdit mode.

        The geometry in this scene graph can be dynamically updated by the application as the user moves the cursor. See the methods setStartSelectionCallback(), setMovingSelectionCallback(), etc. This can useful to display dynamic feedback without actually doing selection. For example to display a "rubber band" line while positioning annotation or measurements.

        Note: The geometry in this scene graph is not automatically used for selection! (It may not be appropriate.) The application can use the select() method, if desired, to do a selection using any set of 2D points defining a "lasso".

      • getLassoCoordsWC

        public SbVec3f[] getLassoCoordsWC()
        Returns the lasso coordinates in world coordinates.
      • getDirectLassoCoordsDC

        public java.nio.ShortBuffer getDirectLassoCoordsDC()
        Returns the lasso coordinates in device coordinates.
      • getLassoCoordsDC

        public SbVec2s[] getLassoCoordsDC()
        Returns the lasso coordinates in device coordinates.
      • getSelectionSceneGraph

        public SoNode getSelectionSceneGraph()
        Returns the scenegraph displayed as "lasso" in fast edit mode. Note: This function is available only in FastEdit mode, returns NULL otherwise.
      • getSelectionPathList

        public java.util.Vector<SoPath> getSelectionPathList()
        Returns paths list of selected objects.
      • setOverlayLassoPattern

        @Deprecated(since="10.0.0.0")
        public void setOverlayLassoPattern​(short pattern)
        Deprecated.
        As of Open Inventor 10.0.0.0. Use lassoPattern field instead.
        Sets the lasso stipple pattern. Values can range from 0 (invisible) to 0xffff (solid). This specifies how dashed or dotted lasso lines will be drawn. This function actually sets the line pattern in all cases, not just overlay. Default is 0xffff (solid).

        Warning Deprecated since Open Inventor 10000. Use lassoPattern field instead.

      • getLassoWidth

        @Deprecated(since="10.0.0.0")
        public float getLassoWidth()
        Deprecated.
        As of Open Inventor 10.0.0.0. Use lassoWidth field instead.
        Gets the lasso line width.

        Warning Deprecated since Open Inventor 10000. Use lassoWidth field instead.

      • setLassoWidth

        @Deprecated(since="10.0.0.0")
        public void setLassoWidth​(float width)
        Deprecated.
        As of Open Inventor 10.0.0.0. Use lassoWidth field instead.
        Sets the lasso line width. This function sets the width in FastEdit mode also. Default is 1.

        Warning Deprecated since Open Inventor 10000. Use lassoWidth field instead.

      • isOverlayLassoAnimated

        @Deprecated(since="10.0.0.0")
        public boolean isOverlayLassoAnimated()
        Deprecated.
        As of Open Inventor 10.0.0.0. Use animateLasso field instead.
        Gets the the lasso animation flag.

        Warning Deprecated since Open Inventor 10000. Use animateLasso field instead.

      • animateOverlayLasso

        @Deprecated(since="10.0.0.0")
        public void animateOverlayLasso​(boolean flg)
        Deprecated.
        As of Open Inventor 10.0.0.0. Use animateLasso field instead.
        Sets the the lasso animation flag. This controls whether the lasso is animated (its line pattern changes) or not. Default is false.

        Warning Deprecated since Open Inventor 10000. Use animateLasso field instead.

      • getOverlayLassoPattern

        @Deprecated(since="10.0.0.0")
        public short getOverlayLassoPattern()
        Deprecated.
        As of Open Inventor 10.0.0.0. Use lassoPattern field instead.
        Gets the lasso stipple pattern. Values can range from 0 (invisible) to 0xffff (solid).

        Warning Deprecated since Open Inventor 10000. Use lassoPattern field instead.