Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ExampleOpenGLCanvasBase.cpp
1 /** Simple example for BIAS::OpenGLCanvas(Base) usage.
2 @author: Jan Woetzel */
3 
4 //#include <Base/Common/LeakChecking.h>
5 
6 #include "ExampleOpenGLCanvasBase.hh"
7 
8 // BIAS
9 #include <Gui/ConsoleRedirectIO.hh>
10 
11 using namespace std;
12 
13 // required for wx RTTI dynamic construction:
14 IMPLEMENT_APP(ExampleOpenGLCanvasApp)
15 
16 
17 // --------------------------------------------------------
18 bool ExampleOpenGLCanvasApp::OnInit()
19 {
20  // utility: create a Redirection console for cout, cerr etc.
22  // testing output:
23  cout<<"Hallo cout"<<endl;
24  cout<<"Hallo cerr"<<endl;
25 
26  MyFrame *frame = new MyFrame( wxT("ExampleOpenGLCanvasBase"), wxPoint(0,0), wxSize(640,480) );
27  frame->Show(TRUE);
28  wxLogGui log;
29  SetTopWindow(frame);
30 
31  return TRUE;
32 }
33 
34 
35 // --------------------------------------------------------
36 BEGIN_EVENT_TABLE(MyFrame, wxFrame)
37 EVT_MENU(ID_QUIT, MyFrame::OnQuit)
38 EVT_MENU(ID_ABOUT, MyFrame::OnAbout)
39 END_EVENT_TABLE()
40 // --------------------------------------------------------
41 
42 
43 MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
44 : wxFrame((wxFrame *)NULL, -1, title, pos, size)
45 ,p_canvas(NULL)
46 {
47  // Create a simple top Menu
48  wxMenu *menuFile = new wxMenu;
49  menuFile->Append( ID_ABOUT, wxT("&About...") );
50  menuFile->AppendSeparator();
51  menuFile->Append( ID_QUIT, wxT("E&xit") );
52  wxMenuBar *menuBar = new wxMenuBar;
53  menuBar->Append(menuFile, wxT("&File"));
54  SetMenuBar(menuBar);
55 
56  // Create a simple bottom status bar
57  CreateStatusBar(3);
58 
59  // Canvas to test:
60  p_canvas=new BIAS::OpenGLCanvasBase(this, -1);
61 
62 }
63 
64 
65 void MyFrame::OnQuit(wxCommandEvent& ){
66  Close(TRUE);
67 }
68 
69 
70 void MyFrame::OnAbout(wxCommandEvent& )
71 {
72  wxString title(wxT("About"));
73  wxString msg; // message
74  msg<<wxT("About - ")<<AsciiToWx(FUNCNAME)<<wxT("\n");
75  msg<<wxT("author: Jan Woetzel (c) 2003-2005\n");
76  msg<<wxT("build: ")<<AsciiToWx(__DATE__)<<wxT(" ")<<AsciiToWx(__TIME__)<<wxT("\n");
77  msg<<wxT("from ")<<AsciiToWx(__FILE__)<<wxT("\n");
78  msg<<wxT("GUI using: ")<<wxVERSION_STRING<<wxT("\n");
79  msg<<wxT("\n");
80  COUT(msg);
81  wxMessageBox(msg, title, wxICON_INFORMATION | wxOK );
82 }
83 
void BIASGui_EXPORT ConsoleRedirectIO(std::string name=std::string(""))
Extra Console for WIN32 WinMain gui applications.
wxString AsciiToWx(const char *thestring)
Converts a C string to a wxString.
Definition: StringConv.hh:32
base class for OpenGL canvases you could derive from to get base functionality (JW) ...