📄 mainfrm.cpp
字号:
ShowControlBar(&m_wndShwrjWorkSpace,false,false);
ShowControlBar(&m_wndTGToolBar,false,false);
ShowControlBar(&m_wndTGWorkSpace,false,false);
m_wndStatusBar.SetPaneText(1,_T("射孔设计"));
break;
case 3:
m_NewMenu.LoadMenu(IDR_MAINFRAME_SHWRJ);
ShowControlBar(&m_wndToolBar,false,false);
ShowControlBar(&m_wndWorkSpace,false,false);
ShowControlBar(&m_wndSpdWorkSpace,false,false);
ShowControlBar(&m_wndSpdToolBar,false,false);
ShowControlBar(&m_wndShwrjWorkSpace,TRUE,false);
ShowControlBar(&m_wndShwrjToolBar,TRUE,false);
ShowControlBar(&m_wndTGToolBar,false,false);
ShowControlBar(&m_wndTGWorkSpace,false,false);
m_wndStatusBar.SetPaneText(1,_T("水合物预测及防治"));
break;
case 4:
m_NewMenu.LoadMenu(IDR_MAINFRAME_TAOGUAN);
ShowControlBar(&m_wndToolBar,false,false);
ShowControlBar(&m_wndWorkSpace,false,false);
ShowControlBar(&m_wndSpdWorkSpace,false,false);
ShowControlBar(&m_wndSpdToolBar,false,false);
ShowControlBar(&m_wndShwrjWorkSpace,false,false);
ShowControlBar(&m_wndShwrjToolBar,false,false);
ShowControlBar(&m_wndTGToolBar,true,false);
ShowControlBar(&m_wndTGWorkSpace,true,false);
m_wndStatusBar.SetPaneText(1,_T("完井管柱强度设计"));
break;
default:
return;
}
ASSERT(m_NewMenu);
// Remove and destroy the old menu
SetMenu(NULL);
::DestroyMenu(m_hMenuDefault);
// Add the new menu
SetMenu(&m_NewMenu);
// Assign default menu
m_hMenuDefault = m_NewMenu.GetSafeHmenu(); // or m_NewMenu.m_hMenu;
m_NewMenu.Detach();
UnlockMyWindowUpdate( );
// UpdateWindow();
}
void CMainFrame::OnDataSdt()
{
// TODO: Add your command handler code here
// 射孔弹型表编辑器
CDialogSDT dlg;
dlg.DoModal ();
}
bool CMainFrame::NewProject()
{
CDialogNewProject dlg;
if(dlg.DoModal () == IDCANCEL)
return FALSE;
/* HANDLE hSearch;
WIN32_FIND_DATA FileData;
hSearch = FindFirstFile(dlg.m_cstrProjectPath, &FileData);
if (hSearch != INVALID_HANDLE_VALUE)
{
if (AfxMessageBox(_T("该文件已存在,覆盖它吗?"),MB_YESNO|MB_ICONQUESTION)== IDNO)
return false;
}
*/
//写工程文件
CFile fileHandle;
if(fileHandle.Open(dlg.m_cstrProjectPath, CFile::modeCreate|CFile::modeWrite))
{
//建立工程文件**************
char strSDTPath[255];
char strEDTPath[255];
char strDDTPath[255];
char strFileHead[6];
m_cstrSDTPath = dlg.m_cstrSDTPath ;
m_cstrEDTPath = "" ;
sprintf(strFileHead,"%s","[SPD]");
sprintf(m_structWellInfo.strOilFieldName ,"%s" ,dlg.m_cstrOilFieldName ); //井信息
sprintf(m_structWellInfo.strWellName ,"%s" ,dlg.m_cstrWellName );
sprintf(m_structWellInfo.strCo ,"%s" ,dlg.m_cstrCon );
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;
sprintf(strSDTPath ,"%s" ,m_cstrSDTPath);
sprintf(strEDTPath ,"%s" ,m_cstrEDTPath);
m_structBDTTable.bState = FALSE; //原始数据未输入
//孔深校正I/O*****
m_structTTPTable.bState = FALSE;
m_structTTPTable.lNum = -1;
m_structTTPResult.bState = FALSE;
//****************
char strNone[510];
fileHandle.Write (strFileHead,6); //文件头:6
//************
fileHandle.Write (&m_structWellInfo,sizeof(STRUCTWELLINFO)); //井况:255
//************
fileHandle.Write (strSDTPath ,255); //射孔弹型表:255
fileHandle.Write (strEDTPath ,255); //射孔器材数据表:255
fileHandle.Write (strDDTPath ,255);
//************
m_structBDTTable.bState = FALSE; //原始数据未输入
fileHandle.Write (&m_structBDTTable ,sizeof(STRUCTBDTTABLE));//基本数据表:510
for(int iTemp = 0;iTemp<8;iTemp++)
fileHandle.Write (&m_structSDT[iTemp],sizeof(STRUCTSDTTABLE));
//输入********************************************
//1.[射孔参数校正]
m_structTTPTable.bState = FALSE;
m_structTTPTable.lNum = -1;
fileHandle.Write (&m_structTTPTable ,sizeof(STRUCTTTPTABLE)); //孔深校正:16
for(iTemp=0;iTemp<8;iTemp++)
fileHandle.Write (&m_structTTPShotPara[iTemp],sizeof(STRUCTTTPSHOTPARA));//孔深校正参数:48 * 255 = 12240
m_structTTPResult.bState = FALSE;
fileHandle.Write (&m_structTTPResult,sizeof(STRUCTTTPRESULT)); //孔深校正结果:3072
//2.[常规负压设计]
m_structMinusPressPara.bState = FALSE;
sprintf(m_structMinusPressPara.strModel,"%s",_T("未选择"));
fileHandle.Write (&m_structMinusPressPara,sizeof(STRUCTMINUSPRESSDESIGN));
m_structMinusPressResult.bState = FALSE;
fileHandle.Write (&m_structMinusPressResult,sizeof(STRUCTMINUSPRESSRESULT));
//3.[污染计算]
m_structPolluteComputePara.bState = FALSE;
fileHandle.Write (&m_structPolluteComputePara,sizeof(STRUCTPOLLUTECOMPUTE));
fileHandle.Write (&m_structPolluteComputeResult,sizeof(STRUCTPOLLUTECOMPUTERESULT));
//4.[射孔参数优选]
m_structShotParaBase.bState = FALSE;
fileHandle.Write(&m_structShotParaBase,sizeof(STRUCTSHOTPARABASE));
for(iTemp=0;iTemp<384;iTemp++)
{
fileHandle.Write(&m_structShotParaSelect[iTemp],
sizeof(STRUCTSHOTPARAPRESELECT));
}
m_bSelected = FALSE;
fileHandle.Write (&m_bSelected,sizeof(BOOL));
fileHandle.Write (&m_structSelectedPara,sizeof(STRUCTSHOTPARAPRESELECT));
//5.[射孔产能及表皮系数预测]
m_structOilShotForecast.bState = FALSE;
fileHandle.Write (&m_structOilShotForecast,
sizeof(STRUCTOILSHOTFORECAST));
m_structGasShotForecast.bState = FALSE;
fileHandle.Write (&m_structGasShotForecast,
sizeof(STRUCTGASSHOTFORECAST));
//6.[防砂压力设计]
m_structSandPressDesign.fP = 0.0f;
m_structSandPressDesign.fPMax = 0.0f;
m_structSandPressDesign.fPMin = 0.0f;
m_structSandPressDesign.fPRec = 0.0f;
m_structSandPressDesign.fQ = 0.0f;
fileHandle.Write (&m_structSandPressDesign,sizeof(STRUCTSANDPRESSDESIGN));
//7.[超正压设计]
fileHandle.Write (strNone,510);
//******************************
CString cstrTemp;
cstrTemp = "工程“" + dlg.m_cstrProjectPath + "”已经建立!";
MessageBox(cstrTemp,"工程信息");
fileHandle.Close();
m_cstrProjectTitle = dlg.m_cstrProjectName;
m_cstrProjectPath = dlg.m_cstrProjectPath ;
OnSpdProjectChanged();
}
else
{
MessageBox("工程文件创建失败 !","错误");
return FALSE;
}
return TRUE;
}
void CMainFrame::OnSpdProjectChanged()
{
CString strAppTitle;
strAppTitle.LoadString(IDR_MAINFRAME);
if(!m_cstrProjectPath.IsEmpty())
{
int iDotPlace, iDirPlace;
TCHAR ch;
bool bFirst = true;
iDotPlace = m_cstrProjectPath.GetLength();
for(iDirPlace = iDotPlace - 1; iDirPlace >= 0; iDirPlace--)
{
ch = m_cstrProjectPath.GetAt(iDirPlace);
if(ch == _T('.') && bFirst)
{
iDotPlace = iDirPlace;
bFirst = false;
}
if(ch == _T('\\'))
break;
}
m_cstrProjectName = m_cstrProjectPath.Mid(iDirPlace+1, iDotPlace - iDirPlace - 1);
SetWindowText(m_cstrProjectName+_T(" - ")+strAppTitle);
SpdUpdateRecentFile(m_cstrProjectPath);
}
else
SetWindowText(strAppTitle);
}
void CMainFrame::OnInitFileNew()
{
// TODO: Add your command handler code here
if(!NewProject())
return;
SpdChangeMenu();
}
void CMainFrame::OnInitFileOpen()
{
// TODO: Add your command handler code here
if(!OpenProject())
return;
SpdChangeMenu();
}
void CMainFrame::SpdChangeMenu()
{
LockMyWindowUpdate( );
while(GetActiveFrame() != this)
GetActiveFrame()->SendMessage(WM_CLOSE,NULL,NULL);
if(m_cstrProjectPath.IsEmpty())
{
m_NewMenu.LoadMenu (IDR_INITIALIZE_SPD);
m_wndSpdWorkSpace.RemoveAllTree();
}
else
{
if(m_structWellInfo.bWellState == TRUE)
{
m_NewMenu.LoadMenu (IDR_MAINFRAME_OIL);
m_wndSpdWorkSpace.ShowOil();
}
else
{
m_NewMenu.LoadMenu (IDR_MAINFRAME_GAS);
m_wndSpdWorkSpace.ShowGas();
}
}
ASSERT(m_NewMenu);
// Remove and destroy the old menu
SetMenu(NULL);
::DestroyMenu(m_hMenuDefault);
// Add the new menu
SetMenu(&m_NewMenu);
// Assign default menu
m_hMenuDefault = m_NewMenu.GetSafeHmenu(); // or m_NewMenu.m_hMenu;
m_NewMenu.Detach();
UnlockMyWindowUpdate( );
m_picState = PicNone;
}
bool CMainFrame::OpenProject()
{
CFileDialog fileDialog(
TRUE,"SPD",NULL,
OFN_HIDEREADONLY | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST ,
"*.SPD|*.SPD|",
NULL);
fileDialog.m_ofn.lpstrInitialDir = theApp.m_strAppPath + _T("\\SK-Data"); // add by lzj
TRACE(theApp.m_strAppPath + _T("\\SK-Data\n"));
if(fileDialog.DoModal () == IDCANCEL)
return FALSE;
CString cstrProjectName;
CFile fileHandle;
char strFileHead[6];
char strTemp[255];
CString cstrTemp;
if(fileHandle.Open(
fileDialog.GetPathName (),
CFile::modeRead))
{
fileHandle.Read (strFileHead,6);
cstrTemp = _T("[SPD]");
if(cstrTemp.Compare (strFileHead) != 0)
{
fileHandle.Close ();
cstrTemp = "工程文件 " +
fileDialog.GetPathName () +
" 格式错误 !";
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_cstrProjectTitle = fileDialog.GetPathName();
m_cstrProjectPath = fileDialog.GetPathName ();
OnSpdProjectChanged();
}
else
{
cstrTemp = "工程文件 " +
fileDialog.GetPathName () +
" 打开失败 !";
MessageBox(cstrTemp,"工程信息");
return FALSE;
}
return TRUE;
}
void CMainFrame::SpdUpdateRecentFile(CString file)
{
CString strSection = _T("Recent File List");
CString strStringItem = _T("File1");
CString value1,value2,value3,value4;
value1 = AfxGetApp()->GetProfileString(strSection, strStringItem);
strStringItem = _T("File2");
value2 = AfxGetApp()->GetProfileString(strSection, strStringItem);
strStringItem = _T("File3");
value3 = AfxGetApp()->GetProfileString(strSection, strStringItem);
strStringItem = _T("File4");
value4 = AfxGetApp()->GetProfileString(strSection, strStringItem);
BOOL bState1,bState2,bState3,bState4;
bState1 = FALSE;
bState2 = FALSE;
bState3 = FALSE;
bState4 = FALSE;
if(value1.Compare (file) == 0)
{
bState1 = TRUE;
}
else if(value2.Compare (file) == 0)
bState2 = TRUE;
else if(value3.Compare (file) == 0)
bState3 = TRUE;
else if(value4.Compare (file) == 0)
bState4 = TRUE;
if(bState2)
{
swap(value1,value2);
}
else if(bState3)
{
swap(value3,value2);
swap(value2,value1);
}
else if(bState4)
{
swap(value4,value3);
swap(value3,value2);
swap(value2,value1);
}
else if(!bState1)
{
value4 = value3;
value3 = value2;
value2 = value1;
value1 = file;
/* swap(value4,value3);
swap(value3,value2);
swap(value2,value1);
*/ }
strStringItem = _T("File1");
AfxGetApp()->WriteProfileString (strSection, strStringItem ,value1);
strStringItem = _T("File2");
AfxGetApp()->WriteProfileString (strSection, strStringItem ,value2);
strStringItem = _T("File3");
AfxGetApp()->WriteProfileString (strSection, strStringItem ,value3);
strStringItem = _T("File4");
AfxGetApp()->WriteProfileString (strSection, strStringItem ,value4);
}
CString CMainFrame::SPDGetRecentFile(int idx)
{
CString strSection = "Recent File List";
CString strStringItem;
CString strValue;
switch(idx)
{
case 1:
strStringItem = "File1";
strValue = AfxGetApp()->GetProfileString(strSection, strStringItem);
break;
case 2:
strStringItem = "File2";
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -