fshake3d  0.0.1
FreeformDensity3DSurfaceEditor
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines
ui_Frame.cpp
Go to the documentation of this file.
00001 #include "ui_Frame.hpp"
00002 
00003 Frame::Frame(int winid)
00004     : mWindowID(winid)
00005 {    
00006 }
00007 
00008 void Frame::setWindow(Window* pWindow)
00009 {
00010   mpWindow = pWindow;
00011   if (mpWindow)
00012   {
00013     Vec4i vp;
00014     vp[0] = mpWindow->getX();
00015     vp[1] = mpWindow->getY();
00016     vp[2] = mpWindow->getWidth();
00017     vp[3] = mpWindow->getHeight();
00018     setViewport( vp );
00019     mpWindow->setEventTarget(this);
00020   }
00021 }
00022 
00023 void Frame::clearBuffers()
00024 {
00025   glClearColor(mBGColor[0],mBGColor[1],mBGColor[2],0.0f);
00026   glClearDepth(1.0);
00027   glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
00028 }
00029 
00030 void Frame::display()
00031 {
00032   clearBuffers();
00033   Bin::display();
00034 }
00035 
00036 void Frame::dispose()
00037 {
00038   if (mWindowID != -1) {
00039     glutDestroyWindow( mWindowID );
00040     mWindowID = -1;
00041   }
00042   if (mpWindow) {
00043     mpWindow->setEventTarget(0);
00044     mpWindow->destroyWindow();
00045     delete mpWindow;
00046     mpWindow = 0;
00047   }
00048 }
00049 
00050 void Frame::onEvent(Event& e)
00051 {
00052   switch(e.getType())
00053   {
00054   case EVENT_WINDOWDISPLAY: 
00055     clearBuffers();
00056     Bin::onEvent(e);
00057     break;
00058   case EVENT_WINDOWDESTROY:
00059     Bin::onEvent(e);
00060     mpWindow = 0;
00061     break;
00062   default:
00063     Bin::onEvent(e);
00064     break;
00065   }
00066 }
00067 
00068 Window* Frame::getWindow()
00069 {
00070   return mpWindow;
00071 }