📄 imagelabview.cpp
字号:
IsFreePan ^= 1;
}
void CImageLABView::OnUpdateFreepan(CCmdUI* pCmdUI)
{
pCmdUI->Enable(CanManualMove);
if(CanManualMove)
pCmdUI->SetCheck(IsFreePan);
else
pCmdUI->SetCheck(false);
}
void CImageLABView::OnCaptureCcd()
{
if(hcg200 == NULL) return;
CImageLABDoc* pDoc = GetDocument();
if(bFreeze)
{
CG200Capture(hcg200, true);
bFreeze = false;
IsScrnImageMemDCOK = false;
pDoc->SetModifiedFlag(false);
}
else
{
int ImageW = pDoc->Image.m_ImageWidth;
int ImageH = pDoc->Image.m_ImageHeight;
int LineL = ImageW* 3;
BYTE *lpNowImage = new BYTE[ImageW* LineL];
CG200Capture(hcg200, false);
bFreeze = true;
//采集图像
DWORD dwPage, PhysMemAddr, MemHandle, LineAddr;
StaticMemAlloc(&dwPage, &PhysMemAddr, &MemHandle, &LineAddr);
char *lpSourceBuf = (char *)LineAddr;
CG200SetDispWindow(hcg200, VideoRect.left, VideoRect.top,
ImageW, ImageH);
CG200CaptureToMem(hcg200, PhysMemAddr, dwPage*4*1024, 2, FRAME, 1);
CG200ReadFromMem( hcg200, lpSourceBuf, dwPage*4*1024, 0, (char *)lpNowImage);
CG200SetDispWindow(hcg200, VideoRect.left, VideoRect.top,
VideoRect.Width(), VideoRect.Height());
BYTE *lpTemp = lpNowImage;
for(int j= ImageH - 1; j >=0 ; j--, lpTemp += LineL)
{
memcpy(pDoc->Image.RowAddress[j], lpTemp, LineL);
}
pDoc->SetModifiedFlag();
if( lpNowImage != NULL) delete []lpNowImage;
}
}
void CImageLABView::OnUpdateCaptureCcd(CCmdUI* pCmdUI)
{
CImageLABDoc* pDoc = GetDocument();
if( pDoc->Image.m_SorceType == 1 )
{
pCmdUI->Enable(true);
pCmdUI->SetCheck(!bFreeze);
}
else
pCmdUI->Enable(false);
}
void CImageLABView::OnShowpin()
{
for(int i= 0; i< MAXPINNUM; i++)
{
if( m_Pin[i] == NULL ) continue;
IsPinVisible = m_Pin[i]->IsWindowVisible();
m_Pin[i]->ShowWindow(IsPinVisible ? SW_HIDE : SW_NORMAL);
}
}
void CImageLABView::OnUpdateShowpin(CCmdUI* pCmdUI)
{
pCmdUI->SetText(IsPinVisible ? "隐藏标记" : "显示标记");
pCmdUI->SetCheck(IsPinVisible);
}
void CImageLABView::OnPrint(CDC* pDC, CPrintInfo* pInfo)
{
CString strBuffer;
strBuffer = AfxGetApp()->GetProfileString("Settings", "Print Number");
if(!strBuffer.IsEmpty())
{
_stscanf(strBuffer, "%d", &m_PrintNumber);
}
else
m_PrintNumber = 0;
m_PrintNumber++;
strBuffer.Format("%d",m_PrintNumber);
AfxGetApp()->WriteProfileString("Settings", "Print Number", strBuffer);
// TODO: Add your specialized code here and/or call the base class
// get string to show as "filename" in header/footer
LPCTSTR pszFileName = GetDocument()->GetPathName();
if (pszFileName[0] == 0)
pszFileName = GetDocument()->GetTitle();
// go thru global CPageSetupDlg to format the header and footer
CString strHeader = CString( pszFileName );
TEXTMETRIC tm;
pDC->GetTextMetrics(&tm);
int cyChar = tm.tmHeight;
CRect rectPage = pInfo->m_rectDraw;
// draw and exclude space for header
if (!strHeader.IsEmpty())
{
pDC->TextOut(rectPage.left, rectPage.top, strHeader);
rectPage.top += cyChar + cyChar / 4;
pDC->MoveTo(rectPage.left, rectPage.top);
pDC->LineTo(rectPage.right, rectPage.top);
rectPage.top += cyChar / 4;
}
CImageLABDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
if( m_OtherDesStore != ""|m_Patient!= ""|m_Docter!= "")
{
TEXTMETRIC tm;
CFont fontText;
fontText.CreateFont(-5*20,0,0,0,400,FALSE,FALSE,0,
ANSI_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,
DEFAULT_PITCH|FF_SWISS,"Arial");
CFont*pOldFont=(CFont*)pDC->SelectObject(&fontText);
pDC->GetTextMetrics(&tm);
rectPage.top += 100;
CRect TextRect1(60, rectPage.top, rectPage.Width(), rectPage.top + 40);
// pDC->SetTextAlign( TA_LEFT );
pDC->DrawText(m_Hospital+"放射科照片报告单",TextRect1, DT_NOCLIP|DT_NOPREFIX|DT_EXPANDTABS|DT_CENTER);
pDC->SelectObject(pOldFont);
int position=(rectPage.Width()-60)/8;
rectPage.top += 320;
pDC->TextOut(60, rectPage.top, "姓 名:");
pDC->TextOut(60+position, rectPage.top, m_Patient);
pDC->TextOut(60+2*position, rectPage.top, "性 别:");
pDC->TextOut(60+3*position, rectPage.top, m_Sex);
pDC->TextOut(60+4*position, rectPage.top, "年 龄:");
pDC->TextOut(60+5*position, rectPage.top, m_Age);
pDC->TextOut(60+6*position, rectPage.top, "X光号:");
pDC->TextOut(60+7*position, rectPage.top, m_Xray);
rectPage.top += 170;
pDC->TextOut(60, rectPage.top, "科 别:");
pDC->TextOut(60+position, rectPage.top, m_Depart);
pDC->TextOut(60+2*position, rectPage.top, "病 室:");
pDC->TextOut(60+3*position, rectPage.top, m_Room);
pDC->TextOut(60+4*position, rectPage.top, "门诊号:");
pDC->TextOut(60+5*position, rectPage.top, m_Nomz);
pDC->TextOut(60+6*position, rectPage.top, "住院号:");
pDC->TextOut(60+7*position, rectPage.top, m_Nozy);
rectPage.top += 170;
pDC->TextOut(60, rectPage.top, "印象:");
CRect TextRect3(60+position, rectPage.top, rectPage.Width()-100, rectPage.top + 600);
pDC->DrawText(m_OtherDesStore, TextRect3, DT_NOCLIP|DT_NOPREFIX|DT_EXPANDTABS|
DT_END_ELLIPSIS|DT_WORDBREAK|DT_LEFT);
rectPage.top += 720;
pDC->TextOut(60+6*position, rectPage.top, "检查医师:");
pDC->TextOut(60+7*position, rectPage.top, m_Docter);
}
rectPage.top += 220;
int w = int( pDoc->Image.m_ImageWidth );
int h = int( pDoc->Image.m_ImageHeight );
int LimitH = rectPage.Height()* 4/ 5;
double scale1 = (double)w / (double)rectPage.Width();
double scale2 = (double)h / (double)LimitH;
int LeftX = 0, RightX, BottomY = rectPage.top;
if( scale1 > scale2 )
{
RightX = rectPage.Width();
BottomY+= int(LimitH* scale2/ scale1 + 0.5 );
}
else
{
int TW = int( rectPage.Width()* scale1/ scale2 + 0.5 );
LeftX = rectPage.left + (rectPage.Width() - TW)/ 2;
RightX = LeftX + TW;
BottomY+= LimitH;
}
pDC->SetTextAlign( TA_CENTER );
int x, y;
CString msg;
CRect showrect = CRect(LeftX, rectPage.top, RightX, BottomY);
if( CImageLABApp::m_iPrintMode == 1 )
{
x = showrect.Width() * 2 / 3;
y = showrect.Height() * 2 / 3;
showrect.left = x / 4;
showrect.top += y / 8;
showrect.right = showrect.left + x;
showrect.bottom = showrect.top + y;
BottomY = showrect.bottom + y / 8;
}
else if( CImageLABApp::m_iPrintMode == 2 )
{
x = showrect.Width() / 3;
y = showrect.Height() / 3;
showrect.left = x;
showrect.top += y / 8;
showrect.right = showrect.left + x;
showrect.bottom = showrect.top + y;
BottomY = showrect.bottom + y / 8;
}
CBitmap TagBmp , *OldBmp;
BOOL is = TagBmp.LoadBitmap(IDB_BITMAP_TAG);
CSize BmpSize(48, 48);
int Width = 200;
CDC TagDC;
TagDC.CreateCompatibleDC(pDC);
OldBmp = TagDC.SelectObject(&TagBmp);
pDC->SetBkMode(TRANSPARENT);
pDC->SetTextAlign( TA_RIGHT );
if( DashRectDrawed )
{
CPoint p1, p2;
GetSelectArea(p1, p2);
CImage temp(pDoc->Image, p1, p2);
temp.ShowCurrentImage(pDC, showrect);
int tw = int( temp.m_ImageWidth );
int th = int( temp.m_ImageHeight );
for(int i= 0; i< MAXPINNUM; i++)
{
if( m_Pin[i] == NULL ) continue;
if( m_PinPos[i].x < p1.x ) continue;
if( m_PinPos[i].y < p1.y ) continue;
if( m_PinPos[i].x > p2.x ) continue;
if( m_PinPos[i].y > p2.y ) continue;
x = showrect.left + int( (float)(m_PinPos[i].x - p1.x)* showrect.Width()/ (float)tw );
y = showrect.top + int( (float)(m_PinPos[i].y - p1.y)* showrect.Height()/ (float)th );
msg.Format("%d", i+ 1);
pDC->MoveTo(x+1, y+2);
pDC->LineTo(x+1+4*4, y + 2+33*4);
pDC->LineTo(x+1+9*4, y+2+12*4);
pDC->LineTo(x+1+40*4, y+ 2+46*4);
pDC->LineTo(x+1 +46*4, y + 2+40*4);
pDC->LineTo(x+1+14*4, y + 2+8*4);
pDC->LineTo(x+ 1+30*4, y + 2+4*4);
pDC->LineTo(x+1, y+2);
pDC->TextOut(x+ Width, y, msg);
}
}
else
{
pDoc->Image.ShowCurrentImage(pDC, showrect);
for(int i= 0; i< MAXPINNUM; i++)
{
if( m_Pin[i] == NULL ) continue;
x = showrect.left + int( (float)m_PinPos[i].x * showrect.Width()/ (float)w );
y = showrect.top + int( (float)m_PinPos[i].y * showrect.Height()/ (float)h );
msg.Format("%d", i+ 1);
pDC->MoveTo(x+1, y+2);
pDC->LineTo(x+1+4*4, y + 2+33*4);
pDC->LineTo(x+1+9*4, y+2+12*4);
pDC->LineTo(x+1+40*4, y+ 2+46*4);
pDC->LineTo(x+1 +46*4, y + 2+40*4);
pDC->LineTo(x+1+14*4, y + 2+8*4);
pDC->LineTo(x+ 1+30*4, y + 2+4*4);
pDC->LineTo(x+1, y+2);
// pDC->StretchBlt(x, y, 200, 200, &TagDC, 0, 0,
// BmpSize.cx, BmpSize.cy, MERGECOPY );
pDC->TextOut(x+ Width, y, msg);
}
}
TagDC.SelectObject(OldBmp);
pDC->SelectStockObject(NULL_BRUSH);
pDC->Rectangle(showrect);
// draw footer
rectPage.bottom -= 3* cyChar;
CTime time = CTime::GetCurrentTime();
CString strDate = time.Format(_T("%d/%m/%Y %A %H:%M:%S"));
pDC->SetTextAlign( TA_CENTER );
pDC->TextOut( (rectPage.left + rectPage.right)/ 2, rectPage.bottom, strDate);
rectPage.bottom -= cyChar / 4;
pDC->MoveTo(rectPage.left, rectPage.bottom);
pDC->LineTo(rectPage.right, rectPage.bottom);
// allow space for footer
pInfo->m_rectDraw = rectPage;
pInfo->m_rectDraw.bottom -= cyChar + cyChar/4 + cyChar/4;
}
/*void CImageLABView::OnPrint(CDC* pDC, CPrintInfo* pInfo)
{
CString strBuffer;
strBuffer = AfxGetApp()->GetProfileString("Settings", "Print Number");
if(!strBuffer.IsEmpty())
{
_stscanf(strBuffer, "%d", &m_PrintNumber);
}
else
m_PrintNumber = 0;
m_PrintNumber++;
strBuffer.Format("%d",m_PrintNumber);
AfxGetApp()->WriteProfileString("Settings", "Print Number", strBuffer);
// TODO: Add your specialized code here and/or call the base class
// get string to show as "filename" in header/footer
LPCTSTR pszFileName = GetDocument()->GetPathName();
if (pszFileName[0] == 0)
pszFileName = GetDocument()->GetTitle();
// go thru global CPageSetupDlg to format the header and footer
CString strHeader = CString( pszFileName );
TEXTMETRIC tm;
pDC->GetTextMetrics(&tm);
int cyChar = tm.tmHeight;
CRect rectPage = pInfo->m_rectDraw;
// draw and exclude space for header
if (!strHeader.IsEmpty())
{
pDC->TextOut(rectPage.left, rectPage.top, strHeader);
rectPage.top += cyChar + cyChar / 4;
pDC->MoveTo(rectPage.left, rectPage.top);
pDC->LineTo(rectPage.right, rectPage.top);
rectPage.top += cyChar / 4;
}
CImageLABDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
rectPage.top += 40;
int w = int( pDoc->Image.m_ImageWidth );
int h = int( pDoc->Image.m_ImageHeight );
int LimitH = rectPage.Height()* 4/ 5;
double scale1 = (double)w / (double)rectPage.Width();
double scale2 = (double)h / (double)LimitH;
int LeftX = 0, RightX, BottomY = rectPage.top;
if( scale1 > scale2 )
{
RightX = rectPage.Width();
BottomY+= int(LimitH* scale2/ scale1 + 0.5 );
}
else
{
int TW = int( rectPage.Width()* scale1/ scale2 + 0.5 );
LeftX = rectPage.left + (rectPage.Width() - TW)/ 2;
RightX = LeftX + TW;
BottomY+= LimitH;
}
pDC->SetTextAlign( TA_CENTER );
int x, y;
CString msg;
CRect showrect = CRect(LeftX, rectPage.top, RightX, BottomY);
if( CImageLABApp::m_iPrintMode == 1 )
{
x = showrect.Width() * 2 / 3;
y = showrect.Height() * 2 / 3;
showrect.left = x / 4;
showrect.top += y / 8;
showrect.right = showrect.left + x;
showrect.bottom = showrect.top + y;
BottomY = showrect.bottom + y / 8;
}
else if( CImageLABApp::m_iPrintMode == 2 )
{
x = showrect.Width() / 3;
y = showrect.Height() / 3;
showrect.left = x;
showrect.top += y / 8;
showrect.right = showrect.left + x;
showrect.bottom = showrect.top + y;
BottomY = showrect.bottom + y / 8;
}
CBitmap TagBmp , *OldBmp;
BOOL is = TagBmp.LoadBitmap(IDB_BITMAP_TAG);
CSize BmpSize(48, 48);
int Width = 200;
CDC TagDC;
TagDC.CreateCompatibleDC(pDC);
OldBmp = TagDC.SelectObject(&TagBmp);
pDC->SetBkMode(TRANSPARENT);
pDC->SetTextAlign( TA_RIGHT );
if( DashRectDrawed )
{
CPoint p1, p2;
GetSelectArea(p1, p2);
CImage temp(pDoc->Image, p1, p2);
temp.ShowCurrentImage(pDC, showrect);
int tw = int( temp.m_ImageWidth );
int th = int( temp.m_ImageHeight );
for(int i= 0; i< MAXPINNUM; i++)
{
if( m_Pin[i] == NULL ) continue;
if( m_PinPos[i].x < p1.x ) continue;
if( m_PinPos[i].y < p1.y ) continue;
if( m_PinPos[i].x > p2.x ) continue;
if( m_PinPos[i].y > p2.y ) continue;
x = showrect.left + int( (float)(m_PinPos[i].x - p1.x)* showrect.Width()/ (float)tw );
y = showrect.top + int( (float)(m_PinPos[i].y - p1.y)* showrect.Height()/ (float)th );
msg.Format("%d", i+ 1);
pDC->MoveTo(x+1, y+2);
pDC->LineTo(x+1+4*4, y + 2+33*4);
pDC->LineTo(x+1+9*4, y+2+12*4);
pDC->LineTo(x+1+40*4, y+ 2+46*4);
pDC->LineTo(x+1 +46*4, y + 2+40*4);
pDC->LineTo(x+1+14*4, y + 2+8*4);
pDC->LineTo(x+ 1+30*4, y + 2+4*4);
pDC->LineTo(x+1, y+2);
pDC->TextOut(x+ Width, y, msg);
}
}
else
{
pDoc->Image.ShowCurrentImage(pDC, showrect);
for(int i= 0; i< MAXPINNUM; i++)
{
if( m_Pin[i] == NULL ) continue;
x = showrect.left + int( (float)m_PinPos[i].x * showrect.Width()/ (float)w );
y = showrect.top + int( (float)m_PinPos[i].y * showrect.Height()/ (float)h );
msg.Format("%d", i+ 1);
pDC->MoveTo(x+1, y+2);
pDC->LineTo(x+1+4*4, y + 2+33*4);
pDC->LineTo(x+1+9*4, y+2+12*4);
pDC->LineTo(x+1+40*4, y+ 2+46*4);
pDC->LineTo(x+1 +46*4, y + 2+40*4);
pDC->LineTo(x+1+14*4, y + 2+8*4);
pDC->LineTo(x+ 1+30*4, y + 2+4*4);
pDC->LineTo(x+1, y+2);
// pDC->StretchBlt(x, y, 200, 200, &TagDC, 0, 0,
// BmpSize.cx, BmpSize.cy, MERGECOPY );
pDC->TextOut(x+ Width, y, msg);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -