CFx SDK Documentation 2024 SP0
Loading...
Searching...
No Matches
TrVisExtensionObject.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// Extension data provider object interfaces
24
25#ifndef ODTRVISEXTENSIONOBJECT
26#define ODTRVISEXTENSIONOBJECT
27
28#include "TD_PackPush.h"
29
30#include "OdBlob.h"
31#include "StaticRxObject.h"
32#include "Ge/GeMatrix3d.h"
33#include "TrVisRenditionPu.h"
34
35// Forward declarations
38class OdTrVisCamera;
39class OdApcQueue;
40class OdTrVisMetafileWritersPool;
42
46class OdTrVisExtensionModule : public OdRxObject // @@@TODO: RxModule inheritance
47{
48 public:
49 virtual OdString moduleName() const = 0;
50 virtual OdUInt32 extensionVersion() const = 0;
51
52 // @@@TODO: module objects constructor and deserializer
53};
54
56
61{
62 public:
63 virtual const OdTrVisExtensionModule *extensionModule() const = 0;
64 virtual OdUInt32 moduleObjectType() const = 0;
65 virtual bool isProxyObject() const { return false; }
66
67 // Setup specific object data
68 virtual void setupSpecificData(OdUInt32 /*nDataId*/, const OdTrVisPropertyDef & /*propDef*/) {}
69
70 /* Serialization:
71 1) Which extension module contains object to load;
72 - So we will be able to load extension data provider in case if it is available;
73 2) Which version of object;
74 - So we will be able to check that serialized data is correct;
75 3) Object data size;
76 - So we will be able to skip this data in case if extension module is unavailable or version isn't fit;
77 4) Custom object data;
78 - So object will be able to restore their state, using stored data.
79 */
80 virtual void serialize(OdStreamBuf * /*pDataStream*/) const {}
81 virtual void deSerialize(OdStreamBuf * /*pDataStream*/) {}
82};
83
85
87{
88 protected:
89 class ModuleProxy : public OdStaticRxObject<OdTrVisExtensionModule>
90 { protected:
93 public: ModuleProxy() : m_moduleVersion(0) {}
94 virtual OdString moduleName() const { return m_moduleName; }
96 virtual OdUInt32 extensionVersion() const { return m_moduleVersion; }
101 public:
103
104 virtual const OdTrVisExtensionModule *extensionModule() const { return &m_moduleProxy; }
107
108 virtual OdUInt32 moduleObjectType() const { return m_nObjectType; }
109 void setObjectType(OdUInt32 nType) { m_nObjectType = nType; }
110
111 virtual bool isProxyObject() const { return true; }
112
113 template <OdUInt32 staticDataBufSize /*= 1024*/>
114 static void copyStream(OdStreamBuf *pBufIn, OdStreamBuf *pBufOut)
115 { OdUInt64 length = pBufIn->length();
116 OdUInt8 staticBuffer[staticDataBufSize];
117 while (length)
118 { const OdUInt32 nDataPart = (OdUInt32)odmin((OdUInt64)staticDataBufSize, length);
119 pBufIn->getBytes(staticBuffer, nDataPart);
120 pBufOut->putBytes(staticBuffer, nDataPart);
121 length -= nDataPart;
122 }
123 }
126
127 virtual void serialize(OdStreamBuf *pDataStream) const {
128 if (m_objectData.length())
129 copyStream<1024>(dataStreamForRead(), pDataStream);
130 }
131 virtual void deSerialize(OdStreamBuf *pDataStream)
132 { copyStream<1024>(pDataStream, dataStreamForWrite()); }
133};
134
139{
140 public:
141 virtual OdApcQueue &apcQueue() = 0;
142 virtual OdTrVisMetafileWritersPool &mfWritersPool() = 0;
143};
144
146
151{
152 protected:
157 public:
161 pObj->setup(viewportId, overlayId);
162 return pObj; }
166 pObj->setup(viewportId, overlayId, pRenditionHost, camera, modelXform);
167 return pObj; }
168
171 { m_pRenditionHost = pRenditionHost; m_pCamera = &camera; m_modelXform = modelXform; }
174 setup(pRenditionHost, camera, modelXform); }
175
176 const OdTrVisCamera &camera() const { return *m_pCamera; }
177 const OdGeMatrix3d &modelXform() const { return m_modelXform; }
179};
180
182
187{
188 protected:
190 public:
193 pObj->setup(pExternal);
194 return pObj; }
197 pObj->setup(viewportId, overlayId);
198 return pObj;
199 }
200
202 void setup(const OdTrVisExtensionObjectInvocation *pExternal = NULL)
204
206};
207
209
214{
215 public:
216 // Returns invocation object if requested data ready to receive.
218 OdTrVisExtensionObjectMtContext *pMtCtx = NULL) = 0;
219 virtual void releaseData(const OdTrVisExtensionObjectInvocation *pInvocation, const OdTrVisRendition *pRendition = NULL) = 0;
220
221 // Invocation can be null here, but in this case nothing will be received. Must be used invocation returned by requestData, since it can be modified there.
222 virtual bool receiveData(const OdTrVisExtensionObjectInternalInvocation *pInvocation, OdTrVisRenderDataInvoke *pReceiver) = 0;
223 protected:
225 { // Only to support OdTrVisRenderDataDirectAccessor. Doesn't require customizations.
226 return receiveData(static_cast<const OdTrVisExtensionObjectInternalInvocation*>(pInvocation), pInvocation->wrapInvoke(pInvoke));
227 }
228};
229
231
232#include "TD_PackPop.h"
233
234#endif // ODTRVISEXTENSIONOBJECT
#define odmin(X, Y)
Definition: OdPlatform.h:34
unsigned int OdUInt32
unsigned char OdUInt8
#define ODRX_SEALED_VIRTUAL
#define ODRX_SEALED
const OdTrVisId kTrVisNullId
Definition: TrVisDefs.h:134
OdSmartPtr< OdTrVisExtensionObjectMtContext > OdTrVisExtensionObjectMtContextPtr
OdSmartPtr< OdTrVisExtensionModule > OdTrVisExtensionModulePtr
OdSmartPtr< OdTrVisExtensionObjectInvocation > OdTrVisExtensionObjectInvocationPtr
OdSmartPtr< OdTrVisExtensionGraphicObject > OdTrVisExtensionGraphicObjectPtr
OdSmartPtr< OdTrVisExtensionObject > OdTrVisExtensionObjectPtr
OdSmartPtr< OdTrVisExtensionObjectInternalInvocation > OdTrVisExtensionObjectInternalInvocationPtr
Definition: OdBlob.h:45
static OdSmartPtr< TInterface > createObject()
Definition: RxObjectImpl.h:107
virtual OdUInt64 length()
virtual void getBytes(void *buffer, OdUInt32 numBytes)
virtual void putBytes(const void *buffer, OdUInt32 numBytes)
void setup(OdTrVisViewportId viewportId, OdTrVisOverlayId overlayId)
virtual OdTrVisRenderDataInvoke * wrapInvoke(OdTrVisRenderDataInvokeHid *pInvoke) const
virtual bool receiveData(const OdTrVisExtensionObjectInternalInvocation *pInvocation, OdTrVisRenderDataInvoke *pReceiver)=0
ODRX_SEALED_VIRTUAL bool collectRenderData(const OdTrVisDirectRenderPartialUpdateInvocation *pInvocation, OdTrVisRenderDataInvokeHid *pInvoke) ODRX_SEALED
virtual void releaseData(const OdTrVisExtensionObjectInvocation *pInvocation, const OdTrVisRendition *pRendition=NULL)=0
virtual const OdTrVisExtensionObjectInternalInvocation * requestData(const OdTrVisExtensionObjectInvocation *pInvocation, OdTrVisExtensionObjectMtContext *pMtCtx=NULL)=0
virtual OdString moduleName() const =0
virtual OdUInt32 extensionVersion() const =0
virtual bool isProxyObject() const
virtual void deSerialize(OdStreamBuf *)
virtual OdUInt32 moduleObjectType() const =0
virtual void serialize(OdStreamBuf *) const
virtual const OdTrVisExtensionModule * extensionModule() const =0
virtual void setupSpecificData(OdUInt32, const OdTrVisPropertyDef &)
static OdSmartPtr< OdTrVisExtensionObjectInternalInvocation > createObject(OdTrVisViewportId viewportId, OdTrVisOverlayId overlayId)
OdTrVisExtensionObjectInvocationPtr m_pExternal
void setup(const OdTrVisExtensionObjectInvocation *pExternal=NULL)
static OdSmartPtr< OdTrVisExtensionObjectInternalInvocation > createObject(const OdTrVisExtensionObjectInvocation *pExternal=NULL)
TD_USING(OdTrVisDirectRenderPartialUpdateInvocation::setup)
const OdTrVisExtensionObjectInvocation * externalInvocation() const
static OdSmartPtr< OdTrVisExtensionObjectInvocation > createObject(OdTrVisViewportId viewportId, OdTrVisOverlayId overlayId, OdTrRndLocalRenditionHost *pRenditionHost, const OdTrVisCamera &camera, const OdGeMatrix3d &modelXform)
const OdGeMatrix3d & modelXform() const
void setup(OdTrVisViewportId viewportId, OdTrVisOverlayId overlayId, OdTrRndLocalRenditionHost *pRenditionHost, const OdTrVisCamera &camera, const OdGeMatrix3d &modelXform)
TD_USING(OdTrVisDirectRenderPartialUpdateInvocation::setup)
void setup(OdTrRndLocalRenditionHost *pRenditionHost, const OdTrVisCamera &camera, const OdGeMatrix3d &modelXform)
const OdTrVisCamera & camera() const
OdTrRndLocalRenditionHost * m_pRenditionHost
OdTrRndLocalRenditionHost * renditionHost() const
static OdSmartPtr< OdTrVisExtensionObjectInvocation > createObject(OdTrVisViewportId viewportId=kTrVisNullId, OdTrVisOverlayId overlayId=kTrVisNullId)
virtual OdTrVisMetafileWritersPool & mfWritersPool()=0
virtual OdApcQueue & apcQueue()=0
virtual const OdTrVisExtensionModule * extensionModule() const
void setModuleVersion(OdUInt32 nVer)
virtual void deSerialize(OdStreamBuf *pDataStream)
void setObjectType(OdUInt32 nType)
virtual OdUInt32 moduleObjectType() const
static void copyStream(OdStreamBuf *pBufIn, OdStreamBuf *pBufOut)
OdStreamBuf * dataStreamForRead() const
virtual void serialize(OdStreamBuf *pDataStream) const
OdTrVisExtensionObjectProxy::ModuleProxy m_moduleProxy
void setModuleName(const OdString &name)
virtual bool isProxyObject() const
GLuint const GLchar * name
Definition: gles2_ext.h:265
GLuint GLsizei GLsizei * length
Definition: gles2_ext.h:274