// (C) Copyright 2002-2005 by Autodesk, Inc.
//
// Permission to use, copy, modify, and distribute this software in
// object code form for any purpose and without fee is hereby granted,
// provided that the above copyright notice appears in all copies and
// that both that copyright notice and the limited warranty and
// restricted rights notice below appear in all supporting
// documentation.
//
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
// UNINTERRUPTED OR ERROR FREE.
//
// Use, duplication, or disclosure by the U.S. Government is subject to
// restrictions set forth in FAR 52.227-19 (Commercial Computer
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
// (Rights in Technical Data and Computer Software), as applicable.
//
//-----------------------------------------------------------------------------
//----- ArxMyObjReactor.cpp : Implementation of ArxMyObjReactor
//-----------------------------------------------------------------------------
#include "StdAfx.h"
#include "ArxMyObjReactor.h"
#include <tchar.h>
//-----------------------------------------------------------------------------
ACRX_CONS_DEFINE_MEMBERS(ArxMyObjReactor, AcDbObjectReactor, 1)
//-----------------------------------------------------------------------------
ArxMyObjReactor::ArxMyObjReactor () : AcDbObjectReactor() {
}
//-----------------------------------------------------------------------------
ArxMyObjReactor::~ArxMyObjReactor () {
int nLen = m_idLineArray.length();
for (int i = 0; i < nLen; i++)
{
AcDbObjectPointer<AcDbEntity> ptrTmp(m_idLineArray[i], AcDb::kForWrite);
ptrTmp->removeReactor(this);
ptrTmp->close();
}
}
// -----------------------------------------------------------------------------
void ArxMyObjReactor::modified(const AcDbObject * dbObj)
{
AcDbLine *pLine = AcDbLine::cast(dbObj);
if (pLine)
{
AcGePoint3d pt1, pt2;
pLine->getStartPoint(pt1);
pLine->getEndPoint(pt2);
//const char* cstr = dbObj->isA()->name();
acutPrintf(_T("\n直线的起点=%.3f, %.3f, 终点=%.3f, %.3f"), pt1.x, pt1.y, pt2.x, pt2.y);
AcGeVector3d vecDirect = pt2 - pt1;
AcGeVector3d vecPerp = vecDirect.perpVector();
vecPerp.normalize();
int nLen = m_idLineArray.length();
for (int i = 0; i < nLen; i++)
{
AcGePoint3d ptStart, ptEnd;
ptStart = pt1 + i * vecPerp;
ptEnd = pt2 + i * vecPerp;
AcDbObjectPointer<AcDbLine> ptrLine(m_idLineArray[i], AcDb::kForWrite) ;
if (ptrLine.openStatus() != Acad::eOk)
{
continue;
}
ptrLine->setStartPoint(ptStart);
ptrLine->setEndPoint(ptEnd);
ptrLine->close();
}
}
else
{
// const char* cstr = dbObj->isA()->name();
acutPrintf(_T("\n请选择直线"));
}
return;
//AcDbObjectReactor::modified (dbObj) ;
}
// -----------------------------------------------------------------------------
void ArxMyObjReactor::erased(const AcDbObject * dbObj, Adesk::Boolean pErasing)
{
AcDbLine *pLine = AcDbLine::cast(dbObj);
if (pLine)
{
acutPrintf(_T("\n删除直线"));
}
else
{
//const char* cstr = dbObj->isA()->name();
acutPrintf(_T("\n请选择直线"));
}
}
void ArxMyObjReactor::AddEventSender( const AcDbObjectId& idObj )
{
m_idLineArray.append(idObj);
}
- 1
- 2
前往页