708 lines
18 KiB
C++
708 lines
18 KiB
C++
#include "stdafx.h"
|
||||
|
|
|
|||
|
|
ACRX_DXF_DEFINE_MEMBERS(ATSPromptMark, ATSEntity, AcDb::kDHL_CURRENT, AcDb::kMReleaseCurrent,
|
|||
|
|
1, ATS_PROMPTMARK, "ATS_PROMPTMARK图形无法解析, 请下载上华软件|网址: www.shanghuasoft.com");
|
|||
|
|
|
|||
|
|
IMPLEMENT_TENTBASE(TDbPromptMark);
|
|||
|
|
|
|||
|
|
// ver: 1-TArch5;2-TArch6;3-TArch7
|
|||
|
|
const Adesk::UInt8 TDbPromptMark::g_nVersion = 3;
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
TDbPromptMark::TDbPromptMark(const XPoint &pt1, const XPoint &pt2, const TCHAR *pszMsg)
|
|||
|
|
: m_nControlFlag(0), m_shape(kRectCrossing), m_nRotation(0.0)
|
|||
|
|
{
|
|||
|
|
XRectAngle rec(pt1, pt2);
|
|||
|
|
m_xSize=rec.Width();
|
|||
|
|
m_ySize=rec.Height();
|
|||
|
|
rec.Center(m_ptLocation);
|
|||
|
|
if(pszMsg) m_sPrompt=pszMsg;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
TDbPromptMark::TDbPromptMark()
|
|||
|
|
:m_nControlFlag(0), m_shape(kRectCrossing),
|
|||
|
|
m_nRotation(0.0),m_xSize(0.0),m_ySize(0.0)
|
|||
|
|
{
|
|||
|
|
m_colorText=7;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
TDbPromptMark::~TDbPromptMark()
|
|||
|
|
{
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
Acad::ErrorStatus
|
|||
|
|
TDbPromptMark::subGetClassID(CLSID* pClsid) const
|
|||
|
|
{
|
|||
|
|
return Acad::eOk;
|
|||
|
|
//return TDbEntity::getClassID(pClsid);
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 提供对格式刷的支持
|
|||
|
|
void TDbPromptMark::CopyPropertiesFrom(AcDbEntity *pSrcEntity, unsigned gMatchFlag)
|
|||
|
|
{
|
|||
|
|
assertWriteEnabled();
|
|||
|
|
TDbEntity::CopyPropertiesFrom(pSrcEntity, gMatchFlag);
|
|||
|
|
TDbPromptMark *pSrc=TDbPromptMark::cast(pSrcEntity);
|
|||
|
|
if(pSrc) {
|
|||
|
|
m_nControlFlag=pSrc->m_nControlFlag;
|
|||
|
|
m_shape=pSrc->m_shape;
|
|||
|
|
if(database()==NULL||
|
|||
|
|
pSrcEntity->database()==NULL||
|
|||
|
|
database()==pSrcEntity->database())//add by whl on 060317
|
|||
|
|
{
|
|||
|
|
m_idTextStyle=pSrc->m_idTextStyle;
|
|||
|
|
}
|
|||
|
|
m_colorText=pSrc->m_colorText;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
//////////////////////////////////////////////////////////////
|
|||
|
|
// 从DWG读入数据:
|
|||
|
|
Acad::ErrorStatus TDbPromptMark::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;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if(nVer==1) {
|
|||
|
|
AcGePoint3d lowLeft, upRight;
|
|||
|
|
pFiler->readItem(&(AcGePoint3d &)lowLeft);
|
|||
|
|
pFiler->readItem(&(AcGePoint3d &)upRight);
|
|||
|
|
ReadString(pFiler, m_sPrompt);
|
|||
|
|
Midpoint(lowLeft, upRight, m_ptLocation);
|
|||
|
|
m_ptLocation.z=0;
|
|||
|
|
m_idTextStyle = GetTextStyleId(_T("STANDARD"), database());
|
|||
|
|
m_xSize = upRight[0]-lowLeft[0];
|
|||
|
|
m_ySize = upRight[1]-lowLeft[1];
|
|||
|
|
m_nRotation = 0.0;
|
|||
|
|
} else { // TArch6
|
|||
|
|
pFiler->readItem(&m_nControlFlag);
|
|||
|
|
Adesk::UInt8 tmp;
|
|||
|
|
pFiler->readItem(&tmp);
|
|||
|
|
m_shape = (ShapeFlag)tmp;
|
|||
|
|
ReadString(pFiler, m_sPrompt);
|
|||
|
|
pFiler->readItem(&m_idTextStyle);
|
|||
|
|
pFiler->readItem((AcGePoint2d *)&m_ptLocation);
|
|||
|
|
pFiler->readItem(&m_xSize);
|
|||
|
|
pFiler->readItem(&m_ySize);
|
|||
|
|
pFiler->readItem(&m_nRotation);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if(nVer>2)
|
|||
|
|
pFiler->readItem(&m_colorText);
|
|||
|
|
return pFiler->filerStatus();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 写出数据到dwg:
|
|||
|
|
Acad::ErrorStatus TDbPromptMark::dwgOutFields(AcDbDwgFiler* pFiler) const
|
|||
|
|
{
|
|||
|
|
assertReadEnabled();
|
|||
|
|
Acad::ErrorStatus es = TDbEntity::dwgOutFields(pFiler);
|
|||
|
|
if(es != Acad::eOk) return es;
|
|||
|
|
if(g_nSaveTArchVer==5) {
|
|||
|
|
pFiler->writeItem((Adesk::UInt8)1);
|
|||
|
|
XRectAngle rect(m_ptLocation, m_xSize, m_ySize);
|
|||
|
|
XPoint ptLow=rect.GetLowLeft();
|
|||
|
|
XPoint ptUp=rect.GetUpRight();
|
|||
|
|
pFiler->writeItem((AcGePoint3d &)ptLow);
|
|||
|
|
pFiler->writeItem((AcGePoint3d &)ptUp);
|
|||
|
|
pFiler->writeString((const TCHAR *)m_sPrompt);
|
|||
|
|
} else if(g_nSaveTArchVer==6) {
|
|||
|
|
pFiler->writeItem((Adesk::UInt8)2);
|
|||
|
|
pFiler->writeItem(m_nControlFlag);
|
|||
|
|
pFiler->writeItem((Adesk::UInt8)m_shape);
|
|||
|
|
pFiler->writeString((const TCHAR *)m_sPrompt);
|
|||
|
|
pFiler->writeItem(m_idTextStyle);
|
|||
|
|
pFiler->writeItem((const AcGePoint2d &)m_ptLocation);
|
|||
|
|
pFiler->writeItem(m_xSize);
|
|||
|
|
pFiler->writeItem(m_ySize);
|
|||
|
|
pFiler->writeItem(m_nRotation);
|
|||
|
|
}else{
|
|||
|
|
pFiler->writeItem(g_nVersion);
|
|||
|
|
pFiler->writeItem(m_nControlFlag);
|
|||
|
|
pFiler->writeItem((Adesk::UInt8)m_shape);
|
|||
|
|
pFiler->writeString((const TCHAR *)m_sPrompt);
|
|||
|
|
pFiler->writeItem(m_idTextStyle);
|
|||
|
|
pFiler->writeItem((const AcGePoint2d &)m_ptLocation);
|
|||
|
|
pFiler->writeItem(m_xSize);
|
|||
|
|
pFiler->writeItem(m_ySize);
|
|||
|
|
pFiler->writeItem(m_nRotation);
|
|||
|
|
pFiler->writeItem(m_colorText);
|
|||
|
|
}
|
|||
|
|
return es;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
Acad::ErrorStatus TDbPromptMark::dxfInFields (AcDbDxfFiler* pFiler)
|
|||
|
|
{
|
|||
|
|
assertWriteEnabled();
|
|||
|
|
|
|||
|
|
Acad::ErrorStatus es = TDbEntity::dxfInFields(pFiler);
|
|||
|
|
if(!es)
|
|||
|
|
return es;
|
|||
|
|
|
|||
|
|
if (!pFiler->atSubclassData(_T("TDbPromptMark"))) {
|
|||
|
|
return Acad::eBadDxfSequence;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
TDbPromptMark bakClone;
|
|||
|
|
CopyObject(*this, bakClone);
|
|||
|
|
|
|||
|
|
int fieldsFlags=0;
|
|||
|
|
resbuf rb;
|
|||
|
|
while ((es == Acad::eOk)
|
|||
|
|
&& ((es = pFiler->readResBuf(&rb)) == Acad::eOk)) {
|
|||
|
|
switch (rb.restype) {
|
|||
|
|
case 10:
|
|||
|
|
m_ptLocation=rb.resval.rpoint;
|
|||
|
|
fieldsFlags |= 0x01;
|
|||
|
|
break;
|
|||
|
|
case 1:
|
|||
|
|
m_sPrompt=rb.resval.rstring;
|
|||
|
|
free(rb.resval.rstring);
|
|||
|
|
break;
|
|||
|
|
case 7:
|
|||
|
|
{
|
|||
|
|
XString sName;
|
|||
|
|
sName=rb.resval.rstring;
|
|||
|
|
free(rb.resval.rstring);
|
|||
|
|
m_idTextStyle=TchExport::GetTextStyleId(sName, database());
|
|||
|
|
}
|
|||
|
|
break;
|
|||
|
|
case 40:
|
|||
|
|
m_xSize=rb.resval.rreal;
|
|||
|
|
break;
|
|||
|
|
case 41:
|
|||
|
|
m_ySize=rb.resval.rreal;
|
|||
|
|
break;
|
|||
|
|
case 50:
|
|||
|
|
m_nRotation=rb.resval.rreal;
|
|||
|
|
break;
|
|||
|
|
case 70:
|
|||
|
|
m_shape=(ShapeFlag)rb.resval.rint;
|
|||
|
|
break;
|
|||
|
|
case 90:
|
|||
|
|
m_nControlFlag=rb.resval.rlong;
|
|||
|
|
break;
|
|||
|
|
default:
|
|||
|
|
// An unrecognized group. Push it back so that
|
|||
|
|
// the subclass can read it again.
|
|||
|
|
pFiler->pushBackItem();
|
|||
|
|
es = Acad::eEndOfFile;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
if (es != Acad::eEndOfFile) {
|
|||
|
|
CopyObject(bakClone, *this);
|
|||
|
|
return Acad::eInvalidResBuf;
|
|||
|
|
}
|
|||
|
|
if(!(fieldsFlags&0x01)) {
|
|||
|
|
pFiler->setError(Acad::eMissingDxfField,_T("\nMissing DXF group code: 10"));
|
|||
|
|
CopyObject(bakClone, *this);
|
|||
|
|
return Acad::eMissingDxfField;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
if(!m_idTextStyle) {
|
|||
|
|
XString style;
|
|||
|
|
if(database())
|
|||
|
|
m_idTextStyle=database()->textstyle();
|
|||
|
|
else {
|
|||
|
|
xg_getvar(_T("TEXTSTYLE"), style);
|
|||
|
|
m_idTextStyle = TchExport::GetTextStyleId(style, database());
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return pFiler->filerStatus();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
Acad::ErrorStatus TDbPromptMark::dxfOutFields(AcDbDxfFiler* pFiler) const
|
|||
|
|
{
|
|||
|
|
Acad::ErrorStatus es;
|
|||
|
|
|
|||
|
|
es = TDbEntity::dxfOutFields(pFiler);
|
|||
|
|
assert(es == Acad::eOk);
|
|||
|
|
|
|||
|
|
es = pFiler->writeItem(AcDb::kDxfSubclass,_T("TDbPromptMark"));
|
|||
|
|
assert(es == Acad::eOk);
|
|||
|
|
|
|||
|
|
pFiler->writePoint3d(10, m_ptLocation);
|
|||
|
|
pFiler->writeString(1, m_sPrompt);
|
|||
|
|
pFiler->writeString(7, (const TCHAR *)GetSymbolName(m_idTextStyle));
|
|||
|
|
pFiler->writeDouble(40, m_xSize);
|
|||
|
|
pFiler->writeDouble(41, m_ySize);
|
|||
|
|
pFiler->writeDouble(50, m_nRotation);
|
|||
|
|
pFiler->writeInt16(70, (Adesk::Int16)m_shape);
|
|||
|
|
pFiler->writeInt32(90, (Adesk::Int32)m_nControlFlag);
|
|||
|
|
|
|||
|
|
return es;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// -----------------------------------------------------------------------
|
|||
|
|
// Overriden functions for edit
|
|||
|
|
// to do:
|
|||
|
|
// 定义了6个夹点:
|
|||
|
|
// 中心点: 用来移动
|
|||
|
|
// 四个角点: 用来改尺寸
|
|||
|
|
// 边点: 用来改角度
|
|||
|
|
Acad::ErrorStatus TDbPromptMark::subGetGripPoints(AcGePoint3dArray& gripPoints,
|
|||
|
|
AcDbIntArray& osnapModes,
|
|||
|
|
AcDbIntArray& geomIds) const
|
|||
|
|
{
|
|||
|
|
gripPoints.append(m_ptLocation);
|
|||
|
|
return Acad::eOk;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
Acad::ErrorStatus TDbPromptMark::subGetStretchPoints(AcGePoint3dArray & stretchPoints) const
|
|||
|
|
{
|
|||
|
|
stretchPoints.append(m_ptLocation);
|
|||
|
|
return Acad::eOk;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 取得夹点说明
|
|||
|
|
Acad::ErrorStatus TDbPromptMark::GetGripText(int i, CString &cs) const
|
|||
|
|
{
|
|||
|
|
Acad::ErrorStatus es=Acad::eOk;
|
|||
|
|
switch(i) {
|
|||
|
|
case 0:
|
|||
|
|
cs=(const TCHAR *)m_sPrompt;
|
|||
|
|
break;
|
|||
|
|
default:
|
|||
|
|
es=Acad::eInvalidInput;
|
|||
|
|
}
|
|||
|
|
return es;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
// Active when being rotated, scaled, moved, etc.
|
|||
|
|
Acad::ErrorStatus TDbPromptMark::subTransformBy(const AcGeMatrix3d& xform)
|
|||
|
|
{
|
|||
|
|
assertWriteEnabled();
|
|||
|
|
TDbEntity::subTransformBy(xform);
|
|||
|
|
((AcGePoint3d &)m_ptLocation).transformBy(xform);
|
|||
|
|
m_ptLocation.z=0;
|
|||
|
|
|
|||
|
|
if(!g_bLayoutRotate) {
|
|||
|
|
|
|||
|
|
AcGeVector3d vt(cos(m_nRotation), sin(m_nRotation), 0.0);
|
|||
|
|
vt.transformBy(xform);
|
|||
|
|
m_nRotation = ads_angle(XPoint(), XPoint(vt[0], vt[1]));
|
|||
|
|
m_xSize *= xform(0,0);
|
|||
|
|
m_ySize *= xform(1,1);
|
|||
|
|
}
|
|||
|
|
return Acad::eOk;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
// 功能: 夹点操作
|
|||
|
|
// bug: 当图块含属性时,系统崩溃
|
|||
|
|
Acad::ErrorStatus TDbPromptMark::subMoveGripPointsAt(
|
|||
|
|
const AcDbIntArray& indices,
|
|||
|
|
const AcGeVector3d& offset)
|
|||
|
|
{
|
|||
|
|
assertWriteEnabled();
|
|||
|
|
XPoint vtOffset=*(XPoint *)&offset;
|
|||
|
|
vtOffset.z=0;
|
|||
|
|
int idx=0;
|
|||
|
|
for (int i = 0; i < indices.length(); i++) {
|
|||
|
|
idx = indices[i];
|
|||
|
|
switch(idx) {
|
|||
|
|
case 0: // Move Center
|
|||
|
|
m_ptLocation += vtOffset;
|
|||
|
|
break; // stretch begin point
|
|||
|
|
default:
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return Acad::eOk;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
Acad::ErrorStatus TDbPromptMark::subMoveStretchPointsAt(
|
|||
|
|
const AcDbIntArray& indices,
|
|||
|
|
const AcGeVector3d& offset)
|
|||
|
|
{
|
|||
|
|
assertWriteEnabled();
|
|||
|
|
return subMoveGripPointsAt(indices, offset);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
/////////////////////////////////////////
|
|||
|
|
// 显示
|
|||
|
|
Acad::ErrorStatus TDbPromptMark::ExplodeOrDraw2d(XExplodeDraw &dc) const
|
|||
|
|
{
|
|||
|
|
TPushProperty vProp(this, dc);
|
|||
|
|
ads_matrix mat;
|
|||
|
|
m_ptLocation.GetRotationMatrix(Layout2Wcs(m_nRotation), mat);
|
|||
|
|
switch(m_shape) {
|
|||
|
|
case kRectCrossing: {
|
|||
|
|
//AcDbPolyline pline;
|
|||
|
|
//GetPolyline(pline);
|
|||
|
|
//pline.setPropertiesFrom(this);
|
|||
|
|
//dc.DrawEntity(pline);
|
|||
|
|
XPoly2D poly2d(1);
|
|||
|
|
XRectAngle box(m_ptLocation, m_xSize, m_ySize);
|
|||
|
|
box.AsPoly2D(poly2d);
|
|||
|
|
poly2d.TransUCS(mat);
|
|||
|
|
//PolyConvert(poly2d, pline);
|
|||
|
|
XLine ln1(box.GetLowLeft(), box.GetUpRight());
|
|||
|
|
XLine ln2(box.GetUpLeft(), box.GetLowRight());
|
|||
|
|
ln1.TransformBy(mat);
|
|||
|
|
ln2.TransformBy(mat);
|
|||
|
|
dc << poly2d << ln1 << ln2;
|
|||
|
|
}
|
|||
|
|
break;
|
|||
|
|
case kCircle: {
|
|||
|
|
XCircle cir(m_ptLocation, m_xSize/2);
|
|||
|
|
XCurveSegment seg;
|
|||
|
|
seg = cir;
|
|||
|
|
dc << seg;
|
|||
|
|
}
|
|||
|
|
break;
|
|||
|
|
case kRect: {
|
|||
|
|
XRectAngle box(m_ptLocation, m_xSize, m_ySize);
|
|||
|
|
XPoly2D poly2d(1);
|
|||
|
|
box.AsPoly2D(poly2d);
|
|||
|
|
poly2d.TransUCS(mat);
|
|||
|
|
dc << poly2d;
|
|||
|
|
}
|
|||
|
|
break;
|
|||
|
|
case kTriangle: {
|
|||
|
|
XPoint ptTop, ptLeft, ptRight;
|
|||
|
|
ads_polar(m_ptLocation, PI/2, m_xSize/2, ptTop);
|
|||
|
|
ads_polar(m_ptLocation, -PI/6, m_xSize/2, ptRight);
|
|||
|
|
ads_polar(m_ptLocation, PI+PI/6, m_xSize/2, ptLeft);
|
|||
|
|
XPoly2D poly2d(1);
|
|||
|
|
poly2d.AppendNode(ptLeft); poly2d.AppendNode(ptRight); poly2d.AppendNode(ptTop);
|
|||
|
|
poly2d.TransUCS(mat);
|
|||
|
|
dc << poly2d;
|
|||
|
|
}
|
|||
|
|
break;
|
|||
|
|
case kCrossing:
|
|||
|
|
case kItericCrossing: {
|
|||
|
|
XPoint ptLeft, ptRight, ptTop, ptBot;
|
|||
|
|
double nRotInc=0.0;
|
|||
|
|
if(m_shape==kItericCrossing)
|
|||
|
|
nRotInc=PI/4;
|
|||
|
|
ads_polar(m_ptLocation, PI+nRotInc, m_xSize/2, ptLeft);
|
|||
|
|
ads_polar(m_ptLocation, 0.0+nRotInc, m_xSize/2, ptRight);
|
|||
|
|
ads_polar(m_ptLocation, PI/2+nRotInc, m_xSize/2, ptTop);
|
|||
|
|
ads_polar(m_ptLocation, PI*1.5+nRotInc, m_xSize/2, ptBot);
|
|||
|
|
XLine ln1(ptLeft, ptRight), ln2(ptBot, ptTop);
|
|||
|
|
ln1.TransformBy(mat); ln2.TransformBy(mat);
|
|||
|
|
dc << ln1 << ln2;
|
|||
|
|
}
|
|||
|
|
break;
|
|||
|
|
case kCircleCrossing:
|
|||
|
|
case kCircleICrossing: {
|
|||
|
|
XCircle cir(m_ptLocation, m_xSize/2);
|
|||
|
|
XCurveSegment seg;
|
|||
|
|
seg = cir;
|
|||
|
|
dc << seg;
|
|||
|
|
XPoint ptLeft, ptRight, ptTop, ptBot;
|
|||
|
|
double nRotInc=0.0;
|
|||
|
|
if(m_shape==kCircleICrossing)
|
|||
|
|
nRotInc=PI/4;
|
|||
|
|
ads_polar(m_ptLocation, PI+nRotInc, m_xSize/2, ptLeft);
|
|||
|
|
ads_polar(m_ptLocation, 0.0+nRotInc, m_xSize/2, ptRight);
|
|||
|
|
ads_polar(m_ptLocation, PI/2+nRotInc, m_xSize/2, ptTop);
|
|||
|
|
ads_polar(m_ptLocation, PI*1.5+nRotInc, m_xSize/2, ptBot);
|
|||
|
|
XLine ln1(ptLeft, ptRight), ln2(ptBot, ptTop);
|
|||
|
|
ln1.TransformBy(mat); ln2.TransformBy(mat);
|
|||
|
|
dc << ln1 << ln2;
|
|||
|
|
}
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
if(GetDrawText() && !!m_idTextStyle && (!!m_sPrompt||g_bExplodeSubText)) {
|
|||
|
|
TDbPromptMark *pClone=(TDbPromptMark *)clone();
|
|||
|
|
pClone->SetDrawText(FALSE);
|
|||
|
|
pClone->SetRotation(0.0);
|
|||
|
|
pClone->SetLayoutRotation(0.0);
|
|||
|
|
XPoint ptLow, ptUp;
|
|||
|
|
pClone->GetExtents2d(ptLow, ptUp);
|
|||
|
|
delete pClone;
|
|||
|
|
XRectAngle rec(ptLow, ptUp);
|
|||
|
|
XPoint ptPos=rec.GetLowRight();
|
|||
|
|
ptPos.TransformBy(mat);
|
|||
|
|
TDbText text;
|
|||
|
|
text.setPropertiesFrom(this);
|
|||
|
|
text.SetStyleId(m_idTextStyle);
|
|||
|
|
text.SetLocation(ptPos);
|
|||
|
|
text.SetRotation(m_nRotation);
|
|||
|
|
text.SetText(m_sPrompt);
|
|||
|
|
text.SetHeight(rec.Height(), FALSE);
|
|||
|
|
if(dc.IsFullExplode())
|
|||
|
|
text.ExplodeOrDraw2d(dc);
|
|||
|
|
else
|
|||
|
|
dc.DrawEntity(text);
|
|||
|
|
}
|
|||
|
|
return Acad::eOk;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
/* * * * * * * * * * 取 动 态 属 性 显 示 数 据 的 函 数 * * * * * * * * * */
|
|||
|
|
void TDbPromptMark::GetTips(DList<TObjInfoUnit> &lstInfo) const
|
|||
|
|
{
|
|||
|
|
lstInfo.Append(new TObjInfoUnit(_T("提示标记"), m_sPrompt));
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
////////////////////////////////////////////////////////////////////////////
|
|||
|
|
// Property methods
|
|||
|
|
/*
|
|||
|
|
void TDbPromptMark::GetPolyline(AcDbPolyline &pline) const
|
|||
|
|
{
|
|||
|
|
ASSERT(m_shape=kRectCrossing);
|
|||
|
|
XRectAngle box(m_ptLocation, m_xSize, m_ySize);
|
|||
|
|
pline.addVertexAt(0, box.GetLowLeft().AsAcGePoint2d());
|
|||
|
|
pline.addVertexAt(1, box.GetLowRight().AsAcGePoint2d());
|
|||
|
|
pline.addVertexAt(2, box.GetUpRight().AsAcGePoint2d());
|
|||
|
|
pline.addVertexAt(3, box.GetUpLeft().AsAcGePoint2d());
|
|||
|
|
pline.setClosed(Adesk::kTrue);
|
|||
|
|
}
|
|||
|
|
*/
|
|||
|
|
|
|||
|
|
const TCHAR * TDbPromptMark::GetDefaultLayer() const
|
|||
|
|
{
|
|||
|
|
return LAY_ERRORMSG;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
int TDbPromptMark::ConvertText(TConvertTextPtr ptr, void *pData)
|
|||
|
|
{
|
|||
|
|
XString sText;
|
|||
|
|
int nRet=ptr(m_sPrompt, sText, pData);
|
|||
|
|
if(nRet==RTNORM) {
|
|||
|
|
assertWriteEnabled();
|
|||
|
|
m_sPrompt=sText;
|
|||
|
|
}
|
|||
|
|
return nRet;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void TDbPromptMark::SetPrompt(const TCHAR *pszMsg)
|
|||
|
|
{
|
|||
|
|
assertWriteEnabled();
|
|||
|
|
if(pszMsg) {
|
|||
|
|
m_sPrompt=pszMsg;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void TDbPromptMark::SetShape(TDbPromptMark::ShapeFlag sp)
|
|||
|
|
{
|
|||
|
|
assertWriteEnabled();
|
|||
|
|
m_shape=sp;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void TDbPromptMark::SetTextStyle(AcDbObjectId id)
|
|||
|
|
{
|
|||
|
|
assertWriteEnabled();
|
|||
|
|
m_idTextStyle=id;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void TDbPromptMark::SetLocation(XPoint pt)
|
|||
|
|
{
|
|||
|
|
assertWriteEnabled();
|
|||
|
|
m_ptLocation = pt;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void TDbPromptMark::SetSizeX(double x)
|
|||
|
|
{
|
|||
|
|
assertWriteEnabled();
|
|||
|
|
m_xSize=x;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void TDbPromptMark::SetSizeY(double y)
|
|||
|
|
{
|
|||
|
|
assertWriteEnabled();
|
|||
|
|
m_ySize=y;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void TDbPromptMark::SetRotation(double nRot)
|
|||
|
|
{
|
|||
|
|
assertWriteEnabled();
|
|||
|
|
m_nRotation=nRot;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
TDbPromptMark::ShapeFlag
|
|||
|
|
TDbPromptMark::GetShape() const
|
|||
|
|
{
|
|||
|
|
return m_shape;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
AcDbObjectId TDbPromptMark::GetTextStyle() const
|
|||
|
|
{
|
|||
|
|
return m_idTextStyle;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
BOOL TDbPromptMark::GetDrawText() const
|
|||
|
|
{
|
|||
|
|
return ((m_nControlFlag&PMF_DRAW_TEXT)!=0);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void TDbPromptMark::SetDrawText(BOOL bTrue)
|
|||
|
|
{
|
|||
|
|
assertWriteEnabled();
|
|||
|
|
if(bTrue)
|
|||
|
|
m_nControlFlag |= PMF_DRAW_TEXT;
|
|||
|
|
else
|
|||
|
|
m_nControlFlag &= ~PMF_DRAW_TEXT;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
int TDbPromptMark::CompareTo(const TDbPromptMark &src) const
|
|||
|
|
{
|
|||
|
|
int n1=Compare(int(GetSizeX()), int(src.GetSizeX()));
|
|||
|
|
if(n1) return n1;
|
|||
|
|
int n2=Compare(int(GetSizeY()), int(src.GetSizeY()));
|
|||
|
|
if(n2) return n2;
|
|||
|
|
int n3=_tcsicmp(GetPrompt(), src.GetPrompt());
|
|||
|
|
if(n3) return n3;
|
|||
|
|
if(GetLocation()==src.GetLocation())
|
|||
|
|
return 0;
|
|||
|
|
return 1;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void InitDbErrorMsg(BOOL bTrue)
|
|||
|
|
{
|
|||
|
|
if(bTrue) {
|
|||
|
|
TDbPromptMark::rxInit();
|
|||
|
|
acrxBuildClassHierarchy();
|
|||
|
|
TDbPromptMark::InitMatchProtocol(TRUE);
|
|||
|
|
} else {
|
|||
|
|
TDbPromptMark::InitMatchProtocol(FALSE);
|
|||
|
|
deleteAcRxClass(TDbPromptMark::desc());
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//extern BOOL g_bGenBoundaryFromCurve;
|
|||
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|||
|
|
// 报告发生错误的地方
|
|||
|
|
void ErrorPosition(const XPoint &ptLowLeft, const XPoint &ptUpRight, const TCHAR *pszMsg)
|
|||
|
|
{
|
|||
|
|
TDbPromptMark *pEntMsg=new TDbPromptMark(ptLowLeft, ptUpRight, pszMsg);
|
|||
|
|
double nW=pEntMsg->GetSizeX(), nH=pEntMsg->GetSizeY();
|
|||
|
|
|
|||
|
|
{
|
|||
|
|
///////////////////////////////////////////////////////
|
|||
|
|
// 判断是否已经有相同的符号存在
|
|||
|
|
XDbBlockTableRec objMSpace;
|
|||
|
|
ASSERT(!!objMSpace);
|
|||
|
|
AcDbBlockTableRecordIterator* pBlockIterator=NULL;
|
|||
|
|
Acad::ErrorStatus es = objMSpace.m_pBlockTableRec->newIterator(pBlockIterator);
|
|||
|
|
ASSERT(es==Acad::eOk && pBlockIterator!=NULL);
|
|||
|
|
BOOL bExist=FALSE;
|
|||
|
|
for (pBlockIterator->start(); !pBlockIterator->done(); pBlockIterator->step()) {
|
|||
|
|
AcDbEntity *pEntity=NULL;
|
|||
|
|
es = pBlockIterator->getEntity(pEntity, AcDb::kForRead);
|
|||
|
|
if(es!=Acad::eOk) continue;
|
|||
|
|
ASSERT(pEntity);
|
|||
|
|
|
|||
|
|
XDbObject vTemp(pEntity);
|
|||
|
|
//不处理不可见的实体
|
|||
|
|
if (pEntity->visibility() == AcDb::kInvisible) {
|
|||
|
|
continue;
|
|||
|
|
}
|
|||
|
|
TDbPromptMark *pMsg=TDbPromptMark::cast(pEntity);
|
|||
|
|
if(pMsg && pEntMsg->CompareTo(*pMsg)==0) {
|
|||
|
|
bExist=TRUE;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
delete pBlockIterator;
|
|||
|
|
if(bExist) {
|
|||
|
|
delete pEntMsg;
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if(nW>1.0E-6 && nH>1.0E-6) {
|
|||
|
|
nW *= 1.5;
|
|||
|
|
nH *= 1.5;
|
|||
|
|
XRectAngle rect2(pEntMsg->GetLocation(), nW, nH);
|
|||
|
|
XPoint ptLow=rect2.GetLowLeft(), ptUp=rect2.GetUpRight();
|
|||
|
|
pEntMsg->SetTextStyle(InitTextStyle(TS_STANDARD));
|
|||
|
|
pEntMsg->AddToMSpace(Adesk::kTrue);
|
|||
|
|
if(arxZoom(ptLow, ptUp)==Acad::eOk) {
|
|||
|
|
XPoint ptTemp;
|
|||
|
|
ads_getpoint(NULL, _T("\n按<回车键>继续: "), ptTemp);
|
|||
|
|
}
|
|||
|
|
} else {
|
|||
|
|
delete pEntMsg;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
void ErrorPosition1(const XPoint &ptLowLeft, const XPoint &ptUpRight, const TCHAR *pszMsg)
|
|||
|
|
{
|
|||
|
|
TDbPromptMark *pEntMsg=new TDbPromptMark(ptLowLeft, ptUpRight, pszMsg);
|
|||
|
|
double nW=pEntMsg->GetSizeX(), nH=pEntMsg->GetSizeY();
|
|||
|
|
|
|||
|
|
{
|
|||
|
|
///////////////////////////////////////////////////////
|
|||
|
|
// 判断是否已经有相同的符号存在
|
|||
|
|
XDbBlockTableRec objMSpace;
|
|||
|
|
ASSERT(!!objMSpace);
|
|||
|
|
AcDbBlockTableRecordIterator* pBlockIterator=NULL;
|
|||
|
|
Acad::ErrorStatus es = objMSpace.m_pBlockTableRec->newIterator(pBlockIterator);
|
|||
|
|
ASSERT(es==Acad::eOk && pBlockIterator!=NULL);
|
|||
|
|
BOOL bExist=FALSE;
|
|||
|
|
for (pBlockIterator->start(); !pBlockIterator->done(); pBlockIterator->step()) {
|
|||
|
|
AcDbEntity *pEntity=NULL;
|
|||
|
|
es = pBlockIterator->getEntity(pEntity, AcDb::kForRead);
|
|||
|
|
if(es!=Acad::eOk) continue;
|
|||
|
|
ASSERT(pEntity);
|
|||
|
|
|
|||
|
|
XDbObject vTemp(pEntity);
|
|||
|
|
//不处理不可见的实体
|
|||
|
|
if (pEntity->visibility() == AcDb::kInvisible) {
|
|||
|
|
continue;
|
|||
|
|
}
|
|||
|
|
TDbPromptMark *pMsg=TDbPromptMark::cast(pEntity);
|
|||
|
|
if(pMsg && pEntMsg->CompareTo(*pMsg)==0) {
|
|||
|
|
bExist=TRUE;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
delete pBlockIterator;
|
|||
|
|
if(bExist) {
|
|||
|
|
delete pEntMsg;
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if(nW>1.0E-6 && nH>1.0E-6) {
|
|||
|
|
nW *= 1.5;
|
|||
|
|
nH *= 1.5;
|
|||
|
|
XRectAngle rect2(pEntMsg->GetLocation(), nW, nH);
|
|||
|
|
XPoint ptLow=rect2.GetLowLeft(), ptUp=rect2.GetUpRight();
|
|||
|
|
pEntMsg->SetTextStyle(InitTextStyle(TS_STANDARD));
|
|||
|
|
pEntMsg->AddToMSpace(Adesk::kTrue);
|
|||
|
|
} else {
|
|||
|
|
delete pEntMsg;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|