#include <Inventor/Qt/viewers/SoQtViewer.h>
Inheritance diagram for SoQtViewer:
Public Types | |
enum | Type { BROWSER, EDITOR } |
enum | DrawStyle { VIEW_AS_IS, VIEW_HIDDEN_LINE, VIEW_NO_TEXTURE, VIEW_LOW_COMPLEXITY, VIEW_LINE, VIEW_POINT, VIEW_BBOX, VIEW_LOW_RES_LINE, VIEW_LOW_RES_POINT, VIEW_SAME_AS_STILL, VIEW_WIREFRAME_OVERLAY } |
enum | DrawType { STILL = 0, INTERACTIVE } |
enum | BufferType { BUFFER_SINGLE, BUFFER_DOUBLE, BUFFER_INTERACTIVE } |
enum | AutoClippingStrategy { VARIABLE_NEAR_PLANE, CONSTANT_NEAR_PLANE } |
Public Member Functions | |
virtual void | setCamera (SoCamera *camera) |
SoCamera * | getCamera (void) const |
virtual void | setCameraType (SoType type) |
SoType | getCameraType (void) const |
virtual void | toggleCameraType (void) |
virtual void | viewAll (void) |
virtual void | saveHomePosition (void) |
virtual void | resetToHomePosition (void) |
virtual void | setHeadlight (SbBool enable) |
SbBool | isHeadlight (void) const |
SoDirectionalLight * | getHeadlight (void) const |
virtual void | setDrawStyle (SoQtViewer::DrawType type, SoQtViewer::DrawStyle style) |
SoQtViewer::DrawStyle | getDrawStyle (const SoQtViewer::DrawType type) const |
virtual void | setBufferingType (SoQtViewer::BufferType type) |
SoQtViewer::BufferType | getBufferingType (void) const |
virtual void | setViewing (SbBool enable) |
SbBool | isViewing (void) const |
virtual void | setCursorEnabled (SbBool enable) |
SbBool | isCursorEnabled (void) const |
void | setAutoClipping (SbBool enable) |
SbBool | isAutoClipping (void) const |
void | setAutoClippingStrategy (const AutoClippingStrategy strategy, const float value=0.6f, SoQtAutoClippingCB *cb=NULL, void *cbuserdata=NULL) |
virtual void | setStereoViewing (SbBool enable) |
SbBool | isStereoViewing (void) const |
virtual void | setStereoOffset (const float dist) |
float | getStereoOffset (void) const |
void | setDetailSeek (const SbBool enable) |
SbBool | isDetailSeek (void) const |
void | setSeekTime (const float seconds) |
float | getSeekTime (void) const |
void | addStartCallback (SoQtViewerCB *func, void *data=NULL) |
void | addFinishCallback (SoQtViewerCB *func, void *data=NULL) |
void | removeStartCallback (SoQtViewerCB *func, void *data=NULL) |
void | removeFinishCallback (SoQtViewerCB *func, void *data=NULL) |
void | setWireframeOverlayColor (const SbColor &color) |
const SbColor & | getWireframeOverlayColor (void) const |
virtual void | setDoubleBuffer (const SbBool enable) |
virtual void | setSceneGraph (SoNode *root) |
virtual SoNode * | getSceneGraph (void) |
Protected Member Functions | |
SoQtViewer (QWidget *parent, const char *name, SbBool embed, Type type, SbBool build) | |
~SoQtViewer () | |
virtual void | sizeChanged (const SbVec2s &size) |
virtual void | setSeekMode (SbBool enable) |
SbBool | isSeekMode (void) const |
SbBool | seekToPoint (const SbVec2s screenpos) |
virtual void | computeSeekFinalOrientation (void) |
virtual void | actualRedraw (void) |
virtual SbBool | processSoEvent (const SoEvent *const event) |
void | interactiveCountInc (void) |
void | interactiveCountDec (void) |
int | getInteractiveCount (void) const |
void | setSeekDistance (const float distance) |
float | getSeekDistance (void) const |
void | setSeekValueAsPercentage (const SbBool on) |
SbBool | isSeekValuePercentage (void) const |
virtual void | changeCameraValues (SoCamera *camera) |
void | addSuperimposition (SoNode *scene) |
void | removeSuperimposition (SoNode *scene) |
void | setSuperimpositionEnabled (SoNode *scene, const SbBool enable) |
SbBool | getSuperimpositionEnabled (SoNode *scene) const |
This is an abstract class, which adds the following features to it's SoQtRenderArea superclass: convenient methods for camera handling, an automatic headlight configuration.
As for the camera handling: when setting a new scenegraph for the viewer, the scenegraph will automatically be scanned for a node derived from SoCamera. If not found, the viewer will itself set up a camera for the scene. The camera can then be conveniently controlled by the application programmers in many aspects:
The SoQtViewer class automatically adds a headlight to the scene, which will always point in the approximate same direction as the current viewer camera, thereby securing that the scene geometry is always lighted and visible. (If you don't want the constant headlight, but rather want to light the scene on your own, this behavior can be turned off with SoQtViewer::setHeadlight()).
SoQtViewer-derived viewers all inherit the following keyboard controls from this class (but only when the viewer is in "examine mode", ie SoQtViewer::isViewing() returns TRUE
):
|
Hints about what context the viewer will be used in. Usually not very interesting for the application programmer, it doesn't matter much which value is used for the viewer type. This "feature" of the viewer is included just to be compatible with the old SGI Inventor API.
|
|
Decides drawstyle for a scene with either a still camera or an animating camera.
|
|
Contains valid values for the first argument to the SoQtViewer::setDrawStyle() call. Decides the effect of the second argument.
|
|
Set of valid values for SoQtViewer::setBufferingType().
|
|
|
Constructor. parent, name and embed are passed on to SoQtRenderArea, so see the documentation for our parent constructor for for more information on those. The t type setting hints about what context the viewer will be used in. Usually not very interesting for the application programmer, but if you want to make sure the SoQtViewer class doesn't muck about with your supplied scenegraph, set the type-flag to SoQtViewer::BROWSER. (This "feature" of the viewer is included just to be compatible with the old SGI Inventor API.) The build flag decides whether or not to delay building the widgets / window which is going to make up the components of the viewer. |
|
Destructor. |
|
Set the camera we want to view the scene with. The camera passed in as an argument to this method must be part of the viewer's scenegraph. If the application code doesn't explicitly set up a camera through this method, the viewer will automatically scan through the scenegraph to find a camera to use. If no camera is available in the scenegraph at all, it will set up it's own camera.
Reimplemented in SoQtPlaneViewer, SoQtExaminerViewer, SoQtConstrainedViewer, and SoQtFlyViewer. |
|
Returns the camera currently used by the viewer for the user's main viewpoint.
It is possible that this function returns
|
|
When the viewer has to make its own camera as a result of the graph passed to setSceneGraph() not containing any camera nodes, this call can be made in advance to decide which type the camera will be of. Default is to use an SoPerspectiveCamera. If this method is called when there is a scene graph and a camera already set up, it will delete the old camera and set up a camera with the new type if the t type is different from that of the current camera.
Reimplemented in SoQtFlyViewer. |
|
Returns camera type which will be used when the viewer has to make its own camera. Note that this call does not return the current cameratype, as one might expect. Use getCamera() and SoType::getTypeId() for that inquiry.
|
|
If the current camera is of perspective type, switch to orthographic, and vice versa. Automatically calls SoQtViewer::setCameraType() so the change will immediately take place. |
|
Reposition the current camera so we can see the complete scene. Reimplemented in SoQtFlyViewer. |
|
Store the current camera settings for later retrieval with resetToHomePosition().
Reimplemented in SoQtConstrainedViewer. |
|
Restore the saved camera settings.
Reimplemented in SoQtConstrainedViewer, and SoQtFlyViewer. |
|
Turn the camera headlight on or off. Default is to have a headlight turned on.
|
|
Returns status of the viewer headlight, whether it is on or off.
|
|
Returns the a pointer to the directional light node which is the viewer headlight. The fields of the node is available for user editing.
|
|
Set up a drawing style. The type argument specifies if the given style should be interpreted as the drawstyle during animation or when the camera is static. Default values for the drawing style is to render the scene "as is" in both still mode and while the camera is moving. See the documentation for the DrawType and DrawStyle for more information.
|
|
Return current drawstyles for the given type (STILL or INTERACTIVE).
|
|
Set the viewer's buffer type. Available types are
(With a buffer type of
Default is
|
|
Return the viewer's buffer type.
|
|
Set view mode. If the view mode is on, user events will be caught and used to influence the camera position / orientation. If view mode is off, all events in the viewer canvas (like for instance keypresses or mouseclicks and -movements) will be passed along to the scene graph. Default is to have the view mode active.
Reimplemented in SoQtFullViewer, SoQtPlaneViewer, SoQtExaminerViewer, and SoQtFlyViewer. |
|
Return state of view mode.
|
|
Set whether or not the mouse cursor representation should be visible in the viewer canvas. Default value is on.
Reimplemented in SoQtPlaneViewer, SoQtExaminerViewer, and SoQtFlyViewer. |
|
Returns visibility status of mouse cursor.
|
|
Turn on or off continuous automatic adjustments of the near and far clipping planes. If on, the distance from the camera position to the near and far planes will be calculated to be a "best fit" around the geometry in the scene, to maximize the "stretch" of values for the visible geometry in the z-buffer. This is important, as z-buffer resolution is usually limited enough that one will quickly see flickering in the rasterization of close polygons upon lousy utilization of the z-buffer. Automatic clipping is on as default. For better control over what happens in boundary conditions (for instance when the distance between near and far planes get very far, or if geometry gets very close to the camera position), it is possible to use the SoQtViewer::setAutoClippingStrategy() method to fine-tune the near/far clipping plane settings.
|
|
Return value of the automatic near/far clipplane adjustment indicator.
|
|
Set the auto clipping strategy used for auto clipping. When auto clipping is enabled, the near plane distance is calculated so that it is just in front of the scene bounding box. If this near plane is behind or very close to the projection point, one of the following strategies will be used to calculate the new clipping plane. The VARIABLE_NEAR_PLANE strategy considers the number of z buffer bits available for the current OpenGL context, and uses value to calculate the number of bits that is lost because of the far/near ratio. value should be in the range [0.0, 1.0]. A higher value will increase the z-buffer precision, but also push the near plane further away from the projection point. The CONSTANT_NEAR_PLANE strategy simply sets the near plane to value. If value at some point approaches the far clipping plane distance, the near plane distance will be set to far plane distance divided by 5000.0. The default strategy is VARIABLE_NEAR_PLANE. It is also possible to register a callback method cb, which will then be invoked after the near and far clipping planes has been calculated by the SoQtViewer code. The callback can then adjust the values for the distance to the near and far planes to exactly match the needs of the application (for instance at specific parts in the scene), to limit the distance to either plane, or whatever else needs to be controlled. The signature of the SoQtAutoClippingCB callback must match:
The first argument is the cbuserdata passed in along with the callback function pointer itself (ie the callback function's closure). The second argument is the near and far clipping plane distances from the camera position, as calculated internally by the viewer. The function callback can then modify the near and far clipping plane distances to what will actually be used by the viewer. This is a good way of dynamically modifying the near and far distances such that they at all times exactly matches the specific layout of the application scene, for instance with regard to the trade-off between z-buffer resolution and how early geometry is clipped at the near plane (or at the far plane). Note that the internal near/far calculations should be good enough for the vast majority of scenes. Application programmers should only need to set up their own adjustments upon "unusual" scenes, like for instance scenes with a large world space, but where one would still like to be able to get up extremely close on details in some parts of the scene.
|
|
Turn stereo viewing on or off. Coin does "correct" stereo rendering, using the method known as "parallel axis asymmetric frustum perspective projection". For more information, see this link: http://astronomy.swin.edu.au/~pbourke/opengl/stereogl/
|
|
Returns a boolean indicating whether or not we're in stereo viewing mode. NOTE: in the original InventorXt API, this method was virtual. It is not virtual here.
|
|
Set the offset between the two viewpoints when in stereo mode. NOTE: In the original InventorXt API, this method was not virtual.
|
|
Return the offset distance between the two viewpoints when in stereo mode.
|
|
Toggle between seeking to a point or seeking to an object. Default is to seek to a point.
|
|
Returns a value indicating whether or not seeks will be performed to the exact point of picking or just towards the picked object.
|
|
Set the duration of animating the camera repositioning after a successful seek. Call with seconds equal to 0.0 to make the camera jump immediately to the correct spot. Default value is 2 seconds.
|
|
Returns the camera repositioning duration following a seek action.
|
|
Add a function to call when user interaction with the scene starts.
|
|
Add a function to call when user interaction with the scene ends.
|
|
Remove one of the functions which has been set up to be called when user interaction with the scene starts.
|
|
Remove one of the functions which has been set up to be called when user interaction with the scene ends.
|
|
Set the color of the overlay wireframe to color.
|
|
Returns the current color of the overlay wireframe. The default color is [1,0,0], ie pure red.
|
|
Overloaded to update the local bufferingtype variable.
Reimplemented from SoQtGLWidget. |
|
Give the viewer a scenegraph to render and interact with. Overloaded from parent class so the viewer can add it's own nodes to control rendering in different styles, rendering with a headlight, etc. The root node will be inserted under the viewer's root node, which also covers the nodes necessary to implement the different preferences drawing style settings. If no camera is part of the scene graph under root, one will be added automatically.
Reimplemented from SoQtRenderArea. |
|
This method returns a reference to the scene graph root node as set by the user.
Reimplemented from SoQtRenderArea. |
|
Called internally from within the SoQt library when the widget embedded in a component changes it size, which is usually triggered by end-user interaction. This method is then invoked to notify the component that the size has changed. It is called from the top and all the way down to the bottom, the size being adjusted to take into account extra decorations having been added at each level in the component class hierarchy. Reimplemented from SoQtRenderArea. Reimplemented in SoQtFullViewer. |
|
Put the viewer in or out of "waiting-to-seek" mode. If the user performs a mouse button click when the viewer is in "waiting-to-seek" mode, the camera will be repositioned so the camera focal point lies on the point of the geometry under the mouse cursor.
Reimplemented in SoQtPlaneViewer, SoQtExaminerViewer, and SoQtFlyViewer. |
|
Return a flag which indicates whether or not the viewer is in "waiting-to-seek" mode. (The actual animated translation will not occur until the end user really starts the seek operation, typically by clicking with the left mousebutton.)
|
|
Call this method to initiate a seek action towards the 3D intersection of the scene and the ray from the screen coordinate's point and in the same direction as the camera is pointing.
Returns |
|
This method is obsoleted in Coin SoQt. |
|
This method instantly redraws the normal (non-overlay) scenegraph by calling SoSceneManager::render(). Subclasses may override this method to add their own rendering before or after Coin renders it's scenegraph. The following is a complete example that demonstrates one way of adding both a background image and foreground (overlay) geometry to the "normal" rendering:
Reimplemented from SoQtRenderArea. Reimplemented in SoQtPlaneViewer, SoQtExaminerViewer, and SoQtFlyViewer. |
|
Toolkit-native events are attempted converted to Coin-generic events in the SoQtRenderArea::processEvent() method. If this succeeds, they are forwarded to this method. This is a virtual method, and is overridden in it's subclasses to catch events of particular interest to the viewer classes, for instance.
Return This method is not part of the original SGI InventorXt API. Note that you can still override the toolkit-native processEvent() method instead of this "generic" method. Reimplemented from SoQtRenderArea. Reimplemented in SoQtFullViewer, SoQtPlaneViewer, SoQtExaminerViewer, and SoQtFlyViewer. |
|
To be able to trigger callback functions when user interaction starts and/or stops, we need to keep track of the viewer state (i.e. are we in still mode or in animation mode?). SoQtViewer automatically adds callbacks to switch between still and moving draw style, and to switch between single/double buffer when the buffer type is INTERACTIVE.
|
|
To be able to trigger callback functions when user interaction starts and/or stops, we need to keep track of the viewer state (i.e. are we in still mode or in animation mode?). SoQtViewer automatically adds callbacks to switch between still and moving draw style, and to switch between single/double buffer when the buffer type is INTERACTIVE.
|
|
Return current interaction count nesting. If equal to zero, the viewer is in animation mode, otherwise the camera is still.
|
|
Set the value used for calculating how close the camera and intersection hit point should be made at the end of a seek operation. The value can be interpreted as an absolute value in the given world unit (which typically is meters) or as a percentage value of the distance between the camera starting position and the intersection hit point. This can be controlled through the setSeekValueAsPercentage() method. It is as default used as an absolute value. Default value is 50 (absolute distance or percent).
|
|
Returns the current seek distance. Value given as an absolute scalar length or as a percentage value of the original distance between the hitpoint and the camera starting position.
|
|
Control whether or not the seek distance value should be interpreted as a percentage value or as an absolute distance. See documentation on setSeekDistance() for more information.
|
|
Returns an boolean which indicates if the seek distance value from getSeekDistance() should be interpreted as a percentage value or as an absolute value.
|
|
Copies the settings of camera into our current camera. Cameras must be of the same class type. Reimplemented in SoQtConstrainedViewer. |
|
This method is for setting up a superimposed scene graph on top of the viewer scene graph. It will be used for adding spin-rotation coordinate systems, fly-viewer speed indicators and similar things. This method is not part of the original InventorXt API. |
|
This method is not part of the original InventorXt API. |
|
This method sets whether the superimposed scene graph should be traversed or not. This method is not part of the original InventorXt API. |
|
This method returns whether the superimposed scene is rendered or not. This method is not part of the original InventorXt API. |