ObjectARX, AutoCAD. Среда программирования библиотеки C++


         

SubErase, subOpen, subClose, and subCancel - часть 7


double j = 1.1;

AcGeMatrix3d scale;

for (int i = 0; i < ellipseCount; i++, j += 0.1) {

scale.setToScaling(j, pEllipse->center());

scale.entry[2][2] = 1.0; // Z scaling == 1

// getTransformed copy uses this->clone() to create

// a new object, which the ent pointer is assigned

// to point to. Therefore, ent should NOT point to an

// existing entity or there will be a memory leak!

//

// Since this->clone() is used, the AsdkEllipse class

// must override this member function to

// be sure that an AsdkEllipse is created instead

// of just an AcDbEllipse.

//

AsdkEllipse *pNextEllipse;

((AsdkEllipse*)ellipses[0])->getTransformedCopy(

scale, (AcDbEntity*&)pNextEllipse);

ellipses.append(pNextEllipse);

}

AcDbBlockTable *pBlockTable;

acdbHostApplicationServices()->workingDatabase()

->getSymbolTable(pBlockTable, AcDb::kForRead);

AcDbBlockTableRecord *pBlockTableRecord;

pBlockTable->getAt(ACDB_MODEL_SPACE, pBlockTableRecord,

AcDb::kForWrite);

pBlockTable->close();

AcDbObjectIdArray ellipseIds;

AcDbObjectId tempId;

for (i = 0; i < ellipses.length(); i++) {

pBlockTableRecord->appendAcDbEntity(tempId,

(AsdkEllipse*)ellipses[i]);

ellipseIds.append(tempId);

}

pBlockTableRecord->close();

// Set up the hard pointers and close the ellipses.

//

for (i = 0; i < ellipses.length(); i++) {

// Add in all the IDs.

//

((AsdkEllipse*)ellipses[i])

->setEllipseIds(ellipseIds);

// Now remove the object ID of the "*this" ellipse

// so it doesn’t reference itself.

//

((AsdkEllipse*)ellipses[i])->removeId(

((AsdkEllipse*)ellipses[i])->objectId());

((AsdkEllipse*)ellipses[i])->close();

}

}

void

initApp()

{

acedRegCmds->addCommand("ASDK_ELLIPSES",

"ASDK_ELLIPSES", "ELLIPSES",

ACRX_CMD_MODAL, createEllipses);

AsdkEllipse::rxInit();

acrxBuildClassHierarchy();

}

void

unloadApp()

{

acedRegCmds->removeGroup("ASDK_ELLIPSES");

// Remove the AsdkEllipse class from the ACRX runtime

// class hierarchy. If this is done while the database is

// still active, it should cause all objects of class

// AsdkEllipse to be turned into proxies.

//

deleteAcRxClass(AsdkEllipse::desc());

}

extern "C" AcRx::AppRetCode

acrxEntryPoint(AcRx::AppMsgCode msg, void* appId)

{

switch (msg) {

case AcRx::kInitAppMsg:

acrxDynamicLinker->unlockApplication(appId);

acrxDynamicLinker->registerAppMDIAware(appId);

initApp();

break;

case AcRx::kUnloadAppMsg:

unloadApp();

}

return AcRx::kRetOK;

}




Содержание  Назад  Вперед