/////////////////////////////////////////////////////////////////////////////// // 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 "StdAfx.h" #include "RxObjectImpl.h" #include "DgAutoplantBoltImpl.h" #include "DgAutoplantBolt.h" #include "DgXAttribute.h" #include "DgAutoplantEntityProperties.h" #include "Ge/GePlane.h" #include "Ge/GeLine3d.h" //============================================================================================== // // OdDgAutoplantSphere // //============================================================================================== ODRX_CONS_DEFINE_MEMBERS(OdDgAutoplantBolt, OdDgProxyGraphicsElement, DGELEMENT_CONSTR) //============================================================================================== OdDgAutoplantBolt::OdDgAutoplantBolt() { set3dFormatFlag(true); setElementType(OdDgElement::kTypeExtraGraphicsElement); } //============================================================================================== OdUInt32 OdDgAutoplantBolt::subSetAttributes(OdGiDrawableTraits* pTraits) const { OdUInt32 uRet = OdDgGraphicsElement::subSetAttributes(pTraits); OdGiSubEntityTraitsPtr pSubEntityTraits = OdGiSubEntityTraits::cast(pTraits); if (!pSubEntityTraits.isNull()) { pSubEntityTraits->setLineType(0); pSubEntityTraits->setLineWeight(OdDb::kLnWt000); } uRet |= kDrawableRegenDraw; return uRet; } //============================================================================================== void OdDgAutoplantBolt::scaleDataAfterWorkingUnitsChange(double dScale) { return m_impl.scaleData(dScale); } //============================================================================================== bool OdDgAutoplantBolt::subWorldDraw(OdGiWorldDraw* pWd) const { return m_impl.subWorldDraw(pWd); } //============================================================================================== void OdDgAutoplantBolt::subViewportDraw(OdGiViewportDraw *pVd) const { return m_impl.subViewportDraw(pVd); } //============================================================================================== OdResult OdDgAutoplantBolt::subGetGeomExtents(OdGeExtents3d& extents) const { return m_impl.subGetGeomExtents(extents); } //============================================================================================== OdResult OdDgAutoplantBolt::subGetGeomExtents(const OdDgElementId& idView, OdGeExtents3d& extents) const { return m_impl.subGetGeomExtents(idView, extents); } //============================================================================================== OdResult OdDgAutoplantBolt::subExplode(OdRxObjectPtrArray& entitySet) const { return m_impl.subExplode(entitySet, this); } //============================================================================================== OdResult OdDgAutoplantBolt::transformBy(const OdGeMatrix3d& xfm) { assertWriteEnabled(); return m_impl.transformBy(xfm); } //============================================================================================== bool OdDgAutoplantBolt::allowToConvertFromElement(OdDgElement* pBaseElement) const { if(pBaseElement && (pBaseElement->getElementType() == OdDgElement::kTypeExtraGraphicsElement) && (OdDgElement::getElementExtendedType(pBaseElement) == (OdUInt64)(OdDgAutoplantBolt::kType)) ) { return true; } return false; } //============================================================================================== void OdDgAutoplantBolt::decomposeForSave() { OdRxObjectPtrArray arrXAttrs; getXAttributes(OdDgExtendedElementTypeXAttribute::kType, arrXAttrs); bool bAddXAttr = true; if( !arrXAttrs.isEmpty() ) { OdDgExtendedElementTypeXAttributePtr pXAttr = arrXAttrs[0]; if( !pXAttr.isNull() ) { bAddXAttr = pXAttr->getElementType() != (OdDgExtendedElementTypeXAttribute::OdDgExtendedElementType)(kType); if (bAddXAttr) removeXAttributes(OdDgExtendedElementTypeXAttribute::kType); } } if (bAddXAttr) { OdDgExtendedElementTypeXAttributePtr pXAttr = OdDgExtendedElementTypeXAttribute::createObject(); pXAttr->setElementType((OdDgExtendedElementTypeXAttribute::OdDgExtendedElementType)(kType)); pXAttr->setFlags(0); pXAttr->setXAttrId(1); addXAttribute(OdDgExtendedElementTypeXAttribute::kType, pXAttr); } } //============================================================================================== OdResult OdDgAutoplantBolt::dgnInFields(OdDgFiler* pFiler) { return m_impl.dgnInFields(pFiler); } //============================================================================================== void OdDgAutoplantBolt::dgnOutFields(OdDgFiler* pFiler) const { m_impl.dgnOutFields(pFiler); } //============================================================================================== OdUInt64 OdDgAutoplantBolt::getFlags() const { return m_impl.getFlags(); } //============================================================================================== void OdDgAutoplantBolt::setFlags(OdUInt64 uFlags) { assertWriteEnabled(); m_impl.setFlags(uFlags); } //============================================================================================== bool OdDgAutoplantBolt::getVisibleInShadedRegenFlag() const { return (m_impl.getFlags() & 0x7) ? false : true; } //============================================================================================== void OdDgAutoplantBolt::setVisibleInShadedRegenFlag(bool bSet) { assertWriteEnabled(); OdUInt64 uFlagMask = 0x7; if (bSet) m_impl.setFlags(m_impl.getFlags() & ~uFlagMask); else m_impl.setFlags(m_impl.getFlags() | uFlagMask); } //============================================================================================== OdGePoint3d OdDgAutoplantBolt::getOrigin() const { return m_impl.getOrigin(); } //============================================================================================== void OdDgAutoplantBolt::setOrigin(const OdGePoint3d& ptOrigin) { assertWriteEnabled(); m_impl.setOrigin(ptOrigin); } //============================================================================================== OdGeVector3d OdDgAutoplantBolt::getDirection() const { return m_impl.getDirection(); } //============================================================================================== void OdDgAutoplantBolt::setDirection(const OdGeVector3d& vrDirection) { assertWriteEnabled(); m_impl.setDirection(vrDirection); } //============================================================================================== double OdDgAutoplantBolt::getRadius() const { return m_impl.getRadius(); } //============================================================================================== void OdDgAutoplantBolt::setRadius(double dRadius) { assertWriteEnabled(); m_impl.setRadius(dRadius); } //============================================================================================== double OdDgAutoplantBolt::getStemLength() const { return m_impl.getRadius(); } //============================================================================================== void OdDgAutoplantBolt::setStemLength(double dLength) { assertWriteEnabled(); m_impl.setStemLength(dLength); } //============================================================================================== // CDA Properties for OdDgAutoplantSphere //============================================================================================== //----------------------------------------------------------------------------------------------------------------------- // property: Origin //----------------------------------------------------------------------------------------------------------------------- OdResult OdDgAutoplantBoltOriginProperty::subGetValue(const OdRxObject* pO, OdRxValue& value) const { OdDgAutoplantBoltPtr pObj = OdDgAutoplantBolt::cast(pO); if (pObj.isNull()) return eNotApplicable; value = pObj->getOrigin(); return eOk; } //----------------------------------------------------------------------------------------------------------------------- OdResult OdDgAutoplantBoltOriginProperty::subSetValue(OdRxObject* pO, const OdRxValue& value) const { OdDgAutoplantBoltPtr pObj = OdDgAutoplantBolt::cast(pO); if (pObj.isNull()) return eNotApplicable; pObj->setOrigin(*rxvalue_cast(&value)); return eOk; } //----------------------------------------------------------------------------------------------------------------------- // property: Direction //----------------------------------------------------------------------------------------------------------------------- OdResult OdDgAutoplantBoltDirectionProperty::subGetValue(const OdRxObject* pO, OdRxValue& value) const { OdDgAutoplantBoltPtr pObj = OdDgAutoplantBolt::cast(pO); if (pObj.isNull()) return eNotApplicable; value = pObj->getDirection(); return eOk; } //----------------------------------------------------------------------------------------------------------------------- OdResult OdDgAutoplantBoltDirectionProperty::subSetValue(OdRxObject* pO, const OdRxValue& value) const { OdDgAutoplantBoltPtr pObj = OdDgAutoplantBolt::cast(pO); if (pObj.isNull()) return eNotApplicable; pObj->setDirection(*rxvalue_cast(&value)); return eOk; } //----------------------------------------------------------------------------------------------------------------------- // property: Radius //----------------------------------------------------------------------------------------------------------------------- OdResult OdDgAutoplantBoltRadiusProperty::subGetValue(const OdRxObject* pO, OdRxValue& value) const { OdDgAutoplantBoltPtr pObj = OdDgAutoplantBolt::cast(pO); if (pObj.isNull()) return eNotApplicable; value = pObj->getRadius(); return eOk; } //----------------------------------------------------------------------------------------------------------------------- OdResult OdDgAutoplantBoltRadiusProperty::subSetValue(OdRxObject* pO, const OdRxValue& value) const { OdDgAutoplantBoltPtr pObj = OdDgAutoplantBolt::cast(pO); if (pObj.isNull()) return eNotApplicable; pObj->setRadius(*rxvalue_cast(&value)); return eOk; } //----------------------------------------------------------------------------------------------------------------------- // property: Stem Length //----------------------------------------------------------------------------------------------------------------------- OdResult OdDgAutoplantBoltStemLengthProperty::subGetValue(const OdRxObject* pO, OdRxValue& value) const { OdDgAutoplantBoltPtr pObj = OdDgAutoplantBolt::cast(pO); if (pObj.isNull()) return eNotApplicable; value = pObj->getStemLength(); return eOk; } //----------------------------------------------------------------------------------------------------------------------- OdResult OdDgAutoplantBoltStemLengthProperty::subSetValue(OdRxObject* pO, const OdRxValue& value) const { OdDgAutoplantBoltPtr pObj = OdDgAutoplantBolt::cast(pO); if (pObj.isNull()) return eNotApplicable; pObj->setStemLength(*rxvalue_cast(&value)); return eOk; } //----------------------------------------------------------------------------------------------------------------------- // property: Visible In Shaded Regen //----------------------------------------------------------------------------------------------------------------------- OdResult OdDgAutoplantBoltVisibleInShadedRegenProperty::subGetValue(const OdRxObject* pO, OdRxValue& value) const { OdDgAutoplantBoltPtr pObj = OdDgAutoplantBolt::cast(pO); if (pObj.isNull()) return eNotApplicable; value = pObj->getVisibleInShadedRegenFlag(); return eOk; } //----------------------------------------------------------------------------------------------------------------------- OdResult OdDgAutoplantBoltVisibleInShadedRegenProperty::subSetValue(OdRxObject* pO, const OdRxValue& value) const { OdDgAutoplantBoltPtr pObj = OdDgAutoplantBolt::cast(pO); if (pObj.isNull()) return eNotApplicable; pObj->setVisibleInShadedRegenFlag(*rxvalue_cast(&value)); return eOk; } //----------------------------------------------------------------------------------------------------------------------- // property: Flags //----------------------------------------------------------------------------------------------------------------------- OdResult OdDgAutoplantBoltFlagsProperty::subGetValue(const OdRxObject* pO, OdRxValue& value) const { OdDgAutoplantBoltPtr pObj = OdDgAutoplantBolt::cast(pO); if (pObj.isNull()) return eNotApplicable; value = pObj->getFlags(); return eOk; } //----------------------------------------------------------------------------------------------------------------------- OdResult OdDgAutoplantBoltFlagsProperty::subSetValue(OdRxObject* pO, const OdRxValue& value) const { OdDgAutoplantBoltPtr pObj = OdDgAutoplantBolt::cast(pO); if (pObj.isNull()) return eNotApplicable; pObj->setFlags(*rxvalue_cast(&value)); return eOk; } //============================================================================================== // Grip and snap points for OdDgAutoplantBolt //============================================================================================== OdResult OdDgAutoplantBoltGripPointsPE::getGripPoints(const OdDgElement* pEnt, OdGePoint3dArray& gripPoints)const { unsigned int size = gripPoints.size(); gripPoints.resize(size + 1); OdDgAutoplantBoltPtr pBolt = pEnt; gripPoints[size] = pBolt->getOrigin(); return eOk; } //============================================================================================== OdResult OdDgAutoplantBoltGripPointsPE::moveGripPointsAt(OdDgElement* pEnt, const OdIntArray& indices, const OdGeVector3d& offset) { unsigned size = indices.size(); if (size == 0) return eOk; OdDgAutoplantBoltPtr pBolt = pEnt; if (size > 1 || indices[0] == 1) { pBolt->transformBy(OdGeMatrix3d::translation(offset)); } else { pBolt->setOrigin(pBolt->getOrigin() + offset); } return eOk; } //============================================================================================== OdResult OdDgAutoplantBoltGripPointsPE::getStretchPoints(const OdDgElement* pEnt, OdGePoint3dArray& stretchPoints) const { OdResult res = getGripPoints(pEnt, stretchPoints); if (res == eOk) { stretchPoints.resize(stretchPoints.size() - 1); } return res; } //============================================================================================== OdResult OdDgAutoplantBoltGripPointsPE::moveStretchPointsAt(OdDgElement* pEnt, const OdIntArray& indices, const OdGeVector3d& offset) { return moveGripPointsAt(pEnt, indices, offset); } //============================================================================================== OdResult OdDgAutoplantBoltGripPointsPE::getOsnapPoints(const OdDgElement* pEnt, OdDgElement::OsnapMode osnapMode, OdGsMarker gsSelectionMark, const OdGePoint3d& pickPoint, const OdGePoint3d& lastPoint, const OdGeMatrix3d& xWorldToEye, OdGePoint3dArray& snapPoints) const { OdDgAutoplantBoltPtr pBolt = pEnt; switch (osnapMode) { case OdDgElement::kOsModeEnd: { snapPoints.append(pBolt->getOrigin()); } break; default: { } break; } return eOk; } //==============================================================================================