FaceTracker2
VisionExample.cpp
1 // VisionExample.cpp : Defines the class behaviors for the application.
2 //
3 
4 #include "stdafx.h"
5 #include "VisionExample.h"
6 #include "MainFrm.h"
7 #include "VisionExampleDoc.h"
8 #include "OpenGLWndFaceTracker.h"
9 
10 #ifdef _DEBUG
11 #define new DEBUG_NEW
12 #undef THIS_FILE
13 static char THIS_FILE[] = __FILE__;
14 #endif
15 
16 /////////////////////////////////////////////////////////////////////////////
17 // CVisionExampleApp
18 
19 BEGIN_MESSAGE_MAP(CVisionExampleApp, CWinApp)
20  //{{AFX_MSG_MAP(CVisionExampleApp)
21  ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
22  // NOTE - the ClassWizard will add and remove mapping macros here.
23  // DO NOT EDIT what you see in these blocks of generated code!
24  //}}AFX_MSG_MAP
25  // Standard file based document commands
26  ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
27  ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
28  // Standard print setup command
29  ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
30 END_MESSAGE_MAP()
31 
32 /////////////////////////////////////////////////////////////////////////////
33 // CVisionExampleApp construction
34 
35 CVisionExampleApp::CVisionExampleApp()
36 {
37  // TODO: add construction code here,
38  // Place all significant initialization in InitInstance
39 }
40 
41 /////////////////////////////////////////////////////////////////////////////
42 // The one and only CVisionExampleApp object
43 
44 CVisionExampleApp theApp;
45 
46 /////////////////////////////////////////////////////////////////////////////
47 // CVisionExampleApp initialization
48 
49 BOOL CVisionExampleApp::InitInstance()
50 {
51  visageFolderManager.init();
52 
53  // Standard initialization
54  // If you are not using these features and wish to reduce the size
55  // of your final executable, you should remove from the following
56  // the specific initialization routines you do not need.
57 
58 #ifdef _AFXDLL
59 // Enable3dControls(); // Call this when using MFC in a shared DLL
60 #else
61 // Enable3dControlsStatic(); // Call this when linking to MFC statically
62 #endif
63 
64  // Change the registry key under which our settings are stored.
65  // TODO: You should modify this string to be something appropriate
66  // such as the name of your company or organization.
67  SetRegistryKey(_T("Local AppWizard-Generated Applications"));
68 
69  LoadStdProfileSettings(); // Load standard INI file options (including MRU)
70 
71  // Register the application's document templates. Document templates
72  // serve as the connection between documents, frame windows and views.
73 
74  CSingleDocTemplate* pDocTemplate;
75  pDocTemplate = new CSingleDocTemplate(
76  IDR_MAINFRAME,
77  RUNTIME_CLASS(CVisionExampleDoc),
78  RUNTIME_CLASS(CMainFrame), // main SDI frame window
79  RUNTIME_CLASS(COpenGLWnd));
80  AddDocTemplate(pDocTemplate);
81 
82  // Parse command line for standard shell commands, DDE, file open
83  CCommandLineInfo cmdInfo;
84  ParseCommandLine(cmdInfo);
85 
86  // Dispatch commands specified on the command line
87  if (!ProcessShellCommand(cmdInfo))
88  return FALSE;
89 
90  // The one and only window has been initialized, so show and update it.
91  m_pMainWnd->ShowWindow(SW_SHOW);
92  m_pMainWnd->UpdateWindow();
93 
94  CMainFrame* pMainWnd = (CMainFrame*)AfxGetMainWnd();
95  pMainWnd->GetDocument()->init();
96 
97  return TRUE;
98 }
99 
100 
101 /////////////////////////////////////////////////////////////////////////////
102 // CAboutDlg dialog used for App About
103 
104 class CAboutDlg : public CDialog
105 {
106 public:
107  CAboutDlg();
108 
109 // Dialog Data
110  //{{AFX_DATA(CAboutDlg)
111  enum { IDD = IDD_ABOUTBOX };
112  //}}AFX_DATA
113 
114  // ClassWizard generated virtual function overrides
115  //{{AFX_VIRTUAL(CAboutDlg)
116  protected:
117  virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
118  //}}AFX_VIRTUAL
119 
120 // Implementation
121 protected:
122  //{{AFX_MSG(CAboutDlg)
123  // No message handlers
124  //}}AFX_MSG
125  DECLARE_MESSAGE_MAP()
126 };
127 
128 CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
129 {
130  //{{AFX_DATA_INIT(CAboutDlg)
131  //}}AFX_DATA_INIT
132 }
133 
134 void CAboutDlg::DoDataExchange(CDataExchange* pDX)
135 {
136  CDialog::DoDataExchange(pDX);
137  //{{AFX_DATA_MAP(CAboutDlg)
138  //}}AFX_DATA_MAP
139 }
140 
141 BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
142  //{{AFX_MSG_MAP(CAboutDlg)
143  // No message handlers
144  //}}AFX_MSG_MAP
145 END_MESSAGE_MAP()
146 
147 // App command to run the dialog
148 void CVisionExampleApp::OnAppAbout()
149 {
150  CAboutDlg aboutDlg;
151  aboutDlg.DoModal();
152 }
153 
154 /////////////////////////////////////////////////////////////////////////////
155 // CVisionExampleApp message handlers
156 
The document.
void init()
Initialise.
The OpenGL-enabled window with rendering and basic interaction.