CFx SDK Documentation 2024 SP0
Loading...
Searching...
No Matches
GsContainerNode.h
Go to the documentation of this file.
1
2// Copyright (C) 2002-2022, 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-2022 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 enum
50 {
51 kEntityListValid = OdGsNode::kLastFlag << 1,
52 kCheckWorkset = OdGsNode::kLastFlag << 2,
53 kHasStockData = OdGsNode::kLastFlag << 3,
54 kVpDepCache = OdGsNode::kLastFlag << 4,
55 kLastFlag = kVpDepCache
56 };
57
58 enum
59 {
60 kChildrenNotUpToDate = 0x80000000 //special flag to use in setChildrenUpToDate/childrenUpToDate
61 //per each viewport, flags are stored in m_vpAwareFlags
62 };
63
65
67 {
70 LightsList m_lightPtrs; // some of the lights are entities (ones that lies in model space)
74 OdUInt32 m_nChildErased, m_nChildErasedPermanently;
78 OdGsUpdateExtents m_realExtents; //Keeps real extents (for EXTMIN/MAX support)
79
80 enum
81 {
84 };
85
87 static OdSmartPtr<VpData> createObject(bool bShareable = false);
88 };
91
92 inline VpData *getVpData(OdUInt32 nVpId, bool bCreateIfNotFound = true) const;
93 VpData *makeVpData(OdUInt32 nVpId) const;
94 inline OdUInt32 vpDataId(const VpData *pVpData) const;
95public:
96
104 inline bool hasVpData(OdUInt32 nVpId) const;
105
111 inline OdUInt32 numVpData() const;
112
118
122 void setEntityListsInvalid();
123
132 OdUInt32 viewportId(const OdGsViewImpl &pView, bool bForceVpId = true) const;
133
139 inline bool isVpDepCache() const;
140
145 void setVpDepCache(const OdGsViewImpl &pView);
146public:
155 void setEntityListValid(OdUInt32 nVpId, bool entityListValid);
156
165 bool childrenUpToDate(OdUInt32 nVpId) const;
166
171 bool needRegen(OdUInt32 nVpId) const;
172
179
185
189 virtual ENodeType nodeType() const { return kContainerNode; }
190
195 virtual void displayEntityList(OdGsDisplayContext& ctx);
196
201 OdGsEntityNode* firstEntityNode(OdUInt32 nVpId);
206 const OdGsEntityNode* firstEntityNode(OdUInt32 nVpId) const;
211 OdGsEntityNode* lastEntityNode(OdUInt32 nVpId);
216 const OdGsEntityNode* lastEntityNode(OdUInt32 nVpId) const;
221 OdList<OdGsLightNode*> &lightNodesList(OdUInt32 nVpId);
226 const OdList<OdGsLightNode*> &lightNodesList(OdUInt32 nVpId) const;
227
269 OdUInt32 awareFlags(OdUInt32 viewportId) const;
270
313 void setAwareFlags(OdUInt32 viewportId, OdUInt32 flags);
314
315protected:
317 bool saveVpData(OdGsFiler *pFiler, const VpData *pVpData) const;
318 bool loadVpData(OdGsFiler *pFiler, VpData *pVpData);
319
320public:
322
330 OdGsContainerNode(OdGsBaseModel* pModel, const OdGiDrawable* pUnderlyingDrawable, bool bSetGsNode = true);
331
336
346 bool entityListValid(OdUInt32 nVpId) const;
347
355 bool allEntityListsValid() const;
356
362 bool isEmpty() const;
363
371 void setChildrenUpToDate(bool childrenUpToDate, const OdUInt32* nVpID = NULL);
372
379 bool childrenRegenDraw(OdUInt32 nVpID) const;
380
386 void setChildrenRegenDraw(bool bVal, OdUInt32 nVpID);
387
393 virtual void addChild(const OdGiDrawable* pDrawable, OdGsViewImpl *pView, bool unerased = false);
394
395 /* \details
396 Adds information about the light if the light doesn't have gsNode yet.
397 \param ctx [in] Current update context.
398 \param pDrawable [in] Pointer to the Drawable object.
399 */
400 virtual void addLight(OdGsUpdateContext& ctx, const OdGiDrawable* pDrawable);
401 /* \details
402 Removes information about the light added through addLight method.
403 \param pOwner [in] gsNode of the owner entity.
404 \param nVpId [in] Optional Viewport ID.
405 */
406 virtual void removeLights(OdGsNode *pOwner, OdUInt32 nVpId = 0xFFFFFFFF);
407
412 virtual void removeChild(OdGsNode* pNode);
413
420 void update(OdGsUpdateContext& ctx, OdGsContainerNode* pParent, OdSiSpatialIndex* pParentIndex);
421
426 void updateVisible( OdGsViewImpl* pViewImpl );
427
432 void display(OdGsDisplayContext& ctx);
433
438 OdSiSpatialIndex& spatialIndex(OdUInt32 nVpId);
443 const OdSiSpatialIndex& spatialIndex(OdUInt32 nVpId) const;
444
449
454
459 bool extents(OdGeExtents3d& extents) const;
460
465 virtual bool extents(const OdGsView* pView, OdGeExtents3d& ext) const;
466
471
472 bool checkWorkset() const;
473 void setCheckWorkset(bool bVal);
474
475 virtual bool updateEntityList(OdGsUpdateContext& ctx);
476
477 virtual void updateEntities(OdGsUpdateContext& ctx);
478
486
496 bool highlightSubnodes(OdUInt32 nSubnodes, bool bHighlight, bool bAll, OdUInt32 nSelStyle = 0);
497
501 void destroy();
502
507
512 inline const OdGsUpdateExtents& realExtents(OdUInt32 nVpId) const;
513
519 inline void setRealExtents(OdUInt32 nVpId, const OdGsUpdateExtents& ext);
520
521 inline void addViewRef(OdUInt32 nVpId);
522 inline void removeViewRef(OdUInt32 nVpId);
523 inline const ViewRefs& viewRefs() const;
524
525 inline const StockProps& stock() const;
526 void makeStock();
529
538 bool saveNodeState(OdGsFiler *pFiler, OdGsBaseVectorizer *pVectorizer = NULL) const;
539
548 bool loadNodeState(OdGsFiler *pFiler, OdGsBaseVectorizer *pVectorizer = NULL);
549
558
568 bool safeEntityUpdate(OdGsEntityNode* pEntity, OdGsUpdateContext& ctx, OdSiSpatialIndex* pSpatialIndex);
569
575 void addEntProps(const OdGsUpdateContext& ctx);
576
584 bool doMTUpdate(OdGsUpdateContext& ctx);
585
591 void doSTUpdate(OdGsUpdateContext& ctx);
592
597
602 inline int numberOfChildren(OdUInt32 nVpId) const;
603 inline OdUInt32 numberOfChildrenST(OdUInt32 nVpId) const;
604 inline OdUInt32 numberOfChildrenErased(OdUInt32 nVpId) const;
605protected:
608 OdUInt32Vector m_vpAwareFlags; //this memory is never shared, no need in OdArray with refcounter on buffer
612public:
613 mutable OdMutex m_nodesMutex; // to protect nodes list from modification when acessing it
614
615public:
622 void addContentToUpdateManager( OdUInt32 viewportId, OdGsUpdateManager* pManager, const UpdateManagerContext& context );
623
630 bool isMetafilesCompatible( const OdGsViewImpl* pView1, const OdGsViewImpl* pView2, OdGsUpdateContext* ctx );
631};
632
633inline OdGsContainerNode::VpData *OdGsContainerNode::getVpData(OdUInt32 nVpId, bool bCreateIfNotFound) const
634{
636 return m_shareableData;
637 VpData *pVpData = (m_vpData.size() > nVpId) ? m_vpData[nVpId].get() : NULL;
638 if (!pVpData && bCreateIfNotFound)
639 return makeVpData(nVpId);
640 return pVpData;
641}
642
643inline OdUInt32 OdGsContainerNode::vpDataId(const VpData *pVpData) const
644{
646 {
647 const OdUInt32 nVpData = m_vpData.size();
648 const VpDataPtr *pVpDataPtr = m_vpData.getPtr();
649 for (OdUInt32 nVpId = 0; nVpId < nVpData; nVpId++)
650 {
651 if (pVpDataPtr[nVpId].get() == pVpData)
652 return nVpId;
653 }
654 }
655 return 0;
656}
657
659{
661 return true;
662 return ((m_vpData.size() > nVpId) && !m_vpData.getAt(nVpId).isNull());
663}
664
666{
668 return 1;
669 return m_vpData.size();
670}
671
673{
674 return GETBIT(m_flags, kVpDepCache);
675}
676
678{
679 if (!isVpDepCache())
681 const VpData *pVpData = getVpData(nVpId, false);
682 if (pVpData)
683 return GETBIT(pVpData->m_flags, kEntityListValid);
684 return false;
685}
686
688{
690}
691
692inline bool OdGsContainerNode::isEmpty() const
693{
694 const OdUInt32 nVpData = numVpData();
695 for (OdUInt32 nView = 0; nView < nVpData; nView++)
696 {
697 const VpData *pVpData = getVpData(nView, false);
698 if (pVpData && pVpData->m_pFirstEntity)
699 return false;
700 }
701 return true;
702}
703
705{
706 for (OdUInt32 nView = 0; nView < numVpData(); nView++)
707 {
708 if (hasVpData(nView))
710 }
712}
713
714inline void OdGsContainerNode::setEntityListValid(OdUInt32 nVpId, bool bValid)
715{
716 SETBIT(getVpData(nVpId)->m_flags, kEntityListValid, bValid);
717 if (!bValid || !isVpDepCache())
719 else
720 { // Check does all entity lists valid
721 const OdUInt32 nViews = numVpData();
722 bool bAllListsValid = true;
723 for (OdUInt32 nView = 0; nView < nViews; nView++)
724 {
725 const VpData *pVpData = getVpData(nView, false);
726 if (pVpData && !GETBIT(pVpData->m_flags, VpData::kEntityListValid))
727 {
728 bAllListsValid = false;
729 break;
730 }
731 }
732 SETBIT(m_flags, kEntityListValid, bAllListsValid);
733 }
734}
735
737{
738 return *getVpData(nVpId)->m_pSpIndex.get();
739}
740
742{
743 return *getVpData(nVpId)->m_pSpIndex.get();
744}
745
747{
748 VpData *pVpData = getVpData(nVpId, false);
749 if (!pVpData)
750 return NULL;
751 return pVpData->m_pFirstEntity;
752}
753
755{
756 VpData *pVpData = getVpData(nVpId, false);
757 if (!pVpData)
758 return NULL;
759 return pVpData->m_pFirstEntity;
760}
761
763{
764 VpData *pVpData = getVpData(nVpId, false);
765 if (!pVpData)
766 return NULL;
767 return pVpData->m_pLastEntity;
768}
769
771{
772 VpData *pVpData = getVpData(nVpId, false);
773 if (!pVpData)
774 return NULL;
775 return pVpData->m_pLastEntity;
776}
777
779{
780 return getVpData(nVpId)->m_lightPtrs;
781}
782
784{
785 return getVpData(nVpId)->m_lightPtrs;
786}
787
789{
790 if(m_vpAwareFlags.size()>nVpID)
792 return false;
793}
794
795inline void OdGsContainerNode::setChildrenUpToDate(bool bValid, const OdUInt32* nVpID)
796{
797 if(nVpID)
798 {
800 if(n <= *nVpID)
801 m_vpAwareFlags.insert(m_vpAwareFlags.end(), (*nVpID)+1-n, 0xFFFFFFFF);
802 SETBIT(m_vpAwareFlags[*nVpID], kChildrenNotUpToDate, !bValid);
803 }
804 else
805 {
806 ODA_ASSERT(!bValid);
807 for(OdUInt32 i = 0; i < m_vpAwareFlags.size(); ++i)
809 }
810}
811
813{
814 if(m_vpAwareFlags.size()>nVpID)
815 return m_vpAwareFlags[nVpID] & ~kChildrenNotUpToDate;
816 return 0xFFFFFFFF;
817}
818
820{
821 flags &= ~kChildrenNotUpToDate;
823 if(n <= nVpID)
824 {
825 m_vpAwareFlags.insert(m_vpAwareFlags.end(), nVpID+1-n, 0xFFFFFFFF);
826 m_vpAwareFlags[nVpID] = flags;
827 }
828 else
829 {
830 m_vpAwareFlags[nVpID] = ((m_vpAwareFlags[nVpID] & kChildrenNotUpToDate) | flags);
831 }
832}
833
835{
836 if(!childrenUpToDate(nVpID))
837 return true;
838
839 OdUInt32 nAF = awareFlags(nVpID);
840 return ( nAF == 0xFFFFFFFF || ( baseModel()->viewChanges(nVpID) & nAF) != 0 );
841}
842
844{
846}
847
849{
851}
852
854{
855 if(m_vpAwareFlags.size()>nVpID)
856 return GETBIT(m_vpAwareFlags[nVpID], kEntityRegenDraw);
857 return false;
858}
859
861{
863 if(n <= nVpID)
864 m_vpAwareFlags.insert(m_vpAwareFlags.end(), nVpID+1-n, 0xFFFFFFFF);
866}
867
869{
870 VpData *pVpData = getVpData(nVpId, false);
871 if (!pVpData)
873 return getVpData(nVpId)->m_realExtents;
874}
875
877{
878 VpData *pVpData = getVpData(nVpId);
879 pVpData->m_realExtents = ext;
880}
881
883{
884 m_viewRefs.add(nVpId);
885}
886
888{
889 m_viewRefs.remove(nVpId);
890}
891
893{
894 return m_viewRefs;
895}
896
898{
899 return m_stock;
900}
901
903{
904 return getVpData(nVpId)->m_nChild;
905}
906
908{
909 return getVpData(nVpId)->m_nChildSingleThreaded;
910}
911
913{ VpData *pVpData = getVpData(nVpId);
914 return pVpData->m_nChildErased + pVpData->m_nChildErasedPermanently;
915}
916
917#include "TD_PackPop.h"
918
919#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
#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
bool isNull() const
Definition: BaseObjectPtr.h:86
void setRealExtents(OdUInt32 nVpId, const OdGsUpdateExtents &ext)
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)
bool isEmpty() const
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)
bool isMetafilesCompatible(const OdGsViewImpl *pView1, const OdGsViewImpl *pView2, OdGsUpdateContext *ctx)
void turnOnLights(OdGsBaseVectorizer &view)
OdUInt32 isAttached(OdGsEntityNode *pNode) const
OdMutexPtr m_lightsMutex
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
VpDataPtr m_shareableData
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()
VpDataArray m_vpData
virtual void displayEntityList(OdGsDisplayContext &ctx)
OdUInt32 m_flags
Definition: GsNode.h:91
@ kLastFlag
Definition: GsNode.h:88
OdGsBaseModel * baseModel() const
Definition: GsNode.h:413
static GS_STATIC_EXPORT const OdGsUpdateExtents kInvalid
Definition: Gs.h:140
Definition: OdList.h:50
const T * get() const
Definition: SmartPtr.h:339
const T & getAt(size_type index) const
Definition: OdVector.h:1407
size_type size() const
Definition: OdVector.h:1204
const T * getPtr() const
Definition: OdVector.h:1356
void insert(iterator before, const_iterator first, const_iterator afterLast)
Definition: OdVector.h:885
iterator end()
Definition: OdVector.h:873
void remove(OdUInt32 viewportId)
Definition: GsViewProps.h:209
void add(OdUInt32 viewportId)
Definition: GsViewProps.h:194
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)