📄 cgeview.cpp
字号:
{
CCgeDoc* pDoc = GetDocument();
CString s,s_n;
CComboBox* combo = (CComboBox*) pDLGBAR->GetDlgItem(IDC_COMBO1);
int index = combo->GetCurSel( );
if (index != CB_ERR )
{
combo->GetLBText(index,s);
}
else
{
combo ->GetWindowText(s);
}
TRACE("\n Windowstet %s ",s);
// pDoc->basline = atoi(s);
pDoc->Fangs = s;
Fangs = s;
//保存原值
if(pDoc->Fangs == pDoc->s[0])
{
pDoc->old_m_stepY = pDoc->m_stepY;
pDoc->FangsKey = false;
}else
{
pDoc->Fangs.Format("%d",atoi(s)-pDoc->m_N0+1);
SetScrollPos(SB_VERT,(atoi(s)-pDoc->m_N0)*pDoc->basline);
pDoc->m_stepY = pDoc->old_m_stepY;
pDoc->FangsKey = true;
}
//pDoc->FangsKey = true;
double tempx,mlog2;
tempx = log(pDoc->m_stepY/pDoc->m_stepY0);
mlog2 = log(2);
pDoc->m_Ndb = tempx/mlog2;
//m
//Invalidate();
//m
}
void CCgeView::OnSFang() //单道放大
{
CCgeDoc *pDoc = GetDocument();
//int xp,yp;
POSITION m_position;
//CMyLine* pLine;
int temp=0;
CClientDC* pDC = new CClientDC(this); ///????
// pDoc->SFangKey = true;
if(!pDoc->m_CMyLineList.IsEmpty())
{
m_position = pDoc->m_CMyLineList.GetHeadPosition();
int i;
for(i=0;i<pDoc->Num_Line;i++)
{
//if(abs(BPoint.y+pDoc->VPos-i*pDoc->basline-pDoc->m_viewY0)<(pDoc->basline/2))
if(abs(BPoint.y-i*pDoc->basline-pDoc->m_viewY0+GetScrollPos(SB_VERT))<(pDoc->basline/2))
{
break;
}
}
CString str_i,str_n;
str_n.Format("%d",i+pDoc->m_N0);
str_i="单独放大第"+str_n+"通道吗?";
if(AfxMessageBox(str_i,MB_OKCANCEL,0)==IDOK)
{
pDoc->Fangs.Format("%d", i+1);
if(pDoc->Fangs == pDoc->s[0])
{
pDoc->old_m_stepY = pDoc->m_stepY;
pDoc->FangsKey = false;
}else
{
pDoc->m_stepY = pDoc->old_m_stepY;
pDoc->FangsKey = true;
}
pDLGBAR->GetDlgItem(IDC_COMBO1)->SetWindowText(str_n);
}
}
pDC->DeleteDC();
m_dtlBKey=false;
// pDoc->SetModifiedFlag();
}
void CCgeView::OnUpdateSFang(CCmdUI* pCmdUI)
{
//pCmdUI->Enable(m_dtlBKey);
}
void CCgeView::m_fill(bool up)
{
CCgeDoc *pDoc = GetDocument();
if(!pDoc->m_CMyLineList.IsEmpty())
{
CRect rect;
GetClientRect(&rect);
CMyLine* pMyLine;
CClientDC dc(this);
OnPrepareDC(&dc);
dc.DPtoLP(&rect);
dc.SelectStockObject(BLACK_BRUSH);
int x,y;
int n = GetScrollPos(SB_VERT) - pDoc->m_viewY0;
int start = n/pDoc->basline;
if(start<0)
start = 0;
int end = (n + rect.Height())/pDoc->basline + 2;
POSITION m_position = pDoc->m_CMyLineList.GetHeadPosition();
for(int i = start;i < pDoc->Num_Line && i< end;i++)
{
for(int j = 0;j < pDoc->Num_Pointes;j++)
{
pMyLine = (CMyLine* )pDoc->m_CMyLineList.GetNext(m_position);
if(j%2!=0)
{
x = j * pDoc->m_stepX - 1;
y = pMyLine->y * pDoc->m_stepY + i * pDoc->basline + pDoc->m_viewY0;
if(up && pMyLine->y * pDoc->m_stepY < 0 || !up && pMyLine->y * pDoc->m_stepY > 0)
{
dc.MoveTo(x, i* pDoc->basline + pDoc->m_viewY0);
dc.LineTo(x, y);
}
}
}
}
}
}
void CCgeView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint)
{
CCgeDoc *pDoc = GetDocument();
ASSERT_VALID(pDoc);
CSize size = pDoc->GetDocSize();
SetScrollSizes(MM_TEXT, size, CSize(500*pDoc->m_stepX,pDoc->basline), CSize(50*pDoc->m_stepX,pDoc->basline));
CComboBox* pCombo1 = (CComboBox* )((CMainFrame*)GetParentFrame())->GetDlgBar().GetDlgItem(IDC_COMBO1);
pCombo1->ResetContent();
pCombo1->AddString(pDoc->s[0]);
int i,bd,ed;
CString bes;
i = pDoc->s[0].Find("-");
bd = atoi(pDoc->s[0].Left(i));
ed = atoi(pDoc->s[0].Mid(i+1));
for(i=bd;i<ed+1;i++)
{
bes.Format("%d",i);
pCombo1->AddString(bes);
}
if(pDoc->FangsKey)
{
CString fs;
fs.Format("%d",atoi(pDoc->Fangs)+pDoc->m_N0-1);
pCombo1->SetWindowText(fs);
}else
{
pCombo1->SetWindowText(pDoc->Fangs);
}
CString s;
s.Format("%d", pDoc->m_Ndb*6);
((CMainFrame*)GetParentFrame())->GetDlgBar().GetDlgItem(IDC_DLGBAREDIT1)->SetWindowText(s+"dB");
s.Format("%d", pDoc->m_H);
((CMainFrame*)GetParentFrame())->GetDlgBar().GetDlgItem(IDC_DLGBAREDIT2)->SetWindowText(s);
s.Format("%d", int(pDoc->basline));
((CMainFrame*)GetParentFrame())->GetDlgBar().GetDlgItem(IDC_DLGBARCOMBO1)->SetWindowText(s);
s.Format("%d",pDoc->m_Mcishu);
((CStatusBar* )AfxGetApp()->m_pMainWnd->GetDescendantWindow(AFX_IDW_STATUS_BAR))->SetPaneText(1,_T(" 叠加次数:")+s);
CScrollView::OnUpdate(pSender, lHint, pHint);
}
void CCgeView::OnShowBaslinekey()
{
baslineKey = !baslineKey;
Invalidate();
}
void CCgeView::OnUpdateShowBaslinekey(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck(baslineKey);
}
BOOL CCgeView::OnScroll(UINT nScrollCode, UINT nPos, BOOL bDoScroll)
{
if(m_nFlowXY != -55)
OnMouseMove(0, CPoint(-55,-55));
OnEditReset() ;
return CScrollView::OnScroll(nScrollCode, nPos, bDoScroll);
}
void CCgeView::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
CCgeDoc* pDoc = (CCgeDoc* )GetDocument();
ASSERT_VALID(pDoc);
CScrollView::OnVScroll(nSBCode, nPos, pScrollBar);
//pDoc->VPos = GetScrollPos (SB_VERT);
}
void CCgeView::OnDestroy()
{
CScrollView::OnDestroy();
// TODO: Add your message handler code here
m_MemDC.DeleteDC();
m_Bitmap.DeleteObject();
memDC.DeleteDC();
// bm.DeleteObject();
}
void CCgeView::OnParRfile()
{
FilePath dlg(
true,
_T(".dat"), //default filename extension
"", //initial filename in edit box
// functionality flags
// OFN_ALLOWMULTISELECT| //allow multiple files to be selected
OFN_CREATEPROMPT | // if File Save As, prompts user if they want to create non-existant file
OFN_OVERWRITEPROMPT | // if File Save As--prompts user to ask if they want to overwrite an existing file
OFN_ENABLESIZING | // if Windows NT 5.0 or Win 98, causes box to be resizable by user
//OFN_EXTENSIONDIFFERENT| // allows user to enter a filename with a different extension from the default
// OFN_FILEMUSTEXIST // file must exist
// OFN_NOLONGNAMES | // causes dialog to use short filenames (8.3)
// OFN_PATHMUSTEXIST | // user can only type valid paths and filenames
// OFN_NOVALIDATE | // the returned filname can have invalid characters
// appearence flags
OFN_HIDEREADONLY | // hides read-only check box
// OFN_NONETWORKBUTTON | // hides Network button
//OFN_READONLY | // initially check Read Only check box
// OFN_SHOWHELP | // Help button appears--when clicked the hook procedure gets a CDN_HELP message
// custom template flags
OFN_ENABLETEMPLATE | // you will be supplying your own custom dialog box template
0,
szFilter, //file filter
//AfxGetApp()->m_pMainWnd);
//this); // parent window
GetParentFrame());
// set an initial directory
char lpszInitDir[MAX_PATH];
_getcwd(lpszInitDir,MAX_PATH);
dlg.m_ofn.lpstrInitialDir=lpszInitDir;
//set the dialog's title
//char lpszTitle[]={"地震仪格式文件"};//{"Save As File"};
char lpszTitle[]={"打开SEG2文件"};//{"Save As File"};
dlg.m_ofn.lpstrTitle=lpszTitle;
// retain the customer's last file filter selection
dlg.m_ofn.lpstrCustomFilter=lpstrCustomFilter;
dlg.m_ofn.nMaxCustFilter=255;
// if OFN_ENABLETEMPLATE is set, define the custom dialog template here
dlg.m_ofn.lpTemplateName=MAKEINTRESOURCE(IDD_DIALOGBAR_NEWFILE);
dlg.m_StrCheckspace = m_path[1];
dlg.m_StrSourse = m_path[2];
dlg.m_StrPo = m_path[3];
dlg.m_StrOffset = m_path[4];
dlg.m_StrLine = m_path[5];
// open file dialog and get file name(s)
if (dlg.DoModal()==IDOK)
{
// get filter number selected (index into filter list that user selected)
int nFilterIndex=dlg.m_ofn.nFilterIndex;
// get file name
CString path=dlg.GetPathName(); //ex: c:\temp\temp.tmp
CString file=dlg.GetFileName(); //ex: temp.tmp
CString title=dlg.GetFileTitle(); //ex: temp
CString ext=dlg.GetFileExt(); //ex: tmp
CCgeDoc* pDoc = (CCgeDoc* )GetDocument();
ASSERT_VALID(pDoc);
m_path[0] = file;
m_path[1] = dlg.m_StrCheckspace;
m_path[2] = dlg.m_StrSourse;
m_path[4] = dlg.m_StrOffset;
m_path[5] = dlg.m_StrLine;
m_path[3] = dlg.m_StrPo;
m_path[6] = dlg.m_StrDate;
pDoc->Seg2Read(m_path); //读SEG2文件
file = m_path[0] ;
dlg.m_StrCheckspace = m_path[1];
dlg.m_StrSourse = m_path[2];
dlg.m_StrLine = m_path[5];
dlg.m_StrPo = m_path[3];
dlg.m_StrOffset = m_path[4];
dlg.m_StrDate = m_path[6];
//BOOL bReadOnly = dlg.GetReadOnlyPref();
pDoc->olddataKey = true; //读完后
// if OFN_ALLOWMULTISELECT is set, loop to get all file names
for (POSITION pos=dlg.GetStartPosition();pos;)
{
CString pathx=dlg.GetNextPathName(pos);
}
}
}
void CCgeView::OnFileNew()
{
CNewFile dlg;
dlg.m_pa0 = m_path[0];
dlg.m_pa1 = m_path[1];
dlg.m_pa2 = m_path[2];
dlg.m_pa5 = m_path[5];
dlg.m_pa3 = m_path[3];
dlg.m_pa4 = m_path[4];
dlg.m_pa6 = m_path[6];
dlg.m_pa7 = m_path[7];
dlg.m_pa8 = m_path[8];
CCgeDoc* pDoc = (CCgeDoc* )GetDocument();
ASSERT_VALID(pDoc);
if( pDoc->olddataKey )
{
dlg.m_butoon1Key = true;
}else
{
dlg.m_butoon1Key = false;
}
if(dlg.DoModal()!=IDOK)
{
return;
}
pDoc->m_pa[0] = m_path[0] = dlg.m_pa0 ;
pDoc->m_pa[1] = m_path[1] = dlg.m_pa1 ;
pDoc->m_pa[2] = m_path[2] = dlg.m_pa2 ;
pDoc->m_pa[5] = m_path[5] = dlg.m_pa5 ;
pDoc->m_pa[3] = m_path[3] = dlg.m_pa3 ;
pDoc->m_pa[4] = m_path[4] = dlg.m_pa4 ;
pDoc->m_pa[6] = m_path[6] = dlg.m_pa6 ;
pDoc->m_pa[7] = m_path[7] = dlg.m_pa7 ;
pDoc->m_pa[8] = m_path[8] = dlg.m_pa8 ;
if(dlg.NewFileKey )
{
pDoc->olddataKey = false;
}
}
void CCgeView::m_EditReset()
{
CCgeDoc *pDoc = (CCgeDoc *)GetDocument();
if (m_dtlBKey && !m_dtlEKey && !m_invertKey)
{
OnStartLine();
}
if (!m_dtlBKey && m_dtlEKey && !m_invertKey)
{
OnEndLine();
}
if (m_dtlBKey && m_dtlEKey && !m_invertKey)
{
OnStartLine();
OnEndLine();
}
if(m_dtlBKey && m_dtlEKey && m_invertKey)
{
OnInvert();
OnStartLine();
OnEndLine();
}
//pDLGBAR->GetDlgItem(IDC_DLGBARUSORMS)->SetWindowText(" "+pDoc->s[4].Right(2));
}
void CCgeView::OnJuxing()
{
CCgeDoc *pDoc = (CCgeDoc *)GetDocument();
CSinDia dlg;
if(pDoc->Num_Pointes <= 8192)
{
dlg.len = pDoc->Num_Pointes;
}else
{
dlg.len = 8192;
}
dlg.m_Fangs = _T(" y = sin(x) 模拟 ");
if(pDoc->m_CMyLineList.IsEmpty())
{
dlg.m_dtf = 1.0 ; //s <1*T/2
//dlg.m_dtf = 0.1 ;
for(int x=0; x<dlg.len; x++)
{
//dlg.wnin[x] = sin(x*6*3.14159*dlg.m_dtf); //3Hz
dlg.wnin[x] = sin(x*1.0*dlg.m_dtf); // 1/(2*pi) Hz
}
}else
{
int i,j;
CMyLine *pMyLine;
pDoc->m_Mps = pDoc->m_CMyLineList.GetHeadPosition();//获得连表的头
int sel_n;
if(pDoc->Fangs == pDoc->s[0])
{
sel_n = 0;
CString s;
s.Format("%d",pDoc->m_N0);
dlg.m_Fangs = s;
}else
{
sel_n = atoi(Fangs) - pDoc->m_N0;//+1;
dlg.m_Fangs = Fangs;
}
for( i=0;i<pDoc->Num_Line;i++)
{
for( j=0;j<dlg.len;j++)
{
pMyLine = (CMyLine* )pDoc->m_CMyLineList.GetAt( pDoc->m_Mps );
if(i==sel_n)
{
dlg.wnin[j] = pMyLine->y;
}
pMyLine = (CMyLine* )pDoc->m_CMyLineList.GetNext(pDoc->m_Mps);
}
}
dlg.m_dtf = pDoc->m_dtf /1000.0; //s
}
dlg.DoModal();
//pDoc->UpdateAllViews(NULL);
//Invalidate();
}
void CCgeView::OnXuebo()
{
m_SBKey = !m_SBKey;
}
void CCgeView::OnUpdateXuebo(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck(m_SBKey);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -