📄 ippsdemo.cpp
字号:
//----------------------------------------------------------------------------
// CreateDemoDoc creates document with specified vector type & length
// and shows it in graphic view
//----------------------------------------------------------------------------
CippsDemoDoc* CippsDemoApp::CreateDemoDoc(ppType type, int len,
BOOL bMakeVisible, CString title)
{
return CreateNewDoc(GetDemoTemplate(),type,len,bMakeVisible,title);
}
//----------------------------------------------------------------------------
// CreateDemoDoc creates document with vector equaled to specified vector
// and shows it in graphic view
//----------------------------------------------------------------------------
CippsDemoDoc* CippsDemoApp::CreateDemoDoc(CVector* pVec, BOOL bMakeVisible, CString title)
{
CippsDemoDoc* pDoc = CreateDemoDoc(pVec->Type(), pVec->Length(), bMakeVisible, title);
if (!pDoc) return NULL;
pDoc->CopyData(*pVec);
return pDoc;
}
//----------------------------------------------------------------------------
// CreateTextDoc creates document with specified vector type & length
// and shows it in textual view
//----------------------------------------------------------------------------
CippsDemoDoc* CippsDemoApp::CreateTextDoc(ppType type, int len,
BOOL bMakeVisible, CString title)
{
ppType newType = m_NewType;
int newLength = m_NewLength;
CippsDemoDoc* pDoc = CreateNewDoc(GetTextTemplate(),type,len,bMakeVisible,title);
m_NewType = newType ;
m_NewLength = newLength;
return pDoc;
}
//----------------------------------------------------------------------------
// CreateTextDoc creates document with vector equaled to specified vector
// and shows it in textual view
//----------------------------------------------------------------------------
CippsDemoDoc* CippsDemoApp::CreateTextDoc(CVector* pVec, BOOL bMakeVisible, CString title)
{
CippsDemoDoc* pDoc = CreateTextDoc(pVec->Type(), pVec->Length(), bMakeVisible, title);
if (!pDoc) return NULL;
pDoc->CopyData(*pVec);
return pDoc;
}
//----------------------------------------------------------------------------
// CreateCharDoc creates document with specified vector type & length
// and shows it in character view
//----------------------------------------------------------------------------
CippsDemoDoc* CippsDemoApp::CreateCharDoc(ppType type, int len,
BOOL bMakeVisible, CString title)
{
ppType newType = m_NewType;
int newLength = m_NewLength;
CippsDemoDoc* pDoc = CreateNewDoc(GetCharTemplate(),type,len,bMakeVisible,title);
m_NewType = newType ;
m_NewLength = newLength;
return pDoc;
}
//----------------------------------------------------------------------------
// CreateCharDoc creates document with vector equaled to specified vector
// and shows it in character view
//----------------------------------------------------------------------------
CippsDemoDoc* CippsDemoApp::CreateCharDoc(CVector* pVec, BOOL bMakeVisible, CString title)
{
CippsDemoDoc* pDoc = CreateCharDoc(pVec->Type(), pVec->Length(), bMakeVisible, title);
if (!pDoc) return NULL;
pDoc->CopyData(*pVec);
return pDoc;
}
//----------------------------------------------------------------------------
// CreateNewDoc creates document with specified vector type & length
// and shows it in graphic, digital or character view due to specified template
//----------------------------------------------------------------------------
CippsDemoDoc* CippsDemoApp::CreateNewDoc(CDocTemplate* pTpl, ppType type, int len,
BOOL bMakeVisible, CString title)
{
m_NewIsEmpty = TRUE;
m_NewType = type;
m_NewLength = len;
CippsDemoDoc* pDoc = (CippsDemoDoc*)pTpl->OpenDocumentFile(NULL,bMakeVisible);
if (pDoc) {
if (!title.IsEmpty()) pDoc->SetTitle(title);
}
if (pDoc)
pDoc->InitHisto();
m_NewIsEmpty = FALSE;
return pDoc;
}
//----------------------------------------------------------------------------
// OpenNewDoc opens new user customized document.
// If newView == VIEW_DEMO then document will be created with signal default
// parameters and will be shown in graphic view;
// if newView == NEW_TEXT then document will be created with digital default
// parameters and will be shown in digital view
// if newView == VIEW_CHAR then document will be created with characher default
// parameters and will be shown in character view
//----------------------------------------------------------------------------
void CippsDemoApp::OpenNewDoc(int newView)
{
POSITION tPos = GetFirstDocTemplatePosition( );
CDocTemplate* pTpl;
for (int i=0; i<=newView; i++)
pTpl = GetNextDocTemplate(tPos);
ASSERT(pTpl);
CippsDemoDoc* pDoc = (CippsDemoDoc*)pTpl->OpenDocumentFile(NULL);
if (pDoc)
pDoc->InitHisto();
}
/////////////////////////////////////////////////////////////////////////////
// Providing Drag & Drop Operations on Demo applications
CDemoDoc* CippsDemoApp::CreateDropDoc(const char* pData, int DropObject)
{
if (!ValidDropHeader(pData, DropObject)) return NULL;
ppType type;
int len ;
CDemoDoc::ReadDropVectorHeader(pData, type, len);
return CreateDemoDoc(type, len, FALSE);
}
BOOL CippsDemoApp::ValidDropHeader(const char* pData, int DropObject) const
{
if (DropObject != DROP_VECTOR) return FALSE;
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CippsDemoApp message handlers
//----------------------------------------------------------------------------
// OnFileNew performs Toolbar-new command
//----------------------------------------------------------------------------
void CippsDemoApp::OnFileNew()
{
// m_NewView = FALSE;
OpenNewDoc(m_NewView);
}
//----------------------------------------------------------------------------
// OnFileNewSignal performs Menu-File-NewSignal command
//----------------------------------------------------------------------------
void CippsDemoApp::OnFileNewSignal()
{
if (!m_pNewSignal->Dialog()) return;
m_NewView = VIEW_DEMO;
OpenNewDoc();
}
//----------------------------------------------------------------------------
// OnFileNewTaps performs Menu-File-NewDigits command
//----------------------------------------------------------------------------
void CippsDemoApp::OnFileNewTaps()
{
if (!m_pNewTaps->Dialog()) return;
m_NewView = VIEW_TEXT;
OpenNewDoc(m_NewView);
}
//----------------------------------------------------------------------------
// OnFileNewChar performs Menu-File-NewCharacters command
//----------------------------------------------------------------------------
void CippsDemoApp::OnFileNewChar()
{
// if (!m_pNewChar->Dialog()) return;
m_NewView = VIEW_CHAR;
OpenNewDoc(m_NewView);
}
//----------------------------------------------------------------------------
// OnUpdateViewXaxis checks Menu-View-XAxis command
//----------------------------------------------------------------------------
void CippsDemoApp::OnUpdateViewXaxis(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck(m_XAxis);
}
//----------------------------------------------------------------------------
// OnUpdateViewYaxis checks Menu-View-YAxis command
//----------------------------------------------------------------------------
void CippsDemoApp::OnUpdateViewYaxis(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck(m_YAxis);
}
//----------------------------------------------------------------------------
// OnViewXaxis performs Menu-View-XAxis command
//----------------------------------------------------------------------------
void CippsDemoApp::OnViewXaxis()
{
m_XAxis = !m_XAxis;
MY_POSITION pos = GetFirstDocPosition();
while (pos)
GetNextIppsDoc(pos)->UpdateXAxis();
}
//----------------------------------------------------------------------------
// OnViewYaxis performs Menu-View-YAxis command
//----------------------------------------------------------------------------
void CippsDemoApp::OnViewYaxis()
{
m_YAxis = !m_YAxis;
MY_POSITION pos = GetFirstDocPosition();
while (pos)
GetNextIppsDoc(pos)->UpdateYAxis();
}
//----------------------------------------------------------------------------
// OnUpdateViewGrid checks Menu-View-Grid command
//----------------------------------------------------------------------------
void CippsDemoApp::OnUpdateViewGrid(CCmdUI* pCmdUI)
{
pCmdUI->Enable(m_XAxis || m_YAxis);
pCmdUI->SetCheck(m_Grid);
}
//----------------------------------------------------------------------------
// OnViewGrid performs Menu-View-Grid command
//----------------------------------------------------------------------------
void CippsDemoApp::OnViewGrid()
{
m_Grid = !m_Grid;
UpdateAllViews();
}
//----------------------------------------------------------------------------
// OnUpdateZoomAll enables Menu-Zoom-ZoomAllAsActive command
//----------------------------------------------------------------------------
void CippsDemoApp::OnUpdateZoomAll(CCmdUI* pCmdUI)
{
pCmdUI->Enable(((CWnd*)ACTIVE_FRAME == (CWnd*)ACTIVE_DOC->GetDemoFrame()) &&
GetDocCount() > 1);
}
//----------------------------------------------------------------------------
// OnZoomAll performs Menu-Zoom-ZoomAllAsActive command
//----------------------------------------------------------------------------
void CippsDemoApp::OnZoomAll()
{
CippsDemoDoc* pActiveDoc = ACTIVE_DOC;
double scaleW = pActiveDoc->FactorW();
double scaleH = pActiveDoc->FactorH();
MY_POSITION pos = GetFirstDocPosition();
while (pos) {
CippsDemoDoc* pDoc = GetNextIppsDoc(pos);
if (pDoc == pActiveDoc) continue;
pDoc->ZoomByFactors(scaleW,scaleH);
}
}
//----------------------------------------------------------------------------
// OnOptColor performs Menu-Options-Color command
//----------------------------------------------------------------------------
void CippsDemoApp::OnOptColor()
{
CColorDlg dlg;
if (dlg.DoModal() == IDOK)
UpdateAllViews();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -