#include "stdafx.h" #include "resource.h" #include "SetWall.h" //设置墙体参数的对话框 #include "WallDlg.h" #include "curtainWallSet.h" #define EXP_NONE 0 #define EXP_TCH 1 #define EXP_NONE 0 #define EXP_TCH 1 extern TARCH_IMPEXP void TogWallBase(); // 捕捉顺序: 墙基线端点,轴线交点,墙基线最近点,轴线最近点 // ptWcs -- I/O int AutoSnapWall(XPoint &ptWcs); int OsGetPointWall(double *ptFrom, const TCHAR *prompt, XPoint &pt, const TCHAR *kword=NULL, int *kwordId=NULL, BOOL *bDiscontinue=NULL); int OsGetCornerWall(double *ptFrom, const TCHAR *prompt, XPoint &pt, const TCHAR *kword=NULL, int *kwordId=NULL); // 拖曳画线性墙 int DragDrawLine(CDrawWallDlg *pDlg, XPoint &ptStart, const TCHAR *prompt, XPoint &ptEnd, const TCHAR *kword=NULL, int *kwordId=NULL, BOOL *bDiscontinue=NULL); // 给定起点, 终点进行拖动半径绘制弧 int DragDrawArc_SER(CDrawWallDlg *pDlg, const XPoint &ptStart, const XPoint &ptEnd, const TCHAR *prompt, double *nRadius, const TCHAR *kword=NULL, int *kwordId=NULL); // 给定起点, 弧上一点, 进行终点拖动绘制弧 int DragDrawArc_SPE(CDrawWallDlg *pDlg, const XPoint &ptStart, const XPoint &ptAny, const TCHAR *prompt, XPoint &ptEnd, const TCHAR *kword=NULL, int *kwordId=NULL); // 给定起点, 终点进行弧上一点拖动绘制弧 int DragDrawArc_SEP(CDrawWallDlg *pDlg, const XPoint &ptStart, const XPoint &ptEnd, const TCHAR *prompt, XPoint &ptAny, const TCHAR *kword=NULL, int *kwordId=NULL); extern TARCH_IMPEXP BOOL g_bRevWallFlag; //玻璃幕墙 add by whl int DrawGlassWall(); void DrawGlassWallCmd(); int GlassWall(const XCurveSegment &curve,CSPSheet&sheet,CCurtainWallSet&wallSetPage ,CGlassFrameSet&vFrameSet,CGlassFrameSet&hFrameSet) { if (curve.GetLength()_DIST_SNAP); wallSetPage.SetWallLength(curve.GetLength()); CAcModuleResourceOverride vTemp; // Zyu modify on 100722,支持64位 //UINT result=sheet.DoModal(); UINT_PTR result=sheet.DoModal(); if(result==IDOK) { TDbCurtainWall *pWall=new TDbCurtainWall; pWall->assertWriteEnabled(); (XCurveSegment &)(*pWall)=curve; pWall->SetUsageFlag(TWallData::kNormal); pWall->SetStyle(TWallData::kCurtain); //pWall->SetExternal(OFFSET_RIGHT); pWall->SetExternal(TRUE); pWall->SetExternal(1,TRUE);//modified by whl wallSetPage.Init(*pWall); vFrameSet.Init(*pWall); hFrameSet.Init(*pWall); pWall->AddToMSpace(Adesk::kTrue); return RTNORM; } else return RTERROR; } void DrawGlassWallCmd() { DrawGlassWall(); } int DrawGlassWall() { CAcModuleResourceOverride vTemp; CSPSheet sheet(_T("绘制玻璃幕墙")); CCurtainWallSet dlg0; CGlassFrameSet dlg1,dlg2(IDD_CURTAIN_WALL2); dlg1.SetBuddy(&dlg2); dlg2.SetBuddy(&dlg1); sheet.AddPage(&dlg0); sheet.AddPage(&dlg1); sheet.AddPage(&dlg2); //创建一个无任何功能作用的CDrawWallDlg对象,其作用只是重用DrawWall()代码时,使编译通过。 //CDrawWallDlg类的成员函数GetLeftWidth()、GetRightWidth()、GetTotalWidth()在 //完全不影响原功能的前提下,进行了少量修改,请将这三个函数替换。 //CDrawWallDlg dlg; // halfWidth=100; XPushMemVar vBackup1(CDrawWallDlg::g_bAutoSnap, FALSE); double lWidth=g_lWallWidth; double rWidth=g_rWallWidth; DocSetLWallWidth(100); DocSetRWallWidth(100); XPoint ptStart; int nWallShape=0; while(1) { if (XGetPoint(NULL, _T("\n起点"), ptStart)!=RTNORM) break; ptStart=Ucs2Wcs(ptStart); BOOL bDiscontinue=FALSE; XPointList aStack; aStack.Append(new XPoint(ptStart)); while(!bDiscontinue) { double nElev=ptStart.z; if (nWallShape==0) { ptStart.z = nElev; XPoint pt2; const TCHAR *szKeywords=_T("A"); XPoint &ptFrom=*aStack.Tail(); int nKwordIndex=0; int rc=0; rc=DragDrawLine(NULL, ptFrom, _T("\n直墙下一点或 [弧墙(A)]<退出>: "), pt2, szKeywords, &nKwordIndex, &bDiscontinue); if (rc!=RTKWORD && rc!=RTNORM) break; if (rc==RTNORM) { pt2.z = ptStart.z; XCurveSegment cv(*aStack.Tail(), pt2, 0.0, LS_FINITE); if (cv.GetLength()>_DIST_SNAP) { if (GlassWall(cv,sheet,dlg0,dlg1,dlg2)==RTNORM) { aStack.Append(new XPoint(pt2)); } } } else { if (nKwordIndex==1) { nWallShape=1; continue; } else if (nKwordIndex==2&& *aStack.Tail()!=ptStart) { XCurveSegment cv(*aStack.Tail(), ptStart, 0.0, LS_FINITE); if (cv.GetLength()>_DIST_SNAP && GlassWall(cv,sheet,dlg0,dlg1,dlg2)==RTNORM) { break; } } } } else if (nWallShape==1) { //弧墙 XPoint ptEnd; int rc=OsGetPointWall(*aStack.Tail(), _T("\n弧墙终点<取消>:"), ptEnd, NULL, NULL, &bDiscontinue); if (rc!=RTNORM) break; XPushVar orthomode(_T("ORTHOMODE"), 0); BOOL bOldRevFlag=g_bRevWallFlag; g_bRevWallFlag=FALSE; const TCHAR *szPromptAny=_T("\n点取弧上任意点或 [半径(R)]<取消>:"); XPoint ptAny; int nIdxKeyword, nRetCode; nRetCode=DragDrawArc_SEP(NULL, *aStack.Tail(), ptEnd, szPromptAny, ptAny, _T("R"), &nIdxKeyword); if (nRetCode!=RTNORM && nRetCode!=RTKWORD) break; XCurveSegment cv; if (nRetCode==RTKWORD) { //两点半径 static double nRadius=5000.0; nRetCode=DragDrawArc_SER(NULL, *aStack.Tail(), ptEnd, XString(_T("\n半径<%.f>:"), nRadius), &nRadius, NULL, NULL); if (nRetCode!=RTCAN) { double nChordLen=ads_distance(*aStack.Tail(), ptEnd); if (nChordLen<2.0*nRadius+1.0E-6) { double bulge=2.0*asin(nChordLen/2.0/nRadius); cv=XCurveSegment(*aStack.Tail(), ptEnd, bulge, LS_FINITE); nRetCode=RTNORM; } else { adsout << _T("半径值太小!"); nRetCode=RTERROR; } } } else { //三点 cv=XArc(*aStack.Tail(), ptAny, ptEnd); if (cv.EndPoint().Distance2d(ptEnd)>_DIST_SNAP) g_bRevWallFlag=TRUE; } if (nRetCode==RTNORM || nRetCode==RTKWORD) { GlassWall(cv,sheet,dlg0,dlg1,dlg2); aStack.Append(new XPoint(ptEnd)); g_bRevWallFlag=bOldRevFlag; } else { g_bRevWallFlag=bOldRevFlag; break; } nWallShape=0; } break; } break; // Only one } DocSetLWallWidth(lWidth); DocSetRWallWidth(rWidth); return RTNORM; } int EditCurtainWall(AcDbObjectId idWall) { OPENOBJ_BEGIN(idWall, AcDb::kForWrite, TDbCurtainWall, pWall); if (!pWall) return RTERROR; //标记墙内外侧 int nLeftColor=3, nRightColor=6; //XScreenDc dc(nLeftColor); XCurveSegment lCurve0, rCurve0; pWall->GetSideCurve(lCurve0, rCurve0); lCurve0.SetStartPoint(Wcs2Ucs(lCurve0.GetStartPoint())); lCurve0.SetEndPoint(Wcs2Ucs(lCurve0.GetEndPoint())); rCurve0.SetStartPoint(Wcs2Ucs(rCurve0.GetStartPoint())); rCurve0.SetEndPoint(Wcs2Ucs(rCurve0.GetEndPoint())); //dc << lCurve0; //dc.m_nFrontColor = nRightColor; //dc << rCurve0; //acedUpdateDisplay(); CAcModuleResourceOverride vTemp; CSPSheet sheet(_T("玻璃幕墙编辑")); CCurtainWallSet dlg0; CGlassFrameSet dlg1,dlg2(IDD_CURTAIN_WALL2); dlg1.SetBuddy(&dlg2); dlg2.SetBuddy(&dlg1); sheet.AddPage(&dlg0); sheet.AddPage(&dlg1); sheet.AddPage(&dlg2); dlg0.Init(*pWall,false); dlg1.Init(*pWall,false); dlg2.Init(*pWall,false); if (sheet.DoModal()==IDOK) { pWall->assertWriteEnabled(); dlg0.Init(*pWall); dlg1.Init(*pWall); dlg2.Init(*pWall); if (pWall->upgradeOpen()!=Acad::eOk) return RTERROR; } ads_redraw(NULL, 0); OPENOBJ_END(); return RTNORM; }