/////////////////////////////////////////////////////////////////////////////// // Copyright (C) 2002-2025, Open Design Alliance (the "Alliance"). // All rights reserved. // // This software and its documentation and related materials are owned by // the Alliance. The software may only be incorporated into application // programs owned by members of the Alliance, subject to a signed // Membership Agreement and Supplemental Software License Agreement with the // Alliance. The structure and organization of this software are the valuable // trade secrets of the Alliance and its suppliers. The software is also // protected by copyright law and international treaty provisions. Application // programs incorporating this software must include the following statement // with their copyright notices: // // This application incorporates Open Design Alliance software pursuant to a license // agreement with Open Design Alliance. // Open Design Alliance Copyright (C) 2002-2025 by Open Design Alliance. // All rights reserved. // // By use of this software, its documentation or related materials, you // acknowledge and accept the above terms. /////////////////////////////////////////////////////////////////////////////// #include "OdaCommon.h" #include "DbBlockReference.h" #include "DbBlockTableRecord.h" #include "DbBlockTable.h" #include "DbAssocGeomDependency.h" #include "DbImpAssocRadialDimActionBody.h" #include "DbAssocNetwork.h" #include "DbRadialDimension.h" #include "ExDimAssoc.h" OdDbImpAssocRadialDimActionBody::OdDbImpAssocRadialDimActionBody() { // CORE-14828 m_version = 0; // m_ActionBodyType = kRadialDim; m_paramBasedActionBody = new OdDbImpAssocParamBasedActionBody(true); } OdDbImpAssocRadialDimActionBody::~OdDbImpAssocRadialDimActionBody() { } OdResult OdDbImpAssocRadialDimActionBody::dwgInFields(OdDbDwgFiler* pFiler) { OdResult res = OdDbImpAssocAnnotationActionBody::dwgInFields(pFiler); if (res != eOk) return res; m_version = pFiler->rdInt16(); ODA_ASSERT_ONCE_X(MDSO, !m_version); m_centerPointRefActionParamId = pFiler->rdSoftPointerId(); return res; } void OdDbImpAssocRadialDimActionBody::dwgOutFields(OdDbDwgFiler* pFiler) const { OdDbImpAssocAnnotationActionBody::dwgOutFields(pFiler); //m_paramBasedActionBody->dwgOutFields(pFiler); ODA_ASSERT_ONCE_X(MDSO, !m_version); pFiler->wrInt16(m_version); pFiler->wrSoftPointerId(m_centerPointRefActionParamId); } OdResult OdDbImpAssocRadialDimActionBody::dxfInFields(OdDbDxfFiler* pFiler) { OdResult res = OdDbImpAssocAnnotationActionBody::dxfInFields(pFiler); if (res != eOk) return res; if (!pFiler->atSubclassData(OdDbAssocRadialDimActionBody::desc()->dxfName())) { ODA_FAIL_ONCE(); return eMakeMeProxy; } NEXT_CODE(90); m_version = OdUInt16(pFiler->rdUInt32()); ODA_ASSERT_ONCE_X(MDSO, !m_version); NEXT_CODE(330); m_centerPointRefActionParamId = pFiler->rdObjectId(); return eOk; } void OdDbImpAssocRadialDimActionBody::dxfOutFields(OdDbDxfFiler* pFiler) const { OdDbImpAssocAnnotationActionBody::dxfOutFields(pFiler); pFiler->wrSubclassMarker(OdDbAssocRadialDimActionBody::desc()->dxfName()); ODA_ASSERT_ONCE_X(MDSO, !m_version); pFiler->wrUInt32(90, m_version); pFiler->wrObjectId(330, m_centerPointRefActionParamId); } //void OdDbImpAssocRadialDimActionBody::composeForLoad(OdDbObject *pObject, // OdDb::SaveType format, // OdDb::DwgVersion version, // OdDbAuditInfo* pAuditInfo) //{ // OdDbAssocRotatedDimActionBody *Body = static_cast(pObject); // //m_matrix = OdDbBlockReference::cast(getArrayEntity(Body->parentAction()).safeOpenObject())->blockTransform(); //} void OdDbImpAssocRadialDimActionBody::evaluateOverride(OdDbObjectId parentActionId) { OdDbAssocActionPtr action = OdDbAssocAction::cast(parentActionId.openObject(OdDb::kForWrite)); OdDbAssocDependencyPtr dimDep = m_annotationEntDepId.openObject(); OdDbAssocDependencyPtr vpDep = lookUpVpDep(action); OdResult res = eOk; for (;;) { if (dimDep.isNull()) { res = action->setStatus(kErasedAssocStatus); return; } OdDbRadialDimensionPtr radialDim = dimDep->dependentOnObject().openObject(); OdDbAssocOsnapPointRefActionParamPtr osnapPointRefParams[2] = { OdDbAssocOsnapPointRefActionParamPtr(), m_centerPointRefActionParamId.openObject() }; if (radialDim.isNull() || osnapPointRefParams[0].isNull() && osnapPointRefParams[1].isNull()) { res = action->setStatus(kErasedAssocStatus); return; } OdGePoint3d ptVals[OdDbDimAssoc::kMaxPointRefs]; OdExDimAssocPtr exDimAssoc = (OdExDimAssoc*)::odrxCreateObject(L"AcDbDimAssoc").get(); if (exDimAssoc.isNull()) break; // FailedToEvaluate OdGePoint3d ptOldVals[OdDbDimAssoc::kMaxPointRefs] = { OdGePoint3d::kOrigin, radialDim->center(), OdGePoint3d::kOrigin, OdGePoint3d::kOrigin }; if (osnapPointRefParams[OdDbDimAssoc::kCenterPoint].get()) { osnapPointRefParams[OdDbDimAssoc::kCenterPoint]->evaluatePointOverride(ptVals[OdDbDimAssoc::kCenterPoint]); OdDbOsnapPointRefPtr pRefPt = osnapPointRefParams[OdDbDimAssoc::kCenterPoint]->asOsnapPointRef(); //pRefPt->evalPoint(ptVals[OdDbDimAssoc::kCenterPoint]); exDimAssoc->setPointRef(OdDbDimAssoc::kCenterPoint, pRefPt); exDimAssoc->setDimObjId(radialDim->objectId()); } if (isEvaluationRequest(dimDep->status())) { // dim modified, check associativity if (!radialDim->center().isEqualTo(ptVals[OdDbDimAssoc::kCenterPoint])) { breakAssociativity(action, dimDep); return; } } bool vpChanged = vpDep.get() && isEvaluationRequest(vpDep->status()); if ( !ptOldVals[OdDbDimAssoc::kCenterPoint].isEqualTo(ptVals[OdDbDimAssoc::kCenterPoint]) || vpChanged) { radialDim->upgradeOpen(); if (vpChanged) { double newDimlFac = radialDim->dimlfac(); OdDbViewportPtr vViewPort = vpDep->dependentOnObject().openObject(); if (vViewPort.get()) { newDimlFac = 1 / vViewPort->customScale(); radialDim->setDimlfac(newDimlFac); } } OdSmartPtr watcher = (ExDimAssocWatcherPE*)OdDbEvalWatcherPE::cast(exDimAssoc).get(); if (watcher.isNull()) break; // FailedToEvaluate res = watcher->updateDimension(exDimAssoc, radialDim, ptVals); radialDim->downgradeOpen(); } res = action->evaluateDependencies(); res = action->setStatus(kIsUpToDateAssocStatus); return; } res = action->setStatus(kFailedToEvaluateAssocStatus); ODA_VERIFY_ONCE(res == eOk); }