📄 ippsdemodoc.cpp
字号:
//---------------------------------------------------------------------------
// ZoomStandard scales grapfh to fit for standard window
//---------------------------------------------------------------------------
void CippsDemoDoc::ZoomStandard()
{
CRect rect (
GetDemoFrame()->GetX(),
GetDemoFrame()->GetY(),
GetDemoFrame()->GetX() + GetDemoView()->GetInitialWidth() + GetDemoFrame()->GetBorderWidth(),
GetDemoFrame()->GetY() + GetDemoView()->GetInitialHeight() + GetDemoFrame()->GetBorderHeight());
ZoomToRect(&rect);
ZoomToRect(&rect);
}
//---------------------------------------------------------------------------
// ZoomByFactors scales grapfh by specified factors and accordingly changes
// frame rectangle
//---------------------------------------------------------------------------
void CippsDemoDoc::ZoomByFactors(double scaleW, double scaleH, POINT * pOffset)
{
if (!GetDemoFrame()) return;
m_scaleW = scaleW;
m_scaleH = scaleH;
if (!pOffset) {
Zoom();
return;
}
CSize size = GetDemoView()->GetScaleSize();
size.cx += GetDemoFrame()->GetBorderWidth();
size.cy += GetDemoFrame()->GetBorderHeight();
if (pOffset->x < 0) pOffset->x = GetDemoFrame()->GetX();
if (pOffset->y < 0) pOffset->y = GetDemoFrame()->GetY();
CRect rect(*pOffset,size);
Zoom(&rect);
}
//---------------------------------------------------------------------------
// ZoomToRect scales grapfh to fit for specified or actual frame rectangle
//---------------------------------------------------------------------------
void CippsDemoDoc::ZoomToRect(RECT* pRect)
{
if (!GetDemoFrame()) return;
CChildFrame* pFrame = GetDemoFrame();
CippsDemoView* pView = GetDemoView();
CRect rect;
if (pRect) rect = *pRect;
else pFrame->GetRect(rect);
int width = rect.Width() - pFrame->GetBorderWidth() - pView->GetBorderWidth();
int height = rect.Height() - pFrame->GetBorderHeight() - pView->GetBorderHeight();
m_scaleW = (double)width / Length();
m_scaleH = (double)height / GetDemoView()->GetAmplitude();
Zoom(&rect);
}
//---------------------------------------------------------------------------
// Zoom implementation
//---------------------------------------------------------------------------
void CippsDemoDoc::Zoom(RECT* pRect)
{
if (!GetDemoFrame()) return;
GetDemoFrame()->Zoom(pRect);
UpdateView();
}
//---------------------------------------------------------------------------
// UpdateXAxis update x axis in graphic view
//---------------------------------------------------------------------------
void CippsDemoDoc::UpdateXAxis()
{
CippsDemoView* pView = GetDemoView();
if (!pView) return;
int amplitude = (int)(pView->GetAmplitude()*FactorH());
int height = pView->GetClientHeight();
if (amplitude <= height) {
CRect rect;
CChildFrame* pFrame = GetDemoFrame();
pFrame->GetRect(rect);
rect.bottom += amplitude + pView->GetBorderHeight()
- height;
pFrame->SetRect(rect);
}
UpdateView();
}
//---------------------------------------------------------------------------
// UpdateYAxis update y axis in graphic view
//---------------------------------------------------------------------------
void CippsDemoDoc::UpdateYAxis()
{
CippsDemoView* pView = GetDemoView();
if (!pView) return;
int length = (int)(Length()*FactorW());
int width = pView->GetClientWidth();
if (length <= width) {
CRect rect;
CChildFrame* pFrame = GetDemoFrame();
pFrame->GetRect(rect);
rect.right += length + pView->GetBorderWidth()
- width;
pFrame->SetRect(rect);
}
UpdateView();
}
/////////////////////////////////////////////////////////////////////////////
// CippsDemoDoc commands
//---------------------------------------------------------------------------
// OnFileSaveAs performs Menu-File-SaveAs command
//---------------------------------------------------------------------------
void CippsDemoDoc::OnFileSaveAs()
{
CDemoDoc::OnFileSaveAs();
/*
CDocTemplate* pTemplate = GetDocTemplate();
ASSERT(pTemplate != NULL);
CString fileName = GetPathName();
if (fileName.IsEmpty())
fileName = GetTitle() + ".wav";
if (!AfxGetApp()->DoPromptFileName(fileName,
AFX_IDS_SAVEFILE,
OFN_HIDEREADONLY | OFN_PATHMUSTEXIST, FALSE, pTemplate))
return;
DoSave(fileName);
*/
}
//---------------------------------------------------------------------------
// OnFileSigned checks Menu-File-Signed command
//---------------------------------------------------------------------------
void CippsDemoDoc::OnUpdateFileSigned(CCmdUI* pCmdUI)
{
BOOL flag = !Float() && Type() != pp64s && !Complex();
pCmdUI->Enable(flag);
pCmdUI->SetCheck(Sign());
}
//---------------------------------------------------------------------------
// OnFileSigned performs Menu-File-Signed command
//---------------------------------------------------------------------------
void CippsDemoDoc::OnFileSigned()
{
DEMO_APP->SetCursorWait();
if (Sign())
m_type = (ppType)((int)m_type & ~PP_SIGN);
else
m_type = (ppType)((int)m_type | PP_SIGN);
m_pProcess->ApplyVector(this);
MarkToPick();
ZoomToRect();
ZoomToRect();
UpdateFrameTitle();
SetStatusString();
DEMO_APP->SetCursorArrow();
}
//---------------------------------------------------------------------------
// OnFileProp performs Menu-File-Properties command
//---------------------------------------------------------------------------
void CippsDemoDoc::OnFileProp()
{
CFilePropDlg dlg;
dlg.m_pDoc = this;
dlg.DoModal();
}
//---------------------------------------------------------------------------
// OnUpdateZoom enables all Menu-Zoom- command except of -Lower & -Narrow
//---------------------------------------------------------------------------
void CippsDemoDoc::OnUpdateZoom(CCmdUI* pCmdUI)
{
pCmdUI->Enable(GetDemoFrame() == ACTIVE_FRAME);
}
//---------------------------------------------------------------------------
// OnUpdateZoomHlow enables Menu-Zoom-Lower command
//---------------------------------------------------------------------------
void CippsDemoDoc::OnUpdateZoomHlow(CCmdUI* pCmdUI)
{
pCmdUI->Enable(
(GetDemoFrame() == ACTIVE_FRAME) &&
(Difference()*m_scaleH >= 16));
}
//---------------------------------------------------------------------------
// OnUpdateZoomWlow enables Menu-Zoom-Narrow command
//---------------------------------------------------------------------------
void CippsDemoDoc::OnUpdateZoomWlow(CCmdUI* pCmdUI)
{
pCmdUI->Enable(
(GetDemoFrame() == ACTIVE_FRAME) &&
(Length()*m_scaleW >= 16));
}
//---------------------------------------------------------------------------
// OnZoomHup performs Menu-Zoom-Heighten command
//---------------------------------------------------------------------------
void CippsDemoDoc::OnZoomHup()
{
m_scaleH *= 2;
Zoom();
}
//---------------------------------------------------------------------------
// OnZoomHlow performs Menu-Zoom-Lower command
//---------------------------------------------------------------------------
void CippsDemoDoc::OnZoomHlow()
{
m_scaleH *= 0.5;
Zoom();
}
//---------------------------------------------------------------------------
// OnZoomWup performs Menu-Zoom-Widen command
//---------------------------------------------------------------------------
void CippsDemoDoc::OnZoomWup()
{
m_scaleW *= 2;
Zoom();
}
//---------------------------------------------------------------------------
// OnZoomWlow performs Menu-Zoom-Narrow command
//---------------------------------------------------------------------------
void CippsDemoDoc::OnZoomWlow()
{
m_scaleW *= 0.5;
Zoom();
}
//---------------------------------------------------------------------------
// OnZoomFith performs Menu-Zoom-FitForHeight command
//---------------------------------------------------------------------------
void CippsDemoDoc::OnZoomFith()
{
CRect rect (
GetDemoFrame()->GetX(),
0,
GetDemoFrame()->GetX() + GetDemoFrame()->GetWidth(),
MAIN_FRAME->GetClientHeight());
ZoomToRect(&rect);
ZoomToRect(&rect);
}
//---------------------------------------------------------------------------
// OnZoomFitw performs Menu-Zoom-FitForWidth command
//---------------------------------------------------------------------------
void CippsDemoDoc::OnZoomFitw()
{
CRect rect (
0,
GetDemoFrame()->GetY(),
MAIN_FRAME->GetClientWidth(),
GetDemoFrame()->GetY() + GetDemoFrame()->GetHeight());
ZoomToRect(&rect);
ZoomToRect(&rect);
}
//---------------------------------------------------------------------------
// OnZoomStandard performs Menu-Zoom-FitForStandard command
//---------------------------------------------------------------------------
void CippsDemoDoc::OnZoomStandard()
{
ZoomStandard();
}
//---------------------------------------------------------------------------
// OnZoomCurrent performs Menu-Zoom-FitForCurrent command
//---------------------------------------------------------------------------
void CippsDemoDoc::OnZoomCurrent()
{
ZoomToRect();
ZoomToRect();
}
//---------------------------------------------------------------------------
// OnZoomCustom performs Menu-Zoom-CustomZoom command
//---------------------------------------------------------------------------
void CippsDemoDoc::OnZoomCustom()
{
CZoomDlg dlg;
dlg.m_pDoc = this;
dlg.m_ScaleW = m_scaleW;
dlg.m_ScaleH = m_scaleH;
if (dlg.DoModal() != IDOK) return;
m_scaleW = dlg.m_ScaleW;
m_scaleH = dlg.m_ScaleH;
Zoom();
}
//---------------------------------------------------------------------------
// OnUpdateWindowPlot enables&checks Menu-Window-PlotWindow command
//---------------------------------------------------------------------------
void CippsDemoDoc::OnUpdateWindowPlot(CCmdUI* pCmdUI)
{
pCmdUI->Enable(TRUE);
pCmdUI->SetCheck(GetDemoFrame() == ACTIVE_FRAME);
}
//---------------------------------------------------------------------------
// OnUpdateWindowText enables&checks Menu-Window-DigitalWindow command
//---------------------------------------------------------------------------
void CippsDemoDoc::OnUpdateWindowText(CCmdUI* pCmdUI)
{
pCmdUI->Enable(TRUE);
pCmdUI->SetCheck(GetTextFrame() == ACTIVE_FRAME);
}
//---------------------------------------------------------------------------
// OnUpdateWindowChar enables&checks Menu-Window-StringWindow command
//---------------------------------------------------------------------------
void CippsDemoDoc::OnUpdateWindowChar(CCmdUI *pCmdUI)
{
pCmdUI->Enable(GetVector()->Type() == pp8u);
pCmdUI->SetCheck(GetCharFrame() == ACTIVE_FRAME);
}
//---------------------------------------------------------------------------
// OnWindowPlot performs Menu-Window-PlotWindow command
//---------------------------------------------------------------------------
void CippsDemoDoc::OnWindowPlot()
{
if (GetDemoFrame())
MAIN_FRAME->MDIActivate(GetDemoFrame());
else {
DEMO_APP->SetCursorWait();
CreateDemoView();
DEMO_APP->SetCursorArrow();
}
}
//---------------------------------------------------------------------------
// OnWindowText performs Menu-Window-DigitalWindow command
//---------------------------------------------------------------------------
void CippsDemoDoc::OnWindowText()
{
if (GetTextFrame())
MAIN_FRAME->MDIActivate(GetTextFrame());
else {
DEMO_APP->SetCursorWait();
CreateTextView();
DEMO_APP->SetCursorArrow();
}
}
//---------------------------------------------------------------------------
// OnWindowChar performs Menu-Window-StringWindow command
//---------------------------------------------------------------------------
void CippsDemoDoc::OnWindowChar()
{
if (GetCharFrame())
MAIN_FRAME->MDIActivate(GetCharFrame());
else {
DEMO_APP->SetCursorWait();
CreateCharView();
DEMO_APP->SetCursorArrow();
}
}
//---------------------------------------------------------------------------
// OnEditInsert performs Menu-Edit-Insert command
//---------------------------------------------------------------------------
void CippsDemoDoc::OnEditInsert()
{
CStringDlg dlg;
GetString(dlg.m_String);
GetCharView()->GetEditCtrl().GetSel(dlg.m_start, dlg.m_end);
if (dlg.DoModal() != IDOK) return;
SetString(dlg.m_String);
UpdateView();
GetCharView()->GetEditCtrl().SetSel(dlg.m_start, dlg.m_end);
}
void CippsDemoDoc::OnUpdateEditInsert(CCmdUI *pCmdUI)
{
pCmdUI->Enable(GetCharFrame() == ACTIVE_FRAME);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -