#include "stdafx.h" #include "TDbColumn.h" ///////////////////////////////////////////////////////////// // 屋顶对象类 ///////////////////////////////////////////////////////////// const Adesk::UInt8 TDbAscent::g_nVersion = 1; ACRX_DXF_DEFINE_MEMBERS(ATSAscent, ATSEntity, AcDb::kDHL_CURRENT, AcDb::kMReleaseCurrent, 1, ATS_ASCENT, "ATS_ASCENT图形无法解析, 请下载上华软件|网址: www.shanghuasoft.com"); IMPLEMENT_TENTBASE(TDbAscent); TDbAscent::TDbAscent() { m_nLength = m_nWidth = m_nHeight = m_nIdent = 0.0; m_nRotation = 0.0; m_nFlag=0; m_pTempRail=NULL; } TDbAscent::~TDbAscent() { } BOOL TDbAscent::IsValid() const { BOOL bRet=TDbEntity::IsValid(); if(!bRet) return bRet; return (m_nLength>0 && m_nWidth>0 && m_nWidth>m_nIdent*2 && m_nHeight>0); // && m_nIdent>-1.0E-6 } // 提供对格式刷的支持 void TDbAscent::CopyPropertiesFrom(AcDbEntity *pSrcEntity, unsigned gMatchFlag) { assertWriteEnabled(); TDbEntity::CopyPropertiesFrom(pSrcEntity, gMatchFlag); TDbAscent *pSrc=TDbAscent::cast(pSrcEntity); if(pSrc) { m_nLength=pSrc->m_nLength; m_nHeight=pSrc->m_nHeight; m_nWidth=pSrc->m_nWidth; m_nIdent=pSrc->m_nIdent; m_nFlag=pSrc->m_nFlag; } } Acad::ErrorStatus TDbAscent::subGetClassID(CLSID* pClsid) const { return Acad::eOk; } // 从DWG读入数据: Acad::ErrorStatus TDbAscent::dwgInFields (AcDbDwgFiler* pFiler) { assertWriteEnabled(); Acad::ErrorStatus es = TDbEntity::dwgInFields(pFiler); if(es != Acad::eOk) return es; Adesk::UInt8 nVer; pFiler->readItem(&nVer); if(nVer>g_nVersion) {// Version is too new return Acad::eMakeMeProxy; } pFiler->readItem((AcGePoint3d *)&m_ptLocation); pFiler->readItem(&m_nRotation); pFiler->readItem(&m_nFlag); pFiler->readItem(&m_nLength); pFiler->readItem(&m_nWidth); pFiler->readItem(&m_nHeight); pFiler->readItem(&m_nIdent); return pFiler->filerStatus(); } Acad::ErrorStatus TDbAscent::dwgOutFields(AcDbDwgFiler* pFiler) const { assertReadEnabled(); Acad::ErrorStatus es = TDbEntity::dwgOutFields(pFiler); if(es != Acad::eOk) return es; pFiler->writeItem(g_nVersion); pFiler->writeItem((AcGePoint3d &)m_ptLocation); pFiler->writeItem(m_nRotation); pFiler->writeItem(m_nFlag); pFiler->writeItem(m_nLength); pFiler->writeItem(m_nWidth); pFiler->writeItem(m_nHeight); pFiler->writeItem(m_nIdent); return pFiler->filerStatus(); } Acad::ErrorStatus TDbAscent::dxfInFields (AcDbDxfFiler* pFiler) { assertWriteEnabled(); Acad::ErrorStatus es = TDbEntity::dxfInFields(pFiler); if(es!=Acad::eOk) return es; if (!pFiler->atSubclassData(_T("TDbAscent"))) { return Acad::eBadDxfSequence; } int fieldsFlags=0; resbuf rb; int nFlag; double r1, r2, r3, r4, r5; XPoint pt; while ((es == Acad::eOk) && ((es = pFiler->readResBuf(&rb)) == Acad::eOk)) { switch (rb.restype) { case AcDb::kDxfXCoord: pt=rb.resval.rpoint; fieldsFlags |= 0x01; break; case AcDb::kDxfReal: r1=rb.resval.rreal; fieldsFlags |= 0x02; break; case AcDb::kDxfReal+1: r2 = rb.resval.rreal; fieldsFlags |= 0x04; break; case AcDb::kDxfReal+2: r3=rb.resval.rreal; fieldsFlags |= 0x08; break; case AcDb::kDxfReal+3: r4=rb.resval.rreal; fieldsFlags |= 0x10; break; case AcDb::kDxfAngle: r5=rb.resval.rreal; fieldsFlags |= 0x20; break; case AcDb::kDxfInt16: nFlag=rb.resval.rint; fieldsFlags |= 0x40; break; //fall through intentional default: // An unrecognized group. Push it back so that // the subclass can read it again. pFiler->pushBackItem(); es = Acad::eEndOfFile; break; } } // At this point the es variable must contain eEndOfFile // - either from readResBuf() or from pushback. If not, // it indicates that an error happened and we should // return immediately. // if (es != Acad::eEndOfFile) return Acad::eInvalidResBuf; if (!(fieldsFlags&0x01)) { pFiler->setError(Acad::eMissingDxfField, _T("\nMissing DXF group code: 10")); return Acad::eMissingDxfField; } if (!(fieldsFlags&0x02)) { pFiler->setError(Acad::eMissingDxfField, _T("\nMissing DXF group code: 40")); return Acad::eMissingDxfField; } if (!(fieldsFlags&0x04)) { pFiler->setError(Acad::eMissingDxfField, _T("\nMissing DXF group code: 41")); return Acad::eMissingDxfField; } if (!(fieldsFlags&0x08)) { pFiler->setError(Acad::eMissingDxfField, _T("\nMissing DXF group code: 42")); return Acad::eMissingDxfField; } m_ptLocation=pt; m_nLength=r1; m_nWidth=r2; m_nHeight=r3; if(fieldsFlags&0x10) m_nIdent=r4; if(fieldsFlags&0x20) m_nRotation=r5; if(fieldsFlags&0x40) m_nFlag=nFlag; return pFiler->filerStatus(); } Acad::ErrorStatus TDbAscent::dxfOutFields(AcDbDxfFiler* pFiler) const { assertReadEnabled(); Acad::ErrorStatus es = TDbEntity::dxfOutFields(pFiler); if(es!=Acad::eOk) return es; pFiler->writeItem(AcDb::kDxfSubclass,_T("TDbAscent")); pFiler->writePoint3d(AcDb::kDxfXCoord, m_ptLocation); pFiler->writeDouble(AcDb::kDxfReal, m_nLength); pFiler->writeDouble(AcDb::kDxfReal+1, m_nWidth); pFiler->writeDouble(AcDb::kDxfReal+2, m_nHeight); pFiler->writeDouble(AcDb::kDxfReal+3, m_nIdent); pFiler->writeDouble(AcDb::kDxfAngle, m_nRotation); pFiler->writeInt16(AcDb::kDxfInt16, m_nFlag); return es; } // ----------------------------------------------------------------------- // Overriden functions for edit // to do: // 允许通过夹点改变边界 Acad::ErrorStatus TDbAscent::subGetGripPoints(AcGePoint3dArray& gripPoints, AcDbIntArray& osnapModes, AcDbIntArray& geomIds) const { //modify by xlc on 090209 // return getStretchPoints(gripPoints); assertReadEnabled(); // 0 -- 移动 gripPoints.append(m_ptLocation); // 1, 2 -- 改长度和宽度 gripPoints.append(GetLowLeft2d().AsAcGePoint3d()); gripPoints.append(GetLowRight2d().AsAcGePoint3d()); // [3,4] XPoint ptUpRight=GetUpRight2d(); XPoint ptUpLeft=GetUpLeft2d(); if(!IsAligned(OFFSET_LEFT) && fabs(m_nIdent)>_DIST_SNAP) { //左小坡 XPoint ptTemp; ads_polar(ptUpLeft, m_nRotation, m_nIdent, ptTemp); gripPoints.append(ptTemp); } if(!IsAligned(OFFSET_RIGHT) && fabs(m_nIdent)>_DIST_SNAP) { //左小坡 XPoint ptTemp; ads_polar(ptUpRight, m_nRotation+PI, m_nIdent, ptTemp); gripPoints.append(ptTemp); } return Acad::eOk; } // stretch points is diffrent from grep points, with no midpoint included Acad::ErrorStatus TDbAscent::subGetStretchPoints(AcGePoint3dArray & stretchPoints) const { assertReadEnabled(); //modify by xlc on 090209修改stretch效果 // // 0 -- 移动 // stretchPoints.append(m_ptLocation); // // 1, 2 -- 改长度和宽度 // stretchPoints.append(GetLowLeft2d().AsAcGePoint3d()); // stretchPoints.append(GetLowRight2d().AsAcGePoint3d()); // // // [3,4] // XPoint ptUpRight=GetUpRight2d(); // XPoint ptUpLeft=GetUpLeft2d(); // if(!IsAligned(OFFSET_LEFT) && fabs(m_nIdent)>_DIST_SNAP) { //左小坡 // XPoint ptTemp; // ads_polar(ptUpLeft, m_nRotation, m_nIdent, ptTemp); // stretchPoints.append(ptTemp); // } // if(!IsAligned(OFFSET_RIGHT) && fabs(m_nIdent)>_DIST_SNAP) { //左小坡 // XPoint ptTemp; // ads_polar(ptUpRight, m_nRotation+PI, m_nIdent, ptTemp); // stretchPoints.append(ptTemp); // } // 0 -- 改长度 stretchPoints.append(m_ptLocation); XPoint pt; Midpoint(GetLowLeft2d(),GetLowRight2d(),pt); // 1 -- 改长度 stretchPoints.append(pt); Midpoint(GetLowLeft2d(),GetUpLeft2d(),pt); // 2 -- 改宽度 stretchPoints.append(pt); Midpoint(GetLowRight2d(),GetUpRight2d(),pt); // 3 -- 改宽度 stretchPoints.append(pt); return Acad::eOk; } // Active when being rotated, scaled, moved, etc. Acad::ErrorStatus TDbAscent::subTransformBy(const AcGeMatrix3d& xform) { assertWriteEnabled(); TDbEntity::subTransformBy(xform); XPoint ptX, ptY; ads_polar(m_ptLocation, m_nRotation, GetWidth(), ptX); ads_polar(m_ptLocation, m_nRotation+PI/2.0, 1000.0, ptY); ((AcGePoint3d &)ptX).transformBy(xform); ((AcGePoint3d &)ptY).transformBy(xform); ((AcGePoint3d &)m_ptLocation).transformBy(xform); double nAng = CT_std_angle(ads_angle(m_ptLocation, ptY)- ads_angle(m_ptLocation, ptX)); if(fabs(nAng-PI*1.5)<_angSnap) { int bLeft=IsAligned(OFFSET_LEFT), bRight=IsAligned(OFFSET_RIGHT); TchPrivate::Exchange(bLeft, bRight); SetAlignment(OFFSET_LEFT, bLeft); SetAlignment(OFFSET_RIGHT, bRight); } m_nRotation = ads_angle(m_ptLocation, ptY)-PI/2; return Acad::eOk; } // 功能: 夹点操作 Acad::ErrorStatus TDbAscent::subMoveGripPointsAt( const AcDbIntArray& indices, const AcGeVector3d& offset) { assertWriteEnabled(); XVector3D vtOffset=*(XPoint *)&offset; vtOffset.z=0; double nVtRot=CT_std_angle(ads_angle(XPoint(), vtOffset)-m_nRotation); double nLen=ads_distance(XPoint(), vtOffset); double nIncWidth=nLen * cos(nVtRot); double nIncLen=nLen * sin(nVtRot); int idx=0; int num=indices.length(); BOOL bChLen=FALSE; for (int i = 0; i < num; i++) { idx = indices[i]; switch(idx) { case 0: // Move Location m_ptLocation += vtOffset; break; case 1: case 2: { if(nIncLen-m_nWidth) { m_nWidth += nIncWidth; ads_polar(XPoint(m_ptLocation), m_nRotation, nIncWidth/2.0, m_ptLocation); } } else { if(nIncWidth_DIST_SNAP && idx==3) { double nNewIdent=m_nIdent+nIncWidth; if(m_nWidth>nNewIdent*2) m_nIdent = nNewIdent; } else { double nNewIdent=m_nIdent-nIncWidth; if(m_nWidth>nNewIdent*2) m_nIdent = nNewIdent; } break; default: break; } } return Acad::eOk; } // 取得夹点说明 Acad::ErrorStatus TDbAscent::GetGripText(int i, CString &cs) const { Acad::ErrorStatus es=Acad::eOk; switch(i) { case 0: cs = _T("移动斜坡"); break; case 1: case 2: cs = _T("改长宽"); break; case 3: case 4: cs = _T("改边坡"); break; } return es; } // 功能: 夹点操作 // 状态: 有待完成修改相关墙体门窗的操作 Acad::ErrorStatus TDbAscent::subMoveStretchPointsAt( const AcDbIntArray& indices, const AcGeVector3d& offset) { //modify by xlc on 090209修改stretch效果,改变长宽 //add by whl on 060213 // int pos; // if(indices.find(0,pos)) // { // AcDbIntArray indices1; // indices1.append(0); // return moveGripPointsAt(indices1,offset); // } assertWriteEnabled(); XVector3D vtOffset=*(XPoint *)&offset; vtOffset.z=0; double nVtRot=CT_std_angle(ads_angle(XPoint(), vtOffset)-m_nRotation); double nLen=ads_distance(XPoint(), vtOffset); double nIncWidth=nLen * cos(nVtRot); double nIncLen=nLen * sin(nVtRot); int idx=0; int num=indices.length(); if(num!=1) { m_ptLocation += vtOffset; } else { int idx=indices[0]; switch(idx) { case 0: if(nIncLen+m_nLength>_DIST_SNAP) { m_nLength += nIncLen; ads_polar(XPoint(m_ptLocation), m_nRotation+PI*0.5, nIncLen, m_ptLocation); } break; case 1: if(m_nLength-nIncLen>_DIST_SNAP) { m_nLength -= nIncLen; } break; case 2: if(m_nWidth-nIncWidth>_DIST_SNAP) { m_nWidth -= nIncWidth; ads_polar(XPoint(m_ptLocation), m_nRotation, nIncWidth*0.5, m_ptLocation); } break; case 3: if(m_nWidth+nIncWidth>_DIST_SNAP) { m_nWidth += nIncWidth; ads_polar(XPoint(m_ptLocation), m_nRotation, nIncWidth*0.5, m_ptLocation); } break; default: m_ptLocation += vtOffset; } } return Acad::eOk; //return moveGripPointsAt(indices, offset); } Acad::ErrorStatus TDbAscent::GetExtents2d(XPoint &ptLow, XPoint &ptUp) const { assertReadEnabled(); XPoly2D poly(1); poly.AppendNode(GetLowLeft2d()); poly.AppendNode(GetLowRight2d()); poly.AppendNode(GetUpRight2d()); poly.AppendNode(GetUpLeft2d()); poly.GetExtend(ptLow, ptUp); ptLow.z=ptUp.z=0; return Acad::eOk; } Acad::ErrorStatus TDbAscent::GetExtents(XPoint &ptLow, XPoint &ptUp) const { Acad::ErrorStatus es=GetExtents2d(ptLow, ptUp); if(es==Acad::eOk) { ptLow.z = GetElevation(); ptUp.z = ptLow.z + GetHeight(); } return es; } Acad::ErrorStatus TDbAscent::ExplodeOrDraw3d(XExplodeDraw &dc) const { //TPushProperty vProp(this, dc); assertReadEnabled(); XPoint ptLowLeft=GetLowLeft2d(); XPoint ptLowRight=GetLowRight2d(); XPoint ptUpRight=GetUpRight2d(); XPoint ptUpLeft=GetUpLeft2d(); XPoint ptUpLeft1=ptUpLeft, ptUpRight1=ptUpRight; XPoint lPts[3], rPts[3]; if(!IsAligned(OFFSET_LEFT) && fabs(m_nIdent)>_DIST_SNAP) { //绘制左小坡 XPoint ptTemp; ads_polar(ptUpLeft, m_nRotation, m_nIdent, ptTemp); ptUpLeft1=ptTemp; lPts[0]=ptLowLeft; lPts[0].z=m_ptLocation.z-m_nHeight; if(m_nIdent>0) { lPts[1]=ptTemp; lPts[1].z=m_ptLocation.z; lPts[2]=ptUpLeft; lPts[2].z=m_ptLocation.z-m_nHeight; } else { lPts[1]=ptUpLeft; lPts[1].z=m_ptLocation.z; lPts[2]=ptTemp; lPts[2].z=m_ptLocation.z-m_nHeight; } } else { // 直面 lPts[0]=ptLowLeft; lPts[0].z=m_ptLocation.z-m_nHeight; lPts[1]=ptUpLeft; lPts[1].z=m_ptLocation.z; lPts[2]=ptUpLeft; lPts[2].z=m_ptLocation.z-m_nHeight; } if(!IsAligned(OFFSET_RIGHT) && fabs(m_nIdent)>_DIST_SNAP) { //绘制右小坡 XPoint ptTemp; ads_polar(ptUpRight, m_nRotation+PI, m_nIdent, ptTemp); ptUpRight1=ptTemp; rPts[0]=ptLowRight; rPts[0].z=m_ptLocation.z-m_nHeight; if(m_nIdent>0) { rPts[1]=ptTemp; rPts[1].z=m_ptLocation.z; rPts[2]=ptUpRight; rPts[2].z=m_ptLocation.z-m_nHeight; } else { rPts[1]=ptUpRight; rPts[1].z=m_ptLocation.z; rPts[2]=ptTemp; rPts[2].z=m_ptLocation.z-m_nHeight; } } else { // 直面 rPts[0]=ptLowRight; rPts[0].z=m_ptLocation.z-m_nHeight; rPts[1]=ptUpRight; rPts[1].z=m_ptLocation.z; rPts[2]=ptUpRight; rPts[2].z=m_ptLocation.z-m_nHeight; } XPoly2D lPoly(1), rPoly(1); for(int m=0; m<3; m++) { lPoly.AppendNode(lPts[m]); rPoly.AppendNode(rPts[m]); } dc.DrawColumn(lPoly, rPoly); // 绘制斜面 XLine lnLeft(ptUpLeft, ptLowLeft), lnRight(ptUpRight, ptLowRight); if(m_nIdent>_DIST_SNAP) { if(!IsAligned(OFFSET_LEFT)) ads_polar(ptUpLeft, m_nRotation, m_nIdent, lnLeft.StartPoint()); if(!IsAligned(OFFSET_RIGHT)) ads_polar(ptUpRight, m_nRotation+PI, m_nIdent, lnRight.StartPoint()); } if(HasSlant()) { //有防滑条 int nLineNum=AS_INT(GetLength()/_AS_SYS_UNIT(100.0)); double nInc=GetLength()/nLineNum; double nIncH=GetHeight()/nLineNum; XLine lnUp(ptUpLeft, ptUpRight); XLine *pArray=new XLine[nLineNum]; for(int i=0; iGetMe()->isKindOf(TDbColumn::desc())) return true; return false; } Acad::ErrorStatus TDbAscent::ExplodeOrDraw2d(XExplodeDraw &dc) const { //TPushProperty vProp(this, dc); XCurveStream dcSrc; XPoint ptLowLeft=GetLowLeft2d(); XPoint ptLowRight=GetLowRight2d(); XPoint ptUpRight=GetUpRight2d(); XPoint ptUpLeft=GetUpLeft2d(); XLine lnLeft(ptUpLeft, ptLowLeft), lnRight(ptUpRight, ptLowRight); if(m_nIdent>_DIST_SNAP) { if(!IsAligned(OFFSET_LEFT)) ads_polar(ptUpLeft, m_nRotation, m_nIdent, lnLeft.StartPoint()); if(!IsAligned(OFFSET_RIGHT)) ads_polar(ptUpRight, m_nRotation+PI, m_nIdent, lnRight.StartPoint()); } dcSrc << XLine(ptLowLeft, ptLowRight) << XLine(ptLowLeft, ptUpLeft) << XLine(ptLowRight, ptUpRight) << XLine(ptUpLeft, ptUpRight); if(!IsAligned(OFFSET_LEFT) && fabs(m_nIdent)>_DIST_SNAP) { if(m_nIdent>0) { dcSrc << lnLeft; } else { XPoint ptTemp; ads_polar(ptUpLeft, m_nRotation+PI, fabs(m_nIdent), ptTemp); dcSrc << XLine(ptTemp, ptUpLeft) << XLine(ptTemp, ptLowLeft); } } if(!IsAligned(OFFSET_RIGHT) && fabs(m_nIdent)>_DIST_SNAP) { if(m_nIdent>0) { dcSrc << lnRight; } else { XPoint ptTemp; ads_polar(ptUpRight, m_nRotation, fabs(m_nIdent), ptTemp); dcSrc << XLine(ptTemp, ptUpRight) << XLine(ptTemp, ptLowRight); } } if(HasSlant()) { //有防滑条 int nLineNum=AS_INT(GetLength()/100.0); double nInc=GetLength()/nLineNum; XLine lnUp(ptUpLeft, ptUpRight); for(int i=1; iClipCurveByTrace(dcSrc.m_lstCurves); } else { XPoly2D polyOutline(1); polyOutline.AppendNode(GetLowLeft2d()); polyOutline.AppendNode(GetLowRight2d()); polyOutline.AppendNode(GetUpRight2d()); polyOutline.AppendNode(GetUpLeft2d()); AcDbObjectId idOwner=ownerId(); AcDbObjectIdArray railArray; if(!!polyOutline && !!idOwner && TDbHandRail::GetRailsByCP(polyOutline, idOwner, railArray)) { int nCount=railArray.length(); for(int cnt=0; cntClipCurveByTrace(dcSrc.m_lstCurves); OPENOBJ_END(); } } } dcSrc.CopyTo(dc); return Acad::eOk; } const TCHAR *TDbAscent::GetDefaultLayer() const { return LAY_STAIR; } /* * * * * * * * * * 取 动 态 属 性 显 示 数 据 的 函 数 * * * * * * * * * */ void TDbAscent::GetTips(DList &lstInfo) const { lstInfo.Append(new TObjInfoUnit(_T("对象类型"), _T("坡道"))); lstInfo.Append(new TObjInfoUnit(_T("长度"), Dist2Str(GetLength()))); lstInfo.Append(new TObjInfoUnit(_T("宽度"), Dist2Str(GetWidth()))); lstInfo.Append(new TObjInfoUnit(_T("高度"), Dist2Str(GetHeight()))); lstInfo.Append(new TObjInfoUnit(_T("缩进"), Dist2Str(GetIdent()))); lstInfo.Append(new TObjInfoUnit(_T("防滑条"), m_nFlag? _T("有") : _T("无"))); lstInfo.Append(new TObjInfoUnit(_T("坡顶标高"), Dist2Str(GetElevation()))); } void TDbAscent::SetTempRail(TDbHandRail *pRail) { m_pTempRail=pRail; } XPoint TDbAscent::GetUpLeft2d() const { assertReadEnabled(); XPoint ptUpLeft; ads_polar(m_ptLocation, m_nRotation+PI, m_nWidth/2.0, ptUpLeft); ptUpLeft.z=0; return ptUpLeft; } XPoint TDbAscent::GetLowLeft2d() const { assertReadEnabled(); XPoint ptUpLeft=GetUpLeft2d(); XPoint ptLowLeft; ads_polar(ptUpLeft, m_nRotation-PI/2, m_nLength, ptLowLeft); return ptLowLeft; } XPoint TDbAscent::GetUpRight2d() const { assertReadEnabled(); XPoint ptUpRight; ads_polar(m_ptLocation, m_nRotation, m_nWidth/2.0, ptUpRight); ptUpRight.z=0; return ptUpRight; } XPoint TDbAscent::GetLowRight2d() const { assertReadEnabled(); XPoint ptUpRight=GetUpRight2d(); XPoint ptLowRight; ads_polar(ptUpRight, m_nRotation-PI/2, m_nLength, ptLowRight); return ptLowRight; } double TDbAscent::GetElevation() const { assertReadEnabled(); return m_ptLocation.z; } double TDbAscent::GetHeight() const { assertReadEnabled(); return m_nHeight; } double TDbAscent::GetWidth() const { assertReadEnabled(); return m_nWidth; } double TDbAscent::GetIdent() const { assertReadEnabled(); return m_nIdent; } XPoint TDbAscent::GetLocation() const { assertReadEnabled(); return m_ptLocation; } double TDbAscent::GetLength() const { assertReadEnabled(); return m_nLength; } double TDbAscent::GetRotation() const { assertReadEnabled(); return m_nRotation; } BOOL TDbAscent::HasSlant() const { assertReadEnabled(); return ((m_nFlag&AF_SLANT)!=0); } BOOL TDbAscent::IsAligned(int nSide) const { assertReadEnabled(); int nTestBit=(nSide==OFFSET_LEFT? AF_LEFT : AF_RIGHT); return ((m_nFlag&nTestBit)!=0); } void TDbAscent::SetElevation(double elev) { assertWriteEnabled(); m_ptLocation.z = elev; } void TDbAscent::SetLength(double l) { assertWriteEnabled(); m_nLength=l; } void TDbAscent::SetHeight(double h) { assertWriteEnabled(); m_nHeight=h; } void TDbAscent::SetWidth(double w) { assertWriteEnabled(); m_nWidth=w; } void TDbAscent::SetIdent(double i) { assertWriteEnabled(); m_nIdent=i; } void TDbAscent::SetLocation(XPoint ptLoc) { assertWriteEnabled(); m_ptLocation=ptLoc; } void TDbAscent::SetRotation(double rot) { assertWriteEnabled(); m_nRotation=rot; } void TDbAscent::SetSlant(BOOL bTrue) { assertWriteEnabled(); if(bTrue) m_nFlag |= AF_SLANT; else m_nFlag &= ~AF_SLANT; } void TDbAscent::SetAlignment(int nSide, BOOL bTrue) { assertWriteEnabled(); int nTestBit=(nSide==OFFSET_LEFT? AF_LEFT : AF_RIGHT); if(bTrue) m_nFlag |= nTestBit; else m_nFlag &= ~nTestBit; } void InitDbAscent(BOOL bTrue) { if(bTrue) { TDbAscent::rxInit(); acrxBuildClassHierarchy(); TDbAscent::InitMatchProtocol(TRUE); TDbAscent::SetEditMethod(EditAscent0); } else { TDbAscent::InitMatchProtocol(FALSE); deleteAcRxClass(TDbAscent::desc()); } } // Command:编辑斜坡 int EditAscent0(AcDbObjectId id) { OPENOBJ_BEGIN(id, AcDb::kForRead, TDbAscent, pStep); if(!pStep) return RTERROR; while(1) { const TCHAR *szPrompt1=_T("\n选择 [长度(E)/宽度(W)/高度(H)/缩进(D)/防滑(F)/标高(T)/左齐(L)/右齐(R)]<退出>:"); XString sKeyword; int nRet=0; INITGET_BEG(0, _T("E W H D F T L R")); nRet=ads_getkword(szPrompt1, sKeyword); INITGET_END(); if(nRet!=RTNORM) break; if(sKeyword[0]==_T('H')) { double nRailHeight=pStep->GetHeight(); nRet=GetReal(_T("\n高度"), nRailHeight, RSG_NONEG|RSG_NOZERO); if(nRet==RTCAN) break; if(nRet==RTNORM) { if(pStep->upgradeOpen()!=Acad::eOk) return RTERROR; pStep->SetHeight(nRailHeight); pStep->downgradeOpen(); } } else if(sKeyword[0]==_T('T')) { double nElev=pStep->GetElevation(); nRet=GetReal(_T("\n标高"), nElev); if(nRet==RTCAN) break; if(nRet==RTNORM) { if(pStep->upgradeOpen()!=Acad::eOk) return RTERROR; pStep->SetElevation(nElev); pStep->downgradeOpen(); } } else if(sKeyword[0]==_T('L')) { if(pStep->upgradeOpen()!=Acad::eOk) return RTERROR; pStep->SetAlignment(OFFSET_LEFT, !pStep->IsAligned(OFFSET_LEFT)); pStep->downgradeOpen(); } else if(sKeyword[0]==_T('R')) { if(pStep->upgradeOpen()!=Acad::eOk) return RTERROR; pStep->SetAlignment(OFFSET_RIGHT, !pStep->IsAligned(OFFSET_RIGHT)); pStep->downgradeOpen(); } else if(sKeyword[0]==_T('W')) { double nRailHeight=pStep->GetWidth(); nRet=GetReal(_T("\n宽度"), nRailHeight, RSG_NONEG|RSG_NOZERO); if(nRet==RTCAN) break; if(nRet==RTNORM) { if(pStep->upgradeOpen()!=Acad::eOk) return RTERROR; pStep->SetWidth(nRailHeight); pStep->downgradeOpen(); } } else if(sKeyword[0]==_T('D')) { double nRailHeight=pStep->GetIdent(); nRet=GetReal(_T("\n缩进"), nRailHeight, RSG_NOZERO); if(nRet==RTCAN) break; if(nRet==RTNORM) { if(pStep->upgradeOpen()!=Acad::eOk) return RTERROR; pStep->SetIdent(nRailHeight); pStep->downgradeOpen(); } } else if(sKeyword[0]==_T('E')) { double nRailHeight=pStep->GetLength(); nRet=GetReal(_T("\n长度"), nRailHeight, RSG_NONEG|RSG_NOZERO); if(nRet==RTCAN) break; if(nRet==RTNORM) { if(pStep->upgradeOpen()!=Acad::eOk) return RTERROR; pStep->SetLength(nRailHeight); pStep->downgradeOpen(); } } else if(sKeyword[0]==_T('F')) { if(pStep->upgradeOpen()!=Acad::eOk) return RTERROR; pStep->SetSlant(!pStep->HasSlant()); pStep->downgradeOpen(); } } OPENOBJ_END(); return RTNORM; }