本文整理汇总了C++中AcDbObject::deepClone方法的典型用法代码示例。如果您正苦于以下问题:C++ AcDbObject::deepClone方法的具体用法?C++ AcDbObject::deepClone怎么用?C++ AcDbObject::deepClone使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AcDbObject
的用法示例。
在下文中一共展示了AcDbObject::deepClone方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: idPair
void
ArxDbgAppEditorReactor::insertCloneMergeDicts(AcDbDictionary* srcDict,
AcDbDictionary* destDict, AcDbIdMapping& idMap)
{
AcDbObjectId tmpObjId;
AcDbObject* objToClone;
AcDbObject* clonedObj;
AcDbDictionaryIterator* iter;
iter = srcDict->newIterator();
for (; !iter->done(); iter->next()) {
iter->getObject(objToClone, AcDb::kForRead);
// if an entry with this name is found already, don't clone
// it, add to the idMap to say that this one got translated
// to one that already exists
const char *pName = iter->name();
if (destDict->getAt(pName, tmpObjId) == Acad::eOk) {
AcDbIdPair idPair(objToClone->objectId(), tmpObjId, true, false, true);
idMap.assign(idPair);
objToClone->close();
}
else {
// doesn't exist yet in the destination dict, so clone and
// place it there.
clonedObj = NULL;
objToClone->deepClone(destDict, clonedObj, idMap);
// INSERT usually uses a method of cloning
// called CheapClone, where it "moves" objects
// into the destination database instead of
// actually cloning them. When this happens,
// objToClone and clonedObj are pointers to the
// same object. We only want to close pObj
// here if it really is a different object.
if (objToClone != clonedObj)
objToClone->close();
if (clonedObj) {
destDict->setAt(pName, clonedObj, tmpObjId);
clonedObj->close();
}
}
}
delete iter;
}
示例2: dbox
Acad::ErrorStatus
ArxDbgDbEntity::deepClone(AcDbObject* pOwner,
AcDbObject*& pClonedObject,
AcDbIdMapping& idMap,
Adesk::Boolean isPrimary) const
{
// You should always pass back pClonedObject == NULL
// if, for any reason, you do not actually clone it
// during this call. The caller should pass it in
// as NULL, but to be safe, we set it here as well.
pClonedObject = NULL;
if (ArxDbgOptions::m_instance.m_showDeepCloneDetails) {
CString titleStr, tmpStr;
titleStr.Format(_T("Beginning -- deepClone: %s"),
ArxDbgUtils::objToClassAndHandleStr(const_cast<ArxDbgDbEntity*>(this), tmpStr));
ArxDbgUiTdmIdMap dbox(&idMap, acedGetAcadDwgView(), titleStr);
dbox.DoModal();
}
AcDb::DeepCloneType type = idMap.deepCloneContext();
// if we know everything will be cloned for us, just let
// the base class do everything for us.
if ((type == AcDb::kDcInsert) ||
(type == AcDb::kDcInsertCopy) ||
(type == AcDb::kDcExplode))
return AcDbEntity::deepClone(pOwner, pClonedObject, idMap, isPrimary);
// following case happens when doing a AcDbDatabase::deepCloneObjects()
// and the owner happens to be the same... then its really like a
// kDcCopy, otherwise deepCloneObjects() is like a kDcBlock
if (type == AcDb::kDcObjects) {
if (ownerId() == pOwner->objectId())
type = AcDb::kDcCopy;
else
type = AcDb::kDcBlock;
}
// now ask derived classes what references they want cloned for them
AcDbObjectIdArray refEntIds;
AcDbIntArray refTypes;
getCloneReferences(type, refEntIds, refTypes);
ASSERT(refEntIds.length() == refTypes.length());
// if derived class doesn't have any references to take care of, then
// we will just let the AcDbEntity::deepClone() take care of things.
if (refEntIds.isEmpty())
return AcDbEntity::deepClone(pOwner, pClonedObject, idMap, isPrimary);
// If this object is in the idMap and is already
// cloned, then return.
bool tmpIsPrimary = isPrimary ? true : false; // get around compiler performance warning
AcDbIdPair idPair(objectId(), AcDbObjectId::kNull, false, tmpIsPrimary);
if (idMap.compute(idPair) && (idPair.value() != NULL))
return Acad::eOk;
// STEP 1:
// Create the clone
//
AcDbObject *pClone = (AcDbObject*)isA()->create();
if (pClone != NULL)
pClonedObject = pClone; // set the return value
else
return Acad::eOutOfMemory;
// STEP 2:
// Append the clone to its new owner. In this example,
// we know that we are derived from AcDbEntity, so we
// can expect our owner to be an AcDbBlockTableRecord,
// unless we have set up an ownership relationship with
// another of our objects. In that case, we need to
// establish how we connect to that owner in our own
// way. This sample shows a generic method using
// setOwnerId().
//
AcDbBlockTableRecord *pBTR = AcDbBlockTableRecord::cast(pOwner);
if (pBTR != NULL) {
AcDbEntity* ent = AcDbEntity::cast(pClone);
pBTR->appendAcDbEntity(ent);
}
else {
if (isPrimary)
return Acad::eInvalidOwnerObject;
// Some form of this code is only necessary if
// anyone has set up an ownership for our object
// other than with an AcDbBlockTableRecord.
//
pOwner->database()->addAcDbObject(pClone);
pClone->setOwnerId(pOwner->objectId());
}
// STEP 3:
// Now we copy our contents to the clone. This is done
// using an AcDbDeepCloneFiler. This filer keeps a
// list of all AcDbHardOwnershipIds and
// AcDbSoftOwnershipIds we, and any classes we derive
// from, have. This list is then used to know what
// additional, "owned" objects need to be cloned below.
//.........这里部分代码省略.........