📄 wgl_32view.cpp
字号:
}
else
SetClassLong(m_hWnd, GCL_HCURSOR, (LONG)HOldCursor);
if(nWhichCurve>=0)
{
nWhichCurve = -1;
InvalidateRect( NULL );
pDoc->UpdateView( TRUE, FALSE );
}
}
void CWgl_32View::OnShortseg()
{
CWgl_32Doc *pDoc = GetDocument();
if(pDoc->bReadError) return;
int& nWhichCurve=pDoc->nWhichCurve;
bShortSeg = !bShortSeg;
if(bShortSeg)
{
SetClassLong(m_hWnd, GCL_HCURSOR, (LONG)HOldCursor);
bCopyArea = FALSE;
bMove = FALSE;
bVExpand = FALSE;
bXExpand = FALSE;
if(bEditYcursor && nWhichCurve>=0)
{
nWhichCurve = -1;
InvalidateRect( NULL );
pDoc->UpdateView( TRUE, FALSE );
}
bEditYcursor = FALSE;
bCopyCurve = FALSE;
bDeleteCurve = FALSE;
}
InvertRect();
}
void CWgl_32View::OnEditCopyArea()
{
CWgl_32Doc *pDoc = GetDocument();
if(pDoc->bReadError) return;
int& nWhichCurve=pDoc->nWhichCurve;
bCopyArea = !bCopyArea;
if(bCopyArea)
{
bMove = FALSE;
bVExpand = FALSE;
bXExpand = FALSE;
bShortSeg = FALSE;
if(bEditYcursor && nWhichCurve>=0)
{
nWhichCurve = -1;
InvalidateRect( NULL );
pDoc->UpdateView( TRUE, FALSE );
}
bEditYcursor = FALSE;
bCopyCurve = FALSE;
bDeleteCurve = FALSE;
}
InvertRect();
}
void CWgl_32View::OnUpdateEditZoomin(CCmdUI* pCmdUI)
{
pCmdUI->Enable( bZoomIn );
}
void CWgl_32View::OnUpdateEditZoomout(CCmdUI* pCmdUI)
{
pCmdUI->Enable( bZoomOut );
}
void CWgl_32View::OnUpdateEditVexpand(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck( bVExpand );
}
void CWgl_32View::OnUpdateEditXexpand(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck( bXExpand );
}
void CWgl_32View::OnUpdateEditYcursor(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck( bEditYcursor );
}
void CWgl_32View::OnUpdateEditMove(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck( bMove );
}
void CWgl_32View::OnUpdateShortseg(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck( bShortSeg );
}
void CWgl_32View::OnUpdateEditCopyCurve(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck( bCopyCurve );
}
void CWgl_32View::OnUpdateEditDelete(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck( bDeleteCurve );
}
void CWgl_32View::OnUpdateEditCopyArea(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck( bCopyArea );
}
void CWgl_32View::OnUpdateDeleteSubCurve(CCmdUI* pCmdUI)
{
CWgl_32Doc *pDoc=GetDocument();
BOOL bShowSubCurve=pDoc->bShowSubCurve;
pCmdUI->Enable( bShowSubCurve );
if(bShowSubCurve)
pCmdUI->SetCheck( pDoc->bDelSubCurve );
}
void CWgl_32View::OnDeleteSubCurve()
{
CWgl_32Doc *pDoc=GetDocument();
if(pDoc->bReadError) return;
if(pDoc->bShowSubCurve)
pDoc->bDelSubCurve = !pDoc->bDelSubCurve;
else
pDoc->bDelSubCurve = FALSE;
}
//Acording the Channel Number,Calculate the LOCAL display Index
int CWgl_32View::GetCurveDisplayIndex(long Number)
{
CWgl_32Doc *pDoc = GetDocument();
WORD m_NumPerView = pDoc->m_NumPerView;
WORD m_ViewChannel = pDoc->m_ViewChannel;
WORD m_ViewChannelMax = pDoc->m_ViewChannelMax;
ChannelNumber *m_pChannelIndex = pDoc->m_pChannelIndex;
int k = -1;
for(int i=m_ViewChannel; i<=m_ViewChannelMax; i++)
{
if( m_pChannelIndex[i].bShow ) k++;
if( m_pChannelIndex[i].No == Number )
{
if(k > m_NumPerView || m_pChannelIndex[k].bShow==0)
return -1;
return k;
}
}
return -1;
}
//Acording the Channel Number,Calculate the TOTAL display Index
int CWgl_32View::GetCurveNumberIndex(long Number)
{
CWgl_32Doc *pDoc = GetDocument();
ChannelNumber *m_pChannelIndex = pDoc->m_pChannelIndex;
WORD& m_ChannelNum = pDoc->m_ChannelNum;
for(int i=0; i<m_ChannelNum; i++)
if( m_pChannelIndex[i].No == Number )
return i;
return -1;
}
//Acording the display point,Calculate the channel number
int CWgl_32View::GetCurveNumber(CPoint point)
{
CWgl_32Doc *pDoc = GetDocument();
ChannelNumber *m_pChannelIndex = pDoc->m_pChannelIndex;
WORD m_ViewChannel = pDoc->m_ViewChannel;
WORD m_ViewChannelMin = pDoc->m_ViewChannelMin;
WORD m_ViewChannelMax = pDoc->m_ViewChannelMax;
WORD CurveHeigh = pDoc->HalfCurveHeigh*2;
int k = m_ViewChannel;
int kc = CurveHeigh;
while(kc < point.y)
{
if(m_pChannelIndex[k++].bShow)
kc += CurveHeigh;
while(k <= m_ViewChannelMax && m_pChannelIndex[k].bShow==0)
k++;
}
if(k < m_ViewChannelMin) return -1;
if(k > m_ViewChannelMax) return -1;
k = m_pChannelIndex[k].No;
return k;
}
void CWgl_32View::OnLButtonUp(UINT nFlags, CPoint point)
{
CWgl_32Doc *pDoc = GetDocument();
if(pDoc->bReadError) return;
CRect rect;
GetClientRect( &rect );
CClientDC dc(this);
if(bXExpand && bLButtonDown)
{
ReleaseCapture();
bXExpand = bLButtonDown = FALSE;
SetClassLong(m_hWnd, GCL_HCURSOR, (LONG)HOldCursor);
if(!rect.PtInRect(point))
{
CPen *OldPen = (CPen *)dc.SelectObject(&AxialPen[4]);
int DrawMode = dc.SetROP2(R2_XORPEN);
dc.MoveTo(nxExpandPre, 0);
dc.LineTo(nxExpandPre, rect.bottom);
if(nxExpandPre!=nXExpandIni)
{
dc.MoveTo(nXExpandIni, 0);
dc.LineTo(nXExpandIni, rect.bottom);
}
dc.SetROP2( DrawMode );
dc.SelectObject( OldPen );
return;
}
int nWidth = point.x-nXExpandIni;
if(nWidth == 0) {
InvalidateRect( NULL );
return;
}
if(nWidth < 0)
{
nWidth = -nWidth;
nxExpandPre = nXExpandIni;
nXExpandIni = point.x;
point.x = nXExpandIni;
}
double& m_XSizeFactor = pDoc->m_XSizeFactor;
int OffX = intINT(nXExpandIni/m_XSizeFactor);
pDoc->PageFromSampNum += OffX;
m_XSizeFactor = m_XSizeFactor*rect.right/nWidth;
bZoomOut = TRUE;
if(m_XSizeFactor>=m_MaxFactorX)
{
m_XSizeFactor = m_MaxFactorX;
bZoomIn = FALSE;
}
SetResynScroll(rect.right,rect.bottom);
InvalidateRect( NULL );
pDoc->UpdateView( FALSE, TRUE );
return;
}
if(bShortSeg && bLButtonDown)
{
ReleaseCapture();
bShortSeg = bLButtonDown = FALSE;
SetClassLong(m_hWnd, GCL_HCURSOR, (LONG)HOldCursor);
if(!rect.PtInRect(point) || pDoc->SetNewSegment(nXExpandIni,point.x))
{
CPen *OldPen = (CPen *)dc.SelectObject(&AxialPen[4]);
int DrawMode = dc.SetROP2(R2_XORPEN);
dc.MoveTo(nxExpandPre, 0);
dc.LineTo(nxExpandPre, rect.bottom);
if(nxExpandPre!=nXExpandIni)
{
dc.MoveTo(nXExpandIni, 0);
dc.LineTo(nXExpandIni, rect.bottom);
}
dc.SetROP2( DrawMode );
dc.SelectObject( OldPen );
return;
}
SetResynScroll(rect.right,rect.bottom);
pDoc->AdjustSampIndex(pDoc->LCursor,FALSE);
pDoc->AdjustSampIndex(pDoc->RCursor,FALSE);
InvalidateRect( NULL );
pDoc->UpdateView( FALSE, TRUE );
return;
}
if(bCopyArea && bLButtonDown)
{
ReleaseCapture();
bLButtonDown = bCopyArea = FALSE;
int DrawMode = dc.SetROP2(R2_XORPEN);
CBrush *OldBrush = (CBrush *)dc.SelectStockObject(NULL_BRUSH);
CPen *OldPen = (CPen *)dc.SelectObject(&AxialPen[4]);
if(ptPre!=ptIni)
{
int xl = min(ptPre.x, ptIni.x);
int xr = max(ptPre.x, ptIni.x);
int yt = min(ptPre.y, ptIni.y);
int yb = max(ptPre.y, ptIni.y);
dc.Rectangle(xl,yt,xr,yb);
}
dc.SetROP2( DrawMode );
dc.SelectObject( OldPen );
dc.SelectObject( OldBrush );
if(ptIni != point)
CopyScrnToClipBoard(ptIni,point);
}
}
void CWgl_32View::CopyScrnToClipBoard(CPoint ptIni,CPoint ptEnd)
{
if( !OpenClipboard() )
{
AfxMessageBox("不能打开剪贴板!");
return;
}
EmptyClipboard();
ClientToScreen(&ptIni);
ClientToScreen(&ptEnd);
int xl = min(ptEnd.x, ptIni.x);
int xr = max(ptEnd.x, ptIni.x);
int yt = min(ptEnd.y, ptIni.y);
int yb = max(ptEnd.y, ptIni.y);
CDC ScrDC,MemDC;
ScrDC.CreateDC("DISPLAY",NULL,NULL,NULL);
MemDC.CreateCompatibleDC(NULL);
CBitmap bitmap;
bitmap.CreateCompatibleBitmap(&ScrDC,xr-xl,yb-yt);
CBitmap *bmOld = (CBitmap *)MemDC.SelectObject(bitmap);
MemDC.BitBlt(0,0,xr-xl,yb-yt,&ScrDC,xl,yt,SRCCOPY);
if(::SetClipboardData(CF_BITMAP,bitmap.Detach())==NULL)
AfxMessageBox("不能设置剪贴板的数据!");
CloseClipboard();
}
void CWgl_32View::OnMouseMove(UINT nFlags, CPoint point)
{
if( !bLButtonDown ) return;
CClientDC dc(this);
if(bXExpand || bShortSeg)
{
CPen *OldPen = (CPen *)dc.SelectObject(&AxialPen[4]);
int DrawMode = dc.SetROP2(R2_XORPEN);
CRect rect;
GetClientRect( &rect );
if(nxExpandPre!=nXExpandIni)
{
dc.MoveTo(nxExpandPre, 0);
dc.LineTo(nxExpandPre, rect.bottom);
}
nxExpandPre = point.x;
if(nxExpandPre!=nXExpandIni)
{
dc.MoveTo(nxExpandPre, 0);
dc.LineTo(nxExpandPre, rect.bottom);
}
dc.SetROP2( DrawMode );
dc.SelectObject( OldPen );
return;
}
if(bCopyArea)
{
int DrawMode = dc.SetROP2(R2_XORPEN);
CBrush *OldBrush = (CBrush *)dc.SelectStockObject(NULL_BRUSH);
CPen *OldPen = (CPen *)dc.SelectObject(&AxialPen[4]);
if(ptPre!=ptIni)
{
int xl = min(ptPre.x, ptIni.x);
int xr = max(ptPre.x, ptIni.x);
int yt = min(ptPre.y, ptIni.y);
int yb = max(ptPre.y, ptIni.y);
dc.Rectangle(xl,yt,xr,yb);
}
ptPre = point;
if(ptPre!=ptIni)
{
int xl = min(ptPre.x, ptIni.x);
int xr = max(ptPre.x, ptIni.x);
int yt = min(ptPre.y, ptIni.y);
int yb = max(ptPre.y, ptIni.y);
dc.Rectangle(xl,yt,xr,yb);
}
dc.SetROP2( DrawMode );
dc.SelectObject( OldPen );
dc.SelectObject( OldBrush );
return;
}
}
BOOL CWgl_32View::GetCurveValue(int PointY, double& value)
{
CWgl_32Doc *pDoc = GetDocument();
int m_ViewChannel = pDoc->m_ViewChannel;
int m_NumPerView = pDoc->m_NumPerView;
int& nWhichCurve = pDoc->nWhichCurve;
int Mean = GetCurveNumberIndex(nWhichCurve);
Mean = Mean-m_ViewChannel;
if(Mean < 0 || Mean>m_ViewChannel+m_NumPerView) // Not displayed in CURRENT view
return FALSE;
ChannelNumber *m_pChannelIndex = pDoc->m_pChannelIndex;
WORD m_ChannelNum = pDoc->m_ChannelNum;
Channel* m_pChannel=pDoc->m_pChannel;
int HalfCurveHeigh = pDoc->HalfCurveHeigh;
int CurveHeigh = HalfCurveHeigh*2;
double max,min;
if(m_pChannel[nWhichCurve].VAD==0)
{
max = pDoc->maxA;
min = pDoc->minA;
}
else
{
max = pDoc->maxV;
min = pDoc->minV;
}
double factor = m_pChannelIndex[nWhichCurve].YFactor*CurveHeigh;
Mean = CurveHeigh*Mean+HalfCurveHeigh;
value = (Mean-PointY)*(max-min)/factor;
value = value;//+0.5*(max+min);
max = m_pChannel[nWhichCurve].max;
min = m_pChannel[nWhichCurve].min;
if(value > max) value = max;
if(value < min) value = min;
return TRUE;
}
void CWgl_32View::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
CWgl_32Doc *pDoc = GetDocument();
if(pDoc->bReadError) return;
CClientDC dc( this );
CRect rect;
GetClientRect( &rect );
double m_XSizeFactor = pDoc->m_XSizeFactor;
unsigned long PageFromSampNum = pDoc->PageFromSampNum;
unsigned long EndSampNum;
pDoc->GetNextHPage(EndSampNum);
unsigned long& LCursor=pDoc->LCursor;
unsigned long& RCursor=pDoc->RCursor;
int DrawMode;
int xpos;
CPen *OldPen;
unsigned long CursorOld;
switch(nChar)
{
case VK_LEFT:
OldPen = (CPen *)dc.SelectObject( &LPen );
DrawMode = dc.SetROP2(R2_XORPEN);
pDoc->GetHNumPosit(xpos,LCursor);
dc.MoveTo(xpos,0);
dc.LineTo(xpos,rect.bottom);
CursorOld = LCursor;
if(LCursor > 0) LCursor = LCursor-1;
LCursor = max(PageFromSampNum, LCursor);
pDoc->AdjustSampIndex(LCursor,FALSE);
pDoc->GetHNumPosit(xpos,LCursor);
dc.MoveTo(xpos,0);
dc.LineTo(xpos,rect.bottom);
dc.SelectObject( OldPen );
dc.SetROP2( DrawMode );
if(CursorOld != LCursor)
pDoc->UpdateAllViews( this );
break;
case VK_RIGHT:
OldPen = (CPen *)dc.SelectObject( &LPen );
DrawMode = dc.SetROP2(R2_XORPEN);
pDoc->GetHNumPosit(xpos,LCursor);
dc.MoveTo(xpos,0);
dc.LineTo(xpos,rect.bottom);
CursorOld = LCursor;
LCursor = LCursor+1;
LCursor = min(EndSampNum, LCursor);
pDoc->AdjustSampIndex(LCursor,TRUE);
pDoc->GetHNumPosit(xpos,LCursor);
dc.MoveTo(xpos,0);
dc.LineTo(xpos,rect.bottom);
dc.SelectObject( OldPen );
dc.SetROP2( DrawMode );
if(CursorOld != LCursor)
pDoc->UpdateAllViews( this );
break;
case VK_UP:
OldPen = (CPen *)dc.SelectObject( &RPen );
DrawMode = dc.SetROP2(R2_XORPEN);
pDoc->GetHNumPosit(xpos,RCursor);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -