void ArxDbgUiTdcWblockClone::doInsertOption(AcDbDatabase* tmpDb) { AcDbDatabase* destDb = getDestDb(); if (destDb == NULL) { ArxDbgUiTdmDatabase dbox(tmpDb, this, _T("Wblock'd Database")); dbox.DoModal(); doSaveOption(tmpDb); } else { Acad::ErrorStatus es; // lock the document we are inserting into ArxDbgDocLockWrite docLock(destDb); if (docLock.lockAndSetCurrent() != Acad::eOk) return; es = destDb->insert(AcGeMatrix3d::kIdentity, tmpDb, false); if (es == Acad::eOk) { ArxDbgUiTdmDatabase dbox(destDb, this, _T("Wblock/Insert Database")); dbox.DoModal(); doSaveOption(destDb); } else { CString str; str.Format(_T("Insert failed: %s"), ArxDbgUtils::rxErrorStr(es)); ArxDbgUtils::stopAlertBox(str); } } }
void ArxDbgUiTdcObjReactorsBase::doStateDbox(const AcDbObject* obj, LPCTSTR dboxTitle) { // purposely throw away const for testing purposes ArxDbgUiDlgObjState dbox(acedGetAcadDwgView(), const_cast<AcDbObject*>(obj), dboxTitle); dbox.DoModal(); }
void ArxDbgUiTdcCloneSet::OnShow() { ArxDbgUiTdmObjects dbox(m_objIds, this, _T("Objects in Clone Set")); dbox.DoModal(); displayObjList(); }
void ArxDbgEditorReactor::otherWblock(AcDbDatabase* pTo, AcDbIdMapping& idMap, AcDbDatabase* pFrom) { printReactorMessage(_T("Other Wblock"), pTo, pFrom); if (m_showDetails) { ArxDbgUiTdmIdMap dbox(&idMap, acedGetAcadDwgView(), _T("Other Wblock")); dbox.DoModal(); } }
void ArxDbgEditorReactor::objectsLazyLoaded(const AcDbObjectIdArray& idArray) { printReactorMessage(_T("Objects Lazy Loaded")); if (m_showDetails) { ArxDbgUiTdmObjects dbox(idArray, acedGetAcadDwgView(), _T("Objects Lazy Loaded")); dbox.DoModal(); } }
void ArxDbgEditorReactor::endDeepClone(AcDbIdMapping& idMap) { printReactorMessage(_T("End Deep Clone")); if (m_showDetails) { ArxDbgUiTdmIdMap dbox(&idMap, acedGetAcadDwgView(), _T("End Deep Clone")); dbox.DoModal(); } }
void ArxDbgEditorReactor::beginWblockObjects(AcDbDatabase* pFrom, AcDbIdMapping& idMap) { printReactorMessage(_T("Begin Wblock Objects"), pFrom); if (m_showDetails) { ArxDbgUiTdmIdMap dbox(&idMap, acedGetAcadDwgView(), _T("Begin Wblock Objects")); dbox.DoModal(); } }
void ArxDbgEditorReactor::beginDeepCloneXlation(AcDbIdMapping& idMap, Acad::ErrorStatus* pRetStatus) { printReactorMessage(_T("Begin Deep Clone Translation")); if (m_showDetails) { ArxDbgUiTdmIdMap dbox(&idMap, acedGetAcadDwgView(), _T("Begin Deep Clone Xlation")); dbox.DoModal(); } }
void ScriptEditorPane::OnReconnect(wxCommandEvent &event) { wxASSERT(execution == NULL); // must not be executing ConnectDialogue dbox(this); if (db != NULL) dbox.Suggest(server); if (dbox.ShowModal() == wxID_CANCEL) return; SetConnection(dbox.GetServerParameters(), dbox.GetConnection()); }
void ArxDbgDatabaseReactor::proxyResurrectionCompleted(const AcDbDatabase* db, const char* appname, AcDbObjectIdArray& objects) { printReactorMessage(db, _T("Proxy Resurrection Completed"), appname); if (m_showDetails) { CString str; str.Format(_T("Resurrected Proxies: %s"), appname); ArxDbgUiTdmObjects dbox(objects, acedGetAcadDwgView(), str); dbox.DoModal(); } }
void ArxDbgEdInputContextReactor::endSSGet(Acad::PromptStatus returnStatus, const AcArray<AcDbObjectId>& ss) { printReactorMessage(_T("End SSGet")); if (printDetails()) { CString str; printReturnStatus(returnStatus); ArxDbgUiTdmObjects dbox(ss, acedGetAcadDwgView(), _T("SSGet Set")); dbox.DoModal(); } }
void ArxDbgUiTdcInsert::OnInsertBlkDef() { CString blkName; m_ebDestName1.GetWindowText(blkName); if (!acdbSNValid(blkName, false)) { CString str; str.Format(_T("%s is not a valid block name."), blkName); ArxDbgUtils::alertBox(str); return; } UpdateData(TRUE); bool isExternal; AcDbDatabase* sourceDb = getSourceDb(isExternal); AcDbDatabase* destDb = getDestDb(); ASSERT(sourceDb != destDb); Acad::ErrorStatus es; // lock the document we are inserting into ArxDbgDocLockWrite docLock(destDb); if (docLock.lockAndSetCurrent() != Acad::eOk) return; bool preserveSrcDb = intToBool(m_preserveOriginalDb); if (!preserveSrcDb && !isExternal) { ArxDbgUtils::alertBox(_T("Ignoring setting of \"Preserve source database\" since destroying\na database associated with a Document would be harsh.")); preserveSrcDb = true; } AcDbObjectId blkId; es = destDb->insert(blkId, blkName, sourceDb, preserveSrcDb); if (es == Acad::eOk) { ArxDbgUiTdmDatabase dbox(destDb, this, _T("Inserted Database")); dbox.DoModal(); doSaveOption(destDb); if (isExternal && !preserveSrcDb) reloadRaidedExternalDwg(sourceDb); } else { CString str; str.Format(_T("Insert failed: %s"), ArxDbgUtils::rxErrorStr(es)); ArxDbgUtils::stopAlertBox(str); } }
void ArxDbgEditorReactor::beginDeepClone(AcDbDatabase* pTo, AcDbIdMapping& idMap) { CString str, str2; ArxDbgUtils::deepCloneContextToStr(idMap.deepCloneContext(), str2); str.Format(_T("Begin Deep Clone: context = %s"), static_cast<LPCTSTR>(str2)); printReactorMessage(str, pTo); if (m_showDetails) { ArxDbgUiTdmIdMap dbox(&idMap, acedGetAcadDwgView(), _T("Begin Deep Clone")); dbox.DoModal(); } }
void ArxDbgUiTdcCloneSet::OnBrowse() { int index = m_lbDbList.GetCurSel(); if (index == LB_ERR) { ASSERT(0); return; } AcDbDatabase* curDb = static_cast<AcDbDatabase*>(m_dbPtrs[index]); ArxDbgUiTdmDatabase dbox(curDb, this); dbox.DoModal(); displayObjList(); }
BOOL ArxDbgUtils::getFname(LPCTSTR title, LPCTSTR ext, LPCTSTR defFname, CString& fname) { CFileDialog dbox(TRUE, ext, defFname); // add title if one was specified if (title != NULL) dbox.m_ofn.lpstrTitle = title; if (dbox.DoModal() == IDOK) { fname = dbox.GetPathName(); return(TRUE); } else return(FALSE); }
void ScriptEditorPane::Connect(const ServerConnection &server_, const wxString &dbname) { wxASSERT(db == NULL); server = server_; ConnectDialogue dbox(this); dbox.DoInitialConnection(server, dbname.empty() ? server.globalDbName : dbname); if (dbox.ShowModal() == wxID_CANCEL) return; db = dbox.GetConnection(); db->Relabel(_T("Query")); state = Idle; ShowConnectedStatus(); db->AddWork(new SetupNoticeProcessorWork(this)); db->SetNotificationReceiver(¬ificationReceiver); UpdateStateInUI(); }
void PqwxFrame::OnOpenScript(wxCommandEvent& event) { bool suggest = haveCurrentServer; ServerConnection suggestServer; wxString suggestDatabase; if (suggest) { suggestServer = currentServer; suggestDatabase = currentDatabase; } wxFileDialog dbox(this, _("Open File"), wxEmptyString, wxEmptyString, _("SQL files (*.sql)|*.sql")); dbox.CentreOnParent(); if (dbox.ShowModal() == wxID_OK) { ScriptEditorPane *editor = documentsBook->OpenNewScript(); editor->OpenFile(dbox.GetPath()); if (suggest) editor->Connect(suggestServer, suggestDatabase); editor->SetFocus(); } }
void ArxDbgUiTdcInsert::OnInsertDb() { UpdateData(TRUE); bool isExternal; AcDbDatabase* sourceDb = getSourceDb(isExternal); AcDbDatabase* destDb = getDestDb(); ASSERT(sourceDb != destDb); Acad::ErrorStatus es; // lock the document we are inserting into ArxDbgDocLockWrite docLock(destDb); if (docLock.lockAndSetCurrent() != Acad::eOk) return; bool preserveSrcDb = intToBool(m_preserveOriginalDb); if (!preserveSrcDb && !isExternal) { ArxDbgUtils::alertBox(_T("Ignoring setting of \"Preserve source database\" since destroying\na database associated with a Document would be harsh.")); preserveSrcDb = true; } es = destDb->insert(AcGeMatrix3d::kIdentity, sourceDb, preserveSrcDb); if (es == Acad::eOk) { ArxDbgUiTdmDatabase dbox(destDb, this, _T("Inserted Database")); dbox.DoModal(); doSaveOption(destDb); if (isExternal && !preserveSrcDb) reloadRaidedExternalDwg(sourceDb); } else { CString str; str.Format(_T("Insert failed: %s"), ArxDbgUtils::rxErrorStr(es)); ArxDbgUtils::stopAlertBox(str); } }
void ArxDbgUiTdcObjReactorsBase::doStateDbox(const AcDbObjectId& objId, LPCTSTR dboxTitle) { ArxDbgUiDlgObjState dbox(acedGetAcadDwgView(), objId, dboxTitle); dbox.DoModal(); }
void ArxDbgUiTdcInsert::OnTransferBlkDef() { // get the block we're suppose to be wblocking int index = m_puBlockDef.GetCurSel(); ASSERT(index != CB_ERR); CString srcBlkName; AcDbObjectId blkDefId; if (!m_blockList.GetAtIndex(index, srcBlkName, blkDefId)) { ASSERT(0); return; } // get name of destination block name CString destBlkName; m_ebDestName2.GetWindowText(destBlkName); if (!acdbSNValid(destBlkName, false)) { CString str; str.Format(_T("%s is not a valid block name."), destBlkName); ArxDbgUtils::alertBox(str); return; } UpdateData(TRUE); bool isExternal; AcDbDatabase* sourceDb = getSourceDb(isExternal); AcDbDatabase* destDb = getDestDb(); ASSERT(sourceDb != destDb); // lock the document we are inserting into ArxDbgDocLockWrite docLock(destDb); if (docLock.lockAndSetCurrent() != Acad::eOk) return; // lock the document we are inserting from ArxDbgDocLockWrite docLock2(sourceDb); if (docLock2.lock() != Acad::eOk) return; bool preserveSrcDb = intToBool(m_preserveOriginalDb); if (!preserveSrcDb && !isExternal) { ArxDbgUtils::alertBox(_T("Ignoring setting of \"Preserve source database\" since destroying\na database associated with a Document would be harsh.")); preserveSrcDb = true; } AcDbObjectId blkId; Acad::ErrorStatus es; es = destDb->insert(blkId, srcBlkName, destBlkName, sourceDb, preserveSrcDb); if (es == Acad::eOk) { ArxDbgUiTdmDatabase dbox(destDb, this, _T("Inserted Database")); dbox.DoModal(); doSaveOption(destDb); if (isExternal && !preserveSrcDb) reloadRaidedExternalDwg(sourceDb); } else { CString str; str.Format(_T("Insert failed: %s"), ArxDbgUtils::rxErrorStr(es)); ArxDbgUtils::stopAlertBox(str); } }
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. // AcDbDeepCloneFiler filer; dwgOut(&filer); // STEP 4: // Rewind the filer and read the data into the clone. // filer.seek(0L, AcDb::kSeekFromStart); pClone->dwgIn(&filer); // STEP 5: // This must be called for all newly created objects // in deepClone. It is turned off by endDeepClone() // after it has translated the references to their // new values. // pClone->setAcDbObjectIdsInFlux(); // STEP 6: // Add the new information to the idMap. We can use // the idPair started above. // idPair.setValue(pClonedObject->objectId()); idPair.setIsCloned(Adesk::kTrue); idMap.assign(idPair); // STEP 7: // Using the filer list created above, find and clone // any owned objects. // AcDbObject *pSubObject; AcDbObject *pClonedSubObject; AcDbObjectId id; Acad::ErrorStatus es; while (filer.getNextOwnedObject(id)) { // Open the object and clone it. Note that we now // set "isPrimary" to kFalse here because the object // is being cloned, not as part of the primary set, // but because it is owned by something in the // primary set. es = acdbOpenAcDbObject(pSubObject, id, AcDb::kForRead); if (es != Acad::eOk) continue; // could have been NULL or erased pClonedSubObject = NULL; pSubObject->deepClone(pClonedObject, pClonedSubObject, idMap, Adesk::kFalse); // If this is a kDcInsert context, the objects // may be "cheapCloned". In this case, they are // "moved" instead of cloned. The result is that // pSubObject and pClonedSubObject will point to // the same object. So, we only want to close // pSubObject if it really is a different object // than its clone. if (pSubObject != pClonedSubObject) pSubObject->close(); // The pSubObject may either already have been // cloned, or for some reason has chosen not to be // cloned. In that case, the returned pointer will // be NULL. Otherwise, since we have no immediate // use for it now, we can close the clone. if (pClonedSubObject != NULL) pClonedSubObject->close(); } // clone the referenced entities AcDbObject* ent; int len = refEntIds.length(); for (int i=0; i<len; i++) { if (refTypes[i] == kClone) { es = acdbOpenAcDbObject(ent, refEntIds[i], AcDb::kForRead); if (es == Acad::eOk) { pClonedSubObject = NULL; es = ent->deepClone(pOwner, pClonedSubObject, idMap, Adesk::kTrue); if (es == Acad::eOk) { // see comment above about cheap clone if (ent != pClonedSubObject) ent->close(); if (pClonedSubObject != NULL) pClonedSubObject->close(); } } } // this case is needed for RefEdit so we can pass its validation // test when editing a blockReference. We don't actually clone it // but we add it to the map so it thinks it got cloned and is therefore // a valid "Closed Set" of objects. else if (refTypes[i] == kFakeClone) { AcDbIdPair idPair(refEntIds[i], refEntIds[i], false, false, true); idMap.assign(idPair); } } if (ArxDbgOptions::m_instance.m_showDeepCloneDetails) { CString titleStr, tmpStr; titleStr.Format(_T("End -- deepClone: %s"), ArxDbgUtils::objToClassAndHandleStr(const_cast<ArxDbgDbEntity*>(this), tmpStr)); ArxDbgUiTdmIdMap dbox(&idMap, acedGetAcadDwgView(), titleStr); dbox.DoModal(); } // Leave pClonedObject open for the caller return Acad::eOk; }
void cmdSnoopClasses() { ArxDbgUiDlgClassDict dbox(acedGetAcadDwgView()); dbox.DoModal(); }
Acad::ErrorStatus ArxDbgDbEntity::wblockClone(AcRxObject* pOwner, AcDbObject*& pClone, AcDbIdMapping& idMap, Adesk::Boolean isPrimary) const { if (ArxDbgOptions::m_instance.m_showWblockCloneDetails) { CString titleStr, tmpStr; titleStr.Format(_T("Beginning -- wblockClone: %s"), ArxDbgUtils::objToClassAndHandleStr(const_cast<ArxDbgDbEntity*>(this), tmpStr)); ArxDbgUiTdmIdMap dbox(&idMap, acedGetAcadDwgView(), titleStr); dbox.DoModal(); } AcDb::DeepCloneType type = idMap.deepCloneContext(); // if xrefInsert or xrefBind, we know everything will // be cloned, so just let normal routine handle this if ((type == AcDb::kDcXrefBind) || (type == AcDb::kDcXrefInsert)) { return AcDbEntity::wblockClone(pOwner, pClone, idMap, isPrimary); } // if we've already been cloned, just return AcDbIdPair idPair(objectId(), AcDbObjectId::kNull, true); if (idMap.compute(idPair) && (idPair.value() != AcDbObjectId::kNull)) { return Acad::eOk; } // If isPrimary is kTrue, then override the default cloning // within our own cloning, which would set it to kFalse, // by cloning our referenced entity first. if (isPrimary) { // now ask derived classes what references they want cloned for them AcDbObjectIdArray refEntIds; AcDbIntArray refTypes; getCloneReferences(type, refEntIds, refTypes); ASSERT(refEntIds.length() == refTypes.length()); // clone each entity we reference first and change the value // of isPrimary to fake it out. Since we clone these first, // when the normal wblockClone is called, it will see that // they are already in the set of cloned objects and will not // try to clone it again. AcDbEntity* ent; Acad::ErrorStatus es; int len = refEntIds.length(); for (int i=0; i<len; i++) { if (refTypes[i] == kClone) { es = acdbOpenAcDbEntity(ent, refEntIds[i], AcDb::kForRead); if (es == Acad::eOk) { // this method only works if they come from the same block // (which SHOULD always be the case!) if (blockId() == ent->blockId()) { // Use the same owner, and pass in the same isPrimary value AcDbObject* pSubClone = NULL; es = ent->wblockClone(pOwner, pSubClone, idMap, Adesk::kTrue); if (pSubClone != NULL) pSubClone->close(); if (es != Acad::eOk) { ASSERT(0); } } else { ASSERT(0); } ent->close(); } } } } // Now we can clone ourselves via calling our parent's method. Acad::ErrorStatus es = AcDbEntity::wblockClone(pOwner, pClone, idMap, isPrimary); if (ArxDbgOptions::m_instance.m_showWblockCloneDetails) { CString titleStr, tmpStr; titleStr.Format(_T("End -- wblockClone: %s"), ArxDbgUtils::objToClassAndHandleStr(const_cast<ArxDbgDbEntity*>(this), tmpStr)); ArxDbgUiTdmIdMap dbox(&idMap, acedGetAcadDwgView(), titleStr); dbox.DoModal(); } return es; }