//-----------------------------------------------------------------------------+ // Copyright (C), 1998-2007, SH Software Co. Ltd. // = FileName : XExplodeDraw 类 // = Version : ver2.0 // = Author : zjq // = CreateDate : 2002-09-09 // = Description: XExplodeDraw 定义 // = Maintainers: // //-----------------------------------------------------------------------------+ #include "StdAfx.h" #include "XExplodeStreamBase.h" #include "acgiutil.h" #include "XGlobalFunc.h" #include "XGlobalCurveFunc.h" XExplodeDraw::XExplodeDraw() : m_vtNormal(0,0,1), m_align(kBottomLeft), m_nHeight(0.0), m_nRotation(0.0), m_nWidthFactor(1.0) , m_bInitStyle(FALSE) { m_nControlFlag = 0; m_align = kMiddleCenter; } XExplodeDraw::~XExplodeDraw() { } void XExplodeDraw::SetPropertiesFrom(const AcDbEntity *pEnt) { } BOOL XExplodeDraw::IsFullExplode() const { return FALSE; } BOOL XExplodeDraw::IsExportTch4() const { return FALSE; } void XExplodeDraw::SetLocation(const XPoint &ptLoc) { m_ptLocation = ptLoc; } void XExplodeDraw::SetRotation(double nRot) { m_nRotation = nRot; } //设置图层和颜色(取图层) void XExplodeDraw::SetColorLayer(Adesk::UInt16 iObjColor, const AcDbObjectId &id) { if (id.isValid()) { SetLayer(id); SetColor(iObjColor); } } void XExplodeDraw::BackUpProperties(XMasterProperties &prop) { prop.m_nColor = GetColor(); prop.m_idLayer = GetLayerId(); prop.m_idLineType = GetLineTypeId(); prop.m_idMaterial = GetMaterialId(); } void XExplodeDraw::RestoreProperties(XMasterProperties prop) { SetLayer(prop.m_idLayer); SetLineType(prop.m_idLineType); SetColor(prop.m_nColor); SetMaterial(prop.m_idMaterial); } XExplodeDraw::TextAlignment XExplodeDraw::GetTextAlignment(AcDb::TextHorzMode nHMode, AcDb::TextVertMode nVMode) { XExplodeDraw::TextAlignment nAlign; // 上 if (nHMode == AcDb::kTextLeft && nVMode == AcDb::kTextTop) { nAlign = XExplodeDraw::kTopLeft; } else if (nHMode == AcDb::kTextCenter && nVMode == AcDb::kTextTop) { nAlign = XExplodeDraw::kTopCenter; } else if (nHMode == AcDb::kTextRight && nVMode == AcDb::kTextTop) { nAlign = XExplodeDraw::kTopRight; } // 中 else if (nHMode == AcDb::kTextLeft && nVMode == AcDb::kTextVertMid) { nAlign = XExplodeDraw::kMiddleLeft; } else if (nHMode == AcDb::kTextCenter && nVMode == AcDb::kTextVertMid) { nAlign = XExplodeDraw::kMiddleCenter; } else if (nHMode == AcDb::kTextRight && nVMode == AcDb::kTextVertMid) { nAlign = XExplodeDraw::kMiddleRight; } // 下 else if (nHMode == AcDb::kTextLeft && nVMode == AcDb::kTextBottom) { nAlign = XExplodeDraw::kBottomLeft; } else if (nHMode == AcDb::kTextCenter && nVMode == AcDb::kTextBottom) { nAlign = XExplodeDraw::kBottomCenter; } else if (nHMode == AcDb::kTextRight && nVMode == AcDb::kTextBottom) { nAlign = XExplodeDraw::kBottomRight; } // 基线 else if (nHMode == AcDb::kTextLeft && nVMode == AcDb::kTextBase) { nAlign = XExplodeDraw::kLeft; } else if (nHMode == AcDb::kTextCenter && nVMode == AcDb::kTextBase) { nAlign = XExplodeDraw::kCenter; } else if (nHMode == AcDb::kTextRight && nVMode == AcDb::kTextBase) { nAlign = XExplodeDraw::kRight; } else if (nHMode == AcDb::kTextMid) { nAlign = XExplodeDraw::kMiddle; } else //kTextAlign, kTextFit { nAlign = XExplodeDraw::kUnknown; } return nAlign; } Adesk::UInt16 XExplodeDraw::GetTextAlignment(XExplodeDraw::TextAlignment align) { // 对齐方式需要进行换算 AcDb::TextHorzMode nHMode; AcDb::TextVertMode nVMode; switch(align) { case kTopLeft: nHMode = AcDb::kTextLeft; nVMode = AcDb::kTextTop; break; case kTopCenter: nHMode = AcDb::kTextCenter; nVMode = AcDb::kTextTop; break; case kTopRight: nHMode = AcDb::kTextRight; nVMode = AcDb::kTextTop; break; case kMiddleLeft: nHMode = AcDb::kTextLeft; nVMode = AcDb::kTextVertMid; break; case kMiddleCenter: nHMode = AcDb::kTextCenter; nVMode = AcDb::kTextVertMid; break; case kMiddleRight: nHMode = AcDb::kTextRight; nVMode = AcDb::kTextVertMid; break; case kBottomLeft: nHMode = AcDb::kTextLeft; nVMode = AcDb::kTextBottom; break; case kBottomCenter: nHMode = AcDb::kTextCenter; nVMode = AcDb::kTextBottom; break; case kBottomRight: nHMode = AcDb::kTextRight; nVMode = AcDb::kTextBottom; break; case kLeft: nHMode = AcDb::kTextLeft; nVMode = AcDb::kTextBase; break; case kCenter: nHMode = AcDb::kTextCenter; nVMode = AcDb::kTextBase; break; case kRight: nHMode = AcDb::kTextRight; nVMode = AcDb::kTextBase; case kMiddle: nHMode = AcDb::kTextMid; nVMode = (AcDb::TextVertMode)0; break; default: nHMode = (AcDb::TextHorzMode)0; nVMode = (AcDb::TextVertMode)0; break; } Adesk::UInt16 nRet = nVMode; nRet = (nRet << 8); nRet += nHMode; return nRet; } XPoint XExplodeDraw::Align2Base(XExplodeDraw::TextAlignment nAlign, XPoint ptAlign, XPoint ext) { XPoint ptBase = ptAlign; // 换算基点 switch(nAlign) { case XExplodeDraw::kTopLeft: ptBase.y -= ext.y; break; case XExplodeDraw::kTopCenter: ptBase.y -= ext.y; ptBase.x -= ext.x / 2.0; break; case XExplodeDraw::kTopRight: ptBase.y -= ext.y; ptBase.x -= ext.x; break; case XExplodeDraw::kMiddleLeft: ptBase.y -= ext.y / 2.0; break; case XExplodeDraw::kMiddleCenter: ptBase.y -= ext.y / 2.0; ptBase.x -= ext.x / 2.0; break; case XExplodeDraw::kMiddleRight: ptBase.y -= ext.y / 2.0; ptBase.x -= ext.x; break; case XExplodeDraw::kBottomLeft: ptBase.y += (ext.z - ext.y); break; case XExplodeDraw::kBottomCenter: ptBase.y += (ext.z - ext.y); ptBase.x -= ext.x / 2.0; break; case XExplodeDraw::kBottomRight: ptBase.y += (ext.z - ext.y); ptBase.x -= ext.x; break; case XExplodeDraw::kLeft: break; case XExplodeDraw::kCenter: ptBase.x -= ext.x / 2.0; break; case XExplodeDraw::kRight: ptBase.x -= ext.x; break; case XExplodeDraw::kMiddle: ptBase.x -= ext.x / 2; ptBase.y -= ext.z / 2.0; ptBase.y += (ext.z - ext.y); break; default: ASSERT(0); } return ptBase; } XPoint XExplodeDraw::Base2Align(XExplodeDraw::TextAlignment nAlign, XPoint ptBase, XPoint ext) { XPoint ptAlign = ptBase; // 换算基点 switch(nAlign) { case XExplodeDraw::kTopLeft: ptAlign.y += ext.y; break; case XExplodeDraw::kTopCenter: ptAlign.y += ext.y; ptAlign.x += ext.x / 2.0; break; case XExplodeDraw::kTopRight: ptAlign.y += ext.y; ptAlign.x += ext.x; break; case XExplodeDraw::kMiddleLeft: ptAlign.y += ext.y / 2.0; break; case XExplodeDraw::kMiddleCenter: ptAlign.y += ext.y / 2.0; ptAlign.x += ext.x / 2.0; break; case XExplodeDraw::kMiddleRight: ptAlign.y += ext.y / 2.0; ptAlign.x += ext.x; break; case XExplodeDraw::kBottomLeft: ptAlign.y -= (ext.z - ext.y); break; case XExplodeDraw::kBottomCenter: ptAlign.y -= (ext.z - ext.y); ptAlign.x += ext.x / 2.0; break; case XExplodeDraw::kBottomRight: ptAlign.y -= (ext.z - ext.y); ptAlign.x += ext.x; break; case XExplodeDraw::kLeft: break; case XExplodeDraw::kCenter: ptAlign.x += ext.x / 2.0; break; case XExplodeDraw::kRight: ptAlign.x += ext.x; break; case XExplodeDraw::kMiddle: ptAlign.x += ext.x / 2; ptAlign.y -= (ext.z - ext.y); ptAlign.y += ext.z / 2.0; break; default: ASSERT(0); break; } return ptAlign; } void XExplodeDraw::LoadAcGiStyle() { Acad::ErrorStatus es = fromAcDbTextStyle(m_textStyle, m_idTextStyle); if (es != Acad::eOk) { m_bInitStyle = FALSE; return; } else { m_bInitStyle = TRUE; } int nRetFlag = m_textStyle.loadStyleRec(); } void XExplodeDraw::SetStyle(const TCHAR * szStyle) { m_idTextStyle = GetTextStyleId(szStyle); LoadAcGiStyle(); } void XExplodeDraw::SetStyle(AcDbObjectId id) { m_idTextStyle = id; LoadAcGiStyle(); } void XExplodeDraw::Polyline(AcDbPolyline &pline) { XPoly2D poly; PolyConvert(pline, poly); *this< &lstCurves, double nThickness) { for (int i = 0; i < lstCurves.Length(); i++) { DrawCurve(lstCurves[i], nThickness); } } void XExplodeDraw::DrawShell(const XPoly2D &polyRegion) { DrawShell(polyRegion, DList()); } void XExplodeDraw::DrawColumn(const XPoly2D &polyRegion1, const XPoly2D &polyRegion2) { DrawMesh(polyRegion1, polyRegion2); DrawShell(polyRegion1); DrawShell(polyRegion2); } void XExplodeDraw::SetAlignment(TextAlignment align) { m_align = align; } void XExplodeDraw::SetHeight(double nHeight) { m_nHeight = nHeight; } void XExplodeDraw::SetWidthFactor(double nWidthFactor) { m_nControlFlag |= EDF_XSCALE; m_nWidthFactor = nWidthFactor; } // 仅炸开使用 void XExplodeDraw::SetAutoProp(BOOL bTrue) { if (bTrue) { m_nControlFlag &= ~EDF_NO_AUTOPROP; } else { m_nControlFlag |= EDF_NO_AUTOPROP; } } BOOL XExplodeDraw::IsAutoProp() const { BOOL bTrue = TRUE; if (m_nControlFlag & EDF_NO_AUTOPROP) { bTrue = FALSE; } return bTrue; } void XExplodeDraw::SetSelectionMarker(int nMark) { } BOOL XExplodeDraw::IsPlotGeneration() const { return FALSE; } void XExplodeDraw::DrawEntity(const AcDbEntity &ent) { } void XExplodeDraw::DrawBody(const XPoly2D &polyOut, const DList &lstHoles,const XVector3D &vtOffset) { } Adesk::UInt16 XExplodeDraw::GetColor() const { return 0; } void XExplodeDraw::SetColor(Adesk::UInt16 nColor) { } //add by zjq on 100629 TArch8.5 //COLORREF XExplodeDraw::GetTrueColor() const AcCmColor XExplodeDraw::GetTrueColor() const { AcCmColor cmColor; return cmColor; } //void XExplodeDraw::SetTrueColor(COLORREF crRef) void XExplodeDraw::SetTrueColor(AcCmColor crRef) { } //显示类起作用,分解类不起作用 void XExplodeDraw::SetColor1(Adesk::UInt16 nColor) { } AcDbObjectId XExplodeDraw::GetLayerId() const { return AcDbObjectId::kNull; } AcDbObjectId XExplodeDraw::GetLineTypeId() const { return AcDbObjectId::kNull; } AcDbObjectId XExplodeDraw::GetMaterialId() const { return AcDbObjectId::kNull; } Acad::ErrorStatus XExplodeDraw::SetLayer(const AcDbObjectId &id) { return Acad::eOk; } Acad::ErrorStatus XExplodeDraw::SetLayer(const TCHAR *pszLay) { return Acad::eOk; } Acad::ErrorStatus XExplodeDraw::SetLineType(const TCHAR *pltype) { return Acad::eOk; } Acad::ErrorStatus XExplodeDraw::SetLineType(AcDbObjectId idLinetype) { return Acad::eOk; } Acad::ErrorStatus XExplodeDraw::SetMaterial(AcDbObjectId idMaterial) { return Acad::eOk; } void XExplodeDraw::DrawXCurve(const XCurveSegment&curve,double nThick) { DrawCurve(curve,nThick); } void XExplodeDraw::DrawX3DFace(const X3DFace&face) { DrawFace(face); } void XExplodeDraw::DrawTextFit(const TCHAR *pszText, XPoint pt1, XPoint pt2, double nTextHeight) { } void XExplodeDraw::DrawAtomicEntSet(const AcDbVoidPtrArray &entSet, const AcGeMatrix3d &matTrans) { } Adesk::Boolean XExplodeDraw::IsDragging() const { return Adesk::kFalse; }