📄 ippsdemodoc.cpp
字号:
/*
//
// 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-2006 Intel Corporation. All Rights Reserved.
//
*/
// ippsDemoDoc.cpp : implementation of the CippsDemoDoc class
//
/////////////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "ippsDemo.h"
#include "ippsDemoDoc.h"
#include "ippsDemoView.h"
#include "ippsTextView.h"
#include "ippsCharView.h"
#include "ChildFrm.h"
#include "TextFrm.h"
#include "CharFrm.h"
#include "MainFrm.h"
#include "Process.h"
#include "Director.h"
#include "Histo.h"
#include "FilePropDlg.h"
#include "FileHistoDlg.h"
#include "ZoomDlg.h"
#include "StoreWav.h"
#include "StoreBmp.h"
#include "NewSignal.h"
#include "NewTaps.h"
#include "NewChar.h"
#include "StringDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CippsDemoDoc
IMPLEMENT_DYNCREATE(CippsDemoDoc, CDemoDoc)
BEGIN_MESSAGE_MAP(CippsDemoDoc, CDemoDoc)
//{{AFX_MSG_MAP(CippsDemoDoc)
ON_COMMAND(ID_FILE_PROP, OnFileProp)
ON_COMMAND(ID_ZOOM_HUP, OnZoomHup)
ON_COMMAND(ID_ZOOM_HLOW, OnZoomHlow)
ON_COMMAND(ID_ZOOM_WUP, OnZoomWup)
ON_COMMAND(ID_ZOOM_WLOW, OnZoomWlow)
ON_COMMAND(ID_ZOOM_CUSTOM, OnZoomCustom)
ON_COMMAND(ID_ZOOM_FITH, OnZoomFith)
ON_COMMAND(ID_ZOOM_FITW, OnZoomFitw)
ON_COMMAND(ID_ZOOM_STANDARD, OnZoomStandard)
ON_COMMAND(ID_ZOOM_CURRENT, OnZoomCurrent)
ON_UPDATE_COMMAND_UI(ID_WINDOW_PLOT, OnUpdateWindowPlot)
ON_UPDATE_COMMAND_UI(ID_WINDOW_TEXT, OnUpdateWindowText)
ON_COMMAND(ID_WINDOW_PLOT, OnWindowPlot)
ON_COMMAND(ID_WINDOW_TEXT, OnWindowText)
ON_UPDATE_COMMAND_UI(ID_ZOOM_CURRENT, OnUpdateZoom)
ON_UPDATE_COMMAND_UI(ID_ZOOM_HLOW, OnUpdateZoomHlow)
ON_UPDATE_COMMAND_UI(ID_ZOOM_WLOW, OnUpdateZoomWlow)
ON_UPDATE_COMMAND_UI(ID_FILE_SIGNED, OnUpdateFileSigned)
ON_COMMAND(ID_FILE_SIGNED, OnFileSigned)
ON_UPDATE_COMMAND_UI(ID_ZOOM_CUSTOM, OnUpdateZoom)
ON_UPDATE_COMMAND_UI(ID_ZOOM_FITH, OnUpdateZoom)
ON_UPDATE_COMMAND_UI(ID_ZOOM_FITW, OnUpdateZoom)
ON_UPDATE_COMMAND_UI(ID_ZOOM_HUP, OnUpdateZoom)
ON_UPDATE_COMMAND_UI(ID_ZOOM_STANDARD, OnUpdateZoom)
ON_UPDATE_COMMAND_UI(ID_ZOOM_WUP, OnUpdateZoom)
ON_COMMAND(ID_EDIT_INSERT, OnEditInsert)
//}}AFX_MSG_MAP
ON_UPDATE_COMMAND_UI(ID_WINDOW_CHAR, OnUpdateWindowChar)
ON_COMMAND(ID_WINDOW_CHAR, OnWindowChar)
ON_UPDATE_COMMAND_UI(ID_EDIT_INSERT, OnUpdateEditInsert)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CippsDemoDoc construction/destruction
CippsDemoDoc::CippsDemoDoc() : CDemoDoc(), CVector()
{
m_scaleW = 1;
m_scaleH = 1;
m_SamplesPerSecond = 0;
}
CippsDemoDoc::~CippsDemoDoc()
{
}
/////////////////////////////////////////////////////////////////////////////
// CDemoDoc virtual function overrides
//---------------------------------------------------------------------------
// GetFrame returns graphic view frame if it exists and returns
// text view frame otherwize
//---------------------------------------------------------------------------
CMDIChildWnd* CippsDemoDoc::GetFrame()
{
return GetDemoFrame() ? (CMDIChildWnd*)GetDemoFrame() :
GetCharFrame() ? (CMDIChildWnd*)GetCharFrame() :
(CMDIChildWnd*)GetTextFrame();
}
//---------------------------------------------------------------------------
// CreateNewData creates new vector with default parameters
//---------------------------------------------------------------------------
BOOL CippsDemoDoc::CreateNewData()
{
if (DEMO_APP->NewIsEmpty()) {
Init(DEMO_APP->GetNewType(), DEMO_APP->GetNewLength());
} else if (DEMO_APP->NewView() == VIEW_DEMO) {
if (!DEMO_APP->GetNewSignal()->CreateVector(this))
return FALSE;
} else if (DEMO_APP->NewView() == VIEW_TEXT) {
if (!DEMO_APP->GetNewTaps()->CreateVector(this))
return FALSE;
} else {
if (!DEMO_APP->GetNewChar()->CreateVector(this))
return FALSE;
}
return TRUE;
}
//---------------------------------------------------------------------------
// UpdateView updates sppecified document view or all views
//---------------------------------------------------------------------------
void CippsDemoDoc::UpdateView(CView* pSender)
{
if (GetDemoView())
GetDemoView()->InvalidateRect(NULL);
UpdateAllViews(pSender);
}
//---------------------------------------------------------------------------
// UpdateFrameTitle updates document title
//---------------------------------------------------------------------------
void CippsDemoDoc::UpdateFrameTitle(CString str)
{
CDemoDoc::UpdateFrameTitle(str);
if (GetTextFrame())
GetTextFrame()->SetWindowText(m_FrameTitle);
if (GetCharFrame())
GetCharFrame()->SetWindowText(m_FrameTitle);
}
/////////////////////////////////////////////////////////////////////////////
// MFC Overrides
//---------------------------------------------------------------------------
// CippsDemoDoc serialization
//---------------------------------------------------------------------------
void CippsDemoDoc::Serialize(CArchive& ar)
{
CFile *file = ar.GetFile();
CStoreWav wav(this);
if (wav.Serialize(file,ar.IsStoring())) return;
CStoreBmp bmp(this);
if (bmp.Serialize(file,ar.IsStoring())) return;
CMyString filePath = file->GetFilePath();
CString ext = filePath.GetExt();
ext.MakeLower();
if (ext == ".txt") {
((CEditView*)m_viewList.GetHead())->SerializeRaw(ar);
if (ar.IsLoading()) {
CString text;
((CEditView*)m_viewList.GetHead())->GetWindowText(text);
Init(pp8u);
SetString(text);
}
}
}
/////////////////////////////////////////////////////////////////////////////
// Attributes
//---------------------------------------------------------------------------
// GetActiveView return active view
//---------------------------------------------------------------------------
CView* CippsDemoDoc::GetActiveView()
{
return ACTIVE_FRAME == (CMDIChildWnd*)GetDemoFrame() ? (CView*)GetDemoView() :
ACTIVE_FRAME == (CMDIChildWnd*)GetTextFrame() ? (CView*)GetTextView() :
ACTIVE_FRAME == (CMDIChildWnd*)GetCharFrame() ? (CView*)GetCharView() :
NULL;
}
//---------------------------------------------------------------------------
// GetDemoView returns graphic view if it exists
//---------------------------------------------------------------------------
CippsDemoView* CippsDemoDoc::GetDemoView()
{
POSITION pos = GetFirstViewPosition();
while (pos) {
CippsDemoView* pView = (CippsDemoView*)GetNextView(pos);
if (pView->GetRuntimeClass()->m_lpszClassName == "CippsDemoView")
return pView;
}
return NULL;
}
//---------------------------------------------------------------------------
// GetTextView returns digital view if it exists
//---------------------------------------------------------------------------
CippsTextView* CippsDemoDoc::GetTextView()
{
POSITION pos = GetFirstViewPosition();
while (pos) {
CippsTextView* pView = (CippsTextView*)GetNextView(pos);
if (pView->GetRuntimeClass()->m_lpszClassName == "CippsTextView")
return pView;
}
return NULL;
}
//---------------------------------------------------------------------------
// GetCharView returns string view if it exists
//---------------------------------------------------------------------------
CippsCharView* CippsDemoDoc::GetCharView()
{
POSITION pos = GetFirstViewPosition();
while (pos) {
CippsCharView* pView = (CippsCharView*)GetNextView(pos);
if (pView->GetRuntimeClass()->m_lpszClassName == "CippsCharView")
return pView;
}
return NULL;
}
//---------------------------------------------------------------------------
// GetDemoFrame returns graphic view frame if it exists
//---------------------------------------------------------------------------
CChildFrame* CippsDemoDoc::GetDemoFrame()
{
return (CChildFrame*)(GetDemoView() ? GetDemoView()->GetParentFrame() : NULL);
}
//---------------------------------------------------------------------------
// GetTextFrame returns digital view frame if it exists
//---------------------------------------------------------------------------
CTextFrame* CippsDemoDoc::GetTextFrame()
{
return (CTextFrame*)(GetTextView() ? GetTextView()->GetParentFrame() : NULL);
}
//---------------------------------------------------------------------------
// GetCharFrame returns string view frame if it exists
//---------------------------------------------------------------------------
CCharFrame* CippsDemoDoc::GetCharFrame()
{
return (CCharFrame*)(GetCharView() ? GetCharView()->GetParentFrame() : NULL);
}
//---------------------------------------------------------------------------
// GetScaledValue returns vector element at specified index
// scaled for drawing
//---------------------------------------------------------------------------
Ipp64fc CippsDemoDoc::GetScaledValue(int index) const
{
Ipp64fc value = Get(index);
value.re *= m_scaleH;
value.im *= m_scaleH;
return value;
}
//---------------------------------------------------------------------------
// GetString & SetString gets & sets data for character view
//---------------------------------------------------------------------------
void CippsDemoDoc::GetString(CString& str, int len) const
{
str = _T("");
if (len < 0 || len > Length()) len = Length();
#ifdef UNICODE
Ipp16u* p16u = (Ipp16u*)GetData();
if (p16u) {
for (int i=0; i<len; i++) {
str += p16u[i];
}
}
#else
Ipp8u* p8u = (Ipp8u*)GetData();
if (p8u) {
for (int i=0; i<len; i++) {
str += p8u[i];
}
}
#endif
}
void CippsDemoDoc::SetString(const CString& str)
{
#ifdef UNICODE
Allocate(str.GetLength());
Ipp16u* p16u = (Ipp16u*)GetData();
if (p16u) {
for (int i=0; i<Length(); i++) {
p16u[i] = str[i];
}
}
#else
Allocate(str.GetLength());
Ipp8u* p8u = (Ipp8u*)GetData();
if (p8u) {
for (int i=0; i<Length(); i++) {
p8u[i] = str[i];
}
}
#endif
}
/////////////////////////////////////////////////////////////////////////////
// Operations
//---------------------------------------------------------------------------
// CreateDemoView creates grapic view
//---------------------------------------------------------------------------
BOOL CippsDemoDoc::CreateDemoView(BOOL bMakeVisible)
{
if (GetDemoFrame()) return TRUE;
return CreateNewView(RUNTIME_CLASS(CChildFrame), RUNTIME_CLASS(CippsDemoView),
bMakeVisible);
}
//---------------------------------------------------------------------------
// CreateTextView creates digital view
//---------------------------------------------------------------------------
BOOL CippsDemoDoc::CreateTextView(BOOL bMakeVisible)
{
if (GetTextFrame()) return TRUE;
return CreateNewView(RUNTIME_CLASS(CTextFrame), RUNTIME_CLASS(CippsTextView),
bMakeVisible);
}
//---------------------------------------------------------------------------
// CreateCharView creates string view
//---------------------------------------------------------------------------
BOOL CippsDemoDoc::CreateCharView(BOOL bMakeVisible)
{
if (GetCharFrame()) return TRUE;
return CreateNewView(RUNTIME_CLASS(CCharFrame), RUNTIME_CLASS(CippsCharView),
bMakeVisible);
}
//---------------------------------------------------------------------------
// CreateNewView creates new view for document
//---------------------------------------------------------------------------
BOOL CippsDemoDoc::CreateNewView(CRuntimeClass* pFrameClass, CRuntimeClass* pViewClass,
BOOL bMakeVisible)
{
CDocTemplate *pTpl = GetDocTemplate();
CCreateContext context;
context.m_pCurrentFrame = m_viewList.GetTail() ?
((CippsDemoView*)m_viewList.GetTail())->GetParentFrame() : NULL;
context.m_pCurrentDoc = this;
context.m_pNewViewClass = pViewClass;
context.m_pNewDocTemplate = pTpl;
CFrameWnd* pFrame = (CFrameWnd*)pFrameClass->CreateObject();
if (!pFrame) return FALSE;
// create new from resource
int idr = IDR_IPPSTYPE;
if (pViewClass->m_lpszClassName == "CippsTextView")
idr = IDR_IPPSTEXT;
else if (pViewClass->m_lpszClassName == "CippsCharView")
idr = IDR_IPPSCHAR;
if (!pFrame->LoadFrame(idr, WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, NULL, &context))
return FALSE;
pTpl->InitialUpdateFrame(pFrame, this, bMakeVisible);
UpdateFrameTitle();
return TRUE;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -