/////////////////////////////////////////////////////////////////////////////// // 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 "DbImpAssoc3PointAngularDimActionBody.h" #include "DbAssoc3PointAngularDimActionBody.h" #include "DbObjectId.h" #include "Db3PointAngularDimension.h" #include "ExDimAssoc.h" OdDbImpAssoc3PointAngularDimActionBody::OdDbImpAssoc3PointAngularDimActionBody() { //m_ActionBodyType = kRotatedDim; m_paramBasedActionBody = new OdDbImpAssocParamBasedActionBody(true); } OdDbImpAssoc3PointAngularDimActionBody::~OdDbImpAssoc3PointAngularDimActionBody() { } OdResult OdDbImpAssoc3PointAngularDimActionBody::dwgInFields(OdDbDwgFiler* pFiler) { OdResult res = OdDbImpAssocAnnotationActionBody::dwgInFields(pFiler); if (res != eOk) return res; m_version = pFiler->rdInt16(); m_centerPointRefActionParamId = pFiler->rdSoftPointerId(); m_xline1PointRefActionParamId = pFiler->rdSoftPointerId(); m_xline2PointRefActionParamId = pFiler->rdSoftPointerId(); return res; } void OdDbImpAssoc3PointAngularDimActionBody::dwgOutFields(OdDbDwgFiler* pFiler) const { OdDbImpAssocAnnotationActionBody::dwgOutFields(pFiler); pFiler->wrInt16(m_version); pFiler->wrSoftPointerId(m_centerPointRefActionParamId); pFiler->wrSoftPointerId(m_xline1PointRefActionParamId); pFiler->wrSoftPointerId(m_xline2PointRefActionParamId); } OdResult OdDbImpAssoc3PointAngularDimActionBody::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 = static_cast(pFiler->rdUInt32()); NEXT_CODE(330); m_centerPointRefActionParamId= pFiler->rdObjectId(); NEXT_CODE(330); m_xline1PointRefActionParamId = pFiler->rdObjectId(); NEXT_CODE(330); m_xline2PointRefActionParamId = pFiler->rdObjectId(); return eOk; } void OdDbImpAssoc3PointAngularDimActionBody::dxfOutFields(OdDbDxfFiler* pFiler) const { OdDbImpAssocAnnotationActionBody::dxfOutFields(pFiler); pFiler->wrSubclassMarker(OdDbAssoc3PointAngularDimActionBody::desc()->dxfName()); pFiler->wrUInt32(90, m_version); pFiler->wrObjectId(330, m_centerPointRefActionParamId); pFiler->wrObjectId(330, m_xline1PointRefActionParamId); pFiler->wrObjectId(330, m_xline2PointRefActionParamId); } //const OdDbSmartCenterMarkParametersPtr OdDbImpAssoc3PointAngularDimActionBody::parameters() const //{ // return m_pParams; //} // //OdDbSmartCenterMarkParametersPtr& OdDbImpAssoc3PointAngularDimActionBody::parameters() //{ // return m_pParams; //} // //void OdDbImpAssoc3PointAngularDimActionBody::composeForLoad(OdDbObject *pObject, // OdDb::SaveType format, // OdDb::DwgVersion version, // OdDbAuditInfo* pAuditInfo) //{ // OdDbAssoc3PointAngularDimActionBody *Body = static_cast(pObject); // //m_matrix = OdDbBlockReference::cast(getArrayEntity(Body->parentAction()).safeOpenObject())->blockTransform(); //} // OdResult breakAssociativity(OdDbAssocAction* action, OdDbAssocOsnapPointRefActionParam* osnapParam); void OdDbImpAssoc3PointAngularDimActionBody::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 (;;) { OdDb3PointAngularDimensionPtr angularDim = dimDep->dependentOnObject().openObject(); OdDbAssocOsnapPointRefActionParamPtr osnapPointRefParams[OdDbDimAssoc::kOverrideCenterPoint + 1] = { m_xline1PointRefActionParamId.openObject(), m_xline2PointRefActionParamId.openObject(), m_centerPointRefActionParamId.openObject() }; if (angularDim.isNull() || osnapPointRefParams[0].isNull() && osnapPointRefParams[1].isNull() && osnapPointRefParams[2].isNull() ) { res = action->setStatus(kErasedAssocStatus); return; } OdDbDimAssocPtr dimAssoc = (OdDbDimAssoc*)::odrxCreateObject(L"AcDbDimAssoc").get(); if (dimAssoc.isNull()) break; // FailedToEvaluate OdGePoint3d ptVals[OdDbDimAssoc::kOverrideCenterPoint+1]; for (int pt = 0; pt < OdDbDimAssoc::kOverrideCenterPoint+1; ++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 int nFlags = dimAssoc->assocFlag(); if (nFlags & OdDbDimAssoc::kFirstPointRef) { if (!angularDim->xLine1Point().isEqualTo(ptVals[OdDbDimAssoc::kXline1Point])) { res = dimAssoc->removePointRef(OdDbDimAssoc::kXline1Point); SETBIT_0(nFlags, OdDbDimAssoc::kFirstPointRef); res = ::breakAssociativity(action, osnapPointRefParams[OdDbDimAssoc::kXline1Point]); } } if (nFlags & OdDbDimAssoc::kSecondPointRef) { if (!angularDim->xLine2Point().isEqualTo(ptVals[OdDbDimAssoc::kXline2Point])) { res = dimAssoc->removePointRef(OdDbDimAssoc::kXline2Point); SETBIT_0(nFlags, OdDbDimAssoc::kSecondPointRef); res = ::breakAssociativity(action, osnapPointRefParams[OdDbDimAssoc::kXline2Point]); } } if (nFlags & OdDbDimAssoc::kThirdPointRef) { if (!angularDim->centerPoint().isEqualTo(ptVals[OdDbDimAssoc::kOverrideCenterPoint])) { res = dimAssoc->removePointRef(OdDbDimAssoc::kOverrideCenterPoint); SETBIT_0(nFlags, OdDbDimAssoc::kThirdPointRef); res = ::breakAssociativity(action, osnapPointRefParams[OdDbDimAssoc::kOverrideCenterPoint]); } } if (nFlags == 0) { res = breakAssociativity(action, dimDep); return; } } OdDbAssocDependencyPtr vpDep = lookUpVpDep(action); bool vpChanged = vpDep.get() && isEvaluationRequest(vpDep->status()); if ( osnapPointRefParams[OdDbDimAssoc::kXline1Point].get() && !angularDim->xLine1Point().isEqualTo(ptVals[OdDbDimAssoc::kXline1Point]) || osnapPointRefParams[OdDbDimAssoc::kXline2Point].get() && !angularDim->xLine2Point().isEqualTo(ptVals[OdDbDimAssoc::kXline2Point]) || osnapPointRefParams[OdDbDimAssoc::kOverrideCenterPoint].get() && !angularDim->centerPoint().isEqualTo(ptVals[OdDbDimAssoc::kOverrideCenterPoint]) || vpChanged) { angularDim->upgradeOpen(); OdSmartPtr watcher = (ExDimAssocWatcherPE*)OdDbEvalWatcherPE::cast(dimAssoc).get(); if (watcher.isNull()) break; // FailedToEvaluate dimAssoc->setDimObjId(angularDim->objectId()); res = watcher->updateDimension(dimAssoc, angularDim, ptVals); angularDim->downgradeOpen(); } res = action->evaluateDependencies(); res = action->setStatus(kIsUpToDateAssocStatus); return; } res = action->setStatus(kFailedToEvaluateAssocStatus); }