Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

vuSphericIBR.cpp

Go to the documentation of this file.
00001 #include "vuSphericIBR.h"
00002 #include "Volume/Lightfield/Unimodal/Spheric/vuSphericFilterFactory.h"
00003 #include "General/vuLightfield/vuSphericViewFilterFactory.h"
00004 
00005 template <int SIZE, class TYPE>
00006 vuSphericIBR<SIZE,TYPE>::vuSphericIBR()
00007 {
00008   m_Data = NULL;
00009 }
00010 
00011 template <int SIZE, class TYPE>
00012 vuSphericIBR<SIZE,TYPE>::~vuSphericIBR()
00013 {
00014   CHECKNDELETE(m_Data);
00015 }
00016 
00017 template <int SIZE, class TYPE>
00018 const char *vuSphericIBR<SIZE,TYPE>::_titleString()
00019 {
00020   return "Image Based Renderer";
00021 }
00022 
00023 template <int SIZE, class TYPE>
00024 bool vuSphericIBR<SIZE,TYPE>::init(const char* DataFile)
00025 {
00026   SetEvtHandlerEnabled(true);
00027 
00028   //Set up the window
00029   SetTitle(_titleString());
00030   CreateStatusBar();
00031 
00032   //Create a volume data instance.
00033   // the "m_Data = new vu1611?2" is called by child classes
00034   m_Data->setFileName(DataFile);
00035 
00036   //Read in the data.
00037   bool success = m_Data->read();
00038   if (success) {
00039     m_glCanvas->SetSize(752,512);
00040     vuString str;
00041     str  = _titleString();
00042     str += ": [";
00043     str += m_Data->getWidth();
00044     str += "x";
00045     str += m_Data->getHeight();
00046     str += "] x ";
00047     str += m_Data->getNumberOfViews();
00048     str += " Views <";
00049     str += SIZE;
00050     str += " ";
00051     str += m_Data->_typeName();
00052     str += ">";
00053     SetTitle(str.c_str());
00054     Fit();
00055     m_SphericView->setVolume(m_Data);
00056     //m_Preview->attachCamera(&m_Data->getCamera());
00057     //m_Preview->setCubeSize(50,50,50);
00058   }
00059   else {
00060     wxMessageDialog dlg(this,m_Data->getErrorMessage(),
00061                         "vuSphericIBR",wxOK);
00062     dlg.ShowModal();
00063   }
00064   return success;
00065 }
00066 
00067 
00068 /* ------------------------------------------------------------------------ */
00069 /* --- add some ui elements ----------------------------------------------- */
00070 /* ------------------------------------------------------------------------ */
00071 
00072 template <int SIZE, class TYPE>
00073 void vuSphericIBR<SIZE,TYPE>::addRight(wxSizer *sizer)
00074 {
00075   m_CHOICEfilter = 
00076     new wxChoice(this, idFILTER, wxDefaultPosition, wxSize(100,-1),
00077                  0, NULL, wxMAXIMIZE_BOX, wxDefaultValidator, "Filter");
00078 
00079   m_CHOICEsubFilter = 
00080     new wxChoice(this, idSUBFILTER, wxDefaultPosition, wxSize(100,-1),
00081                  0, NULL, wxMAXIMIZE_BOX, wxDefaultValidator, "SubFilter");
00082 
00083   
00084   {
00085     // lightfield filter choice
00086     dword    count        = 0;
00087     vuString *filterNames = NULL;
00088 
00089     vuSphericFilterFactory<SIZE,TYPE>::getFilterNames(filterNames, count);
00090     for (dword i=0; i<count; i++) {
00091       m_CHOICEfilter->Append(filterNames[i].c_str());    
00092     }
00093     m_CHOICEfilter->SetSelection(0);
00094 
00095   
00096     // view filter choice
00097     vuSphericViewFilterFactory<SIZE,TYPE>::getFilterNames(filterNames, count);
00098     for (dword i=0; i<count; i++) {
00099       m_CHOICEsubFilter->Append(filterNames[i].c_str());    
00100     }
00101     m_CHOICEsubFilter->SetSelection(0);
00102   }
00103 
00104 
00105   sizer->Add(new wxStaticText(this, -1, "Filter:", wxDefaultPosition,
00106                               wxSize(60,-1),wxALIGN_LEFT),0,wxEXPAND, 5);
00107   sizer->Add(m_CHOICEfilter,0,wxALL|wxALIGN_LEFT,1);
00108 
00109   sizer->Add(new wxStaticText(this, -1, "Sub Filter:", wxDefaultPosition,
00110                               wxSize(80,-1),wxALIGN_LEFT),0,wxEXPAND, 5);
00111 
00112   sizer->Add(m_CHOICEsubFilter,0,wxALL|wxALIGN_LEFT,1);
00113 
00114   m_SphericView = new vuSphericViewWin(this,200,200);
00115   sizer->Add( m_SphericView, 
00116               1,       // make horizontally stretchable
00117               wxALL,   // make border all around (implicit top alignment)
00118               10 );    // set border width to 10
00119 #if 0
00120   m_Preview = new vuPreviewWin(this,200,200);
00121   sizer->Add( m_Preview, 
00122               1,           // make horizontally stretchable
00123               wxALL,       // make border all around (implicit top alignment)
00124               10 );        // set border width to 10
00125 #endif
00126 }
00127 
00128 template <int SIZE, class TYPE>
00129 bool vuSphericIBR<SIZE,TYPE>::glInit()
00130 {
00131   if (m_Data == NULL) return false;
00132   m_Data->initOpenGL();
00133   return true;
00134 }
00135 
00136 template <int SIZE, class TYPE>
00137 void vuSphericIBR<SIZE,TYPE>::glRender()
00138 {
00139   wxStopWatch watch;
00140 
00141   watch.Start();
00142   m_Data->render();
00143   watch.Pause();
00144 
00145   m_SphericView->redraw();
00146   //m_Preview->redraw();
00147 
00148   SetStatusText(wxString("Render Time: ")+vuString(watch.Time()).c_str() +
00149                 "ms");
00150 }
00151 
00152 template <int SIZE, class TYPE>
00153 void vuSphericIBR<SIZE,TYPE>::glResize()
00154 {
00155   m_Data->glResize(m_glCanvas->getWidth(), m_glCanvas->getHeight());
00156 }
00157 
00158 template <int SIZE, class TYPE>
00159 void vuSphericIBR<SIZE,TYPE>::onMouse(wxMouseEvent &ev)
00160 {
00161   // here is the place for additional mouse bevaviour.
00162 }
00163 
00164 template <int SIZE, class TYPE>
00165 void vuSphericIBR<SIZE,TYPE>::onKeyboard(wxKeyEvent& event)
00166 {
00167 }
00168 
00169 template <int SIZE, class TYPE>
00170 vu1 *vuSphericIBR<SIZE,TYPE>::getVolume()
00171 {
00172   return (vu1 *)m_Data;
00173 }
00174 
00175 /* --------------------------------------------------------------------- */
00176 /* --- some GUI callbacks ---------------------------------------------- */
00177 /* --------------------------------------------------------------------- */
00178 
00179 template <int SIZE, class TYPE>
00180 void vuSphericIBR<SIZE,TYPE>::OnChoiceFilter(wxCommandEvent& event)
00181 {
00182   dword idx = m_CHOICEfilter->GetSelection();
00183  
00184   m_Data->setFilter(vuSphericFilterFactory<SIZE,TYPE>::getFilter(idx));
00185 
00186   m_Data->setIsReRendering(true);
00187   m_glCanvas->redraw();
00188 }
00189 
00190 template <int SIZE, class TYPE>
00191 void vuSphericIBR<SIZE,TYPE>::OnChoiceSubFilter(wxCommandEvent& event)
00192 {
00193   dword idx = m_CHOICEsubFilter->GetSelection();
00194  
00195   m_Data->setViewFilter(vuSphericViewFilterFactory<SIZE,TYPE>::getFilter(idx));
00196 
00197   m_Data->setIsReRendering(true);
00198   m_glCanvas->redraw();
00199 }
00200 
00201 template <int SIZE, class TYPE>
00202 vuCamera* vuSphericIBR<SIZE,TYPE>::getCamera()
00203 {
00204   return m_Data->getCameraPtr ();
00205 }
00206 
00207 template <int SIZE, class TYPE>
00208 vuImage* vuSphericIBR<SIZE,TYPE>::getCurrentImage()
00209 {
00210   return NULL;
00211 }
00212 
00213 template <int SIZE, class TYPE>
00214 void vuSphericIBR<SIZE,TYPE>::DrawFromImage()
00215 {
00216   m_glCanvas->redraw ();
00217 }
00218 
00219 template <int SIZE, class TYPE>
00220 void vuSphericIBR<SIZE,TYPE>::DrawAgain()
00221 {
00222 }

Generated on Wed Dec 15 21:20:36 2004 for vuVolume by  doxygen 1.3.9.1