/////////////////////////////////////////////////////////////////////////////// // 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 "DbBlockReference.h" #include "DbBlockTableRecord.h" #include "DbBlockTable.h" #include "DbAssocDependency.h" #include "DbAssocGeomDependency.h" #include "DbLinetypeTable.h" #include "DbImpAssoc2LineAngularDimActionBody.h" #include "DbObjectId.h" #include "Db2LineAngularDimension.h" #include "Ge/GeLineSeg3d.h" #include "DbAssocActionParam.h" #include "ExDimAssoc.h" OdDbImpAssoc2LineAngularDimActionBody::OdDbImpAssoc2LineAngularDimActionBody() { m_paramBasedActionBody = new OdDbImpAssocParamBasedActionBody(true); // m_ActionBodyType = kRotatedDim; } OdDbImpAssoc2LineAngularDimActionBody::~OdDbImpAssoc2LineAngularDimActionBody() { } OdResult OdDbImpAssoc2LineAngularDimActionBody::dwgInFields(OdDbDwgFiler* pFiler) { OdResult res = OdDbImpAssocAnnotationActionBody::dwgInFields(pFiler); if (res != eOk) return res; m_version = pFiler->rdInt16(); m_xline1StartPointRefActionParamId = pFiler->rdSoftPointerId(); m_xline1EndPointRefActionParamId = pFiler->rdSoftPointerId(); m_xline2StartPointRefActionParamId = pFiler->rdSoftPointerId(); m_xline2EndPointRefActionParamId = pFiler->rdSoftPointerId(); return res; } void OdDbImpAssoc2LineAngularDimActionBody::dwgOutFields(OdDbDwgFiler* pFiler) const { OdDbImpAssocAnnotationActionBody::dwgOutFields(pFiler); pFiler->wrInt16(m_version); pFiler->wrSoftPointerId(m_xline1StartPointRefActionParamId); pFiler->wrSoftPointerId(m_xline1EndPointRefActionParamId); pFiler->wrSoftPointerId(m_xline2StartPointRefActionParamId); pFiler->wrSoftPointerId(m_xline2EndPointRefActionParamId); } OdResult OdDbImpAssoc2LineAngularDimActionBody::dxfInFields(OdDbDxfFiler* pFiler) { OdResult res = OdDbImpAssocAnnotationActionBody::dxfInFields(pFiler); if (res != eOk) return res; if (!pFiler->atSubclassData(OdDbAssoc2LineAngularDimActionBody::desc()->dxfName())) { ODA_FAIL_ONCE(); return eMakeMeProxy; } NEXT_CODE(90); m_version = static_cast(pFiler->rdUInt32()); NEXT_CODE(330); m_xline1StartPointRefActionParamId = pFiler->rdObjectId(); NEXT_CODE(330); m_xline1EndPointRefActionParamId = pFiler->rdObjectId(); NEXT_CODE(330); m_xline2StartPointRefActionParamId = pFiler->rdObjectId(); NEXT_CODE(330); m_xline2EndPointRefActionParamId = pFiler->rdObjectId(); return eOk; } void OdDbImpAssoc2LineAngularDimActionBody::dxfOutFields(OdDbDxfFiler* pFiler) const { OdDbImpAssocAnnotationActionBody::dxfOutFields(pFiler); pFiler->wrSubclassMarker(OdDbAssoc2LineAngularDimActionBody::desc()->dxfName()); pFiler->wrUInt32(90, m_version); pFiler->wrObjectId(330, m_xline1StartPointRefActionParamId); pFiler->wrObjectId(330, m_xline1EndPointRefActionParamId); pFiler->wrObjectId(330, m_xline2StartPointRefActionParamId); pFiler->wrObjectId(330, m_xline2EndPointRefActionParamId); } //const OdDbSmartCenterMarkParametersPtr OdDbImpAssoc2LineAngularDimActionBody::parameters() const //{ // return m_pParams; //} // //OdDbSmartCenterMarkParametersPtr& OdDbImpAssoc2LineAngularDimActionBody::parameters() //{ // return m_pParams; //} // void OdDbImpAssoc2LineAngularDimActionBody::composeForLoad(OdDbObject *pObject, OdDb::SaveType, OdDb::DwgVersion, OdDbAuditInfo*) { OdDbAssoc2LineAngularDimActionBody *Body = static_cast(pObject); (void)Body; //m_matrix = OdDbBlockReference::cast(getArrayEntity(Body->parentAction()).safeOpenObject())->blockTransform(); } OdResult breakAssociativity(OdDbAssocAction* action, OdDbAssocOsnapPointRefActionParam* osnapParam); void OdDbImpAssoc2LineAngularDimActionBody::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 (;;) { OdDb2LineAngularDimensionPtr angularDim = dimDep->dependentOnObject().openObject(); OdDbAssocOsnapPointRefActionParamPtr osnapPointRefParams[4] = { m_xline1StartPointRefActionParamId.openObject(), m_xline1EndPointRefActionParamId.openObject(), m_xline2StartPointRefActionParamId.openObject(), m_xline2EndPointRefActionParamId.openObject() }; if (angularDim.isNull() || osnapPointRefParams[0].isNull() && osnapPointRefParams[1].isNull() && osnapPointRefParams[2].isNull() && osnapPointRefParams[3].isNull()) { res = action->setStatus(kErasedAssocStatus); return; } OdDbDimAssocPtr dimAssoc = (OdDbDimAssoc*)::odrxCreateObject(L"AcDbDimAssoc").get(); if (dimAssoc.isNull()) break; // FailedToEvaluate OdGePoint3d ptVals[4]; for (int pt = 0; pt < 4; ++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->xLine1Start().isEqualTo(ptVals[OdDbDimAssoc::kXline1Start])) { res = dimAssoc->removePointRef(OdDbDimAssoc::kXline1Start); SETBIT_0(nFlags, OdDbDimAssoc::kFirstPointRef); res = ::breakAssociativity(action, osnapPointRefParams[OdDbDimAssoc::kXline1Start]); } } if (nFlags & OdDbDimAssoc::kSecondPointRef) { if (!angularDim->xLine1End().isEqualTo(ptVals[OdDbDimAssoc::kXline1End])) { res = dimAssoc->removePointRef(OdDbDimAssoc::kXline1End); SETBIT_0(nFlags, OdDbDimAssoc::kSecondPointRef); res = ::breakAssociativity(action, osnapPointRefParams[OdDbDimAssoc::kXline1End]); } } if (nFlags & OdDbDimAssoc::kThirdPointRef) { if (!angularDim->xLine2Start().isEqualTo(ptVals[OdDbDimAssoc::kXline2Start])) { res = dimAssoc->removePointRef(OdDbDimAssoc::kXline2Start); SETBIT_0(nFlags, OdDbDimAssoc::kThirdPointRef); res = ::breakAssociativity(action, osnapPointRefParams[OdDbDimAssoc::kXline2Start]); } } if (nFlags & OdDbDimAssoc::kFourthPointRef) { if (!angularDim->xLine2End().isEqualTo(ptVals[OdDbDimAssoc::kXline2End])) { res = dimAssoc->removePointRef(OdDbDimAssoc::kXline2End); SETBIT_0(nFlags, OdDbDimAssoc::kFourthPointRef); res = ::breakAssociativity(action, osnapPointRefParams[OdDbDimAssoc::kXline2End]); } } if (nFlags==0) { res = breakAssociativity(action, dimDep); return; } } OdDbAssocDependencyPtr vpDep = lookUpVpDep(action); bool vpChanged = vpDep.get() && isEvaluationRequest(vpDep->status()); if ( osnapPointRefParams[OdDbDimAssoc::kXline1Start].get() && !angularDim->xLine1Start().isEqualTo(ptVals[OdDbDimAssoc::kXline1Start]) || osnapPointRefParams[OdDbDimAssoc::kXline1End].get() && !angularDim->xLine1End().isEqualTo(ptVals[OdDbDimAssoc::kXline1End]) || osnapPointRefParams[OdDbDimAssoc::kXline2Start].get() && !angularDim->xLine2Start().isEqualTo(ptVals[OdDbDimAssoc::kXline2Start]) || osnapPointRefParams[OdDbDimAssoc::kXline2End].get() && !angularDim->xLine2End().isEqualTo(ptVals[OdDbDimAssoc::kXline2End]) || 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); }