00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef _SO_QT_RENDERAREA_
00028 #define _SO_QT_RENDERAREA_
00029
00030 #include <QtOpenGL/QGLColormap>
00031
00032 #include <Inventor/Qt/OivQtCompat.h>
00033 #include <Inventor/Qt/SoQtGLWidget.h>
00034
00035 #include <Inventor/SbColor.h>
00036 #include <Inventor/SoSceneManager.h>
00037 #include <Inventor/actions/SoGLRenderAction.h>
00038 #include <Inventor/nodes/SoCamera.h>
00039 #include <Inventor/SbElapsedTime.h>
00040
00041 #include <Inventor/Gui/SoGuiRenderArea.h>
00042
00043 class SoSelection;
00044 class SoQtDevice;
00045 class SoNode;
00046 class SoQtMouse;
00047 class SoQtKeyboard;
00048 class SoQtRenderArea;
00049 class SoGuiAlgoViewers;
00050 class SoTimerSensor;
00051 class SoAntialiasingParameters;
00052
00056 typedef SbBool SoQtRenderAreaEventCB( void* userData, QEvent* anyevent );
00057
00061 typedef SbBool SoQtRenderAreaRenderCB( void* userData, SoQtRenderArea* rendArea );
00062
00101 class SoQtRenderArea : public SoQtGLWidget
00102 {
00103 Q_OBJECT
00104
00105 public:
00110 SoQtRenderArea( QWidget* parent = NULL,
00111 const char* name = NULL,
00112 SbBool buildInsideParent = TRUE,
00113 SbBool getMouseInput = TRUE,
00114 SbBool getKeyboardInput = TRUE );
00118 ~SoQtRenderArea();
00119
00123 virtual void setSceneGraph( SoNode* newScene );
00124
00128 virtual SoNode* getSceneGraph();
00129
00135 void registerDevice( SoQtDevice* d );
00136
00142 void unregisterDevice( SoQtDevice* d );
00143
00151 void setBackgroundColor( const SbColor& c );
00152
00156 SbColor getBackgroundColor() const { return m_guiRenderArea->getBackgroundColor(); }
00157
00162 void setBackgroundIndex( int index ) { m_guiRenderArea->setBackgroundIndex( index ); }
00163
00167 int getBackgroundIndex() const { return m_guiRenderArea->getBackgroundIndex(); }
00168
00173 void setColorMap( QGLColormap* cmap );
00174
00178 void setViewportRegion( const SbViewportRegion& newRegion )
00179 { m_guiRenderArea->setViewportRegion( newRegion ); }
00180
00184 const SbViewportRegion &getViewportRegion() const
00185 { return m_guiRenderArea->getViewportRegion(); }
00186
00196 void setTransparencyType( SoGLRenderAction::TransparencyType type );
00197
00202 SoGLRenderAction::TransparencyType getTransparencyType() const
00203 { return m_guiRenderArea->getTransparencyType(); }
00204
00213 void setFastEditSavePolicy( SoGLRenderAction::FastEditSavePolicy policy,
00214 SbBool fastEditDelayedObjects = FALSE);
00215
00219 SoGLRenderAction::FastEditSavePolicy getFastEditSavePolicy() const
00220 { return m_guiRenderArea->getFastEditSavePolicy(); }
00221
00237 void setInvalidateCacheMode( SoGLRenderAction::InvalidateCacheMode icm );
00238
00242 SoGLRenderAction::InvalidateCacheMode getInvalidateCacheMode();
00243
00251 void setClearBeforeRender( SbBool trueOrFalse, SbBool zbTrueOrFalse = TRUE )
00252 { m_guiRenderArea->setClearBeforeRender( trueOrFalse, zbTrueOrFalse ); }
00253
00257 SbBool isClearBeforeRender() const { return m_guiRenderArea->isClearBeforeRender(); }
00258
00263 SbBool isClearZBufferBeforeRender() const { return m_guiRenderArea->isClearZBufferBeforeRender(); }
00264
00272 void setAutoRedraw( SbBool trueOrFalse );
00273
00278 SbBool isAutoRedraw() const { return m_guiRenderArea->isAutoRedraw(); }
00279
00283 void setRedrawPriority( uint32_t priority ) { m_guiRenderArea->setRedrawPriority( priority ); }
00284
00288 uint32_t getRedrawPriority() const { return m_guiRenderArea->getRedrawPriority(); }
00289
00293 static uint32_t getDefaultRedrawPriority() { return SoSceneManager::getDefaultRedrawPriority(); }
00294
00299 void render() { redraw(); }
00300
00305 void scheduleRedraw();
00306
00317 void redrawOnSelectionChange( SoSelection* s );
00318
00330 void setEventCallback( SoQtRenderAreaEventCB *fcn, void* userData = NULL );
00331
00338 void setSceneManager( SoSceneManager* sm );
00339
00346 SoSceneManager* getSceneManager() const { return m_guiRenderArea->getSceneManager(); }
00347
00357 void setGLRenderAction( SoGLRenderAction* ra );
00358
00362 SoGLRenderAction* getGLRenderAction() const { return m_guiRenderArea->getGLRenderAction(); }
00363
00368 const SbGLShareContext getShareContext();
00369
00385 void setPostRenderCallback( SoQtRenderAreaRenderCB *fcn, void* userData = NULL )
00386 { appPostRenderCB = fcn; appPostRenderData = userData; }
00387
00392 SoQtRenderAreaRenderCB *getPostRenderCallback( const void* &userData ) const
00393 { userData = appPostRenderData; return appPostRenderCB; }
00394
00408 void setFloatingColorBuffer( SbBool enable,
00409 FloatColorBufferSize size = FLOAT_16_COLOR_BUFFER );
00410
00414 void getFloatingColorBuffer( SbBool& enable, FloatColorBufferSize& size );
00415
00419 static SbBool isFloatingColorBufferSupported();
00420
00424 void sendEvent( QEvent* anEvent );
00425
00431 virtual void setMPEGRecorder( SoMPEGRenderer* recorder )
00432 { m_guiRenderArea->setMPEGRecorder( recorder ); }
00433
00437 virtual SoMPEGRenderer* getMPEGRecorder() const
00438 { return m_guiRenderArea->getMPEGRecorder(); }
00439
00440 private:
00441 SoQtRenderArea( QWidget* parent,
00442 const char* name,
00443 SbBool buildInsideParent,
00444 SbBool getMouseInput,
00445 SbBool getKeyboardInput,
00446 SoGuiAlgoViewers* guiAlgos );
00447
00448 SoQtRenderArea( QWidget* parent,
00449 const char* name,
00450 SbBool buildInsideParent,
00451 SbBool getMouseInput,
00452 SbBool getKeyboardInput,
00453 SbBool buildNow,
00454 SbBool sync,
00455 SoGuiAlgoViewers* guiAlgos );
00456
00457 SoQtRenderArea( QWidget* parent,
00458 const char* name,
00459 SbBool buildInsideParent,
00460 SbBool getMouseInput,
00461 SbBool getKeyboardInput,
00462 SbBool buildNow,
00463 SoGuiAlgoViewers* guiAlgos );
00464
00468 SoGuiAlgoViewers* getGuiAlgoViewers() const { return (SoGuiAlgoViewers*)m_guiRenderArea; }
00469
00470 private:
00471 SoGuiRenderArea* getGuiRenderArea() const;
00472
00473 void setStereoMode( SoCamera::StereoMode stMode );
00474 void setStereoElement();
00475 virtual SbBool isInteractive() const;
00476 void redrawCleanUp();
00477
00478 SoQtRenderArea( QWidget* parent,
00479 const char* name,
00480 SbBool buildInsideParent,
00481 SbBool getMouseInput,
00482 SbBool getKeyboardInput,
00483 SbBool buildNow,
00484 SbBool sync );
00485
00486
00487 float stereoBalance, stereoOffset;
00488 SbBool stereoAbsoluteAdjustments;
00489 SoCamera::StereoMode stereoMode;
00490 SbBool stereoReversed;
00491
00492 private:
00493
00494
00495
00496
00497
00498
00499 SoQtRenderArea( QWidget* parent,
00500 const char* name,
00501 SbBool buildInsideParent,
00502 SbBool getMouseInput,
00503 SbBool getKeyboardInput,
00504 SbBool buildNow );
00505
00506
00507
00508 SoQtRenderArea( QWidget* parent,
00509 const char* name,
00510 SbBool buildInsideParent,
00511 SbBool getMouseInput,
00512 SbBool getKeyboardInput,
00513 SoGuiRenderArea* guiRenderArea );
00514
00515 SoQtRenderArea( QWidget* parent,
00516 const char* name,
00517 SbBool buildInsideParent,
00518 SbBool getMouseInput,
00519 SbBool getKeyboardInput,
00520 SbBool buildNow,
00521 SbBool sync,
00522 SoGuiRenderArea* guiRenderArea );
00523
00524 SoQtRenderArea( QWidget* parent,
00525 const char* name,
00526 SbBool buildInsideParent,
00527 SbBool getMouseInput,
00528 SbBool getKeyboardInput,
00529 SbBool buildNow,
00530 SoGuiRenderArea* guiRenderArea );
00531
00532
00533
00534
00535
00536
00537
00538
00539 virtual void redraw();
00540 virtual void actualRedraw();
00541
00542
00543
00544
00545 virtual void processEvent( QEvent* anyevent );
00546 virtual void initGraphic();
00547 virtual void sizeChanged( const SbVec2s& );
00548 virtual void posChanged( const SbVec2i32&, const SbVec2i32& );
00549 virtual void widgetChanged( QWidget* w );
00550
00551 QWidget* buildWidget(QWidget* parent);
00552
00553
00554 virtual SbString getDefaultWidgetName() const;
00555 virtual SbString getDefaultTitle() const;
00556 virtual SbString getDefaultIconTitle() const;
00557
00558
00559 SbPList* m_deviceList;
00560
00561
00562 static void renderCB( void* v, SoSceneManager* sm );
00563
00564
00565 SoQtRenderAreaEventCB *defaultAppEventHandler;
00566 void *defaultAppEventHandlerData;
00567 SoQtRenderAreaEventCB *appEventHandler;
00568 void *appEventHandlerData;
00569
00570
00571 SbBool invokeAppCB( QEvent* anyevent );
00572 SbBool processInventorEvent( QEvent* anyevent );
00573 const SoEvent* translateAnyEvent( QEvent* anyevent );
00574
00575
00576 SoQtRenderAreaRenderCB *appPostRenderCB;
00577 void *appPostRenderData;
00578
00579
00580 SbBool m_isFloatingPointRendering;
00581 FloatColorBufferSize m_floatingPointRenderingPrecision;
00582
00583
00584 void onFocusEvent(SbBool hasFocus);
00585
00586 private:
00587
00588
00589 #if defined(__linux__)
00590 XColorPointer m_mapColors;
00591 int m_mapColorNum;
00592 #endif
00593
00594 SoQtMouse* m_mouseDevice;
00595 SoQtKeyboard* m_keybdDevice;
00596 void reinstallDevices( QWidget* newWidget );
00597
00598 static void selectionChangeCB( void* userData, SoSelection* s );
00599 QWidget* m_deviceWidget;
00600
00601 SbBool m_firstEvent;
00602
00603 void activate();
00604 void deactivate();
00605
00606
00607 void constructorCommon( SbBool getMouseInput,
00608 SbBool getKeyboardInput,
00609 SbBool buildNow );
00610
00611 void constructorCommon2( SbBool getMouseInput,
00612 SbBool getKeyboardInput,
00613 SbBool buildNow );
00614
00615 SbVec2i32 getWindowPosition();
00616
00617 QPoint m_oldPos;
00618 QSize m_oldSize;
00619 QSize m_minimumSize;
00620 QSize m_maximumSize;
00621
00622 SoGuiRenderArea* m_guiRenderArea;
00623
00624
00625
00626
00627
00628 static SbBool s_abortRenderCallback(SoAction*,void*);
00629
00630 bool m_firstStdRedraw;
00631 bool m_firstConnectedRedraw;
00632 SoTimerSensor* m_viewerUpdaterSensor;
00633 static void viewerUpdaterCB( void*, SoSensor* );
00634 void updateFirstFrame();
00635
00636 SoAntialiasingParameters* m_accumulationParameters;
00637
00638 private Q_SLOTS:
00639 void visibilityChangeCB( SbBool visible );
00640
00641 };
00642
00643
00644 #endif // _SO_QT_RENDERAREA_
00645
00646
00647