Rechercher une page de manuel
SoQtViewer
Langue: en
Version: 377761 (fedora - 01/12/10)
Section: 3 (Bibliothèques de fonctions)
Sommaire
- NAME
- SYNOPSIS
- Detailed Description
- Member Enumeration Documentation
- enum SoQtViewer::TypeHints 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.
- enum SoQtViewer::DrawStyleDecides drawstyle for a scene with either a still camera or an animating camera.
- enum SoQtViewer::DrawTypeContains valid values for the first argument to the SoQtViewer::setDrawStyle() call. Decides the effect of the second argument.
- enum SoQtViewer::BufferTypeSet of valid values for SoQtViewer::setBufferingType().
- enum SoQtViewer::AutoClippingStrategyEnum for auto clipping strategy.
- enum SoQtViewer::StereoTypeContains list of supported stereo rendering techniques.
- Constructor & Destructor Documentation
- SoQtViewer::SoQtViewer (QWidget * parent, const char * name, SbBool embed, SoQtViewer::Type t, SbBool build) [protected]Constructor. parent, name and embed are passed on to SoQtRenderArea, so see the documentation for our parent constructor for for more information on those.
- SoQtViewer::~SoQtViewer () [protected]Destructor.
- Member Function Documentation
- void SoQtViewer::initClass (void) [static]Sets up initialization for data common to all instances of this class, submitting necessary information to the internal SoQt type system.
- SoType SoQtViewer::getClassTypeId (void) [static]This static method returns the SoType object associated with objects of this class.
- SoType SoQtViewer::getTypeId (void) const [virtual]Returns the type identification of an object derived from a class inheriting SoQtObject. This is used for run-time type checking and 'downward' casting.
- void SoQtViewer::setCamera (SoCamera * cam) [virtual]Set the camera we want the viewer to manipulate when interacting with the viewer controls.
- SoCamera * SoQtViewer::getCamera (void) constReturns the camera currently used by the viewer for the user's main viewpoint.
- void SoQtViewer::setCameraType (SoType t) [virtual]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.
- SoType SoQtViewer::getCameraType (void) constReturns camera type which will be used when the viewer has to make its own camera.
- void SoQtViewer::toggleCameraType (void) [virtual]If the current camera is of perspective type, switch to orthographic, and vice versa.
- void SoQtViewer::viewAll (void) [virtual]Reposition the current camera so we can see the complete scene.
- void SoQtViewer::saveHomePosition (void) [virtual]Store the current camera settings for later retrieval with resetToHomePosition().
- void SoQtViewer::resetToHomePosition (void) [virtual]Restore the saved camera settings.
- void SoQtViewer::setHeadlight (SbBool on) [virtual]Turn the camera headlight on or off.
- SbBool SoQtViewer::isHeadlight (void) constReturns status of the viewer headlight, whether it is on or off.
- SoDirectionalLight * SoQtViewer::getHeadlight (void) constReturns the a pointer to the directional light node which is the viewer headlight.
- void SoQtViewer::setDrawStyle (SoQtViewer::DrawType type, SoQtViewer::DrawStyle style) [virtual]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.
- SoQtViewer::DrawStyle SoQtViewer::getDrawStyle (const SoQtViewer::DrawType type) constReturn current drawstyles for the given type (STILL or INTERACTIVE).
- void SoQtViewer::setBufferingType (SoQtViewer::BufferType type) [virtual]Set the viewer's buffer type. Available types are SoQtViewer::BUFFER_SINGLE, SoQtViewer::BUFFER_DOUBLE and SoQtViewer::BUFFER_INTERACTIVE.
- SoQtViewer::BufferType SoQtViewer::getBufferingType (void) constReturn the viewer's buffer type.
- void SoQtViewer::setViewing (SbBool enable) [virtual]Set view mode.
- SbBool SoQtViewer::isViewing (void) constReturn state of view mode.
- void SoQtViewer::setCursorEnabled (SbBool on) [virtual]Set whether or not the mouse cursor representation should be visible in the viewer canvas.
- SbBool SoQtViewer::isCursorEnabled (void) constReturns visibility status of mouse cursor.
- void SoQtViewer::setAutoClipping (SbBool enable)Turn on or off continuous automatic adjustments of the near and far clipping planes.
- SbBool SoQtViewer::isAutoClipping (void) constReturn value of the automatic near/far clipplane adjustment indicator.
- void SoQtViewer::setAutoClippingStrategy (const AutoClippingStrategy strategy, const float value = 0.6f, SoQtAutoClippingCB * cb = NULL, void * cbuserdata = NULL)Set the strategy used for automatic updates of the distances to the near and far clipping planes.
- void SoQtViewer::setStereoViewing (SbBool enable) [virtual]Turn stereo viewing on or off.
- SbBool SoQtViewer::isStereoViewing (void) constReturns a boolean indicating whether or not we're in stereo viewing mode.
- void SoQtViewer::setStereoOffset (const float dist) [virtual]Set the offset between the two viewpoints when in stereo mode. Default value is 0.1.
- float SoQtViewer::getStereoOffset (void) constReturn the offset distance between the two viewpoints when in stereo mode.
- SbBool SoQtViewer::setStereoType (SoQtViewer::StereoType s)Set up stereo rendering.
- SoQtViewer::StereoType SoQtViewer::getStereoType (void) constReturns the current type of stereo rendering used (or SoQtViewer::STEREO_NONE if monoscopic).
- void SoQtViewer::setAnaglyphStereoColorMasks (const SbBool left[3], const SbBool right[3])If display is configured to render in anaglyph stereo, this function can be used to control which filter is used for each eye.
- void SoQtViewer::getAnaglyphStereoColorMasks (SbBool left[3], SbBool right[3])Returns color masks for left and right eye filters in anaglyph stereo.
- void SoQtViewer::setDetailSeek (const SbBool on)Toggle between seeking to a point or seeking to an object.
- SbBool SoQtViewer::isDetailSeek (void) constReturns a value indicating whether or not seeks will be performed to the exact point of picking or just towards the picked object.
- void SoQtViewer::setSeekTime (const float seconds)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.
- float SoQtViewer::getSeekTime (void) constReturns the camera repositioning duration following a seek action.
- void SoQtViewer::addStartCallback (SoQtViewerCB * func, void * data = NULL)Add a function to call when user interaction with the scene starts.
- void SoQtViewer::addFinishCallback (SoQtViewerCB * func, void * data = NULL)Add a function to call when user interaction with the scene ends.
- void SoQtViewer::removeStartCallback (SoQtViewerCB * func, void * data = NULL)Remove one of the functions which has been set up to be called when user interaction with the scene starts.
- void SoQtViewer::removeFinishCallback (SoQtViewerCB * func, void * data = NULL)Remove one of the functions which has been set up to be called when user interaction with the scene ends.
- void SoQtViewer::setWireframeOverlayColor (const SbColor & color)Set the color of the overlay wireframe to color.
- const SbColor & SoQtViewer::getWireframeOverlayColor (void) constReturns the current color of the overlay wireframe. The default color is [1,0,0], ie pure red.
- void SoQtViewer::setDoubleBuffer (const SbBool on) [virtual]Overloaded to update the local bufferingtype variable.
- void SoQtViewer::setSceneGraph (SoNode * root) [virtual]Give the viewer a scenegraph to render and interact with. Overridden from parent class so the viewer can add it's own nodes to control rendering in different styles, rendering with a headlight, etc.
- SoNode * SoQtViewer::getSceneGraph (void) [virtual]This method returns a reference to the scene graph root node as set by the user.
- void SoQtViewer::sizeChanged (const SbVec2s & size) [protected, virtual]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.
- void SoQtViewer::setSeekMode (SbBool enable) [protected, virtual]Put the viewer in or out of 'waiting-to-seek' mode.
- SbBool SoQtViewer::isSeekMode (void) const [protected]Return a flag which indicates whether or not the viewer is in 'waiting-to-seek' mode.
- SbBool SoQtViewer::seekToPoint (const SbVec2s screenpos) [protected]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.
- void SoQtViewer::seekToPoint (const SbVec3f & scenepos) [protected]Call this method to initiate a seek action towards the give 3D world coordinate point in the scene, scenepos.
- void SoQtViewer::computeSeekFinalOrientation (void) [protected, virtual]This method can be overridden in subclasses if the final orientation of the camera after a seek should be something other than what is computed in SoQtViewer::seekToPoint(const SbVec3f & scenepos)
- void SoQtViewer::actualRedraw (void) [protected, virtual]This method instantly redraws the normal (non-overlay) scenegraph by calling SoSceneManager::render().
- SbBool SoQtViewer::processSoEvent (const SoEvent *const event) [protected, virtual]Toolkit-native events are attempted converted to Coin-generic events in the SoQtRenderArea::processEvent() method. If this succeeds, they are forwarded to this method.
- void SoQtViewer::interactiveCountInc (void) [protected]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?).
- void SoQtViewer::interactiveCountDec (void) [protected]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?).
- int SoQtViewer::getInteractiveCount (void) const [protected]Return current interaction count nesting. If equal to zero, the viewer is in animation mode, otherwise the camera is still.
- void SoQtViewer::setSeekDistance (const float distance) [protected]Set the value used for calculating how close the camera and intersection hit point should be made at the end of a seek operation.
- float SoQtViewer::getSeekDistance (void) const [protected]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.
- void SoQtViewer::setSeekValueAsPercentage (const SbBool on) [protected]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.
- SbBool SoQtViewer::isSeekValuePercentage (void) const [protected]Returns an boolean which indicates if the seek distance value from getSeekDistance() should be interpreted as a percentage value or as an absolute value.
- void SoQtViewer::changeCameraValues (SoCamera * camera) [protected, virtual]Copies the settings of camera into our current camera. Cameras must be of the same class type.
- void SoQtViewer::addSuperimposition (SoNode * scene) [protected]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.
- void SoQtViewer::removeSuperimposition (SoNode * scene) [protected]This method is not part of the original InventorXt API.
- void SoQtViewer::setSuperimpositionEnabled (SoNode * scene, const SbBool enable) [protected]This method sets whether the superimposed scene graph should be traversed or not.
- SbBool SoQtViewer::getSuperimpositionEnabled (SoNode * scene) const [protected]This method returns whether the superimposed scene is rendered or not.
- Author
NAME
SoQtViewer -The SoQtViewer class is the top level base viewer class.
This is an abstract class, which adds the following features to it's SoQtRenderArea superclass: convenient methods for camera handling, an automatic headlight configuration.
SYNOPSIS
#include <Inventor/Qt/viewers/SoQtViewer.h>
Inherits SoQtRenderArea.
Inherited by SoQtFullViewer.
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 }
enum StereoType { STEREO_NONE, STEREO_ANAGLYPH, STEREO_QUADBUFFER, STEREO_INTERLEAVED_ROWS, STEREO_INTERLEAVED_COLUMNS }
Public Member Functions
virtual SoType getTypeId (void) const
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
SbBool setStereoType (SoQtViewer::StereoType s)
SoQtViewer::StereoType getStereoType (void) const
void setAnaglyphStereoColorMasks (const SbBool left[3], const SbBool right[3])
void getAnaglyphStereoColorMasks (SbBool left[3], SbBool right[3])
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)
Static Public Member Functions
static void initClass (void)
static SoType getClassTypeId (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)
void seekToPoint (const SbVec3f &scenepos)
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
Friends
class SoQtViewerP
class SoQtPlaneViewer
Detailed Description
The SoQtViewer class is the top level base viewer class.
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:
- *
- camera type: toggle between using an orthographic camera and a perspective camera with SoQtViewer::toggleCameraType()
- *
- zoom out to exactly encompass all scene geometry within the view by using SoQtViewer::viewAll()
- *
- tag a specific position and orientation for the camera as the 'home' position with SoQtViewer::saveHomePosition(), which one can then return to by using SoQtViewer::resetToHomePosition()
- *
- automatically fit the near and far clipping planes of the camera around the scene's geometry by using SoQtViewer::setAutoClipping()
- *
- control stereo viewing parameters
Note that there is no dragger or manipulator attached to the scene camera. The camera transform manipulation is calculated in a more direct manner in the non-abstract viewer classes inheriting SoQtViewer by reading mouse and keyboard events and interpreting how these should influence the camera. The calculations results in new values for SoCamera::position, SoCamera::orientation, and the other SoCamera field values for the camera designated to be the viewer viewpoint camera. These values are then inserted directly into the viewer's SoCamera node.
See e.g. the source code for SoQtExaminerViewer::processSoEvent() for the details.
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):
- *
- *
position'
- *
- arrow keys: moves camera slightly left, right, up or down
- *
Member Enumeration Documentation
enum SoQtViewer::TypeHints 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.
Enumerator:
- BROWSER
- If a user-supplied scenegraph passed into the setSceneGraph() function does not contain a camera, setting the viewer type to BROWSER will make the viewer in that case automatically set up a camera outside the scene, as part of the viewer's private and hidden 'supergraph'.
- EDITOR
- If a user-supplied scenegraph passed into the setSceneGraph() function does not contain a camera, setting the viewer type to EDITOR will make the viewer in that case automatically set up a camera in the user-supplied scene.
So if you want to avoid having the SoQtViewer class muck about with your supplied scenegraph, set the type-flag to SoQtViewer::BROWSER instead, which makes an inserted camera node go into the viewer's own 'wrapper' scene graph instead.
enum SoQtViewer::DrawStyleDecides drawstyle for a scene with either a still camera or an animating camera.
See also:
- SoQtViewer::setDrawStyle(), SoQtViewer::DrawType
Enumerator:
- VIEW_AS_IS
- Normal rendering, draws all scene geometry in it's original style.
- VIEW_HIDDEN_LINE
- Draw scene in 'hidden line' mode: that is, as wireframe with no 'see-through'.
Note that this is actually an expensive way to render, as the scene must be rendered twice to achieve the effect of hiding lines behind the invisible geometry.
- VIEW_NO_TEXTURE
- Render scene without textures.
- VIEW_LOW_COMPLEXITY
- Render all 'complex' shape types with low complexity to improve rendering performance.
- VIEW_LINE
- View all polygon geometry in wireframe mode.
- VIEW_POINT
- Render only the vertex positions of the geometry.
- VIEW_BBOX
- View the scene's bounding boxes, instead of rendering the full geometry.
A very efficient way of optimizing rendering performance for scenes with high primitive counts while moving the camera about is to set this mode for the SoQtViewer::INTERACTIVE DrawType.
- VIEW_LOW_RES_LINE
- Render as wireframe and don't bother with getting them rendered correctly in depth.
- VIEW_LOW_RES_POINT
- Render as vertex points and don't bother with getting them rendered correctly in depth.
- VIEW_SAME_AS_STILL
- Always render a scene with an animating camera (ie SoQtViewer::INTERACTIVE DrawType) in the same manner as scene with a still camera.
- VIEW_WIREFRAME_OVERLAY
- Render the scene as normal, but overlay a set of lines showing the contours of all polygons.
enum SoQtViewer::DrawTypeContains valid values for the first argument to the SoQtViewer::setDrawStyle() call. Decides the effect of the second argument.
See also:
- SoQtViewer::setDrawStyle(), SoQtViewer::DrawStyle
Enumerator:
- STILL
- If this value is passed as the first argument of SoQtViewer::setDrawStyle(), the second argument decides which draw style to use when the viewer camera is standing still in the same position with the same orientation -- i.e. when the end user is not interacting with the scene camera.
- INTERACTIVE
- If this value is passed as the first argument of SoQtViewer::setDrawStyle(), the second argument decides which draw style to use when the end user is interacting with the scene camera, causing continuous animation redraws.
enum SoQtViewer::BufferTypeSet of valid values for SoQtViewer::setBufferingType().
Enumerator:
- BUFFER_SINGLE
- Change underlying OpenGL canvas to be single-buffered.
- BUFFER_DOUBLE
- Change underlying OpenGL canvas to be double-buffered.
- BUFFER_INTERACTIVE
- Set up so animation rendering is done in a double-buffered OpenGL canvas, but ordinary rendering happens directly in the front-buffer.
This mode can be useful with absurdly large scenes, as the rendering will visibly progress, and one will avoid having the end user wonder why nothing is happening while the scene is rendered to the back buffer in the default SoQtViewer::BUFFER_DOUBLE mode.
enum SoQtViewer::AutoClippingStrategyEnum for auto clipping strategy.
See also:
- setAutoClippingStrategy()
Enumerator:
- VARIABLE_NEAR_PLANE
- Variable near plane auto clipping strategy. Explained in detail in the documentation for the SoQtViewer::setAutoClippingStrategy() method.
- CONSTANT_NEAR_PLANE
- Constant near plane auto clipping strategy. Explained in detail in the documentation for the SoQtViewer::setAutoClippingStrategy() method.
enum SoQtViewer::StereoTypeContains list of supported stereo rendering techniques.
See also:
- SoQtViewer::setStereoType()
Enumerator:
- STEREO_NONE
- Use monoscopic rendering.
- STEREO_ANAGLYPH
- Render stereo by superimposing two images of the same scene, but with different color filters over the left and right view (or 'eye').
This is a way of rendering stereo which works on any display, using color-filter glasses. Such glasses are usually cheap and easy to come by.
See also:
- setAnaglyphStereoColorMasks()
- STEREO_QUADBUFFER
- Render stereo by using OpenGL quad-buffers. This is the most common interface for stereo rendering for more expensive hardware devices, such as shutter glasses and polarized glasses.
The well known Crystal Eyes glasses are commonly used with this type of stereo display.
- STEREO_INTERLEAVED_ROWS
- Interleaving / interlacing rows from the left and right eye is another stereo rendering method requiring special hardware. One example of a provider of shutter glasses working with interleaved glasses is VRex:
http://www.vrex.com/
- STEREO_INTERLEAVED_COLUMNS
- Same basic technique as SoQtViewer::STEREO_INTERLEAVED_ROWS, only it is vertical lines that are interleaved / interlaced, instead of horizontal lines.
Constructor & Destructor Documentation
SoQtViewer::SoQtViewer (QWidget * parent, const char * name, SbBool embed, SoQtViewer::Type t, SbBool build) [protected]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.
References addFinishCallback(), addStartCallback(), BUFFER_DOUBLE, BUFFER_SINGLE, SoQtRenderArea::buildWidget(), getClassTypeId(), SoQtComponent::getParentWidget(), INTERACTIVE, SoQtGLWidget::isDoubleBuffer(), SoQtComponent::setBaseWidget(), SoQtComponent::setClassName(), STILL, VIEW_AS_IS, and VIEW_SAME_AS_STILL.
SoQtViewer::~SoQtViewer () [protected]Destructor.
References removeSuperimposition(), and setSceneGraph().
Member Function Documentation
void SoQtViewer::initClass (void) [static]Sets up initialization for data common to all instances of this class, submitting necessary information to the internal SoQt type system.
Reimplemented from SoQtRenderArea.
Reimplemented in SoQtConstrainedViewer, SoQtExaminerViewer, SoQtFlyViewer, SoQtFullViewer, and SoQtPlaneViewer.
SoType SoQtViewer::getClassTypeId (void) [static]This static method returns the SoType object associated with objects of this class.
Reimplemented from SoQtRenderArea.
Reimplemented in SoQtConstrainedViewer, SoQtExaminerViewer, SoQtFlyViewer, SoQtFullViewer, and SoQtPlaneViewer.
Referenced by setCameraType(), setSceneGraph(), SoQtViewer(), and toggleCameraType().
SoType SoQtViewer::getTypeId (void) const [virtual]Returns the type identification of an object derived from a class inheriting SoQtObject. This is used for run-time type checking and 'downward' casting.
Usage example:
void foo(SoQtViewer * comp) { if (comp->getTypeId() == SoQtExaminerViewer::getClassTypeId()) { // safe downward cast, knows the type SoQtExaminerViewer * exviewer = (SoQtExaminerViewer *)comp; } else if (comp->getTypeId().isOfType(SoQtFlyViewer::getClassTypeId())) { // safe downward cast, knows the type SoQtFlyViewer * flyviewer = (SoQtFlyViewer *)comp; // then something else } }
Reimplemented from SoQtRenderArea.
Reimplemented in SoQtConstrainedViewer, SoQtExaminerViewer, SoQtFlyViewer, SoQtFullViewer, and SoQtPlaneViewer.
void SoQtViewer::setCamera (SoCamera * cam) [virtual]Set the camera we want the viewer to manipulate when interacting with the viewer controls.
The camera passed in as an argument to this method must already be part of the viewer's scenegraph. You do not inject viewpoint cameras to the viewer with this method.
You should rather insert a camera into the scene graph first (if necessary, often one will be present already), then register it as the camera used by the viewer controls with this method.
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.
See also:
- getCamera()
Reimplemented in SoQtConstrainedViewer, SoQtExaminerViewer, SoQtFlyViewer, and SoQtPlaneViewer.
References saveHomePosition().
Referenced by SoQtConstrainedViewer::setCamera(), SoQtPlaneViewer::setCamera(), SoQtExaminerViewer::setCamera(), setCameraType(), and setSceneGraph().
SoCamera * SoQtViewer::getCamera (void) constReturns the camera currently used by the viewer for the user's main viewpoint.
It is possible that this function returns NULL, for instance if there's no scenegraph present in the viewer. (This is mostly meant as a note for developers extending the SoQt library, as application programmers usually controls if and when a viewer contains a scenegraph, and therefore know in advance if this method will return a valid camera pointer.)
See also:
- setCamera()
Referenced by actualRedraw(), SoQtFlyViewer::actualRedraw(), SoQtPlaneViewer::bottomWheelMotion(), changeCameraValues(), SoQtConstrainedViewer::checkForCameraUpConstrain(), SoQtPlaneViewer::leftWheelMotion(), SoQtPlaneViewer::processSoEvent(), SoQtExaminerViewer::processSoEvent(), SoQtPlaneViewer::rightWheelMotion(), SoQtExaminerViewer::rightWheelMotion(), setSceneGraph(), SoQtConstrainedViewer::setUpDirection(), and SoQtConstrainedViewer::tiltCamera().
void SoQtViewer::setCameraType (SoType t) [virtual]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.
See also:
- getCameraType()
Reimplemented in SoQtFlyViewer.
References getClassTypeId(), and setCamera().
Referenced by SoQtFlyViewer::setCameraType(), and toggleCameraType().
SoType SoQtViewer::getCameraType (void) constReturns 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.
See also:
- setCameraType()
Referenced by SoQtPlaneViewer::createViewerButtons(), and SoQtExaminerViewer::createViewerButtons().
void SoQtViewer::toggleCameraType (void) [virtual]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.
References getClassTypeId(), and setCameraType().
void SoQtViewer::viewAll (void) [virtual]Reposition the current camera so we can see the complete scene.
Reimplemented in SoQtFlyViewer.
References SoQtRenderArea::getViewportRegion().
Referenced by SoQtFlyViewer::viewAll().
void SoQtViewer::saveHomePosition (void) [virtual]Store the current camera settings for later retrieval with resetToHomePosition().
See also:
- resetToHomePosition()
Reimplemented in SoQtConstrainedViewer.
Referenced by SoQtConstrainedViewer::saveHomePosition(), and setCamera().
void SoQtViewer::resetToHomePosition (void) [virtual]Restore the saved camera settings.
See also:
- saveHomePosition()
Reimplemented in SoQtConstrainedViewer, and SoQtFlyViewer.
Referenced by processSoEvent(), and SoQtConstrainedViewer::resetToHomePosition().
void SoQtViewer::setHeadlight (SbBool on) [virtual]Turn the camera headlight on or off.
Default is to have a headlight turned on.
See also:
- isHeadlight(), getHeadlight()
SbBool SoQtViewer::isHeadlight (void) constReturns status of the viewer headlight, whether it is on or off.
See also:
- setHeadlight(), getHeadlight()
SoDirectionalLight * SoQtViewer::getHeadlight (void) constReturns the a pointer to the directional light node which is the viewer headlight.
The fields of the node is available for user editing.
See also:
- isHeadlight(), setHeadlight()
void SoQtViewer::setDrawStyle (SoQtViewer::DrawType type, SoQtViewer::DrawStyle style) [virtual]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.
See also:
- getDrawStyle()
References getDrawStyle(), INTERACTIVE, and STILL.
SoQtViewer::DrawStyle SoQtViewer::getDrawStyle (const SoQtViewer::DrawType type) constReturn current drawstyles for the given type (STILL or INTERACTIVE).
See also:
- setDrawStyle()
References INTERACTIVE, and STILL.
Referenced by setDrawStyle().
void SoQtViewer::setBufferingType (SoQtViewer::BufferType type) [virtual]Set the viewer's buffer type. Available types are SoQtViewer::BUFFER_SINGLE, SoQtViewer::BUFFER_DOUBLE and SoQtViewer::BUFFER_INTERACTIVE.
(With a buffer type of SoQtViewer::BUFFER_INTERACTIVE, the viewer will render with doublebuffering during user interaction and with single buffering otherwise.)
Default is SoQtViewer::BUFFER_DOUBLE.
See also:
- getBufferingType()
References BUFFER_DOUBLE, BUFFER_INTERACTIVE, BUFFER_SINGLE, and SoQtGLWidget::setDoubleBuffer().
SoQtViewer::BufferType SoQtViewer::getBufferingType (void) constReturn the viewer's buffer type.
See also:
- setBufferingType()
void SoQtViewer::setViewing (SbBool enable) [virtual]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.
See also:
- isViewing()
Reimplemented in SoQtExaminerViewer, SoQtFlyViewer, SoQtFullViewer, and SoQtPlaneViewer.
References SoQtRenderArea::getGLRenderAction().
Referenced by processSoEvent(), and SoQtFullViewer::setViewing().
SbBool SoQtViewer::isViewing (void) constReturn state of view mode.
TRUE means that the mode of the viewer is set such that user interaction with the mouse is used to modify the position and orientation of the camera.
See also:
- setViewing()
Referenced by SoQtFlyViewer::actualRedraw(), SoQtFullViewer::createViewerButtons(), processSoEvent(), SoQtPlaneViewer::processSoEvent(), SoQtFullViewer::processSoEvent(), SoQtFlyViewer::processSoEvent(), SoQtExaminerViewer::processSoEvent(), SoQtExaminerViewer::setFeedbackSize(), SoQtExaminerViewer::setFeedbackVisibility(), setSeekMode(), SoQtPlaneViewer::setSeekMode(), SoQtExaminerViewer::setSeekMode(), SoQtPlaneViewer::setViewing(), SoQtFlyViewer::setViewing(), SoQtExaminerViewer::setViewing(), SoQtFullViewer::setViewing(), and SoQtExaminerViewer::stopAnimating().
void SoQtViewer::setCursorEnabled (SbBool on) [virtual]Set whether or not the mouse cursor representation should be visible in the viewer canvas.
Default value is on.
See also:
- isCursorEnabled()
Reimplemented in SoQtExaminerViewer, SoQtFlyViewer, and SoQtPlaneViewer.
Referenced by SoQtPlaneViewer::setCursorEnabled(), SoQtFlyViewer::setCursorEnabled(), and SoQtExaminerViewer::setCursorEnabled().
SbBool SoQtViewer::isCursorEnabled (void) constReturns visibility status of mouse cursor.
See also:
- setCursorEnabled()
void SoQtViewer::setAutoClipping (SbBool enable)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 calculations of near and far clip planes are 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.
On a major note, be aware that turning auto-updating of near and far clip planes off have a potentially serious detrimental effect on performance, due to an important side effect: updating the near and far clip planes triggers an SoGetBoundingBoxAction to traverse the scene graph, which causes bounding boxes to be calculated and stored in caches. The bounding box caches are then used by the SoGLRenderAction traversal for view frustum culling operations. With no bounding box caches, the rendering will not do culling, which can cause much worse performance. Kongsberg Oil & Gas Technologies are working on correcting this problem properly from within the Coin library.
On a minor note, be aware that notifications will be temporarily turned off for the scene's SoCamera when changing the near and far clipping planes (which is done right before each redraw). This is done to avoid notifications being sent through the scene graph right before rendering, as that causes some latency. It is mentioned here in case you have any client code which for some reason needs to sense all changes to the scene camera. This is however unlikely, so you can very probably ignore this.
See also:
- getAutoClipping()
References SoQtRenderArea::scheduleRedraw().
SbBool SoQtViewer::isAutoClipping (void) constReturn value of the automatic near/far clipplane adjustment indicator.
See also:
- setAutoClipping()
void SoQtViewer::setAutoClippingStrategy (const AutoClippingStrategy strategy, const float value = 0.6f, SoQtAutoClippingCB * cb = NULL, void * cbuserdata = NULL)Set the strategy used for automatic updates of the distances to the near and far clipping planes.
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:
SbVec2f myfunc(void * data, const SbVec2f & nearfar);
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, including 'slack'.
The function callback can then modify the near and far clipping plane distances to what will actually be used by the viewer. These values will then be used unmodified for the viewer's camera.
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.
See also:
- setAutoClipping()
References SoQtRenderArea::scheduleRedraw(), and VARIABLE_NEAR_PLANE.
void SoQtViewer::setStereoViewing (SbBool enable) [virtual]Turn stereo viewing on or off.
Note: this function is being obsoleted, you should use the setStereoType() function instead.
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/
See also:
- isStereoViewing(), setStereoType()
References SoQtRenderArea::scheduleRedraw().
Referenced by setStereoType().
SbBool SoQtViewer::isStereoViewing (void) constReturns 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.
See also:
- setStereoViewing(), getStereoType()
Referenced by getStereoType().
void SoQtViewer::setStereoOffset (const float dist) [virtual]Set the offset between the two viewpoints when in stereo mode. Default value is 0.1.
NOTE: In the original InventorXt API, this method was not virtual.
See also:
- getStereoOffset()
References SoQtRenderArea::scheduleRedraw().
float SoQtViewer::getStereoOffset (void) constReturn the offset distance between the two viewpoints when in stereo mode.
See also:
- setStereoOffset()
SbBool SoQtViewer::setStereoType (SoQtViewer::StereoType s)Set up stereo rendering.
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/
Note: it is prefered that one uses this function for control of which type of stereo rendering to use, instead of the older SoQtViewer::setStereoViewing() and SoQtGLWidget::setQuadBufferStereo() functions.
The default is to do monoscopic rendering, i.e. the default SoQtViewer::StereoType value is SoQtViewer::STEREO_NONE.
See also:
- SoQtViewer::StereoType, SoCamera::setStereoAdjustment
Since:
- SoQt 1.2
References SoQtGLWidget::getStencilBuffer(), getStereoType(), SoQtGLWidget::isQuadBufferStereo(), SoQtGLWidget::setQuadBufferStereo(), SoQtGLWidget::setStencilBuffer(), setStereoViewing(), STEREO_ANAGLYPH, STEREO_INTERLEAVED_COLUMNS, STEREO_INTERLEAVED_ROWS, STEREO_NONE, and STEREO_QUADBUFFER.
SoQtViewer::StereoType SoQtViewer::getStereoType (void) constReturns the current type of stereo rendering used (or SoQtViewer::STEREO_NONE if monoscopic).
References SoQtGLWidget::isQuadBufferStereo(), isStereoViewing(), STEREO_ANAGLYPH, and STEREO_QUADBUFFER.
Referenced by actualRedraw(), and setStereoType().
void SoQtViewer::setAnaglyphStereoColorMasks (const SbBool left[3], const SbBool right[3])If display is configured to render in anaglyph stereo, this function can be used to control which filter is used for each eye.
The default filters are red (i.e. color vector [TRUE,FALSE,FALSE]) for the left eye, and cyan (color vector [FALSE,TRUE,TRUE]) for the right eye.
See also:
- SoQtViewer::StereoType, setStereoType()
References SoQtRenderArea::scheduleRedraw().
void SoQtViewer::getAnaglyphStereoColorMasks (SbBool left[3], SbBool right[3])Returns color masks for left and right eye filters in anaglyph stereo.
See also:
- setAnaglyphStereoColorMasks()
void SoQtViewer::setDetailSeek (const SbBool on)Toggle between seeking to a point or seeking to an object.
Default is to seek to a point.
See also:
- isDetailSeek()
SbBool SoQtViewer::isDetailSeek (void) constReturns a value indicating whether or not seeks will be performed to the exact point of picking or just towards the picked object.
See also:
- setDetailSeek()
void SoQtViewer::setSeekTime (const float seconds)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.
See also:
- getSeekTime()
float SoQtViewer::getSeekTime (void) constReturns the camera repositioning duration following a seek action.
See also:
- setSeekTime()
void SoQtViewer::addStartCallback (SoQtViewerCB * func, void * data = NULL)Add a function to call when user interaction with the scene starts.
See also:
- removeStartCallback(), addFinishCallback()
Referenced by SoQtViewer().
void SoQtViewer::addFinishCallback (SoQtViewerCB * func, void * data = NULL)Add a function to call when user interaction with the scene ends.
See also:
- removeFinishCallback(), addStartCallback()
Referenced by SoQtViewer().
void SoQtViewer::removeStartCallback (SoQtViewerCB * func, void * data = NULL)Remove one of the functions which has been set up to be called when user interaction with the scene starts.
See also:
- addStartCallback(), removeFinishCallback()
void SoQtViewer::removeFinishCallback (SoQtViewerCB * func, void * data = NULL)Remove one of the functions which has been set up to be called when user interaction with the scene ends.
See also:
- addFinishCallback(), removeStartCallback()
void SoQtViewer::setWireframeOverlayColor (const SbColor & color)Set the color of the overlay wireframe to color.
See also:
- getWireframeOverlayColor()
References SoQtRenderArea::scheduleRedraw().
const SbColor & SoQtViewer::getWireframeOverlayColor (void) constReturns the current color of the overlay wireframe. The default color is [1,0,0], ie pure red.
See also:
- setWireframeOverlayColor()
void SoQtViewer::setDoubleBuffer (const SbBool on) [virtual]Overloaded to update the local bufferingtype variable.
See also:
- setBufferingType(), getBufferingType()
Reimplemented from SoQtGLWidget.
References BUFFER_DOUBLE, BUFFER_SINGLE, and SoQtGLWidget::setDoubleBuffer().
void SoQtViewer::setSceneGraph (SoNode * root) [virtual]Give the viewer a scenegraph to render and interact with. Overridden 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 automatically be instantiated and added. You can get a reference to this camera by using the SoQtViewer::getCamera() method.
See also:
- getSceneGraph(), setCameraType()
Reimplemented from SoQtRenderArea.
References BROWSER, getCamera(), getClassTypeId(), SoQtRenderArea::getSceneGraph(), SoQtRenderArea::getViewportRegion(), setCamera(), and SoQtRenderArea::setSceneGraph().
Referenced by ~SoQtViewer().
SoNode * SoQtViewer::getSceneGraph (void) [virtual]This method returns a reference to the scene graph root node as set by the user.
See also:
- SoQtRenderArea::getSceneManager()
Reimplemented from SoQtRenderArea.
void SoQtViewer::sizeChanged (const SbVec2s & size) [protected, virtual]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.
References SoQtRenderArea::sizeChanged().
Referenced by SoQtFullViewer::sizeChanged().
void SoQtViewer::setSeekMode (SbBool enable) [protected, virtual]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.
See also:
- isSeekMode(), setDetailSeek()
Reimplemented in SoQtExaminerViewer, SoQtFlyViewer, and SoQtPlaneViewer.
References interactiveCountDec(), and isViewing().
Referenced by processSoEvent(), seekToPoint(), SoQtPlaneViewer::setSeekMode(), SoQtFlyViewer::setSeekMode(), and SoQtExaminerViewer::setSeekMode().
SbBool SoQtViewer::isSeekMode (void) const [protected]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.)
See also:
- setSeekMode()
Referenced by processSoEvent(), SoQtPlaneViewer::processSoEvent(), SoQtFlyViewer::processSoEvent(), SoQtExaminerViewer::processSoEvent(), SoQtPlaneViewer::setSeekMode(), SoQtFlyViewer::setSeekMode(), and SoQtExaminerViewer::setSeekMode().
SbBool SoQtViewer::seekToPoint (const SbVec2s screenpos) [protected]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 TRUE if the ray from the screenpos position intersect with any parts of the onscreen geometry, otherwise FALSE.
References SoQtRenderArea::getViewportRegion(), interactiveCountInc(), and setSeekMode().
Referenced by processSoEvent(), SoQtPlaneViewer::processSoEvent(), and SoQtExaminerViewer::processSoEvent().
void SoQtViewer::seekToPoint (const SbVec3f & scenepos) [protected]Call this method to initiate a seek action towards the give 3D world coordinate point in the scene, scenepos.
Since:
- SoQt 1.3.0
References computeSeekFinalOrientation(), interactiveCountDec(), and interactiveCountInc().
void SoQtViewer::computeSeekFinalOrientation (void) [protected, virtual]This method can be overridden in subclasses if the final orientation of the camera after a seek should be something other than what is computed in SoQtViewer::seekToPoint(const SbVec3f & scenepos)
Reimplemented in SoQtPlaneViewer.
Referenced by seekToPoint().
void SoQtViewer::actualRedraw (void) [protected, virtual]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:
// This example shows how to put a permanent background image on // your viewer canvas, below the 3D graphics, plus overlay // foreground geometry. Written by mortene. // Copyright Kongsberg Oil & Gas Technologies 2002. // ************************************************************************* #include <Inventor/Qt/SoQt.h> #include <Inventor/Qt/viewers/SoQtExaminerViewer.h> #include <Inventor/nodes/SoBaseColor.h> #include <Inventor/nodes/SoCone.h> #include <Inventor/nodes/SoCube.h> #include <Inventor/nodes/SoImage.h> #include <Inventor/nodes/SoLightModel.h> #include <Inventor/nodes/SoOrthographicCamera.h> #include <Inventor/nodes/SoRotationXYZ.h> #include <Inventor/nodes/SoSeparator.h> #include <Inventor/nodes/SoTranslation.h> #include <GL/gl.h> // ************************************************************************* class MyExaminerViewer : public SoQtExaminerViewer { public: MyExaminerViewer(QWidget * parent, const char * filename); ~MyExaminerViewer(); protected: virtual void actualRedraw(void); private: SoSeparator * bckgroundroot; SoSeparator * foregroundroot; SoRotationXYZ * arrowrotation; }; MyExaminerViewer::MyExaminerViewer(QWidget * parent, const char * filename) : SoQtExaminerViewer(parent) { // Coin should not clear the pixel-buffer, so the background image // is not removed. this->setClearBeforeRender(FALSE, TRUE); // Set up background scenegraph with image in it. this->bckgroundroot = new SoSeparator; this->bckgroundroot->ref(); SoOrthographicCamera * cam = new SoOrthographicCamera; cam->position = SbVec3f(0, 0, 1); cam->height = 1; // SoImage will be at z==0.0. cam->nearDistance = 0.5; cam->farDistance = 1.5; SoImage * img = new SoImage; img->vertAlignment = SoImage::HALF; img->horAlignment = SoImage::CENTER; img->filename = filename; this->bckgroundroot->addChild(cam); this->bckgroundroot->addChild(img); // Set up foreground, overlayed scenegraph. this->foregroundroot = new SoSeparator; this->foregroundroot->ref(); SoLightModel * lm = new SoLightModel; lm->model = SoLightModel::BASE_COLOR; SoBaseColor * bc = new SoBaseColor; bc->rgb = SbColor(1, 1, 0); cam = new SoOrthographicCamera; cam->position = SbVec3f(0, 0, 5); cam->height = 10; cam->nearDistance = 0; cam->farDistance = 10; const double ARROWSIZE = 2.0; SoTranslation * posit = new SoTranslation; posit->translation = SbVec3f(-2.5 * ARROWSIZE, 1.5 * ARROWSIZE, 0); arrowrotation = new SoRotationXYZ; arrowrotation->axis = SoRotationXYZ::Z; SoTranslation * offset = new SoTranslation; offset->translation = SbVec3f(ARROWSIZE/2.0, 0, 0); SoCube * cube = new SoCube; cube->width = ARROWSIZE; cube->height = ARROWSIZE/15.0; this->foregroundroot->addChild(cam); this->foregroundroot->addChild(lm); this->foregroundroot->addChild(bc); this->foregroundroot->addChild(posit); this->foregroundroot->addChild(arrowrotation); this->foregroundroot->addChild(offset); this->foregroundroot->addChild(cube); } MyExaminerViewer::~MyExaminerViewer() { this->bckgroundroot->unref(); this->foregroundroot->unref(); } void MyExaminerViewer::actualRedraw(void) { // Must set up the OpenGL viewport manually, as upon resize // operations, Coin won't set it up until the SoGLRenderAction is // applied again. And since we need to do glClear() before applying // the action.. const SbViewportRegion vp = this->getViewportRegion(); SbVec2s origin = vp.getViewportOriginPixels(); SbVec2s size = vp.getViewportSizePixels(); glViewport(origin[0], origin[1], size[0], size[1]); const SbColor col = this->getBackgroundColor(); glClearColor(col[0], col[1], col[2], 0.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Render our scenegraph with the image. SoGLRenderAction * glra = this->getGLRenderAction(); glra->apply(this->bckgroundroot); // Render normal scenegraph. SoQtExaminerViewer::actualRedraw(); // Increase arrow angle with 1/1000 ° every frame. arrowrotation->angle = arrowrotation->angle.getValue() + (0.001 / M_PI * 180); // Render overlay front scenegraph. glClear(GL_DEPTH_BUFFER_BIT); glra->apply(this->foregroundroot); } // ************************************************************************* int main(int argc, char ** argv) { if (argc != 2) { (void)fprintf(stderr, 'n Usage: %s <image-filename>n', argv[0]); exit(1); } QWidget * window = SoQt::init(argv[0]); MyExaminerViewer * viewer = new MyExaminerViewer(window, argv[1]); viewer->setSceneGraph(new SoCone); viewer->show(); SoQt::show(window); SoQt::mainLoop(); delete viewer; return 0; } // *************************************************************************
Reimplemented from SoQtRenderArea.
Reimplemented in SoQtExaminerViewer, SoQtFlyViewer, and SoQtPlaneViewer.
References SoQtRenderArea::getBackgroundColor(), getCamera(), SoQtRenderArea::getSceneManager(), getStereoType(), SoQtRenderArea::isClearBeforeRender(), SoQtRenderArea::isClearZBufferBeforeRender(), SoQtGLWidget::isDoubleBuffer(), STEREO_ANAGLYPH, STEREO_INTERLEAVED_COLUMNS, STEREO_INTERLEAVED_ROWS, STEREO_NONE, and STEREO_QUADBUFFER.
Referenced by SoQtPlaneViewer::actualRedraw(), SoQtFlyViewer::actualRedraw(), and SoQtExaminerViewer::actualRedraw().
SbBool SoQtViewer::processSoEvent (const SoEvent *const event) [protected, virtual]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 TRUE iff the event was processed. If not it should be passed on further up in the inheritance hierarchy by the caller. This last point is extremely important to take note of if you are expanding the toolkit with your own viewer class.
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 SoQtExaminerViewer, SoQtFlyViewer, SoQtFullViewer, and SoQtPlaneViewer.
References isSeekMode(), isViewing(), SoQtRenderArea::processSoEvent(), resetToHomePosition(), seekToPoint(), setSeekMode(), and setViewing().
Referenced by SoQtFullViewer::processSoEvent().
void SoQtViewer::interactiveCountInc (void) [protected]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.
See also:
- interactiveCountDec(), getInteractiveCount()
addStartCallback(), addFinishCallback()
removeStartCallback(), removeFinishCallback()
setDrawStyle(), setBufferingType()
Referenced by SoQtFullViewer::bottomWheelStart(), SoQtFullViewer::leftWheelStart(), SoQtFullViewer::rightWheelStart(), and seekToPoint().
void SoQtViewer::interactiveCountDec (void) [protected]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.
See also:
- interactiveCountInc(), getInteractiveCount()
addStartCallback(), addFinishCallback()
removeStartCallback(), removeFinishCallback()
setDrawStyle(), setBufferingType()
Referenced by SoQtFullViewer::bottomWheelFinish(), SoQtFullViewer::leftWheelFinish(), SoQtFullViewer::rightWheelFinish(), seekToPoint(), and setSeekMode().
int SoQtViewer::getInteractiveCount (void) const [protected]Return current interaction count nesting. If equal to zero, the viewer is in animation mode, otherwise the camera is still.
See also:
- interactiveCountInc(), interactiveCountDec()
void SoQtViewer::setSeekDistance (const float distance) [protected]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).
See also:
- getSeekDistance(), setSeekValueAsPercentage(), setSeekTime()
float SoQtViewer::getSeekDistance (void) const [protected]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.
See also:
- setSeekDistance(), isSeekValueAsPercentage()
void SoQtViewer::setSeekValueAsPercentage (const SbBool on) [protected]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.
See also:
- setSeekDistance(), isSeekValueAsPercentage()
References isSeekValuePercentage().
SbBool SoQtViewer::isSeekValuePercentage (void) const [protected]Returns an boolean which indicates if the seek distance value from getSeekDistance() should be interpreted as a percentage value or as an absolute value.
See also:
- setSeekValuePercentage(), getSeekDistance()
Referenced by setSeekValueAsPercentage().
void SoQtViewer::changeCameraValues (SoCamera * camera) [protected, virtual]Copies the settings of camera into our current camera. Cameras must be of the same class type.
Reimplemented in SoQtConstrainedViewer.
References getCamera().
Referenced by SoQtConstrainedViewer::changeCameraValues().
void SoQtViewer::addSuperimposition (SoNode * scene) [protected]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.
void SoQtViewer::removeSuperimposition (SoNode * scene) [protected]This method is not part of the original InventorXt API.
Referenced by SoQtFlyViewer::~SoQtFlyViewer(), and ~SoQtViewer().
void SoQtViewer::setSuperimpositionEnabled (SoNode * scene, const SbBool enable) [protected]This method sets whether the superimposed scene graph should be traversed or not.
This method is not part of the original InventorXt API.
Referenced by SoQtFlyViewer::setViewing().
SbBool SoQtViewer::getSuperimpositionEnabled (SoNode * scene) const [protected]This method returns whether the superimposed scene is rendered or not.
This method is not part of the original InventorXt API.
Author
Generated automatically by Doxygen for SoQt from the source code.
Contenus ©2006-2024 Benjamin Poulain
Design ©2006-2024 Maxime Vantorre