📄 righview.cpp
字号:
// RighView.cpp : implementation file
//
#include "stdafx.h"
#include "cge.h"
#include "RighView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
const COLORREF LRGB = RGB(0,0,255);
const COLORREF RRGB = RGB(255,0,0);
const COLORREF MRGB = RGB(255,0,255);
extern int intINT( double );
#define DISTEXTHIGH 7
/////////////////////////////////////////////////////////////////////////////
// CRighView
IMPLEMENT_DYNCREATE(CRighView, CView)
CRighView::CRighView()
{
Font1.CreatePointFont(DISTEXTHIGH*10,"Arial");
Font2.CreatePointFont((DISTEXTHIGH+1)*10,"Arial");
WhichCurve = -1;
}
CRighView::~CRighView()
{
}
BEGIN_MESSAGE_MAP(CRighView, CView)
//{{AFX_MSG_MAP(CRighView)
ON_WM_CREATE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CRighView drawing
void CRighView::OnDraw(CDC* pDC)
{
CCgeDoc* pDoc = GetDocument();
if(pDoc->bReadError) return;
CRect rect;
GetClientRect( &rect );
rect.right -= cxVScroll;
int OldBKMode = pDC->SetBkMode( TRANSPARENT );
CFont *OldFont=(CFont *)pDC->SelectObject(CFont::FromHandle(Font1));
pDC->TextOut(rect.right+2,-1,"ms");
pDC->MoveTo(0, 1);
pDC->LineTo(rect.right, 1);
double *RelateTime = pDoc->RelateTime;
double m_XSizeFactor = pDoc->m_XSizeFactor;
unsigned long EndSampNum = pDoc->EndSampNum;
unsigned long PageFromSampNum=pDoc->PageFromSampNum;
unsigned long LCursor = pDoc->LCursor;
unsigned long RCursor = pDoc->RCursor;
double LCursorA = pDoc->LCursorA;
double RCursorA = pDoc->RCursorA;
int nWhichCurve = pDoc->nWhichCurve;
if(nWhichCurve >= 0)
WhichCurve = nWhichCurve;
if(WhichCurve >= 0)
{
Channel* m_pChannel = &(pDoc->m_pChannel[WhichCurve]);
double a = m_pChannel->a;
double b = m_pChannel->b;
LCursorA = a*LCursorA+b;
RCursorA = a*RCursorA+b;
}
CString strTemp;
strTemp.Format("%-10.3f",RelateTime[EndSampNum-1]/1000);
strTemp.TrimRight();
CSize size=pDC->GetTextExtent(strTemp);
int step = size.cx;
int cyH = DISTEXTHIGH+1;
int nGrid = 0;
int xcStart = 0;
int xlstartA = 0;
ShortNode *pShortNode = pDoc->m_pShortNode;
while(pShortNode[xlstartA].lend <= PageFromSampNum)
xlstartA ++;
xlstartA--;
int& ShortNodeNum=pDoc->ShortNodeNum;
unsigned long lli = PageFromSampNum;
while(xlstartA < ShortNodeNum)
{
while(xlstartA < ShortNodeNum && pShortNode[xlstartA].bShow==0)
{
int tw;
if(lli == pShortNode[xlstartA].lend)
tw = pDoc->ShortWidth;
else
tw = pDoc->ShortWidth/2;
pDC->MoveTo(xcStart, 0);
pDC->LineTo(xcStart, cyH);
pDC->MoveTo(xcStart+tw, 0);
pDC->LineTo(xcStart+tw, cyH);
xcStart += tw;
xlstartA++;
lli = pShortNode[xlstartA].lend;
if(xcStart >= rect.right) break;
}
xlstartA ++;
unsigned long lle;
if(xlstartA < ShortNodeNum)
{
lle = pShortNode[xlstartA].lend;
if(lle != EndSampNum) lle++;
}
else
goto next;
double xxi = xcStart;
for(; lli < lle; lli++)
{
if(xxi >= nGrid*step)
{
nGrid ++;
int xi = intINT( xxi );
pDC->MoveTo(xi, 0);
pDC->LineTo(xi,cyH);
strTemp.Format("%-10.3f",RelateTime[lli]/1000);
pDC->TextOut(int(xi), cyH, strTemp);
}
xxi = xxi+m_XSizeFactor;
if(xxi > rect.right)
goto next;
}
lli = pShortNode[xlstartA].lend;
xcStart = intINT(xxi);
} // end while(xlstartA < ShortNodeNum)
next:
rect.top = cyH+size.cy;
pDC->SelectStockObject(WHITE_BRUSH);
rect.right += cxVScroll+1;
rect.left = -1;
rect.bottom += 1;
pDC->Rectangle( rect );
pDC->SelectObject(CFont::FromHandle(Font2));
step = rect.right/6;
xcStart = 0;
cyH = rect.top+1;
double time = RelateTime[LCursor]/1000;
strTemp.Format("TL= %-10.3f",time);
COLORREF OldColor = pDC->SetTextColor(LRGB);
pDC->TextOut(xcStart,cyH,strTemp);
xcStart += step-10;
double timea = RelateTime[RCursor]/1000;
strTemp.Format("TR=%-10.3f",timea);
pDC->SetTextColor(RRGB);
pDC->TextOut(xcStart,cyH,strTemp);
xcStart += step-10;
strTemp.Format("TL-TR=%-10.3f",time-timea);
pDC->SetTextColor(MRGB);
pDC->TextOut(xcStart,cyH,strTemp);
xcStart += step+20;
if(WhichCurve==-1)
strTemp=_T("VL=");
else
strTemp.Format("VL=%-10.4f",LCursorA);
pDC->SetTextColor(LRGB);
pDC->TextOut(xcStart,cyH,strTemp);
xcStart += step-5;
if(WhichCurve==-1)
strTemp=_T("VR=");
else
strTemp.Format("VR=%-10.4f",RCursorA);
pDC->SetTextColor(RRGB);
pDC->TextOut(xcStart,cyH,strTemp);
xcStart += step-5;
if(WhichCurve==-1)
strTemp=_T("VL-VR=");
else
strTemp.Format("VL-VR=%-10.4f",LCursorA-RCursorA);
pDC->SetTextColor(MRGB);
pDC->TextOut(xcStart,cyH,strTemp);
pDC->SetTextColor( OldColor );
pDC->SetBkMode( OldBKMode );
pDC->SelectObject( &OldFont );
}
/////////////////////////////////////////////////////////////////////////////
// CRighView diagnostics
#ifdef _DEBUG
void CRighView::AssertValid() const
{
CView::AssertValid();
}
void CRighView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CWgl_32Doc* CRighView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CWgl_32Doc)));
return (CWgl_32Doc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CRighView message handlers
int CRighView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CView::OnCreate(lpCreateStruct) == -1)
return -1;
cxVScroll = GetSystemMetrics(SM_CXVSCROLL);
return 0;
}
void CRighView::OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView)
{
CSplitterWnd *pWnd = (CSplitterWnd *)GetParent();
pWnd->SetActivePane(0,1);
}
BOOL CRighView::PreCreateWindow(CREATESTRUCT& cs)
{
cs.lpszClass = AfxRegisterWndClass(CS_HREDRAW | CS_VREDRAW,
AfxGetApp()->LoadStandardCursor(IDC_ARROW), (HBRUSH)GetStockObject(LTGRAY_BRUSH));
return CView::PreCreateWindow(cs);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -