/////////////////////////////////////////////////////////////////////////////// // 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 "DbImpAssocAlignedDimActionBody.h" #include "DbObjectId.h" #include "DbAlignedDimension.h" #include "Ge/GeLineSeg3d.h" #include "DbAssocActionParam.h" #include "ExDimAssoc.h" OdDbImpAssocAlignedDimActionBody::OdDbImpAssocAlignedDimActionBody() { m_paramBasedActionBody = new OdDbImpAssocParamBasedActionBody(true); // m_ActionBodyType = kRotatedDim; } OdDbImpAssocAlignedDimActionBody::~OdDbImpAssocAlignedDimActionBody() { } OdResult OdDbImpAssocAlignedDimActionBody::dwgInFields(OdDbDwgFiler* pFiler) { OdResult res = OdDbImpAssocAnnotationActionBody::dwgInFields(pFiler); if (res != eOk) return res; m_version = pFiler->rdInt16(); m_xline1PointRefActionParamId = pFiler->rdSoftPointerId(); m_xline2PointRefActionParamId = pFiler->rdSoftPointerId(); return res; } void OdDbImpAssocAlignedDimActionBody::dwgOutFields(OdDbDwgFiler* pFiler) const { OdDbImpAssocAnnotationActionBody::dwgOutFields(pFiler); pFiler->wrInt16(m_version); pFiler->wrSoftPointerId(m_xline1PointRefActionParamId); pFiler->wrSoftPointerId(m_xline2PointRefActionParamId); } OdResult OdDbImpAssocAlignedDimActionBody::dxfInFields(OdDbDxfFiler* pFiler) { OdResult res = OdDbImpAssocAnnotationActionBody::dxfInFields(pFiler); if (res != eOk) return res; if (!pFiler->atSubclassData(OdDbAssocAlignedDimActionBody::desc()->dxfName())) { ODA_FAIL_ONCE(); return eMakeMeProxy; } NEXT_CODE(90); m_version = static_cast(pFiler->rdUInt32()); NEXT_CODE(330); m_xline1PointRefActionParamId = pFiler->rdObjectId(); NEXT_CODE(330); m_xline2PointRefActionParamId = pFiler->rdObjectId(); return eOk; } void OdDbImpAssocAlignedDimActionBody::dxfOutFields(OdDbDxfFiler* pFiler) const { OdDbImpAssocAnnotationActionBody::dxfOutFields(pFiler); pFiler->wrSubclassMarker(OdDbAssocAlignedDimActionBody::desc()->dxfName()); pFiler->wrUInt32(90, m_version); pFiler->wrObjectId(330, m_xline1PointRefActionParamId); pFiler->wrObjectId(330, m_xline2PointRefActionParamId); } //const OdDbSmartCenterMarkParametersPtr OdDbImpAssocAlignedDimActionBody::parameters() const //{ // return m_pParams; //} // //OdDbSmartCenterMarkParametersPtr& OdDbImpAssocAlignedDimActionBody::parameters() //{ // return m_pParams; //} // void OdDbImpAssocAlignedDimActionBody::composeForLoad(OdDbObject *pObject, OdDb::SaveType, OdDb::DwgVersion, OdDbAuditInfo*) { OdDbAssocAlignedDimActionBody *Body = static_cast(pObject); (void)Body; //m_matrix = OdDbBlockReference::cast(getArrayEntity(Body->parentAction()).safeOpenObject())->blockTransform(); } OdResult breakAssociativity(OdDbAssocAction* action, OdDbAssocOsnapPointRefActionParam* osnapParam); void OdDbImpAssocAlignedDimActionBody::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 (;;) { OdDbAlignedDimensionPtr alignDim = dimDep->dependentOnObject().openObject(); OdDbAssocOsnapPointRefActionParamPtr osnapPointRefParams[2] = { m_xline1PointRefActionParamId.openObject(), m_xline2PointRefActionParamId.openObject() }; if (alignDim.isNull() || osnapPointRefParams[0].isNull() && osnapPointRefParams[1].isNull()) { res = action->setStatus(kErasedAssocStatus); return; } OdDbDimAssocPtr dimAssoc = (OdDbDimAssoc*)::odrxCreateObject(L"AcDbDimAssoc").get(); if (dimAssoc.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 int nFlags = dimAssoc->assocFlag(); if (nFlags & OdDbDimAssoc::kFirstPointRef) { if (!alignDim->xLine1Point().isEqualTo(ptVals[OdDbDimAssoc::kXline1Point])) { res = dimAssoc->removePointRef(OdDbDimAssoc::kXline1Point); SETBIT_0(nFlags, OdDbDimAssoc::kFirstPointRef); } } if (nFlags & OdDbDimAssoc::kSecondPointRef) { if (!alignDim->xLine2Point().isEqualTo(ptVals[OdDbDimAssoc::kXline2Point])) { res = dimAssoc->removePointRef(OdDbDimAssoc::kXline2Point); SETBIT_0(nFlags, OdDbDimAssoc::kSecondPointRef); } } switch (nFlags) { case 0: res = breakAssociativity(action, dimDep); return; case 1: res = ::breakAssociativity(action, osnapPointRefParams[OdDbDimAssoc::kXline2Point]); break; case 2: res = ::breakAssociativity(action, osnapPointRefParams[OdDbDimAssoc::kXline1Point]); break; case 3: default: break; } } OdDbAssocDependencyPtr vpDep = lookUpVpDep(action); bool vpChanged = vpDep.get() && isEvaluationRequest(vpDep->status()); if ( osnapPointRefParams[OdDbDimAssoc::kXline1Point].get() && !alignDim->xLine1Point().isEqualTo(ptVals[OdDbDimAssoc::kXline1Point]) || osnapPointRefParams[OdDbDimAssoc::kXline2Point].get() && !alignDim->xLine2Point().isEqualTo(ptVals[OdDbDimAssoc::kXline2Point]) || vpChanged) { alignDim->upgradeOpen(); if (vpChanged) { double newDimlFac = alignDim->dimlfac(); OdDbViewportPtr vViewPort = vpDep->dependentOnObject().openObject(); if (vViewPort.get()) { newDimlFac = 1 / vViewPort->customScale(); alignDim->setDimlfac(newDimlFac); } } OdSmartPtr watcher = (ExDimAssocWatcherPE*)OdDbEvalWatcherPE::cast(dimAssoc).get(); if (watcher.isNull()) break; // FailedToEvaluate dimAssoc->setDimObjId(alignDim->objectId()); res = watcher->updateDimension(dimAssoc, alignDim, ptVals); alignDim->downgradeOpen(); } res = action->evaluateDependencies(); res = action->setStatus(kIsUpToDateAssocStatus); return; } res = action->setStatus(kFailedToEvaluateAssocStatus); } OdResult OdDbImpAssocAlignedDimActionBody::createInstance( const OdDbFullSubentPathArray entPathArray, OdGePoint3dArray ptsSelected, OdDbObjectId& actionBodyId) { OdString createAlignedDim = OD_T("Aligned"); return OdDbImpAssocRotatedDimActionBody::createInstance(entPathArray, ptsSelected, actionBodyId, createAlignedDim); } OdResult OdDbImpAssocAlignedDimActionBody::createInstance( const OdDbFullSubentPathArray& entPathArray, const OdGePoint3dArray& ptsSelected, OdDbObjectId& actionBodyId, const OdArray& snapModeArr) { OdString createAlignedDim = OD_T("Aligned"); return OdDbImpAssocRotatedDimActionBody::createInstance(entPathArray, ptsSelected, actionBodyId, snapModeArr, createAlignedDim); } //OdResult OdDbImpAssocAlignedDimActionBody::createInstance(const OdDbObjectId bodyId1, const OdGePoint3d ptPoint1, // const OdDbObjectId bodyId2, const OdGePoint3d ptPoint2, const OdGePoint3d dimLinePt, // OdDbObjectId& arrayId, // OdDbObjectId& actionBodyId) //{ // OdString createAlignedDim = OD_T("Aligned");; // return OdDbImpAssocRotatedDimActionBody::createInstance(bodyId1, ptPoint1, bodyId2, ptPoint2, dimLinePt, arrayId, actionBodyId, createAlignedDim); //}