+++ /dev/null
-/*M///////////////////////////////////////////////////////////////////////////////////////\r
-//\r
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.\r
-//\r
-// By downloading, copying, installing or using the software you agree to this license.\r
-// If you do not agree to this license, do not download, install,\r
-// copy or use the software.\r
-//\r
-//\r
-// Intel License Agreement\r
-// For Open Source Computer Vision Library\r
-//\r
-// Copyright (C) 2000, Intel Corporation, all rights reserved.\r
-// Third party copyrights are property of their respective owners.\r
-//\r
-// Redistribution and use in source and binary forms, with or without modification,\r
-// are permitted provided that the following conditions are met:\r
-//\r
-// * Redistribution's of source code must retain the above copyright notice,\r
-// this list of conditions and the following disclaimer.\r
-//\r
-// * Redistribution's in binary form must reproduce the above copyright notice,\r
-// this list of conditions and the following disclaimer in the documentation\r
-// and/or other materials provided with the distribution.\r
-//\r
-// * The name of Intel Corporation may not be used to endorse or promote products\r
-// derived from this software without specific prior written permission.\r
-//\r
-// This software is provided by the copyright holders and contributors "as is" and\r
-// any express or implied warranties, including, but not limited to, the implied\r
-// warranties of merchantability and fitness for a particular purpose are disclaimed.\r
-// In no event shall the Intel Corporation or contributors be liable for any direct,\r
-// indirect, incidental, special, exemplary, or consequential damages\r
-// (including, but not limited to, procurement of substitute goods or services;\r
-// loss of use, data, or profits; or business interruption) however caused\r
-// and on any theory of liability, whether in contract, strict liability,\r
-// or tort (including negligence or otherwise) arising in any way out of\r
-// the use of this software, even if advised of the possibility of such damage.\r
-//\r
-//M*/// MainFrm.cpp : implementation of the CMainFrame class\r
-//\r
-\r
-#include "stdafx.h"\r
-#include "StereoGR.h"\r
-\r
-#include "MainFrm.h"\r
-#include "StereoGRDoc.h"\r
-#include "StereoGRView.h"\r
-\r
-#ifdef _DEBUG\r
-#define new DEBUG_NEW\r
-#undef THIS_FILE\r
-static char THIS_FILE[] = __FILE__;\r
-#endif\r
-\r
-/////////////////////////////////////////////////////////////////////////////\r
-// CMainFrame\r
-\r
-IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWnd)\r
-\r
-BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)\r
- //{{AFX_MSG_MAP(CMainFrame)\r
- ON_WM_CREATE()\r
- ON_WM_TIMER()\r
- ON_COMMAND(ID_DGRECOG, OnDgRecog)\r
- ON_UPDATE_COMMAND_UI(ID_DGRECOG, OnUpdateDgrecog)\r
- ON_WM_CLOSE()\r
- //}}AFX_MSG_MAP\r
-END_MESSAGE_MAP()\r
-\r
-static UINT indicators[] =\r
-{\r
- ID_SEPARATOR, // status line indicator\r
- ID_SEPARATOR,\r
- ID_SEPARATOR,\r
- ID_INDICATOR_NUM,\r
- ID_INDICATOR_SCRL,\r
-};\r
-\r
-/////////////////////////////////////////////////////////////////////////////\r
-// CMainFrame construction/destruction\r
-\r
-CMainFrame::CMainFrame()\r
-{\r
- m_isTimerStarted = FALSE;\r
- m_drawCount = 0;\r
-}\r
-\r
-CMainFrame::~CMainFrame()\r
-{\r
-}\r
-\r
-int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)\r
-{\r
- if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)\r
- return -1;\r
- \r
- if (!m_wndToolBar.CreateEx(this) ||\r
- !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))\r
- {\r
- TRACE0("Failed to create toolbar\n");\r
- return -1; // fail to create\r
- }\r
- if (!m_wndDlgBar.Create(this, IDR_MAINFRAME, \r
- CBRS_ALIGN_TOP, AFX_IDW_DIALOGBAR))\r
- {\r
- TRACE0("Failed to create dialogbar\n");\r
- return -1; // fail to create\r
- }\r
-\r
- if (!m_wndReBar.Create(this) ||\r
- !m_wndReBar.AddBar(&m_wndToolBar) ||\r
- !m_wndReBar.AddBar(&m_wndDlgBar))\r
- {\r
- TRACE0("Failed to create rebar\n");\r
- return -1; // fail to create\r
- }\r
-\r
- if (!m_wndStatusBar.Create(this) ||\r
- !m_wndStatusBar.SetIndicators(indicators,\r
- sizeof(indicators)/sizeof(UINT)))\r
- {\r
- TRACE0("Failed to create status bar\n");\r
- return -1; // fail to create\r
- }\r
-\r
- // TODO: Remove this if you don't want tool tips\r
- m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |\r
- CBRS_TOOLTIPS | CBRS_FLYBY);\r
-\r
- ShowControlBar(&m_wndToolBar, SW_SHOW, FALSE);\r
- ShowControlBar(&m_wndDlgBar, SW_HIDE, FALSE);\r
-\r
- m_menu.LoadMenu(IDR_STEREOTYPE);\r
- SetMenu(&m_menu);\r
- return 0;\r
-}\r
-\r
-BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)\r
-{\r
- if( !CMDIFrameWnd::PreCreateWindow(cs) )\r
- return FALSE;\r
- // TODO: Modify the Window class or styles here by modifying\r
- // the CREATESTRUCT cs\r
-\r
- return TRUE;\r
-}\r
-\r
-/////////////////////////////////////////////////////////////////////////////\r
-// CMainFrame diagnostics\r
-\r
-#ifdef _DEBUG\r
-void CMainFrame::AssertValid() const\r
-{\r
- CMDIFrameWnd::AssertValid();\r
-}\r
-\r
-void CMainFrame::Dump(CDumpContext& dc) const\r
-{\r
- CMDIFrameWnd::Dump(dc);\r
-}\r
-\r
-#endif //_DEBUG\r
-\r
-/////////////////////////////////////////////////////////////////////////////\r
-// CMainFrame message handlers\r
-\r
-\r
-CStatusBar* CMainFrame::GetStatusBar()\r
-{\r
- return &m_wndStatusBar;\r
-}\r
-\r
-void CMainFrame::AddView(CStereoGRView *pView)\r
-{\r
- int id = pView->GetDocument()->GetDocType();\r
- STEREOGRAPP(app)\r
- app->SetView(id, pView);\r
- if(!m_isTimerStarted)\r
- {\r
- SetTimer(1, 1, 0);\r
- m_isTimerStarted = TRUE;\r
- }\r
-\r
- m_drawCount = 0;\r
-}\r
-\r
-void CMainFrame::OnTimer(UINT nIDEvent) \r
-{\r
- Update();\r
- CMDIFrameWnd::OnTimer(nIDEvent);\r
-}\r
-\r
-void CMainFrame::Update()\r
-{\r
- /* Count the frame rate */\r
- float fps = CountRate();\r
- CString str;\r
- str.Format("%.1f frames per second", fps);\r
- // This feature is disabled in the current release\r
-// m_wndStatusBar.SetPaneText(0, LPCTSTR(str));\r
-\r
- STEREOGRAPP(app)\r
- app->Update();\r
-}\r
-\r
-void CMainFrame::RemoveView(CStereoGRView *pView)\r
-{\r
- int id = pView->GetDocument()->GetDocType();\r
- STEREOGRAPP(app);\r
- app->SetView(id, 0);\r
- int* viewIds = app->GetViewIDs();\r
- viewIds[id] = 0;\r
-\r
- m_drawCount = 0;\r
-}\r
-\r
-void CMainFrame::InitializeMenu()\r
-{\r
- CMenu* pMenu = GetMenu();\r
- pMenu = pMenu->GetSubMenu(1);\r
-// pMenu->InsertMenu(0, MF_BYPOSITION | MF_STRING, 1100, "Test");\r
-}\r
-\r
-\r
-BOOL CMainFrame::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo) \r
-{\r
- CStereoGRApp* app = (CStereoGRApp*)AfxGetApp();\r
- int* viewIds = app->GetViewIDs();\r
- if(pHandlerInfo == 0)\r
- {\r
- if(nID >= ID_VIEW1 && nID <= ID_VIEW12)\r
- {\r
- int id = nID - ID_VIEW1;\r
- if(nCode == CN_COMMAND)\r
- {\r
- viewIds[id] = !viewIds[id];\r
- CStereoGRApp* app = (CStereoGRApp*)AfxGetApp();\r
- if(viewIds[id])\r
- {\r
- app->OpenView(id);\r
- }\r
- else\r
- {\r
- app->CloseView(id);\r
- }\r
- return TRUE;\r
- }\r
- else if(nCode == CN_UPDATE_COMMAND_UI)\r
- {\r
- CCmdUI* pCmdUI = (CCmdUI*)pExtra;\r
- if((nID >= ID_VIEW1 && nID <= ID_VIEW6) || nID == ID_VIEW8 || (nID >= ID_VIEW10 && nID <= ID_VIEW12))\r
- {\r
- pCmdUI->Enable();\r
- pCmdUI->SetCheck(viewIds[id]);\r
- }\r
- else\r
- {\r
- pCmdUI->Enable(FALSE);\r
- }\r
- return TRUE;\r
- }\r
-\r
- }\r
- }\r
-\r
- return CMDIFrameWnd::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);\r
-}\r
-\r
-\r
-float CMainFrame::CountRate()\r
-{\r
- if(!m_drawCount)\r
- {\r
- m_time = GetTickCount();\r
- m_drawCount++;\r
- return 0;\r
- }\r
- \r
- long time = GetTickCount();\r
- if(time == m_time)\r
- {\r
- return 0;\r
- }\r
-\r
- float fps = 1000.0f*m_drawCount/(GetTickCount() - m_time);\r
- m_drawCount++;\r
-\r
- return fps;\r
-}\r
-\r
-void CMainFrame::OnDgRecog() \r
-{\r
- CStereoGRApp* app = ((CStereoGRApp*)AfxGetApp());\r
-\r
- app->m_doRecog = !app->m_doRecog;\r
-\r
- //CButton* pbut = (CButton*)GetDlgItem( ID_DGRECOG );\r
- //pbut->SetCheck( app->m_doRecog ); \r
-\r
- // TODO: Add your command handler code here \r
-}\r
-\r
-void CMainFrame::OnUpdateDgrecog(CCmdUI* pCmdUI) \r
-{\r
- CStereoGRApp* app = ((CStereoGRApp*)AfxGetApp());\r
-\r
- //CButton* pbut = (CButton*)pCmdUI;\r
- pCmdUI->SetCheck( app->m_doRecog ); \r
- \r
- // TODO: Add your command update UI handler code here\r
- \r
-}\r
-\r
-void CMainFrame::OnClose() \r
-{\r
- STEREOGRAPP(app)\r
-\r
- for(int i = 0; i < VIEWS_COUNT; i++)\r
- {\r
- if(app->GetView(i) == 0)\r
- continue;\r
-\r
- CString str;\r
- str.Format("Settings\\StereoGR\\View%d", i);\r
- int x = 0, y = 0;\r
- RECT viewRect;\r
- RECT clientRect;\r
- GetClRect(&clientRect);\r
- ClientToScreen(&clientRect);\r
- app->GetView(i)->GetParent()->GetWindowRect(&viewRect);\r
- x = viewRect.left - clientRect.left;\r
- y = viewRect.top - clientRect.top;\r
- app->WriteProfileInt(LPCTSTR(str), "left", x);\r
- app->WriteProfileInt(LPCTSTR(str), "top", y);\r
- }\r
- \r
- app->SaveSettings();\r
- CMDIFrameWnd::OnClose();\r
-}\r
-\r
-BOOL CMainFrame::DestroyWindow() \r
-{\r
- \r
- \r
- return CMDIFrameWnd::DestroyWindow();\r
-}\r
-\r
-void CMainFrame::GetClRect( LPRECT lpRect ) const\r
-{\r
- CWnd::GetWindowRect(lpRect);\r
- CRect toolbarRect;\r
- m_wndToolBar.GetWindowRect(&toolbarRect);\r
- lpRect->top += toolbarRect.Size().cy;\r
-}\r