JunkBox_Win_Lib 1.5.3
Loading...
Searching...
No Matches
RwGRDoc.cpp
Go to the documentation of this file.
1//
2// CRwGRDoc.cpp : インプリメンテーション ファイル
3//
4
5#include "MFCBase.h"
6#include "RwGRDoc.h"
7
8#include "MessageBoxDLG.h"
9#include "ReadFilesDLG.h"
10#include "ProgressBarDLG.h"
11
12
13#ifdef _DEBUG
14#define new DEBUG_NEW
15#undef THIS_FILE
16static char THIS_FILE[] = __FILE__;
17#endif
18
19
20using namespace jbxwl;
21
22
24// CRwGRDoc
25
26IMPLEMENT_DYNCREATE(CRwGRDoc, CExDocument)
27
29{
30// multiSliceData = FALSE;
31// nonCmnHead = FALSE;
32}
33
34
38
39
40BEGIN_MESSAGE_MAP(CRwGRDoc, CExDocument)
41 //{{AFX_MSG_MAP(CRwGRDoc)
42 // メモ - ClassWizard はこの位置にマッピング用のマクロを追加または削除します.
43 //}}AFX_MSG_MAP
44END_MESSAGE_MAP()
45
46
47
48
49// CRwGRDoc 診断
50
51#ifdef _DEBUG
56
57
58//
59void CRwGRDoc::Dump(CDumpContext& dc) const
60{
62}
63#endif //_DEBUG
64
65
66
68// CRwGRDoc シリアライズ
69//
70void CRwGRDoc::Serialize(CArchive& ar)
71{
72 if (ar.IsStoring())
73 {
74 // TODO: この位置に保存用のコードを追加してください
75 }
76 else
77 {
78 // TODO: この位置に読み込み用のコードを追加してください
79 }
80}
81
82
83
85// CRwGRDoc コマンド
86//
87BOOL CRwGRDoc::ReadDataFile(LPCTSTR fname)
88{
89 CString message = _T("");
90 CString fnm = get_file_name_t(fname); // ファイル名のみ
91 CString err_fname = _T(""); // エラーを起こしたファイル名
92 CmnHead hd;
93
94 // グローバルカウンタの設定
96 counter = new CProgressBarDLG(IDD_PROGBAR, NULL, TRUE); // ディスパッチャー有効
97 if (counter!=NULL) {
99 }
100
102
103 // マルチスライス読み込み
104 if (multiSliceData) {
105 // ファイル読み込み設定
107 if (rsdlg==NULL) return FALSE;
108 if (rsdlg->DoModal()!=IDOK) { // キャンセルボタン
111 delete (rsdlg);
112 return FALSE;
113 }
114 startNo = rsdlg->fromNum;
115 endNo = rsdlg->toNum;
116 CString mfname = rsdlg->fName;
117 delete (rsdlg);
118
119 if (counter!=NULL) {
121 mesg.LoadString(IDS_STR_RDNG_FILE);
122 char* mbstr = ts2mbs(mesg);
123 counter->Start(0, mbstr);
124 ::free(mbstr);
125 }
126
127 Title = mfname;
128 char* fname_str = ts2mbs(mfname);
129
130 // データの読み込み
132
133 DEBUG_INFO("CRwGRDoc::ReadDataFile(): Multi Slice: file = %s, start = %d, end = %d\n", fname_str, startNo, endNo);
135
136 if (msGraph.state>=0 && msGraph.state!=Xabs(endNo-startNo)+1) {
139 ::free(numf);
140
142 noti.LoadString(IDS_STR_CNFRM_CNTNUE);
143 mesg.LoadString(IDS_STR_ERR_OPEN_FILE);
144 message = _T("CRwGRDoc::ReadDataFile():\n\n") + mesg + _T(" ") + err_fname;
145 MessageBox(pFrame->m_hWnd, message, noti, MB_OK);
146 }
147 if (msGraph.state>0) msGraph.state = 0;
148
149 if (msGraph.isNull() && msGraph.state==JBXL_GRAPH_HEADER_ERROR) {
151 }
152
153 ::free(fname_str);
154 }
155
156 // 通常の読み込み.
157 else {
159 mesg.LoadString(IDS_STR_RDNG_FILE);
160 char* mbstr = ts2mbs(mesg);
161 if (counter!=NULL) counter->Start(0, mbstr);
162 ::free(mbstr);
163 Title = fnm;
165
166 char* fname_str = ts2mbs(fname);
168 ::free(fname_str);
169 }
170
171 //
172 this->infHead = getinfo_CmnHead(hd);
173 this->colorMode = msGraph.color;
174 free_CmnHead(&hd);
175
176 // グローバルカウンタの削除
177 if (counter!=NULL) {
178 counter->Stop();
180 delete counter;
181 }
182
183 // エラー処理
184 if (msGraph.isNull()) {
186
187 if (msGraph.state==JBXL_GRAPH_OPFILE_ERROR) {
188 mesg.LoadString(IDS_STR_ERR_OPEN_FILE);
189 noti.LoadString(IDS_STR_ERROR);
190 if (multiSliceData) {
191 message = _T("CRwGRDoc::ReadDataFile():\n\n") + mesg + _T(" ") + err_fname;
192 MessageBox(pFrame->m_hWnd, message, noti, MB_OK);
193 }
194 else {
195 MessageBox(pFrame->m_hWnd, _T("CRwGRDoc::ReadDataFile():\n\n") + mesg, noti, MB_OK);
196 }
197 }
198 else if (msGraph.state==JBXL_GRAPH_MEMORY_ERROR) {
199 mesg.LoadString(IDS_STR_ERR_MEMORY);
200 noti.LoadString(IDS_STR_ERROR);
201 MessageBox(pFrame->m_hWnd, _T("CRwGRDoc::ReadDataFile():\n\n") + mesg, noti, MB_OK);
202 }
203 else if (msGraph.state==JBXL_GRAPH_CANCEL) {
204 mesg.LoadString(IDS_STR_CANCEL_OPNFILE);
205 noti.LoadString(IDS_STR_CANCEL);
206 MessageBox(pFrame->m_hWnd, _T("CRwGRDoc::ReadDataFile():\n\n") + mesg, noti, MB_OK);
208 }
209 else {
210 mesg.LoadString(IDS_STR_ERR_UNKWN);
211 noti.LoadString(IDS_STR_ERROR);
212 MessageBox(pFrame->m_hWnd, _T("CRwGRDoc::ReadDataFile():\n\n") + mesg, noti, MB_OK);
213 }
215
216 return FALSE;
217 }
218
219 return TRUE;
220}
221
222
223//
224// hasViewData==TRUE なら MakeViewData()は実行されない.
225//
227{
229
230 // カウンタの設定
232 if (msGraph.zs > 10) {
233 //counter = new CProgressBarDLG(IDD_PROGBAR, NULL, NULL, FALSE);
234 counter = new CProgressBarDLG(IDD_PROGBAR, NULL, TRUE); // ディスパッチャー有効
235 if (counter!=NULL) {
236 mesg.LoadString(IDS_STR_TRNS_DISPDATA);
238 char* mbstr = ts2mbs(mesg);
239 counter->Start(0, mbstr);
240 ::free(mbstr);
241 }
242 }
243
244 // データ変換
246
247 // カウンタの停止と削除
248 if (counter!=NULL) {
249 counter->Stop();
251 delete counter;
252 }
253
254 // エラー処理
255 if (cmnHead.kind==HEADER_NONE) {
256 if (cmnHead.xsize==JBXL_GRAPH_MEMORY_ERROR) {
257 mesg.LoadString(IDS_STR_ERR_MEMORY);
258 noti.LoadString(IDS_STR_ERROR);
259 MessageBox(pFrame->m_hWnd, _T("CRwGRDoc::MakeViewData():\n\n") + mesg, noti, MB_OK);
260 }
261 else if (cmnHead.xsize==JBXL_GRAPH_CANCEL) {
262 mesg.LoadString(IDS_STR_CANCEL_TRNS_DATA);
263 noti.LoadString(IDS_STR_CANCEL);
264 MessageBox(pFrame->m_hWnd, _T("CRwGRDoc::MakeViewData():\n\n") + mesg, noti, MB_OK);
266 }
267 else {
268 mesg.LoadString(IDS_STR_ERR_UNKWN);
269 noti.LoadString(IDS_STR_ERROR);
270 MessageBox(pFrame->m_hWnd, _T("CRwGRDoc::MakeViewData():\n\n") + mesg, noti, MB_OK);
271 }
273 return FALSE;
274 }
275
276 return TRUE;
277}
278
279
280//
282{
283 CmnHead chd;
284
285 int mode = 0;
286 if (msGraph.color==GRAPH_COLOR_MONO || msGraph.color==GRAPH_COLOR_MONO16 || // 表示は 8bit
290 // 8bit/pixcel
292 }
293 if (ctrlCntrst || msGraph.color==GRAPH_COLOR_MONO16) {
295 }
296 //
297 chd = copyMSGraph2CmnHead(msGraph, mode, true); // msGraphは参照渡し
298 //
299 cMax = vMax = msGraph.max;
300 cMin = vMin = msGraph.min;
301
303 || msGraph.color==GRAPH_COLOR_RGBA16) {
304 // 16bit/pixcel
305 //vMax = cMax = UWORDMAX;
306 //vMin = cMin = 0;
307 }
308 else if (!ctrlCntrst && cMin>=0 && cMax<=VIEW_8_MAX) {
309 vMax = cMax = VIEW_8_MAX;
310 vMin = cMin = 0;
311 }
312
313 base = msGraph.base;
314
315 return chd;
316}
#define VIEW_8_MAX
Definition ExView.h:39
再帰定義可能なプログレスバーカウンタ
static char THIS_FILE[]
Definition RwGRDoc.cpp:16
ExCmnHead cmnHead
Definition ExDocument.h:53
CExFrame * pFrame
Definition ExDocument.h:56
ExMSGraph< sWord > msGraph
Definition ExDocument.h:52
virtual void AssertValid() const
virtual void Dump(CDumpContext &dc) const
bool cancelOperation
Definition ExFrame.h:52
bool doneErrorMessage
Definition ExFrame.h:51
virtual BOOL MakeViewData()
Definition RwGRDoc.cpp:226
virtual ~CRwGRDoc()
Definition RwGRDoc.cpp:35
virtual BOOL ReadDataFile(LPCTSTR str)
Definition RwGRDoc.cpp:87
virtual void Serialize(CArchive &ar)
Definition RwGRDoc.cpp:70
virtual void AssertValid() const
Definition RwGRDoc.cpp:52
virtual void Dump(CDumpContext &dc) const
Definition RwGRDoc.cpp:59
virtual CmnHead TranslateData()
Definition RwGRDoc.cpp:281
CSetHeaderDLG SetHeaderDLG
CString get_file_name_t(LPCTSTR str)
Definition WinTools.cpp:277
char * ts2mbs(LPCTSTR str)
Definition WinTools.h:57
CString mbs2ts(char *str)
Definition WinTools.cpp:79
CString numbering_name_t(LPCTSTR fmt, int n)
Definition WinTools.cpp:403
#define IDS_STR_RDNG_FILE
Definition resource.h:107
#define IDS_STR_ERROR
Definition resource.h:98
#define IDS_STR_ERR_MEMORY
Definition resource.h:82
#define IDS_STR_ERR_UNKWN
Definition resource.h:84
#define IDS_STR_CANCEL_TRNS_DATA
Definition resource.h:85
#define IDS_STR_CANCEL
Definition resource.h:101
#define IDS_STR_TRNS_DISPDATA
Definition resource.h:110
#define IDD_PROGBAR
Definition resource.h:6
#define IDS_STR_ERR_OPEN_FILE
Definition resource.h:79
#define IDS_STR_CANCEL_OPNFILE
Definition resource.h:86
#define IDS_STR_CNFRM_CNTNUE
Definition resource.h:109