575 lines
13 KiB
C++
575 lines
13 KiB
C++
//-----------------------------------------------------------------------------+
|
|
// Copyright (C), 1998-2007, Beijing Tangent Software Co. Ltd.
|
|
// = FileName : TGGiExplodeDrawBase 类
|
|
// = Version : ver2.0
|
|
// = Author : wlw
|
|
// = CreateDate : 2002-09-09
|
|
// = Description: TGGiExplodeDrawBase 定义
|
|
// = Maintainers:
|
|
//
|
|
//-----------------------------------------------------------------------------+
|
|
#include "StdAfx.h"
|
|
#include "TGGiExplodeDrawBase.h"
|
|
#include "acgiutil.h"
|
|
#include "TchGlobalFunc.h"
|
|
#include "TchGlobalCurveFunc.h"
|
|
|
|
TGGiExplodeDrawBase::TGGiExplodeDrawBase()
|
|
: 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;
|
|
}
|
|
|
|
TGGiExplodeDrawBase::~TGGiExplodeDrawBase()
|
|
{
|
|
|
|
}
|
|
|
|
void TGGiExplodeDrawBase::SetPropertiesFrom(const AcDbEntity *pEnt)
|
|
{
|
|
|
|
}
|
|
|
|
BOOL TGGiExplodeDrawBase::IsFullExplode() const
|
|
{
|
|
return FALSE;
|
|
}
|
|
|
|
BOOL TGGiExplodeDrawBase::IsExportTch4() const
|
|
{
|
|
return FALSE;
|
|
}
|
|
|
|
void TGGiExplodeDrawBase::SetLocation(const TADSGePoint3d &ptLoc)
|
|
{
|
|
m_ptLocation = ptLoc;
|
|
}
|
|
|
|
void TGGiExplodeDrawBase::SetRotation(double nRot)
|
|
{
|
|
m_nRotation = nRot;
|
|
}
|
|
|
|
//设置图层和颜色(取图层)
|
|
void TGGiExplodeDrawBase::SetColorLayer(Adesk::UInt16 iObjColor, const AcDbObjectId &id)
|
|
{
|
|
if (id.isValid())
|
|
{
|
|
SetLayer(id);
|
|
SetColor(iObjColor);
|
|
}
|
|
}
|
|
|
|
void TGGiExplodeDrawBase::BackUpProperties(TMasterProperties &prop)
|
|
{
|
|
prop.m_nColor = GetColor();
|
|
prop.m_idLayer = GetLayerId();
|
|
prop.m_idLineType = GetLineTypeId();
|
|
prop.m_idMaterial = GetMaterialId();
|
|
}
|
|
|
|
void TGGiExplodeDrawBase::RestoreProperties(TMasterProperties prop)
|
|
{
|
|
SetLayer(prop.m_idLayer);
|
|
SetLineType(prop.m_idLineType);
|
|
SetColor(prop.m_nColor);
|
|
SetMaterial(prop.m_idMaterial);
|
|
}
|
|
|
|
TGGiExplodeDrawBase::TextAlignment
|
|
TGGiExplodeDrawBase::GetTextAlignment(AcDb::TextHorzMode nHMode, AcDb::TextVertMode nVMode)
|
|
{
|
|
TGGiExplodeDrawBase::TextAlignment nAlign;
|
|
|
|
// 上
|
|
if (nHMode == AcDb::kTextLeft && nVMode == AcDb::kTextTop)
|
|
{
|
|
nAlign = TGGiExplodeDrawBase::kTopLeft;
|
|
}
|
|
else if (nHMode == AcDb::kTextCenter && nVMode == AcDb::kTextTop)
|
|
{
|
|
nAlign = TGGiExplodeDrawBase::kTopCenter;
|
|
}
|
|
else if (nHMode == AcDb::kTextRight && nVMode == AcDb::kTextTop)
|
|
{
|
|
nAlign = TGGiExplodeDrawBase::kTopRight;
|
|
}
|
|
|
|
// 中
|
|
else if (nHMode == AcDb::kTextLeft && nVMode == AcDb::kTextVertMid)
|
|
{
|
|
nAlign = TGGiExplodeDrawBase::kMiddleLeft;
|
|
}
|
|
else if (nHMode == AcDb::kTextCenter && nVMode == AcDb::kTextVertMid)
|
|
{
|
|
nAlign = TGGiExplodeDrawBase::kMiddleCenter;
|
|
}
|
|
else if (nHMode == AcDb::kTextRight && nVMode == AcDb::kTextVertMid)
|
|
{
|
|
nAlign = TGGiExplodeDrawBase::kMiddleRight;
|
|
}
|
|
|
|
// 下
|
|
else if (nHMode == AcDb::kTextLeft && nVMode == AcDb::kTextBottom)
|
|
{
|
|
nAlign = TGGiExplodeDrawBase::kBottomLeft;
|
|
}
|
|
else if (nHMode == AcDb::kTextCenter && nVMode == AcDb::kTextBottom)
|
|
{
|
|
nAlign = TGGiExplodeDrawBase::kBottomCenter;
|
|
}
|
|
else if (nHMode == AcDb::kTextRight && nVMode == AcDb::kTextBottom)
|
|
{
|
|
nAlign = TGGiExplodeDrawBase::kBottomRight;
|
|
}
|
|
|
|
// 基线
|
|
else if (nHMode == AcDb::kTextLeft && nVMode == AcDb::kTextBase)
|
|
{
|
|
nAlign = TGGiExplodeDrawBase::kLeft;
|
|
}
|
|
else if (nHMode == AcDb::kTextCenter && nVMode == AcDb::kTextBase)
|
|
{
|
|
nAlign = TGGiExplodeDrawBase::kCenter;
|
|
}
|
|
else if (nHMode == AcDb::kTextRight && nVMode == AcDb::kTextBase)
|
|
{
|
|
nAlign = TGGiExplodeDrawBase::kRight;
|
|
}
|
|
|
|
else if (nHMode == AcDb::kTextMid)
|
|
{
|
|
nAlign = TGGiExplodeDrawBase::kMiddle;
|
|
}
|
|
else //kTextAlign, kTextFit
|
|
{
|
|
nAlign = TGGiExplodeDrawBase::kUnknown;
|
|
}
|
|
|
|
return nAlign;
|
|
}
|
|
|
|
Adesk::UInt16
|
|
TGGiExplodeDrawBase::GetTextAlignment(TGGiExplodeDrawBase::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;
|
|
}
|
|
|
|
TADSGePoint3d
|
|
TGGiExplodeDrawBase::Align2Base(TGGiExplodeDrawBase::TextAlignment nAlign,
|
|
TADSGePoint3d ptAlign, TADSGePoint3d ext)
|
|
{
|
|
TADSGePoint3d ptBase = ptAlign;
|
|
|
|
// 换算基点
|
|
switch(nAlign)
|
|
{
|
|
case TGGiExplodeDrawBase::kTopLeft:
|
|
ptBase.y -= ext.y;
|
|
break;
|
|
case TGGiExplodeDrawBase::kTopCenter:
|
|
ptBase.y -= ext.y;
|
|
ptBase.x -= ext.x / 2.0;
|
|
break;
|
|
case TGGiExplodeDrawBase::kTopRight:
|
|
ptBase.y -= ext.y;
|
|
ptBase.x -= ext.x;
|
|
break;
|
|
case TGGiExplodeDrawBase::kMiddleLeft:
|
|
ptBase.y -= ext.y / 2.0;
|
|
break;
|
|
case TGGiExplodeDrawBase::kMiddleCenter:
|
|
ptBase.y -= ext.y / 2.0;
|
|
ptBase.x -= ext.x / 2.0;
|
|
break;
|
|
case TGGiExplodeDrawBase::kMiddleRight:
|
|
ptBase.y -= ext.y / 2.0;
|
|
ptBase.x -= ext.x;
|
|
break;
|
|
case TGGiExplodeDrawBase::kBottomLeft:
|
|
ptBase.y += (ext.z - ext.y);
|
|
break;
|
|
case TGGiExplodeDrawBase::kBottomCenter:
|
|
ptBase.y += (ext.z - ext.y);
|
|
ptBase.x -= ext.x / 2.0;
|
|
break;
|
|
case TGGiExplodeDrawBase::kBottomRight:
|
|
ptBase.y += (ext.z - ext.y);
|
|
ptBase.x -= ext.x;
|
|
break;
|
|
|
|
case TGGiExplodeDrawBase::kLeft:
|
|
break;
|
|
case TGGiExplodeDrawBase::kCenter:
|
|
ptBase.x -= ext.x / 2.0;
|
|
break;
|
|
case TGGiExplodeDrawBase::kRight:
|
|
ptBase.x -= ext.x;
|
|
break;
|
|
case TGGiExplodeDrawBase::kMiddle:
|
|
ptBase.x -= ext.x / 2;
|
|
ptBase.y -= ext.z / 2.0;
|
|
ptBase.y += (ext.z - ext.y);
|
|
break;
|
|
default:
|
|
ASSERT(0);
|
|
}
|
|
|
|
return ptBase;
|
|
}
|
|
|
|
TADSGePoint3d TGGiExplodeDrawBase::Base2Align(TGGiExplodeDrawBase::TextAlignment nAlign,
|
|
TADSGePoint3d ptBase, TADSGePoint3d ext)
|
|
{
|
|
TADSGePoint3d ptAlign = ptBase;
|
|
|
|
// 换算基点
|
|
switch(nAlign)
|
|
{
|
|
case TGGiExplodeDrawBase::kTopLeft:
|
|
ptAlign.y += ext.y;
|
|
break;
|
|
case TGGiExplodeDrawBase::kTopCenter:
|
|
ptAlign.y += ext.y;
|
|
ptAlign.x += ext.x / 2.0;
|
|
break;
|
|
case TGGiExplodeDrawBase::kTopRight:
|
|
ptAlign.y += ext.y;
|
|
ptAlign.x += ext.x;
|
|
break;
|
|
case TGGiExplodeDrawBase::kMiddleLeft:
|
|
ptAlign.y += ext.y / 2.0;
|
|
break;
|
|
case TGGiExplodeDrawBase::kMiddleCenter:
|
|
ptAlign.y += ext.y / 2.0;
|
|
ptAlign.x += ext.x / 2.0;
|
|
break;
|
|
case TGGiExplodeDrawBase::kMiddleRight:
|
|
ptAlign.y += ext.y / 2.0;
|
|
ptAlign.x += ext.x;
|
|
break;
|
|
case TGGiExplodeDrawBase::kBottomLeft:
|
|
ptAlign.y -= (ext.z - ext.y);
|
|
break;
|
|
case TGGiExplodeDrawBase::kBottomCenter:
|
|
ptAlign.y -= (ext.z - ext.y);
|
|
ptAlign.x += ext.x / 2.0;
|
|
break;
|
|
case TGGiExplodeDrawBase::kBottomRight:
|
|
ptAlign.y -= (ext.z - ext.y);
|
|
ptAlign.x += ext.x;
|
|
break;
|
|
case TGGiExplodeDrawBase::kLeft:
|
|
break;
|
|
case TGGiExplodeDrawBase::kCenter:
|
|
ptAlign.x += ext.x / 2.0;
|
|
break;
|
|
case TGGiExplodeDrawBase::kRight:
|
|
ptAlign.x += ext.x;
|
|
break;
|
|
case TGGiExplodeDrawBase::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 TGGiExplodeDrawBase::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 TGGiExplodeDrawBase::SetStyle(const TCHAR * szStyle)
|
|
{
|
|
m_idTextStyle = GetTextStyleId(szStyle);
|
|
LoadAcGiStyle();
|
|
}
|
|
|
|
void TGGiExplodeDrawBase::SetStyle(AcDbObjectId id)
|
|
{
|
|
m_idTextStyle = id;
|
|
LoadAcGiStyle();
|
|
}
|
|
|
|
void TGGiExplodeDrawBase::Polyline(AcDbPolyline &pline)
|
|
{
|
|
TGGePoly2D poly;
|
|
PolyConvert(pline, poly);
|
|
|
|
*this<<poly;
|
|
}
|
|
|
|
void TGGiExplodeDrawBase::DrawCurve(const TGGeCurveSegment &cv, double nThickness)
|
|
{
|
|
if (cv.Is(CURVE_LINE))
|
|
{
|
|
DrawLine(cv.GetLine(), nThickness);
|
|
}
|
|
else if (cv.Is(CURVE_ARC))
|
|
{
|
|
DrawArc(cv.GetArc(), nThickness);
|
|
}
|
|
else if (cv.Is(CURVE_CIRCLE))
|
|
{
|
|
TGGeCircle cir = cv.GetCircle();
|
|
DrawCircle(cir, nThickness);
|
|
}
|
|
}
|
|
|
|
void TGGiExplodeDrawBase::DrawCurveList(const TDPtrList<TGGeCurveSegment> &lstCurves, double nThickness)
|
|
{
|
|
for (int i = 0; i < lstCurves.Length(); i++)
|
|
{
|
|
DrawCurve(lstCurves[i], nThickness);
|
|
}
|
|
}
|
|
|
|
void TGGiExplodeDrawBase::DrawShell(const TGGePoly2D &polyRegion)
|
|
{
|
|
DrawShell(polyRegion, TDPtrList<TGGePoly2D>());
|
|
}
|
|
|
|
void TGGiExplodeDrawBase::DrawColumn(const TGGePoly2D &polyRegion1, const TGGePoly2D &polyRegion2)
|
|
{
|
|
DrawMesh(polyRegion1, polyRegion2);
|
|
DrawShell(polyRegion1);
|
|
DrawShell(polyRegion2);
|
|
}
|
|
|
|
void TGGiExplodeDrawBase::SetAlignment(TextAlignment align)
|
|
{
|
|
m_align = align;
|
|
}
|
|
|
|
void TGGiExplodeDrawBase::SetHeight(double nHeight)
|
|
{
|
|
m_nHeight = nHeight;
|
|
}
|
|
|
|
void TGGiExplodeDrawBase::SetWidthFactor(double nWidthFactor)
|
|
{
|
|
m_nControlFlag |= EDF_XSCALE;
|
|
m_nWidthFactor = nWidthFactor;
|
|
}
|
|
|
|
// 仅炸开使用
|
|
void TGGiExplodeDrawBase::SetAutoProp(BOOL bTrue)
|
|
{
|
|
if (bTrue)
|
|
{
|
|
m_nControlFlag &= ~EDF_NO_AUTOPROP;
|
|
}
|
|
else
|
|
{
|
|
m_nControlFlag |= EDF_NO_AUTOPROP;
|
|
}
|
|
}
|
|
|
|
BOOL TGGiExplodeDrawBase::IsAutoProp() const
|
|
{
|
|
BOOL bTrue = TRUE;
|
|
if (m_nControlFlag & EDF_NO_AUTOPROP)
|
|
{
|
|
bTrue = FALSE;
|
|
}
|
|
|
|
return bTrue;
|
|
}
|
|
|
|
void TGGiExplodeDrawBase::SetSelectionMarker(int nMark)
|
|
{
|
|
|
|
}
|
|
|
|
BOOL TGGiExplodeDrawBase::IsPlotGeneration() const
|
|
{
|
|
return FALSE;
|
|
}
|
|
|
|
void TGGiExplodeDrawBase::DrawEntity(const AcDbEntity &ent)
|
|
{
|
|
|
|
}
|
|
|
|
void TGGiExplodeDrawBase::DrawBody(const TGGePoly2D &polyOut, const TDPtrList<TGGePoly2D> &lstHoles,const TVector3D &vtOffset)
|
|
{
|
|
|
|
}
|
|
|
|
Adesk::UInt16 TGGiExplodeDrawBase::GetColor() const
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
void TGGiExplodeDrawBase::SetColor(Adesk::UInt16 nColor)
|
|
{
|
|
|
|
}
|
|
|
|
//add by xlc on 100629 TArch8.5
|
|
//COLORREF TGGiExplodeDrawBase::GetTrueColor() const
|
|
AcCmColor TGGiExplodeDrawBase::GetTrueColor() const
|
|
{
|
|
AcCmColor cmColor;
|
|
return cmColor;
|
|
}
|
|
|
|
//void TGGiExplodeDrawBase::SetTrueColor(COLORREF crRef)
|
|
void TGGiExplodeDrawBase::SetTrueColor(AcCmColor crRef)
|
|
{
|
|
|
|
}
|
|
|
|
//显示类起作用,分解类不起作用
|
|
void TGGiExplodeDrawBase::SetColor1(Adesk::UInt16 nColor)
|
|
{
|
|
|
|
}
|
|
|
|
AcDbObjectId TGGiExplodeDrawBase::GetLayerId() const
|
|
{
|
|
return AcDbObjectId::kNull;
|
|
}
|
|
|
|
AcDbObjectId TGGiExplodeDrawBase::GetLineTypeId() const
|
|
{
|
|
return AcDbObjectId::kNull;
|
|
}
|
|
|
|
AcDbObjectId TGGiExplodeDrawBase::GetMaterialId() const
|
|
{
|
|
return AcDbObjectId::kNull;
|
|
}
|
|
|
|
Acad::ErrorStatus TGGiExplodeDrawBase::SetLayer(const AcDbObjectId &id)
|
|
{
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus TGGiExplodeDrawBase::SetLayer(const TCHAR *pszLay)
|
|
{
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus TGGiExplodeDrawBase::SetLineType(const TCHAR *pltype)
|
|
{
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus TGGiExplodeDrawBase::SetLineType(AcDbObjectId idLinetype)
|
|
{
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus TGGiExplodeDrawBase::SetMaterial(AcDbObjectId idMaterial)
|
|
{
|
|
return Acad::eOk;
|
|
}
|
|
|
|
void TGGiExplodeDrawBase::DrawXCurve(const TGGeCurveSegment&curve,double nThick)
|
|
{
|
|
DrawCurve(curve,nThick);
|
|
}
|
|
|
|
void TGGiExplodeDrawBase::DrawX3DFace(const TGGe3DFace&face)
|
|
{
|
|
DrawFace(face);
|
|
}
|
|
|
|
void TGGiExplodeDrawBase::DrawTextFit(const TCHAR *pszText, TADSGePoint3d pt1, TADSGePoint3d pt2, double nTextHeight)
|
|
{
|
|
|
|
}
|
|
|
|
void TGGiExplodeDrawBase::DrawAtomicEntSet(const AcDbVoidPtrArray &entSet, const AcGeMatrix3d &matTrans)
|
|
{
|
|
|
|
}
|
|
|
|
Adesk::Boolean TGGiExplodeDrawBase::IsDragging() const
|
|
{
|
|
return Adesk::kFalse;
|
|
} |