CFx SDK Documentation 2026 SP0
Loading...
Searching...
No Matches
GsContainerNode.h
Go to the documentation of this file.
1
2// Copyright (C) 2002-2024, Open Design Alliance (the "Alliance").
3// All rights reserved.
4//
5// This software and its documentation and related materials are owned by
6// the Alliance. The software may only be incorporated into application
7// programs owned by members of the Alliance, subject to a signed
8// Membership Agreement and Supplemental Software License Agreement with the
9// Alliance. The structure and organization of this software are the valuable
10// trade secrets of the Alliance and its suppliers. The software is also
11// protected by copyright law and international treaty provisions. Application
12// programs incorporating this software must include the following statement
13// with their copyright notices:
14//
15// This application incorporates Open Design Alliance software pursuant to a license
16// agreement with Open Design Alliance.
17// Open Design Alliance Copyright (C) 2002-2024 by Open Design Alliance.
18// All rights reserved.
19//
20// By use of this software, its documentation or related materials, you
21// acknowledge and accept the above terms.
23
24#ifndef __OD_GS_CONTAINER_NODE__
25#define __OD_GS_CONTAINER_NODE__
26
27#include "TD_PackPush.h"
28
29#include "Gs/GsNode.h"
30#include "Gs/GsDrawableHolder.h"
31#include "Si/SiSpatialIndex.h"
32#include "OdVector.h"
33#include "ThreadsCounter.h"
34
35class OdGsEntityNode;
36class OdGsLightNode;
37class OdGsBlockNode;
38
47{
48protected:
49 //DOM-IGNORE-BEGIN
50
51 enum
52 {
58 };
59
60 enum
61 {
62 kChildrenNotUpToDate = 0x80000000 //special flag to use in setChildrenUpToDate/childrenUpToDate
63 //per each viewport, flags are stored in m_vpAwareFlags
64 };
65
67
94
95 inline VpData *getVpData(OdUInt32 nVpId, bool bCreateIfNotFound = true) const;
96 VpData *makeVpData(OdUInt32 nVpId) const;
97 inline OdUInt32 vpDataId(const VpData *pVpData) const;
98
99 //DOM-IGNORE-END
100public:
101
109 inline bool hasVpData(OdUInt32 nVpId) const;
110
116 inline OdUInt32 numVpData() const;
117
123
128
137 OdUInt32 viewportId(const OdGsViewImpl &pView, bool bForceVpId = true) const;
138
144 inline bool isVpDepCache() const;
145
150 void setVpDepCache(const OdGsViewImpl &pView);
151public:
161
170 bool childrenUpToDate(OdUInt32 nVpId) const;
171
176 bool needRegen(OdUInt32 nVpId) const;
177
184
190
194 virtual ENodeType nodeType() const { return kContainerNode; }
195
201
211 const OdGsEntityNode* firstEntityNode(OdUInt32 nVpId) const;
221 const OdGsEntityNode* lastEntityNode(OdUInt32 nVpId) const;
232
275
319
320protected:
322 bool saveVpData(OdGsFiler *pFiler, const VpData *pVpData) const;
323 bool loadVpData(OdGsFiler *pFiler, VpData *pVpData);
324
325public:
327
335 OdGsContainerNode(OdGsBaseModel* pModel, const OdGiDrawable* pUnderlyingDrawable, bool bSetGsNode = true);
336
341
351 bool entityListValid(OdUInt32 nVpId) const;
352
360 bool allEntityListsValid() const;
361
367 bool isEmpty() const;
368
376 void setChildrenUpToDate(bool childrenUpToDate, const OdUInt32* nVpID = NULL);
377
384 bool childrenRegenDraw(OdUInt32 nVpID) const;
385
391 void setChildrenRegenDraw(bool bVal, OdUInt32 nVpID);
392
398 virtual void addChild(const OdGiDrawable* pDrawable, OdGsViewImpl *pView, bool unerased = false);
399
400 /* \details
401 Adds information about the light if the light doesn't have gsNode yet.
402 \param ctx [in] Current update context.
403 \param pDrawable [in] Pointer to the Drawable object.
404 */
405 virtual void addLight(OdGsUpdateContext& ctx, const OdGiDrawable* pDrawable);
406 /* \details
407 Removes information about the light added through addLight method.
408 \param pOwner [in] gsNode of the owner entity.
409 \param nVpId [in] Optional Viewport ID.
410 */
411 virtual void removeLights(OdGsNode *pOwner, OdUInt32 nVpId = 0xFFFFFFFF);
412
417 virtual void removeChild(OdGsNode* pNode);
418
425 void update(OdGsUpdateContext& ctx, OdGsContainerNode* pParent, OdSiSpatialIndex* pParentIndex);
426
431 void updateVisible( OdGsViewImpl* pViewImpl );
432
438
448 const OdSiSpatialIndex& spatialIndex(OdUInt32 nVpId) const;
449
454
459
465
470 virtual bool extents(const OdGsView* pView, OdGeExtents3d& ext) const;
471
476
477 bool checkWorkset() const;
478 void setCheckWorkset(bool bVal);
479
480 virtual bool updateEntityList(OdGsUpdateContext& ctx);
481
482 virtual void updateEntities(OdGsUpdateContext& ctx);
483
491
501 bool highlightSubnodes(OdUInt32 nSubnodes, bool bHighlight, bool bAll, OdUInt32 nSelStyle = 0);
502
506 void destroy();
507
512
517 inline const OdGsUpdateExtents& realExtents(OdUInt32 nVpId) const;
518
524 inline void setRealExtents(OdUInt32 nVpId, const OdGsUpdateExtents& ext, bool bRecompute = false);
525
526 inline void addViewRef(OdUInt32 nVpId);
527 inline void removeViewRef(OdUInt32 nVpId);
528 inline const ViewRefs& viewRefs() const;
529
530 inline const StockProps& stock() const;
531 void makeStock();
534
543 bool saveNodeState(OdGsFiler *pFiler, OdGsBaseVectorizer *pVectorizer = NULL) const;
544
553 bool loadNodeState(OdGsFiler *pFiler, OdGsBaseVectorizer *pVectorizer = NULL);
554
563
573 bool safeEntityUpdate(OdGsEntityNode* pEntity, OdGsUpdateContext& ctx, OdSiSpatialIndex* pSpatialIndex);
574
580 void addEntProps(const OdGsUpdateContext& ctx);
581
589 bool doMTUpdate(OdGsUpdateContext& ctx);
590
596 void doSTUpdate(OdGsUpdateContext& ctx);
597
602
607 inline int numberOfChildren(OdUInt32 nVpId) const;
608 inline OdUInt32 numberOfChildrenST(OdUInt32 nVpId) const;
609 inline OdUInt32 numberOfChildrenErased(OdUInt32 nVpId) const;
610protected:
613 OdUInt32Vector m_vpAwareFlags; //this memory is never shared, no need in OdArray with refcounter on buffer
617public:
618 mutable OdMutex m_nodesMutex; // to protect nodes list from modification when acessing it
619
620public:
628
635 bool isMetafilesCompatible( const OdGsViewImpl* pView1, const OdGsViewImpl* pView2, OdGsUpdateContext* ctx );
636};
637
638inline OdGsContainerNode::VpData *OdGsContainerNode::getVpData(OdUInt32 nVpId, bool bCreateIfNotFound) const
639{
641 return m_shareableData;
642 VpData *pVpData = (m_vpData.size() > nVpId) ? m_vpData[nVpId].get() : NULL;
643 if (!pVpData && bCreateIfNotFound)
644 return makeVpData(nVpId);
645 return pVpData;
646}
647
648inline OdUInt32 OdGsContainerNode::vpDataId(const VpData *pVpData) const
649{
651 {
652 const OdUInt32 nVpData = m_vpData.size();
653 const VpDataPtr *pVpDataPtr = m_vpData.getPtr();
654 for (OdUInt32 nVpId = 0; nVpId < nVpData; nVpId++)
655 {
656 if (pVpDataPtr[nVpId].get() == pVpData)
657 return nVpId;
658 }
659 }
660 return 0;
661}
662
664{
666 return true;
667 return ((m_vpData.size() > nVpId) && !m_vpData.getAt(nVpId).isNull());
668}
669
671{
673 return 1;
674 return m_vpData.size();
675}
676
678{
679 return GETBIT(m_flags, kVpDepCache);
680}
681
683{
684 if (!isVpDepCache())
686 const VpData *pVpData = getVpData(nVpId, false);
687 if (pVpData)
688 return GETBIT(pVpData->m_flags, kEntityListValid);
689 return false;
690}
691
693{
695}
696
697inline bool OdGsContainerNode::isEmpty() const
698{
699 const OdUInt32 nVpData = numVpData();
700 for (OdUInt32 nView = 0; nView < nVpData; nView++)
701 {
702 const VpData *pVpData = getVpData(nView, false);
703 if (pVpData && pVpData->m_pFirstEntity)
704 return false;
705 }
706 return true;
707}
708
710{
711 for (OdUInt32 nView = 0; nView < numVpData(); nView++)
712 {
713 if (hasVpData(nView))
715 }
717}
718
719inline void OdGsContainerNode::setEntityListValid(OdUInt32 nVpId, bool bValid)
720{
721 SETBIT(getVpData(nVpId)->m_flags, kEntityListValid, bValid);
722 if (!bValid || !isVpDepCache())
724 else
725 { // Check does all entity lists valid
726 const OdUInt32 nViews = numVpData();
727 bool bAllListsValid = true;
728 for (OdUInt32 nView = 0; nView < nViews; nView++)
729 {
730 const VpData *pVpData = getVpData(nView, false);
731 if (pVpData && !GETBIT(pVpData->m_flags, VpData::kEntityListValid))
732 {
733 bAllListsValid = false;
734 break;
735 }
736 }
737 SETBIT(m_flags, kEntityListValid, bAllListsValid);
738 }
739}
740
742{
743 return *getVpData(nVpId)->m_pSpIndex.get();
744}
745
747{
748 return *getVpData(nVpId)->m_pSpIndex.get();
749}
750
752{
753 VpData *pVpData = getVpData(nVpId, false);
754 if (!pVpData)
755 return NULL;
756 return pVpData->m_pFirstEntity;
757}
758
760{
761 VpData *pVpData = getVpData(nVpId, false);
762 if (!pVpData)
763 return NULL;
764 return pVpData->m_pFirstEntity;
765}
766
768{
769 VpData *pVpData = getVpData(nVpId, false);
770 if (!pVpData)
771 return NULL;
772 return pVpData->m_pLastEntity;
773}
774
776{
777 VpData *pVpData = getVpData(nVpId, false);
778 if (!pVpData)
779 return NULL;
780 return pVpData->m_pLastEntity;
781}
782
787
789{
790 return getVpData(nVpId)->m_lightPtrs;
791}
792
794{
795 if(m_vpAwareFlags.size()>nVpID)
797 return false;
798}
799
800inline void OdGsContainerNode::setChildrenUpToDate(bool bValid, const OdUInt32* nVpID)
801{
802 if(nVpID)
803 {
805 if(n <= *nVpID)
806 m_vpAwareFlags.insert(m_vpAwareFlags.end(), (*nVpID)+1-n, 0xFFFFFFFF);
807 SETBIT(m_vpAwareFlags[*nVpID], kChildrenNotUpToDate, !bValid);
808 }
809 else
810 {
811 ODA_ASSERT(!bValid);
812 for(OdUInt32 i = 0; i < m_vpAwareFlags.size(); ++i)
814 }
815}
816
818{
819 if(m_vpAwareFlags.size()>nVpID)
821 return 0xFFFFFFFF;
822}
823
825{
826 flags &= ~kChildrenNotUpToDate;
828 if(n <= nVpID)
829 {
830 m_vpAwareFlags.insert(m_vpAwareFlags.end(), nVpID+1-n, 0xFFFFFFFF);
831 m_vpAwareFlags[nVpID] = flags;
832 }
833 else
834 {
835 m_vpAwareFlags[nVpID] = ((m_vpAwareFlags[nVpID] & kChildrenNotUpToDate) | flags);
836 }
837}
838
840{
841 if(!childrenUpToDate(nVpID))
842 return true;
843
844 OdUInt32 nAF = awareFlags(nVpID);
845 return ( nAF == 0xFFFFFFFF || ( baseModel()->viewChanges(nVpID) & nAF) != 0 );
846}
847
849{
851}
852
854{
856}
857
859{
860 if(m_vpAwareFlags.size()>nVpID)
861 return GETBIT(m_vpAwareFlags[nVpID], kEntityRegenDraw);
862 return false;
863}
864
866{
868 if(n <= nVpID)
869 m_vpAwareFlags.insert(m_vpAwareFlags.end(), nVpID+1-n, 0xFFFFFFFF);
871}
872
874{
875 VpData *pVpData = getVpData(nVpId, false);
876 if (!pVpData)
878 return getVpData(nVpId)->m_realExtents;
879}
880
881inline void OdGsContainerNode::setRealExtents(OdUInt32 nVpId, const OdGsUpdateExtents& ext, bool bRecompute)
882{
883 VpData *pVpData = getVpData(nVpId);
884 pVpData->m_realExtents = ext;
885 SETBIT(pVpData->m_flags, VpData::kRecomputeExtents, bRecompute);
886}
887
889{
890 m_viewRefs.add(nVpId);
891}
892
894{
895 m_viewRefs.remove(nVpId);
896}
897
899{
900 return m_viewRefs;
901}
902
904{
905 return m_stock;
906}
907
909{
910 return getVpData(nVpId)->m_nChild;
911}
912
917
919{ VpData *pVpData = getVpData(nVpId);
920 return pVpData->m_nChildErased + pVpData->m_nChildErasedPermanently;
921}
922
923#include "TD_PackPop.h"
924
925#endif // __OD_GS_CONTAINER_NODE__
#define ODA_ASSERT(exp)
Definition DebugStuff.h:57
ENodeType
Definition GsBaseModel.h:69
@ kContainerNode
Definition GsBaseModel.h:74
#define GS_TOOLKIT_EXPORT
Definition GsExport.h:37
@ kEntityRegenDraw
unsigned int OdUInt32
OdVector< OdUInt32, OdMemoryAllocator< OdUInt32 > > OdUInt32Vector
Definition OdVector.h:1713
#define SETBIT(flags, bit, value)
Definition OdaDefs.h:516
#define SETBIT_0(flags, bit)
Definition OdaDefs.h:519
#define GETBIT(flags, bit)
Definition OdaDefs.h:517
OdSmartPtr< OdSiSpatialIndex > OdSiSpatialIndexPtr
typename OdMemoryAllocator< OdUInt32 >::size_type size_type
Definition OdArray.h:837
virtual void updateEntities(OdGsUpdateContext &ctx)
OdUInt32 awareFlags(OdUInt32 viewportId) const
bool saveNodeState(OdGsFiler *pFiler, OdGsBaseVectorizer *pVectorizer=NULL) const
void addViewRef(OdUInt32 nVpId)
bool loadVpData(OdGsFiler *pFiler, VpData *pVpData)
OdList< OdGsLightNode * > & lightNodesList(OdUInt32 nVpId)
void invalidate(OdGsContainerNode *pParent, OdGsViewImpl *pView, OdUInt32 mask)
void setVpDepCache(const OdGsViewImpl &pView)
OdUInt32 currViewChanges() const
OdVector< VpDataPtr > VpDataArray
OdList< OdGsLightNode * > LightsList
virtual void removeChild(OdGsNode *pNode)
void setRealExtents(OdUInt32 nVpId, const OdGsUpdateExtents &ext, bool bRecompute=false)
bool isMetafilesCompatible(const OdGsViewImpl *pView1, const OdGsViewImpl *pView2, OdGsUpdateContext *ctx)
void turnOnLights(OdGsBaseVectorizer &view)
OdUInt32 isAttached(OdGsEntityNode *pNode) const
virtual void propagateLayerChanges(OdGsViewImpl &view)
void display(OdGsDisplayContext &ctx)
OdGsEntityNode * firstEntityNode(OdUInt32 nVpId)
OdGsEntityNode * lastEntityNode(OdUInt32 nVpId)
int numberOfChildren(OdUInt32 nVpId) const
OdUInt32 viewportId(const OdGsViewImpl &pView, bool bForceVpId=true) const
virtual bool extents(const OdGsView *pView, OdGeExtents3d &ext) const
virtual bool updateEntityList(OdGsUpdateContext &ctx)
const ViewRefs & viewRefs() const
bool findCompatibleCache(OdGsViewImpl &keyView)
ODRX_DECLARE_MEMBERS(OdGsContainerNode)
bool highlightSubnodes(OdUInt32 nSubnodes, bool bHighlight, bool bAll, OdUInt32 nSelStyle=0)
void setCheckWorkset(bool bVal)
virtual ENodeType nodeType() const
void addEntProps(const OdGsUpdateContext &ctx)
bool isVpDepCache() const
bool allEntityListsValid() const
bool saveVpData(OdGsFiler *pFiler, const VpData *pVpData) const
bool entityListValid(OdUInt32 nVpId) const
void doSTUpdate(OdGsUpdateContext &ctx)
OdUInt32 vpDataId(const VpData *pVpData) const
VpData * makeVpData(OdUInt32 nVpId) const
const OdGsUpdateExtents & realExtents(OdUInt32 nVpId) const
bool postprocessNodeLoading(OdGsFiler *pFiler)
VpData * getVpData(OdUInt32 nVpId, bool bCreateIfNotFound=true) const
void updateVisible(OdGsViewImpl *pViewImpl)
bool extents(OdGeExtents3d &extents) const
OdUInt32Vector m_vpAwareFlags
bool childrenUpToDate(OdUInt32 nVpId) const
void setChildrenUpToDate(bool childrenUpToDate, const OdUInt32 *nVpID=NULL)
bool doMTUpdate(OdGsUpdateContext &ctx)
bool safeEntityUpdate(OdGsEntityNode *pEntity, OdGsUpdateContext &ctx, OdSiSpatialIndex *pSpatialIndex)
void setChildrenRegenDraw(bool bVal, OdUInt32 nVpID)
void setAwareFlags(OdUInt32 viewportId, OdUInt32 flags)
OdSmartPtr< VpData > VpDataPtr
void addContentToUpdateManager(OdUInt32 viewportId, OdGsUpdateManager *pManager, const UpdateManagerContext &context)
virtual void addLight(OdGsUpdateContext &ctx, const OdGiDrawable *pDrawable)
virtual void addChild(const OdGiDrawable *pDrawable, OdGsViewImpl *pView, bool unerased=false)
OdUInt32 numberOfChildrenErased(OdUInt32 nVpId) const
OdSiSpatialIndex & spatialIndex(OdUInt32 nVpId)
bool needRegen(OdUInt32 nVpId) const
bool hasVpData(OdUInt32 nVpId) const
bool childrenRegenDraw(OdUInt32 nVpID) const
void propagateInvalidVpFlag()
virtual void removeLights(OdGsNode *pOwner, OdUInt32 nVpId=0xFFFFFFFF)
void addChildNode(OdUInt32 nVpId, OdGsEntityNode *pEnt)
OdUInt32 numVpData() const
OdGsContainerNode(OdGsBaseModel *pModel, const OdGiDrawable *pUnderlyingDrawable, bool bSetGsNode=true)
const StockProps & stock() const
bool loadNodeState(OdGsFiler *pFiler, OdGsBaseVectorizer *pVectorizer=NULL)
OdUInt32 numberOfChildrenST(OdUInt32 nVpId) const
void update(OdGsUpdateContext &ctx, OdGsContainerNode *pParent, OdSiSpatialIndex *pParentIndex)
bool checkWorkset() const
void removeViewRef(OdUInt32 nVpId)
void setEntityListValid(OdUInt32 nVpId, bool entityListValid)
void propagateLayerChangesStock()
virtual void displayEntityList(OdGsDisplayContext &ctx)
friend class OdGsViewImpl
Definition GsNode.h:62
OdUInt32 m_flags
Definition GsNode.h:93
@ kLastFlag
Definition GsNode.h:90
friend class OdGsBaseModel
Definition GsNode.h:61
OdGsBaseModel * baseModel() const
Definition GsNode.h:449
OdGsNode(OdGsBaseModel *pModel, const OdGiDrawable *pUnderlyingDrawable)
static GS_STATIC_EXPORT const OdGsUpdateExtents kInvalid
Definition Gs.h:141
const T * get() const
Definition SmartPtr.h:315
GLenum GLint GLuint mask
Definition gles2_ext.h:262
OdGsUpdateExtents m_realExtents
OdGsEntityNode * m_pClearSpatialQueryStateFirst
OdGsEntityNode * m_pLastEntity
OdSiSpatialIndexPtr m_pSpIndex
OdGsEntityNode * m_pFirstEntity
static OdSmartPtr< VpData > createObject(bool bShareable=false)