planners/output/PL_OutputWindow.cpp

Go to the documentation of this file.
00001 //## begin module%376A8A4B01A9.cm preserve=no
00002 //        %X% %Q% %Z% %W%
00003 //## end module%376A8A4B01A9.cm
00004 
00005 //## begin module%376A8A4B01A9.cp preserve=no
00006 //## end module%376A8A4B01A9.cp
00007 
00008 //## Module: PL_OutputWindow%376A8A4B01A9; Pseudo Package body
00009 //## Source file: E:\mpk\code\Planners\PL_OutputWindow.cpp
00010 
00011 //## begin module%376A8A4B01A9.additionalIncludes preserve=no
00012 //## end module%376A8A4B01A9.additionalIncludes
00013 
00014 //## begin module%376A8A4B01A9.includes preserve=yes
00015 //## end module%376A8A4B01A9.includes
00016 
00017 // PL_OutputWindow
00018 #include "PL_OutputWindow.h"
00019 //## begin module%376A8A4B01A9.additionalDeclarations preserve=yes
00020 #include <assert.h>
00021 #ifndef NOGL
00022 #include "opengl/glos.h"
00023 #include <gl/gl.h>
00024 #endif
00025 
00026 //## end module%376A8A4B01A9.additionalDeclarations
00027 
00028 
00029 // Class PL_OutputWindow 
00030 
00031 
00032 
00033 PL_OutputWindow::~PL_OutputWindow()
00034 {
00035   //## begin PL_OutputWindow::~PL_OutputWindow%.body preserve=yes
00036         EndOutput();
00037   //## end PL_OutputWindow::~PL_OutputWindow%.body
00038 }
00039 
00040 void PL_OutputWindow::DrawLine (double x0, double y0, double x1, double y1) const
00041 {
00042 #ifndef NOGL
00043     glBegin( GL_LINES );
00044         glVertex2d( static_cast< short int >( x0 ), static_cast< short int >( y0 ) ) ;
00045         glVertex2s( static_cast< short int >( x1 ), static_cast< short int >( y1 ) ) ;
00046     glEnd() ;
00047 #endif
00048 }
00049 
00050 void PL_OutputWindow::DrawPoint (double x0, double y0) const
00051 {
00052 #ifndef NOGL
00053         glBegin( GL_POINTS );
00054                 glVertex2d( x0, y0 );
00055         glEnd();
00056 #endif
00057 }
00058 
00059 void PL_OutputWindow::StartOutput ()
00060 {
00061   //## begin PL_OutputWindow::StartOutput%929729310.body preserve=yes
00062 #ifdef WIN32
00063         BOOL success;
00064         success = this->DestroyWindow() ;
00065         success = this->Create( IDD_BLANK_DIALOG, NULL ) ;
00066         assert( success == TRUE ) ;
00067 
00068         //setup all the openGL stuff
00069         PIXELFORMATDESCRIPTOR pfd =
00070     {
00071         sizeof(PIXELFORMATDESCRIPTOR), // Structure size.
00072         1,                             // Structure version number.
00073         PFD_DRAW_TO_WINDOW |           // Property flags.
00074         PFD_SUPPORT_OPENGL ,
00075         PFD_TYPE_RGBA,
00076         24,                          // 24-bit color.
00077         0, 0, 0, 0, 0, 0,              // Not concerned with these.
00078         0, 0, 0, 0, 0, 0, 0,           // No alpha or accum buffer.
00079         32,                            // 32-bit depth buffer.
00080         0, 0,                          // No stencil or aux buffer.
00081         PFD_MAIN_PLANE,                // Main layer type.
00082         0,                             // Reserved.
00083         0, 0, 0                        // Unsupported.
00084     };
00085     CClientDC clientDC( this );
00086         CDC* cdc = this->GetDC() ;
00087 
00088     int pixelFormat = ChoosePixelFormat(clientDC.m_hDC, &pfd);
00089         success = SetPixelFormat(clientDC.m_hDC, pixelFormat, &pfd);    
00090 
00091         HDC             hdc = cdc->m_hDC; 
00092         HGLRC   hglrc = wglCreateContext (hdc);  
00093         this->ReleaseDC( cdc ) ;
00094 
00095         pDC = this->GetDC() ;
00096         wglMakeCurrent (pDC->m_hDC, hglrc); // call OpenGL APIs as desired ... 
00097 #endif
00098   //## end PL_OutputWindow::StartOutput%929729310.body
00099 }
00100 
00101 void PL_OutputWindow::EndOutput ()
00102 {
00103 #ifdef WIN32
00104     wglMakeCurrent( NULL, NULL );
00105 
00106         //shut down the OpenGL window
00107         BOOL destroySuccess = this->DestroyWindow() ;
00108         assert( destroySuccess == TRUE ) ;
00109 #endif
00110 }
00111 
00112 void PL_OutputWindow::NameDialog (const char* name)
00113 {
00114 #ifdef WIN32
00115         this->SetWindowText( name ) ;
00116 #endif
00117 }
00118 
00119 // Additional Declarations
00120   //## begin PL_OutputWindow%376A8A4B01A9.declarations preserve=yes
00121   //## end PL_OutputWindow%376A8A4B01A9.declarations
00122 
00123 //## begin module%376A8A4B01A9.epilog preserve=yes
00124 //## end module%376A8A4B01A9.epilog

Generated on Sat Apr 1 21:30:44 2006 for Motion Planning Kernel by  doxygen 1.4.6-NO