⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testdlg.cpp

📁 采用距离反比加权算法
💻 CPP
📖 第 1 页 / 共 4 页
字号:
}
void CTestDlg::DisableModeOne(BOOL b)
{
	m_staticOrgDir.EnableWindow(b);
	m_editOrgDir.EnableWindow(b);
	m_buttonOrgDir.EnableWindow(b);
	m_buttonReadFile.EnableWindow(b);
	
}
void CTestDlg::DisableModeTwo(BOOL b)
{	
	m_staticAreaDir.EnableWindow(b);
	m_editAreaDir.EnableWindow(b);
	m_buttonAreaDir.EnableWindow(b);
	m_buttonAreaFile.EnableWindow(b);	
}

void CTestDlg::OnButtonReadFile() 
{
	// TODO: Add your control notification handler code here
    m_bRead=TRUE;
	m_buttonReadFile.EnableWindow(FALSE);

	m_wellFileArray.Clear();
	m_strArrayStep.RemoveAll();
	m_strProArray.RemoveAll();
	
	if(m_nModeOne==0)
	{
		if(m_strOrgFileDir=="")
		{
			AfxMessageBox("目录不存在!");
			return;	
		}
		CStringArray strArray;
		int nCount=EnumFolderFile(m_strOrgFileDir,strArray);

		for(int i=0;i<nCount;i++)
		{
			CString strName=strArray[i];
			CString strFileName=m_strOrgFileDir+"\\"+strName;
			CString strExt=GetFileExtName(strName);
			if(strExt!="LAS")
				continue;
			if(!FileExists(strFileName))
				continue;
			CWellFile *pfile=new CWellFile;
			if(pfile->GetHead(strFileName))
			{
				pfile->m_strFilePath=strFileName;
				m_wellFileArray.Add(pfile);
				if(!StepExist(pfile->m_dbStep))
				{
					CString str;
					str.Format("%lf",pfile->m_dbStep);
					m_strArrayStep.Add(str);

				}
			}
			else
			{
				delete pfile;
				pfile=NULL;
			}
		}
		
	}

	m_buttonReadFile.EnableWindow(TRUE);

//////////////////查找不同物性值然后在组合框中显示///////////////////

	SearchPro();
	m_comboxBoxPro.Clear();

	int nItem=m_strProArray.GetSize();

	for(int i=0;i<nItem;i++)
	{
		CString strItem=m_strProArray.GetAt(i);
        m_comboxBoxPro.AddString(strItem);
	}
    m_comboxBoxPro.SetCurSel(0);
///////////////////////采样////////////////////////////
    int nStep=m_strArrayStep.GetSize();

	for(i=0;i<nStep;i++)
	{
      CString strItem=m_strArrayStep.GetAt(i);
	  m_comboxSample.AddString(strItem);
	}
	m_comboxSample.SetCurSel(0);
	UpdateData(FALSE);
	m_bRead=FALSE;
}

void CTestDlg::OnButtonOrgDir() 
{
	// TODO: Add your control notification handler code here
	CString strPath;
	GetBrowserPath(this,strPath,"选择导入的井数据目录:");
	
	m_strOrgFileDir=strPath;
	
	UpdateData(FALSE);
}
int	CTestDlg::EnumFolderFile(CString strFolder,CStringArray& strArray)
{
	CFileFind fFind;
	CString strFind = strFolder + "\\*.*";
	CString strFileName;
	strArray.RemoveAll ();
	
	if (!fFind.FindFile (strFind))
		return -1;
	
	BOOL bFind = 1;
	while (bFind )
	{
		bFind =fFind.FindNextFile ();
		if (fFind.IsArchived())
		{
			strFileName = fFind.GetFileName ();
			if (strFileName != "." && strFileName != "..")
				strArray.Add (strFileName);
		}
	}
	return strArray.GetSize ();
}
BOOL CTestDlg::FileExists(CString strFileName)
{
	CFileFind fFind;
	if (!fFind.FindFile(strFileName))
		return FALSE;
	
	return TRUE;
}
void CTestDlg::SearchPro()
{
	int nCount=m_wellFileArray.GetSize();

	for(int i=0;i<nCount;i++)
	{
		CWellFile *pfile=m_wellFileArray.GetAt(i);
		if(pfile==NULL)
			continue;
		int nProp=pfile->m_strArray.GetSize();

		for(int j=0;j<nProp;j++)
		{
			CString strProp=pfile->m_strArray.GetAt(j);
			if(!PropExist(strProp))
				m_strProArray.Add(strProp);
		}
	}
}
BOOL CTestDlg::PropExist(CString strPro)
{
	int nCount=m_strProArray.GetSize();

	for(int i=0;i<nCount;i++)
	{
		CString str=m_strProArray.GetAt(i);
		if(str==strPro)
			return TRUE;
	}
	return FALSE;
}

void CTestDlg::OnCloseupComboProSheet() 
{
	// TODO: Add your control notification handler code here
	int nNo=m_comboxBoxPro.GetCurSel();

	int nCount=m_strProArray.GetSize();

	if(nNo<0||nNo>nCount-1)
	{
		AfxMessageBox("选择非法!");
		return;
	}
	m_strCurrentPro=m_strProArray.GetAt(nNo);
	
	UpdateData(false);
}

void CTestDlg::OnCloseupComboResetStep() 
{
	// TODO: Add your control notification handler code here
	int m_nComboCur = m_comboxResetStep.GetCurSel();
	if(m_nComboCur == 0)m_nScale = 1;
	if(m_nComboCur == 1)m_nScale = 2;
	if(m_nComboCur == 2)m_nScale = 3;
	if(m_nComboCur == 3)m_nScale = 4;
	if(m_nComboCur == 4)m_nScale = 5;
	if(m_nComboCur == 5)m_nScale = 6;
	if(m_nComboCur == 6)m_nScale= 7;
	if(m_nComboCur == 7)m_nScale = 8;
	if(m_nComboCur == 8)m_nScale = 9;
	if(m_nComboCur == 9)m_nScale = 10;
	if(m_nComboCur == 10)m_nScale = 11;
	if(m_nComboCur == 11)m_nScale = 12;
	if(m_nComboCur == 12)m_nScale = 13;
	if(m_nComboCur == 13)m_nScale = 14;
	if(m_nComboCur == 14)m_nScale = 15;
	if(m_nComboCur == 15)m_nScale= 16;
	if(m_nComboCur == 16)m_nScale = 17;
	if(m_nComboCur == 17)m_nScale = 18;
    if(m_nComboCur == 18)m_nScale = 19;
	if(m_nComboCur == 19)m_nScale = 20;
	
	
	UpdateData(false);
}
void CTestDlg::Make3do()
{
	int nCounter=0;
	int nCount=m_wellFileArray.GetSize();
	for(int i=0;i<nCount;i++)
	{
		CWellFile *pfile=m_wellFileArray.GetAt(i);
   
        if(pfile==NULL)
			continue;
		pfile->Clear();
		if(!pfile->PropCurrentExist(m_strCurrentPro))
			continue;
		pfile->m_bSelected=TRUE;
		pfile->m_nScale=m_nScale;
		nCounter++;
	}
   

	CProgressDlg    *m_pProgress=new CProgressDlg(0);
    m_pProgress->m_strTitle="生成三维离散数据进度条";
	m_pProgress->Create(this);
	m_pProgress->SetRange(0,nCounter);
	
    int nPos=0;
	int nPointTotal=0;
	

	for(int j=0;j<nCount;j++)
	{
		CWellFile *pfile=m_wellFileArray.GetAt(j);
		if(pfile==NULL)
			continue;
		if(m_pProgress->m_bCancel)
		{
			m_pProgress->DestroyWindow();
			return;
		}
		if(pfile->m_bSelected)
		{
			m_pProgress->SetPos(nPos++);
			if(!pfile->GetBody())
				continue;
			int n=pfile->m_pointArray.GetSize();
			nPointTotal+=n;
		}
	        
		
	}
	 m_pProgress->DestroyWindow();

	 CString strFileName=m_str3doDir+"\\"+m_str3doFileName+".3do";
	 int nVal=1;
	 
	 FILE *fp;
	 fp=fopen(strFileName,"w");
	 if(fp==NULL)
		 return;
    
	 fprintf(fp,"%d    %d    %d\n",nPointTotal,nVal,nVal);
	 for(j=0;j<nCount;j++)
	 {
		 CWellFile *pfile=m_wellFileArray.GetAt(j);
		 if(pfile==NULL)
			 continue;
		 if(pfile->m_bSelected)
		 {
			 int n=pfile->m_pointArray.GetSize();
			 double x,y;
			 x=pfile->m_dbX;
			 y=pfile->m_dbY;

			 for(int m=0;m<n;m++)
			 {
				 point pt=pfile->m_pointArray.GetAt(m);
				 pt.z=pfile->m_dbZ-pt.z;
				 fprintf(fp,"%lf  %lf  %lf  %lf\n",x,y,pt.z,pt.v);
			 }
			 
		 }
	        
		 
	 }
	 fclose(fp);

	 AfxMessageBox("三维离散数据模型组合完毕!");
}

void CTestDlg::OnButtonMake3do() 
{
	// TODO: Add your control notification handler code here
	UpdateData();
	if(m_wellFileArray.GetSize()<1)
	{
		AfxMessageBox("文件未加载,无法生成3do文件!");
		return;
	}
	if(m_strCurrentPro=="")
	{
		AfxMessageBox("请选择合适物性类别!");
		return;
	}
	if(m_str3doFileName=="")
	{
		AfxMessageBox("三维离散数据名称未指定!");
		return;
	}
	if(m_str3doDir=="")
	{
		AfxMessageBox("三维离散数据要存放的目录未指定!");
		return;
	}
	
	Make3do();
}
BOOL CTestDlg::StepExist(double dbStep)
{
	CString str;

	str.Format("%lf",dbStep);

	int nCount=m_strArrayStep.GetSize();

	for(int i=0;i<nCount;i++)
	{
		CString strStep=m_strArrayStep.GetAt(i);

		if(strStep==str)
			return TRUE;
	}
	return FALSE;
}

void CTestDlg::OnButtonSave3do() 
{
	// TODO: Add your control notification handler code here
	CString strPath;
	GetBrowserPath(this,strPath,"选择导入的井数据目录:");
	
	m_str3doDir=strPath;
	
	UpdateData(FALSE);
}
void CTestDlg::DivXYGrid()
{
	if(m_nGridX<1||m_nGridY<1)
		return;
	int nCount=m_LayerArray.GetSize();
	for(int i=0;i<nCount;i++)
	{
		CLayer *pLayer=m_LayerArray.GetAt(i);
		if(pLayer==NULL)
			continue;
		pLayer->Init(m_nGridX,m_nGridY,m_dbMaxX,m_dbMinX,m_dbMaxY,m_dbMinY);
		pLayer->DivGridXY();
		
	}
}
int CTestDlg::GetXYLayer(CLayer *pLayer,double x,double y)
{
	int nIndex=0;

	int nCount=pLayer->m_GridArray.GetSize();
	for(int i=0;i<nCount;i++)
	{
		CGridXY *pGrid=pLayer->m_GridArray.GetAt(i);
		if(x>=pGrid->m_dbLeft&&x<=pGrid->m_dbRight&&y>=pGrid->m_dbTop&&y<=pGrid->m_dbBottom)
			return i;
	}
	return nIndex;
}

void CTestDlg::OnButtonAreaDir() 
{
	// TODO: Add your control notification handler code here
	CString strPath;
	GetBrowserPath(this,strPath,"选择工区目录:");
	
	m_strAreaPath=strPath;
	

	UpdateData(FALSE);
}

void CTestDlg::OnButtonAreaFile() 
{
	// TODO: Add your control notification handler code here
    m_bRead=TRUE;
	
	m_buttonAreaDir.EnableWindow(FALSE);

	m_wellFileArray.Clear();
	m_strArrayStep.RemoveAll();
	m_strProArray.RemoveAll();

	CString strPath=m_strAreaPath+"\\井";
	
	if(!FileExists(strPath))
		return;
	
	CStringArray strArray;
	int nCount=EnumFolderSubFolder(strPath,strArray);

	for(int i=0;i<nCount;i++)
	{
		CString strName=strArray[i];
		CString strFileName=strPath+"\\"+strName+"\\井区数据"+"\\"+strName+".LAS";

	
		if(!FileExists(strFileName))
			continue;
		CWellFile *pfile=new CWellFile;
		if(pfile->GetHead(strFileName))
		{
			
			pfile->m_strFilePath=strFileName;
			m_wellFileArray.Add(pfile);
			if(!StepExist(pfile->m_dbStep))
			{
				CString str;
				str.Format("%lf",pfile->m_dbStep);
				m_strArrayStep.Add(str);
				
			}
		}
		else
		{
			delete pfile;
			pfile=NULL;
		}
	}
	SearchPro();
	m_comboxBoxPro.Clear();
	
	int nItem=m_strProArray.GetSize();
	
	for( i=0;i<nItem;i++)
	{
		CString strItem=m_strProArray.GetAt(i);
        m_comboxBoxPro.AddString(strItem);
	}
    m_comboxBoxPro.SetCurSel(0);
	///////////////////////采样////////////////////////////
    int nStep=m_strArrayStep.GetSize();
	
	for(i=0;i<nStep;i++)
	{
		CString strItem=m_strArrayStep.GetAt(i);
		m_comboxSample.AddString(strItem);
	}
	m_comboxSample.SetCurSel(0);
	UpdateData(FALSE);

	m_buttonAreaDir.EnableWindow(TRUE);

	m_bRead=FALSE;
}
int	CTestDlg::EnumFolderSubFolder(CString strFolder,CStringArray& strArray)
{
	CFileFind fFind;
	CString strFind = strFolder + "\\*.*";
	CString strFileName;
	strArray.RemoveAll ();
	
	if (!fFind.FindFile (strFind))
		return -1;
	
	BOOL bFind = 1;
	while (bFind )
	{
		bFind =fFind.FindNextFile ();
		if (fFind.IsDirectory())
		{
			strFileName = fFind.GetFileName ();
			if (strFileName != "." && strFileName != "..")
				strArray.Add (strFileName);
		}
	}
	return strArray.GetSize ();
}

BOOL CTestDlg::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message) 
{
	// TODO: Add your message handler code here and/or call default
	if(m_bRead)
		SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));
	else
	    SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW));
	
	return TRUE;
	//return CDialog::OnSetCursor(pWnd, nHitTest, message);
}
void CTestDlg::InitImageFileHeader(EA3DDATAFILEHEADER *pFileHeader)
{
	BYTE btMark[4] = {'E','A','3','D'};
	
	memcpy(pFileHeader->btMark,btMark,sizeof(btMark));
	
	pFileHeader->nCols=m_nCols;
	pFileHeader->nRows=m_nRows;
	pFileHeader->nSampleCount=m_nSamples;
	pFileHeader->dbMaxValue=m_dbMaxV;
	pFileHeader->dbMinValue=m_dbMinV;
	pFileHeader->dbMinZ=m_dbMinZ;
	pFileHeader->dbMaxZ=m_dbMaxZ;
	pFileHeader->dbCoordX1=m_dbMinX;
	pFileHeader->dbCoordY1=m_dbMinY;
	
	pFileHeader->dbCoordX2=m_dbMinX;
	pFileHeader->dbCoordY2=m_dbMaxY;
	
	pFileHeader->dbCoordX3=m_dbMaxX;
	pFileHeader->dbCoordY3=m_dbMaxY;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -