-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDCMOpenView.cpp
296 lines (226 loc) · 7.73 KB
/
DCMOpenView.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
// DCMOpenView.cpp : implementation of the CDCMOpenView class
//
#include "stdafx.h"
#include "DCMOpen.h"
#include "DCMOpenDoc.h"
#include "DCMOpenView.h"
#include "DlgImageIfo.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDCMOpenView
IMPLEMENT_DYNCREATE(CDCMOpenView, CView)
BEGIN_MESSAGE_MAP(CDCMOpenView, CView)
//{{AFX_MSG_MAP(CDCMOpenView)
ON_WM_LBUTTONDOWN()
ON_WM_LBUTTONUP()
ON_WM_MOUSEMOVE()
ON_COMMAND(ID_DEFAULT, OnDefault)
ON_COMMAND(ID_DICOMINFO, OnDicominfo)
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
ON_COMMAND(ID_FUCTION_32775, &CDCMOpenView::OnFuctionFangda)
ON_COMMAND(ID_FUCTION_32776, &CDCMOpenView::OnFuctionSuoXiao)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDCMOpenView construction/destruction
CDCMOpenView::CDCMOpenView()
{//对参数的初始化
// TODO: add construction code here
m_LPoint.x=0;
m_LPoint.y=0;
m_MPoint.x=0;
m_MPoint.y=0;
isLBDown=FALSE;
m_zoom = 1.0;
m_angel = 0.0;
}
CDCMOpenView::~CDCMOpenView()
{
}
BOOL CDCMOpenView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CDCMOpenView drawing
void CDCMOpenView::OnDraw(CDC* pDC)
{//将DICOM图像显示出来
CDCMOpenDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
pDoc->m_DCM.DCMDraw(pDC);
if(pDoc->m_DCM.p_DCM!=NULL)
{//在图像的右侧,将一些信息显示出来,对照软件图像右侧,就能看到这些信息
CString str;
char *name = new char [128];
memcpy(name,pDoc->m_DCM.CRDataset[19].data,128);//将CDCMOpenDoc中的m_DCM中的第19个表中的数据拷贝至name
name[2]=' ';
pDC->TextOut(600,10,name);//TextOut()函数就是用来显示文字的
pDC->TextOut(600,30,"PID:");
pDC->TextOut(650,30,pDoc->m_DCM.CRDataset[20].data);
pDC->TextOut(600,50,"SEX:");
pDC->TextOut(650,50,pDoc->m_DCM.CRDataset[21].data);
pDC->TextOut(600,70,pDoc->m_DCM.CRDataset[2].data);
pDC->TextOut(600,110,pDoc->m_DCM.CRDataset[14].data);
pDC->TextOut(600,130,pDoc->m_DCM.CRDataset[15].data);
int wc=pDoc->m_DCM.WC;
int ww=pDoc->m_DCM.WW;
str.Format("Window Center: %d ",wc);
pDC->TextOut(600,200,str);
str.Format("Window Width : %d ",ww);
pDC->TextOut(600,220,str);
}
}
/////////////////////////////////////////////////////////////////////////////
// CDCMOpenView printing
BOOL CDCMOpenView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CDCMOpenView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CDCMOpenView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CDCMOpenView diagnostics
#ifdef _DEBUG
void CDCMOpenView::AssertValid() const
{
CView::AssertValid();
}
void CDCMOpenView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CDCMOpenDoc* CDCMOpenView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CDCMOpenDoc)));
return (CDCMOpenDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CDCMOpenView message handlers
void CDCMOpenView::OnLButtonDown(UINT nFlags, CPoint point)
{//当鼠标左键按下后,isLBDown参数就会发生变化,这将导致OnMouseMove中的代码起作用
// TODO: Add your message handler code here and/or call default
isLBDown=TRUE;
m_LPoint=point;
m_prePoint=point;
CView::OnLButtonDown(nFlags, point);
}
void CDCMOpenView::OnLButtonUp(UINT nFlags, CPoint point)
{//当鼠标左键抬起后,isLBDown参数就会发生变化,这将导致OnMouseMove中的代码不起作用
// TODO: Add your message handler code here and/or call default
isLBDown=FALSE;
CView::OnLButtonUp(nFlags, point);
}
void CDCMOpenView::OnMouseMove(UINT nFlags, CPoint point)
{//当鼠标滑动时候,窗宽窗位会发生变化,point是鼠标在屏幕中的位置,这个值将会导致,窗宽窗位的值发生变化
// TODO: Add your message handler code here and/or call default
CDCMOpenDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
if(pDoc->m_DCM.p_DCM==NULL)
return ;
m_MPoint=point;
if(isLBDown)//只有当左键按下之后,以下代码才会发生改变,isLBDown值在OnLButtonDown()函数和OnLButtonUp()函数中会产生变化
{
// pDoc->m_DCM.WW+=(point.x-m_prePoint.x)*5;//计算窗宽
// pDoc->m_DCM.WC+=(point.y-m_prePoint.y)*5;//计算窗位
// if(pDoc->m_DCM.WW>4311)
// pDoc->m_DCM.WW=4311;//当窗宽大于4311,就直接赋值4311
// if(pDoc->m_DCM.WW<1)
// pDoc->m_DCM.WW=1;//同上
// if(pDoc->m_DCM.WC>2119)
// pDoc->m_DCM.WC=2119;//同上
// if(pDoc->m_DCM.WC<15)
// pDoc->m_DCM.WC=15;//同上
m_angel += (point.x - m_prePoint.x)/5;
m_prePoint=point;
int wc=pDoc->m_DCM.WC;
int ww=pDoc->m_DCM.WW;
delete[] pDoc->m_DCM.p_data1;
pDoc->m_DCM.p_data1 = new BYTE[pDoc->m_DCM.m_srcWidth*pDoc->m_DCM.m_srcHeight];
pDoc->m_DCM.CreatBMPDate(pDoc->m_DCM.p_data1 , wc ,ww );//每当窗宽窗位发生改变就吊用CreatBMPDate将图像值改变,进而改变图像的现实
::initTransPixelBuffer(pDoc->m_DCM.m_srcWidth,pDoc->m_DCM.m_srcHeight);
::GetTrans((unsigned char*)pDoc->m_DCM.p_data1,pDoc->m_DCM.p_data1,pDoc->m_DCM.m_srcWidth,pDoc->m_DCM.m_srcHeight,m_angel);
pDoc->m_DCM.m_Width = pDoc->m_DCM.m_srcWidth;
pDoc->m_DCM.m_Height = pDoc->m_DCM.m_srcHeight;
//pDoc->m_DCM.TransFer(m_angel);
Invalidate(TRUE);
}
// Invalidate(TRUE);
CView::OnMouseMove(nFlags, point);
}
void CDCMOpenView::OnDefault()
{//这个函数是将窗宽窗位复原,并复原图像值,在按下软件菜单栏中“default”的时候
// TODO: Add your command handler code here
CDCMOpenDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
pDoc->m_DCM.WC=pDoc->m_DCM.m_WinCenter;
pDoc->m_DCM.WW=pDoc->m_DCM.m_WinWidth;
int wc=pDoc->m_DCM.WC;
int ww=pDoc->m_DCM.WW;
pDoc->m_DCM.CreatBMPDate(pDoc->m_DCM.p_data1 , wc ,ww );
Invalidate(TRUE);
}
void CDCMOpenView::OnDicominfo()
{
// TODO: Add your command handler code here
CDCMOpenDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
CDlgImageIfo* dlg;
dlg=new CDlgImageIfo(this);
dlg->Create(IDD_DLG_IMAGEINFO);//创建显示dicom数据信息的框架,就是在按下软件菜单栏中“图像信息”的时候
for(int i=0;i<30;i++)
{
dlg->m_Dataset[i]=pDoc->m_DCM.CRDataset[i];
dlg->m_TagName[i]=pDoc->m_DCM.TagName[i];
}
dlg->ShowWindow(SW_RESTORE);//吊用框架自带的函数,显示,数据信息,在此同时,会吊用CDlgImageIfo中的OnPaint()函数
}
void CDCMOpenView::OnFuctionFangda()
{
// TODO: 在此添加命令处理程序代码
m_zoom = m_zoom*2.0;
CDCMOpenDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
int wc=pDoc->m_DCM.WC;
int ww=pDoc->m_DCM.WW;
delete[] pDoc->m_DCM.p_data1;
pDoc->m_DCM.p_data1 = new BYTE[pDoc->m_DCM.m_srcWidth*pDoc->m_DCM.m_srcHeight];
pDoc->m_DCM.CreatBMPDate(pDoc->m_DCM.p_data1 , wc ,ww );
pDoc->m_DCM.m_Width = pDoc->m_DCM.m_srcWidth;
pDoc->m_DCM.m_Height = pDoc->m_DCM.m_srcHeight;
pDoc->m_DCM.Scale(m_zoom,0,0);
Invalidate(TRUE);
}
void CDCMOpenView::OnFuctionSuoXiao()
{
// TODO: 在此添加命令处理程序代码
m_zoom = m_zoom/2.0;
CDCMOpenDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
int wc=pDoc->m_DCM.WC;
int ww=pDoc->m_DCM.WW;
delete[] pDoc->m_DCM.p_data1;
pDoc->m_DCM.p_data1 = new BYTE[pDoc->m_DCM.m_srcWidth*pDoc->m_DCM.m_srcHeight];
pDoc->m_DCM.CreatBMPDate(pDoc->m_DCM.p_data1 , wc ,ww );
pDoc->m_DCM.m_Width = pDoc->m_DCM.m_srcWidth;
pDoc->m_DCM.m_Height = pDoc->m_DCM.m_srcHeight;
pDoc->m_DCM.Scale(m_zoom,0,0);
Invalidate(TRUE);
}