/////////////////////////////////////////////////////////////////////////////// // 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 "DbAssocDependency.h" #include "DbAssocGeomDependency.h" #include "DbImpAssocDiametricDimActionBody.h" #include "DbAssocDiametricDimActionBody.h" #include "DbObjectId.h" #include "DbDiametricDimension.h" #include "ExDimAssoc.h" OdDbImpAssocDiametricDimActionBody::OdDbImpAssocDiametricDimActionBody() { m_paramBasedActionBody = new OdDbImpAssocParamBasedActionBody(true); } OdDbImpAssocDiametricDimActionBody::~OdDbImpAssocDiametricDimActionBody() { } OdResult OdDbImpAssocDiametricDimActionBody::dwgInFields(OdDbDwgFiler* pFiler) { OdResult res = OdDbImpAssocAnnotationActionBody::dwgInFields(pFiler); if (res != eOk) return res; m_version = pFiler->rdInt16(); m_centerPointAssocParamId = pFiler->rdSoftPointerId(); return res; } void OdDbImpAssocDiametricDimActionBody::dwgOutFields(OdDbDwgFiler* pFiler) const { OdDbImpAssocAnnotationActionBody::dwgOutFields(pFiler); pFiler->wrInt16(m_version); pFiler->wrSoftPointerId(m_centerPointAssocParamId); } OdResult OdDbImpAssocDiametricDimActionBody::dxfInFields(OdDbDxfFiler* pFiler) { OdResult res = OdDbImpAssocAnnotationActionBody::dxfInFields(pFiler); if (res != eOk) return res; if (!pFiler->atSubclassData(OdDbAssocDiametricDimActionBody::desc()->dxfName())) { ODA_FAIL_ONCE(); return eMakeMeProxy; } NEXT_CODE(90); m_version = OdUInt16(pFiler->rdUInt32()); NEXT_CODE(330); m_centerPointAssocParamId = pFiler->rdObjectId(); return eOk; } void OdDbImpAssocDiametricDimActionBody::dxfOutFields(OdDbDxfFiler* pFiler) const { OdDbImpAssocAnnotationActionBody::dxfOutFields(pFiler); pFiler->wrSubclassMarker(OdDbAssocDiametricDimActionBody::desc()->dxfName()); pFiler->wrUInt32(90, m_version); pFiler->wrObjectId(330, m_centerPointAssocParamId); } void OdDbImpAssocDiametricDimActionBody::evaluateOverride(OdDbObjectId parentActionId) { OdResult res = eOk; OdDbAssocActionPtr action = OdDbAssocAction::cast(parentActionId.openObject(OdDb::kForWrite)); OdDbAssocDependencyPtr dimDep = m_annotationEntDepId.openObject(); if (dimDep.isNull()) { res = action->setStatus(kErasedAssocStatus); return; } for (;;) { OdDbDiametricDimensionPtr diamDim = dimDep->dependentOnObject().openObject(); OdDbAssocOsnapPointRefActionParamPtr osnapPointRefParam = m_centerPointAssocParamId.openObject(); if (diamDim.isNull() || osnapPointRefParam.isNull()) { res = action->setStatus(kErasedAssocStatus); return; } OdDbDimAssocPtr dimAssoc = (OdDbDimAssoc*)::odrxCreateObject(L"AcDbDimAssoc").get(); if (dimAssoc.isNull()) break; // FailedToEvaluate OdSmartPtr watcher = (ExDimAssocWatcherPE*)OdDbEvalWatcherPE::cast(dimAssoc).get(); if (watcher.isNull()) break; // FailedToEvaluate OdGePoint3d ptVals[2]; if (osnapPointRefParam.get()) { osnapPointRefParam->evaluatePointOverride(ptVals[OdDbDimAssoc::kCenterPoint]); OdDbOsnapPointRefPtr pRefPt = osnapPointRefParam->asOsnapPointRef(); //res = pRefPt->evalPoint(ptVals[OdDbDimAssoc::kCenterPoint]); dimAssoc->setPointRef(OdDbDimAssoc::kCenterPoint, pRefPt); } OdDbAssocDependencyPtr vpDep = lookUpVpDep(action); bool vpChanged = vpDep.get() && isEvaluationRequest(vpDep->status()); OdDbAssocActionParamPtr circParam = osnapPointRefParam->paramAtIndex(0).openObject(); bool circChanged = circParam.get() && isEvaluationRequest(circParam->status(true)); if (circChanged || vpChanged) { diamDim->upgradeOpen(); if (vpChanged) { double newDimlFac = diamDim->dimlfac(); OdDbViewportPtr vViewPort = vpDep->dependentOnObject().openObject(); if (vViewPort.get()) { newDimlFac = 1 / vViewPort->customScale(); diamDim->setDimlfac(newDimlFac); } } dimAssoc->setDimObjId(diamDim->objectId()); watcher->updateDimension(dimAssoc, diamDim, ptVals); diamDim->downgradeOpen(); } res = action->evaluateDependencies(); res = action->setStatus(kIsUpToDateAssocStatus); return; } res = action->setStatus(kFailedToEvaluateAssocStatus); }