STDMETHODIMP CAsdkSquareWrapper::SetElementValue(
    /* [in] */ DISPID dispID,
    /* [in] */ DWORD dwCookie,
    /* [in] */ VARIANT VarIn)
{
    AcAxDocLock docLock(m_objRef.objectId(), AcAxDocLock::kNormal);
    if(docLock.lockStatus() != Acad::eOk && docLock.lockStatus() != Acad::eNoDatabase)
        return E_ACCESSDENIED;
    AcAxObjectRefPtr<AsdkSquare> pSq(&m_objRef, AcDb::kForRead);
    if (pSq.openStatus() != Acad::eOk)
            return E_ACCESSDENIED;          

    if (dispID == DISPID_CENTERPOINT) {
        AcGePoint3d acgePt;
        pSq->squareCenter(acgePt);
        AcAxPoint3d acaxPt(acgePt);
        
        acaxPt[dwCookie] = V_R8(&VarIn);
        pSq->upgradeOpen();
        pSq->setSquareCenter(acaxPt);
        Fire_Notification(DISPID_CENTERPOINT);
    }

    return S_OK;
}
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);
        }
    }
}
示例#3
0
//
//	CDbModReactor overrides
//
//
//
void CDbModReactor::objectModified(const AcDbDatabase* pDb,
                                  const AcDbObject* pDbObj)
{
	AcAxDocLock docLock(pDbObj->ownerId(), AcAxDocLock::kNormal);	
	if(docLock.lockStatus() != Acad::eOk)
		return;
    else
		objDisplay("modified", pDbObj);
}
示例#4
0
void CDbModReactor::objectErased(const AcDbDatabase* pDb,
                                const AcDbObject* pDbObj,
                                Adesk::Boolean bErased)
{
	AcAxDocLock docLock(pDbObj->ownerId(), AcAxDocLock::kNormal);	
	if(docLock.lockStatus() != Acad::eOk)
		return;
    else
	{
		char buf[40];
		sprintf(buf, "%serased", (bErased ? "" : "not "));
		objDisplay(buf, pDbObj);
	}
}
STDMETHODIMP CAsdkSquareWrapper::put_Number(short newVal)
{
    AcAxDocLock docLock(m_objRef.objectId(), AcAxDocLock::kNormal);
    if(docLock.lockStatus() != Acad::eOk && docLock.lockStatus() != Acad::eNoDatabase)
        return E_ACCESSDENIED;
    AcAxObjectRefPtr<AsdkSquare> pSq(&m_objRef, AcDb::kForWrite);
    if (pSq.openStatus() != Acad::eOk)
        return E_ACCESSDENIED;          

    pSq->setSquareId(newVal);
    Fire_Notification(DISPID_NUMBER);

    return S_OK;
}
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);
	}
}
STDMETHODIMP CAsdkSquareWrapper::put_SquareSize(double newVal)
{
    // TODO: Add your implementation code here
    AcAxDocLock docLock(m_objRef.objectId(), AcAxDocLock::kNormal);
    if(docLock.lockStatus() != Acad::eOk && docLock.lockStatus() != Acad::eNoDatabase)
        return E_ACCESSDENIED;
    AcAxObjectRefPtr<AsdkSquare> pSq(&m_objRef, AcDb::kForWrite);
    if (pSq.openStatus() != Acad::eOk)
            return E_ACCESSDENIED;          

    pSq->setSquareSideLength(newVal);
    Fire_Notification(DISPID_SQUARESIZE);

    return S_OK;
}
STDMETHODIMP CAsdkSquareWrapper::put_CenterPoint(VARIANT newVal)
{
    AcAxDocLock docLock(m_objRef.objectId(), AcAxDocLock::kNormal);
    if(docLock.lockStatus() != Acad::eOk && docLock.lockStatus() != Acad::eNoDatabase)
        return E_ACCESSDENIED;

    AcAxPoint3d pt = newVal;

    AcAxObjectRefPtr<AsdkSquare> pSq(&m_objRef, AcDb::kForWrite, Adesk::kTrue);
    if (pSq.openStatus() != Acad::eOk)
            return E_ACCESSDENIED;          
        
    pSq->setSquareCenter(pt);
    Fire_Notification(DISPID_CENTERPOINT);

    return S_OK;
}
void
ArxDbgUiTdcWblockClone::OnWblockBlkDef()
{
        // get the block we're suppose to be wblocking
    int index = m_puBlockDef.GetCurSel();
    ASSERT(index != CB_ERR);

    CString str;
    AcDbObjectId blkDefId;
    if (!m_blockList.GetAtIndex(index, str, blkDefId)) {
        ASSERT(0);
        return;
    }

    AcDbDatabase* sourceDb = getSourceDb();
    ASSERT(sourceDb != NULL);

        // lock the document we are wblocking from
    ArxDbgDocLockWrite docLock(sourceDb);
    if (docLock.lock() != Acad::eOk)
        return;

    // restore database to non-xref state (xes returns eOk if this
    // was necessary, and something else if it wasn't).
    Acad::ErrorStatus xes = sourceDb->restoreOriginalXrefSymbols();
    AcDbDatabase* tmpDb = NULL;
    Acad::ErrorStatus es = sourceDb->wblock(tmpDb, blkDefId);
    if (xes ==Acad::eOk)
        xes = sourceDb->restoreForwardingXrefSymbols();
    if (es == Acad::eOk) {
        doInsertOption(tmpDb);

        delete tmpDb;   // we're done with it
    }
    else {
        CString str;
        str.Format(_T("Wblock failed: %s"), ArxDbgUtils::rxErrorStr(es));
        ArxDbgUtils::stopAlertBox(str);

        delete tmpDb;   // yes, a failed wblock can leave a partially created database!
                        // so always delete it.
    }
}
void
ArxDbgUiTdcWblockClone::OnWblockObjects() 
{
    AcDbDatabase* sourceDb = getSourceDb();
    ASSERT(sourceDb != NULL);

    AcDbObjectIdArray objIds;
    m_cloneSet.getObjectsForDatabase(sourceDb, objIds);

    // unfortunately, wblock is a little restrictive on what
    // it will allow to be cloned automatically.  So, we factor
    // out all the entities and allow those to be cloned, and
    // then our ArxDbgAppEditorReactor will handle the rest by hand.
    AcDbObjectIdArray okToClone, mustCloneByHand;
    divideCloneSet(objIds, mustCloneByHand, okToClone);

    // lock the document we are wblocking from
    ArxDbgDocLockWrite docLock(sourceDb);
    if (docLock.lock() != Acad::eOk)
        return;
    // restore database to non-xref state (xes returns eOk if this
    // was necessary, and something else if it wasn't).
    Acad::ErrorStatus xes = sourceDb->restoreOriginalXrefSymbols();
    AcDbDatabase* tmpDb = NULL;
    Acad::ErrorStatus es = sourceDb->wblock(tmpDb, okToClone, m_basePt);
    if (xes ==Acad::eOk)
        xes = sourceDb->restoreForwardingXrefSymbols();
    if (es == Acad::eOk) {
        doInsertOption(tmpDb);

        delete tmpDb;   // we're done with it
    }
    else {
        CString str;
        str.Format(_T("Wblock failed: %s"), ArxDbgUtils::rxErrorStr(es));
        ArxDbgUtils::stopAlertBox(str);

        delete tmpDb;   // yes, a failed wblock can leave a partially created database!
                        // so always delete it.
    }
}
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
ArxDbgUiTdcWblockClone::OnWblockAll()
{
    UpdateData(TRUE);

    AcDbDatabase* sourceDb = getSourceDb();
    ASSERT(sourceDb != NULL);

    if (m_doForceCopy)
        sourceDb->forceWblockDatabaseCopy();

        // lock the document we are wblocking from
    ArxDbgDocLockWrite docLock(sourceDb);
    if (docLock.lock() != Acad::eOk)
        return;

    // restore database to non-xref state (xes returns eOk if this
    // was necessary, and something else if it wasn't).
    Acad::ErrorStatus xes = sourceDb->restoreOriginalXrefSymbols();
    AcDbDatabase* tmpDb = NULL;
    Acad::ErrorStatus es = sourceDb->wblock(tmpDb);
    if (xes ==Acad::eOk)
        xes = sourceDb->restoreForwardingXrefSymbols();
    if (es == Acad::eOk) {
        doInsertOption(tmpDb);

        delete tmpDb;   // we're done with it
    }
    else {
        CString str;
        str.Format(_T("Wblock failed: %s"), ArxDbgUtils::rxErrorStr(es));
        ArxDbgUtils::stopAlertBox(str);

        delete tmpDb;   // yes, a failed wblock can leave a partially created database!
                        // so always delete it.
    }
}
HRESULT CAsdkSquareWrapper::AddToDb(AcDbObjectId& objId, AcDbObjectId ownerId, TCHAR* keyName)
{
    try 
    {
        AcAxDocLock docLock(ownerId);

        Acad::ErrorStatus es;
        AcAxObjectRefPtr<AsdkSquare> pSq(&m_objRef, AcDb::kForRead);

        AcDbBlockTableRecordPointer pBlockTableRecord(ownerId, AcDb::kForWrite);
        if((es = pBlockTableRecord.openStatus()) != Acad::eOk)
            throw es;

        if((es = pBlockTableRecord->appendAcDbEntity(objId, pSq.object())) != Acad::eOk)
            throw es;
    }
    catch(const Acad::ErrorStatus)
    {
        //we can becaome more sophisticated 
        return Error(L"Failed to add square to database", IID_IAsdkSquareWrapper ,E_FAIL);
    }

    return SetObjectId(objId);
}
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);
	}
}