337 lines
7.1 KiB
C++
337 lines
7.1 KiB
C++
#include "stdafx.h"
|
|
#include "FZTTDlg.h"
|
|
#include "KTCADUtilityEx.h"
|
|
#include "AecDbEarthWorm.h"
|
|
#include "UITools.h"
|
|
|
|
IMPLEMENT_DYNAMIC(CFZTTDlg, CDialog)
|
|
|
|
static void FreeBuffer(AcDbVoidPtrArray& arTextPtrs)
|
|
{
|
|
AcDbEntity* pEnt = NULL;
|
|
while(arTextPtrs.length() > 0)
|
|
{
|
|
pEnt = (AcDbEntity*)arTextPtrs.first();
|
|
arTextPtrs.removeFirst();
|
|
DELETE_PTR(pEnt);
|
|
}
|
|
}
|
|
|
|
CFZTTDlg::CFZTTDlg(CWnd* pParent /*=NULL*/)
|
|
: CDialog(CFZTTDlg::IDD, pParent)
|
|
, m_dL(1000)
|
|
, m_dW(600)
|
|
, m_dH(600)
|
|
, m_dRoomWSel(0)
|
|
, m_dBreakSpace(2000)
|
|
, m_dDirLen(800)
|
|
{
|
|
m_pRectCell = NULL;
|
|
m_nRoomIndex = -1;
|
|
|
|
m_pRectCell = new AcDbPolyline;
|
|
m_pRectCell->addVertexAt(0,AcGePoint2d::kOrigin);
|
|
m_pRectCell->addVertexAt(1,AcGePoint2d(1,0));
|
|
m_pRectCell->addVertexAt(1,AcGePoint2d(1,1));
|
|
m_pRectCell->addVertexAt(1,AcGePoint2d(0,1));
|
|
m_pRectCell->setColorIndex(6);
|
|
m_pRectCell->setClosed(Adesk::kTrue);
|
|
m_pRectCell->setConstantWidth(0.1);
|
|
::memset(&m_data, 0, sizeof(EWFnctNode));
|
|
}
|
|
|
|
CFZTTDlg::~CFZTTDlg()
|
|
{
|
|
}
|
|
|
|
void CFZTTDlg::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CDialog::DoDataExchange(pDX);
|
|
DDX_Text(pDX, IDC_EDIT1, m_dL);
|
|
DDX_Text(pDX, IDC_EDIT2, m_dW);
|
|
DDX_Text(pDX, IDC_EDIT3, m_dH);
|
|
DDX_Text(pDX, IDC_EDITROOMW, m_dRoomWSel);
|
|
DDX_Text(pDX, IDC_EDIT5, m_dBreakSpace);
|
|
DDX_Text(pDX, IDC_EDIT4, m_dDirLen);
|
|
}
|
|
|
|
|
|
BEGIN_MESSAGE_MAP(CFZTTDlg, CDialog)
|
|
ON_BN_CLICKED(IDOK, &CFZTTDlg::OnBnClickedOk)
|
|
ON_BN_CLICKED(IDC_BUTTON1, &CFZTTDlg::OnBnClickedButton1)
|
|
ON_BN_CLICKED(IDC_BUTTON4, &CFZTTDlg::OnBnClickedButton4)
|
|
ON_MESSAGE(WM_VIEW_LBUTTONDOWN,&CFZTTDlg::OnViewLButtonDown)
|
|
END_MESSAGE_MAP()
|
|
|
|
void CFZTTDlg::SetCrossSectionScr(LPCTSTR pszCrossSectionScr)
|
|
{
|
|
m_sCrossSectionScr = pszCrossSectionScr;
|
|
}
|
|
|
|
void CFZTTDlg::SetBosses(AcArray<EBoss>& arBosses)
|
|
{
|
|
m_arBosses.append(arBosses);
|
|
}
|
|
|
|
void CFZTTDlg::GetBosses(AcArray<EBoss>& arBosses)
|
|
{
|
|
arBosses.append(m_arBosses);
|
|
}
|
|
|
|
BOOL CFZTTDlg::OnInitDialog()
|
|
{
|
|
CDialog::OnInitDialog();
|
|
|
|
// 子类化控件对象
|
|
if (!m_wndViewCtrl.SubclassDlgItem(IDC_STATIC_FRM, this))
|
|
{
|
|
// 错误时,结束对话框
|
|
EndDialog(IDCANCEL);
|
|
return FALSE;
|
|
}
|
|
|
|
ShowEarthWorm();
|
|
|
|
m_data.fNodeDef[0] = AS_MUNITF(1000.f);
|
|
m_data.fNodeDef[1] = AS_MUNITF(600.f);
|
|
m_data.fNodeDef[2] = AS_MUNITF(600.f);
|
|
m_data.fNodeDef[3] = AS_MUNITF(0.f);
|
|
m_data.fNodeDef[4] = AS_MUNITF(2000.f);
|
|
m_data.fNodeDef[5] = AS_MUNITF(800.f);
|
|
UIDataCache::FindNode(_T("FZTT"), &m_data);
|
|
|
|
m_dL = AS_M2MM(m_data.fNodeDef[0]);
|
|
m_dW = AS_M2MM(m_data.fNodeDef[1]);
|
|
m_dH = AS_M2MM(m_data.fNodeDef[2]);
|
|
m_dRoomWSel = AS_M2MM(m_data.fNodeDef[3]);
|
|
m_dBreakSpace = AS_M2MM(m_data.fNodeDef[4]);
|
|
m_dDirLen = AS_M2MM(m_data.fNodeDef[5]);
|
|
|
|
UpdateData(FALSE);
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
void CFZTTDlg::ShowEarthWorm()
|
|
{
|
|
m_wndViewCtrl.clearAll();
|
|
m_wndViewCtrl.init(true);
|
|
m_wndViewCtrl.SetOrbitFlag(OBF_PAN | OBF_ZOOM | OBF_COTE);
|
|
|
|
AecDbEarthWorm worm;
|
|
worm.SetCrossSectionScr(m_sCrossSectionScr);
|
|
worm.SetChamferInter(100.0f);
|
|
|
|
ESection eType = eRect;
|
|
AcGePoint2dArray arDatas;
|
|
eType = worm.ExtractEarthWormScr(arDatas);
|
|
|
|
AcGeLineSeg3d ln;
|
|
AcGePoint3d pt2(1000.0,0,0);
|
|
ln.set(AcGePoint3d::kOrigin,pt2);
|
|
|
|
AcDbRegion* pEWRegion = worm.CreateSectionRegion(ln,eType,arDatas);
|
|
if (pEWRegion != NULL)
|
|
{
|
|
AcDbExtents exts;
|
|
pEWRegion->getGeomExtents(exts);
|
|
|
|
AcGeMatrix3d xform;
|
|
xform.setToScaling(0.95);
|
|
pEWRegion->transformBy(xform);
|
|
|
|
m_wndViewCtrl.InitFromCurrentView2D(exts,true);
|
|
|
|
AcDbVoidPtrArray arr;
|
|
int rooms = worm.CreateSectionRoomRegion(ln, eType, arDatas, arr);
|
|
|
|
AcDbEntity* pEnt = NULL;
|
|
AcDbVoidPtrArray arr2;
|
|
worm.CreateSectionRoomAddition(ln,eType,arr2);
|
|
for (int i = 0; i < arr2.length(); i++)
|
|
{
|
|
pEnt = (AcDbEntity*)arr2.at(i);
|
|
m_wndViewCtrl.Add(pEnt);
|
|
}
|
|
|
|
m_wndViewCtrl.Add(pEWRegion);
|
|
m_wndViewCtrl.view()->invalidate();
|
|
|
|
m_wndViewCtrl.Invalidate();
|
|
m_wndViewCtrl.RedrawWindow();
|
|
}
|
|
}
|
|
|
|
LRESULT CFZTTDlg::OnViewLButtonDown(WPARAM wp,LPARAM lp)
|
|
{
|
|
AcGePoint3d* pPt = (AcGePoint3d*)lp;
|
|
pPt->z = 0.0;
|
|
|
|
//判断 点落在 room 内
|
|
AecDbEarthWorm worm;
|
|
worm.SetCrossSectionScr(m_sCrossSectionScr);
|
|
worm.SetChamferInter(100.0);
|
|
|
|
ESection eType = eRect;
|
|
AcGePoint2dArray arDatas;
|
|
eType = worm.ExtractEarthWormScr(arDatas);
|
|
|
|
AcGeLineSeg3d ln;
|
|
AcGePoint3d pt2(1000.0,0,0);
|
|
ln.set(AcGePoint3d::kOrigin,pt2);
|
|
|
|
m_nRoomIndex = -1;
|
|
AcGePoint3d ptGe[4];
|
|
AcDbVoidPtrArray arRegPtrs;
|
|
int nRooms = worm.CreateSectionRoomRegion(ln,eType,arDatas,arRegPtrs);
|
|
if (nRooms > 0)
|
|
{
|
|
AcDbRegion* pReg = NULL;
|
|
for (int i = 0;i < arRegPtrs.length();i++)
|
|
{
|
|
pReg = (AcDbRegion*)arRegPtrs.at(i);
|
|
if (pReg != NULL)
|
|
{
|
|
AcDbExtents ext;
|
|
pReg->getGeomExtents(ext);
|
|
|
|
ptGe[0] = ext.minPoint();
|
|
ptGe[1] = ptGe[0];
|
|
ptGe[1].x = ext.maxPoint().x;
|
|
ptGe[2] = ext.maxPoint();
|
|
ptGe[3] = ptGe[0];
|
|
ptGe[3].y = ext.maxPoint().y;
|
|
|
|
m_dRoomWSel = 1000.0 * (ext.maxPoint().x - ext.minPoint().x);//毫米
|
|
|
|
if (KTCADUtilityEx::IsPointInBoundary(*pPt,ptGe[0],ptGe[2]) )
|
|
{
|
|
m_nRoomIndex = i;
|
|
|
|
AcGsView* pView = m_wndViewCtrl.view();
|
|
AcGsModel* pModel = m_wndViewCtrl.model();
|
|
if (pView != NULL)
|
|
{
|
|
if (m_pRectCell != NULL)
|
|
pView->erase(m_pRectCell);
|
|
}
|
|
|
|
if (m_pRectCell != NULL)
|
|
{
|
|
for (int i = 0;i < 4;i++)
|
|
{
|
|
m_pRectCell->setPointAt(i,ptGe[i].convert2d(AcGePlane::kXYPlane) );
|
|
}
|
|
}
|
|
|
|
if (pView != NULL)
|
|
{
|
|
pView->add(m_pRectCell,pModel);
|
|
}
|
|
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (m_nRoomIndex == -1)
|
|
{
|
|
m_pRectCell->setPointAt(0,AcGePoint2d::kOrigin);
|
|
m_pRectCell->setPointAt(1,AcGePoint2d(1,0));
|
|
m_pRectCell->setPointAt(2,AcGePoint2d(1,1));
|
|
m_pRectCell->setPointAt(3,AcGePoint2d(0,1));
|
|
}
|
|
|
|
FreeBuffer(arRegPtrs);
|
|
|
|
m_wndViewCtrl.view()->invalidate();
|
|
//pGsCtrl->Invalidate();
|
|
m_wndViewCtrl.RedrawWindow();
|
|
}
|
|
return 0L;
|
|
}
|
|
|
|
void CFZTTDlg::OnBnClickedOk()
|
|
{
|
|
UpdateData(TRUE);
|
|
|
|
m_data.fNodeDef[0] = AS_MUNITF(m_dL);
|
|
m_data.fNodeDef[1] = AS_MUNITF(m_dW);
|
|
m_data.fNodeDef[2] = AS_MUNITF(m_dH);
|
|
m_data.fNodeDef[3] = AS_MUNITF(m_dRoomWSel);
|
|
m_data.fNodeDef[4] = AS_MUNITF(m_dBreakSpace);
|
|
m_data.fNodeDef[5] = AS_MUNITF(m_dDirLen);
|
|
|
|
UIDataCache::WriteNode(_T("FZTT"), &m_data);
|
|
OnOK();
|
|
}
|
|
|
|
void CFZTTDlg::OnBnClickedButton1()
|
|
{
|
|
UpdateData();
|
|
if (m_dL < 1.0)
|
|
{
|
|
AfxMessageBox(_T("凸台定位尺寸太小!"));
|
|
return;
|
|
}
|
|
|
|
if (m_dW < 1.0)
|
|
{
|
|
AfxMessageBox(_T("凸台宽度尺寸太小!"));
|
|
return;
|
|
}
|
|
|
|
if (m_dH < 1.0)
|
|
{
|
|
AfxMessageBox(_T("凸台高度尺寸太小!"));
|
|
return;
|
|
}
|
|
|
|
if (m_nRoomIndex != -1)
|
|
{
|
|
EBoss boss;
|
|
boss.nRoomIndex = m_nRoomIndex;
|
|
boss.ptData.set(AS_MUNIT(m_dL),AS_MUNIT(m_dW),AS_MUNIT(m_dH));
|
|
boss.dBreakSpace = AS_MUNIT(m_dBreakSpace);
|
|
boss.dDirLen = AS_MUNIT(m_dDirLen);
|
|
m_arBosses.append(boss);
|
|
|
|
ShowEarthWorm();
|
|
}
|
|
}
|
|
|
|
void CFZTTDlg::OnBnClickedButton4()
|
|
{
|
|
UpdateData();
|
|
if (m_dL < 1.0)
|
|
{
|
|
AfxMessageBox(_T("凸台定位尺寸太小!"));
|
|
return;
|
|
}
|
|
|
|
if (m_nRoomIndex == -1)
|
|
{
|
|
AfxMessageBox(_T("请选择管廊舱室!"));
|
|
return;
|
|
}
|
|
|
|
bool bFind = false;
|
|
for (int i = 0;i < m_arBosses.length();i++)
|
|
{
|
|
EBoss& boss = m_arBosses.at(i);
|
|
if (boss.nRoomIndex == m_nRoomIndex)
|
|
{
|
|
if ( fabs(boss.ptData.x - AS_MUNIT(m_dL)) < AS_MUNIT(10.0) )
|
|
{
|
|
m_arBosses.removeAt(i);
|
|
bFind = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (bFind)
|
|
{
|
|
ShowEarthWorm();
|
|
}
|
|
}
|