VR-Forces 4.0.4 Class Documentation
examples/exampleMFC/MFCClasses.h
Go to the documentation of this file.
00001 #ifndef MFCClasses_H
00002 #define MFCClasses_H
00003 
00004 #include <afxwin.h>
00005 #include <GL/GL.h>
00006 #include <osg/GraphicsContext>
00007 #include <osgViewer/GraphicsWindow>
00008 #include <vlutil/vlPerformanceStats.h>
00009 #include <vrvCore/DtDe.h>
00010 #include <vrvCore/DtDeMainWindow.h>
00011 #include <vrvCore/DtWindow.h>
00012 #include <vrvCore/DtWindowFactory.h>
00013 #include <vrvOsg/DtOsgWindow.h>
00014 #include <vrvOsg/vrvOsg.h>
00015 
00017 class DtMfcMainWindow : public CFrameWnd, public makVrv::DtDeMainWindow
00018 {
00019 public:
00020    DtMfcMainWindow(makVrv::DtDe& de);
00021 
00022    //DtDeMainWindow Interface
00024    virtual void setApplicationTitle(const std::string& appName);
00025 
00027    virtual std::string DtMfcMainWindow::applicationTitle() const;
00028 
00030    virtual void setApplicationIcon(const std::string& iconName);
00031 
00033    virtual void setShowQuitDialogOnClose(bool value);
00034 
00036    virtual void destroyWindow();
00037 
00039    virtual void quit();
00040 
00041 protected:
00042    bool myShowQuitFlag;
00043 
00044 };
00045 
00046 class DtMfcControlAsOsgContext;
00047 
00049 class DtEmbeddedMfcOsgWindow : public CWnd, public makVrv::DtOsgWindow
00050 {
00051 public:
00052    UINT_PTR m_unpTimer;
00053 
00055    DtEmbeddedMfcOsgWindow(makVrv::DtDe& de, makVrv::DtWindowConfiguration& wc);
00056 
00058    virtual ~DtEmbeddedMfcOsgWindow();
00059 
00061    virtual bool isValid() const;
00062 
00064    virtual void setPosition(int x,int y);
00065 
00067    virtual void resize(int width,int height);
00068 
00072    virtual void sizeChanged(int width,int height);
00073 
00074    //Create the OpenGL Window
00075    void oglCreate(CRect rect, CWnd *parent);
00076 
00078    void oglInitialize(bool doubleBuffer, bool stereo, unsigned int colorBits,
00079       unsigned int depthBits, unsigned int stencilBits, bool vsync);
00080 
00081    bool isRealizedImplementation() const;
00082 
00084    void oglClose();
00085 
00087    bool makeCurrent();
00088 
00090    bool release();
00091 
00093    void swapBuffers();  
00094 
00096    void setVSync(bool enabled);
00097 
00098    // Added message classes:
00099    afx_msg void OnPaint();   
00100    afx_msg void OnSize(UINT nType, int cx, int cy);
00101    afx_msg void OnDraw(CDC *pDC);
00102    afx_msg int  OnCreate(LPCREATESTRUCT lpCreateStruct);
00103    afx_msg void OnMouseMove(UINT nFlags, CPoint point);
00104    afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
00105    afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
00106    afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
00107    afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
00108    afx_msg void OnMButtonDown(UINT nFlags, CPoint point);
00109    afx_msg void OnMButtonUp(UINT nFlags, CPoint point);
00110 
00111    DECLARE_MESSAGE_MAP()  
00112    
00113 private:
00114 
00115    DtMfcControlAsOsgContext* myControl;
00116    CWnd* myHWnd;
00117    HDC   myHDC;         
00118    HGLRC myHGLRC;       
00119    int   myPixelFormat;
00120 
00121 };
00122 
00124 class DtEmbeddedMfcOsgWindowCreator : public makVrv::DtWindowCreator
00125 {
00126 public:
00127 
00129    virtual makVrv::DtWindow* create(makVrv::DtDe& de, 
00130       makVrv::DtWindowConfiguration& config);
00131 };
00132 
00133 
00135 class DtMfcControlAsOsgContext : public osgViewer::GraphicsWindowEmbedded
00136 {
00137 public:        
00138 
00139    DtMfcControlAsOsgContext( makVrv::DtDe& de, 
00140       DtEmbeddedMfcOsgWindow* wnd, osg::GraphicsContext::Traits* traits);
00141 
00142    virtual bool valid() const;
00143    virtual bool realizeImplementation();
00144    virtual bool isRealizedImplementation() const;
00145    virtual void closeImplementation();
00146    virtual void grabFocus();
00147    virtual void grabFocusIfPointerInWindow();
00148    virtual bool makeCurrentImplementation();
00149    virtual bool releaseContextImplementation();
00150    virtual void swapBuffersImplementation();
00151    virtual void requestWarpPointer( float x, float y );
00152    virtual void useCursor( bool onOff );
00153 
00154 protected:
00155    DtEmbeddedMfcOsgWindow* myControl;
00156    makVrv::DtDe& myDe;
00157 };
00158 
00160 class DtMfcMainWindowProvider : public makVrv::DtDeMainWindowProvider
00161 {
00162 public:
00163 
00165    DtMfcMainWindowProvider(makVrv::DtDe& de);
00166 
00167 protected:
00168 
00170    virtual makVrv::DtDeMainWindow* createMainWindow(makVrv::DtDe& de);
00171 };
00172 
00173 
00174 #endif

Document ID: Generated on Fri Jun 29 16:33:32 EDT 2012 from SVN revision 116588
Copyright © 2005-2012 VT MÄK Inc. All Rights Reserved (www.mak.com)