Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
biasGLviewerWx.cpp
1 /*
2 This file is part of the BIAS library (Basic ImageAlgorithmS).
3 
4 Copyright (C) 2003-2009 (see file CONTACT for details)
5  Multimediale Systeme der Informationsverarbeitung
6  Institut fuer Informatik
7  Christian-Albrechts-Universitaet Kiel
8 
9 
10 BIAS is free software; you can redistribute it and/or modify
11 it under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
13 (at your option) any later version.
14 
15 BIAS is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU Lesser General Public License for more details.
19 
20 You should have received a copy of the GNU Lesser General Public License
21 along with BIAS; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 */
24 
25 #include "biasGLviewerWx.hh"
26 #include <Gui/StringConv.hh>
27 #include <Utils/IOUtils.hh>
28 #include <img/miplogochars32x32.xpm>
29 
30 using namespace std;
31 using namespace BIAS;
32 
33 #define GRP_IMAGE 1
34 #define GRP_GENERAL 2
35 #define GRP_SEGMENTATION 3
36 #define GRP_BACKGROUND 4
37 #define GRP_MODELS 5
38 #define GRP_VIEW 6
39 
40 BEGIN_EVENT_TABLE( BIASOpenGLViewerFrame, wxFrame)
41 EVT_CLOSE ( BIASOpenGLViewerFrame::OnQuit)
42 EVT_MENU ( wxID_EXIT, BIASOpenGLViewerFrame::OnExit)
43 EVT_MENU ( wxID_ABOUT, BIASOpenGLViewerFrame::OnAbout)
44 EVT_MENU ( ID_SAVE_PARAMETER, BIASOpenGLViewerFrame::OnSaveParameters)
45 EVT_MENU ( ID_SHOW_PARAMETER, BIASOpenGLViewerFrame::OnShowParameters)
46 EVT_MENU ( ID_FULLSCREEN, BIASOpenGLViewerFrame::OnFullscreen)
47 
48 EVT_MENU ( ID_SOLID, BIASOpenGLViewerFrame::OnViewSolid)
49 EVT_MENU ( ID_LINES, BIASOpenGLViewerFrame::OnViewLines)
50 EVT_MENU ( ID_POINTS, BIASOpenGLViewerFrame::OnViewPoints)
51 
52 EVT_BUTTON( ID_LOADMODEL, BIASOpenGLViewerFrame::OnAddModel )
53 EVT_BUTTON( ID_DELETEMODELS, BIASOpenGLViewerFrame::OnDeleteModels )
54 EVT_BUTTON( ID_FULLSCREEN, BIASOpenGLViewerFrame::OnFullscreen)
55 EVT_BUTTON( ID_SCREENSHOT, BIASOpenGLViewerFrame::OnScreenshot)
56 
57 EVT_TIMER ( ID_TIMER, BIASOpenGLViewerFrame::OnTimer)
58 EVT_CHECKBOX(ID_CHECK_MEASURE, BIASOpenGLViewerFrame::OnMeasure)
59 END_EVENT_TABLE()
60 
61 
63 BIASOpenGLViewerFrame(wxWindow* parent, wxWindowID id,
64  const wxString& title, const wxPoint& pos, const wxSize& size, long style) :
65  wxFrame(parent, id, title, pos, size, style)
66 {
67  SetIcon(wxIcon(miplogochars32x32_xpm));
68 
69  this->SetSizeHints(wxDefaultSize, wxDefaultSize);
70 
71  toolBar_ = this->CreateToolBar(wxTB_DOCKABLE | wxTB_HORIZONTAL, wxID_ANY);
72 
73  fullscreenButton_ = new wxButton(toolBar_, ID_FULLSCREEN, wxT("Fullscreen"),
74  wxDefaultPosition, wxDefaultSize, 0);
75  toolBar_->AddControl(fullscreenButton_);
76 
77  loadModelButton_ = new wxButton(toolBar_, ID_LOADMODEL, wxT("Load Model"),
78  wxDefaultPosition, wxDefaultSize, 0);
79  toolBar_->AddControl(loadModelButton_);
80 
81  deleteModelsButton_ = new wxButton(toolBar_, ID_DELETEMODELS, wxT("Delete Models"),
82  wxDefaultPosition, wxDefaultSize, 0);
83  toolBar_->AddControl(deleteModelsButton_);
84 
85  screenshotButton_ = new wxButton(toolBar_, ID_SCREENSHOT, wxT("Screenshot"),
86  wxDefaultPosition, wxDefaultSize, 0);
87  toolBar_->AddControl(screenshotButton_);
88 
89 
90  measureCheckbox_ = new wxCheckBox(toolBar_,ID_CHECK_MEASURE,wxT("Measure"));
91  measureCheckbox_->SetValue(false);
92  toolBar_->AddControl(measureCheckbox_);
93  toolBar_->Realize();
94  //menu
95  //file
96  menubar_ = new wxMenuBar(0);
97  fileMenu_ = new wxMenu();
98  fileMenu_->Append(ID_SAVE_PARAMETER, wxT("&Save Parameters") );
99  menuItemShowParameter_ = new wxMenuItem(fileMenu_, ID_SHOW_PARAMETER, wxString(
100  wxT("Show &Parameters")), wxEmptyString, wxITEM_CHECK);
101  fileMenu_->Append(menuItemShowParameter_);
102  fileMenu_->Append( wxID_EXIT, wxT("E&xit") );
103  menubar_->Append(fileMenu_, wxT("&File"));
104  //view
105  viewMenu_ = new wxMenu();
106  menuItemFullscreen_ = new wxMenuItem(fileMenu_, ID_FULLSCREEN, wxString(
107  wxT("&Fullscreen")), wxEmptyString, wxITEM_CHECK);
108  viewMenu_->Append(menuItemFullscreen_);
109  menuItemSolid_ = new wxMenuItem(fileMenu_, ID_SOLID, wxString(
110  wxT("&Solid")), wxEmptyString, wxITEM_CHECK);
111  viewMenu_->Append(menuItemSolid_);
112  menuItemLines_ = new wxMenuItem(fileMenu_, ID_LINES, wxString(
113  wxT("&Lines")), wxEmptyString, wxITEM_CHECK);
114  viewMenu_->Append(menuItemLines_);
115  menuItemPoints_ = new wxMenuItem(fileMenu_, ID_POINTS, wxString(
116  wxT("&Points")), wxEmptyString, wxITEM_CHECK);
117  viewMenu_->Append(menuItemPoints_);
118 
119  menubar_->Append(viewMenu_, wxT("&View"));
120  //help
121  helpMenu_ = new wxMenu();
122  helpMenu_->Append(wxID_ABOUT, wxT("&About...") );
123  menubar_->Append(helpMenu_, wxT("&Help"));
124 
125  this->SetMenuBar(menubar_);
126 
127  const int numFields = 2;
128  CreateStatusBar(numFields);
129 
130 
131 
132  //********************* ContextWX ********************************************************
133  const BIAS::Vector4<float> cc(65/255.0, 139/255.0, 212/255.0, 0);
134  int ContextAttribs[] = { WX_GL_RGBA,
135  WX_GL_LEVEL, 0,
136  WX_GL_MIN_RED, 8,
137  WX_GL_MIN_GREEN, 8,
138  WX_GL_MIN_BLUE, 8,
139  WX_GL_MIN_ALPHA, 8,
140  WX_GL_DEPTH_SIZE, 24,
141  WX_GL_STENCIL_SIZE, 8,
142  WX_GL_DOUBLEBUFFER, 0 };
143  contextWX_ = new ContextWX( this, wxID_ANY,wxDefaultPosition, wxSize(640, 480), 0,wxT("GLCanvas"),ContextAttribs);
144  contextWX_->SetBlending(false);
145  contextWX_->SetBackfaceCulling(false);
146 
147  // GLProjectionParametersBase
148  virtualCamera_= new BIAS::GLProjectionParametersPerspective();//if (virtualCamera_ == NULL)
149  (dynamic_cast<BIAS::GLProjectionParametersPerspective*> (virtualCamera_))->SetSimplePerspectiveCam(65);
150  Vector3<double> C(0,0,-10); Quaternion<double> Q(0,0,0,1);
151  (dynamic_cast<BIAS::GLProjectionParametersPerspective*> (virtualCamera_))->SetExtrinsics(C,Q);
152  virtualCamera_->SetAutoReshapeBehaviour(BIAS::GLProjectionParametersInterface::AutoRescaleParams);
153 
154  contextWX_->SetGLProjectionParametersInterface(virtualCamera_);
155  contextWX_->SetControl(&Control_);
156  contextWX_->SetAutoClipping(true);
157  contextWX_->SetAutoClipMinZNear(0.1);
158  contextWX_->SetClearColor(cc);
159  contextWX_->InitializationComplete();
160  //********************************************************************************
161 
162  InitParameters_();
163  InitModels();
164  this->Layout();
165 
166  timer_.SetOwner(this, ID_TIMER);
167  timer_.Start(5,true);
168 }
169 
170 
173 
174 }
175 
176 
177 void BIASOpenGLViewerFrame::
178 OnMeasure(wxCommandEvent& event){
179  Control_.SetDistanceMeasure(event.IsChecked());
180 }
181 
182 void BIASOpenGLViewerFrame::
183 OnTimer(wxTimerEvent& /*event*/) {
184  timer_.Stop();
185  contextWX_->Refresh();
186  timer_.Start(5, true);
187 }
188 
191 
192  screenShotControl_.Init(contextWX_, *screenShotName_, "png", "", true);
193 
194  // add a light source
195  lightScene_.SetLightAsHeadLight(true);
196  lightScene_.SetDrawLightPosition(false);
197  lightScene_.SetAmbient(Vector4<double> (0.3, 0.3, 0.3, 1.0));
198  lightScene_.SetDiffuse(Vector4<double> (1.0, 1.0, 1.0, 1.0));
199  lightScene_.SetSpecular(Vector4<double> (0.1, 0.1, 0.1, 1.0));
200 
201  contextWX_->AppendScene(&lightScene_);
202 #ifdef BIAS_HAVE_OPENSCENEGRAPH
203  scene_.Init();
204  contextWX_->AppendScene(&scene_);
205 #endif
206 
207 #ifdef BIAS_HAVE_GLUT
208  contextWX_->AppendScene(&sceneGlut_);
209 #endif
210  contextWX_->AppendScene(&Control_);
211  contextWX_->AppendAdditionalListener(&screenShotControl_);
212  return 0;
213 }
214 
217  if(*useSceneCenter_) {
218  BIAS::Vector3<double> CameraCenter, radius, SceneCenter;
219  Quaternion<double> CameraQuaternion;
220  if (!contextWX_->GetSceneCenter(SceneCenter, radius))
221  BIASERR("could not retrieve bounding box from scene");
222  // move 10% outwards
223  if(C != NULL && Q != NULL){
224  CameraCenter = *C;
225  CameraQuaternion = *Q;
226  virtualCamera_->GetMyselfAsProjectionParameterBase()->SetC(CameraCenter);
227  virtualCamera_->GetMyselfAsProjectionParameterBase()->SetQ(CameraQuaternion);
228  Control_.SetPointOfInterest(SceneCenter);
229  return 0;
230  }
231  else
232  CameraCenter = SceneCenter + 1.1 * radius;
233  cout<<"using scene center "<<SceneCenter<<" and new camera center "
234  <<CameraCenter <<endl;
235  // set point of interest only if not equal to camera center
236  if ((CameraCenter-SceneCenter).NormL2()>0.001) {
237  virtualCamera_->GetMyselfAsProjectionParameterBase()->SetC(CameraCenter);
238  Control_.SetPointOfInterest(SceneCenter);
239  } else {
240  cerr<<"could not set poi, empty scene ?"<<endl;
241  }
242  return 0;
243  }
244  else return 1;
245 }
246 /****************************************************
247  @brief
248 
249 
250  *****************************************************/
251 void BIASOpenGLViewerFrame::
252 OnSaveParameters(wxCommandEvent& event){
253 
254  wxString fileName;
255  wxFileDialog dialog(this,wxT("Save Parameters"),wxT(""),wxT(""),
256  wxT("MIP Parameter files (*.param)|*.param"),
257  wxFD_SAVE|wxFD_OVERWRITE_PROMPT);
258  int ret = dialog.ShowModal();
259  if(ret == wxID_OK){
260  fileName = dialog.GetPath();
261  WriteParameter(WxToAscii(fileName));
262  }
263 }
264 
265 /****************************************************
266  @brief
267 
268 
269  *****************************************************/
270 void BIASOpenGLViewerFrame::
271 OnShowParameters(wxCommandEvent& event){
272  if(paramFrame_ != NULL){
273  if(event.IsChecked() ){
274  paramFrame_->Show(true);
275  }
276  else{
277  paramFrame_->Show(false);
278  }
279 
280  }
281 }
282 
283 /****************************************************
284  @brief
285 
286 
287  *****************************************************/
288 void BIASOpenGLViewerFrame::
289 OnAbout(wxCommandEvent& WXUNUSED(event))
290 {
291  wxString desc;
292  desc << wxT("The BIAS OpenGL Viewer, part of the\n\n");
293  desc << wxT(" BIAS library (Basic ImageAlgorithmS)\n");
294  stringstream text;
295  text << "built on " << __DATE__ << " " << __TIME__ << "\n"
296  << "GUI using: " << WxToAscii(wxVERSION_STRING)<< "\n";
297  desc<<AsciiToWx(text.str());
298 
299  wxString lic = wxT("BIAS is free software; you can redistribute it and/or modify\n \
300  it under the terms of the GNU Lesser General Public Licence as published by\n \
301  the Free Software Foundation; either version 2.1 of the Licence, or\n \
302  (at your option) any later version.\n \
303  \n \
304  BIAS is distributed in the hope that it will be useful,\n \
305  but WITHOUT ANY WARRANTY; without even the implied warranty of\n \
306  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n \
307  GNU Lesser General Public Licence for more details.\n \
308  \n \
309  You should have received a copy of the GNU Lesser General Public Licence\n \
310  along with BIAS; if not, write to the Free Software\n \
311  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n");
312 
313  wxAboutDialogInfo aboutdlg;
314  aboutdlg.SetDescription( desc );
315  aboutdlg.SetLicence( lic );
316  aboutdlg.SetCopyright( wxT("Copyright (C) 2003-2010\n \
317  Multimediale Systeme der Informationsverarbeitung\n \
318  Institut fuer Informatik\n \
319  Christian-Albrechts-Universitaet Kiel") );
320  aboutdlg.SetWebSite( wxT("http://www.mip.informatik.uni-kiel.de/") );
321 
322  wxAboutBox( aboutdlg );
323 }
324 
325 
326 /****************************************************
327  @brief
328 
329 
330  *****************************************************/
331 void BIASOpenGLViewerFrame::
332 OnDeleteModels(wxCommandEvent& event){
333 #ifdef BIAS_HAVE_OPENSCENEGRAPH
334  scene_.Clear();
335 #endif
336 }
337 /****************************************************
338  @brief
339 
340 
341  *****************************************************/
343 SetParameterFile(int argc, char** argv,std::string& paramFile) {
344  firstUnknownParam_ =0;
345  bool ret = IOUtils::ParseCommandLineEvalHelp(*this,argc, argv,firstUnknownParam_);
346  if(!ret) BIASWARN("Parsing command line arguments failed. Please check them!");
347 
348  wxSize panelSize(400,600);
349  paramFrame_ = NULL;
350  paramFrame_ = GetFrame(this);
351  if(paramFrame_ ==NULL ){
352  BIASERR("Param Panel can not be created, exiting!");
353  return;
354  }
355 
356 #ifdef BIAS_HAVE_OPENSCENEGRAPH
357  if(argc - firstUnknownParam_ >= 1 && firstUnknownParam_ > 0) {
358  for(int i=0;i< (argc - firstUnknownParam_);i++){
359  cout<<"loading "<<argv[firstUnknownParam_+i]<< "... \n"; cout.flush();
360  if(scene_.AppendSubTreeFromFile(argv[firstUnknownParam_+i])!=0)
361  cout<<" failed\n";
362  else{
363  cout<<" success\n";
364  }
365  }
366  ResetSceneCenter();
367  }
368  else
369  LoadDefaultModel_();
370 #endif
371 #ifdef BIAS_HAVE_GLUT
372  sceneGlut_.SetDrawTeapot(*teapot_,0.4);
373  sceneGlut_.SetDrawCube(*cube_,0.4);
374  sceneGlut_.SetDrawIcosahedron(*icosahedron_);
375  sceneGlut_.SetDrawTetrahedron(*tetrahedron_);
376 #endif
377 }
378 
379 
382 #ifdef BIAS_HAVE_OPENSCENEGRAPH
383  string model=BIAS_IMG_DIR;
384  model += "BIAS_LOGO_3D.3ds";
385  if(scene_.AppendSubTreeFromFile(model)==0){
386  Vector3<double> C(-0.186, 1.1, 1.09);
387  Quaternion<double> Q(0.07, -0.7, 0.69,0.008);
388  ResetSceneCenter(&C,&Q);
389  }
390 #endif
391 }
392 
393 /****************************************************
394  @brief
395 
396 
397  *****************************************************/
399 InitParameters_() {
400 
401  // Animation / Control Params
402  int groupID = GetFreeGroupID();
403  useFlyMode_ = AddParamBool(
404  "fly", "set mouse control to fly mode", false, 0 ,groupID);
405  useRotMode_ = AddParamBool(
406  "onlyRot", "turn only rotation for mouse control on", false, 0, groupID);
407  SetGroupName(groupID, "Animation / Control");
408 
409  // View Params
410  groupID = GetFreeGroupID();
411  zNear_ = AddParamDouble(
412  "zNear", "set near clipping plane distance, overrides autoClipping", 0.001, 0.000001, DBL_MAX, 0 ,groupID);
413  zFar_ = AddParamDouble(
414  "zFar", "set near clipping plane distance, overrides autoClipping", 10000, 0.00001, DBL_MAX, 0, groupID);
415  fov_ = AddParamDouble(
416  "fov", "field of view in degree", 0, 0, 359.9, 0, groupID);
417  autoClipping_ = AddParamBool(
418  "autoClipping", "turns auto clipping on/off", true, 0 , groupID);
419  backfaceCulling_ = AddParamBool(
420  "backfaceCulling", "do not draw back faces of triangles?", false, 0, groupID);
421 #ifdef BIAS_HAVE_GLUT
422  teapot_ = AddParamBool("teapot", "Add a glut teapot to scene", false, 0, groupID);
423  RegisterCallbackObject("teapot", this);
424 
425  cube_ = AddParamBool("cube", "Add a glut cube to scene", false, 0, groupID);
426  RegisterCallbackObject("cube", this);
427  tetrahedron_ = AddParamBool("tetrahedron", "Add a glut tetrahedron to scene", false, 0, groupID);
428  RegisterCallbackObject("tetrahedron", this);
429  icosahedron_ = AddParamBool("icosahedron", "Add a glut icosahedron to scene", false, 0, groupID);
430  RegisterCallbackObject("icosahedron", this);
431 #endif
432  SetGroupName(groupID, "View");
433 
434  // Camera Params
435  groupID = GetFreeGroupID();
436  projectionFile_ = AddParamString(
437  "projection", "load camera parameters from this file, sets findSceneCenter to false if useJustIntrinsics is false (default)",
438  "", 'p', groupID);
439  useSceneCenter_ = AddParamBool(
440  "findSceneCenter", "sets camera to center of scene",
441  true, 0, groupID);
442  useJustIntrinsics_ = AddParamBool(
443  "useJustIntrinsics", "uses only intrinsics from loaded projection",
444  false, 0, groupID);
445 
446  // create values for reshape behaviour
447  std::vector<std::string> reshapeBehaviour;
448  reshapeBehaviour.push_back("Deny");
449  reshapeBehaviour.push_back("AutoRescaleParams");
450  reshapeBehaviour.push_back("AutoCutImage");
451  reshapeBehaviour.push_back("AutoSimplePerspectiveCam");
452 
453  autoReshapeBehaviour_ = AddParamEnum(
454  "reshapeBehaviour", "sets the automatic reshape behaviour of the camera",
455  reshapeBehaviour, 1,NULL, 0, groupID);
456  SetGroupName(groupID, "Camera");
457 
458  // Misc Params
459  groupID = GetFreeGroupID();
460  winwidth_ = AddParamInt(
461  "winwidth", "window width", 0, 0, INT_MAX, 'w', groupID);
462  winheight_ = AddParamInt(
463  "winheight", "window width", 0, 0, INT_MAX, 'h', groupID);
464  screenShotName_ = AddParamString(
465  "screenShotName", "name for screenshoys default is 'screenShot'", "screenShot", 0, groupID);
466  backGroundColor_ = AddParamVecDbl(
467  "bgColor", "set background clear color", "200.0 230.0 230.0", 0, groupID);
468  SetGroupName(groupID, "Window");
469 
470 }
471 /****************************************************
472  @brief
473 
474 
475  *****************************************************/
477 ParameterChanged(const std::string &paramname,const void *data) {
478  cout<<"Change:";
479 #ifdef BIAS_HAVE_GLUT
480  if (strcmp((const char*) paramname.c_str(), "teapot") == 0) {
481  sceneGlut_.SetDrawTeapot(*teapot_,0.4);
482  ResetSceneCenter();
483  }
484  else if (strcmp((const char*) paramname.c_str(), "cube") == 0) {
485  sceneGlut_.SetDrawCube(*cube_,0.4);
486  ResetSceneCenter();
487  }
488  else if (strcmp((const char*) paramname.c_str(), "icosahedron") == 0) {
489  sceneGlut_.SetDrawIcosahedron(*icosahedron_);
490  ResetSceneCenter();
491  }
492  else if (strcmp((const char*) paramname.c_str(), "tetrahedron") == 0) {
493  sceneGlut_.SetDrawTetrahedron(*tetrahedron_);
494  ResetSceneCenter();
495  }
496 #endif
497 }
498 
499 
500 /****************************************************
501  @brief
502 
503 
504  *****************************************************/
505 void BIASOpenGLViewerFrame::
506 OnAddModel(wxCommandEvent& event) {
507 #ifdef BIAS_HAVE_OPENSCENEGRAPH
508  wxString fileName;
509  wxFileDialog
510  dialog(
511  this,
512  wxT("Load Model"),
513  wxT(""),
514  wxT(""),
515  wxT("Model files (*.wrl;*.dae;*.obj;*.osg;*.3ds;)|*.wrl;*.dae;*.obj;*.osg;*.3ds;|All files (*.*)|*.*"),
516  wxFD_OPEN);
517  int ret = dialog.ShowModal();
518  if (ret == wxID_OK) {
519  if(scene_.AppendSubTreeFromFile(WxToAscii(dialog.GetPath()))!=0)
520  cout<<" failed\n";
521  else{
522  cout<<" success\n";
523  ResetSceneCenter();
524  contextWX_->Refresh();
525  }
526  }
527 #else
528  stringstream text;
529  text<<"OpenSceneGraph is not activated in BIAS, please activate to load 3D Models.";
530  wxMessageBox(AsciiToWx(text.str()),wxT("Error"), wxOK | wxICON_ERROR, this);
531 #endif
532 }
533 
534 /****************************************************
535  @brief
536 
537 
538  *****************************************************/
539 void BIASOpenGLViewerFrame::OnQuit(wxCloseEvent& event) {
540  wxCommandEvent e;
541  OnExit(e);
542 }
543 /****************************************************
544  @brief
545 
546 
547  *****************************************************/
548 void BIASOpenGLViewerFrame::OnExit(wxCommandEvent& /*event*/) {
549  Destroy();
550 }
551 /****************************************************
552  @brief
553 
554 
555  *****************************************************/
556 void BIASOpenGLViewerFrame::
557 OnFullscreen(wxCommandEvent& event) {
558  ShowFullScreen(!IsFullScreen(), wxFULLSCREEN_NOCAPTION | wxFULLSCREEN_NOSTATUSBAR);
559  menuItemFullscreen_->Check(IsFullScreen());
560 }
561 
562 void BIASOpenGLViewerFrame::
563 OnScreenshot(wxCommandEvent& event){
564  bool ret = screenShotControl_.StoreScreenShot();
565  if(ret == false){
566  stringstream text;
567  text<<"Storing screenshot failed.";
568  wxMessageBox(AsciiToWx(text.str()),wxT("Error"), wxOK | wxICON_ERROR, this);
569  }
570 }
571 
572 void BIASOpenGLViewerFrame::
573 OnViewSolid( wxCommandEvent& event ){
574 
575  glPolygonMode( GL_FRONT_AND_BACK, GL_FILL);
576  //cout << "PolygonMode: Fill." << endl;
577  menuItemSolid_->Check(true);
578  menuItemPoints_->Check(false);
579  menuItemLines_->Check(false);
580 }
581 
582 void BIASOpenGLViewerFrame::
583 OnViewLines( wxCommandEvent& event ){
584  glPolygonMode( GL_FRONT_AND_BACK, GL_LINE);
585  //cout << "PolygonMode: Line." << endl;
586  menuItemSolid_->Check(false);
587  menuItemPoints_->Check(false);
588  menuItemLines_->Check(true);
589 }
590 
591 void BIASOpenGLViewerFrame::
592 OnViewPoints( wxCommandEvent& event ){
593  glPolygonMode( GL_FRONT_AND_BACK, GL_POINT);
594  //cout << "PolygonMode: Point." << endl;
595  menuItemSolid_->Check(false);
596  menuItemPoints_->Check(true);
597  menuItemLines_->Check(false);
598 }
599 ////////////////////////////////////////////////////////////////////////////////////////
600 ////////////////////////////////////////////////////////////////////////////////////////
601 ////////////////////////////////////////////////////////////////////////////////////////
602 class BIASOpenGLViewerApp: public wxApp
603 {
604  virtual bool OnInit();
605 };
606 
607 
608 //declaration
609 DECLARE_APP(BIASOpenGLViewerApp)
610 
611 // implementation
612 IMPLEMENT_APP(BIASOpenGLViewerApp)
613 
614 bool BIASOpenGLViewerApp::OnInit()
615 {
616  // utility: create a Redirection console for cout, cerr etc.
617  //ConsoleRedirectIO("BIASOpenGLViewer");
618 
619  string fileName= "BIASOpenGLViewer.param";
620 
621  wxSize guiSize(640,480);
622  BIASOpenGLViewerFrame *frame_=NULL;
623  frame_ = new BIASOpenGLViewerFrame(NULL,-1,_T("BIAS OpenGLViewerWx"),wxPoint(0,0),guiSize);
624 
625  frame_->SetParameterFile(argc,WxToAsciiArray(argv,argc),fileName);
626  frame_->Show(true);
627  return TRUE;
628 }
wxString AsciiToWx(const char *thestring)
Converts a C string to a wxString.
Definition: StringConv.hh:32
Class BIASOpenGLViewerFrame.
rescale internal projection parameters preserving aspect ratio and scale by integer values only...
Context implementation for wxWidgets.
Definition: ContextWX.hh:31
void SetParameterFile(int argc, char **argv, std::string &paramFile)
int ResetSceneCenter(BIAS::Vector3< double > *C=NULL, BIAS::Quaternion< double > *Q=NULL)
Class for converting an array of wxStrings to an array of non-const ASCII strings.
Definition: StringConv.hh:60
void ParameterChanged(const std::string &paramname, const void *data)
class for rendering with projection parameters of ProjectionParametersPerspective ...