00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef SO_WX_GLWIDGET
00025 #define SO_WX_GLWIDGET
00026
00028
00029
00030
00032
00033 #include <Inventor/Wx/SoWxComponent.h>
00034 #include <Inventor/Wx/SoWxGLX.h>
00035
00036 #include <Inventor/nodes/SoFullSceneAntialiasing.h>
00037
00038 #include <Inventor/Gui/SoGuiGLWidget.h>
00039
00040 #define MGRWIDGET_ID 101
00041 #define ATTRIBLIST_END 0
00042 #define NO_OP -1 // Used in the attribute list passed to the wxGLCanvas as a noop.
00043
00044 typedef std::set<int, std::less<int> > SoSamplesList;
00045
00068 class SoGuiGLWidget;
00069 class SoWxGLX;
00070 class SoGLContext;
00071
00072 class SoWxGLWidget : public SoWxComponent
00073 {
00074 public:
00075
00077 enum FloatColorBufferSize
00078 {
00082 FLOAT_16_COLOR_BUFFER = SoGuiGLWidget::FLOAT_16_COLOR_BUFFER,
00086 FLOAT_32_COLOR_BUFFER = SoGuiGLWidget::FLOAT_32_COLOR_BUFFER
00087 };
00088
00092 int getColorMapSize();
00093 void setColorMapSize( int size );
00094
00104 virtual wxWindow* getNormalWindow();
00105
00115 wxGLContext* getNormalContext() { return m_wxContextNormal; }
00116
00117 SoGLContext* getNormalSoContext() { return m_contextNormal; }
00118
00125 SoWxGLX* getNormalWidget();
00126
00127 #if 1 SoDEPRECATED
00140 SoWxGLX* getOverlayWidget() { return NULL; }
00141
00142 #if defined(_WIN32)
00143 SoDEPRECATED
00147 Hdc getOverlayDC() { return m_hdcOverlay; }
00148 #endif
00149 #endif
00151 #if defined(_WIN32)
00152
00155 Hdc getNormalDC() { return m_hdcNormal; }
00156 #endif
00157
00169 virtual void setNormalVisual( int* attribList );
00170
00174 int* getNormalVisual();
00175
00179 virtual void show();
00180
00184 virtual void hide();
00185
00189 void setAntialiasing(const float quality, const SoSceneManager::AntialiasingMode mode = SoSceneManager::AUTO);
00190
00194 void setAntialiasing(SoAntialiasingParameters* advancedParameters);
00195
00199 float getAntialiasingQuality() const;
00200
00204 SoSceneManager::AntialiasingMode getAntialiasingMode() const;
00205
00209 SoAntialiasingParameters* getAntialiasingParameters() const;
00210
00216 virtual void setDoubleBuffer( SbBool onOrOff );
00217
00221 SbBool isDoubleBuffer() { return m_guiGLWidget->isDoubleBuffer(); }
00222
00226 void setBorder( SbBool onOrOff );
00227
00231 int getBorderSize() { return m_guiGLWidget->getBorderSize(); }
00232
00236 SbBool isBorder() const { return m_guiGLWidget->isBorder(); }
00237
00242 void setDrawToFrontBufferEnable( SbBool enableFlag );
00243
00247 SbBool isDrawToFrontBufferEnable() const { return m_guiGLWidget->isDrawToFrontBufferEnable(); }
00248
00253 virtual SbBool bindNormalContext();
00254
00258 virtual SbBool unbindNormalContext();
00259
00263 SbBool swapNormalBuffers();
00264
00278 void setFloatingColorBuffer( SbBool enable,
00279 FloatColorBufferSize size = FLOAT_16_COLOR_BUFFER );
00280
00284 void getFloatingColorBuffer( SbBool& enable, FloatColorBufferSize& size );
00285
00288 bool saveSnapshot( const SbString& filename, bool overwrite = true );
00289
00290 #if 1 SoDEPRECATED
00296 SbBool isFsaaSupported();
00297 SoDEPRECATED
00304 SbBool isFullSceneAntialiasingHQAvailable() const;
00305 SoDEPRECATED
00312 SbBool setFullSceneAntialiasingHQ( SbBool enable );
00313 SoDEPRECATED
00318 SbBool isFullSceneAntialiasingHQEnabled() const;
00319 SoDEPRECATED
00324 virtual SbBool makeNormalCurrent();
00325
00326 #endif
00328 #if 1 SoDEPRECATED
00350 SbBool setFullSceneAntialiasing( SbBool enable,
00351 float quality = -1.0,
00352 int filterMask = SoFullSceneAntialiasing::ALL );
00353 SoDEPRECATED
00359 SbBool isFullSceneAntialiasingEnabled() const;
00360 SoDEPRECATED
00365 SbBool getFullSceneAntialiasing( float& quality );
00366 SoDEPRECATED
00371 SbBool isFullSceneAntialiasingAvailable() const;
00372
00373 #endif
00375 private:
00376
00377 SoGuiGLWidget* getGuiGLWidget() const;
00378
00379
00380 SbBool isFsaaSupportHighQuality();
00381 SbBool isFsaaHighQuality();
00382
00383
00384
00385 static SbBool swapNormalBuffersCB(void *data);
00386 static SbBool bindNormalCurrentCB(void *data);
00387 static SbBool unbindNormalCurrentCB(void *data);
00388 static void* getNormalWindowCB(void *data);
00389
00390 private:
00391
00392
00393
00394
00395
00396
00397
00398 void flush();
00399
00400 static void exposeCB( SoWxGLWidget* p );
00401
00402
00403
00404 static void eventHandler( wxWindow* wxW, SoWxGLWidget* w, wxEvent& wxE, bool* boolean );
00405 static void showEventHandler( SoWxGLWidget* w, wxShowEvent& wxE );
00406
00407 #ifdef _WIN32
00408
00409 DWORD getThreadId() { return m_dwThreadId; };
00410 void setThreadId(DWORD id) { m_dwThreadId = id; };
00411 #endif
00412
00419 void setCursor( wxCursor newCursor );
00420
00424 wxCursor getCursor();
00425
00426 private:
00427
00428 SoWxGLWidget( wxWindow* parent = NULL,
00429 const char* name = NULL,
00430 SbBool buildInsideParent = TRUE,
00431 int glModes = SO_GLX_RGB,
00432 SbBool buildNow = TRUE,
00433 SbBool sync = TRUE );
00434
00435 SoWxGLWidget( wxWindow* parent,
00436 const char* name,
00437 SbBool buildInsideParent,
00438 int glModes,
00439 SbBool buildNow,
00440 SbBool sync,
00441 SoGuiGLWidget* guiGLWidget );
00442
00443 virtual ~SoWxGLWidget();
00444
00445
00446
00447
00448
00449 virtual void redraw() = 0;
00450 virtual void processEvent( wxEvent& anyEvent );
00451 virtual void visibilityChangeCB( wxShowEvent& showEvent );
00452
00453
00454
00455
00456
00457
00458 virtual void initGraphic();
00459 virtual void sizeChanged( const SbVec2s& size );
00460 virtual void posChanged( const SbVec2i32&, const SbVec2i32& ) { };
00461 virtual void widgetChanged( wxWindow* w );
00462 virtual void onFocusEvent( SbBool );
00463
00464
00465
00466
00467
00468 void setGlxSize( SbVec2s newSize );
00469 const SbVec2s& getGlxSize() const { return m_guiGLWidget->getGlxSize(); }
00470
00471
00472
00473
00474 void setStereoBuffer( SbBool flag );
00475 SbBool isStereoBuffer() { return (m_guiGLWidget->getGLModes() & SO_GLX_STEREO); }
00476
00477
00478 SbBool isRGBMode() { return (m_guiGLWidget->getGLModes() & SO_GLX_RGB); }
00479
00480
00481 int getDisplayListShareGroup( SoGLContext* ctx );
00482
00483 SbBool waitForExpose;
00484
00485 wxPanel* buildWidget( wxWindow* parent, int* attribList = 0 );
00486 void changeCursor( wxCursor newCursor );
00487 wxPanel* getGlxMgrWidget() { return m_mgrWidget; }
00488
00489 bool eventFilter( wxEvent& anEvent );
00490
00491 virtual void onExpose();
00492
00493 SoINTERNAL private:
00494 SbBool m_initialFsaaEnable;
00495 int m_initialFsaaFilterMask;
00496 SbBool m_initialFsaaValueChanged;
00497 SbBool m_isFsaaEnable;
00498
00499
00500 private:
00501
00502 void constructorCommon( int glModes, SbBool buildNow, SbBool connectionType );
00503 SoGuiGLWidget* m_guiGLWidget;
00504
00505
00506 void keyboardEvents( wxKeyEvent& redirectedEvent );
00507 void moveEvents( wxMoveEvent& redirectedEvent );
00508 void sizeEvents( wxSizeEvent& redirectedEvent );
00509 void showEvents( wxShowEvent& redirectedEvent );
00510
00511
00512 void internalClose( wxCommandEvent& ce );
00513
00514
00515 wxPanel* m_mgrWidget;
00516 SoWxGLX* m_doubleBufferWidget;
00517 SoWxGLX* m_singleBufferWidget;
00518 SoGLContext* m_contextNormal;
00519 SoGLContext* m_contextSingle;
00520 SoGLContext* m_contextDouble;
00521
00522 wxGLContext* m_wxContextNormal;
00523 wxGLContext* m_wxContextSingle;
00524 wxGLContext* m_wxContextDouble;
00525
00526 #if defined(_WIN32)
00527 Hdc m_hdcNormal, m_hdcOverlay, m_hdcSingle, m_hdcDouble;
00528 DWORD m_dwThreadId;
00529 #endif // _WIN32
00530
00531 SbBool m_directConnection;
00532
00533 wxCursor m_currentCursor;
00534 int* m_attribList;
00535 SbBool m_windowResized;
00536
00537
00538 void buildNormalGLXWidget( int* attribList = NULL );
00539
00540 void destroyNormalWindows();
00541 void destroyGLXWidget( SoWxGLX* &w, SoGLContext*& ctx, SbBool normalCall );
00542 void changeGLX();
00543
00544
00545 static void ginitCB( SoWxGLX* w, SoWxGLWidget* p, void* d );
00546 static void resizeCB( wxWindow* w, SoWxGLWidget* p, void* d );
00547
00548
00549 int getNumSamples(size_t n);
00550 int findSampleIndex(int findInt);
00551 void listFSAAMaxSamples();
00552 SoSamplesList m_samplesParseTab;
00553
00554
00555 SbBool m_initGLX;
00556
00557 wxFrame* m_dummyFrame;
00558
00559
00560 DECLARE_EVENT_TABLE()
00561 };
00562
00563
00564 #endif // SO_WX_GLWIDGET
00565
00566