📄 mainfrm.cpp
字号:
strValue = AfxGetApp()->GetProfileString(strSection, strStringItem);
break;
case 3:
strStringItem = "File3";
strValue = AfxGetApp()->GetProfileString(strSection, strStringItem);
break;
case 4:
strStringItem = "File4";
strValue = AfxGetApp()->GetProfileString(strSection, strStringItem);
break;
default:
break;
}
return strValue;
}
bool CMainFrame::OpenRecentFile(int idx)
{
CString strFilePath = SPDGetRecentFile (idx);
if(strFilePath.IsEmpty())
return false;
CFile fileHandle;
char strFileHead[6];
char strTemp[255];
CString cstrTemp,fileName;
if(fileHandle.Open(
strFilePath,
CFile::modeRead))
{
fileHandle.Read (strFileHead,6);
cstrTemp = _T("[SPD]");
if(cstrTemp.Compare (strFileHead) != 0)
{
fileHandle.Close ();
cstrTemp = "工程文件 " +
fileName +
" 格式错误 !";
MessageBox(cstrTemp,"工程信息");
return FALSE;
}
fileHandle.Read (&m_structWellInfo,sizeof(STRUCTWELLINFO));
fileHandle.Read (strTemp,255);
m_cstrSDTPath = strTemp;
fileHandle.Read (strTemp,255);
m_cstrEDTPath = strTemp;
fileHandle.Read (strTemp,255);
m_cstrDDTPath = strTemp;
fileHandle.Read (&m_structBDTTable ,sizeof(STRUCTBDTTABLE));
for(int iTemp = 0;iTemp<8;iTemp++)
fileHandle.Read(&m_structSDT[iTemp],sizeof(STRUCTSDTTABLE));
//输入****************
char strNone[510];
//1.[射孔参数校正]
fileHandle.Read (&m_structTTPTable ,sizeof(STRUCTTTPTABLE)); //孔深校正:16
for(iTemp=0;iTemp<8;iTemp++)
fileHandle.Read (&m_structTTPShotPara[iTemp],sizeof(STRUCTTTPSHOTPARA));//孔深校正参数:48 * 255 = 12240
fileHandle.Read (&m_structTTPResult,sizeof(STRUCTTTPRESULT)); //孔深校正结果:3072
//2.[常规负压设计]
fileHandle.Read (&m_structMinusPressPara,sizeof(STRUCTMINUSPRESSDESIGN));
fileHandle.Read (&m_structMinusPressResult,sizeof(STRUCTMINUSPRESSRESULT));
//3.[污染计算]
fileHandle.Read (&m_structPolluteComputePara,sizeof(STRUCTPOLLUTECOMPUTE));
fileHandle.Read (&m_structPolluteComputeResult,sizeof(STRUCTPOLLUTECOMPUTERESULT));
//4.[射孔参数优选]
fileHandle.Read(&m_structShotParaBase,sizeof(STRUCTSHOTPARABASE));
for(iTemp=0;iTemp<384;iTemp++)
{
fileHandle.Read(&m_structShotParaSelect[iTemp],
sizeof(STRUCTSHOTPARAPRESELECT));
}
fileHandle.Read (&m_bSelected,sizeof(BOOL));
fileHandle.Read (&m_structSelectedPara,sizeof(STRUCTSHOTPARAPRESELECT));
//5.[射孔产能及表皮系数预测]
fileHandle.Read (&m_structOilShotForecast,
sizeof(STRUCTOILSHOTFORECAST));
fileHandle.Read (&m_structGasShotForecast,
sizeof(STRUCTGASSHOTFORECAST));
//6.[防砂压力设计]
fileHandle.Read (&m_structSandPressDesign,sizeof(STRUCTSANDPRESSDESIGN));
//7.[超正压设计]
fileHandle.Read (strNone,510);
//****************************************
fileHandle.Close ();
m_cstrProjectPath = strFilePath;
OnSpdProjectChanged();
m_cstrProjectTitle = m_cstrProjectPath;
}
else
{
cstrTemp = "工程文件 " +
m_cstrProjectPath +
" 打开失败 !";
MessageBox(cstrTemp,"工程信息");
return FALSE;
}
return TRUE;
}
void CMainFrame::OnFileMruFile1()
{
// TODO: Add your command handler code here
if(!OpenRecentFile(1))
return;
SpdChangeMenu();
}
void CMainFrame::OnFileMruFile2()
{
// TODO: Add your command handler code here
if(!OpenRecentFile(2))
return;
SpdChangeMenu();
}
void CMainFrame::OnFileMruFile3()
{
// TODO: Add your command handler code here
if(!OpenRecentFile(3))
return;
SpdChangeMenu();
}
void CMainFrame::OnFileMruFile4()
{
// TODO: Add your command handler code here
if(!OpenRecentFile(4))
return;
SpdChangeMenu();
}
void CMainFrame::OnSpdSaveUser()
{
if(m_cstrProjectPath.IsEmpty())
return;
CFile fileHandle;
CString cstrTemp;
char strTemp[255];
if(!fileHandle.Open(
m_cstrProjectPath,
CFile::modeWrite))
{
cstrTemp = "工程文件 " +
m_cstrProjectPath +
" 打开错误 !";
MessageBox(cstrTemp,"工程信息");
return;
}
char fileHead[6];
sprintf(fileHead,"%s","[SPD]");
fileHandle.Write (fileHead,6);
fileHandle.Write (&m_structWellInfo ,sizeof(STRUCTWELLINFO));
sprintf(strTemp,"%s",m_cstrSDTPath);
fileHandle.Write (strTemp,255);
sprintf(strTemp,"%s",m_cstrEDTPath);
fileHandle.Write (strTemp,255);
sprintf(strTemp,"%s",m_cstrDDTPath);
fileHandle.Write (strTemp,255);
fileHandle.Write (&m_structBDTTable ,sizeof(STRUCTBDTTABLE));
for(int iTemp = 0;iTemp<8;iTemp++)
fileHandle.Write (&m_structSDT[iTemp],sizeof(STRUCTSDTTABLE));
//输入**************************
char strNone[510];
//1.[射孔参数校正]
fileHandle.Write (&m_structTTPTable ,sizeof(STRUCTTTPTABLE)); //孔深校正:16
for(iTemp=0;iTemp<8;iTemp++)
fileHandle.Write (&m_structTTPShotPara[iTemp],sizeof(STRUCTTTPSHOTPARA));//孔深校正参数:48 * 255 = 12240
fileHandle.Write (&m_structTTPResult,sizeof(STRUCTTTPRESULT)); //孔深校正结果:3072
//2.[常规负压设计]
fileHandle.Write (&m_structMinusPressPara,sizeof(STRUCTMINUSPRESSDESIGN));
fileHandle.Write (&m_structMinusPressResult,sizeof(STRUCTMINUSPRESSRESULT));
//3.[污染计算]
fileHandle.Write (&m_structPolluteComputePara,sizeof(STRUCTPOLLUTECOMPUTE));
fileHandle.Write (&m_structPolluteComputeResult,sizeof(STRUCTPOLLUTECOMPUTERESULT));
//4.[射孔参数优选]
fileHandle.Write(&m_structShotParaBase,sizeof(STRUCTSHOTPARABASE));
for(iTemp=0;iTemp<384;iTemp++)
{
fileHandle.Write(&m_structShotParaSelect[iTemp],
sizeof(STRUCTSHOTPARAPRESELECT));
}
fileHandle.Write (&m_bSelected,sizeof(BOOL));
fileHandle.Write (&m_structSelectedPara,sizeof(STRUCTSHOTPARAPRESELECT));
//5.[射孔产能及表皮系数预测]
fileHandle.Write (&m_structOilShotForecast,
sizeof(STRUCTOILSHOTFORECAST));
fileHandle.Write (&m_structGasShotForecast,
sizeof(STRUCTGASSHOTFORECAST));
//8.[防砂压力设计]
fileHandle.Write (&m_structSandPressDesign,sizeof(STRUCTSANDPRESSDESIGN));
//9.[超正压设计]
fileHandle.Write (strNone,510);
//******************************
fileHandle.Close();
cstrTemp = "工程 " +
m_cstrProjectPath +
" 存档完毕 !";
MessageBox(cstrTemp,"工程信息");
}
void CMainFrame::OnUpdateSpdSaveUser(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->Enable(!m_cstrProjectPath.IsEmpty());
}
void CMainFrame::OnUpdateMenuitemWord(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->Enable(!m_cstrProjectPath.IsEmpty());
}
void CMainFrame::OnSpdSaveAsUser()
{
// TODO: Add your command handler code here
if(m_cstrProjectPath.IsEmpty())
return;
CFileDialog fileDialog(
FALSE,"SPD",NULL,
OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,
"*.SPD|*.SPD|",
NULL);
// fileDialog.m_ofn.lpstrInitialDir = ".\\data\\"; // change by lzj
if(fileDialog.DoModal ()==IDCANCEL)
return;
CString strFilePath;
strFilePath = fileDialog.GetPathName ();
/*
HANDLE hSearch;
WIN32_FIND_DATA FileData;
hSearch = FindFirstFile(strFilePath, &FileData);
if (hSearch != INVALID_HANDLE_VALUE)
{
if (AfxMessageBox(_T("该文件已存在,覆盖它吗?"),MB_YESNO|MB_ICONQUESTION)== IDNO)
return;
}
*/
CFile fileHandle;
CString cstrTemp;
char fileHead[6];
char strTemp[255];
if(!fileHandle.Open(strFilePath, CFile::modeCreate|CFile::modeWrite))
{
cstrTemp = "工程文件“" + strFilePath + "”打开错误!";
MessageBox(cstrTemp,"工程信息");
return;
}
sprintf(fileHead,"%s","[SPD]");
fileHandle.Write (fileHead,6);
fileHandle.Write (&m_structWellInfo ,sizeof(STRUCTWELLINFO));
sprintf(strTemp,"%s",m_cstrSDTPath);
fileHandle.Write (strTemp,255);
sprintf(strTemp,"%s",m_cstrEDTPath);
fileHandle.Write (strTemp,255);
sprintf(strTemp,"%s",m_cstrDDTPath);
fileHandle.Write (strTemp,255);
fileHandle.Write (&m_structBDTTable ,sizeof(STRUCTBDTTABLE));
for(int iTemp = 0;iTemp<8;iTemp++)
fileHandle.Write (&m_structSDT[iTemp],sizeof(STRUCTSDTTABLE));
//输入*******************************
char strNone[510];
fileHandle.Write (&m_structTTPTable ,sizeof(STRUCTTTPTABLE)); //孔深校正:16
for(iTemp=0;iTemp<8;iTemp++)
fileHandle.Write (&m_structTTPShotPara[iTemp],sizeof(STRUCTTTPSHOTPARA));//孔深校正参数:48 * 255 = 12240
fileHandle.Write (&m_structTTPResult,sizeof(STRUCTTTPRESULT)); //孔深校正结果:3072
//2.[常规负压设计]
fileHandle.Write (&m_structMinusPressPara,sizeof(STRUCTMINUSPRESSDESIGN));
fileHandle.Write (&m_structMinusPressResult,sizeof(STRUCTMINUSPRESSRESULT));
//3.[污染计算]
fileHandle.Write (&m_structPolluteComputePara,sizeof(STRUCTPOLLUTECOMPUTE));
fileHandle.Write (&m_structPolluteComputeResult,sizeof(STRUCTPOLLUTECOMPUTERESULT));
//4.[射孔参数优选]
fileHandle.Write(&m_structShotParaBase,sizeof(STRUCTSHOTPARABASE));
for(iTemp=0;iTemp<384;iTemp++)
{
fileHandle.Write(&m_structShotParaSelect[iTemp],
sizeof(STRUCTSHOTPARAPRESELECT));
}
fileHandle.Write (&m_bSelected,sizeof(BOOL));
fileHandle.Write (&m_structSelectedPara,sizeof(STRUCTSHOTPARAPRESELECT));
//5.[射孔产能及表皮系数预测]
fileHandle.Write (&m_structOilShotForecast,
sizeof(STRUCTOILSHOTFORECAST));
fileHandle.Write (&m_structGasShotForecast,
sizeof(STRUCTGASSHOTFORECAST));
//6.[防砂压力设计]
fileHandle.Write (&m_structSandPressDesign,sizeof(STRUCTSANDPRESSDESIGN));
//7.[超正压设计]
fileHandle.Write (strNone,510);
//********************************
fileHandle.Close();
cstrTemp = "工程 " +
strFilePath +
" 另存完毕 !";
MessageBox(cstrTemp,"工程信息");
m_cstrProjectPath = strFilePath;
OnSpdProjectChanged();
}
void CMainFrame::OnSpdCloseproject()
{
// TODO: Add your command handler code here
m_cstrProjectPath.Empty();
OnSpdProjectChanged();
SpdChangeMenu();
}
void CMainFrame::OnDataEditprojectinfo()
{
if(m_cstrProjectPath.IsEmpty())
return;
// TODO: Add your command handler code here
CDialogProjectModify dlg(m_cstrProjectPath,
&m_structWellInfo,
m_cstrSDTPath,
m_cstrEDTPath);
if(dlg.DoModal () == IDCANCEL)
return;
m_cstrSDTPath = dlg.m_cstrSDTPath ;
m_cstrEDTPath = "" ;
sprintf(m_structWellInfo.strOilFieldName ,"%s" ,dlg.m_cstrOilFieldName ); //井信息
sprintf(m_structWellInfo.strWellName ,"%s" ,dlg.m_cstrWellName );
sprintf(m_structWellInfo.strCo ,"%s" ,dlg.m_cstrCo );
sprintf(m_structWellInfo.strStylist ,"%s" ,dlg.m_cstrStylist );
sprintf(m_structWellInfo.strAuditing ,"%s" ,dlg.m_cstrAuditing );
sprintf(m_structWellInfo.strDate ,"%s" ,dlg.m_cstrDate );
m_structWellInfo.bWellState = dlg.m_bWellState ;
m_structWellInfo.bStratumState = TRUE ;
m_structWellInfo.iFractureState = 0;
m_structWellInfo.iAim = 0;
SpdChangeMenu();
}
void CMainFrame::DestroyScale()
{
m_dlgScale = NULL;
}
void CMainFrame::RedrawPic()
{
switch(m_picState)
{
case PicNone:
break;
case OilKsKm:
OnMenuitemOilPaintKskm();
break;
case OilKsXw:
OnMenuitemOilPaintKsxw();
break;
case OilKzrXw:
OnMenuitemOilPaintKzrxw();
break;
case OilKsKj:
OnMenuitemOilPaintKskj();
break;
case OilKsYh:
OnMenuitemOilPaintKsyh();
break;
case OilKsYc:
OnMenuitemOilPaintKsyc();
break;
case OilKsWh:
OnMenuitemOilPaintKswh();
break;
case OilWhKs:
OnMenuitemOilPaintWhfks();
break;
case OilKsWc:
OnMenuitemOilPaintKswc();
break;
case OilKsKzr:
OnMenuitemOilPaintKskzr();
break;
case GasKsKm:
OnMenuitemGasPaintKskm();
break;
case GasKsXw:
OnMenuitemGasPaintKsxw();
break;
case GasKsKj:
OnMenuitemGasPaintKskj();
break;
case GasKsDp:
OnMenuitemGasPaintKsdp();
break;
case GasKsYc:
OnMenuitemGasPaintKsyc();
break;
case GasKsPk:
OnMenuitemGasPaintKspk();
break;
case GasKsWc:
OnMenuitemGasPaintKswc();
break;
case GasKsKzr:
OnMenuitemGasPaintKskzr();
break;
default:
break;
}
}
void CMainFrame::OnDataInput()
{
// TODO: Add your command handler code here
if(m_cstrProjectPath.IsEmpty())
return;
/* if(GetActiveFrame() != this)
{
CChildFrame *pChild = (CChildFrame *)GetActiveFrame();
CRuntimeClass* pNewViewClass;
pNewViewClass = RUNTIME_CLASS(CSourceDataView);
CView* pOldActiveView = pChild->GetActiveView();
CCreateContext context;
context.m_pNewViewClass = pNewViewClass;
context.m_pCurrentDoc = GetActiveDocument();
// context.m_pCurrentFrame = pChild;
CView* pNewView = STATIC_DOWNCAST(CView, pChild->CreateView(&context));
if (pNewView != NULL)
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -