223 lines
5.2 KiB
C++
223 lines
5.2 KiB
C++
#include "stdafx.h"
|
|
#include "ShowZDInfDlg.h"
|
|
#include "KTTempZoom.h"
|
|
|
|
extern Acad::ErrorStatus AddToModelSpace(AcDbEntity* pEnt, AcDbObjectId& id, AcDbDatabase* pDb = NULL, bool bClose = true);
|
|
|
|
IMPLEMENT_DYNAMIC(CShowZDInfDlg, CDialog)
|
|
|
|
CShowZDInfDlg::CShowZDInfDlg(CWnd* pParent /*=NULL*/)
|
|
: CDialog(CShowZDInfDlg::IDD, pParent)
|
|
{
|
|
m_pvtTxtOnXLines = NULL;
|
|
m_nLastItem = -1;
|
|
m_dVDist = 54.0;
|
|
}
|
|
|
|
CShowZDInfDlg::~CShowZDInfDlg()
|
|
{
|
|
AcAxDocLock lock;
|
|
if (m_idPos.isValid())
|
|
{
|
|
AcDbEntity* pEnt = NULL;
|
|
if ( Acad::eOk == acdbOpenAcDbEntity(pEnt,m_idPos,AcDb::kForWrite))
|
|
{
|
|
pEnt->erase();
|
|
pEnt->close();
|
|
}
|
|
}
|
|
}
|
|
|
|
void CShowZDInfDlg::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CDialog::DoDataExchange(pDX);
|
|
DDX_Control(pDX, IDC_LIST1, m_wndListCtrl);
|
|
}
|
|
|
|
BEGIN_MESSAGE_MAP(CShowZDInfDlg, CDialog)
|
|
ON_BN_CLICKED(IDOK, &CShowZDInfDlg::OnBnClickedOk)
|
|
ON_NOTIFY(NM_CLICK, IDC_LIST1, &CShowZDInfDlg::OnNMClickList1)
|
|
ON_MESSAGE( WM_ACAD_KEEPFOCUS, &CShowZDInfDlg::onAcadKeepFocus )
|
|
END_MESSAGE_MAP()
|
|
|
|
LONG_PTR CShowZDInfDlg::onAcadKeepFocus( UINT_PTR, LONG_PTR)
|
|
{
|
|
POINT pt;
|
|
::GetCursorPos(&pt);
|
|
CRect rect;
|
|
GetWindowRect(&rect);
|
|
if(!(rect.PtInRect(pt)))
|
|
{
|
|
return FALSE;
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
void CShowZDInfDlg::SetvtTxtOnXLineLn(std::vector<TextOnXLine>* pvtTxtOnXLines,CString& sELTypeName,double dVDist)
|
|
{
|
|
m_pvtTxtOnXLines = pvtTxtOnXLines;
|
|
m_sELTypeName = sELTypeName;
|
|
m_dVDist = dVDist;
|
|
}
|
|
|
|
BOOL CShowZDInfDlg::OnInitDialog()
|
|
{
|
|
CDialog::OnInitDialog();
|
|
|
|
m_ImageList.Create(IDB_BITMAP4,16,1,RGB(0, 255, 255));
|
|
m_wndListCtrl.SetImageList(&m_ImageList,LVSIL_SMALL);
|
|
m_wndListCtrl.SetExtendedStyle(LVS_EX_FULLROWSELECT);
|
|
|
|
m_wndListCtrl.InsertColumn(0,_T("桩号"),LVCFMT_LEFT,120,120);
|
|
m_wndListCtrl.InsertColumn(1,m_sELTypeName,LVCFMT_LEFT,120,120);
|
|
m_wndListCtrl.InsertColumn(2,_T("X"),LVCFMT_LEFT,0,0);
|
|
m_wndListCtrl.InsertColumn(3,_T("Y"),LVCFMT_LEFT,0,0);
|
|
|
|
//m_wndListCtrl.SetColumnItemData(1,NULL,ET_Edit);
|
|
|
|
ShowZDInfToList();
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
void CShowZDInfDlg::ShowZDInfToList()
|
|
{
|
|
if (m_pvtTxtOnXLines != NULL)
|
|
{
|
|
if (!m_pvtTxtOnXLines->empty() )
|
|
{
|
|
m_dTxH = m_pvtTxtOnXLines->begin()->dTxtH;
|
|
}
|
|
|
|
CString sPos;
|
|
int nItem = -1;
|
|
std::vector<TextOnXLine>::iterator it;
|
|
for ( it = m_pvtTxtOnXLines->begin();it != m_pvtTxtOnXLines->end();it++)
|
|
{
|
|
nItem = m_wndListCtrl.GetItemCount();
|
|
|
|
m_wndListCtrl.InsertItem(nItem,it->szText2);//桩号
|
|
m_wndListCtrl.SetItemText(nItem,1,it->szText1);//高程
|
|
|
|
sPos.Format(_T("%g"),it->ptOnXLine.x);
|
|
m_wndListCtrl.SetItemText(nItem,2,sPos);
|
|
|
|
sPos.Format(_T("%g"),it->ptOnXLine.y);
|
|
m_wndListCtrl.SetItemText(nItem,3,sPos);
|
|
}
|
|
m_pvtTxtOnXLines = NULL;
|
|
}
|
|
}
|
|
|
|
void CShowZDInfDlg::OnBnClickedOk()
|
|
{
|
|
//写文件
|
|
CString sDwgFile = curDoc()->fileName();
|
|
sDwgFile.MakeLower();
|
|
|
|
int nPos = sDwgFile.ReverseFind(_T('.'));
|
|
if (nPos != -1)
|
|
{
|
|
CString sFileName,sStack,sEl;
|
|
sFileName = sDwgFile.Mid(0,nPos);
|
|
|
|
CString sFullFile,sLine;
|
|
sFullFile.Format(_T("%s-%s.txt"),sFileName,m_sELTypeName);
|
|
|
|
CString szFilter = _T("纵断数据文件 (*.txt)|*.txt;*.txt||");
|
|
CFileDialog fileDlg(FALSE,_T("txt"),sFullFile,OFN_HIDEREADONLY,szFilter,acedGetAcadFrame());
|
|
int nRes = (int)fileDlg.DoModal();
|
|
if (nRes == IDOK)
|
|
{
|
|
sFullFile = fileDlg.GetPathName();
|
|
}
|
|
else
|
|
{
|
|
return;
|
|
}
|
|
|
|
CStdioFile file;
|
|
if (file.Open(sFullFile,CFile::modeCreate | CFile::modeWrite | CFile::typeText ))
|
|
{
|
|
for(int i = 0;i < m_wndListCtrl.GetItemCount();i++)
|
|
{
|
|
|
|
sStack = m_wndListCtrl.GetItemText(i,0);
|
|
sEl = m_wndListCtrl.GetItemText(i,1);
|
|
|
|
//桩号 高程
|
|
sLine.Format(_T("%s %s\n"),sStack,sEl);
|
|
file.WriteString(sLine);
|
|
}
|
|
file.Close();
|
|
|
|
CString sTip;
|
|
sTip.Format(_T("提取 %s 保存本地文件完毕!是否打开?"),m_sELTypeName);
|
|
if ( IDYES == AfxMessageBox(sTip,MB_YESNO) )
|
|
{
|
|
SHELLEXECUTEINFO csSEI;
|
|
memset(&csSEI, 0, sizeof(csSEI));
|
|
csSEI.cbSize = sizeof(SHELLEXECUTEINFO);
|
|
csSEI.fMask = SEE_MASK_FLAG_NO_UI;
|
|
csSEI.lpVerb = _T("open");
|
|
csSEI.lpFile = sFullFile;
|
|
csSEI.nShow = SW_SHOWMAXIMIZED;
|
|
::ShellExecuteEx(&csSEI);
|
|
}
|
|
}
|
|
}
|
|
OnOK();
|
|
}
|
|
|
|
void CShowZDInfDlg::OnNMClickList1(NMHDR *pNMHDR, LRESULT *pResult)
|
|
{
|
|
/*LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast<LPNMITEMACTIVATE>(pNMHDR);
|
|
if ( pNMItemActivate->iItem != -1 && pNMItemActivate->iItem != m_nLastItem)
|
|
{
|
|
CString sPos = m_wndListCtrl.GetItemText(pNMItemActivate->iItem,2);
|
|
double dX = _ttof(sPos);
|
|
|
|
sPos = m_wndListCtrl.GetItemText(pNMItemActivate->iItem,3);
|
|
double dY = _ttof(sPos);
|
|
|
|
AcAxDocLock lock;
|
|
if (m_idPos.isValid())
|
|
{
|
|
AcDbEntity* pEnt = NULL;
|
|
if ( Acad::eOk == acdbOpenAcDbEntity(pEnt,m_idPos,AcDb::kForWrite))
|
|
{
|
|
AcDbXline* pXLine = AcDbXline::cast(pEnt);
|
|
if (pXLine != NULL)
|
|
{
|
|
AcGePoint3d ptX = pXLine->basePoint();
|
|
ptX.x = dX;
|
|
pXLine->setBasePoint(ptX);
|
|
}
|
|
pEnt->close();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
AcDbXline* pXLine = new AcDbXline;
|
|
AcGePoint3d ptX;
|
|
ptX.set(dX,0,0);
|
|
pXLine->setBasePoint(ptX);
|
|
pXLine->setUnitDir(AcGeVector3d::kYAxis);
|
|
pXLine->setColorIndex(1);
|
|
AddToModelSpace(pXLine,m_idPos);
|
|
}
|
|
|
|
ads_point ptLow,ptUp;
|
|
ptLow[X] = dX;
|
|
ptLow[X] -= 0.5 * m_dTxH;
|
|
ptLow[Y] = dY - 0.25 * m_dVDist;
|
|
ptLow[Z] = 0.0;
|
|
|
|
ads_point_set(ptLow,ptUp);
|
|
ptUp[X] += m_dTxH;
|
|
ptUp[Y] += 1.5 * m_dVDist;
|
|
KTTempZoom::arxZoom(ptLow,ptUp);
|
|
}*/
|
|
*pResult = 0;
|
|
}
|