CFx SDK Documentation  2022 SP0
GsViewLocalId.h
Go to the documentation of this file.
1 // Copyright (C) 2002-2017, 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 Teigha(R) software pursuant to a license
16 // agreement with Open Design Alliance.
17 // Teigha(R) Copyright (C) 2002-2017 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 #ifndef __OD_GS_VIEW_LOCAL_ID__
24 #define __OD_GS_VIEW_LOCAL_ID__
25 
26 #include "Gs/Gs.h"
27 
28 #include "TD_PackPush.h"
29 
30 class OdGsViewImpl;
31 class OdGsBaseModel;
32 
33 /* Note:
34  All GsNode's locally owned by only one GsModel, so GsNode metafiles is also owned by GsModel. GsModel could be shared
35  between different rendering modules. But viewportId is creating from SlotManager owned by rendering device, so
36  viewportId's for different devices will lie in same range, so couldn't be used as unique view identifier inside
37  GsModel. To solve problem we create for each GsModel their own SlotManager which is used for generate unique
38  viewportId for each view referenced by GsModel. This localViewportId is stored on GsModel side, view access to it
39  and store it's own copy localViewportId for optimization purposes (this is not problem for MT because only one
40  GsModel is used per parallel vectorization.
41 */
42 
50 {
51  /* Note: the initial registration will be done on addViewRef. But for example MT ghost views or views
52  of layout helper will do registration on first update. In this case first of all we
53  search exist registered view, if it is doesn't exist we search view with similar viewportId
54  and similar device (case of MT ghost view and layout helper view). Composite device
55  must register view ID manually. */
56  public:
57  // Call on view deletion to clear model view entry
58  virtual void onViewDelete(OdGsViewImpl *pView) = 0;
59  // Manually reset Id
60  virtual void resetViewId(OdGsViewImpl *pView, OdUInt32 nId) = 0;
61  // Get current view Id (or -1 if view doesn't registered)
62  virtual OdUInt32 getViewId(OdGsViewImpl *pView) = 0;
63  // Make view registration (you must check first does id is already registered)
64  virtual OdUInt32 registerView(OdGsViewImpl *pView) = 0;
65  // Get maximum registered Id
66  virtual OdUInt32 getMaxId() const = 0;
67 
69 };
71 
78 // Used in OdGsViewImpl
80 {
81  protected:
86  public:
87  explicit OdGsViewLocalId(OdGsViewImpl *pView = NULL)
88  : m_pLocalIdModel(NULL)
89  , m_localId(0)
90  , m_pView(pView)
91  {
92  }
94 
95  void setView(OdGsViewImpl *pView)
96  {
97  m_pView = pView;
98  }
99  OdGsViewImpl *view() const
100  {
101  return m_pView;
102  }
103 
104  // Gets local viewport Id optimized
106  {
107  if (m_pLocalIdModel == pModel)
108  return m_localId;
109  m_pLocalIdModel = pModel;
110  return m_localId = getLocalViewportId(pModel);
111  }
112  // Gets local viewport Id directly from GsModel
114 
115  // Reset current state
116  void reset()
117  {
118  m_pLocalIdModel = NULL;
119  m_localId = 0;
120  }
121 
123  {
124  return m_localIdRefs;
125  }
126 };
127 
128 #define ODGS_LOCAL_IDS
129 
130 #include "TD_PackPop.h"
131 
132 #endif // __OD_GS_VIEW_LOCAL_ID__
#define GS_TOOLKIT_EXPORT
Definition: GsExport.h:37
#define NULL
Definition: GsProperties.h:177
OdSmartPtr< OdGsBaseModelLocalIds > OdGsBaseModelLocalIdsPtr
Definition: GsViewLocalId.h:70
unsigned int OdUInt32
virtual void resetViewId(OdGsViewImpl *pView, OdUInt32 nId)=0
virtual void onViewDelete(OdGsViewImpl *pView)=0
virtual OdUInt32 registerView(OdGsViewImpl *pView)=0
virtual OdUInt32 getMaxId() const =0
static OdSmartPtr< OdGsBaseModelLocalIds > createObject()
virtual OdUInt32 getViewId(OdGsViewImpl *pView)=0
OdUInt32 m_localId
Definition: GsViewLocalId.h:83
void setView(OdGsViewImpl *pView)
Definition: GsViewLocalId.h:95
OdUInt32 getLocalViewportId(const OdGsBaseModel *pModel) const
const OdGsBaseModel * m_pLocalIdModel
Definition: GsViewLocalId.h:82
OdGsViewImpl * m_pView
Definition: GsViewLocalId.h:85
OdArray< OdGsBaseModelLocalIdsPtr > m_localIdRefs
Definition: GsViewLocalId.h:84
OdUInt32 localViewportId(const OdGsBaseModel *pModel) const
OdArray< OdGsBaseModelLocalIdsPtr > & refs()
OdGsViewLocalId(OdGsViewImpl *pView=NULL)
Definition: GsViewLocalId.h:87
OdGsViewImpl * view() const
Definition: GsViewLocalId.h:99