-
Notifications
You must be signed in to change notification settings - Fork 0
/
ControlView.cpp
165 lines (123 loc) · 3.07 KB
/
ControlView.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
// ControlView.cpp : implementation file
//
#include "stdafx.h"
#include "3dfstbrk.h"
#include "ControlView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CControlView
IMPLEMENT_DYNCREATE(CControlView, CFHEditView)
CControlView::CControlView()
{
}
CControlView::~CControlView()
{
}
BEGIN_MESSAGE_MAP(CControlView, CFHEditView)
//{{AFX_MSG_MAP(CControlView)
// NOTE - the ClassWizard will add and remove mapping macros here.
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CControlView drawing
void CControlView::OnInitialUpdate()
{
CFHEditView::OnInitialUpdate();
}
void CControlView::OnDraw(CDC* pDC)
{
CDocument* pDoc = GetDocument();
// TODO: add draw code here
}
/////////////////////////////////////////////////////////////////////////////
// CControlView diagnostics
#ifdef _DEBUG
void CControlView::AssertValid() const
{
CFHEditView::AssertValid();
}
void CControlView::Dump(CDumpContext& dc) const
{
CFHEditView::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CControlView message handlers
void CControlView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint)
{
CFHEditView::OnUpdate(pSender, lHint, pHint);
}
CControlDoc * CControlView::GetDocument()
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CControlDoc)));
return (CControlDoc*)m_pDocument;
}
void CControlView::UpdateGrid()
{
// TODO: Add your specialized code here and/or call the base class
m_Grid.DeleteAllItems ();
CControlDoc *pDoc=GetDocument();
long nShot=pDoc->m_CtlFile .GetShotCtlNumber ();
long nRcv=pDoc->m_CtlFile .GetRcvCtlNumber ();
long nRow=m_Grid.GetRowCount ();
if(nRcv>nRow)nRow=nRcv;
if(nShot>nRow)nRow=nShot;
if(nRow<10)nRow=10;
SetSize(nRow,3);
SetItem(0,0,"No.");
SetItem(0,1,"Shot Ctl");
SetItem(0,2,"Rcv Ctl");
for(long i=0;i<nShot;i++){
SetItem(i+1,1,pDoc->m_CtlFile .m_pShotCtlPoint [i].Ph );
}
for(i=0;i<nRcv;i++){
SetItem(i+1,2,pDoc->m_CtlFile .m_pRcvCtlPoint [i].Ph );
}
for(i=1;i<m_Grid.GetRowCount ();i++){
SetItem(i,0,i);
}
CFHEditView::UpdateGrid();
}
void CControlView::UpdateDoc()
{
CControlDoc *pDoc=GetDocument();
pDoc->m_CtlFile .Reset ();
long nRow=m_Grid.GetRowCount ();
long nShot=0,nRcv=0,Ph;
for(long i=nRow-1;i>0;i--){
GetItem(i,1,&Ph);
if(Ph!=0){
break;
}
}
if(Ph!=0)nShot=i;
//
for(i=nRow-1;i>0;i--){
GetItem(i,2,&Ph);
if(Ph!=0){
break;
}
}
if(Ph!=0)nRcv=i;
//
pDoc->m_CtlFile.SetRcvCtlNumber (nRcv);
pDoc->m_CtlFile.SetShotCtlNumber (nShot);
for(i=1;i<nRow;i++){
GetItem(i,1,&Ph);
if(Ph==0){
break;
}
pDoc->m_CtlFile.m_pShotCtlPoint [i-1].Ph =Ph;
}
for(i=1;i<nRow;i++){
GetItem(i,2,&Ph);
if(Ph==0){
break;
}
pDoc->m_CtlFile.m_pRcvCtlPoint [i-1].Ph =Ph;
}
}