📄 deformadj.cpp
字号:
// DeformAdj.cpp : Defines the class behaviors for the application.
//
#include "stdafx.h"
#include "DeformAdj.h"
#include "afxadv.h"
#include "MainFrm.h"
#include "DeformAdjDoc.h"
#include "DeformAdjView.h"
#include "DirectoryDlg.h"
#include "Splash.h"
#include <io.h>
#include <stdio.h>
#include <stdlib.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern CString directory; //项目目录
extern CString projname; //项目名称
extern CString m_TouygEdit;
extern CString m_JiaEdit;
extern CString m_GuancgEdit;
extern CString m_FangxEdit;
extern CString m_ChicxEdit;
extern CString m_ChengEdit;
extern CString m_CejujEdit;
extern CString m_CejucEdit;
extern int IsSavedProject;
extern int m_projclose;
extern int m_projsave;
extern int m_projnew;
extern int m_projopen,m_projsetup;
extern int m_input;
/////////////////////////////////////////////////////////////////////////////
// CDeformAdjApp
BEGIN_MESSAGE_MAP(CDeformAdjApp, CWinApp)
//{{AFX_MSG_MAP(CDeformAdjApp)
ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
ON_COMMAND(ID_PROJECT_NEW, OnProjectNew)
ON_UPDATE_COMMAND_UI(ID_FILE_MRU_FILE1, OnUpdateFileMruFile1)
ON_COMMAND(ID_FILE_MRU_FILE1, OnFileMruFile1)
ON_COMMAND(ID_FILE_MRU_FILE2, OnFileMruFile2)
ON_COMMAND(ID_FILE_MRU_FILE3, OnFileMruFile3)
ON_COMMAND(ID_FILE_MRU_FILE4, OnFileMruFile4)
//}}AFX_MSG_MAP
// Standard file based document commands
ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
// Standard print setup command
ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDeformAdjApp construction
CDeformAdjApp::CDeformAdjApp()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}
/////////////////////////////////////////////////////////////////////////////
// The one and only CDeformAdjApp object
CDeformAdjApp theApp;
/////////////////////////////////////////////////////////////////////////////
// CDeformAdjApp initialization
BOOL CDeformAdjApp::InitInstance()
{
// CG: The following block was added by the Splash Screen component. { CCommandLineInfo cmdInfo; ParseCommandLine(cmdInfo); CSplashWnd::EnableSplashScreen(cmdInfo.m_bShowSplash); }
AfxEnableControlContainer();
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.
IsSavedProject=1;
m_projclose=0;
m_projsave=0;
m_projnew=1;
m_projopen=1;
m_projsetup=0;
m_input=0;
#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif
// Change the registry key under which our settings are stored.
// TODO: You should modify this string to be something appropriate
// such as the name of your company or organization.
SetRegistryKey(_T("Local AppWizard-Generated Applications"));
LoadStdProfileSettings(4); // Load standard INI file options (including MRU)
// Register the application's document templates. Document templates
// serve as the connection between documents, frame windows and views.
CSingleDocTemplate* pDocTemplate;
pDocTemplate = new CSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CDeformAdjDoc),
RUNTIME_CLASS(CMainFrame), // main SDI frame window
RUNTIME_CLASS(CDeformAdjView));
AddDocTemplate(pDocTemplate);
// Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
// cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing;
ParseCommandLine(cmdInfo);
// Dispatch commands specified on the command line
if (!ProcessShellCommand(cmdInfo))
return FALSE;
// The one and only window has been initialized, so show and update it.
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->SetWindowText( "变形观测数据处理包" );
m_pMainWnd->UpdateWindow();
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
// No message handlers
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
// App command to run the dialog
void CDeformAdjApp::OnAppAbout()
{
CAboutDlg aboutDlg;
aboutDlg.DoModal();
}
/////////////////////////////////////////////////////////////////////////////
// CDeformAdjApp message handlers
void CDeformAdjApp::OnProjectNew()
{
// TODO: Add your command handler code here
CDirectoryDlg dlg;
CString str,temp,currdir ;
BOOL IsOk ;
int strno,strno1;
if ( dlg.DoModal() == IDOK )
{
directory = dlg.m_DireEdit;
str = dlg.m_ProjName;
projname = str + ".prj" ;
if ( directory == "" || str == "")
{
AfxMessageBox("请输入工程目录和名称!");
return;
}
if ( directory.Right(1) == "\\");
else
directory = directory + "\\";
directory = directory + str ;
if ( directory.Right(1) == "\\");
else
directory = directory + "\\";
strno = directory.Find("\\" , 0 );
temp = directory.Left( strno );
IsOk=CreateDirectory( temp , NULL );
currdir=temp;
IsOk = SetCurrentDirectory( currdir );
while (strno != -1)
{
strno1 = directory.Find("\\" , strno+1 );
temp = directory.Mid( strno+1,strno1-strno-1 );
currdir = currdir + "\\"+temp;
IsOk=CreateDirectory( currdir , NULL );
IsOk = SetCurrentDirectory( currdir );
strno=strno1;
}
if( (_access( projname, 0 )) != -1 )
{
AfxMessageBox("该工程已经存在,请重新建立工程!");
return;
}
CFile f0( projname , CFile::modeCreate ); //工程文件
CFile f1( "pingm.xyn" , CFile::modeCreate ); //平面坐标文件
CFile f2( "gaoc.ela" , CFile::modeCreate ); //高程文件
CFile f3( "jiaod.dms" , CFile::modeCreate ); //角度观测文件
CFile f4( "fangx.dms" , CFile::modeCreate ); //方向观测文件
CFile f5( "shiz.str" , CFile::modeCreate ); //视准观测文件
CFile f6( "gaod.ela" , CFile::modeCreate ); //高差观测文件
CFile f7( "bianc.szt" , CFile::modeCreate ); //边长观测文件
CFile f8( "jiaod.adj" , CFile::modeCreate ); //角度观测改正后文件
CFile f9( "fangx.adj" , CFile::modeCreate ); //方向观测改正后文件
CFile f10( "shiz.adj" , CFile::modeCreate ); //视准观测改正后文件
CFile f11( "gaod.adj" , CFile::modeCreate ); //高差观测改正后文件
CFile f12( "bianc.adj" , CFile::modeCreate ); //边长观测改正后文件
CFile f13( "shuiw.dph" , CFile::modeCreate ); //水位观测文件
CFile f14( "wend.tme" , CFile::modeCreate ); //温度观测文件
CFile f15( "hresult.adj" , CFile::modeCreate ); //平面经典平差结果
CFile f16( "vresult.adj" , CFile::modeCreate ); //高程经典平差结果
CFile f17( "calc.rut" , CFile::modeCreate );
m_pMainWnd->SetWindowText( str+" - 变形观测数据处理包" );
m_projsetup=1;m_projopen=0;m_projclose=1;
}
}
void CDeformAdjApp::OnUpdateFileMruFile1(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
if ( pCmdUI ->m_nIndex == 0)
OnUpdateRecentFileMenu(pCmdUI);
return;
}
BOOL CDeformAdjApp::PreTranslateMessage(MSG* pMsg)
{
// CG: The following lines were added by the Splash Screen component. if (CSplashWnd::PreTranslateAppMessage(pMsg)) return TRUE; return CWinApp::PreTranslateMessage(pMsg);
}
void CDeformAdjApp::OnFileMruFile1()
{
// TODO: Add your command handler code here
CString str,name;
CMainFrame* pmain;
pmain = (CMainFrame*)m_pMainWnd ;
CMenu* pMenu = pmain->GetMenu();
CMenu* pSubMenu = pMenu->GetSubMenu(0);
pSubMenu->GetMenuString( ID_FILE_MRU_FILE1, str, MF_BYCOMMAND ) ;
int strsum = str.GetLength()-3;
name = str.Right(strsum);
int j = name.Find( ':' );
if (j==-1)
return;
int length = name.GetLength();
int i = name.ReverseFind( '\\' );
directory = name.Left( i+1 );
projname = name.Right( length - i -1 );
CString title = projname.Left( length - i -5 );
CDeformAdjDoc* pdoc;
pdoc = (CDeformAdjDoc*)(((CFrameWnd*)AfxGetApp() -> m_pMainWnd ) ->GetActiveDocument());
CFile f;
if ( f.Open( name ,CFile::modeRead ) == false )
{
AfxMessageBox("请确认工程文件是否移动,建议用'打开工程'菜单确认工程文件的具体位置!");
return;
}
CArchive ar ( &f , CArchive::load );
ar >> projname;
ar >> m_TouygEdit;
ar >> m_JiaEdit;
ar >> m_GuancgEdit;
ar >> m_FangxEdit;
ar >> m_ChicxEdit;
ar >> m_ChengEdit;
ar >> m_CejujEdit;
ar >> m_CejucEdit;
ar.Close();
f.Close();
AfxGetApp()->AddToRecentFileList(name);
((CFrameWnd*)AfxGetApp() -> m_pMainWnd ) -> SetWindowText( title+" - 变形观测数据处理包" );
m_projsetup=1;m_projopen=0;m_projclose=1;m_projsave=1;m_projnew=0;
m_input=1;
}
void CDeformAdjApp::OnFileMruFile2()
{
// TODO: Add your command handler code here
CString str,name;
CMainFrame* pmain;
pmain = (CMainFrame*)m_pMainWnd ;
CMenu* pMenu = pmain->GetMenu();
CMenu* pSubMenu = pMenu->GetSubMenu(0);
pSubMenu->GetMenuString( ID_FILE_MRU_FILE2, str, MF_BYCOMMAND ) ;
int strsum = str.GetLength()-3;
name = str.Right(strsum);
int length = name.GetLength();
int i = name.ReverseFind( '\\' );
directory = name.Left( i+1 );
projname = name.Right( length - i -1 );
CString title = projname.Left( length - i -5 );
CDeformAdjDoc* pdoc;
pdoc = (CDeformAdjDoc*)(((CFrameWnd*)AfxGetApp() -> m_pMainWnd ) ->GetActiveDocument());
CFile f;
if ( f.Open( name ,CFile::modeRead ) == false )
{
AfxMessageBox("请确认工程文件是否移动,建议用'打开工程'菜单确认工程文件的具体位置!");
return;
}
CArchive ar ( &f , CArchive::load );
ar >> projname;
ar >> m_TouygEdit;
ar >> m_JiaEdit;
ar >> m_GuancgEdit;
ar >> m_FangxEdit;
ar >> m_ChicxEdit;
ar >> m_ChengEdit;
ar >> m_CejujEdit;
ar >> m_CejucEdit;
ar.Close();
f.Close();
AfxGetApp()->AddToRecentFileList(name);
((CFrameWnd*)AfxGetApp() -> m_pMainWnd ) -> SetWindowText( title+" - 变形观测数据处理包" );
m_projsetup=1;m_projopen=0;m_projclose=1;m_projsave=1;m_projnew=0;
m_input=1;
}
void CDeformAdjApp::OnFileMruFile3()
{
// TODO: Add your command handler code here
CString str,name;
CMainFrame* pmain;
pmain = (CMainFrame*)m_pMainWnd ;
CMenu* pMenu = pmain->GetMenu();
CMenu* pSubMenu = pMenu->GetSubMenu(0);
pSubMenu->GetMenuString( ID_FILE_MRU_FILE3, str, MF_BYCOMMAND ) ;
int strsum = str.GetLength()-3;
name = str.Right(strsum);
int length = name.GetLength();
int i = name.ReverseFind( '\\' );
directory = name.Left( i+1 );
projname = name.Right( length - i -1 );
CString title = projname.Left( length - i -5 );
CDeformAdjDoc* pdoc;
pdoc = (CDeformAdjDoc*)(((CFrameWnd*)AfxGetApp() -> m_pMainWnd ) ->GetActiveDocument());
CFile f;
if ( f.Open( name ,CFile::modeRead ) == false )
{
AfxMessageBox("请确认工程文件是否移动,建议用'打开工程'菜单确认工程文件的具体位置!");
return;
}
CArchive ar ( &f , CArchive::load );
ar >> projname;
ar >> m_TouygEdit;
ar >> m_JiaEdit;
ar >> m_GuancgEdit;
ar >> m_FangxEdit;
ar >> m_ChicxEdit;
ar >> m_ChengEdit;
ar >> m_CejujEdit;
ar >> m_CejucEdit;
ar.Close();
f.Close();
AfxGetApp()->AddToRecentFileList(name);
((CFrameWnd*)AfxGetApp() -> m_pMainWnd ) -> SetWindowText( title+" - 变形观测数据处理包" );
m_projsetup=1;m_projopen=0;m_projclose=1;m_projsave=1;m_projnew=0;
m_input=1;
}
void CDeformAdjApp::OnFileMruFile4()
{
// TODO: Add your command handler code here
CString str,name;
CMainFrame* pmain;
pmain = (CMainFrame*)m_pMainWnd ;
CMenu* pMenu = pmain->GetMenu();
CMenu* pSubMenu = pMenu->GetSubMenu(0);
pSubMenu->GetMenuString( ID_FILE_MRU_FILE4, str, MF_BYCOMMAND ) ;
int strsum = str.GetLength()-3;
name = str.Right(strsum);
int length = name.GetLength();
int i = name.ReverseFind( '\\' );
directory = name.Left( i+1 );
projname = name.Right( length - i -1 );
CString title = projname.Left( length - i -5 );
CDeformAdjDoc* pdoc;
pdoc = (CDeformAdjDoc*)(((CFrameWnd*)AfxGetApp() -> m_pMainWnd ) ->GetActiveDocument());
CFile f;
if ( f.Open( name ,CFile::modeRead ) == false )
{
AfxMessageBox("请确认工程文件是否移动,建议用'打开工程'菜单确认工程文件的具体位置!");
return;
}
CArchive ar ( &f , CArchive::load );
ar >> projname;
ar >> m_TouygEdit;
ar >> m_JiaEdit;
ar >> m_GuancgEdit;
ar >> m_FangxEdit;
ar >> m_ChicxEdit;
ar >> m_ChengEdit;
ar >> m_CejujEdit;
ar >> m_CejucEdit;
ar.Close();
f.Close();
AfxGetApp()->AddToRecentFileList(name);
((CFrameWnd*)AfxGetApp() -> m_pMainWnd ) -> SetWindowText( title+" - 变形观测数据处理包" );
m_projsetup=1;m_projopen=0;m_projclose=1;m_projsave=1;m_projnew=0;
m_input=1;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -