Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
SimpleGLFrame.cpp
1 #ifdef WIN32
2 # pragma warning (disable: 4005) // for VS8 + WX
3 #endif
4 
5 #include "SimpleGLFrame.hh"
6 
7 using namespace std;
8 using namespace BIAS;
9 
10 // initialize globals
11 int BIASSimpleGLApp_EXPORT BIAS::SimpleGLFrame::mode=0;
12 int BIASSimpleGLApp_EXPORT BIAS::SimpleGLFrame::label=0;
13 int BIASSimpleGLApp_EXPORT BIAS::SimpleGLFrame::flag=0;
14 
15 
16 // --------------------------------------------------------
17 BEGIN_EVENT_TABLE(BIAS::SimpleGLFrame, wxFrame)
18 EVT_MENU(ID_QUIT, SimpleGLFrame::OnQuit)
19 EVT_MENU(ID_ABOUT, SimpleGLFrame::OnAbout)
20 EVT_MENU(ID_MODE_PLUS, SimpleGLFrame::OnInteraction)
21 EVT_MENU(ID_MODE_MINUS, SimpleGLFrame::OnInteraction)
22 EVT_MENU(ID_LABEL_PLUS, SimpleGLFrame::OnInteraction)
23 EVT_MENU(ID_LABEL_MINUS, SimpleGLFrame::OnInteraction)
24 EVT_MENU(ID_FLAG_PLUS, SimpleGLFrame::OnInteraction)
25 EVT_MENU(ID_FLAG_MINUS, SimpleGLFrame::OnInteraction)
26 END_EVENT_TABLE()
27 // --------------------------------------------------------
28 
29 BIAS::SimpleGLFrame::SimpleGLFrame(const wxString & title,
30  const wxPoint & pos, const wxSize & size)
31  :wxFrame((wxFrame *) NULL, -1, title, pos, size)
32  ,pCanvas(NULL)
33 {
34  // Create a simple top Menu
35  wxMenu *menuFile = new wxMenu;
36  menuFile->Append(ID_ABOUT, _T("&About...") );
37  menuFile->AppendSeparator();
38  menuFile->Append(ID_QUIT, _T("E&xit") );
39 
40  wxMenu *menuInteraction = new wxMenu;
41  menuInteraction->Append(ID_MODE_PLUS, _T("&1 mode++...\tCtrl-1") );
42  menuInteraction->Append(ID_MODE_MINUS, _T("&2 mode--...\tCtrl-2") );
43  menuInteraction->Append(ID_LABEL_PLUS, _T("&3 label++...\tCtrl-3") );
44  menuInteraction->Append(ID_LABEL_MINUS,_T("&4 label--...\tCtrl-4") );
45  menuInteraction->Append(ID_FLAG_PLUS, _T("&5 flag++...\tCtrl-5") );
46  menuInteraction->Append(ID_FLAG_MINUS, _T("&6 flag--...\tCtrl-6") );
47 
48  menuInteraction->AppendSeparator();
49 
50  wxMenuBar *menuBar = new wxMenuBar;
51  menuBar->Append(menuFile, _T("&File") );
52  menuBar->Append(menuInteraction, _T("&Interaction") );
53  SetMenuBar(menuBar);
54 
55  // Create a simple bottom status bar
56  CreateStatusBar(1);
57 
58  // Canvas to test:
59  pCanvas = new SimpleGLCanvas(this);
60 
61  // put them into sizers:
62  wxBoxSizer *sizer = new wxBoxSizer(wxHORIZONTAL);
63  sizer->Add(pCanvas, 1, wxEXPAND | wxALL);
64 #if wxCHECK_VERSION(2, 6, 2)
65  sizer->AddSpacer(4); // available in 2.6.2 but not 2.4.2 (JW)
66 #endif
67 
68  // limit min. size:
69  sizer->SetItemMinSize(pCanvas, 500, 400);
70  sizer->SetSizeHints(this);
71 
72  // set sizer and triggers Layout()
73  SetSizerAndFit(sizer);
74 }
75 
76 
77 void BIAS::SimpleGLFrame::OnQuit(wxCommandEvent &)
78 {
79  Close(TRUE);
80 }
81 
82 
83 void BIAS::SimpleGLFrame::OnAbout(wxCommandEvent &)
84 {
85  wxString title( _T("About") );
86  stringstream msg;
87  msg << "About - " << FUNCNAME << "\n";
88  msg << "author: Jan Woetzel (c) 2003-2006\n";
89  msg << "build: " << __DATE__ << " " << __TIME__ << "\n";
90  msg << "from " << __FILE__ << "\n";
91  msg << "GUI using: " << wxVERSION_STRING << "\n";
92  msg << "\n";
93  COUT(msg.str());
94  wxMessageBox(wxString(msg.str().c_str(), wxConvUTF8), title, wxICON_INFORMATION | wxOK);
95 }
96 
97 void BIAS::SimpleGLFrame::OnInteraction(wxCommandEvent & event){
98  switch(event.GetId()){
99  case ID_MODE_PLUS: mode++; break;
100  case ID_MODE_MINUS: mode--; break;
101  case ID_LABEL_PLUS: label++; break;
102  case ID_LABEL_MINUS: label--; break;
103  case ID_FLAG_PLUS: flag++; break;
104  case ID_FLAG_MINUS: flag--; break;
105 
106  //default:;
107  }
108  stringstream ss;
109  ss<<"mode="<<mode<<" label="<<label<<" flag="<<flag<<" ";
110  cout<<ss.str()<<endl;
111  SetStatusText( wxString(ss.str().c_str(), wxConvUTF8) );
112 }
void OnAbout(wxCommandEvent &event)
void OnInteraction(wxCommandEvent &event)
Helper frame for SimplaGLApp.
Helper canvas for SimpleGLApp
static int mode
(global) params for simple user interaction with client Display routine
void OnQuit(wxCommandEvent &event)