📄 demo.cpp
字号:
{
if (!pos) return NULL;
POSITION tPos = pos.tpl;
CDocTemplate* pTpl = GetNextDocTemplate(tPos);
CDemoDoc* pDoc = (CDemoDoc*)pTpl->GetNextDoc(pos.doc);
if (pos.doc == NULL) {
pos.tpl = tPos;
while (pos.tpl) {
CDocTemplate* pTpl = GetNextDocTemplate(tPos);
pos.doc = pTpl->GetFirstDocPosition( );
if (pos.doc) break;
pos.tpl = tPos;
}
}
return pDoc;
}
//----------------------------------------------------------------------------
// GetDocCount returns number of all opened MFC documents
//----------------------------------------------------------------------------
int CDemoApp::GetDocCount() const
{
MY_POSITION pos = GetFirstDocPosition();
int n = 0;
while (pos) {
GetNextDoc(pos);
n++;
}
return n;
}
//----------------------------------------------------------------------------
// FindDoc returns pointer to the document with the specified title
//----------------------------------------------------------------------------
CDemoDoc* CDemoApp::FindDoc(CString title) const
{
MY_POSITION pos;
pos = GetFirstDocPosition( );
while (pos) {
CDemoDoc* pDoc = GetNextDoc(pos);
if (pDoc->GetTitle() == title) return pDoc;
}
return NULL;
}
//----------------------------------------------------------------------------
// UpdateAllViews updates all views of all opened MFC documents
//----------------------------------------------------------------------------
void CDemoApp::UpdateAllViews()
{
MY_POSITION pos = GetFirstDocPosition();
while (pos)
GetNextDoc(pos)->UpdateView();
}
/////////////////////////////////////////////////////////////////////////////
// Message Boxes
//----------------------------------------------------------------------------
// MessageBox displays message box using CDemoApp::GetDemoTitle() fot title
//----------------------------------------------------------------------------
int CDemoApp::MessageBox(LPCTSTR lpszText, UINT nType, LPCTSTR title) const
{
return MAIN_FRAME->MessageBox(lpszText,
title ? title : AfxGetAppName(), nType);
}
//----------------------------------------------------------------------------
// ErrorMessage displays message box for error information
//----------------------------------------------------------------------------
BOOL CDemoApp::ErrorMessage(CString info) const
{
MAIN_FRAME->MessageBox(LPCTSTR(info), AfxGetAppName(), MB_OK|MB_ICONERROR);
return FALSE;
}
/////////////////////////////////////////////////////////////////////////////
// Attributes
//----------------------------------------------------------------------------
// GetLib returns pointer to class that serves IPP library with
// the specified index
//----------------------------------------------------------------------------
CLib* CDemoApp::GetLib(int idx) const {
if (m_pLib && idx < GetNumLibs()) return m_pLib + idx;
else return NULL;
}
//----------------------------------------------------------------------------
// GetLibHandle returns handle of exported IPP DLL with the specified
// index; it returns NULL if no library is exported (linked library is used
// in this case)
//----------------------------------------------------------------------------
HINSTANCE CDemoApp::GetLibHandle(int idx) const {
if (GetLib(idx) && idx < GetNumLibs())
return GetLib(idx)->GetHandle();
else
return NULL;
}
//----------------------------------------------------------------------------
// GetIppProc returns address of the specified exported IPP DLL function
// with specified library index; it returns NULL if no library is exported
// (common function call should be used in this case)
//----------------------------------------------------------------------------
FARPROC CDemoApp::GetIppProc(LPCTSTR name, int idx) const {
if (GetLib(idx) && idx < GetNumLibs())
return GetLib(idx)->GetProc(name);
else
return NULL;
}
//----------------------------------------------------------------------------
// ForCpu64 returns TRUE if Demo has been built for Win64 architecture
//----------------------------------------------------------------------------
BOOL CDemoApp::ForCpu64() const {
#ifdef WIN64
return TRUE;
#else
return FALSE;
#endif
}
/////////////////////////////////////////////////////////////////////////////
// Cursor Managing
//----------------------------------------------------------------------------
// RegCursorPick registrates cursor which appears while vector or (image)
// processing on the pick up document stage. Pick cursor means that some
// document have to be grabed but not the document beneath cursor. This cursor
// varies depending on wanted parameter name of IPP function
//----------------------------------------------------------------------------
void CDemoApp::RegCursorPick(UINT id)
{
m_hPick = LoadCursor(id);
}
//----------------------------------------------------------------------------
// RegCursorGrab registrates cursor which appears while vector or (image)
// processing on the pick up document stage. Grab cursor means that the
// document beneath cursor may be grabbed for processing. This cursor varies
// depending on wanted parameter name of IPP function
//----------------------------------------------------------------------------
void CDemoApp::RegCursorGrab(UINT id)
{
m_hGrab = LoadCursor(id);
}
/////////////////////////////////////////////////////////////////////////////
// Providing Drag & Drop Operations on Demo applications
//----------------------------------------------------------------------------
// GetDropFormatString returns Drop Format string
//----------------------------------------------------------------------------
CString CDemoApp::GetDropFormatString() const
{
return _T("IPP Vector");
}
/////////////////////////////////////////////////////////////////////////////
// CDemoApp message handlers
//----------------------------------------------------------------------------
// OnAppAbout displays About dialog
//----------------------------------------------------------------------------
void CDemoApp::OnAppAbout()
{
CAboutDlg dlg;
dlg.DoModal();
}
//----------------------------------------------------------------------------
// OnFileOpen opens file
//----------------------------------------------------------------------------
void CDemoApp::OnFileOpen()
{
CWinApp::OnFileOpen();
}
//----------------------------------------------------------------------------
// OnUpdateOptLib enables Menu-Options-Library command
//----------------------------------------------------------------------------
void CDemoApp::OnUpdateOptLib(CCmdUI* pCmdUI)
{
pCmdUI->Enable(ForCpu64() || (ippGetCpuType() < ippCpuITP));
}
//----------------------------------------------------------------------------
// OnOptLib performs Menu-Options-Library command
//----------------------------------------------------------------------------
void CDemoApp::OnOptLib()
{
//COptLibSheet sheet(_T("Choose IPP dll to use"));
//sheet.CreatePages(m_pLib,GetNumLibs());
//sheet.m_startPage = m_OptLibPage;
//if (sheet.DoModal() != IDOK)
// return;
//m_OptLibPage = sheet.m_startPage;
//for (int i=0; i<GetNumLibs(); i++) {
// COptLibPage* pPage = (COptLibPage*)sheet.GetPage(i);
// m_pLib[i].ChangeLib(pPage->m_LibType, pPage->m_PathStr);
//}
}
//----------------------------------------------------------------------------
// OnUpdateOptOutstand enables Menu-Options-Outstanding command
//----------------------------------------------------------------------------
void CDemoApp::OnUpdateOptOutstand(CCmdUI* pCmdUI)
{
int count = 0;
for (int i=0; i<GetNumLibs(); i++)
count += (int)(m_pIppList[i].GetOutstandList()->GetCount());
pCmdUI->Enable(count);
}
//----------------------------------------------------------------------------
// OnOptOutstand performs Menu-Options-Outstanding command
//----------------------------------------------------------------------------
void CDemoApp::OnOptOutstand()
{
int i;
CPropertySheet sheet(_T("Outstanding functions"));
for (i=0; i<GetNumLibs(); i++) {
CFuncList* pList = m_pIppList[i].GetOutstandList();
if (pList->GetCount() > 0) {
CListPage* pPage = new CListPage(GetLibTitle(i));
pPage->m_pFuncList = pList;
pPage->m_Name = GetLibTitle(i);
sheet.AddPage(pPage);
}
}
sheet.DoModal();
for (i=0; i<sheet.GetPageCount(); i++) {
delete sheet.GetPage(i);
}
}
//----------------------------------------------------------------------------
// OnOptTiming performs Menu-Options-Timing command
//----------------------------------------------------------------------------
void CDemoApp::OnOptTiming()
{
CTiming::DoTimingDialog();
}
//----------------------------------------------------------------------------
// OnUpdateProcessStop enables Menu-Process-StopProcessing command
//----------------------------------------------------------------------------
void CDemoApp::OnUpdateProcessStop(CCmdUI* pCmdUI)
{
pCmdUI->Enable(GetPickMode());
}
//----------------------------------------------------------------------------
// OnProcessStop performs Menu-Process-StopProcessing command
//----------------------------------------------------------------------------
void CDemoApp::OnProcessStop()
{
GetDirector()->StopProcess();
}
//----------------------------------------------------------------------------
// OnUpdatePickDst enables Toolbar-PickDst button
//----------------------------------------------------------------------------
void CDemoApp::OnUpdatePickDst(CCmdUI* pCmdUI)
{
pCmdUI->Enable(GetDocCount());
pCmdUI->SetCheck(m_PickDst);
}
//----------------------------------------------------------------------------
// OnPickDst performs Toolbar-PickDst command
//----------------------------------------------------------------------------
void CDemoApp::OnPickDst()
{
m_PickDst = !m_PickDst;
if (!m_PickDst && m_pDirector->GetRun() && m_pDirector->GetRun()->IsPickVecDst())
m_pDirector->PickNext();
}
//----------------------------------------------------------------------------
// OnWindowCloseall performs Menu-Window-CloseAll command
//----------------------------------------------------------------------------
void CDemoApp::OnWindowCloseall()
{
CloseAllDocuments(FALSE);
}
//----------------------------------------------------------------------------
// OnIdle performs idle-time processing
//----------------------------------------------------------------------------
BOOL CDemoApp::OnIdle(LONG lCount)
{
BOOL result = CWinApp::OnIdle(lCount);
CDemoDoc* pDoc = ACTIVE_DOC;
if (!pDoc) return result;
CWnd* pMessageBar = MAIN_FRAME->GetMessageBar();
CString message;
pMessageBar->GetWindowText(message);
if (message == "Ready")
pDoc->SetStatusString();
return result;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -