⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 demo.cpp

📁 Intel开发的IPP库的应用例程
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/*
//
//               INTEL CORPORATION PROPRIETARY INFORMATION
//  This software is supplied under the terms of a license agreement or
//  nondisclosure agreement with Intel Corporation and may not be copied
//  or disclosed except in accordance with the terms of that agreement.
//        Copyright(c) 1999-2007 Intel Corporation. All Rights Reserved.
//
*/

// Demo.cpp : implementation of the CDemo class
//
/////////////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "demo.h"
#include "DemoDoc.h"
#include "Process.h"
#include "Director.h"

#include "MainFrm.h"
//#include "OptLibSheet.h"
//#include "OptLibPage.h"
#include "Timing.h"
#include "AboutDlg.h"
#include "DragDrop.h"
#include "ListPage.h"
#include "Lib.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
//
// CDemoApp: base class for ippiDemo / ippsDemo MFC applications
//
/////////////////////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////////////////////////
// Virtual attributes

//----------------------------------------------------------------------------
// GetVersionString returns current version of Demo appllication
//----------------------------------------------------------------------------
CString CDemoApp::GetVersionString() const { return _T("5.2");}

//----------------------------------------------------------------------------
// GetCopyrightLastYear returns the current year
//----------------------------------------------------------------------------
int CDemoApp::GetCopyrightLastYear() const { return 2007;}

BEGIN_MESSAGE_MAP(CDemoApp, CWinApp)
    //{{AFX_MSG_MAP(CDemoApp)
   ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
   ON_COMMAND(ID_FILE_OPEN, OnFileOpen)
    ON_UPDATE_COMMAND_UI(ID_OPT_LIB, OnUpdateOptLib)
    ON_COMMAND(ID_OPT_LIB, OnOptLib)
    ON_UPDATE_COMMAND_UI(ID_OPT_OUTSTAND, OnUpdateOptOutstand)
    ON_COMMAND(ID_OPT_OUTSTAND, OnOptOutstand)
    ON_COMMAND(ID_OPT_TIMING, OnOptTiming)
   ON_UPDATE_COMMAND_UI(ID_PICK_DST, OnUpdatePickDst)
   ON_COMMAND(ID_PICK_DST, OnPickDst)
    ON_UPDATE_COMMAND_UI(ID_PROCESS_STOP, OnUpdateProcessStop)
    ON_COMMAND(ID_PROCESS_STOP, OnProcessStop)
   ON_COMMAND(ID_WINDOW_CLOSEALL, OnWindowCloseall)
    //}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDemoApp construction

CDemoApp::CDemoApp()
{
   m_pLib = NULL;
   m_pRecentFuncList = new CRecentFuncList;
   m_pIppList = NULL;;
   m_pDirector = NULL;

   m_OptLibPage = 0;
   m_PickMode = FALSE;
   m_PickDst = FALSE;

   m_hCross = 0;
   m_hArrow = 0;
   m_hWait  = 0;
   m_hPick  = 0;
   m_hGrab  = 0;

   m_pDropSource = NULL;
   m_DropFormat = 0;

   m_CurrProcess = 0;
   m_CurrBook = 0;
   m_CurrChapter = 0;

}

CDemoApp::~CDemoApp()
{
   delete m_pRecentFuncList;
}
/////////////////////////////////////////////////////////////////////////////
// General Demo Operations

//----------------------------------------------------------------------------
// InitInstance is called at the beginning of MFC application.
// Besides of standard MFC initialization it loads IPP libraries and
// creates the list of IPP functions that will be called
//----------------------------------------------------------------------------
BOOL CDemoApp::InitInstance()
{
   CSExcept::InitTranslator();

   AfxEnableControlContainer();
   m_hArrow = LoadStandardCursor(IDC_ARROW);
   m_hCross = LoadStandardCursor(IDC_CROSS);
   m_hWait  = LoadStandardCursor(IDC_WAIT);
   m_hPick = m_hGrab = m_hArrow;

    // Standard initialization
    // If you are not using these features and wish to reduce the size
    //  of your final executable, you should remove from the following
    //  the specific initialization routines you do not need.

#ifdef _AFXDLL
    Enable3dControls();         // Call this when using MFC in a shared DLL
#else
    Enable3dControlsStatic();   // Call this when linking to MFC statically
#endif

    // Change the registry key under which our settings are stored.
    // TODO: You should modify this string to be something appropriate
    // such as the name of your company or organization.
//    SetRegistryKey(_T("Intel\0xAE Corporation"));

//   LoadStdProfileSettings(6);  // Load standard INI file options (including MRU)
   m_pDirector = CreateDirector();
//   LoadProfileSettings();

   CreateDocTemplates();

    // Init drag/drop
   if (OleInitialize(NULL) == S_OK) {
      m_pDropSource = new CDropSource;
      m_DropFormat = ::RegisterClipboardFormat(GetDropFormatString());
   }

    // create main MDI Frame window
   CMainFrame* pMainFrame = new CMainFrame;
   if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
      return FALSE;
   m_pMainWnd = pMainFrame;

    // The main window has been initialized, so show and update it.
    pMainFrame->ShowWindow(m_nCmdShow);
    pMainFrame->UpdateWindow();

   MAIN_FRAME->SetMessageText(_T("Loading libraries"));
   InitLibrary();
   MAIN_FRAME->SetMessageText(_T("Preparing function list"));
   InitFunctions();
   SetCurrentFunction();

    // Parse command line for standard shell commands, DDE, file open
    CCommandLineInfo cmdInfo;
    ParseCommandLine(cmdInfo);
    if (cmdInfo.m_bRunEmbedded || cmdInfo.m_bRunAutomated)
    {
        return TRUE;
    }
    DispatchCommands(cmdInfo);
    ProcessShellCommand(cmdInfo);

   MAIN_FRAME->SetMessageText(_T("Ready"));
    return TRUE;
}

//----------------------------------------------------------------------------
// ExitInstance is called at the end of MFC application 
//----------------------------------------------------------------------------
int CDemoApp::ExitInstance() 
{
   OleUninitialize( );
   SaveProfileSettings();
   return CWinApp::ExitInstance();
}

//----------------------------------------------------------------------------
// LoadProfileSettings loads application settings
//----------------------------------------------------------------------------
void CDemoApp::LoadProfileSettings()
{
//   m_CurrBook = GetProfileInt(_T("Main"),_T("Book"),0);
//   m_CurrChapter = GetProfileInt(_T("Main"),_T("Chapter"),0);
//   m_CurrFunc = GetProfileString(_T("Main"),_T("FuncName"),_T(""));
//   m_PickDst       = GetProfileInt(_T("Main"),_T("PickDst"),FALSE);
//
//   m_pLibList->LoadProfileSettings();
//   CTiming::LoadProfileSettings();
} 

//----------------------------------------------------------------------------
// SaveProfileSettings saves application settings
//----------------------------------------------------------------------------
void CDemoApp::SaveProfileSettings()
{
//   CProcess* pProcess = m_pDirector->GetProcess();
//   WriteProfileInt(_T("Main"),_T("Book"),pProcess->GetCurrentBook());
//   WriteProfileInt(_T("Main"),_T("Chapter"),pProcess->GetCurrentChapter());
//   WriteProfileString(_T("Main"),_T("FuncName"),pProcess->GetCurrentFunction());
//   WriteProfileInt(_T("Main"),_T("PickDst"),m_PickDst);
//
//   m_LibList.SaveProfileSettings();
//   CTiming::SaveProfileSettings();
}

//----------------------------------------------------------------------------
// InitLibrary is called by the CDemoApp::InitInstance.
// It loads demonstrated IPP libraries
//----------------------------------------------------------------------------
void CDemoApp::InitLibrary()
{
   m_pLib = new CLib[GetNumLibs()];
   if (m_pLib) {
      for (int i=0; i<GetNumLibs(); i++) {
         m_pLib[i].Init(GetLibPrefix(i));
      }
   }
}

//----------------------------------------------------------------------------
// InitFunctions is called by the CDemoApp::InitInstance.
// It creates the list of demonstrated IPP functions
//----------------------------------------------------------------------------
void CDemoApp::InitFunctions()
{
   m_pIppList = new CFuncList[GetNumLibs()];
   for (int i=0; i<GetNumLibs(); i++) 
      m_pIppList[i].CreateFuncList(i);
   m_pDirector->GetProcess()->InitFunctions();
}

//----------------------------------------------------------------------------
// CreateDirector creates new CDirector class 
//----------------------------------------------------------------------------
CDirector* CDemoApp::CreateDirector() const
{
   return new CDirector;
}

//----------------------------------------------------------------------------
// SetCurrentFunction sets IPP function that will be highlighted at the 
// beginning of Process dialog. Usually it is the last called IPP function.
//----------------------------------------------------------------------------
void CDemoApp::SetCurrentFunction() {
    m_pDirector->GetProcess()->SetCurrentFunction(
       m_CurrProcess, m_CurrBook,m_CurrChapter,m_CurrFunc);
}

/////////////////////////////////////////////////////////////////////////////
// Doc Managing Operations & Attributes

//----------------------------------------------------------------------------
// CreateDocTemplates creates document templates
//----------------------------------------------------------------------------
void CDemoApp::CreateDocTemplates()
{
   CMultiDocTemplate* pDocTemplate;
   pDocTemplate = new CMultiDocTemplate(
      IDR_IPP_TYPE,
      RUNTIME_CLASS(CDemoDoc),
      RUNTIME_CLASS(CMDIChildWnd), 
      RUNTIME_CLASS(CScrollView));
   AddDocTemplate(pDocTemplate);
}

//----------------------------------------------------------------------------
// GetFirstDocPosition returns the first document position to begin
// the iteration process
//----------------------------------------------------------------------------
MY_POSITION CDemoApp::GetFirstDocPosition() const
{
   MY_POSITION pos = {NULL,NULL};

   pos.tpl = GetFirstDocTemplatePosition( );
   if (!pos.tpl) return pos;
   while (pos.tpl) {
      POSITION tPos = pos.tpl;
      CDocTemplate* pTpl = GetNextDocTemplate(tPos);
      pos.doc = pTpl->GetFirstDocPosition( );
      if (pos.doc) break;
      pos.tpl = tPos;
   }
   return pos;
}

//----------------------------------------------------------------------------
// GetNextDoc returns pointer to the current document in the iteration 
// process and sets the next doc position to the pos
//----------------------------------------------------------------------------
CDemoDoc* CDemoApp::GetNextDoc(MY_POSITION& pos) const

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -