#include "stdafx.h" #include "anotate_export.h" #include "globalFunc.h" #include "AecDbText.h" #include "aecdbradiusdim.h" #include "aecdbDimension.h" #include "AecDbSymbMultiLeader.h" #include "AecDbSymbCoord.h" #include "AecDbDrawingName.h" #include "AecDbSymbNorthThumb.h" #include "AecDbSymbArrow.h" #include "AecDbSymbIndexPointer.h" #include "AecDbSymbDrawingIndex.h" #include "AecDbSymbSection.h" #include "AecDbSymbElevation.h" AcDbObjectId InitTextStyle(TTextStyle ts, AcDbDatabase *pDb = NULL); AcDbObjectId InitDimStyle(TDimStyle ds); AcDbEntity* TMakeDim::makeRadius( const AcGePoint3d &ptCnt , const AcGePoint3d &ptEnd ) { AecXDbRadiusDim *pDim = new AecXDbRadiusDim; pDim->SetLayoutRotation(GlobalFunc::Ucs2Wcs(0.0)); pDim->SetStyleId(InitDimStyle(DS_RADIUS)); pDim->SetDimCenter(ptCnt); pDim->SetDimEndPoint(ptEnd); double nDimDist = pDim->GetDimLen(FALSE); if (nDimDist > ptCnt.distanceTo(ptEnd)) pDim->SetDimLen(-nDimDist, FALSE); pDim->SetDiameter(FALSE); return pDim; } AcDbEntity* TMakeDim::makeDiameter( const AcGePoint3d &ptCnt , const AcGePoint3d &ptEnd ) { AecXDbRadiusDim *pDim = new AecXDbRadiusDim; pDim->SetLayoutRotation(GlobalFunc::Ucs2Wcs(0.0)); pDim->SetStyleId(InitDimStyle(DS_RADIUS)); pDim->SetDimCenter(ptCnt); pDim->SetDimEndPoint(ptEnd); AecXDbText text; pDim->GetDimText(text); // if is default, then it is empty XString sText = pDim->GetText(); text.SetText(sText); XPoint ptExt = text.GetExtents(); if (pDim->GetRadius() < ptExt.x) pDim->SetDimLen(-ptExt.x*1.5, FALSE); pDim->SetDiameter(TRUE); return pDim; } AcDbEntity* TMakeDim::makeAngle( const AcGePoint3d &ptCen , const AcGePoint3d &ptStart , const AcGePoint3d &ptEnd ) { AecDbDimension *pDim = new AecDbDimension; pDim->SetAngular(TRUE); pDim->SetDist2DimLine(2.0); pDim->SetLayoutRotation(GlobalFunc::Ucs2Wcs(0)); pDim->SetStyleId(InitDimStyle(DS_LINEAR)); XPoint ptLoc; ads_polar(asDblArray(ptStart) , ads_angle(asDblArray(ptCen), asDblArray(ptStart)), 2.0*GlobalFunc::DocGetPScale(), ptLoc); pDim->SetLocation(ptLoc); pDim->SetDimRadius(ptCen.distanceTo(ptStart)); pDim->SetRotation(CT_std_angle(ads_angle(asDblArray(ptCen), asDblArray(ptStart)) + PI / 2)); pDim->SetObjRadius(ptCen.distanceTo(ptStart) + 2.0*GlobalFunc::DocGetPScale()); XArc ar(asDblArray(ptCen), ptCen.distanceTo(ptStart) , ads_angle(asDblArray(ptCen), asDblArray(ptStart)) , ads_angle(asDblArray(ptCen), asDblArray(ptEnd))); if (pDim->IsValidSegment(ar.GetLength())) pDim->AppendSegment(ar.GetLength()); pDim->SetLayoutRotation(GlobalFunc::Ucs2Wcs(0.0)); return pDim; } AcDbEntity* TMakeDim::makeArc( const AcGeCircArc3d &arc , ETYPE type, double toDimLine ) { double xx = arc.radius(); double yy = arc.startAng(); double zz = arc.endAng(); AcGePoint3d ptC = arc.center(); // arDim 为要标注的对象 GeArc arDim(asDblArray(arc.center()), arc.radius(), arc.startAng(), arc.endAng()); // 创建出标注的arc对象 AecDbDimension *pDim = new AecDbDimension; GeCurveSegment segDim; segDim = arDim; pDim->SetStyleId(InitDimStyle(DS_LINEAR)); pDim->SetLocation(segDim.StartPoint()); pDim->SetRotation(segDim.IDirection(0)); pDim->SetAngular(TRUE); pDim->SetObjRadius(arDim.GetRadius()); XArc arDimLine = arDim; double dimRad(.0); switch (type) { case TMakeDim::eAngle: pDim->SetDimArcLen(FALSE); pDim->SetDimChord(FALSE); pDim->SetDist2DimLine(toDimLine); dimRad = arDim.GetRadius() - toDimLine * GlobalFunc::DocGetPScale(); break; case TMakeDim::eChord: pDim->SetDimArcLen(FALSE); pDim->SetDimChord(TRUE); pDim->SetDist2DimLine(0.0); dimRad = arDim.GetRadius(); break; case TMakeDim::eArc: pDim->SetDimArcLen(TRUE); pDim->SetDimChord(FALSE); pDim->SetDist2DimLine(toDimLine); dimRad = arDim.GetRadius() - toDimLine * GlobalFunc::DocGetPScale(); break; default: break; } pDim->SetDimRadius(dimRad); arDimLine.SetRadius(dimRad); pDim->AppendSegment(arDimLine.GetLength()); return pDim; } AcDbEntity* TMakeDim::makeMPoint( const std::vector &pts , double toDimLine ) { if (pts.size() < 2) return NULL; AecDbDimension *pDim = new AecDbDimension; pDim->SetDist2DimLine(toDimLine); pDim->SetLocation(pts[0]); pDim->SetAngular(FALSE); AcDbObjectId idDimStyle = InitDimStyle(DS_LINEAR); pDim->SetStyleId(idDimStyle); for (size_t i = 0; i < pts.size(); ++i) { if (i + 1 >= pts.size()) break; pDim->AppendSegment(pts[i].distanceTo(pts[i+1])); } pDim->SetLayoutRotation(GlobalFunc::Ucs2Wcs(0.0)); return pDim; } AcDbEntity* TMakeDim::make2Point( const AcGePoint3d &ptS , const AcGePoint3d &ptE , double toDimLine ) { std::vector pts(2); pts[0] = ptS; pts[1] = ptE; return makeMPoint(pts, toDimLine); } AcDbEntity* TMakeDim::make2Point( const AcGePoint3d &ptS , const AcGePoint3d &ptE , LPCTSTR pszDim , double toDimLine) { std::vector pts(2); pts[0] = ptS; pts[1] = ptE; AecDbDimension *pDim = (AecDbDimension*)makeMPoint(pts, toDimLine); pDim->SetTextContent(0, pszDim); return pDim; } AcDbEntity* TMakeDim::makeCoordDim( const AcGePoint3d &ptLoc , const AcGePoint3d &ptSec , ETYPE Unit , int precision , ETYPE arrow , ETYPE wcs , ETYPE xy , double NorthAng ) { AecXDbSymbCoord *pCoord = new AecXDbSymbCoord; XPoint pt = ptLoc; pt = GlobalFunc::Ucs2Wcs(pt); XPoint ptWCS = pt; ads_matrix mat; XPoint().GetRotationMatrix(-NorthAng + PI*.5, mat); if (wcs == eUCS) pt = GlobalFunc::Wcs2Ucs(pt); else pt.TransformBy(mat); double x, y; if (Unit == emmM) // mm-M { x = _AS_METER(ptLoc.y); y = _AS_METER(ptLoc.x); } else // M-M { x = ptLoc.y; y = ptLoc.x; } if (fabs(x) < 1E-6) x = 0; if (fabs(y) < 1E-6) y = 0; pCoord->SetLocation(ptWCS); pCoord->SetValue(XPoint(x, y)); pCoord->SetTextStyleId(InitTextStyle(TS_SYMBOL)); pCoord->SetAB(xy == eAB); AecXDbSymbMultiLeader::TArrowStyle eArrowType = AecXDbSymbMultiLeader::kNone; switch (arrow) { case eNoneArrow: eArrowType = AecXDbSymbMultiLeader::kNone; break; case eCircle: eArrowType = AecXDbSymbMultiLeader::kDote; break; case eArrow: eArrowType = AecXDbSymbMultiLeader::kArrow; break; case eCross: eArrowType = AecXDbSymbMultiLeader::kCrossing; break; default:eArrowType = AecXDbSymbMultiLeader::kNone; break; } pCoord->SetStyle(eArrowType); pCoord->SetLayoutRotation(GlobalFunc::Ucs2Wcs(0.0));//modified by whl pCoord->SetPrecNum(precision); XPoint ptResult(ptSec); XVector3D vt = ptResult - ptWCS; double nAngle = ads_angle(XPoint(), vt); nAngle = CT_std_angle(nAngle - GlobalFunc::Ucs2Wcs(0.0));//add by whl Adesk::UInt8 nQuadrant; if (nAngle >= 0.0 && nAngle < PI / 2) nQuadrant = 0; else if (nAngle >= PI / 2 && nAngle < PI) nQuadrant = 1; else if (nAngle >= PI && nAngle < PI*1.5) nQuadrant = 2; else nQuadrant = 3; XLine ln(ptWCS, nAngle); pCoord->SetQuadrant(nQuadrant);//设置象限 pCoord->SetTurnPoint(ptResult); return pCoord; } AcDbEntity* TMakeDim::makeSymbCut( const AcGePoint3d &ptS , const AcGePoint3d &ptE , double len ) { //TDbSymbCut *pCut = new TDbSymbCut; //AcGeVector3d vt = ptS - ptE; //vt.rotateBy(PI * .5, AcGeVector3d::kZAxis); //vt.normalize(); //vt *= len; //AcGePoint3d pt3 = ptE + vt; //AcGePoint3d pt4 = ptS + vt; //GePoly2D poly; //poly.AppendNode(ptS); //poly.AppendNode(ptE); //poly.AppendNode(pt3); //poly.AppendNode(pt4); //pCut->SetOutline(poly); //pCut->SetEdgeType(0, 1); ////pCut->SetClipType(TGGiClipBoundary::kClipOut); //return pCut; return NULL; } AcDbEntity* TMakeDim::makeDrawingNameSymb( const AcGePoint3d &pt , LPCTSTR pszName , LPCTSTR pszScale , double nameHeight , double scaleHeight , LPCTSTR pszNameStyle , LPCTSTR pszScaleStyle , bool bShowScale , ETYPE Gb ) { AcDbObjectId nameStyleID(AcDbObjectId::kNull), scaleStyleID(AcDbObjectId::kNull); if (!pszName || !pszNameStyle) return NULL; nameStyleID = GlobalFunc::GetTextStyleId(pszNameStyle); if (!nameStyleID) return NULL; if (bShowScale) { if (!pszScale || !pszScaleStyle) return NULL; scaleStyleID = GlobalFunc::GetTextStyleId(pszScaleStyle); if (!scaleStyleID) return NULL; } AecXDbDrawingName *pEnt = new AecXDbDrawingName; pEnt->SetNameText(pszName); pEnt->SetNameStyleId(nameStyleID); pEnt->SetNameHeight(nameHeight); if (bShowScale) { pEnt->SetScaleText(pszScale); pEnt->SetScaleStyleId(scaleStyleID); pEnt->SetScaleHeight(scaleHeight); } pEnt->SetShowScale(bShowScale); pEnt->SetDrawStyle(Gb == eGB ? 1 : 0); pEnt->SetMidLocation(pt); return pEnt; } AcDbEntity* TMakeDim::makeSymbLeader( const AcGePoint3d &pt1 , const AcGePoint3d &pt2 , double baseLen , LPCTSTR pszUp , LPCTSTR pszDown , LPCTSTR pszStyle , double height , ETYPE arrow , double arrowSize , ETYPE align ) { if (!pszStyle) return NULL; AcDbObjectId idStyle = GlobalFunc::GetTextStyleId(pszStyle); if (!idStyle) return NULL; AecXDbSymbMultiLeader *pEnt = new AecXDbSymbMultiLeader; pEnt->SetTextStyleId(idStyle); pEnt->SetTextHeight(height); pEnt->SetText1(!pszUp ? _T("") : pszUp); pEnt->SetText2(!pszDown ? _T("") : pszDown); pEnt->SetArrowSize(arrowSize); AecXDbSymbMultiLeader::TArrowStyle eArrowType = AecXDbSymbMultiLeader::kNone; switch (arrow) { case TMakeDim::eNoneArrow: eArrowType = AecXDbSymbMultiLeader::kNone; break; case TMakeDim::eCircle: eArrowType = AecXDbSymbMultiLeader::kDote; break; case TMakeDim::eArrow: eArrowType = AecXDbSymbMultiLeader::kArrow; break; case TMakeDim::eCross: eArrowType = AecXDbSymbMultiLeader::kCrossing; break; default:eArrowType = AecXDbSymbMultiLeader::kNone; break; } pEnt->SetArrow(eArrowType); AecXDbSymbMultiLeader::TSymbMLTextAlign nAlign = AecXDbSymbMultiLeader::kAtStart; switch (align) { case TMakeDim::eBeginAlign: nAlign = AecXDbSymbMultiLeader::kAtStart; break; case TMakeDim::eEndAlign: nAlign = AecXDbSymbMultiLeader::kAtEnd; break; case TMakeDim::eMidAlign: nAlign = AecXDbSymbMultiLeader::kAtMiddle; break; default: nAlign = AecXDbSymbMultiLeader::kAtStart; break; } pEnt->SetTextAlign(nAlign); XPointList lstVertexes; lstVertexes.Append(new XPoint(GlobalFunc::Ucs2Wcs(pt1))); pEnt->SetLeaderVertexes(lstVertexes); pEnt->SetLeaderPoint(pt2); pEnt->SetTextBaseLen(baseLen, FALSE); return pEnt; } AcDbEntity* TMakeDim::makeSymbNode( const AcGePoint3d &pt1 , const AcGePoint3d &pt2 , double baseLen // 文字基线长度 , LPCTSTR pszUp , LPCTSTR pszStyle , double height , ETYPE arrow , double arrowSize , ETYPE align) { return makeSymbLeader(pt1, pt2, baseLen, pszUp, _T(""), pszStyle, height, arrow, arrowSize, align); } AcDbEntity* TMakeDim::makeNorthThumb( const AcGePoint3d &pt , double ang ) { AecXDbSymbNorthThumb *pEnt = new AecXDbSymbNorthThumb; pEnt->SetCenter(pt); pEnt->SetRotation(ang); return pEnt; } AcDbEntity* TMakeDim::makeNorthThumb( const AcGePoint3d &pt , const AcGePoint3d &ptAng ) { AecXDbSymbNorthThumb *pEnt = new AecXDbSymbNorthThumb; pEnt->SetCenter(pt); pEnt->SetRotation(ads_angle(asDblArray(pt), asDblArray(ptAng))); return pEnt; } AcDbEntity* TMakeDim::makeSymbArrow( const AcGePoint3d &ptS , const AcGePoint3d &ptE , LPCTSTR pszUp , LPCTSTR pszDown , LPCTSTR pszStyle , double height , double arrowSize , ETYPE arrow , ETYPE align ) { if (!pszStyle) return NULL; AcDbObjectId idStyle = GlobalFunc::GetTextStyleId(pszStyle); if (!idStyle) return NULL; AecXDbSymbArrow *pEnt = new AecXDbSymbArrow; pEnt->SetTextStyleId(idStyle); pEnt->SetTextHeight(height); pEnt->SetText(!pszUp ? _T("") : pszUp); pEnt->SetText2(!pszDown ? _T("") : pszDown); pEnt->SetArrowSize(arrowSize); AecXDbSymbArrow::TArrowType arType = AecXDbSymbArrow::kArrow; switch (arrow) { case TMakeDim::eNoneArrow: arType = AecXDbSymbArrow::kNone; break; case TMakeDim::eCircle: arType = AecXDbSymbArrow::kDote; break; case TMakeDim::eArrow: arType = AecXDbSymbArrow::kArrow; break; case TMakeDim::eHalfArrow: arType = AecXDbSymbArrow::kHalfArrow; break; case TMakeDim::eCross: arType = AecXDbSymbArrow::kCrossing; break; } pEnt->SetArrowType(arType); AecXDbSymbArrow::TArTextAlign txAlign = AecXDbSymbArrow::kAlignMid; switch (align) { case TMakeDim::eSideLineAlign: txAlign = AecXDbSymbArrow::kAtSide; break; case TMakeDim::eMidLineAlign: txAlign = AecXDbSymbArrow::kAlignMid; break; case TMakeDim::eEndLineAlign: txAlign = AecXDbSymbArrow::kAlignEnd; break; } pEnt->SetTextAlign(txAlign); GePoly2D poly; poly.AppendNode(ptE); poly.AppendNode(ptS); pEnt->SetPoly2D(poly); pEnt->SetShowText2(TRUE); return pEnt; } AcDbEntity* TMakeDim::makeSymbIndex( const AcGePoint3d &pt1 , double dRadius , const AcGePoint3d &pt2 , double baseLen , LPCTSTR pszIdxUp , LPCTSTR pszIdxDown , LPCTSTR pszDimUp , LPCTSTR pszDimDown , LPCTSTR pszIdxStyle , LPCTSTR pszDimStyle , double height , ETYPE align ) { if (!pszIdxStyle || !pszDimStyle) return NULL; AcDbObjectId idIdxStyle = GlobalFunc::GetTextStyleId(pszIdxStyle); AcDbObjectId idDimStyle = GlobalFunc::GetTextStyleId(pszDimStyle); if (!idIdxStyle || !idDimStyle) return NULL; AecXDbSymbIndexPointer *pEnt = new AecXDbSymbIndexPointer; pEnt->SetTextStyleId(idIdxStyle); pEnt->SetDimTextStyle(idDimStyle); pEnt->SetTextHeight(height); pEnt->SetText1(!pszDimUp ? _T("") : pszDimUp); pEnt->SetText2(!pszDimDown ? _T("") : pszDimDown); pEnt->SetIndexLabel(!pszIdxUp ? _T("") : pszIdxUp); pEnt->SetDrawingLabel(!pszIdxDown ? _T("") : pszIdxDown); pEnt->SetIndexPointer(TRUE); AecXDbSymbIndexPointer::TSymbIPTextAlign nAlign = AecXDbSymbIndexPointer::kAtStart; switch (align) { case TMakeDim::eBeginAlign: nAlign = AecXDbSymbIndexPointer::kAtStart; break; case TMakeDim::eEndAlign: nAlign = AecXDbSymbIndexPointer::kAtEnd; break; case TMakeDim::eMidAlign: nAlign = AecXDbSymbIndexPointer::kAtMiddle; break; default: nAlign = AecXDbSymbIndexPointer::kAtStart; break; } pEnt->SetTextAlign(nAlign); pEnt->SetStartPoint(pt1); // 起点 pEnt->SetSourceExtent(dRadius*2.0); pEnt->SetTurnPoint(pt2); // 转折点 pEnt->SetTextBaseLen(baseLen, FALSE); // 文字基线长度 return pEnt; } AcDbEntity* TMakeDim::makeSymbIndexDim( const AcGePoint3d &pt , LPCTSTR pszUp , LPCTSTR pszDown , LPCTSTR pszScale , LPCTSTR pszStyleDim , LPCTSTR pszStyleScale , double height , double radius , double lw ) { if (!pszStyleScale || !pszStyleDim) return NULL; AcDbObjectId idStyleScale = GlobalFunc::GetTextStyleId(pszStyleScale); AcDbObjectId idStyleDim = GlobalFunc::GetTextStyleId(pszStyleDim); if (!idStyleDim || !idStyleScale) return NULL; AecXDbSymbDrawingIndex *pEnt = new AecXDbSymbDrawingIndex; pEnt->SetLayoutRotation(GlobalFunc::Ucs2Wcs(0.0)); pEnt->SetDrawingLabel(!pszDown ? _T("") : pszDown); //图号 pEnt->SetIndexLabel(!pszUp ? _T("") : pszUp); //编号 pEnt->SetTextStyleId(idStyleDim); pEnt->SetScaleStyleId(idStyleScale); pEnt->SetScaleTextHeight(height); pEnt->SetDrawScale(pszScale != NULL); pEnt->SetScaleText(!pszScale ? _T("") : pszScale); pEnt->SetCenter(pt); pEnt->SetRadius(radius); pEnt->SetLineWidth(lw); return pEnt; } AcDbEntity* TMakeDim::makeSymbSection( const AcGePoint3d &pt1 , const AcGePoint3d &pt2 , const AcGePoint3d &ptDir , LPCTSTR pszLable , LPCTSTR pszDrawing , ETYPE sectionType , LPCTSTR pszStyleLable , LPCTSTR pszStyleDrawing , double heightLable , double heightDrawing , ETYPE drawingPos , ETYPE drawingDir) { if (!pszStyleLable || !pszStyleDrawing) return NULL; AcDbObjectId idStyleLable = GlobalFunc::GetTextStyleId(pszStyleLable); AcDbObjectId idStyleDrawing = GlobalFunc::GetTextStyleId(pszStyleDrawing); if (!idStyleLable || !idStyleDrawing) return NULL; AecXDbSymbSection *pEnt = new AecXDbSymbSection; pEnt->SetLayoutRotation(GlobalFunc::Ucs2Wcs(0.0)); pEnt->SetText(!pszLable ? _T("") : pszLable); pEnt->SetTextHeight(heightLable); pEnt->SetTextStyleId(idStyleLable); pEnt->SetDrawingIndex(!pszDrawing ? _T("") : pszDrawing); pEnt->SetIndexHeight(heightDrawing); pEnt->SetIndexStyleId(idStyleDrawing); int sectionMode = 4; switch (sectionType) { case TMakeDim::eZJPQ: sectionMode = 1; break; case TMakeDim::eDMPQ: sectionMode = 4; break; default: sectionMode = 4; break; } if (sectionMode == 4) pEnt->SetViewLine(FALSE); int sectionLoc = 0; switch (drawingPos) { case TMakeDim::e2Pos: sectionLoc = 0; break; case TMakeDim::eEndPos: sectionLoc = 1; break; case TMakeDim::eStartPos: sectionLoc = 2; break; default: sectionLoc = 0; break; } if (sectionLoc == 0) //两端显示 { pEnt->SetIsHasIndexS(TRUE); pEnt->SetIsHasIndexE(TRUE); } else if (sectionLoc == 1)//始端显示 { pEnt->SetIsHasIndexS(TRUE); pEnt->SetIsHasIndexE(FALSE); } else if (sectionLoc == 2)//末端显示 { pEnt->SetIsHasIndexS(FALSE); pEnt->SetIsHasIndexE(TRUE); } int sectionDir = 0; switch (drawingDir) { case TMakeDim::ePQWZX: sectionDir = 0; break; case TMakeDim::ePSFXX: sectionDir = 1; break; default: sectionDir = 0; break; } pEnt->SetDimDirection(sectionDir); XLine line(asDblArray(pt1), asDblArray(pt2)); int side = line.OnWhichSide(ptDir); pEnt->setLastPoint(ptDir); if (side == OFFSET_LEFT) pEnt->SetViewDirection(CT_std_angle(ads_angle(asDblArray(pt1), asDblArray(pt2))) + PI * .5); else pEnt->SetViewDirection(CT_std_angle(ads_angle(asDblArray(pt1), asDblArray(pt2))) - PI * .5); GePoly2D poly; poly.AppendNode(pt1); poly.AppendNode(pt2); pEnt->SetPoly2D(poly); return pEnt; } AcDbEntity* TMakeDim::makeSymbElevation1( const AcGePoint3d &pt , LPCTSTR pszText , LPCTSTR pszStyle , double height , bool bHasBaseLine , double baseLen , bool bHasLeaderLine , double leaderLen , bool bPre2 ) { if (!pszStyle) return NULL; AcDbObjectId idStyle = GlobalFunc::GetTextStyleId(pszStyle); if (!idStyle) return NULL; AecXDbSymbElevation *pEnt = new AecXDbSymbElevation; AcDbObjectId InitLayer(const TCHAR *, BOOL); const TCHAR *pszLayer = pEnt->GetDefaultLayer(); if (pszLayer) { AcDbObjectId idLayer = InitLayer(pszLayer, TRUE); if (idLayer.isValid()) pEnt->setLayer(pszLayer); } pEnt->SetTextStyleId(idStyle); pEnt->SetLocation(pt); pEnt->SetText(!pszText ? _T("") : pszText); pEnt->SetTextHeight(height); pEnt->SetTextBaseLen(pEnt->GetDefaultTextBaseLen()); pEnt->SetPrec2(bPre2); pEnt->SetLeader(bHasLeaderLine); pEnt->SetBaseLine(bHasBaseLine); if (bHasBaseLine) pEnt->SetBaseLen(baseLen); if (bHasLeaderLine) pEnt->SetLeaderLen(baseLen); return pEnt; } double TMakeDim::getElevation(AcDbEntity *pEnt) { if (!pEnt) return false; if (!pEnt->isKindOf(AecXDbSymbElevation::desc())) return .0; AecXDbSymbElevation *pElev = (AecXDbSymbElevation*)pEnt; double dd(.0); pElev->GetElev1(dd); return dd; } bool TMakeDim::modifyElevation(AcDbEntity *pEnt, LPCTSTR sElev) { if (!pEnt) return false; if (!sElev) return false; if (!pEnt->isKindOf(AecXDbSymbElevation::desc())) return false; AecXDbSymbElevation *pElev = (AecXDbSymbElevation*)pEnt; pElev->SetText(sElev); return true; } AcDbEntity* TMakeDim::makeSymbElevation2( const AcGePoint3d &pt , LPCTSTR pszText , LPCTSTR pszStyle , double height , bool bPre2 ) { if (!pszStyle) return NULL; AcDbObjectId idStyle = GlobalFunc::GetTextStyleId(pszStyle); if (!idStyle) return NULL; AecXDbSymbElevation *pEnt = new AecXDbSymbElevation; AcDbObjectId InitLayer(const TCHAR *, BOOL); const TCHAR *pszLayer = pEnt->GetDefaultLayer(); if (pszLayer) { AcDbObjectId idLayer = InitLayer(pszLayer, TRUE); if (idLayer.isValid()) pEnt->setLayer(pszLayer); } pEnt->SetTextStyleId(idStyle); pEnt->SetLocation(pt); pEnt->SetText(!pszText ? _T("") : pszText); pEnt->SetTextHeight(height); pEnt->SetHollowTriangle(TRUE); pEnt->SetTextBaseLen(3.); pEnt->SetPrec2(bPre2); return pEnt; } extern "C" __declspec(dllexport) AcDbEntity* makeRadius( const AcGePoint3d &ptCnt /* 圆心 */ , const AcGePoint3d &ptEnd /* 圆上的标注点 */) { return TMakeDim::makeRadius(ptCnt, ptEnd); } extern "C" __declspec(dllexport) AcDbEntity* makeDiameter( const AcGePoint3d &ptCnt /* 圆心 */ , const AcGePoint3d &ptEnd /* 圆上的标注点 */) { return TMakeDim::makeDiameter(ptCnt, ptEnd); } extern "C" __declspec(dllexport) AcDbEntity* makeAngle( const AcGePoint3d &ptCnt /* 圆心 */ , const AcGePoint3d &ptStart /* 标注起始点 */ , const AcGePoint3d &ptEnd /* 标注终止点 */) { return TMakeDim::makeAngle(ptCnt, ptStart, ptEnd); } extern "C" __declspec(dllexport) AcDbEntity* makeArc( const AcGeCircArc3d &arc /* 要标注的对象(圆弧对象) */ , TMakeDim::ETYPE type /* 标注类型 */ , double toDimLine /* 定位点到尺寸线的距离, 可以为负值, 图纸单位 */) { return TMakeDim::makeArc(arc, type, toDimLine); } extern "C" __declspec(dllexport) AcDbEntity* makeMPoint( const std::vector &pts /* 点组,数量不小于2 */ , double toDimLine /* 定位点到尺寸线的距离, 可以为负值, 图纸单位 */) { return TMakeDim::makeMPoint(pts, toDimLine); } extern "C" __declspec(dllexport) AcDbEntity* make2Point( const AcGePoint3d &ptS /* 要标注的起点 */ , const AcGePoint3d &ptE /* 要标注的终点 */ , double toDimLine /* 定位点到尺寸线的距离, 可以为负值, 图纸单位 */) { return TMakeDim::make2Point(ptS, ptE, toDimLine); } extern "C" __declspec(dllexport) AcDbEntity* make2Point2( const AcGePoint3d &ptS /* 要标注的起点 */ , const AcGePoint3d &ptE /* 要标注的终点 */ , LPCTSTR pszDim , double toDimLine /* 定位点到尺寸线的距离, 可以为负值, 图纸单位 */) { return TMakeDim::make2Point(ptS, ptE, pszDim, toDimLine); } extern "C" __declspec(dllexport) AcDbEntity* makeCoordDim( const AcGePoint3d &ptLoc /* 要标注的点 */ , const AcGePoint3d &ptSec /* 转折点 */ , TMakeDim::ETYPE Unit /*= TMakeDim::emmM /* 绘图单位 */ , int precision /*= 3 /* 精度 */ , TMakeDim::ETYPE arrow /*= TMakeDim::eNoneArrow /* 箭头样式 */ , TMakeDim::ETYPE wcs /*= TMakeDim::eWCS /* 坐标取值 */ , TMakeDim::ETYPE xy /*= TMakeDim::eXY /* 坐标类型 */ , double NorthAng /*= 90. /* 北向角度 */) { return TMakeDim::makeCoordDim(ptLoc, ptSec, Unit, precision, arrow, wcs, xy, NorthAng); } extern "C" __declspec(dllexport) AcDbEntity* makeSymbCut( const AcGePoint3d &ptS /* 起点 */ , const AcGePoint3d &ptE /* 终点 */ , double len /* 向外延伸长度 */) { return TMakeDim::makeSymbCut(ptS, ptE, len); } extern "C" __declspec(dllexport) AcDbEntity* makeDrawingNameSymb( const AcGePoint3d &pt /* 标注点 */ , LPCTSTR pszName /* 标注文字 */ , LPCTSTR pszScale /* 比例文字 */ , double nameheight /*= 7. /* 标注文字字高 */ , double scaleheight /*= 5. /* 比例文字字高 */ , LPCTSTR pszNameStyle /*= _T("STANDARD") /* 标注文字样式 */ , LPCTSTR pszScaleStyle /*= _T("STANDARD") /* 比例文字样式 */ , bool bShowScale /*= true /* 是否显示比例 */ , TMakeDim::ETYPE Gb /*= TMakeDim::eOld /* 图名标注标准 */) { return TMakeDim::makeDrawingNameSymb(pt, pszName, pszScale, nameheight, scaleheight, pszNameStyle, pszScaleStyle, bShowScale, Gb); } extern "C" __declspec(dllexport) AcDbEntity* makeSymbLeader( const AcGePoint3d &pt1 /* 标注点 */ , const AcGePoint3d &pt2 /* 转折点 */ , double baseLen /* 文字基线长度 */ , LPCTSTR pszUp /* 上标文字 */ , LPCTSTR pszDown /* 下标文字 */ , LPCTSTR pszStyle /*= _T("STANDARD") /* 文字样式 */ , double height /*= 3.5 /* 字高 */ , TMakeDim::ETYPE arrow /*= TMakeDim::eNoneArrow /* 箭头样式 */ , double arrowSize /*= 3.0 /* 箭头大小 */ , TMakeDim::ETYPE align /*= TMakeDim::eMidAlign /* 文字相对基线对齐方式 */) { return TMakeDim::makeSymbLeader(pt1, pt2, baseLen, pszUp, pszDown, pszStyle, height, arrow, arrowSize, align); } extern "C" __declspec(dllexport) AcDbEntity* makeSymbNode( const AcGePoint3d &pt1 /* 标注点 */ , const AcGePoint3d &pt2 /* 转折点 */ , double baseLen /* 文字基线长度 */ , LPCTSTR pszUp /* 上标文字 */ , LPCTSTR pszStyle /*= _T("STANDARD") /* 文字样式 */ , double height /*= 3.5 /* 字高 */ , TMakeDim::ETYPE arrow /*= TMakeDim::eNoneArrow /* 箭头样式 */ , double arrowSize /*= 3.0 /* 箭头大小 */ , TMakeDim::ETYPE align /*= TMakeDim::eBeginAlign /* 文字相对基线对齐方式 */) { return TMakeDim::makeSymbNode(pt1, pt2, baseLen, pszUp, pszStyle, height, arrow, arrowSize, align); } extern "C" __declspec(dllexport) AcDbEntity* makeNorthThumb( const AcGePoint3d &pt /* 插入点 */ , const AcGePoint3d &ptAng /* 取另一个点, 用 pt 和 ptAng 来判断指向角度 */) { return TMakeDim::makeNorthThumb(pt, ptAng); } // extern "C" __declspec(dllexport) AcDbEntity* makeNorthThumb( // const AcGePoint3d &pt // 插入点 // , double ang // 指向角度 // ) // { // return TMakeDim::makeNorthThumb(pt, ang); // } extern "C" __declspec(dllexport) AcDbEntity* makeSymbArrow( const AcGePoint3d &ptS /* 起点 */ , const AcGePoint3d &ptE /* 终点 */ , LPCTSTR pszUp /* 上标文字 */ , LPCTSTR pszDown /* 下标文字 */ , LPCTSTR pszStyle /*= _T("STANDARD") /* 文字样式 */ , double height /*= 3.5 /* 字高 */ , double arrowSize /*= 3.0 /* 箭头大小 */ , TMakeDim::ETYPE arrow /*= TMakeDim::eArrow /* 箭头样式 */ , TMakeDim::ETYPE align /*= TMakeDim::eMidLineAlign /* 对齐方式 */) { return TMakeDim::makeSymbArrow(ptS, ptE, pszUp, pszDown, pszStyle, height, arrowSize, arrow, align); } extern "C" __declspec(dllexport) AcDbEntity* makeSymbIndex( const AcGePoint3d &pt1 /* 起始点 */ , double dRadius /* 范围半径 */ , const AcGePoint3d &pt2 /* 转折点 */ , double baseLen /* 文字基线长度 */ , LPCTSTR pszIdxUp /* 索引编号 */ , LPCTSTR pszIdxDown /* 索引图号 */ , LPCTSTR pszDimUp /* 上标文字 */ , LPCTSTR pszDimDown /* 下标文字 */ , LPCTSTR pszIdxStyle /*= _T("STANDARD") /* 索引文字样式 */ , LPCTSTR pszDimStyle /*= _T("STANDARD") /* 标注文字样式 */ , double height /*= 3.5 /* 标注文字字高 */ , TMakeDim::ETYPE align /*= TMakeDim::eEndAlign /* 标注对齐方式 */) { return TMakeDim::makeSymbIndex(pt1, dRadius, pt2, baseLen, pszIdxUp, pszIdxDown, pszDimUp, pszDimDown, pszIdxStyle, pszDimStyle, height, align); } extern "C" __declspec(dllexport) AcDbEntity* makeSymbIndexDim( const AcGePoint3d &pt /* 插入点 */ , LPCTSTR pszUp /* 上标文字 */ , LPCTSTR pszDown /*= NULL /* 下标文字 */ , LPCTSTR pszScale /*= NULL /* 比例文字 */ , LPCTSTR pszStyleDim /*= _T("STANDARD") /* 标注文字样式 */ , LPCTSTR pszStyleScale /*= _T("STANDARD") /* 比例文字样式 */ , double height /*= 3.5 /* 字高 */ , double radius /*= 7 /* 半径 */ , double lw /*= .5 /* 线宽 */) { return TMakeDim::makeSymbIndexDim(pt, pszUp, pszDown, pszScale, pszStyleDim, pszStyleScale, height, radius, lw); } extern "C" __declspec(dllexport) AcDbEntity* makeSymbSection( const AcGePoint3d &pt1 /* 起点 */ , const AcGePoint3d &pt2 /* 终点 */ , const AcGePoint3d &ptDir /*方向点*/ , LPCTSTR pszLable /* 编号文字 */ , LPCTSTR pszDrawing /*= NULL /* 图号文字 */ , TMakeDim::ETYPE sectionType /*= TMakeDim::eDMPQ /* 标注样式 */ , LPCTSTR pszStyleLable /*= _T("STANDARD") /* 标注文字样式 */ , LPCTSTR pszStyleDrawing /*= _T("STANDARD") /* 比例文字样式 */ , double heightLable /*= 5.0 /* 编号字高 */ , double heightDrawing /*= 3.5 /* 图号字高 */ , TMakeDim::ETYPE drawingPos /*= TMakeDim::e2Pos /* 图号位置类型 */ , TMakeDim::ETYPE drawingDir /*= TMakeDim::ePQWZX /* 图号方向 */) { return TMakeDim::makeSymbSection(pt1, pt2, ptDir, pszLable, pszDrawing, sectionType, pszStyleLable, pszStyleDrawing, heightLable, heightDrawing, drawingPos, drawingDir); } extern "C" __declspec(dllexport) AcDbEntity* makeSymbElevation1( const AcGePoint3d &pt /* 插入点 */ , LPCTSTR pszText /* 标注文字 */ , LPCTSTR pszStyle /*= _T("STANDARD") /* 标注文字样式 */ , double height /*= 3.5 /* 字高 */ , bool bHasBaseLine /*= false /* 带基线? */ , double baseLen /*= 0. /* 基线长度 */ , bool bHasLeaderLine /*= false /* 带引线? */ , double leaderLen /*= 0. /* 引线长度 */ , bool bPre2 /*= true /* 精度为2,否为3 */) { return TMakeDim::makeSymbElevation1(pt, pszText, pszStyle, height, bHasBaseLine, baseLen, bHasLeaderLine, leaderLen, bPre2); } extern "C" __declspec(dllexport) AcDbEntity* makeSymbElevation2( const AcGePoint3d &pt /* 插入点 */ , LPCTSTR pszText /* 标注文字 */ , LPCTSTR pszStyle /*= _T("STANDARD") /* 标注文字样式 */ , double height /*= 3.5 /* 字高 */ , bool bPre2 /*= true /* 精度为2,否为3 */) { return TMakeDim::makeSymbElevation2(pt, pszText, pszStyle, height, bPre2); } extern "C" __declspec(dllexport) double getElevation(AcDbEntity *pEnt) { return TMakeDim::getElevation(pEnt); } extern "C" __declspec(dllexport) bool modifyElevation(AcDbEntity * pEnt, LPCTSTR sElev) { return TMakeDim::modifyElevation(pEnt, sElev); } extern "C" __declspec(dllexport) bool setObjId2DataMap(AcDbEntity* pEnt, LPCTSTR pszKey, const AcDbObjectId& idValue) { return TMakeDim::setData2DataMap(pEnt, pszKey, idValue); } extern "C" __declspec(dllexport) bool getObjIdByDataMap(AcDbEntity* pEnt, LPCTSTR pszKey, AcDbObjectId& idValue) { return TMakeDim::getDataByDataMap(pEnt, pszKey, idValue); } extern "C" __declspec(dllexport) bool setInteger2DataMap(AcDbEntity* pEnt, LPCTSTR pszKey, const int& idValue) { return TMakeDim::setData2DataMap(pEnt, pszKey, idValue); } extern "C" __declspec(dllexport) bool getIntegerByDataMap(AcDbEntity* pEnt, LPCTSTR pszKey, int& idValue) { return TMakeDim::getDataByDataMap(pEnt, pszKey, idValue); } extern "C" __declspec(dllexport) bool setPt3d2DataMap(AcDbEntity * pEnt, LPCTSTR pszKey, const AcGePoint3d &idValue) { return TMakeDim::setData2DataMap(pEnt, pszKey, idValue); } extern "C" __declspec(dllexport) bool getPt3dByDataMap(AcDbEntity * pEnt, LPCTSTR pszKey, AcGePoint3d &idValue) { return TMakeDim::getDataByDataMap(pEnt, pszKey, idValue); } extern "C" __declspec(dllexport) bool setStr2DataMap(AcDbEntity * pEnt, LPCTSTR pszKey, const CString &idValue) { return TMakeDim::setData2DataMap(pEnt, pszKey, idValue); } extern "C" __declspec(dllexport) bool getStrByDataMap(AcDbEntity * pEnt, LPCTSTR pszKey, CString &idValue) { return TMakeDim::getDataByDataMap(pEnt, pszKey, idValue); } extern "C" __declspec(dllexport) bool setDouble2DataMap(AcDbEntity * pEnt, LPCTSTR pszKey, const double &idValue) { return TMakeDim::setData2DataMap(pEnt, pszKey, idValue); } extern "C" __declspec(dllexport) bool getDoubleByDataMap(AcDbEntity * pEnt, LPCTSTR pszKey, double &idValue) { return TMakeDim::getDataByDataMap(pEnt, pszKey, idValue); } extern "C" __declspec(dllexport) bool setVec3d2DataMap(AcDbEntity * pEnt, LPCTSTR pszKey, const AcGeVector3d &idValue) { return TMakeDim::setData2DataMap(pEnt, pszKey, idValue); } extern "C" __declspec(dllexport) bool getVec3dByDataMap(AcDbEntity * pEnt, LPCTSTR pszKey, AcGeVector3d &idValue) { return TMakeDim::getDataByDataMap(pEnt, pszKey, idValue); } extern "C" { __declspec(dllexport) double getPScaleForSymb() { return g_DimOption::instance().g_nDefaultScale; } __declspec(dllexport) bool IsMeterUnitForPipeElevDim() { return g_DimOption::instance().g_bMeterUnitPipeElevDim == FALSE ? false : true; } __declspec(dllexport) bool IsMeterUnitForHoleElevDim() { return g_Option::instance().g_bMeterUnitHoleElevDim == FALSE ? false : true; } __declspec(dllexport) int getPrecForPipeElevDim() { return g_DimOption::instance().g_iPrecForPipeElevDim; } __declspec(dllexport) int getPrecForHoleElevDim() { return g_Option::instance().g_iPrecForHoleElevDim; } }