/////////////////////////////////////////////////////////////////////////////// // 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 "DbAssocArrayModifyActionBody.h" #include "DbImpAssocRotatedDimActionBody.h" #include "DbBlockReference.h" #include "DbBlockTableRecord.h" #include "DbBlockTable.h" #include "DbAssocDependency.h" #include "DbAssocGeomDependency.h" #include "DbLinetypeTable.h" #include "DbImpAssocOrdinateDimActionBody.h" #include "DbAssocOrdinateDimActionBody.h" #include "DbAssoc3PointAngularDimActionBody.h" #include "DbObjectId.h" #include "DbOrdinateDimension.h" #include "ExDimAssoc.h" OdDbImpAssocOrdinateDimActionBody::OdDbImpAssocOrdinateDimActionBody() { // m_ActionBodyType = kRotatedDim; m_paramBasedActionBody = new OdDbImpAssocParamBasedActionBody(true); } OdDbImpAssocOrdinateDimActionBody::~OdDbImpAssocOrdinateDimActionBody() { } OdResult OdDbImpAssocOrdinateDimActionBody::dwgInFields(OdDbDwgFiler* pFiler) { OdResult res = OdDbImpAssocAnnotationActionBody::dwgInFields(pFiler); if (res != eOk) return res; m_version = pFiler->rdInt16(); m_origPointRefActionParamId = pFiler->rdSoftPointerId(); m_defPointRefActionParamId = pFiler->rdSoftPointerId(); return res; } void OdDbImpAssocOrdinateDimActionBody::dwgOutFields(OdDbDwgFiler* pFiler) const { OdDbImpAssocAnnotationActionBody::dwgOutFields(pFiler); pFiler->wrInt16(m_version); pFiler->wrSoftPointerId(m_origPointRefActionParamId); pFiler->wrSoftPointerId(m_defPointRefActionParamId); } OdResult OdDbImpAssocOrdinateDimActionBody::dxfInFields(OdDbDxfFiler* pFiler) { OdResult res = OdDbImpAssocAnnotationActionBody::dxfInFields(pFiler); if (res != eOk) return res; if (!pFiler->atSubclassData(OdDbAssoc3PointAngularDimActionBody::desc()->dxfName())) { ODA_FAIL_ONCE(); return eMakeMeProxy; } NEXT_CODE(90); m_version = OdUInt16(pFiler->rdUInt32()); NEXT_CODE(330); m_origPointRefActionParamId = pFiler->rdObjectId(); NEXT_CODE(330); m_defPointRefActionParamId = pFiler->rdObjectId(); return eOk; } void OdDbImpAssocOrdinateDimActionBody::dxfOutFields(OdDbDxfFiler* pFiler) const { OdDbImpAssocAnnotationActionBody::dxfOutFields(pFiler); pFiler->wrSubclassMarker(OdDbAssoc3PointAngularDimActionBody::desc()->dxfName()); pFiler->wrUInt32(90, m_version); pFiler->wrObjectId(330, m_origPointRefActionParamId); pFiler->wrObjectId(330, m_defPointRefActionParamId); } void OdDbImpAssocOrdinateDimActionBody::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 (;;) { OdDbOrdinateDimensionPtr ordDim = dimDep->dependentOnObject().openObject(); OdDbAssocOsnapPointRefActionParamPtr osnapPointRefParams[2] = { m_origPointRefActionParamId.openObject(), m_defPointRefActionParamId.openObject() }; if (ordDim.isNull() || osnapPointRefParams[0].isNull() && osnapPointRefParams[1].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]; for (int pt = 0; pt < 2; ++pt) { if (osnapPointRefParams[pt].get()) { osnapPointRefParams[pt]->evaluatePointOverride(ptVals[pt]); OdDbOsnapPointRefPtr pRefPt = osnapPointRefParams[pt]->asOsnapPointRef(); //res = pRefPt->evalPoint(ptVals[pt]); dimAssoc->setPointRef(pt, pRefPt); } } if (isEvaluationRequest(dimDep->status())) { // dim modified, check associativity if (!osnapPointRefParams[OdDbDimAssoc::kDefiningPoint].isNull()) { if (!ordDim->definingPoint().isEqualTo(ptVals[OdDbDimAssoc::kDefiningPoint])) { dimAssoc->removePointRef(OdDbDimAssoc::kDefiningPoint); breakAssociativity(action, dimDep); return; } } } OdDbAssocDependencyPtr vpDep = lookUpVpDep(action); bool vpChanged = vpDep.get() && isEvaluationRequest(vpDep->status()); if ( !osnapPointRefParams[OdDbDimAssoc::kOriginPoint].isNull() && !ordDim->origin().isEqualTo(ptVals[OdDbDimAssoc::kOriginPoint]) || !osnapPointRefParams[OdDbDimAssoc::kDefiningPoint].isNull() && !ordDim->definingPoint().isEqualTo(ptVals[OdDbDimAssoc::kDefiningPoint]) || vpChanged) { ordDim->upgradeOpen(); if (vpChanged) { double newDimlFac = ordDim->dimlfac(); OdDbViewportPtr vViewPort = vpDep->dependentOnObject().openObject(); if (vViewPort.get()) { newDimlFac = 1 / vViewPort->customScale(); ordDim->setDimlfac(newDimlFac); } } dimAssoc->setDimObjId(ordDim->objectId()); watcher->updateDimension(dimAssoc, ordDim, ptVals); ordDim->downgradeOpen(); } res = action->evaluateDependencies(); res = action->setStatus(kIsUpToDateAssocStatus); return; } res = action->setStatus(kFailedToEvaluateAssocStatus); }