当前位置: 首页>>代码示例>>C++>>正文


C++ AcDbObjectIdArray::removeLast方法代码示例

本文整理汇总了C++中AcDbObjectIdArray::removeLast方法的典型用法代码示例。如果您正苦于以下问题:C++ AcDbObjectIdArray::removeLast方法的具体用法?C++ AcDbObjectIdArray::removeLast怎么用?C++ AcDbObjectIdArray::removeLast使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AcDbObjectIdArray的用法示例。


在下文中一共展示了AcDbObjectIdArray::removeLast方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

//When an new entity is added, set its draw order based on the draw order of other entities on the same layer.
void
adskMyDbReactor::objectAppended(const AcDbDatabase* db, const AcDbObject* pObj)
{
	AcDbEntity * pEnt = AcDbEntity::cast(pObj);
	Acad::ErrorStatus es;
	if (pEnt != NULL)
	{
		AcDbBlockTable *pBT = NULL;
		AcDbBlockTableRecord *pBTR	= NULL;
		
		//use transaction since the datbase is still open for write here.
		es=actrTransactionManager->enableGraphicsFlush(true);
		AcTransaction *pTrans = actrTransactionManager->startTransaction() ;
		
		if(!pTrans)
		{
			acutPrintf("\nCan't start transaction!");
			return;
		}
		AcDbObject *pObj = NULL ;
		AcDbDatabase *pDb = NULL;
		AcDbObjectId modelSpaceId;
		pDb = AcDbDatabase::cast(db);
		
		//get AcDbBlockTable for read
		if(Acad::eOk != pDb->getBlockTable(pBT, AcDb::kForRead))
		{
			acutPrintf("can't open block table for read");
			actrTransactionManager->abortTransaction();
			return;
		}
		
		//get the model space object id
		if(Acad::eOk != pBT->getAt( ACDB_MODEL_SPACE, modelSpaceId))
		{
			acutPrintf("\ncan't get model space Id");
			actrTransactionManager->abortTransaction();
			pBT->close();
			return;
		}
		
		pBT->close();
		
		
		//get model space block record for write from transaction
		if (Acad::eOk != pTrans->getObject((AcDbObject*&)pBTR, modelSpaceId, AcDb::kForWrite))
		{
			acutPrintf("\ncan't open model space block table record for write");
			actrTransactionManager->abortTransaction();
			return;
		}
		
		AcDbObjectIdArray eIds;
		
		//get AcDbSortEntsTable
		AcDbSortentsTable *pSortTab = NULL;
		if(Acad::eOk != pBTR->getSortentsTable(pSortTab, AcDb::kForWrite, false))
		{
			acutPrintf("\ncan't get AcDbSortEntsTable for write");
			actrTransactionManager->abortTransaction();
			return;
		}
		
		//put objectIds of all the entities in an Id array.The order of objectIds in the array is the
		//same as their draworders from bottom to top.The newly created entity is always at the top and the last item
		//in the array
		if(Acad::eOk != pSortTab->getFullDrawOrder(eIds))
		{
			acutPrintf("\ncan't get full draworder");
			pSortTab->close();
			actrTransactionManager->abortTransaction();
			return;
		}
		AcDbEntity *pRefEnt = NULL;
		//iterate through the entities in the order of their draworders. If an entity on the same layer is found
		//insert the newly created entity before it.
		int i;
		for(i =0; i<eIds.length(); i++)
		{
			es = pTrans->getObject((AcDbObject*&)pRefEnt, eIds.at(i), AcDb::kForRead);
			if(pRefEnt->layerId() == pEnt->layerId())
				break;
		}	
		eIds.insertAt(i, pEnt->objectId());
		//remove the newly created entity from the end of the array
		eIds.removeLast();
		//reset draworder
		es = pSortTab->setRelativeDrawOrder(eIds);
		pSortTab->close();
		es=actrTransactionManager->endTransaction();
		actrTransactionManager->flushGraphics();

		//set flag for regen
		gbDraworderChanged = true;	
	}

}
开发者ID:kevinzhwl,项目名称:ObjectARXMod,代码行数:98,代码来源:adskMyDbReactor.cpp


注:本文中的AcDbObjectIdArray::removeLast方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。