Files
gjm 164968b62e chore
把非utf8-bom编码的cpp/h文件改为 utf8 bom 编码, msvc识别utf8编码时,如果不是bom格式的,会使用当前cp_oem来解码.
2026-10-04 00:04:20 +08:00

103 lines
2.5 KiB
C++

#include "stdafx.h"
#include "Tgkatana.h"
TUTIL_IMPEXP BOOL GetEntFromPt(const AcGePoint3d &pt, LPCTSTR sDxfName, TEntitySet &ent);
TUTIL_IMPEXP void SetHandCursorSelectType(LPCTSTR pszType);
TUTIL_IMPEXP void SetHandCursorSelectEntity(TEntitySet &ent);
TUTIL_IMPEXP BOOL MouseMoveMonitorByHandCursor(MSG *msg);
TUTIL_IMPEXP void StartChangeCursor();
TUTIL_IMPEXP void EndChangeCursor();
namespace
{
bool JudgeKatanaPt(const AcGePoint3d &pt, TEntitySet ent)
{
OPENOBJ_BEGIN(ent, AcDb::kForRead, TDbWall, pWall)
if (pWall)
{
TADSGePoint3d ptPro;
pWall->ProjectToMe(pt, ptPro);
AcGePoint3d ptGePro(asPnt3d(ptPro));
if (DOWN_ZERO(ptGePro.distanceTo(pWall->StartPoint()) - GlwKatana::GetLessLength()) ||
DOWN_ZERO(ptGePro.distanceTo(pWall->EndPoint()) - GlwKatana::GetLessLength()))
return false;
}
OPENOBJ_END()
return true;
}
}
void CreateKanata()
{
TEntitySet ent;
SetHandCursorSelectEntity(ent);
SetHandCursorSelectType(_T("TCH_WALL"));
acedRegisterFilterWinMsg(MouseMoveMonitorByHandCursor);
StartChangeCursor();
GlwKatana *pKatana(NULL);
AcDbObjectId idNew(AcDbObjectId::kNull), idOld(AcDbObjectId::kNull);
AcGePoint3d ptCenter(AcGePoint3d::kOrigin), ptLeft(AcGePoint3d::kOrigin), ptRight(AcGePoint3d::kOrigin);
while (true)
{
TPushAcadVar<int> vOsMode(_T("OSMODE"), OS_INT|OS_NEA|OS_END);
ads_point pt;
int nRel = acedGetPoint(NULL, _T("\n请选择要斩断的墙."), pt);
if (nRel != RTNORM) goto finish;
ptCenter = asPnt3d(pt);
UCS2WCS(ptCenter);
if (!GetEntFromPt(ptCenter, _T("TCH_WALL"), ent))
{
acutPrintf(_T("\n请选择墙实体!"));
continue;
}
if (!JudgeKatanaPt(ptCenter, ent))
{
continue;
}
OPENOBJ_BEGIN(ent, AcDb::kForWrite, TDbWall, pWall)
if (pWall)
{
TADSGePoint3d ptPro;
idOld = pWall->objectId();
pWall->ProjectToMe(ptCenter, ptPro);
if (pWall->BreakAt(ptPro, idNew, NULL, NULL, true))
break;
else
continue;
}
else
{
acutPrintf(_T("\n请重新选择墙实体!"));
continue;
}
OPENOBJ_END()
}
pKatana = new GlwKatana();
ent.Redraw(4);
finish:
EndChangeCursor();
acedRemoveFilterWinMsg(MouseMoveMonitorByHandCursor);
if (!pKatana) return;
pKatana->setColorIndex(6);
pKatana->setLayer(InitLayer(LAY_CLNG_GRID));
AcDbObjectId idKatana = AddToModelSpace(pKatana);
if (!idKatana.isValid())
{
delete pKatana;
return;
}
OPENOBJ_BEGIN(idKatana, AcDb::kForWrite, GlwKatana, pK)
if (pK)
{
pK->Init(idNew, idOld);
}
OPENOBJ_END()
//CreateKanata();
}