zjf
2023-03-06 392b76515f40376b6d36f40a114850ef63650384
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
/////////////////////////////////////////////////////////////////////////////// 
// Copyright (C) 2002-2016, 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 Teigha(R) software pursuant to a license 
//   agreement with Open Design Alliance.
//   Teigha(R) Copyright (C) 2002-2016 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 __ODDRAWABLE_H__
#define __ODDRAWABLE_H__  /* { Secret} **/
 
#include "RxObject.h"
#include "RxOverrule.h"
 
class OdGiDrawableTraits;
class OdGiWorldDraw;
class OdGiViewportDraw;
class OdGsCache;
class OdDbStub;
class OdGeExtents3d;
 
#include "TD_PackPush.h"
 
/** \details
    This class is the base class for all graphical objects, both transient and persistent.
    
    \remarks
    This interface must be implemented by all graphical objects. Such objects
    are capable of vectorizing themselves within the Teigha framework.
 
    <group OdGi_Classes> 
*/
class FIRSTDLL_EXPORT OdGiDrawable : public OdRxObject
{
protected:
  OdGiDrawable();
public:
 
  ODRX_DECLARE_MEMBERS(OdGiDrawable);
 
  enum SetAttributesFlags
  {
    kDrawableNone                         = 0, // Default flags; the drawable object uses only OdGi primitives, 
                                               // with no nested calls to draw().
    kDrawableIsAnEntity                   = 1, // Classes derived from OdDbEntity must set this flag,
                                               // which is set by the default implementation of 
                                               // OdDbEntity::subSetAttributes().
    kDrawableUsesNesting                  = 2, // The drawable uses nested calls to draw(), but makes no
                                               // calls to other OdGi primatives. 
    kDrawableIsCompoundObject             = 4, // The drawable is to be treated as a block. Valid only when combined 
                                               // with kDrawableIsAnEntity. If set, you must override 
                                               // OdDbEntity::getCompoundObjectTransform().
    kDrawableViewIndependentViewportDraw  = 8,  // Currently not supported.
    kDrawableIsInvisible                  = 16, // Object is invisible, and should not be rendered.
    kDrawableHasAttributes                = 32, // Currently not supported.
    kDrawableRegenTypeDependantGeometry   = 64, // This flag must be set for objects which is drawn differently in different regen type modes.
    kDrawableIsDimension                  = (kDrawableIsAnEntity + kDrawableIsCompoundObject + 128), // Dimension objects must set these flags
                                                // which are set by the default implementation of OdDbDimension.
    kDrawableRegenDraw                    = 256, // The drawable must be always regenerated.
    kDrawableStandardDisplaySingleLOD     = 512,   // Currently not supported.
    kDrawableShadedDisplaySingleLOD       = 1024,  // Currently not supported.
    kDrawableViewDependentViewportDraw    = 2048,  // Currently not supported.
    kDrawableBlockDependentViewportDraw   = 4096,  // Currently not supported.
    kDrawableIsExternalReference          = 8192,  // Currently not supported.
    kDrawableNotPlottable                 = 16384, // Currently not supported.
 
    kLastFlag                             = kDrawableNotPlottable // Marker
  };
 
  enum DrawableType
  {
      kGeometry              = 0, 
      kDistantLight          = 1, // this number is important!
      kPointLight            = 2, // this number is important!
      kSpotLight             = 3, // this number is important!
      kAmbientLight,
      kSolidBackground,
      kGradientBackground,
      kImageBackground,
      kGroundPlaneBackground,
      kViewport,
      kWebLight,
      kSkyBackground,
      kImageBasedLightingBackground
  };
 
  virtual DrawableType drawableType() const { return kGeometry; }
 
  /** \details
    Sets the vectorization attributes of this object, and returns its attribute flags.  
 
    \param pTraits [in]  Pointer to OdGiDrawableTraits object from and to which the attributes are to be set.
 
    \remarks
    This function is called by the vectorization framework, prior to calling worldDraw() or
    viewportDraw(), to set the attributes for an object.
 
    \sa
    SetAttributesFlags 
  */
  ODRX_SEALED_VIRTUAL OdUInt32 setAttributes(OdGiDrawableTraits* pTraits) const ODRX_SEALED;
 
  /** \details
    Creates a viewport-independent geometric representation of this object.
    
    \remarks
    Returns true if and only if the geometric representation can be generated in a
    viewport-independent manner. 
 
    \note
    A return value of false indicates that viewportDraw() must be called for this object.
 
    The 3D GS will call this function at least once but may cache subsequent display updates.
 
    Use OdGsModel::onModified() to ensure that the 3D GS will call worldDraw() for next display update.
    
    The default implementation does nothing but return true. This function can be
    overridden in custom classes.
 
    \param pWd [in]  Pointer to the OdGiWorldDraw interface.
  */
  ODRX_SEALED_VIRTUAL bool worldDraw(OdGiWorldDraw* pWd) const ODRX_SEALED;
 
  /** \details
    Creates a viewport-dependent geometric representation of this object.
 
    \remarks
    Causes OdGiDrawable to describe its geometry to the specified OdGiViewportDraw object. 
 
    This function is called once per viewport.
 
    \remarks
    By overriding this function, it is possible to have totally different images in each viewport; a schematic
    in one viewport, a layout in another.
    
    The default implementation of this function does nothing. This function can be
    overridden in custom classes.
 
    \param pVd [in]  Pointer to the OdGiViewportDraw interface.
  */
  ODRX_SEALED_VIRTUAL void viewportDraw(OdGiViewportDraw* pVd) const ODRX_SEALED;
 
  /** \details
    Returns true if and only if this object is persistent (stored in a database).
  */
  virtual bool isPersistent() const = 0;
 
  /** \details
    Returns the database ID of this object.
 
    \remarks
    Returns a null pointer if this object is not persistent.
  */
  virtual OdDbStub* id() const = 0;
 
  /** \details
    Assigns the specified OdGsCache to this object.
    
    \param pGsNode [in]  Pointer to the OdGsCache to be assigned.
  */
  virtual void setGsNode(OdGsCache* pGsNode) = 0;
 
  /** \details
    Returns the OdGsCache associated with this object.
  */
  virtual OdGsCache* gsNode() const = 0;
 
  /** \details
    Returns the setAttributes flags for the current viewportDraw. 
    
    \param pVd [in]  Pointer to OdGiViewportDraw interface.
    
    \note
    The default implementation of this function always returns 0.
  */
  ODRX_SEALED_VIRTUAL OdUInt32 viewportDrawLogicalFlags(OdGiViewportDraw* pVd) const ODRX_SEALED;
 
 /** \details
    Returns a WCS bounding box that represents the extents of this entity.
 
    \param extents [out]  Receives the WCS extents.
 
    \remarks
    Returns eOk if successful or an appropriate error code if not.
 
    The default implementation of this function always returns eInvalidExtents. 
 */
  virtual OdResult getGeomExtents(OdGeExtents3d& extents) const;
 
 /** \details
    Returns a set of flags that represents the multi-threaded rendering support of this entity.
 
    \remarks
    Returns 0 if the drawable can be rendered only in a single threaded mode.
 
    The default implementation of this function returns flags defined with the OdRxClass::customFlags() method.
 */
  ODRX_SEALED_VIRTUAL OdUInt32 regenSupportFlags() const ODRX_SEALED;
 
protected:
  virtual OdUInt32 subSetAttributes (OdGiDrawableTraits * traits) const = 0;
  virtual bool subWorldDraw (OdGiWorldDraw * wd) const = 0;
  virtual void subViewportDraw (OdGiViewportDraw * vd) const = 0;
  virtual OdUInt32 subViewportDrawLogicalFlags (OdGiViewportDraw * vd) const;
  virtual OdUInt32 subRegenSupportFlags() const;
  friend class OdGiDrawableOverrule;
};
 
typedef OdSmartPtr<OdGiDrawable> OdGiDrawablePtr;
 
/** \details
  This class overrules a subset of drawable linked operations which a drawable object specifies. 
  It is used as a base class for classes derived from OdGiDrawable to change their behavior. 
  Each default implementation calls the corresponding method of the target class.
 
  Library: TD_Gi
  <group OdGi_Classes> 
*/
class FIRSTDLL_EXPORT OdGiDrawableOverrule : public OdRxOverrule
{
public:
  ODRX_DECLARE_MEMBERS(OdGiDrawableOverrule);
 
  /** \details
    Constructor creates an instance of this class.
  */
  OdGiDrawableOverrule();
 
  /** \details
    Overrules the OdGiDrawable::setAttributes() method and calls it in the default implementation.
 
    \param pSubject [in]  A raw pointer to the drawable object.
    \param traits [in]  A pointer to the graphics traits.
  */
  virtual OdUInt32 setAttributes (const OdGiDrawable* pSubject, OdGiDrawableTraits * traits);
 
  /** \details
    Overrules the OdGiDrawable::worldDraw() method and calls it in the default implementation.
 
    \param pSubject [in]  A raw pointer to the drawable object.
    \param wd [in]  A pointer to the Gi world drawable object.
  */
  virtual bool worldDraw (const OdGiDrawable* pSubject, OdGiWorldDraw * wd);
 
  /** \details
    Overrules the OdGiDrawable::viewportDraw() method and calls it in the default implementation.
 
    \param pSubject [in]  A raw pointer to the drawable object.
    \param vd [in]  A pointer to the Gi viewport drawable object.
  */
  virtual void viewportDraw (const OdGiDrawable* pSubject, OdGiViewportDraw * vd);
 
  /** \details
    Overrules the OdGiDrawable::viewportDrawLogicalFlags() method and calls it in the default implementation.
 
    \param pSubject [in]  A raw pointer to the drawable object.
    \param vd [in]  A pointer to the Gi viewport drawable object.
  */
  virtual OdUInt32 viewportDrawLogicalFlags (const OdGiDrawable* pSubject, OdGiViewportDraw * vd);
 
  /** \details
    Overrules the regen support flags.
 
    \param pSubject [in]  A raw pointer to the drawable object.
  */
  virtual OdUInt32 regenSupportFlags(const OdGiDrawable* pSubject);
};
 
#include "TD_PackPop.h"
 
#endif // __ODDRAWABLE_H__