Open Inventor Release 2024.1.0
 
Loading...
Searching...
No Matches
SoViewingCube Class Reference

Interactive cubic shape to control the orientation of a camera. More...

#include <Inventor/ViewerComponents/nodes/SoViewingCube.h>

+ Inheritance diagram for SoViewingCube:

Public Types

enum  PositionInViewport {
  TOP_RIGHT ,
  TOP_LEFT ,
  BOTTOM_RIGHT ,
  BOTTOM_LEFT
}
 Possible positions of the viewing cube in the scene camera viewport. More...
 
enum  EdgeStyle {
  FLAT ,
  ROUND ,
  CORNER
}
 Different types of edges. More...
 

Public Member Functions

virtual SoType getTypeId () const
 Returns the type identifier for this specific instance.
 
 SoViewingCube ()
 
virtual SbBool affectsState () const
 This node does not affect the state.
 
- Public Member Functions inherited from SoNode
virtual void setOverride (const SbBool state)
 Turns the override flag on or off.
 
virtual SbBool isOverride () const
 Returns the state of the override flag.
 
virtual SoNodecopy (SbBool copyConnections=FALSE) const
 Creates and returns an exact copy of the node.
 
virtual void touch ()
 Marks an instance as modified, simulating a change to it.
 
- Public Member Functions inherited from SoFieldContainer
void setToDefaults ()
 Sets all fields in this object to their default values.
 
SbBool hasDefaultValues () const
 Returns TRUE if all of the object's fields have their default values.
 
SbBool fieldsAreEqual (const SoFieldContainer *fc) const
 Returns TRUE if this object's fields are exactly equal to fc's fields.
 
void copyFieldValues (const SoFieldContainer *fc, SbBool copyConnections=FALSE)
 Copies the contents of fc's fields into this object's fields.
 
SoNONUNICODE SbBool set (const char *fieldDataString)
 Sets one or more fields in this object to the values specified in the given string, which should be a string in the Open Inventor file format.
 
SbBool set (const SbString &fieldDataString)
 Sets one or more fields in this object to the values specified in the given string, which should be a string in the Open Inventor file format.
 
void get (SbString &fieldDataString)
 Returns the values of the fields of this object in the Open Inventor ASCII file format in the given string.
 
virtual int getFields (SoFieldList &list) const
 Appends references to all of this object's fields to resultList, and returns the number of fields appended.
 
virtual int getAllFields (SoFieldList &list) const
 Returns a list of fields, including the eventIn's and eventOut's.
 
virtual SoFieldgetField (const SbName &fieldName) const
 Returns a the field of this object whose name is fieldName.
 
virtual SoFieldgetEventIn (const SbName &fieldName) const
 Returns a the eventIn with the given name.
 
virtual SoFieldgetEventOut (const SbName &fieldName) const
 Returns the eventOut with the given name.
 
SbBool getFieldName (const SoField *field, SbName &fieldName) const
 Returns the name of the given field in the fieldName argument.
 
SbBool enableNotify (SbBool flag)
 Notification at this Field Container is enabled (if flag == TRUE) or disabled (if flag == FALSE).
 
SbBool isNotifyEnabled () const
 Notification is the process of telling interested objects that this object has changed.
 
virtual void setUserData (void *data)
 Sets application data.
 
void * getUserData (void) const
 Gets user application data.
 
- Public Member Functions inherited from SoBase
virtual SbName getName () const
 Returns the name of an instance.
 
virtual void setName (const SbName &name)
 Sets the name of an instance.
 
void setSynchronizable (const bool b)
 Sets this to be a ScaleViz synchronizable object.
 
bool isSynchronizable () const
 Gets the ScaleViz synchronizable state of this object.
 
- Public Member Functions inherited from SoRefCounter
void ref () const
 Adds a reference to an instance.
 
void unref () const
 Removes a reference from an instance.
 
void unrefNoDelete () const
 unrefNoDelete() should be called when it is desired to decrement the reference count, but not delete the instance if this brings the reference count to zero.
 
int getRefCount () const
 Returns current reference count.
 
void lock () const
 lock this instance.
 
void unlock () const
 unlock this instance.
 
- Public Member Functions inherited from SoTypedObject
SbBool isOfType (const SoType &type) const
 Returns TRUE if this object is of the type specified in type or is derived from that type.
 
template<typename TypedObjectClass >
SbBool isOfType () const
 Returns TRUE if this object is of the type of class TypedObjectClass or is derived from that class.
 

Static Public Member Functions

static SoType getClassTypeId ()
 Returns the type identifier for this class.
 
- Static Public Member Functions inherited from SoNode
static SoType getClassTypeId ()
 Returns the type identifier for this class.
 
static SoNodegetByName (const SbName &name)
 A node's name can be set using SoBase::setName().
 
static int getByName (const SbName &name, SoNodeList &list)
 A node's name can be set using SoBase::setName().
 
- Static Public Member Functions inherited from SoFieldContainer
static SoType getClassTypeId ()
 Returns the type of this class.
 
- Static Public Member Functions inherited from SoBase
static SoType getClassTypeId ()
 Returns type identifier for this class.
 
- Static Public Member Functions inherited from SoTypedObject
static SoType getClassTypeId ()
 Returns the type identifier for this class.
 

Public Attributes

SoSFNode sceneCamera
 Camera which is synchronized with this viewing cube.
 
SoSFVec2f size
 Size of the viewport, in pixels, in which the viewing cube is drawn.
 
SoSFEnum position
 Position of the viewing cube in the scene camera viewport.
 
SoSFEnum edgeStyle
 Style of edges and corners.
 
SoSFColor selectionColor
 Color used to highlight the part of the viewing cube that is under the cursor.
 
SoSFColor faceColor
 Color used to render the faces of the cube.
 
SoSFColor edgeColor
 Color used to render the edges of the cube.
 
SoSFColor cornerColor
 Color used to render the corners of the cube.
 
SoSFFilePathString facePosX
 Texture to customize the face's appearance which has a "Right" label by default.
 
SoSFFilePathString faceNegX
 Texture to customize the face's appearance which has a "Left" label by default.
 
SoSFFilePathString facePosY
 Texture to customize the face's appearance which has a "Top" label by default.
 
SoSFFilePathString faceNegY
 Texture to customize the face's appearance which has a "Bottom" label by default.
 
SoSFFilePathString facePosZ
 Texture to customize the face's appearance which has a "Front" label by default.
 
SoSFFilePathString faceNegZ
 Texture to customize the face's appearance which has a "Back" label by default.
 
SoSFFloat edgeSize
 Size of the edges, relative to the size of the faces.
 
SoSFFloat animationDuration
 Duration of camera movement to reach the desired position.
 
SoSFEnum upAxis
 Up axis of the scene.
 
SoSFFloat opacityMin
 Defines the viewing cube opacity when the cursor is far from it.
 
SoSFFloat opacityMax
 Defines the viewing cube opacity when the cursor is close to it or over it.
 
SoSFNode compass
 Defines an additional and optional scene graph to visualize a compass encapsulated in the viewing cube.
 

Detailed Description

Interactive cubic shape to control the orientation of a camera.

VSG extension (Preview feature)

The viewing cube is an interactive shape that indicates the current orientation of a camera (like a "compass" or "gnomon") and also responds to user actions by re-orienting the associated camera to one of the predefined orientations. These orientations are defined so that the camera will be in front of a selected part of the bounding cube of the scene.

Interactions

When the mouse cursor is over the viewing cube, the part (face, edge, or corner) that is under the cursor is highlighted with the selectionColor. Then if the left mouse button (button 1) is clicked (pressed and released), the selected part of the viewing cube is used to define the new orientation.

The viewing cube can be used as a replacement for the X/Y/Z camera orientation buttons implemented in many graphical user interfaces. It provides even more possibilities thanks to the pickable edges and corners of the viewing cube which offer 26 different viewing positions. However, if the edgeSize is set to 0, the edges and corners are not pickable. In this case the user can only select six different positions.

The camera controlled by the viewing cube is defined by the field sceneCamera. This is normally the same camera that the 3D viewer is controlling. In this case both the viewer and the viewing cube control the camera and the viewing cube orientation is synchronized with the sceneCamera.

In principle, as SoViewingCube is a standard class derived from SoNode, it can be inserted in any scene graph and used with a classical viewer or SceneExaminer class. In that case the viewing cube will correctly indicate the camera orientation, but it will not be convenient for the user to use the viewing cube's interaction features. These viewers are always in either viewing mode (mouse events control the camera) or in selection mode (mouse events are sent to the scene graph). In viewing mode, the viewing cube will not respond to mouse clicks, but in selection mode the viewer will not respond to mouse clicks.

Therefore we recommend to use the SceneOrbiter class as the viewer when using a viewing cube. SceneOrbiter is a "mode less" viewer. A mouse click without moving the mouse is interpreted as a selection (for example triggering the viewing cube behavior), but a mouse click and "drag" is interpreted as controlling the camera. For convenience, the SceneOrbiter automatically adds a viewing cube to the scene graph.

The viewing cube is rendered in a corner of the render area. Its size and position in the render area are defined by the size and position fields.

viewing cube at the top right corner of a render area

Rendering customization

When the mouse cursor is moved on top of the viewing cube, the part that is under the cursor is highlighted using the color defined by the field selectionColor. The colors of the cube can also be personalized with 3 fields: faceColor, edgeColor and cornerColor.

Cubic shape customization

The shape of the viewing cube can be customized by several fields. The shape of the edges and corners is defined by the field edgeStyle. The edges can form a sharp corner, be rounded or be flat (beveled). The size of the edges and corners relative to the cube face is defined by the field edgeSize.

edgeStyle=ROUND and edgeSize=0.1

Each flat face of the viewing cube can also be customized. By default the text Top/Bottom/Front/Back/Left/Right appears on the center of each face according to its orientation. The six fields facePosX ... faceNegZ allow the application to replace the default appearance of each face with an image. Note that these images should have a transparent background so the highlight color is visible when the cursor is over the face.

viewing cube custom faces with F/R/B textures

Opacity

The viewing cube's opacity may vary depending on the distance between it and the cursor.

  • if the cursor is far from the center of the cube, the opacityMin is applied.
  • if the cursor is very close or over the cube, the opacityMax is applied.
  • otherwise the opacity varies in the range [opacityMin, opacityMax]

When the cursor moves in an area close to the cube but not over the cube and if the opacityMin and opacityMax differ, a rendering of the scene occurs each time the mouse is moved in this area, which can lead to slowing down of the application.

By default, opacityMin and opacityMax are set to 1, which means the cube is always opaque.

Limitations:

  • Some visual artifact on semi transparent ViewingCube when you use NO_SORT transparency type.
  • The opacity of the ViewingCube is only updated on a mouse move event without button pressed. Therefore the opacity won't change if you move the mouse without pressing a button.

Compass The compass is not impacted by the varying opacity, thus independently from the fields opacityMin and opacityMax

Animation

To provide a better user experience, picking a part of the viewing cube does not immediately change the camera orientation. A smooth animation is done between the current camera orientation and the new orientation. The duration of the animation is defined by the animationDuration field.

Note that the animation of the camera is done in such a way that the default text of each face Top/Bottom/Front/Back/Left/Right are always legible.

FILE FORMAT/DEFAULT

    ViewingCube {
    sceneCamera NULL
    size (150.0, 150.0)
    position TOP_RIGHT
    edgeStyle ROUND
    edgeSize 0.4
    selectionColor cyan
    faceColor 0.8 0.8 0.8
    edgeColor 0.8 0.8 0.8
    cornerColor 0.8 0.8 0.8
    animationDuration 0.8
    upAxis "Y"
    facePosX ""
    faceNegX ""
    facePosY ""
    faceNegY ""
    facePosZ ""
    faceNegZ ""
    opacityMin 1
    opacityMax 1
    compass NULL
    }

SEE ALSO

SceneOrbiter

Definition at line 194 of file SoViewingCube.h.

Member Enumeration Documentation

◆ EdgeStyle

Different types of edges.

Enumerator
FLAT 

Edges are flat (beveled).

ROUND 

Edges have a rounded shape.

CORNER 

Edges form a sharp corner.

Definition at line 218 of file SoViewingCube.h.

◆ PositionInViewport

Possible positions of the viewing cube in the scene camera viewport.

Enumerator
TOP_RIGHT 

The viewing cube is positioned at the top right corner.

TOP_LEFT 

The viewing cube is positioned at the top left corner.

BOTTOM_RIGHT 

The viewing cube is positioned at the bottom right corner.

BOTTOM_LEFT 

The viewing cube is positioned at the bottom left corner.

Definition at line 203 of file SoViewingCube.h.

Constructor & Destructor Documentation

◆ SoViewingCube()

SoViewingCube::SoViewingCube ( )

Member Function Documentation

◆ affectsState()

virtual SbBool SoViewingCube::affectsState ( ) const
virtual

This node does not affect the state.

Returns FALSE.

Reimplemented from SoNode.

◆ getClassTypeId()

static SoType SoViewingCube::getClassTypeId ( )
static

Returns the type identifier for this class.


◆ getTypeId()

virtual SoType SoViewingCube::getTypeId ( ) const
virtual

Returns the type identifier for this specific instance.

Reimplemented from SoNode.

Member Data Documentation

◆ animationDuration

SoSFFloat SoViewingCube::animationDuration

Duration of camera movement to reach the desired position.

Any negative value of this field is equivalent to 0 (no animation). Default is 0.8 seconds.

Definition at line 414 of file SoViewingCube.h.

◆ compass

SoSFNode SoViewingCube::compass

Defines an additional and optional scene graph to visualize a compass encapsulated in the viewing cube.

This scene graph will have to be centered on (0, 0, 0) to be aligned with the center of the viewing cube. According to its size, the compass will be visible or not when the viewing cube is opaque.

By default this field is NULL, so no compass is displayed. Some examples of simple compasses are provided in the folder $OIVHOME/examples/data/Inventor/ViewingCube/Compass

Definition at line 451 of file SoViewingCube.h.

◆ cornerColor

SoSFColor SoViewingCube::cornerColor

Color used to render the corners of the cube.

Default is gray (0.8,0.8,0.8).

Definition at line 328 of file SoViewingCube.h.

◆ edgeColor

SoSFColor SoViewingCube::edgeColor

Color used to render the edges of the cube.

Default is gray (0.8,0.8,0.8).

Definition at line 321 of file SoViewingCube.h.

◆ edgeSize

SoSFFloat SoViewingCube::edgeSize

Size of the edges, relative to the size of the faces.

The size of the corners are also adjusted according to this value. When the edgeSize is 0, neither edges nor corners of the viewing cube can be highlighted or selected. Thus the viewing cube allows to select only 6 predefined positions of the camera.

This field's value is clamped in a range [0-1]. edgeSize = 1 corresponds to 25% of the face's size. Default is 0.4.

Depending on the edgeStyle value, the edgeSize defines either a radius (for ROUND style) or a width.

Above is a viewing cube with edgeSize = 0

Below are images of a viewing cube with different edgeSize=0.1 on the left column and edgeSize=0.25 on the right column.

edgeStyle = CORNER

edgeStyle = ROUND

edgeStyle = FLAT

Definition at line 407 of file SoViewingCube.h.

◆ edgeStyle

SoSFEnum SoViewingCube::edgeStyle

Style of edges and corners.

Use enum EdgeStyle.

edgeStyle = ROUND edgeStyle = CORNER edgeStyle = FLAT

Definition at line 296 of file SoViewingCube.h.

◆ faceColor

SoSFColor SoViewingCube::faceColor

Color used to render the faces of the cube.

Default is gray (0.8,0.8,0.8).

Definition at line 314 of file SoViewingCube.h.

◆ faceNegX

SoSFFilePathString SoViewingCube::faceNegX

Texture to customize the face's appearance which has a "Left" label by default.

See facePosX for detail.

Definition at line 344 of file SoViewingCube.h.

◆ faceNegY

SoSFFilePathString SoViewingCube::faceNegY

Texture to customize the face's appearance which has a "Bottom" label by default.

See facePosX for detail.

Definition at line 356 of file SoViewingCube.h.

◆ faceNegZ

SoSFFilePathString SoViewingCube::faceNegZ

Texture to customize the face's appearance which has a "Back" label by default.

See facePosX for detail.

Definition at line 368 of file SoViewingCube.h.

◆ facePosX

SoSFFilePathString SoViewingCube::facePosX

Texture to customize the face's appearance which has a "Right" label by default.

This field defines the name of the file which contains this texture.

The standard image file formats are supported. See SoRasterImageRW for the list. The image format must handle an alpha channel in order to allow the selected face to be highlighted with the selectionColor.

Definition at line 338 of file SoViewingCube.h.

◆ facePosY

SoSFFilePathString SoViewingCube::facePosY

Texture to customize the face's appearance which has a "Top" label by default.

See facePosX for detail.

Definition at line 350 of file SoViewingCube.h.

◆ facePosZ

SoSFFilePathString SoViewingCube::facePosZ

Texture to customize the face's appearance which has a "Front" label by default.

See facePosX for detail.

Definition at line 362 of file SoViewingCube.h.

◆ opacityMax

SoSFFloat SoViewingCube::opacityMax

Defines the viewing cube opacity when the cursor is close to it or over it.

The value range is [0, 1].

Default is 1.

Definition at line 439 of file SoViewingCube.h.

◆ opacityMin

SoSFFloat SoViewingCube::opacityMin

Defines the viewing cube opacity when the cursor is far from it.

The value range is [0, 1].

Default is 1.

Definition at line 431 of file SoViewingCube.h.

◆ position

SoSFEnum SoViewingCube::position

Position of the viewing cube in the scene camera viewport.

Use enum PositionInViewport.

Default is TOP_RIGHT.

Definition at line 283 of file SoViewingCube.h.

◆ sceneCamera

SoSFNode SoViewingCube::sceneCamera

Camera which is synchronized with this viewing cube.

When using a viewing cube with a SceneOrbiter, the method SceneOrbiter::enableViewingCube(true) automatically sets the field sceneCamera.

However, to use a viewing cube with a SceneExaminer, the following code sample gives an example to set the field sceneCamera.

qtViewerExaminer = new ViewerExaminer(NULL);
SceneExaminer* sceneExaminer = qtViewerExaminer->getRenderArea()->getSceneInteractor();
SoViewingCube* viewingCube = new SoViewingCube;
viewingCube->sceneCamera = sceneExaminer->getCamera();
sceneExaminer->addChild(viewingCube);
Tool class for building a basic interactive OpenInventor application with scene "examiner" viewing be...
SoCamera * getCamera() const
Returns the current camera.
virtual void addChild(SoNode *child)
Adds a child as last one in group.
Interactive cubic shape to control the orientation of a camera.
SoSFNode sceneCamera
Camera which is synchronized with this viewing cube.
Base class to have a MFC viewer with the OpenInventor OpenGL rendering.

Definition at line 269 of file SoViewingCube.h.

◆ selectionColor

SoSFColor SoViewingCube::selectionColor

Color used to highlight the part of the viewing cube that is under the cursor.

Default is cyan (0,1,1).

The following image shows the highlighted edge behind the cursor when selectionColor = (1,0,0)

Definition at line 307 of file SoViewingCube.h.

◆ size

SoSFVec2f SoViewingCube::size

Size of the viewport, in pixels, in which the viewing cube is drawn.

Default is 150 pixels width, 150 pixels height.

Definition at line 275 of file SoViewingCube.h.

◆ upAxis

SoSFEnum SoViewingCube::upAxis

Up axis of the scene.

Setting the up axis allows the adjustment of the viewing cube rotations. Thus, this axis remains vertical at all times relative to the viewport, it is always parallel to the vertical border of the viewport. The chosen axis defines the initial position and orientation of the camera (front-top-right corner). Use enum openinventor::inventor::Axis::Type. Default is Y.

Definition at line 423 of file SoViewingCube.h.


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