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
00067 class SoGuiGLWidget;
00068 class SoWxGLX;
00069 class SoGLContext;
00070 class SoDEPRECATED SoWxGLWidget : public SoWxComponent
00072 {
00073 public:
00074
00076 enum FloatColorBufferSize
00077 {
00081 FLOAT_16_COLOR_BUFFER = SoGuiGLWidget::FLOAT_16_COLOR_BUFFER,
00085 FLOAT_32_COLOR_BUFFER = SoGuiGLWidget::FLOAT_32_COLOR_BUFFER
00086 };
00087
00091 int getColorMapSize();
00092 void setColorMapSize( int size );
00093
00103 virtual wxWindow* getNormalWindow();
00104
00114 wxGLContext* getNormalContext() { return m_wxContextNormal; }
00115
00116 SoGLContext* getNormalSoContext() { return m_contextNormal.ptr(); }
00117
00124 SoWxGLX* getNormalWidget();
00125
00126 #if defined(_WIN32)
00127
00130 Hdc getNormalDC() { return m_hdcNormal; }
00131 #endif
00132
00144 virtual void setNormalVisual( int* attribList );
00145
00149 int* getNormalVisual();
00150
00154 virtual void show();
00155
00159 virtual void hide();
00160
00164 void setAntialiasing(const float quality, const SoSceneManager::AntialiasingMode mode = SoSceneManager::AUTO);
00165
00169 void setAntialiasing(SoAntialiasingParameters* advancedParameters);
00170
00174 float getAntialiasingQuality() const;
00175
00179 SoSceneManager::AntialiasingMode getAntialiasingMode() const;
00180
00184 SoAntialiasingParameters* getAntialiasingParameters() const;
00185
00191 virtual void setDoubleBuffer( SbBool onOrOff );
00192
00196 SbBool isDoubleBuffer() { return m_guiGLWidget->isDoubleBuffer(); }
00197
00201 void setBorder( SbBool onOrOff );
00202
00206 int getBorderSize() { return m_guiGLWidget->getBorderSize(); }
00207
00211 SbBool isBorder() const { return m_guiGLWidget->isBorder(); }
00212
00217 void setDrawToFrontBufferEnable( SbBool enableFlag );
00218
00222 SbBool isDrawToFrontBufferEnable() const { return m_guiGLWidget->isDrawToFrontBufferEnable(); }
00223
00228 virtual SbBool bindNormalContext();
00229
00233 virtual SbBool unbindNormalContext();
00234
00238 SbBool swapNormalBuffers();
00239
00253 void setFloatingColorBuffer( SbBool enable,
00254 FloatColorBufferSize size = FLOAT_16_COLOR_BUFFER );
00255
00259 void getFloatingColorBuffer( SbBool& enable, FloatColorBufferSize& size );
00260
00263 bool saveSnapshot( const SbString& filename, bool overwrite = true );
00264
00265 #if 1 SoDEPRECATED
00271 SbBool isFsaaSupported();
00272 SoDEPRECATED
00277 SbBool isFullSceneAntialiasingHQAvailable() const;
00278 SoDEPRECATED
00283 SbBool setFullSceneAntialiasingHQ( SbBool enable );
00284 SoDEPRECATED
00289 SbBool isFullSceneAntialiasingHQEnabled() const;
00290 SoDEPRECATED
00295 virtual SbBool makeNormalCurrent();
00296
00297 #endif
00299 #if 1 SoDEPRECATED
00321 SbBool setFullSceneAntialiasing( SbBool enable,
00322 float quality = -1.0,
00323 int filterMask = SoFullSceneAntialiasing::ALL );
00324 SoDEPRECATED
00330 SbBool isFullSceneAntialiasingEnabled() const;
00331 SoDEPRECATED
00336 SbBool getFullSceneAntialiasing( float& quality );
00337 SoDEPRECATED
00342 SbBool isFullSceneAntialiasingAvailable() const;
00343
00344 #endif
00346 private:
00347
00348 SoGuiGLWidget* getGuiGLWidget() const;
00349
00350
00351 SbBool isFsaaSupportHighQuality();
00352 SbBool isFsaaHighQuality();
00353
00354
00355
00356 static SbBool swapNormalBuffersCB(void *data);
00357 static SbBool bindNormalCurrentCB(void *data);
00358 static SbBool unbindNormalCurrentCB(void *data);
00359 static void* getNormalWindowCB(void *data);
00360
00361 private:
00362
00363
00364
00365
00366
00367
00368
00369 void flush();
00370
00371 static void exposeCB( SoWxGLWidget* p );
00372
00373
00374
00375 static void eventHandler( wxWindow* wxW, SoWxGLWidget* w, wxEvent& wxE, bool* boolean );
00376 static void showEventHandler( SoWxGLWidget* w, wxShowEvent& wxE );
00377
00378 #ifdef _WIN32
00379
00380 DWORD getThreadId() { return m_dwThreadId; };
00381 void setThreadId(DWORD id) { m_dwThreadId = id; };
00382 #endif
00383
00390 void setCursor( wxCursor newCursor );
00391
00395 wxCursor getCursor();
00396
00397 private:
00398
00399 SoWxGLWidget( wxWindow* parent = NULL,
00400 const char* name = NULL,
00401 SbBool buildInsideParent = TRUE,
00402 int glModes = SO_GLX_RGB,
00403 SbBool buildNow = TRUE,
00404 SbBool sync = TRUE );
00405
00406 SoWxGLWidget( wxWindow* parent,
00407 const char* name,
00408 SbBool buildInsideParent,
00409 int glModes,
00410 SbBool buildNow,
00411 SbBool sync,
00412 SoGuiGLWidget* guiGLWidget );
00413
00414 virtual ~SoWxGLWidget();
00415
00416
00417
00418 virtual void redraw() = 0;
00419 virtual void processEvent( wxEvent& anyEvent );
00420 virtual void visibilityChangeCB( wxShowEvent& showEvent );
00421
00422
00423
00424
00425
00426
00427 virtual void initGraphic();
00428 virtual void sizeChanged( const SbVec2s& size );
00429 virtual void posChanged( const SbVec2i32&, const SbVec2i32& ) { };
00430 virtual void widgetChanged( wxWindow* w );
00431 virtual void onFocusEvent( SbBool );
00432
00433
00434
00435
00436
00437 void setGlxSize( SbVec2s newSize );
00438 const SbVec2s& getGlxSize() const { return m_guiGLWidget->getGlxSize(); }
00439
00440
00441
00442
00443 void setStereoBuffer( SbBool flag );
00444 SbBool isStereoBuffer() { return (m_guiGLWidget->getGLModes() & SO_GLX_STEREO); }
00445
00446
00447 SbBool isRGBMode() { return (m_guiGLWidget->getGLModes() & SO_GLX_RGB); }
00448
00449
00450 int getDisplayListShareGroup( SoGLContext* ctx );
00451
00452 SbBool waitForExpose;
00453
00454 wxPanel* buildWidget( wxWindow* parent, int* attribList = 0 );
00455 void changeCursor( wxCursor newCursor );
00456 wxPanel* getGlxMgrWidget() { return m_mgrWidget; }
00457
00458 bool eventFilter( wxEvent& anEvent );
00459
00460 virtual void onExpose();
00461
00462 private:
00463
00464 void constructorCommon( int glModes, SbBool buildNow, SbBool connectionType );
00465 SoGuiGLWidget* m_guiGLWidget;
00466
00467
00468 void keyboardEvents( wxKeyEvent& redirectedEvent );
00469 void moveEvents( wxMoveEvent& redirectedEvent );
00470 void sizeEvents( wxSizeEvent& redirectedEvent );
00471 void showEvents( wxShowEvent& redirectedEvent );
00472
00473
00474 void internalClose( wxCommandEvent& ce );
00475
00476
00477 wxPanel* m_mgrWidget;
00478 SoWxGLX* m_doubleBufferWidget;
00479 SoWxGLX* m_singleBufferWidget;
00480 SoRef<SoGLContext> m_contextNormal;
00481 SoRef<SoGLContext> m_contextSingle;
00482 SoRef<SoGLContext> m_contextDouble;
00483
00484 wxGLContext* m_wxContextNormal;
00485 wxGLContext* m_wxContextSingle;
00486 wxGLContext* m_wxContextDouble;
00487
00488 #if defined(_WIN32)
00489 Hdc m_hdcNormal, m_hdcSingle, m_hdcDouble;
00490 DWORD m_dwThreadId;
00491 #endif // _WIN32
00492
00493 SbBool m_directConnection;
00494
00495 wxCursor m_currentCursor;
00496 int* m_attribList;
00497 SbBool m_windowResized;
00498
00499
00500 void buildNormalGLXWidget( int* attribList = NULL );
00501
00502 void destroyNormalWindows();
00503 void destroyGLXWidget( SoWxGLX* &w, SoRef<SoGLContext>& ctx, SbBool normalCall );
00504 void changeGLX();
00505
00506
00507 static void ginitCB( SoWxGLX* w, SoWxGLWidget* p, void* d );
00508 static void resizeCB( wxWindow* w, SoWxGLWidget* p, void* d );
00509
00510
00511 int getNumSamples(size_t n);
00512 int findSampleIndex(int findInt);
00513 void listFSAAMaxSamples();
00514 SoSamplesList m_samplesParseTab;
00515
00516
00517 SbBool m_initGLX;
00518
00519 wxFrame* m_dummyFrame;
00520
00521
00522 DECLARE_EVENT_TABLE()
00523 };
00524
00525
00526 #endif // SO_WX_GLWIDGET
00527
00528