/////////////////////////////////////////////////////////////////////////////// // 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. /////////////////////////////////////////////////////////////////////////////// #ifndef __OD_GS_AWAREFLAGS_ARRAY__ #define __OD_GS_AWAREFLAGS_ARRAY__ #include "TD_PackPush.h" #include "OdVector.h" #include "GsViewPropsDef.h" /** \details This class is a service class for handling of viewport aware flags array. Corresponding C++ library: TD_Gs */ class OdGsAwareFlagsArray { public: OdGsAwareFlagsArray() {} enum : OdUInt32 { kChildrenNotUpToDate = 0x80000000, // special flag to use in setChildrenUpToDate / childrenUpToDate // per each viewport, flags are stored in m_vpAwareFlags kInvalidAwareFlags = 0xFFFFFFFF & ~kEntityRegenDraw }; void setChildrenUpToDate(bool childrenUpToDate, const OdUInt32 nVpID); void setChildrenUpToDate(bool childrenUpToDate); bool childrenUpToDate(OdUInt32 nVpID) const; bool childrenRegenDraw(OdUInt32 nVpID) const; OdUInt32 get(OdUInt32 nVpID) const; void set(OdUInt32 nVpID, OdUInt32 flags); void clear() { m_vpAwareFlags.clear(); } bool isEmpty() const { return m_vpAwareFlags.isEmpty(); } OdUInt32 numAwareFlags() const { return m_vpAwareFlags.size(); } bool areInvalid(OdUInt32 nVpID) const; void setInvalid(OdUInt32 nVpID) { if (m_vpAwareFlags.size() > nVpID) m_vpAwareFlags[nVpID] = kInvalidAwareFlags; } protected: bool findFlag(OdUInt32 nVpID) const { return nVpID < m_vpAwareFlags.size(); } OdUInt32Vector &vpAwareFlags() { return m_vpAwareFlags; } const OdUInt32Vector &vpAwareFlags() const { return m_vpAwareFlags; } void setFlagAlloc(bool bVal, const OdUInt32 nFlag, const OdUInt32 nVpID); private: // viewport aware flags OdUInt32Vector m_vpAwareFlags; // this memory is never shared, no need in OdArray with refcounter on buffer }; inline void OdGsAwareFlagsArray::setFlagAlloc(bool bVal, const OdUInt32 nFlag, const OdUInt32 nVpID) { OdUInt32Vector::size_type n = m_vpAwareFlags.size(); if (n <= nVpID) m_vpAwareFlags.insert(m_vpAwareFlags.end(), nVpID + 1 - n, kInvalidAwareFlags); SETBIT(m_vpAwareFlags[nVpID], nFlag, bVal); } inline void OdGsAwareFlagsArray::setChildrenUpToDate(bool childrenUpToDate, const OdUInt32 nVpID) { setFlagAlloc(!childrenUpToDate, kChildrenNotUpToDate, nVpID); } inline void OdGsAwareFlagsArray::setChildrenUpToDate(bool childrenUpToDate) { ODA_ASSERT(!childrenUpToDate); for (OdUInt32 i = 0; i < m_vpAwareFlags.size(); ++i) SETBIT(m_vpAwareFlags[i], kChildrenNotUpToDate, !childrenUpToDate); } inline bool OdGsAwareFlagsArray::childrenUpToDate(OdUInt32 nVpID) const { if (findFlag(nVpID)) return !GETBIT(m_vpAwareFlags[nVpID], kChildrenNotUpToDate); return false; } inline bool OdGsAwareFlagsArray::childrenRegenDraw(OdUInt32 nVpID) const { if (findFlag(nVpID)) return GETBIT(m_vpAwareFlags[nVpID], kEntityRegenDraw); return false; } inline OdUInt32 OdGsAwareFlagsArray::get(OdUInt32 nVpID) const { if (findFlag(nVpID)) return m_vpAwareFlags[nVpID] & ~kChildrenNotUpToDate; return kInvalidAwareFlags; } inline void OdGsAwareFlagsArray::set(OdUInt32 nVpID, OdUInt32 flags) { flags &= ~kChildrenNotUpToDate; OdUInt32Vector::size_type n = m_vpAwareFlags.size(); if (n <= nVpID) { m_vpAwareFlags.insert(m_vpAwareFlags.end(), nVpID + 1 - n, kInvalidAwareFlags); m_vpAwareFlags[nVpID] = flags; } else { m_vpAwareFlags[nVpID] = ((m_vpAwareFlags[nVpID] & kChildrenNotUpToDate) | flags); } } inline bool OdGsAwareFlagsArray::areInvalid(OdUInt32 nVpID) const { if (findFlag(nVpID)) return m_vpAwareFlags[nVpID] == kInvalidAwareFlags; return true; } #include "TD_PackPop.h" #endif // __OD_GS_AWAREFLAGS_ARRAY__