1130 lines
28 KiB
C++
1130 lines
28 KiB
C++
#include "stdafx.h"
|
|
#include "DbRect.h"
|
|
#include "globalFunc.h"
|
|
#include "ObjInfoUnit.h"
|
|
|
|
ACRX_DXF_DEFINE_MEMBERS(CDbRect, AecXDbCurveBaseEx, AcDb::kDHL_CURRENT, AcDb::kMReleaseCurrent,
|
|
1, AEC_ZT_RECT, "AEC_RECT图形无法解析, 请下载上华软件|网址: www.shanghuasoft.com");
|
|
|
|
|
|
const Adesk::UInt8 CDbRect::g_nVersion = 2;
|
|
|
|
CDbRect::CDbRect()
|
|
:m_nRotation(0.0), m_nSizeX(0.0), m_nSizeY(0.0), m_nSizeZ(0.0),
|
|
m_nRectFlag(0), m_vtNormal(0, 0, 1)
|
|
{
|
|
m_baseFlag = kCenter;
|
|
}
|
|
|
|
|
|
|
|
// 提供对格式刷的支持
|
|
void CDbRect::CopyPropertiesFrom(AcDbEntity *pSrcEntity, unsigned gMatchFlag)
|
|
{
|
|
assertWriteEnabled();
|
|
AecXDbCurveBaseEx::CopyPropertiesFrom(pSrcEntity, gMatchFlag);
|
|
CDbRect *pSrc = CDbRect::cast(pSrcEntity);
|
|
if (pSrc) {
|
|
m_nRectFlag = pSrc->m_nRectFlag; //标志
|
|
m_nSizeX = pSrc->m_nSizeX;
|
|
m_nSizeY = pSrc->m_nSizeY;
|
|
m_nSizeZ = pSrc->m_nSizeZ;
|
|
m_baseFlag = pSrc->m_baseFlag;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
BOOL CDbRect::IsValid() const
|
|
{
|
|
//BOOL bValid = AecXDbCurveBaseEx::IsValid();
|
|
//if (!bValid)
|
|
// return bValid;
|
|
if (m_nSizeX < g_Option::instance()._DIST_SNAP || m_nSizeY < g_Option::instance()._DIST_SNAP)
|
|
return FALSE;
|
|
return TRUE;
|
|
}
|
|
|
|
/*
|
|
Acad::ErrorStatus
|
|
CDbRect::getClassID(CLSID* pClsid) const
|
|
{
|
|
return Acad::eOk;
|
|
|
|
}
|
|
*/
|
|
|
|
|
|
// 取得四个角点
|
|
XPoint CDbRect::GetLowLeft() const
|
|
{
|
|
//modified by fxj 090427
|
|
double nAng = 0.0;
|
|
if (m_nSizeX >= g_Option::instance()._DIST_SNAP)
|
|
nAng = atan(m_nSizeY / m_nSizeX);
|
|
else if (m_nSizeY >= g_Option::instance()._DIST_SNAP)
|
|
nAng = PI / 2.0;
|
|
else
|
|
return m_ptCen;
|
|
|
|
double nLen = sqrt(m_nSizeY * m_nSizeY + m_nSizeX * m_nSizeX);
|
|
XPoint ptLowLeft;
|
|
ads_polar(m_ptCen, m_nRotation + PI + nAng, nLen / 2.0, ptLowLeft);
|
|
return ptLowLeft;
|
|
}
|
|
|
|
|
|
XPoint CDbRect::GetLowRight() const
|
|
{
|
|
//modified by fxj 090427
|
|
double nAng = 0.0;
|
|
if (m_nSizeX >= g_Option::instance()._DIST_SNAP)
|
|
nAng = atan(m_nSizeY / m_nSizeX);
|
|
else if (m_nSizeY >= g_Option::instance()._DIST_SNAP)
|
|
nAng = PI / 2.0;
|
|
else
|
|
return m_ptCen;
|
|
|
|
|
|
double nLen = sqrt(m_nSizeY * m_nSizeY + m_nSizeX * m_nSizeX);
|
|
XPoint ptLowRight;
|
|
ads_polar(m_ptCen, m_nRotation - nAng, nLen / 2.0, ptLowRight);
|
|
return ptLowRight;
|
|
}
|
|
|
|
|
|
XPoint CDbRect::GetUpRight() const
|
|
{
|
|
//modified by fxj 090427
|
|
double nAng = 0.0;
|
|
if (m_nSizeX >= g_Option::instance()._DIST_SNAP)
|
|
nAng = atan(m_nSizeY / m_nSizeX);
|
|
else if (m_nSizeY >= g_Option::instance()._DIST_SNAP)
|
|
nAng = PI / 2.0;
|
|
else
|
|
return m_ptCen;
|
|
|
|
double nLen = sqrt(m_nSizeY * m_nSizeY + m_nSizeX * m_nSizeX);
|
|
XPoint ptUpRight;
|
|
ads_polar(m_ptCen, m_nRotation + nAng, nLen / 2.0, ptUpRight);
|
|
return ptUpRight;
|
|
}
|
|
|
|
|
|
XPoint CDbRect::GetUpLeft() const
|
|
{
|
|
//modified by fxj 090427
|
|
double nAng = 0.0;
|
|
if (m_nSizeX >= g_Option::instance()._DIST_SNAP)
|
|
nAng = atan(m_nSizeY / m_nSizeX);
|
|
else if (m_nSizeY >= g_Option::instance()._DIST_SNAP)
|
|
nAng = PI / 2.0;
|
|
else
|
|
return m_ptCen;
|
|
|
|
double nLen = sqrt(m_nSizeY * m_nSizeY + m_nSizeX * m_nSizeX);
|
|
XPoint ptUpLeft;
|
|
ads_polar(m_ptCen, m_nRotation + PI - nAng, nLen / 2.0, ptUpLeft);
|
|
return ptUpLeft;
|
|
}
|
|
|
|
|
|
void CDbRect::GetPolyline(AcDbPolyline &pline) const
|
|
{
|
|
pline.reset(Adesk::kFalse, 0);
|
|
pline.setElevation(0.0);
|
|
pline.setNormal(m_vtNormal);
|
|
pline.addVertexAt(0, GetLowLeft().AsAcGePoint2d());
|
|
pline.addVertexAt(1, GetLowRight().AsAcGePoint2d());
|
|
pline.addVertexAt(2, GetUpRight().AsAcGePoint2d());
|
|
pline.addVertexAt(3, GetUpLeft().AsAcGePoint2d());
|
|
pline.setThickness(m_nSizeZ);
|
|
pline.setClosed(Adesk::kTrue);
|
|
}
|
|
|
|
|
|
//Acad::ErrorStatus
|
|
//CDbRect::subGetClassID(CLSID* pClsid) const
|
|
//{
|
|
// return Acad::eOk;
|
|
//}
|
|
|
|
|
|
// 从DWG读入数据:
|
|
Acad::ErrorStatus CDbRect::dwgInFields(AcDbDwgFiler* pFiler)
|
|
{
|
|
assertWriteEnabled();
|
|
|
|
Acad::ErrorStatus es = AecXDbCurveBaseEx::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(&m_nRectFlag);
|
|
pFiler->readItem(&(AcGePoint3d &)m_ptCen); //底面中心
|
|
pFiler->readItem(&m_nRotation);
|
|
pFiler->readItem(&m_nSizeX);
|
|
pFiler->readItem(&m_nSizeY);
|
|
pFiler->readItem(&m_nSizeZ);
|
|
pFiler->readItem(&(AcGeVector3d &)m_vtNormal);
|
|
if (nVer > 1) {
|
|
Adesk::UInt8 flag;
|
|
pFiler->readItem(&flag);
|
|
m_baseFlag = (BasePosition)flag;
|
|
}
|
|
|
|
return pFiler->filerStatus();
|
|
}
|
|
|
|
Acad::ErrorStatus CDbRect::dwgOutFields(AcDbDwgFiler* pFiler) const
|
|
{
|
|
assertReadEnabled();
|
|
Acad::ErrorStatus es = AecXDbCurveBaseEx::dwgOutFields(pFiler);
|
|
if (es != Acad::eOk) return es;
|
|
|
|
pFiler->writeItem(g_nVersion);
|
|
pFiler->writeItem(m_nRectFlag);
|
|
pFiler->writeItem((AcGePoint3d &)m_ptCen); //底面中心
|
|
pFiler->writeItem(m_nRotation);
|
|
pFiler->writeItem(m_nSizeX);
|
|
pFiler->writeItem(m_nSizeY);
|
|
pFiler->writeItem(m_nSizeZ);
|
|
pFiler->writeItem((AcGeVector3d &)m_vtNormal);
|
|
|
|
pFiler->writeItem((Adesk::UInt8)m_baseFlag);
|
|
return pFiler->filerStatus();
|
|
}
|
|
|
|
|
|
|
|
Acad::ErrorStatus CDbRect::dxfInFields(AcDbDxfFiler* pFiler)
|
|
{
|
|
assertWriteEnabled();
|
|
|
|
Acad::ErrorStatus es = AecXDbCurveBaseEx::dxfInFields(pFiler);
|
|
if (es != Acad::eOk)
|
|
return es;
|
|
|
|
if (!pFiler->atSubclassData(_T("CDbRect"))) {
|
|
return Acad::eBadDxfSequence;
|
|
}
|
|
|
|
int fieldsFlags = 0;
|
|
resbuf rb;
|
|
int n1;
|
|
double r1 = 0.0, r2 = 0.0, r3 = 0.0;
|
|
XPoint pt;
|
|
while ((es == Acad::eOk)
|
|
&& ((es = pFiler->readResBuf(&rb)) == Acad::eOk)) {
|
|
switch (rb.restype) {
|
|
case 40:
|
|
r1 = rb.resval.rreal;
|
|
fieldsFlags |= 0x01;
|
|
break;
|
|
case 41:
|
|
r2 = rb.resval.rreal;
|
|
fieldsFlags |= 0x02;
|
|
break;
|
|
case 42:
|
|
r3 = rb.resval.rreal;
|
|
fieldsFlags |= 0x04;
|
|
break;
|
|
case AcDb::kDxfInt16:
|
|
n1 = rb.resval.rint;
|
|
fieldsFlags |= 0x08;
|
|
break;
|
|
case 10:
|
|
pt = rb.resval.rpoint;
|
|
fieldsFlags |= 0x10;
|
|
break;
|
|
case 210:
|
|
m_vtNormal = rb.resval.rpoint;
|
|
break;
|
|
case 50:
|
|
m_nRotation = rb.resval.rreal;
|
|
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 & 0x10)) {
|
|
pFiler->setError(_T("\nMissing DXF group code: 10"));
|
|
return Acad::eMissingDxfField;
|
|
}
|
|
if (!(fieldsFlags & 0x01) || !(fieldsFlags & 0x02) || r1 < g_Option::instance()._DIST_SNAP || r2 < g_Option::instance()._DIST_SNAP) {
|
|
pFiler->setError(_T("\nError DXF group code: 40, 41"));
|
|
return Acad::eMissingDxfField;
|
|
}
|
|
m_ptCen = pt;
|
|
m_nSizeX = r1;
|
|
m_nSizeY = r2;
|
|
if (fieldsFlags & 0x04)
|
|
m_nSizeZ = r3;
|
|
if (fieldsFlags & 0x08)
|
|
m_nRectFlag = n1;
|
|
|
|
return pFiler->filerStatus();
|
|
}
|
|
|
|
Acad::ErrorStatus CDbRect::dxfOutFields(AcDbDxfFiler* pFiler) const
|
|
{
|
|
Acad::ErrorStatus es;
|
|
|
|
es = AecXDbCurveBaseEx::dxfOutFields(pFiler);
|
|
assert(es == Acad::eOk);
|
|
|
|
es = pFiler->writeItem(AcDb::kDxfSubclass, _T("CDbRect"));
|
|
assert(es == Acad::eOk);
|
|
pFiler->writeDouble(40, m_nSizeX);
|
|
pFiler->writeDouble(41, m_nSizeY);
|
|
pFiler->writeDouble(42, m_nSizeZ);
|
|
pFiler->writePoint3d(10, m_ptCen);
|
|
pFiler->writeDouble(50, m_nRotation);
|
|
pFiler->writeInt16(AcDb::kDxfInt16, m_nRectFlag);
|
|
pFiler->writeVector3d(210, m_vtNormal);
|
|
|
|
return es;
|
|
}
|
|
|
|
Acad::ErrorStatus
|
|
CDbRect::subTransformBy(const AcGeMatrix3d& xform)
|
|
{
|
|
assertWriteEnabled();
|
|
AecXDbCurveBaseEx::subTransformBy(xform);
|
|
XPoint ptLowLeft = GetLowLeft();
|
|
XPoint ptLowRight = GetLowRight();
|
|
XPoint ptUpLeft = GetUpLeft();
|
|
ptUpLeft.z = m_ptCen.z + m_nSizeZ;
|
|
|
|
XPoint ptCen = GlobalFunc::Ecs2Wcs(m_ptCen, m_vtNormal);
|
|
ptLowLeft = GlobalFunc::Ecs2Wcs(ptLowLeft, m_vtNormal);
|
|
ptLowRight = GlobalFunc::Ecs2Wcs(ptLowRight, m_vtNormal);
|
|
ptUpLeft = GlobalFunc::Ecs2Wcs(ptUpLeft, m_vtNormal);
|
|
|
|
((AcGePoint3d &)ptCen).transformBy(xform);
|
|
((AcGePoint3d &)ptLowLeft).transformBy(xform);
|
|
((AcGePoint3d &)ptLowRight).transformBy(xform);
|
|
((AcGePoint3d &)ptUpLeft).transformBy(xform);
|
|
((AcGeVector3d &)m_vtNormal).transformBy(xform);
|
|
|
|
ptLowLeft = GlobalFunc::Wcs2Ecs(ptLowLeft, m_vtNormal);
|
|
ptLowRight = GlobalFunc::Wcs2Ecs(ptLowRight, m_vtNormal);
|
|
ptUpLeft = GlobalFunc::Wcs2Ecs(ptUpLeft, m_vtNormal);
|
|
m_ptCen = GlobalFunc::Wcs2Ecs(ptCen, m_vtNormal);
|
|
m_nRotation = ads_angle(ptLowLeft, ptLowRight);
|
|
m_nSizeX = ptLowLeft.Distance2d(ptLowRight);
|
|
m_nSizeY = ptLowLeft.Distance2d(ptUpLeft);
|
|
m_nSizeZ = fabs(ptUpLeft.z - m_ptCen.z);
|
|
return Acad::eOk;
|
|
}
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
// Overriden functions for edit
|
|
// 定义了6个夹点:
|
|
// 中心点: 用来移动
|
|
// 四个角点: 用来改尺寸
|
|
// 边点: 用来改角度
|
|
Acad::ErrorStatus CDbRect::subGetGripPoints(AcGePoint3dArray& gripPoints,
|
|
AcDbIntArray& osnapModes,
|
|
AcDbIntArray& geomIds) const
|
|
{
|
|
XPoint ptCen = GlobalFunc::Ecs2Wcs(GetCenter(), m_vtNormal);
|
|
XPoint ptLowLeft = GlobalFunc::Ecs2Wcs(GetLowLeft(), m_vtNormal);
|
|
XPoint ptLowRight = GlobalFunc::Ecs2Wcs(GetLowRight(), m_vtNormal);
|
|
XPoint ptUpRight = GlobalFunc::Ecs2Wcs(GetUpRight(), m_vtNormal);
|
|
XPoint ptUpLeft = GlobalFunc::Ecs2Wcs(GetUpLeft(), m_vtNormal);
|
|
|
|
gripPoints.append(ptCen);
|
|
gripPoints.append(ptLowLeft);
|
|
gripPoints.append(ptLowRight);
|
|
gripPoints.append(ptUpRight);
|
|
gripPoints.append(ptUpLeft);
|
|
return Acad::eOk;
|
|
}
|
|
|
|
|
|
Acad::ErrorStatus
|
|
CDbRect::subGetStretchPoints(AcGePoint3dArray & stretchPoints) const
|
|
{
|
|
assertReadEnabled();
|
|
XPoint ptCen = GlobalFunc::Ecs2Wcs(GetCenter(), m_vtNormal);
|
|
XPoint ptLowLeft = GlobalFunc::Ecs2Wcs(GetLowLeft(), m_vtNormal);
|
|
XPoint ptLowRight = GlobalFunc::Ecs2Wcs(GetLowRight(), m_vtNormal);
|
|
XPoint ptUpRight = GlobalFunc::Ecs2Wcs(GetUpRight(), m_vtNormal);
|
|
XPoint ptUpLeft = GlobalFunc::Ecs2Wcs(GetUpLeft(), m_vtNormal);
|
|
stretchPoints.append(ptCen);
|
|
/*
|
|
gripPoints.append(ptLowLeft);
|
|
gripPoints.append(ptLowRight);
|
|
gripPoints.append(ptUpRight);
|
|
gripPoints.append(ptUpLeft);
|
|
*/
|
|
return Acad::eOk;
|
|
}
|
|
|
|
|
|
Acad::ErrorStatus CDbRect::subGetOsnapPoints(
|
|
AcDb::OsnapMode osnapMode,
|
|
INT_PTR gsSelectionMark,
|
|
const AcGePoint3d& ptPick,
|
|
const AcGePoint3d& lastPoint,
|
|
const AcGeMatrix3d& viewXform,
|
|
AcGePoint3dArray& snapPoints,
|
|
AcDbIntArray& geomIds) const
|
|
{
|
|
Acad::ErrorStatus es = Acad::eOk;
|
|
//int nCount=snapPoints.length();
|
|
//int expMode=GetExplodeMode();
|
|
XPoint ptCen = GlobalFunc::Ecs2Wcs(GetCenter(), m_vtNormal);
|
|
XPoint ptLowLeft = GlobalFunc::Ecs2Wcs(GetLowLeft(), m_vtNormal);
|
|
XPoint ptLowRight = GlobalFunc::Ecs2Wcs(GetLowRight(), m_vtNormal);
|
|
XPoint ptUpRight = GlobalFunc::Ecs2Wcs(GetUpRight(), m_vtNormal);
|
|
XPoint ptUpLeft = GlobalFunc::Ecs2Wcs(GetUpLeft(), m_vtNormal);
|
|
//if (!IsExplode3D()) {
|
|
// ptCen.z = 0;
|
|
// ptLowLeft.z = 0;
|
|
// ptLowRight.z = 0;
|
|
// ptUpLeft.z = 0;
|
|
//}
|
|
|
|
switch (osnapMode) {
|
|
case AcDb::kOsModeIns:
|
|
case AcDb::kOsModeCen:
|
|
snapPoints.append(ptCen);
|
|
break;
|
|
case AcDb::kOsModeNode:
|
|
snapPoints.append(ptCen);
|
|
snapPoints.append(ptLowLeft);
|
|
snapPoints.append(ptLowRight);
|
|
snapPoints.append(ptUpRight);
|
|
snapPoints.append(ptUpLeft);
|
|
break;
|
|
case AcDb::kOsModeQuad:
|
|
snapPoints.append(ptLowLeft);
|
|
snapPoints.append(ptLowRight);
|
|
snapPoints.append(ptUpRight);
|
|
snapPoints.append(ptUpLeft);
|
|
break;
|
|
default:
|
|
es = AecXDbCurveBaseEx::subGetOsnapPoints(osnapMode,
|
|
gsSelectionMark,
|
|
ptPick,
|
|
lastPoint,
|
|
viewXform,
|
|
snapPoints,
|
|
geomIds);
|
|
}
|
|
|
|
return es;
|
|
}
|
|
Acad::ErrorStatus CDbRect::GetPathPoly(XPoly2D& polyPath, AcGeVector3d&normal)const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
polyPath.AppendNode(GetLowLeft());
|
|
polyPath.AppendNode(GetLowRight());
|
|
polyPath.AppendNode(GetUpRight());
|
|
polyPath.AppendNode(GetUpLeft());
|
|
normal = m_vtNormal.AsAcGeVector3d();
|
|
return Acad::eOk;
|
|
}
|
|
|
|
|
|
// 绘制二维
|
|
Acad::ErrorStatus
|
|
CDbRect::Draw2d(AcGiDraw &dc) const
|
|
{
|
|
//add by fxj 090427
|
|
if (m_nSizeX >= g_Option::instance()._DIST_SNAP && m_nSizeY >= g_Option::instance()._DIST_SNAP)
|
|
;
|
|
else
|
|
return Acad::eOk;
|
|
|
|
|
|
XPoint ptLowLeft = GlobalFunc::Ecs2Wcs(GetLowLeft(), m_vtNormal);
|
|
XPoint ptLowRight = GlobalFunc::Ecs2Wcs(GetLowRight(), m_vtNormal);
|
|
XPoint ptUpRight = GlobalFunc::Ecs2Wcs(GetUpRight(), m_vtNormal);
|
|
XPoint ptUpLeft = GlobalFunc::Ecs2Wcs(GetUpLeft(), m_vtNormal);
|
|
ptLowLeft.z = ptLowRight.z = ptUpRight.z = ptUpLeft.z = 0;
|
|
|
|
XPoly2D poly2d(1);
|
|
poly2d.AppendNode(ptLowLeft);
|
|
poly2d.AppendNode(ptLowRight);
|
|
poly2d.AppendNode(ptUpRight);
|
|
poly2d.AppendNode(ptUpLeft);
|
|
//dc << poly2d;
|
|
DrawPoly2D(dc, poly2d);
|
|
if (m_nRectFlag == RF_DIA45)
|
|
//dc << XLine(ptLowLeft, ptUpRight);
|
|
DrawLine(dc, XLine(ptLowLeft, ptUpRight));
|
|
else if (m_nRectFlag == RF_DIA135)
|
|
//dc << XLine(ptUpLeft, ptLowRight);
|
|
DrawLine(dc, XLine(ptUpLeft, ptLowRight));
|
|
else if (m_nRectFlag == RF_CROSSING)
|
|
//dc << XLine(ptLowLeft, ptUpRight) << XLine(ptUpLeft, ptLowRight);
|
|
DrawLine(dc, XLine(ptLowLeft, ptUpRight));
|
|
DrawLine(dc, XLine(ptUpLeft, ptLowRight));
|
|
return Acad::eOk;
|
|
}
|
|
|
|
|
|
Acad::ErrorStatus
|
|
CDbRect::Draw3d(AcGiDraw &dc) const
|
|
{
|
|
//add by fxj 090427
|
|
if (m_nSizeZ >= g_Option::instance()._DIST_SNAP)
|
|
;
|
|
else
|
|
return Acad::eOk;
|
|
if (m_nSizeX >= g_Option::instance()._DIST_SNAP && m_nSizeY >= g_Option::instance()._DIST_SNAP)
|
|
;
|
|
else
|
|
return Acad::eOk;
|
|
|
|
XPoint ptLowLeft = GlobalFunc::Ecs2Wcs(GetLowLeft(), m_vtNormal);
|
|
XPoint ptLowRight = GlobalFunc::Ecs2Wcs(GetLowRight(), m_vtNormal);
|
|
XPoint ptUpRight = GlobalFunc::Ecs2Wcs(GetUpRight(), m_vtNormal);
|
|
XPoint ptUpLeft = GlobalFunc::Ecs2Wcs(GetUpLeft(), m_vtNormal);
|
|
|
|
|
|
|
|
|
|
XPoly2D poly2d(1);
|
|
poly2d.AppendNode(ptLowLeft);
|
|
poly2d.AppendNode(ptLowRight);
|
|
poly2d.AppendNode(ptUpRight);
|
|
poly2d.AppendNode(ptUpLeft);
|
|
XVector3D vt = m_vtNormal;
|
|
vt.Normalize();
|
|
vt *= m_nSizeZ;
|
|
//dc.DrawBody(poly2d, vt);
|
|
DrawPoly2D(dc, poly2d);
|
|
return Acad::eOk;
|
|
}
|
|
|
|
|
|
|
|
// 取得夹点说明
|
|
Acad::ErrorStatus CDbRect::GetGripText(int i, CString &cs) const
|
|
{
|
|
Acad::ErrorStatus es = Acad::eOk;
|
|
switch (i) {
|
|
case 0:
|
|
cs = (GetCtrlToggle() ? _T("移动(Ctrl-中心旋转)") : _T("中心旋转(Ctrl-移动)"));
|
|
break;
|
|
case 1:
|
|
cs = (GetCtrlToggle() ? _T("移动(Ctrl-对角拉伸)") : _T("对角拉伸(Ctrl-移动)"));
|
|
break;
|
|
case 2:
|
|
cs = (GetCtrlToggle() ? _T("移动(Ctrl-对角拉伸)") : _T("对角拉伸(Ctrl-移动)"));
|
|
break;
|
|
case 3:
|
|
cs = (GetCtrlToggle() ? _T("移动(Ctrl-对角拉伸)") : _T("对角拉伸(Ctrl-移动)"));
|
|
break;
|
|
case 4:
|
|
cs = (GetCtrlToggle() ? _T("移动(Ctrl-对角拉伸)") : _T("对角拉伸(Ctrl-移动)"));
|
|
break;
|
|
default:
|
|
es = Acad::eInvalidInput;
|
|
}
|
|
|
|
return es;
|
|
}
|
|
|
|
|
|
|
|
// 功能: 夹点操作
|
|
Acad::ErrorStatus CDbRect::subMoveGripPointsAt(
|
|
const AcDbIntArray& indices,
|
|
const AcGeVector3d& offset)
|
|
{
|
|
assertWriteEnabled();
|
|
XPoint &vtOffset = *(XPoint *)&offset;
|
|
|
|
BOOL bCtrlPressed = GetCtrlToggle();
|
|
if (bCtrlPressed) {
|
|
XPoint ptCen = GlobalFunc::Ecs2Wcs(GetCenter(), m_vtNormal);
|
|
ptCen += vtOffset;
|
|
m_ptCen = GlobalFunc::Wcs2Ecs(ptCen, m_vtNormal);
|
|
return Acad::eOk;
|
|
}
|
|
|
|
|
|
XVector3D vtEcs = GlobalFunc::Wcs2Ecs(vtOffset, m_vtNormal, TRUE);
|
|
int idx = 0;
|
|
for (int i = 0; i < indices.length(); i++) {
|
|
idx = indices[i];
|
|
switch (idx) {
|
|
case 0: // Move Center
|
|
{
|
|
double nRot = ads_angle(XPoint(), GlobalFunc::Wcs2Ecs(vtOffset, m_vtNormal, TRUE));
|
|
m_nRotation = nRot;
|
|
}
|
|
break; // stretch begin point
|
|
case 1: // Move LowLeft
|
|
{
|
|
XPoint ptLowLeft = GlobalFunc::Ecs2Wcs(GetLowLeft(), m_vtNormal);
|
|
XPoint ptUpRight = GetUpRight();
|
|
ptLowLeft += vtOffset;
|
|
ptLowLeft = GlobalFunc::Wcs2Ecs(ptLowLeft, m_vtNormal);
|
|
ptLowLeft.z = ptUpRight.z;
|
|
XLine ln(ptUpRight, m_nRotation);
|
|
XPoint ptPrj;
|
|
ptLowLeft.Project(&ln, ptPrj);
|
|
m_nSizeX = ptPrj.Distance2d(ptUpRight);
|
|
m_nSizeY = ptPrj.Distance2d(ptLowLeft);
|
|
Midpoint(ptUpRight, ptLowLeft, m_ptCen);
|
|
}
|
|
break;
|
|
case 2: // Move LowRight
|
|
{
|
|
XPoint ptLowRight = GetLowRight();
|
|
XPoint ptUpLeft = GetUpLeft();
|
|
ptLowRight += vtEcs;
|
|
ptLowRight.z = ptUpLeft.z;
|
|
XLine ln(ptUpLeft, m_nRotation);
|
|
XPoint ptPrj;
|
|
ptLowRight.Project(&ln, ptPrj);
|
|
m_nSizeX = ptPrj.Distance2d(ptUpLeft);
|
|
m_nSizeY = ptPrj.Distance2d(ptLowRight);
|
|
Midpoint(ptLowRight, ptUpLeft, m_ptCen);
|
|
}
|
|
break;
|
|
case 3: // Move UpRight
|
|
{
|
|
XPoint ptUpRight = GetUpRight();
|
|
XPoint ptLowLeft = GetLowLeft();
|
|
ptUpRight += vtEcs;
|
|
ptUpRight.z = ptLowLeft.z;
|
|
XLine ln(ptLowLeft, m_nRotation);
|
|
XPoint ptPrj;
|
|
ptUpRight.Project(&ln, ptPrj);
|
|
m_nSizeX = ptPrj.Distance2d(ptLowLeft);
|
|
m_nSizeY = ptPrj.Distance2d(ptUpRight);
|
|
Midpoint(ptUpRight, ptLowLeft, m_ptCen);
|
|
}
|
|
break;
|
|
case 4: // Move UpLeft
|
|
{
|
|
XPoint ptUpLeft = GetUpLeft();
|
|
XPoint ptLowRight = GetLowRight();
|
|
ptUpLeft += vtEcs;
|
|
ptUpLeft.z = ptUpLeft.z;
|
|
XLine ln(ptLowRight, m_nRotation);
|
|
XPoint ptPrj;
|
|
ptUpLeft.Project(&ln, ptPrj);
|
|
m_nSizeX = ptPrj.Distance2d(ptLowRight);
|
|
m_nSizeY = ptPrj.Distance2d(ptUpLeft);
|
|
Midpoint(ptLowRight, ptUpLeft, m_ptCen);
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
#if ARX>15
|
|
void CDbRect::CreateGrip()
|
|
{
|
|
//BaseEx::CreateGrip();
|
|
|
|
//for (long i = 1; i < 5; i++)
|
|
//{
|
|
// GetGrip(i)->AppendDim(new TDbGripDistDim(AcDbDimData::kDimResultantLength));//X
|
|
// GetGrip(i)->AppendDim(new TDbGripDistDim(AcDbDimData::kDimResultantLength));//Y
|
|
//}
|
|
}
|
|
Acad::ErrorStatus CDbRect::EntityToDim(long iGrip, long iDim, const AcDbEntity*pEnt)
|
|
{
|
|
//TDbGripDim*pDim = GetGripDim(iGrip, iDim);
|
|
//if (pDim == NULL)
|
|
// return Acad::eInvalidInput;
|
|
//if (pEnt == NULL)
|
|
// pEnt = this;
|
|
//CDbRect *pInsert = CDbRect::cast(pEnt);
|
|
//if (pInsert == NULL)
|
|
// return Acad::eInvalidInput;
|
|
|
|
//TDbGripDistDim *pDistDim = (TDbGripDistDim*)pDim;
|
|
//if (iGrip == 2 || iGrip == 4)
|
|
//{
|
|
// if (iDim == 0)
|
|
// pDistDim->SetData(pInsert->GetGripPoint((iGrip + 2) % 4 + 1), pInsert->GetGripPoint(iGrip), pInsert->GetSizeY() / 3);
|
|
// else if (iDim == 1)
|
|
// pDistDim->SetData(pInsert->GetGripPoint(iGrip), pInsert->GetGripPoint(iGrip % 4 + 1), pInsert->GetSizeX() / 3);
|
|
// else
|
|
// return Acad::eNotImplementedYet;
|
|
//}
|
|
//else if (iGrip == 1 || iGrip == 3)
|
|
//{
|
|
// if (iDim == 1)
|
|
// pDistDim->SetData(pInsert->GetGripPoint((iGrip + 2) % 4 + 1), pInsert->GetGripPoint(iGrip), pInsert->GetSizeX() / 3);
|
|
// else if (iDim == 0)
|
|
// pDistDim->SetData(pInsert->GetGripPoint(iGrip), pInsert->GetGripPoint(iGrip % 4 + 1), pInsert->GetSizeY() / 3);
|
|
// else
|
|
// return Acad::eNotImplementedYet;
|
|
//}
|
|
//else
|
|
// return Acad::eNotImplementedYet;
|
|
|
|
return Acad::eOk;
|
|
}
|
|
Acad::ErrorStatus CDbRect::DimToEntity(long iGrip, long iDim, double newValue, const AcGeVector3d& offset)
|
|
{
|
|
assertWriteEnabled();
|
|
|
|
if (newValue < 1E-9)
|
|
return Acad::eInvalidInput;
|
|
|
|
double d;
|
|
if (iDim == 0)
|
|
{
|
|
d = newValue - m_nSizeX;
|
|
m_nSizeX = newValue;
|
|
}
|
|
else if (iDim == 1)
|
|
{
|
|
d = newValue - m_nSizeY;
|
|
m_nSizeY = newValue;
|
|
}
|
|
else
|
|
return Acad::eNotImplementedYet;
|
|
|
|
if (!GetCtrlToggle())
|
|
{
|
|
XPoint vt = iDim == 0 ? XPoint(d / 2, 0) : XPoint(0, d / 2);
|
|
switch (iGrip)
|
|
{
|
|
case 1:
|
|
vt.Rotate(GetRotation() + PI);
|
|
break;
|
|
case 2:
|
|
if (iDim == 0)
|
|
vt.Rotate(GetRotation());
|
|
else
|
|
vt.Rotate(GetRotation() + PI);
|
|
break;
|
|
case 3:
|
|
vt.Rotate(GetRotation());
|
|
break;
|
|
case 4:
|
|
if (iDim == 0)
|
|
vt.Rotate(GetRotation() + PI);
|
|
else
|
|
vt.Rotate(GetRotation());
|
|
break;
|
|
default:
|
|
return Acad::eNotImplementedYet;
|
|
}
|
|
m_ptCen += vt;
|
|
}
|
|
|
|
return Acad::eOk;
|
|
}
|
|
#endif
|
|
// 功能: 夹点操作
|
|
Acad::ErrorStatus CDbRect::subMoveStretchPointsAt(
|
|
const AcDbIntArray& indices,
|
|
const AcGeVector3d& offset)
|
|
{
|
|
assertWriteEnabled();
|
|
if (indices.length()) {
|
|
XPoint &vtOffset = *(XPoint *)&offset;
|
|
XVector3D vtEcs = GlobalFunc::Wcs2Ecs(vtOffset, m_vtNormal, TRUE);
|
|
m_ptCen += vtEcs;
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
|
|
void CDbRect::GetTips(DList<ObjInfoUnit> &lstInfo) const
|
|
{
|
|
lstInfo.Append(new ObjInfoUnit(_T("对象类型"), _T("上华矩形")));
|
|
lstInfo.Append(new ObjInfoUnit(_T("中心点"), GlobalFunc::Point2d2Str(m_ptCen)));
|
|
lstInfo.Append(new ObjInfoUnit(_T("转角"), XString(_T("%d"), AS_INT(m_nRotation * 180 / PI))));
|
|
lstInfo.Append(new ObjInfoUnit(_T("长度X"), GlobalFunc::Dist2Str(m_nSizeX)));
|
|
lstInfo.Append(new ObjInfoUnit(_T("宽度Y"), GlobalFunc::Dist2Str(m_nSizeY)));
|
|
lstInfo.Append(new ObjInfoUnit(_T("高度Z"), GlobalFunc::Dist2Str(m_nSizeZ)));
|
|
}
|
|
|
|
BOOL CDbRect::SetPolyline(const AcDbPolyline &pline)
|
|
{
|
|
assertWriteEnabled();
|
|
XPoly2D poly2d;
|
|
GlobalFunc::PolyConvert(pline, poly2d);
|
|
if (poly2d.TotalSegments() == 4) {
|
|
XVector3D vtNorm = pline.normal();
|
|
SetNormal(vtNorm);
|
|
SetRotation(ads_angle(*poly2d[0], *poly2d[1]));
|
|
XPoint ptCen;
|
|
poly2d.Center(ptCen);
|
|
SetCenter(ptCen);
|
|
SetSizeX(ads_distance(*poly2d[0], *poly2d[1]));
|
|
SetSizeY(ads_distance(*poly2d[2], *poly2d[1]));
|
|
SetSizeZ(pline.thickness());
|
|
return TRUE;
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
Acad::ErrorStatus
|
|
CDbRect::getPlane(AcGePlane& plane, AcDb::Planarity& flag) const
|
|
{
|
|
AcDbPolyline pline;
|
|
GetPolyline(pline);
|
|
return pline.getPlane(plane, flag);
|
|
}
|
|
|
|
Adesk::Boolean CDbRect::isPlanar() const
|
|
{
|
|
AcDbPolyline pline;
|
|
GetPolyline(pline);
|
|
return pline.isPlanar();
|
|
}
|
|
|
|
Adesk::Boolean CDbRect::isClosed() const
|
|
{
|
|
AcDbPolyline pline;
|
|
GetPolyline(pline);
|
|
return pline.isClosed();
|
|
}
|
|
|
|
Adesk::Boolean CDbRect::isPeriodic() const
|
|
{
|
|
AcDbPolyline pline;
|
|
GetPolyline(pline);
|
|
return pline.isPeriodic();
|
|
}
|
|
|
|
Acad::ErrorStatus CDbRect::getStartPoint(AcGePoint3d& ptStart) const
|
|
{
|
|
AcDbPolyline pline;
|
|
GetPolyline(pline);
|
|
return pline.getStartPoint(ptStart);
|
|
}
|
|
|
|
Acad::ErrorStatus CDbRect::getEndPoint(AcGePoint3d& ptEnd) const
|
|
{
|
|
AcDbPolyline pline;
|
|
GetPolyline(pline);
|
|
return pline.getEndPoint(ptEnd);
|
|
}
|
|
|
|
Acad::ErrorStatus CDbRect::extend(
|
|
Adesk::Boolean extendStart,
|
|
const AcGePoint3d& toPoint)
|
|
{
|
|
assertWriteEnabled();
|
|
AcDbPolyline pline;
|
|
GetPolyline(pline);
|
|
return pline.extend(extendStart, toPoint);
|
|
}
|
|
|
|
Acad::ErrorStatus CDbRect::extend(double newParam)
|
|
{
|
|
assertWriteEnabled();
|
|
AcDbPolyline pline;
|
|
GetPolyline(pline);
|
|
return pline.extend(newParam);
|
|
}
|
|
|
|
Acad::ErrorStatus CDbRect::getClosestPointTo(
|
|
const AcGePoint3d& givenPnt,
|
|
const AcGeVector3d& normal,
|
|
AcGePoint3d& pointOnCurve,
|
|
Adesk::Boolean extend) const
|
|
{
|
|
AcDbPolyline pline;
|
|
GetPolyline(pline);
|
|
return pline.getClosestPointTo(givenPnt, normal, pointOnCurve, extend);
|
|
}
|
|
|
|
Acad::ErrorStatus CDbRect::getClosestPointTo(
|
|
const AcGePoint3d& givenPnt,
|
|
AcGePoint3d& pointOnCurve,
|
|
Adesk::Boolean extend) const
|
|
{
|
|
AcDbPolyline pline;
|
|
GetPolyline(pline);
|
|
return pline.getClosestPointTo(givenPnt, pointOnCurve, extend);
|
|
}
|
|
|
|
Acad::ErrorStatus CDbRect::getDistAtParam(
|
|
double param,
|
|
double& dist) const
|
|
{
|
|
AcDbPolyline pline;
|
|
GetPolyline(pline);
|
|
return pline.getDistAtParam(param, dist);
|
|
}
|
|
|
|
Acad::ErrorStatus CDbRect::getDistAtPoint(
|
|
const AcGePoint3d& point,
|
|
double& distance) const
|
|
{
|
|
AcDbPolyline pline;
|
|
GetPolyline(pline);
|
|
return pline.getDistAtPoint(point, distance);
|
|
}
|
|
|
|
Acad::ErrorStatus CDbRect::getStartParam(double& startParam) const
|
|
{
|
|
AcDbPolyline pline;
|
|
GetPolyline(pline);
|
|
return pline.getStartParam(startParam);
|
|
}
|
|
|
|
Acad::ErrorStatus CDbRect::getEndParam(double& endParam) const
|
|
{
|
|
AcDbPolyline pline;
|
|
GetPolyline(pline);
|
|
return pline.getEndParam(endParam);
|
|
}
|
|
|
|
Acad::ErrorStatus CDbRect::getParamAtPoint(
|
|
const AcGePoint3d& point,
|
|
double& param) const
|
|
{
|
|
AcDbPolyline pline;
|
|
GetPolyline(pline);
|
|
return pline.getParamAtPoint(point, param);
|
|
}
|
|
|
|
Acad::ErrorStatus CDbRect::getParamAtDist(
|
|
double dist,
|
|
double& param) const
|
|
{
|
|
AcDbPolyline pline;
|
|
GetPolyline(pline);
|
|
return pline.getParamAtDist(dist, param);
|
|
}
|
|
|
|
Acad::ErrorStatus CDbRect::getPointAtDist(
|
|
double dist,
|
|
AcGePoint3d& point) const
|
|
{
|
|
AcDbPolyline pline;
|
|
GetPolyline(pline);
|
|
return pline.getPointAtDist(dist, point);
|
|
}
|
|
|
|
Acad::ErrorStatus CDbRect::getPointAtParam(double param, AcGePoint3d &point) const
|
|
{
|
|
AcDbPolyline pline;
|
|
GetPolyline(pline);
|
|
return pline.getPointAtParam(param, point);
|
|
}
|
|
|
|
#if (ARX>14)
|
|
Acad::ErrorStatus CDbRect::getOffsetCurvesGivenPlaneNormal(
|
|
const AcGeVector3d& normal,
|
|
double offsetDist,
|
|
AcDbVoidPtrArray& offsetCurves) const
|
|
{
|
|
AcDbVoidPtrArray entSet;
|
|
AcDbPolyline pline;
|
|
GetPolyline(pline);
|
|
Acad::ErrorStatus es = pline.getOffsetCurvesGivenPlaneNormal(normal, offsetDist, entSet);
|
|
if (es == Acad::eOk) {
|
|
int nCount = entSet.length();
|
|
for (int n = 0; n < nCount; n++) {
|
|
AcDbEntity *pEnt = (AcDbEntity *)entSet[n];
|
|
if (pEnt->isKindOf(AcDbPolyline::desc())) {
|
|
AcDbPolyline *pCurve = AcDbPolyline::cast(pEnt);
|
|
CDbRect *pRect = new CDbRect;
|
|
pRect->setPropertiesFrom(this);
|
|
if (pRect->SetPolyline(*pCurve))
|
|
offsetCurves.append(pRect);
|
|
else
|
|
delete pRect;
|
|
}
|
|
}
|
|
}
|
|
GlobalFunc::ReleaseEntSet(entSet);
|
|
return es;
|
|
}
|
|
#endif
|
|
|
|
Acad::ErrorStatus CDbRect::getOffsetCurves(
|
|
double offsetDist,
|
|
AcDbVoidPtrArray& offsetCurves) const
|
|
{
|
|
if (offsetDist * 2 + m_nSizeX < g_Option::instance()._DIST_SNAP ||
|
|
offsetDist * 2 + m_nSizeY < g_Option::instance()._DIST_SNAP)
|
|
return Acad::eInvalidInput;
|
|
CDbRect *pClone = (CDbRect *)clone();
|
|
pClone->m_nSizeX += 2 * offsetDist;
|
|
pClone->m_nSizeY += 2 * offsetDist;
|
|
offsetCurves.append(pClone);
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus CDbRect::getOrthoProjectedCurve(
|
|
const AcGePlane& projPlane,
|
|
AcDbCurve*& projCurve) const
|
|
{
|
|
AcDbPolyline pline;
|
|
GetPolyline(pline);
|
|
AcDbCurve *pCurve = NULL;
|
|
Acad::ErrorStatus es = pline.getOrthoProjectedCurve(projPlane, pCurve);
|
|
if (es == Acad::eOk) {
|
|
AcDbPolyline *pPolyline = AcDbPolyline::cast(pCurve);
|
|
if (pPolyline) {
|
|
CDbRect *pClone = (CDbRect *)clone();
|
|
if (pClone->SetPolyline(*pPolyline))
|
|
projCurve = pClone;
|
|
else {
|
|
delete pClone;
|
|
es = Acad::eInvalidInput;
|
|
}
|
|
}
|
|
else
|
|
es = Acad::eInvalidInput;
|
|
}
|
|
if (pCurve) delete pCurve;
|
|
return es;
|
|
}
|
|
|
|
Acad::ErrorStatus CDbRect::getProjectedCurve(
|
|
const AcGePlane& projPlane,
|
|
const AcGeVector3d& projDir,
|
|
AcDbCurve*& projCurve) const
|
|
{
|
|
AcDbPolyline pline;
|
|
GetPolyline(pline);
|
|
AcDbCurve *pCurve = NULL;
|
|
Acad::ErrorStatus es = pline.getProjectedCurve(projPlane, projDir, pCurve);
|
|
if (es == Acad::eOk) {
|
|
AcDbPolyline *pPolyline = AcDbPolyline::cast(pCurve);
|
|
if (pPolyline) {
|
|
CDbRect *pClone = (CDbRect *)clone();
|
|
if (pClone->SetPolyline(*pPolyline))
|
|
projCurve = pClone;
|
|
else {
|
|
delete pClone;
|
|
es = Acad::eInvalidInput;
|
|
}
|
|
}
|
|
else
|
|
es = Acad::eInvalidInput;
|
|
}
|
|
if (pCurve) delete pCurve;
|
|
return es;
|
|
}
|
|
|
|
Acad::ErrorStatus CDbRect::getFirstDeriv(
|
|
double param,
|
|
AcGeVector3d& firstDeriv) const
|
|
{
|
|
AcDbPolyline pline;
|
|
GetPolyline(pline);
|
|
return pline.getFirstDeriv(param, firstDeriv);
|
|
}
|
|
|
|
Acad::ErrorStatus CDbRect::getFirstDeriv(
|
|
const AcGePoint3d& point,
|
|
AcGeVector3d& firstDeriv) const
|
|
{
|
|
AcDbPolyline pline;
|
|
GetPolyline(pline);
|
|
return pline.getFirstDeriv(point, firstDeriv);
|
|
}
|
|
|
|
Acad::ErrorStatus CDbRect::getSecondDeriv(
|
|
double param,
|
|
AcGeVector3d& secDeriv) const
|
|
{
|
|
AcDbPolyline pline;
|
|
GetPolyline(pline);
|
|
return pline.getSecondDeriv(param, secDeriv);
|
|
}
|
|
|
|
Acad::ErrorStatus CDbRect::getSecondDeriv(
|
|
const AcGePoint3d& point,
|
|
AcGeVector3d& secDeriv) const
|
|
{
|
|
AcDbPolyline pline;
|
|
GetPolyline(pline);
|
|
return pline.getSecondDeriv(point, secDeriv);
|
|
}
|
|
|
|
Acad::ErrorStatus CDbRect::getSpline(AcDbSpline*& spline) const
|
|
{
|
|
AcDbPolyline pline;
|
|
GetPolyline(pline);
|
|
return pline.getSpline(spline);
|
|
}
|
|
|
|
Acad::ErrorStatus CDbRect::getSplitCurves(
|
|
const AcGeDoubleArray& params,
|
|
AcDbVoidPtrArray& curveSegments) const
|
|
{
|
|
AcDbPolyline pline;
|
|
GetPolyline(pline);
|
|
return pline.getSplitCurves(params, curveSegments);
|
|
}
|
|
|
|
Acad::ErrorStatus CDbRect::getSplitCurves(
|
|
const AcGePoint3dArray& points,
|
|
AcDbVoidPtrArray& curveSegments) const
|
|
{
|
|
AcDbPolyline pline;
|
|
GetPolyline(pline);
|
|
return pline.getSplitCurves(points, curveSegments);
|
|
}
|
|
|
|
|
|
void InitDbRect(BOOL bTrue)
|
|
{
|
|
if (bTrue) {
|
|
CDbRect::rxInit();
|
|
acrxBuildClassHierarchy();
|
|
//CDbRect::InitMatchProtocol(TRUE);
|
|
}
|
|
else {
|
|
//CDbRect::InitMatchProtocol(FALSE);
|
|
deleteAcRxClass(CDbRect::desc());
|
|
}
|
|
}
|
|
|
|
|
|
void CreateRectangle()
|
|
{
|
|
XPoint pt1, pt2;
|
|
if (XGetPoint(NULL, _T("\n第一个角点"), pt1) == RTNORM &&
|
|
ads_getcorner(pt1, _T("\n第二个角点<退出>:"), pt2) == RTNORM) {
|
|
XVector3D vt = GlobalFunc::Ucs2Wcs(XVector3D(0, 0, 1), TRUE);
|
|
XRectAngle box(pt1, pt2);
|
|
XPoint ptCen;
|
|
Midpoint(pt1, pt2, ptCen);
|
|
CDbRect *pRect = new CDbRect;
|
|
pRect->SetNormal(vt);
|
|
pRect->SetCenter(GlobalFunc::Ucs2Ecs(ptCen, vt));
|
|
pRect->SetSizeX(box.Width());
|
|
pRect->SetSizeY(box.Height());
|
|
pRect->SetRotation(GlobalFunc::Ucs2Wcs(0.0));
|
|
//pRect->AddToCSpace(Adesk::kTrue);
|
|
GlobalFunc::AddToCurrentSpace(pRect, Adesk::kTrue);
|
|
}
|
|
} |