SoQtViewer(3)
โจ SoQtViewer(3) โ the SoQt manual, bestie edition โจ
okay so this is the manual page for SoQtViewer, from the SoQt family, and it is the top level base viewer class โ like, the blueprint every other viewer is built on top of. main character energy fr.
๐ NAME ๐
SoQtViewer โ the top level base viewer class. that's it, that's the whole name section, she's concise and she knows it ๐
๐ฆ SYNOPSIS ๐ฆ
you get to her by including this, exactly this, no typos bestie:
#include <Inventor/Qt/viewers/SoQtViewer.h>
- Inherits
SoQtRenderAreaโ she got it from her mom. - Inherited by
SoQtFullViewerโ and she passed the genes on ๐
๐ธ Public Types ๐ธ
here's the whole enum haul, listed exactly, no cap:
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 }
note that STILL = 0 on DrawType โ that default is doing work ๐
๐ Public Member Functions ๐
every single one, and yes I'm listing all of them, because we don't skip:
virtual void setCamera (SoCamera *camera)โ hands her a camera โจSoCamera * getCamera (void) constโ hands the camera backvirtual void setCameraType (SoType type)โ pick your camera typeSoType getCameraType (void) constโ which camera type is it thovirtual void toggleCameraType (void)โ flips it, iconicallyvirtual void viewAll (void)โ see literally everythingvirtual void saveHomePosition (void)โ bookmarks home base ๐virtual void resetToHomePosition (void)โ takes you back homevirtual void setHeadlight (SbBool enable)โ headlight on or offSbBool isHeadlight (void) constโ is the headlight onSoDirectionalLight * getHeadlight (void) constโ the actual headlight objectvirtual void setDrawStyle (SoQtViewer::DrawType type, SoQtViewer::DrawStyle style)โ draw type + draw style, both at onceSoQtViewer::DrawStyle getDrawStyle (const SoQtViewer::DrawType type) constโ reads back the style for that typevirtual void setBufferingType (SoQtViewer::BufferType type)โ set the buffering vibeSoQtViewer::BufferType getBufferingType (void) constโ read the buffering vibevirtual void setViewing (SbBool enable)โ viewing on/offSbBool isViewing (void) constโ viewing yes/novirtual void setCursorEnabled (SbBool enable)โ cursor in or outSbBool isCursorEnabled (void) constโ cursor status checkvoid setAutoClipping (SbBool enable)โ auto clipping, on or offSbBool isAutoClipping (void) constโ auto clipping, yes or novoid setAutoClippingStrategy (const AutoClippingStrategy strategy, const float value=0.6f, SoQtAutoClippingCB *cb=NULL, void *cbuserdata=NULL)โ strategy, plusvalue=0.6f,cb=NULL,cbuserdata=NULLdefaults ๐ซถvirtual void setStereoViewing (SbBool enable)โ stereo viewing toggleSbBool isStereoViewing (void) constโ stereo viewing queryvirtual void setStereoOffset (const float dist)โ sets the stereo offset distancefloat getStereoOffset (void) constโ gets the stereo offset distanceSbBool setStereoType (SoQtViewer::StereoType s)โ note it returns anSbBool, and takes one of thoseStereoTypevaluesSoQtViewer::StereoType getStereoType (void) constโ which stereo type is activevoid setAnaglyphStereoColorMasks (const SbBool left[3], const SbBool right[3])โ 3 flags per eye, left and rightvoid getAnaglyphStereoColorMasks (SbBool left[3], SbBool right[3])โ reads those 3-per-eye masks outvoid setDetailSeek (const SbBool enable)โ detail seek toggleSbBool isDetailSeek (void) constโ detail seek queryvoid setSeekTime (const float seconds)โ seek time, in secondsfloat getSeekTime (void) constโ seek time, read backvoid addStartCallback (SoQtViewerCB *func, void *data=NULL)โ hook afuncwith optionaldata=NULLfor startvoid addFinishCallback (SoQtViewerCB *func, void *data=NULL)โ same deal but for finishvoid removeStartCallback (SoQtViewerCB *func, void *data=NULL)โ un-hook the start onevoid removeFinishCallback (SoQtViewerCB *func, void *data=NULL)โ un-hook the finish onevoid setWireframeOverlayColor (const SbColor &color)โ sets that wireframe overlay colorconst SbColor & getWireframeOverlayColor (void) constโ returns it as a const refvirtual void setDoubleBuffer (const SbBool enable)โ double buffer on/offvirtual void setSceneGraph (SoNode *root)โ give her arootnodevirtual SoNode * getSceneGraph (void)โ get the root node back
๐ Public Member Functions inherited from SoQtRenderArea ๐
all of these come pre-loved from the parent, exact signatures:
SoQtRenderArea (QWidget *parent=NULL, const char *name=NULL, SbBool embed=TRUE, SbBool mouseInput=TRUE, SbBool keyboardInput=TRUE)~SoQtRenderArea ()void setOverlaySceneGraph (SoNode *scene)SoNode * getOverlaySceneGraph (void)void setBackgroundColor (const SbColor &color)const SbColor & getBackgroundColor (void) constvoid setBackgroundIndex (int idx)int getBackgroundIndex (void) constvoid setOverlayBackgroundIndex (int idx)int getOverlayBackgroundIndex (void) constvoid setColorMap (int start, int num, const SbColor *colors)void setOverlayColorMap (int start, int num, const SbColor *colors)void setViewportRegion (const SbViewportRegion &newRegion)const SbViewportRegion & getViewportRegion (void) constvoid setTransparencyType (SoGLRenderAction::TransparencyType type)SoGLRenderAction::TransparencyType getTransparencyType (void) constvoid setAntialiasing (SbBool smoothing, int numPasses)void getAntialiasing (SbBool &smoothing, int &numPasses) constvoid setClearBeforeRender (SbBool enable, SbBool zbEnable=TRUE)SbBool isClearBeforeRender (void) constSbBool isClearZBufferBeforeRender (void) constvoid setClearBeforeOverlayRender (SbBool enable)SbBool isClearBeforeOverlayRender (void) constvoid setAutoRedraw (SbBool enable)SbBool isAutoRedraw (void) constvoid setRedrawPriority (uint32_t priority)uint32_t getRedrawPriority (void) constvoid render (void)void renderOverlay (void)void scheduleRedraw (void)void scheduleOverlayRedraw (void)void redrawOnSelectionChange (SoSelection *selection)void redrawOverlayOnSelectionChange (SoSelection *selection)void setEventCallback (SoQtRenderAreaEventCB *func, void *user=NULL)void setSceneManager (SoSceneManager *manager)SoSceneManager * getSceneManager (void) constvoid setOverlaySceneManager (SoSceneManager *manager)SoSceneManager * getOverlaySceneManager (void) constvoid setGLRenderAction (SoGLRenderAction *action)SoGLRenderAction * getGLRenderAction (void) constvoid setOverlayGLRenderAction (SoGLRenderAction *action)SoGLRenderAction * getOverlayGLRenderAction (void) constSbBool sendSoEvent (const SoEvent *event)void registerDevice (SoQtDevice *device)void unregisterDevice (SoQtDevice *device)
๐ Public Member Functions inherited from SoQtGLWidget ๐
void setBorder (const SbBool enable)SbBool isBorder (void) constSbBool isDoubleBuffer (void) constvoid setDrawToFrontBufferEnable (const SbBool enable)SbBool isDrawToFrontBufferEnable (void) constvoid setQuadBufferStereo (const SbBool enable)SbBool isQuadBufferStereo (void) constvoid setAccumulationBuffer (const SbBool enable)SbBool getAccumulationBuffer (void) constvoid setStencilBuffer (const SbBool enable)SbBool getStencilBuffer (void) constvoid setAlphaChannel (const SbBool enable)SbBool getAlphaChannel (void) constvoid setOverlayRender (const SbBool onoff)SbBool isOverlayRender (void) constvoid setSampleBuffers (const int numsamples)int getSampleBuffers (void) constvoid setStealFocus (SbBool enable)SbBool isStealFocus (void) constQWidget * getGLWidget (void) constQWidget * getNormalWidget (void) constQWidget * getOverlayWidget (void) constSbBool hasOverlayGLArea (void) constSbBool hasNormalGLArea (void) constunsigned long getOverlayTransparentPixel (void)void getPointSizeLimits (SbVec2f &range, float &granularity)void getLineWidthLimits (SbVec2f &range, float &granularity)
๐ Public Member Functions inherited from SoQtComponent ๐
virtual SoType getTypeId (void) constvirtual ~SoQtComponent ()virtual void show (void)virtual void hide (void)virtual void setComponentCursor (const SoQtCursor &cursor)SbBool isFullScreen (void) constSbBool setFullScreen (const SbBool onoff)SbBool isVisible (void)SbBool isTopLevelShell (void) constQWidget * getWidget (void) constQWidget * getBaseWidget (void) constQWidget * getShellWidget (void) constQWidget * getParentWidget (void) constvoid setSize (const SbVec2s size)SbVec2s getSize (void) constvoid setTitle (const char *const title)const char * getTitle (void) constvoid setIconTitle (const char *const title)const char * getIconTitle (void) constconst char * getWidgetName (void) constconst char * getClassName (void) constvoid setWindowCloseCallback (SoQtComponentCB *const func, void *const user=NULL)
๐ Public Member Functions inherited from SoQtObject ๐
SbBool isOfType (SoType type) const
๐ง Protected Member Functions ๐ง
the behind-the-scenes girlies โ protected, so like, family only:
SoQtViewer (QWidget *parent, const char *name, SbBool embed, Type type, SbBool build)โ the constructor~SoQtViewer ()โ the destructorvirtual void sizeChanged (const SbVec2s &size)โ reacts to a size changevirtual void setSeekMode (SbBool enable)โ seek mode on/offSbBool isSeekMode (void) constโ seek mode checkSbBool seekToPoint (const SbVec2s screenpos)โ seek using a screen position, returnsSbBoolvoid seekToPoint (const SbVec3f &scenepos)โ overload: seek using a scene positionvirtual void computeSeekFinalOrientation (void)โ works out the final orientation for the seekvirtual void actualRedraw (void)โ the actual redrawvirtual SbBool processSoEvent (const SoEvent *const event)โ processes an So event, returnsSbBoolvoid interactiveCountInc (void)โ bumps the interactive count upvoid interactiveCountDec (void)โ bumps it back downint getInteractiveCount (void) constโ reads the interactive countvoid setSeekDistance (const float distance)โ seek distance setterfloat getSeekDistance (void) constโ seek distance gettervoid setSeekValueAsPercentage (const SbBool on)โ should the seek value be a percentageSbBool isSeekValuePercentage (void) constโ is it a percentage thovirtual void changeCameraValues (SoCamera *camera)โ tweaks the camera's valuesvoid addSuperimposition (SoNode *scene)โ add a superimposition scenevoid removeSuperimposition (SoNode *scene)โ remove itvoid setSuperimpositionEnabled (SoNode *scene, const SbBool enable)โ enable/disable a superimpositionSbBool getSuperimpositionEnabled (SoNode *scene) constโ is that superimposition enabled
๐ Protected Member Functions inherited from SoQtRenderArea ๐
SoQtRenderArea (QWidget *parent, const char *name, SbBool embed, SbBool mouseInput, SbBool keyboardInput, SbBool build)virtual void redraw (void)virtual void redrawOverlay (void)virtual void actualOverlayRedraw (void)virtual void processEvent (QEvent *event)virtual void initGraphic (void)virtual void initOverlayGraphic (void)virtual void widgetChanged (QWidget *widget)virtual void afterRealizeHook (void)QWidget * buildWidget (QWidget *parent)virtual const char * getDefaultWidgetName (void) constvirtual const char * getDefaultTitle (void) constvirtual const char * getDefaultIconTitle (void) constvirtual SbBool glScheduleRedraw (void)
๐ Protected Member Functions inherited from SoQtGLWidget ๐
SoQtGLWidget (QWidget *const parent=NULL, const char *const name=NULL, const SbBool embed=TRUE, const int glmodes=SO_GL_RGB, const SbBool build=TRUE)~SoQtGLWidget ()QWidget * buildWidget (QWidget *parent)void setGLSize (const SbVec2s size)SbVec2s getGLSize (void) constfloat getGLAspectRatio (void) constvoid setGlxSize (const SbVec2s size)SbVec2s getGlxSize (void) constfloat getGlxAspectRatio (void) constvoid setStereoBuffer (SbBool flag)SbBool isStereoBuffer (void) constSbBool isRGBMode (void)void glLockNormal (void)void glUnlockNormal (void)void glLockOverlay (void)void glUnlockOverlay (void)void glSwapBuffers (void)void glFlushBuffer (void)
okay that's the entire synopsis dump, every enum, every signature, every inherited one, all accounted for ๐ next part has the actual descriptions so stay tuned bestie ๐ซถ
SoQtComponent (QWidget *const parent=NULL, const char *const name=NULL, const SbBool embed=TRUE)โ the constructor for the superclass, withparent,nameandembedall defaulted out for you ๐ซถvoid setClassName (const char *const name)โ sets the class name, bestie, that's it, that's the whole jobvoid setBaseWidget (QWidget *widget)โ tells the component which widget is the base onevoid registerWidget (QWidget *widget)โ registers a widget with the componentvoid unregisterWidget (QWidget *widget)โ takes it back out again, no hard feelingsvoid addVisibilityChangeCallback (SoQtComponentVisibilityCB *const func, void *const user=NULL)โ hooks up a callback that fires when the thing gets shown/hidden ๐void removeVisibilityChangeCallback (SoQtComponentVisibilityCB *const func, void *const user=NULL)โ removes that callback, bye โ๏ธ
โจ Additional Inherited Members โจ
Static public member functions it got from SoQtRenderArea:
static uint32_t getDefaultRedrawPriority (void)โ hands you the default redraw priority value
Static public member functions it got from SoQtComponent:
static void initClass (void)โ runs the class initstatic SoType getClassTypeId (void)โ gives you the class type idstatic void setWidgetCursor (QWidget *w, const SoQtCursor &cursor)โ sets the cursor on widgetwtocursorstatic SoQtComponent * getComponent (QWidget *widget)โ looks up the component for a widgetstatic void initClasses (void)โ inits the classes, plural, yes queen ๐ธ
Static public member functions it got from SoQtObject:
static void initClass (void)โ class init again, different ancestor, don't @ mestatic SoType getClassTypeId (void)โ type id, againstatic void init (void)โ plaininit(), no frills
Protected attributes it got from SoQtGLWidget:
SbBool waitForExposeโ whether it waits for the expose eventSbBool drawToFrontBufferโ whether it draws straight to the front buffer
๐ Detailed Description ๐
Okay so SoQtViewer is the top level base viewer class. Like, the main character of viewer classes ๐
It's an abstract class, which means you don't instantiate it directly, but what it does is take its SoQtRenderArea superclass and glow it up with: convenient camera handling methods, and an automatic headlight configuration. Two for one, slay.
So about that camera handling: when you set a new scene graph on the viewer, that scene graph gets automatically scanned for a node derived from SoCamera. If none is found, the viewer itself sets up a camera for the scene. And after that, you (the application programmer) can control the camera so many ways, it's giving options on options ๐
- camera type: toggle between an orthographic camera and a perspective camera using
SoQtViewer::toggleCameraType() - zoom out to exactly encompass all scene geometry within the view using
SoQtViewer::viewAll()โ literally fit the whole thing, no cap - tag a specific position and orientation for the camera as the "home" position with
SoQtViewer::saveHomePosition(), which you can then return to by usingSoQtViewer::resetToHomePosition()โ home sweet home ๐ - automatically fit the near and far clipping planes of the camera around the scene's geometry with
SoQtViewer::setAutoClipping() - control stereo viewing parameters โ yes, stereo, we stan
Heads up bestie ๐ there is no dragger or manipulator attached to the scene camera. None. Instead, the camera transform manipulation gets calculated in a much more direct manner in the non-abstract viewer classes that inheritSoQtViewer, by reading mouse and keyboard events and interpreting how those should influence the camera. The calculation results in new values forSoCamera::position,SoCamera::orientation, and all the otherSoCamerafield values for the camera designated to be the viewer viewpoint camera. Those values then get inserted directly into the viewer'sSoCameranode.
Wanna see the details? Go look at the source code for SoQtExaminerViewer::processSoEvent() ๐
The SoQtViewer class also automatically adds a headlight to the scene, and that headlight will always point in the approximate same direction as the current viewer camera โ which secures that the scene geometry is always lighted and visible. Very considerate of it ngl. (But if you don't want that constant headlight and would rather light the scene yourself, this behavior can be turned off with SoQtViewer::setHeadlight().)
Every SoQtViewer-derived viewer inherits these keyboard controls from this class (but only when the viewer is in "examinemode", i.e. when SoQtViewer::isViewing() returns TRUE):
"s": puts the viewer into "seek mode", where the end user can click anywhere on scene geometry to trigger an animation that moves the camera towards the point that got clicked ๐ฏ"Home": hit this key to move the camera back to the last saved "homeposition"- arrow keys: moves the camera slightly left, right, up or down
"q": exits the application, bye bestie ๐ญ
๐ Member Enumeration Documentation ๐
๐ซ enum SoQtViewer::Type ๐ซ
These are hints about what context the viewer will be used in. Usually not very interesting for the application programmer โ honestly it doesn't matter much which value you use for the viewer type. This "feature" of the viewer is included just to be compatible with the old SGI Inventor API. Legacy behavior, we respect it ๐ซก
BROWSERโ if a user-supplied scene graph passed into thesetSceneGraph()function does not contain a camera, setting the viewer type toBROWSERwill 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 scene graph passed into thesetSceneGraph()function does not contain a camera, setting the viewer type toEDITORwill make the viewer, in that case, automatically set up a camera in the user-supplied scene.
So basically: if you want to avoid having the SoQtViewer class muck about with your supplied scene graph, set the type-flag to SoQtViewer::BROWSER instead โ that makes the inserted camera node go into the viewer's own "wrapper" scene graph instead. Protect your scene, bestie ๐ก๏ธ
๐ฆ enum SoQtViewer::DrawStyle ๐ฆ
Decides the draw style for a scene, whether it's got a still camera or an animating camera.
See also: SoQtViewer::setDrawStyle(), SoQtViewer::DrawType
VIEW_AS_ISโ normal rendering, draws all scene geometry in its original style. The default vibe โจVIEW_HIDDEN_LINEโ draws the scene in "hidden line" mode: that is, as wireframe with no "see-through".
Ngl this is actually an expensive way to render, because the scene must be rendered twice to achieve the effect of hiding lines behind the invisible geometry. Paying double for that look ๐
VIEW_NO_TEXTUREโ renders the scene without textures. Stripped down, no filter.VIEW_LOW_COMPLEXITYโ renders all "complex" shape types with low complexity to improve rendering performance.
"Complex shapes" in this context includes spheres, cones, cylinder, NURBS surfaces, and others which get tessellated to polygons before being rendered.
VIEW_LINEโ views all polygon geometry in wireframe mode.VIEW_POINTโ renders only the vertex positions of the geometry.VIEW_BBOXโ views 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. Big brain move ๐ง
VIEW_LOW_RES_LINEโ renders as wireframe and doesn't bother with getting them rendered correctly in depth. Chaotic, honestly.VIEW_LOW_RES_POINTโ renders as vertex points and doesn't bother with getting them rendered correctly in depth. Same energy.VIEW_SAME_AS_STILLโ always renders a scene with an animating camera (i.e.SoQtViewer::INTERACTIVEDrawType) in the same manner as a scene with a still camera.VIEW_WIREFRAME_OVERLAYโ renders the scene as normal, but overlays a set of lines showing the contours of all polygons. Contour couture ๐
๐ธ enum SoQtViewer::DrawType ๐ธ
Contains the valid values for the first argument to the SoQtViewer::setDrawStyle() call. Decides the effect of the second argument.
See also: SoQtViewer::setDrawStyle(), SoQtViewer::DrawStyle
STILLโ if this value is passed as the first argument ofSoQtViewer::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 ofSoQtViewer::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::BufferType ๐
The set of valid values for SoQtViewer::setBufferingType().
BUFFER_SINGLEโ changes the underlying OpenGL canvas to be single buffered.BUFFER_DOUBLEโ changes the underlying OpenGL canvas to be double buffered.BUFFER_INTERACTIVEโ sets things 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, because the rendering will visibly progress, and you 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. No more staring at a frozen screen wondering if it crashed ๐
๐ง enum SoQtViewer::AutoClippingStrategy ๐ง
The enum for auto clipping strategy.
See also: setAutoClippingStrategy()
VARIABLE_NEAR_PLANEโ variable near plane auto clipping strategy. Explained in detail in the documentation for theSoQtViewer::setAutoClippingStrategy()method.CONSTANT_NEAR_PLANEโ constant near plane auto clipping strategy. Explained in detail in the documentation for theSoQtViewer::setAutoClippingStrategy()method.
๐ enum SoQtViewer::StereoType ๐
Contains the list of supported stereo rendering techniques.
See also: SoQtViewer::setStereoType()
STEREO_NONEโ use monoscopic rendering. One (1) image, we keep it simple.STEREO_ANAGLYPHโ renders 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 that works on any display, using color-filter glasses. Those glasses are usually cheap and easy to come by โ iconic budget queen ๐ธ
See also: setAnaglyphStereoColorMasks()
STEREO_QUADBUFFERโ renders 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. Fancy โจ
STEREO_INTERLEAVED_ROWSโ interleaving / interlacing rows from the left and right eye is another stereo rendering method that requires special hardware. One example of a provider of shutter glasses working with interleaved glasses is VRex:
STEREO_INTERLEAVED_COLUMNSโ basically the same technique asSoQtViewer::STEREO_INTERLEAVED_ROWS, but vertical lines are interleaved / interlaced, instead of horizontal lines. Rotated, but make it fashion ๐
๐ Constructor & Destructor Documentation ๐
SoQtViewer::SoQtViewer โ the constructor, aka where it all begins โจ
SoQtViewer::SoQtViewer (QWidget * parent, const char * name, SbBool embed,
SoQtViewer::Type t, SbBool build) [protected]
Bestie, this is the constructor ๐
. The parent, name and embed args get passed straight on to SoQtRenderArea, so if you want the tea on those, go read the docs for our parent constructor โ it's all there, no gatekeeping.
The t type setting is basically a hint about what context the viewer is gonna be used in. Usually it's not very interesting for the application programmer (ngl, most of y'all can ignore it), but โ and this is the important bit โ if you want to make absolutely sure the SoQtViewer class doesn't muck about with your supplied scene graph, you set the type-flag to SoQtViewer::BROWSER. That whole "feature" of the viewer is in there just to be compatible with the old SGI Inventor API, so it's giving legacy-icon energy ๐ซถ.
The build flag decides whether or not to delay building the widgets / window that's going to make up the components of the viewer. Your call, main character ๐ซก.
SoQtViewer::~SoQtViewer โ the destructor ๐ฆ
SoQtViewer::~SoQtViewer () [protected]
Destructor. It's the end of an era, the closing of a chapter, theโฆ yeah it just tears the thing down ๐.
๐ Member Function Documentation ๐
setCamera โ tell the viewer which camera to play with ๐ฅ
void SoQtViewer::setCamera (SoCamera * cam) [virtual]
Okay so this is the one that sets the camera we want the viewer to manipulate when you're interacting with the viewer controls ๐ฎ.
Here's the part people get wrong every single time, so pay attention bestie: the camera you pass in as an argument to this method must already be part of the viewer's scene graph. You do not inject viewpoint cameras to the viewer with this method. Periodt. ๐ซ
What you actually do is: insert a camera into the scene graph first (if necessary โ and often one will be present already, so vibe check your graph first), then register it as the camera used by the viewer controls with this method. Order matters, iykyk.
And if your application code doesn't explicitly set up a camera through this method? The viewer will automatically scan through the scene graph to find a camera to use ๐. And if there's no camera available in the scene graph at all, it'll set up its own camera. Self-sufficient king behavior ๐.
See also: getCamera()
Reimplemented in: SoQtConstrainedViewer, SoQtExaminerViewer, SoQtFlyViewer, and SoQtPlaneViewer.
getCamera โ which camera are we on rn? ๐ธ
SoCamera * SoQtViewer::getCamera (void ) const
Returns the camera currently used by the viewer for the user's main viewpoint ๐ซ.
Plot twist: it is possible that this function returns NULL, for instance if there's no scene graph present in the viewer. (This is mostly a note for developers extending the SoQt library, because application programmers usually control if and when a viewer contains a scene graph, and therefore know in advance whether this method will return a valid camera pointer. So likeโฆ you already know, babe ๐.)
See also: setCamera()
setCameraType โ what kind of camera should we spawn? ๐ฌ
void SoQtViewer::setCameraType (SoType t) [virtual]
So when the viewer has to make its own camera โ which happens as a result of the graph passed to setSceneGraph() not containing any camera nodes โ you can make this call in advance to decide which type the camera will be of. Pre-planning, we love to see it โจ.
Default is to use an SoPerspectiveCamera.
And here's the spicy bit: if you call this method when there's a scene graph and a camera already set up, it will delete the old camera and set up a camera with the new type โ but only if the t type is different from that of the current camera. No unnecessary drama, no cap ๐
.
See also: getCameraType()
Reimplemented in: SoQtFlyViewer.
getCameraType โ what camera type would we use? ๐ฎ
SoType SoQtViewer::getCameraType (void ) const
Returns the camera type which will be used when the viewer has to make its own camera.
โ ๏ธ Heads up: this call does not return the current camera type, as one might expect. I know, I know, it's giving trick question ๐ญ. Use getCamera() and SoType::getTypeId() for that inquiry instead.
See also: setCameraType()
toggleCameraType โ perspective โ orthographic, the flip ๐ฆ
void SoQtViewer::toggleCameraType (void ) [virtual]
If the current camera is of perspective type, switch to orthographic, and vice versa. One click, two vibes, iconic behavior ๐.
It automatically calls SoQtViewer::setCameraType() so the change will immediately take place โ no waiting, no loading screen, instant slay โจ.
viewAll โ see the whole scene, bestie ๐
void SoQtViewer::viewAll (void ) [virtual]
Reposition the current camera so we can see the complete scene. That's it, that's the whole function. Zoom out, take it all in, main character framing ๐.
Reimplemented in: SoQtFlyViewer.
saveHomePosition โ bookmark this camera moment ๐
void SoQtViewer::saveHomePosition (void ) [virtual]
Store the current camera settings for later retrieval with resetToHomePosition(). It's a save point, bestie. A little screenshot of your camera's soul ๐ซถ.
See also: resetToHomePosition()
Reimplemented in: SoQtConstrainedViewer.
resetToHomePosition โ go back to the vibe you saved ๐
void SoQtViewer::resetToHomePosition (void ) [virtual]
Restore the saved camera settings. Your "take me back" button, no cap ๐.
See also: saveHomePosition()
Reimplemented in: SoQtConstrainedViewer, and SoQtFlyViewer.
setHeadlight โ the light that follows the camera ๐ก
void SoQtViewer::setHeadlight (SbBool on) [virtual]
Turn the camera headlight on or off โ the classic on/off situation, we love a binary ๐ฅ.
Default is to have a headlight turned on. So yes, there's light on you by default, you're literally glowing โจ.
See also: isHeadlight(), getHeadlight()
isHeadlight โ is the headlight on? ๐ฏ๏ธ
SbBool SoQtViewer::isHeadlight (void ) const
Returns the status of the viewer headlight, whether it is on or off. Short king of a function, does exactly one thing ๐.
See also: setHeadlight(), getHeadlight()
getHeadlight โ hand me the actual light node ๐ชฉ
SoDirectionalLight * SoQtViewer::getHeadlight (void ) const
Returns a pointer to the directional light node which is the viewer headlight ๐ก. And the best part? The fields of the node are available for user editing โ go ahead and customize it, it's yours now, make it your whole aesthetic ๐จ.
See also: isHeadlight(), setHeadlight()
setDrawStyle โ how do we draw this thing? ๐๏ธ
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 draw style during animation or when the camera is static โ so you get to choose two separate lewks, one for the moving era and one for the still era ๐
.
Default values for the drawing style is to render the scene "as is" in both still mode and while the camera is moving. No filters, no edits, raw and unfiltered โจ.
See the documentation for the DrawType and DrawStyle for more information โ they've got the full rundown.
See also: getDrawStyle()
getDrawStyle โ what's the current lewk? ๐
SoQtViewer::DrawStyle SoQtViewer::getDrawStyle (const SoQtViewer::DrawType
type) const
Return current draw styles for the given type (STILL or INTERACTIVE). Two moods, two answers โ you gotta tell me which one you're asking about ๐ญ.
See also: setDrawStyle()
setBufferingType โ single, double, or interactive? ๐๏ธ
void SoQtViewer::setBufferingType (SoQtViewer::BufferType type) [virtual]
Set the viewer's buffer type. The available types are:
SoQtViewer::BUFFER_SINGLESoQtViewer::BUFFER_DOUBLESoQtViewer::BUFFER_INTERACTIVE
(With a buffer type of SoQtViewer::BUFFER_INTERACTIVE, the viewer will render with double buffering during user interaction and with single buffering otherwise โ it's literally switching outfits based on the occasion ๐.)
Default is SoQtViewer::BUFFER_DOUBLE. Double the buffer, double the slay ๐ซถ.
See also: getBufferingType()
getBufferingType โ which buffer are we on? ๐ฆ
SoQtViewer::BufferType SoQtViewer::getBufferingType (void ) const
Return the viewer's buffer type. Quick little status check, in and out, no drama โจ.
See also: setBufferingType()
setViewing โ view mode on or off ๐ฎ
void SoQtViewer::setViewing (SbBool enable) [virtual]
Set view mode. Okay so here's the vibe breakdown:
- If view mode is on, user events will be caught and used to influence the camera position / orientation. You're driving the camera, bestie ๐๏ธ.
- If view mode is off, all events in the viewer canvas (like for instance keypresses or mouse clicks and -movements) will be passed along to the scene graph. The camera is hands-off โ the scene graph takes the wheel ๐.
Default is to have the view mode active. You're in control by default, as you should be ๐.
See also: isViewing()
Reimplemented in: SoQtExaminerViewer, SoQtFlyViewer, SoQtFullViewer, and SoQtPlaneViewer.
isViewing โ are we in view mode? ๐ง
SbBool SoQtViewer::isViewing (void ) const
Return 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. So TRUE = you're the one moving the camera with the mouse, iconic ๐
.
See also: setViewing()
setCursorEnabled โ should the cursor show up? ๐ฑ๏ธ
void SoQtViewer::setCursorEnabled (SbBool on) [virtual]
Set whether or not the mouse cursor representation should be visible in the viewer canvas. Yes, the cursor can simply not be there, it's giving invisible era ๐.
Default value is on. Cursor present, cursor thriving โจ.
See also: isCursorEnabled()
Reimplemented in: SoQtExaminerViewer, SoQtFlyViewer, and SoQtPlaneViewer.
isCursorEnabled โ is the cursor visible? ๐๏ธ
SbBool SoQtViewer::isCursorEnabled (void ) const
Returns visibility status of mouse cursor. Present or not present, that is the question ๐ญ.
See also: setCursorEnabled()
setAutoClipping โ the automatic clipping plane situation โ๏ธ
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, because 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. Lousy utilization! We don't do lousy here ๐.
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. That's your fine-tuning era ๐ง.
โ ๏ธ 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 anSoGetBoundingBoxActionto traverse the scene graph, which causes bounding boxes to be calculated and stored in caches. The bounding box caches are then used by theSoGLRenderActiontraversal 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. Proceed and ignore, bestie ๐ซถ.
See also: getAutoClipping()
isAutoClipping โ is auto clipping on? ๐
SbBool SoQtViewer::isAutoClipping (void ) const
Return value of the automatic near/far clip plane adjustment indicator. Basically: is auto clipping a thing rn or nah ๐ .
See also: setAutoClipping()
setAutoClippingStrategy โ fine-tune the auto clipping vibes โ๏ธ
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. But 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:
VARIABLE_NEAR_PLANEโ this strategy considers the number of z buffer bits available for the current OpenGL context, and usesvalueto calculate the number of bits that is lost because of the far/near ratio.valueshould 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. Trade-offs, always trade-offs ๐ญ.CONSTANT_NEAR_PLANEโ this strategy simply sets the near plane tovalue. Ifvalueat some point approaches the far clipping plane distance, the near plane distance will be set to far plane distance divided by5000.0. Catch that safety net ๐ธ๏ธ.
The default strategy is VARIABLE_NEAR_PLANE โจ.
So here's the โจextraโจ layer, bestie: you can also register a callback method cb, and it gets invoked after the near and far clipping planes have been calculated by the SoQtViewer code. Then your callback can adjust the values for the distance to the near and far planes so they exactly match what the application actually needs (like, at specific parts in the scene, you know?), or 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);
First argument is the cbuserdata passed in along with the callback function pointer itself (i.e. the callback function's closure, iykyk). Second argument is the near and far clipping plane distances from the camera position, as calculated internally by the viewer โ including "slack". ๐
Then the function callback can modify the near and far clipping plane distances to whatever will actually be used by the viewer. And these values will then be used unmodified for the viewer's camera. Fr fr. No cap.
This is a genuinely good way of dynamically modifying the near and far distances so they at all times exactly match 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()
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. (She's iconic but she's aging, okay?)
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()
SbBool SoQtViewer::isStereoViewing (void ) const
Returns a boolean indicating whether or not we're in stereo viewing mode. Simple as that. ๐ซ
NOTE: in the original InventorXt API, this method was virtual. It is not virtual here.
See also: setStereoViewing(), 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()
float SoQtViewer::getStereoOffset (void ) const
Return 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 preferred that one uses this function for control of which type of stereo rendering to use, instead of the olderSoQtViewer::setStereoViewing()andSoQtGLWidget::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
SoQtViewer::StereoType SoQtViewer::getStereoType (void ) const
Returns 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. ๐ถ๏ธ
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()
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 ) const
Returns 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 ) const
Returns 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()
void SoQtViewer::addFinishCallback (SoQtViewerCB * func, void * data = NULL)
Add a function to call when user interaction with the scene ends. ๐
See also: removeFinishCallback(), addStartCallback()
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()
const SbColor & SoQtViewer::getWireframeOverlayColor (void ) const
Returns the current color of the overlay wireframe. The default color is [1,0,0], i.e. 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.
void SoQtViewer::setSceneGraph (SoNode * root) โ [virtual]
Give the viewer a scene graph to render and interact with. Overridden from parent class so the viewer can add its 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.
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 its 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.
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.
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 mouse button.)
See also: 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.
void SoQtViewer::seekToPoint (const SbVec3f & scenepos) โ [protected]
Call this method to initiate a seek action towards the given 3D world coordinate point in the scene, scenepos. ๐
Since: SoQt 1.3.0
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.
void SoQtViewer::actualRedraw (void ) โ [protected], [virtual]
This method instantly redraws the normal (non-overlay) scene graph by calling SoSceneManager::render(). ๐๏ธ
Subclasses may override this method to add their own rendering before or after Coin renders its scene graph.
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.
// *************************************************************************
Okay bestie, last stretch โ here's the rest of the page, and it opens with a full-on worked example, which is honestly iconic of it. ๐
Here's a complete little program that shows off the actualRedraw() override: it paints a background image behind your scene and an overlaid arrow indicator in front of it. Read it top to bottom, it's all there:
#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 scene graph 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, overlaid scene graph.
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 scene graph with the image.
SoGLRenderAction * glra = this->getGLRenderAction();
glra->apply(this->bckgroundroot);
// Render normal scene graph.
SoQtExaminerViewer::actualRedraw();
// Increase arrow angle with 1/1000 degrees every frame.
arrowrotation->angle = arrowrotation->angle.getValue() + (0.001 / M_PI * 180);
// Render overlay front scene graph.
glClear(GL_DEPTH_BUFFER_BIT);
glra->apply(this->foregroundroot);
}
// *************************************************************************
int
main(int argc, char ** argv)
{
if (argc != 2) {
(void)fprintf(stderr, "\n\n\tUsage: %s <image-filename>\n\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;
}
// *************************************************************************
Lowkey obsessed with that demo ngl. ๐ฆ
Heads up: right before the next function, the page drops the note that the function above it is Reimplemented fromSoQtRenderAreaand Reimplemented inSoQtExaminerViewer,SoQtFlyViewer, andSoQtPlaneViewer. Keep that in mind, bestie โ inheritance be like that.
SbBool SoQtViewer::processSoEvent(const SoEvent *const event)[protected], [virtual] โ so here's the tea: toolkit-native events get scooped up and converted into Coin-generic events over in theSoQtRenderArea::processEvent()method, and if that conversion goes through, they land here. โจ This is a virtual method, and its subclasses override it to catch events that are actually interesting to the viewer classes โ you know the vibe. ReturnTRUEif the event was processed. If it wasn't processed, it should get passed on further up the inheritance hierarchy by whoever called you. This last point is extremely important to take note of if you're expanding the toolkit with your own viewer class โ genuinely, don't skip it. ๐ This method is not part of the original SGI InventorXt API. Note that you can still override the toolkit-nativeprocessEvent()method instead of this "generic" one. iykyk. Reimplemented fromSoQtRenderArea. Reimplemented inSoQtExaminerViewer,SoQtFlyViewer,SoQtFullViewer, andSoQtPlaneViewer.void SoQtViewer::interactiveCountInc(void)[protected] โ okay so to be able to trigger callback functions when user interaction starts and/or stops, we gotta keep track of the viewer state (i.e. are we in still mode or in animation mode?). ๐SoQtViewerautomatically adds callbacks to switch between still and moving draw style, and to switch between single/double buffer when the buffer type isINTERACTIVE. Slay. See also:interactiveCountDec(),getInteractiveCount()addStartCallback(),addFinishCallback()removeStartCallback(),removeFinishCallback()setDrawStyle(),setBufferingType()
void SoQtViewer::interactiveCountDec(void)[protected] โ literally the exact same lore as above, just the decrement side of things: 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?). ๐SoQtViewerautomatically adds callbacks to switch between still and moving draw style, and to switch between single/double buffer when the buffer type isINTERACTIVE. See also:interactiveCountInc(),getInteractiveCount()addStartCallback(),addFinishCallback()removeStartCallback(),removeFinishCallback()setDrawStyle(),setBufferingType()
int SoQtViewer::getInteractiveCount(void) const[protected] โ returns the current interaction count nesting. If it's 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] โ sets the value used for calculating how close the camera and the intersection hit point should be made at the end of a seek operation. ๐ฏ That value can be read 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. You control which via thesetSeekValueAsPercentage()method. By default it's used as an absolute value. Default value is50(absolute distance or percent). See also:getSeekDistance(),setSeekValueAsPercentage(),setSeekTime()
float SoQtViewer::getSeekDistance(void) const[protected] โ returns the current seek distance. The value comes back as an absolute scalar length or as a percentage value of the original distance between the hit point and the camera starting position. ๐ง See also:setSeekDistance(),isSeekValueAsPercentage()
void SoQtViewer::setSeekValueAsPercentage(const SbBool on)[protected] โ controls whether or not the seek distance value should be interpreted as a percentage value or as an absolute distance. Peep the docs onsetSeekDistance()for more info. ๐ธ See also:setSeekDistance(),isSeekValueAsPercentage()
SbBool SoQtViewer::isSeekValuePercentage(void) const[protected] โ returns a boolean that indicates if the seek distance value fromgetSeekDistance()should be interpreted as a percentage value or as an absolute value. ๐ See also:setSeekValuePercentage(),getSeekDistance()
void SoQtViewer::changeCameraValues(SoCamera * camera)[protected], [virtual] โ copies the settings of camera into our current camera. Fr fr, the cameras must be of the same class type โ no mixing, bestie. ๐ซถ Reimplemented inSoQtConstrainedViewer.void SoQtViewer::addSuperimposition(SoNode * scene)[protected] โ this one is for setting up a superimposed scene graph on top of the viewer scene graph. It'll 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] โ (the page gives no extra description here, just the vibes) 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. ๐ This method is not part of the original InventorXt API.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. (Not me โ Doxygen did that. Respect tho.) ๐ซก
And that's a wrap on SoQtViewer(3), bestie โ ๐ this page is Version 1.6.2, dated Sat Jan 6 2024 12:20:55, lovingly spat out by Doxygen straight from the SoQt source code. Go forth and superimpose responsibly. ๐โจ๐
๐ฆ where this page comes from
- opensuse-leap 16.0: SoQt-devel 1.6.2-bp160.1.13 ยท BSD-3-Clause
- opensuse-leap 16.0: SoQt-devel 1.6.2-bp160.1.13 ยท BSD-3-Clause
- opensuse-leap 16.0: SoQt-devel 1.6.2-bp160.1.13 ยท BSD-3-Clause
- opensuse-leap 16.0: SoQt-devel 1.6.2-bp160.1.13 ยท BSD-3-Clause
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms