SoExtSelection Class Reference
[Groups]

VSG extension Selection node that supports lasso selection. More...

#include <Inventor/nodes/SoExtSelection.h>

Inheritance diagram for SoExtSelection:
SoSelection SoSeparator SoGroup SoNode SoFieldContainer SoBase SoRefCounter SoTypedObject

List of all members.

Classes

struct  PreFilterEventArg
 Structure given to callback when an event is raised. More...

Public Types

enum  LassoType {
  NOLASSO,
  LASSO,
  RECTANGLE,
  ELLIPSE
}
enum  LassoPolicy {
  FULL_BBOX,
  PART_BBOX,
  FULL,
  PART
}
enum  LassoMode {
  VISIBLE_SHAPES,
  ALL_SHAPES
}
enum  ReturnType {
  NOSELECT_CONTINUE,
  SELECT_RETURN,
  SELECT_CONTINUE,
  NOSELECT_RETURN
}
typedef SbBool SoExtSelectionTriangleCB (void *userData, SoCallbackAction *action, const SoPrimitiveVertex *v1, const SoPrimitiveVertex *v2, const SoPrimitiveVertex *v3)
typedef SbBool SoExtSelectionLineSegmentCB (void *userData, SoCallbackAction *action, const SoPrimitiveVertex *v1, const SoPrimitiveVertex *v2)
typedef SbBool SoExtSelectionPointCB (void *userData, SoCallbackAction *action, const SoPrimitiveVertex *v1)
typedef SbBool SelectionEventCallback (const SbVec2s &position, const SbVec3f &scenePosition, SoExtSelection *selection, void *userData)

Public Member Functions

virtual SoType getTypeId () const
 SoExtSelection ()
void useFastEditing (SbBool flg=TRUE)
SbBool isUsingFastEditing ()
SoSeparatorgetOverlaySceneGraph ()
void select (SoNode *root, int numCoord, SbVec2f *lassoCoord, const SbViewportRegion &viewport, SbBool shiftPressed)
virtual void addChild (SoNode *child)
virtual void setSelectionSceneGraph (SoNode *sceneGraph)
virtual SoNodegetSelectionSceneGraph () const
virtual void setStartSelectionCallback (SelectionEventCallback *callback, void *userData=NULL)
virtual void setEndSelectionCallback (SelectionEventCallback *callback, void *userData=NULL)
virtual void setMovingSelectionCallback (SelectionEventCallback *callback, void *userData=NULL)
void setTriangleFilterCallback (SoExtSelectionTriangleCB *cb, void *userData=NULL)
void setLineSegmentFilterCallback (SoExtSelectionLineSegmentCB *cb, void *userData=NULL)
void setPointFilterCallback (SoExtSelectionPointCB *cb, void *userData=NULL)
const SbVec2sgetLassoCoordsDC (int &numCoords)
const SbVec3fgetLassoCoordsWC (int &numCoords)
const SoPathListgetSelectionPathList () const

Static Public Member Functions

static SoType getClassTypeId ()

Public Attributes

SoSFEnum lassoType
SoSFEnum lassoPolicy
SoSFEnum lassoMode
SoSFBool animateLasso
SoSFColor lassoColor
SoSFFloat lassoWidth
SoSFUShort lassoPattern
SoSFInt32 lassoPatternScaleFactor
SbEventHandler
< PreFilterEventArg & > 
onPreFilter

Deprecated



SoDEPRECATED void setOverlayLassoColorIndex (int index)
SoDEPRECATED int getOverlayLassoColorIndex ()
SoDEPRECATED void setLassoColor (SbColor c)
SoDEPRECATED SbColor getLassoColor ()
SoDEPRECATED void setLassoWidth (float width)
SoDEPRECATED float getLassoWidth ()
SoDEPRECATED void setOverlayLassoPattern (unsigned short pattern)
SoDEPRECATED unsigned short getOverlayLassoPattern ()
SoDEPRECATED void animateOverlayLasso (SbBool flg=TRUE)
SoDEPRECATED SbBool isOverlayLassoAnimated ()

Detailed Description

VSG extension 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 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

SEE ALSO

SoRayPickAction, SoSelection, SoWinRenderArea, SoBoxHighlightRenderAction, SoHaloHighlightRenderAction, SoLineHighlightRenderAction

See related examples:

DetailSelection, ExtSelection, FastSelection


Member Typedef Documentation

typedef SbBool SoExtSelection::SelectionEventCallback(const SbVec2s &position, const SbVec3f &scenePosition, SoExtSelection *selection, void *userData)

This is the declaration to use for selection event callback functions.


See setStartSelectionCallback(), setEndSelectionCallback(), and setMovingSelectionCallback(). These callbacks are useful to modify the selection scene graph (see setSelectionSceneGraph) to implement dynamically changing selection feedback.

Note: These callbacks can only be used in FastEdit mode.

Parameters:
position The position of the event in pixel coordinates (0,0 is lower left corner).
scenePosition The position of the event in normalized -1..1 3D coordinates.
selection The selection node that called the function.
userData Optional pointer specified when the callback was set.
Returns:
If the callback handles the event it must return TRUE, else return FALSE.

Member Enumeration Documentation

Lasso mode.

Enumerator:
VISIBLE_SHAPES 

Only visible shapes can be selected.

NOTE: Transparency is not considered. If a semi-transparent shape is in front of another shape, only the front shape will be selected. Even if the shape in back is "visually" visible, it is considered to be hidden by the front shape.

ALL_SHAPES 

All shapes can be selected.

Even if outside of view volume. (default)

Lasso policy.

Enumerator:
FULL_BBOX 

Full bounding box (default).

PART_BBOX 

Partial bounding box.

FULL 

Full.

PART 

Partial.

Lasso type.

Enumerator:
NOLASSO 

No lasso (default).

LASSO 

Lasso.

RECTANGLE 

Rectangle.

ELLIPSE 

Ellipse.

Return type.

Enumerator:
NOSELECT_CONTINUE 

same as FALSE - Do not select the node, but continue with node's next triangle/line/point

SELECT_RETURN 

same as TRUE - Select the node and stop traversing node's triangle/line/point

SELECT_CONTINUE 

Select the node but continue for the remaining triangle/line/point.

NOSELECT_RETURN 

Do not select the node and stop traversing node's triangle/line/point.


Constructor & Destructor Documentation

SoExtSelection::SoExtSelection (  ) 

Constructor.


Member Function Documentation

virtual void SoExtSelection::addChild ( SoNode child  )  [virtual]

Adds a child at the end of the list of children.

It redefines the SoSeparator::addChild function just to ensure that the selection scenegraph is always the last child in the list.

Reimplemented from SoGroup.

SoDEPRECATED void SoExtSelection::animateOverlayLasso ( SbBool  flg = TRUE  ) 

Sets the the lasso animation flag.

This controls whether the lasso is animated (its line pattern changes) or not. Default is FALSE.

Deprecated:

Deprecated since Open Inventor 10000
Use animateLasso field instead.
static SoType SoExtSelection::getClassTypeId (  )  [static]

Returns the type identifier for this class.

Reimplemented from SoSelection.

SoDEPRECATED SbColor SoExtSelection::getLassoColor (  ) 

Gets the lasso color.

Applies only if the lasso is not drawn in the overlay plane.

Deprecated:

Deprecated since Open Inventor 10000
Use lassoColor field instead.
const SbVec2s* SoExtSelection::getLassoCoordsDC ( int &  numCoords  ) 

Returns the lasso coordinates in device coordinates.

const SbVec3f* SoExtSelection::getLassoCoordsWC ( int &  numCoords  ) 

Returns the lasso coordinates in world coordinates.

SoDEPRECATED float SoExtSelection::getLassoWidth (  ) 

Gets the lasso line width.

Deprecated:

Deprecated since Open Inventor 10000
Use lassoWidth field instead.
SoDEPRECATED int SoExtSelection::getOverlayLassoColorIndex (  ) 

Gets the lasso color index.

Applies only if the lasso is drawn in the overlay plane.

Deprecated:

Deprecated since Open Inventor 10000
No longer supported. Always returns 0.
SoDEPRECATED unsigned short SoExtSelection::getOverlayLassoPattern (  ) 

Gets the lasso stipple pattern.

Values can range from 0 (invisible) to 0xffff (solid).

Deprecated:

Deprecated since Open Inventor 10000
Use lassoPattern field instead.
SoSeparator* SoExtSelection::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.

const SoPathList& SoExtSelection::getSelectionPathList (  )  const

Returns paths list of selected objects.

virtual SoNode* SoExtSelection::getSelectionSceneGraph (  )  const [virtual]

Returns the scenegraph displayed as "lasso" in fast edit mode.

Note: This function is available only in FastEdit mode, returns NULL otherwise.

virtual SoType SoExtSelection::getTypeId (  )  const [virtual]

Returns the type identifier for this specific instance.

Reimplemented from SoSelection.

SoDEPRECATED SbBool SoExtSelection::isOverlayLassoAnimated (  ) 

Gets the the lasso animation flag.

Deprecated:

Deprecated since Open Inventor 10000
Use animateLasso field instead.
SbBool SoExtSelection::isUsingFastEditing (  ) 

Gets whether the lasso is drawn using fast editing.

void SoExtSelection::select ( SoNode root,
int  numCoord,
SbVec2f lassoCoord,
const SbViewportRegion viewport,
SbBool  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!.

virtual void SoExtSelection::setEndSelectionCallback ( SelectionEventCallback callback,
void *  userData = NULL 
) [virtual]

Sets the callback called when the mouse button is released in selection mode.

Note: This function is available only in FastEdit mode.

SoDEPRECATED void SoExtSelection::setLassoColor ( SbColor  c  ) 

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).

Deprecated:

Deprecated since Open Inventor 10000
Use lassoColor field instead.
SoDEPRECATED void SoExtSelection::setLassoWidth ( float  width  ) 

Sets the lasso line width.

This function sets the width in FastEdit mode also. Default is 1.

Deprecated:

Deprecated since Open Inventor 10000
Use lassoWidth field instead.
void SoExtSelection::setLineSegmentFilterCallback ( SoExtSelectionLineSegmentCB cb,
void *  userData = NULL 
)

Sets the line segment filter callback.

See setTriangleFilterCallback() for details.

virtual void SoExtSelection::setMovingSelectionCallback ( SelectionEventCallback callback,
void *  userData = NULL 
) [virtual]

Sets the callback called when the mouse is moved in selection mode.

The callback is only called while the mouse button is down.

Note: This function is available only in FastEdit mode.

SoDEPRECATED void SoExtSelection::setOverlayLassoColorIndex ( int  index  ) 

Sets the lasso color index.

Applies only if the lasso is drawn in the overlay plane.

Deprecated:

Deprecated since Open Inventor 10000
No longer supported. Calling this method does nothing.
SoDEPRECATED void SoExtSelection::setOverlayLassoPattern ( unsigned short  pattern  ) 

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).

Deprecated:

Deprecated since Open Inventor 10000
Use lassoPattern field instead.
void SoExtSelection::setPointFilterCallback ( SoExtSelectionPointCB cb,
void *  userData = NULL 
)

Sets the point filter callback.

See setTriangleFilterCallback() for details.

virtual void SoExtSelection::setSelectionSceneGraph ( SoNode sceneGraph  )  [virtual]

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".

virtual void SoExtSelection::setStartSelectionCallback ( SelectionEventCallback callback,
void *  userData = NULL 
) [virtual]

Sets the callback called when the mouse button is clicked in selection mode.

Note: This function is available only in FastEdit mode.

void SoExtSelection::setTriangleFilterCallback ( SoExtSelectionTriangleCB cb,
void *  userData = NULL 
)

Sets the triangle filter callback .

The primitive filter callbacks can be used to retrieve information about the selected primitives of traversed shape nodes - points, line segments, or triangles - and to filter the shape selection based on the selected primitives. These callbacks are called while traversing the scene graph shapes with an SoCallbackAction started by the SoExtSelection node. Whenever a shape primitive is surrounded by the lasso, the callback is called and receives as argument the action and the primitive. Depending on the shape type, the point, line or triangle callback will be called. See SoCallbackAction.

When a callback returns TRUE, the corresponding shape is selected according to the selection policy. Then the selection stops processing the current shape's primitives and continues with the next shape in the scene graph. When a callback returns FALSE, the action continues normally to process the remaining shape's primitives, allowing you to filter or collect additional primitives.

The primitive filter callbacks are called only when the lassoPolicy is set to SoExtSelection::PART and the lassoMode is set to SoExtSelection::ALL_SHAPES.

It is the responsibility of the application to manage the primitive selection policy. Exactly like SoSelection, the node selection list can only handle paths to nodes and cannot store primitive detail information.

void SoExtSelection::useFastEditing ( SbBool  flg = TRUE  ) 

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.


Member Data Documentation

Controls lasso animation.

Default is FALSE. NOTE: field available since Open Inventor 10.0

Color of lasso.

Default value is red (1,0,0). NOTE: field available since Open Inventor 10.0

Specifies the lasso mode (whether ALL_SHAPES or only VISIBLE_SHAPES can be selected).

Use enum LassoMode. 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.

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. NOTE: field available since Open Inventor 10.0

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. NOTE: field available since Open Inventor 10.0

Specifies the lasso policy.

See description above. Use enum LassoPolicy. Default is FULL_BBOX.

Specifies lasso type (none, lasso, or rectangle).

Use enum LassoType. Default is NOLASSO.

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. NOTE: field available since Open Inventor 10.0

The ExtSelection will traverse each node of scene graph and test intersection against each nodes.

The event is called before doing intersection test and can be used to skip a particular node to avoid doing costly computation. To skip a node, call the method SoExtSelection::PreFilterEventArg::skipNode() inside your callback.


The documentation for this class was generated from the following file:

Open Inventor Toolkit reference manual, generated on 4 Sep 2023
Copyright © Thermo Fisher Scientific All rights reserved.
https://www.openinventor.com/