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
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
/////////////////////////////////////////////////////////////////////////////// 
// 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 ODGSBASEVECTORIZEDEVICE_INC
#define ODGSBASEVECTORIZEDEVICE_INC
 
#include "TD_PackPush.h"
#include "Gs/GsBaseModule.h"
#include "Gs/GsDCRectArray.h"
#include "Gs/GsVectPerformance.h"
#include "Gs/GsModel.h"
#include "SlotManager.h"
#include "ThreadsCounter.h"
 
/** \details
    This template class is a specialization of the OdArray class for ODCOLORREF objects.
*/
typedef OdArray<ODCOLORREF, OdMemoryAllocator<ODCOLORREF> > ODGSPALETTE;
 
class OdGiPathNode;
class OdGiTransientManager;
class OdGiSectionGeometryManager;
 
class OdGsBaseVectorizeView;
class OdGsViewImpl;
 
/** \details
  This template class is a specialization of the OdSmartPtr class for OdGiTransientManager object pointers. 
*/
typedef OdSmartPtr<OdGiTransientManager> OdGiTransientManagerPtr;
 
/** \details
    This class implements bitmapped GUI display windows.
 
    \remarks
    OdGsBaseVectorizeDevice objects own, update, and refresh one or more OdGsView objects.
    
    In addition, they responds to operating system notifications,
    such as window resize, forwarded by the graphics system client.
 
    Library: Gs
 
    <group OdGs_Classes> 
*/
class GS_TOOLKIT_EXPORT OdGsBaseVectorizeDevice : public OdGsDevice
{
  friend class OdGsViewImpl;
  friend class OdGsBaseVectorizeView;
 
  friend class OdGsBaseModule;
  OdGsBaseModulePtr       m_pModule;
  OdSlotManager           m_slotManager;
protected:
  OdArray<OdGsViewPtr>    m_views;
  ODGSPALETTE             m_logPalette;
  ODCOLORREF              m_Background;
  OdGsDCRect              m_outputRect;
  OdSmartPtr<OdGiContext> m_pUserContext;
  OdRxObjectPtr           m_sectionGeometryMap;
  OdRxObjectPtr           m_sectionManager;
  OdGiTransientManagerPtr m_transientManager;
 
  OdUInt32                m_flags;
  enum
  {
    kFirstFlag             = 1,
 
    kInvalid               = kFirstFlag << 0,
    kSortRenderTypes       = kFirstFlag << 1,
    kSpatialIndexDisabled  = kFirstFlag << 2,
    kDynamicHighlight      = kFirstFlag << 3,
    kDynamicSubhighlight   = kFirstFlag << 4,
    kSupportBlocks         = kFirstFlag << 5,
    kSupportOverlays       = kFirstFlag << 6,
    kSupportComposition    = kFirstFlag << 7,
    kEnableComposition     = kFirstFlag << 8,
    kMtDisplay             = kFirstFlag << 9,
    kUseSectionGeometryMap = kFirstFlag << 10,
    kUseVpLtypeScaleMult   = kFirstFlag << 11,
    kUseVpFilterFunction   = kFirstFlag << 12,
    kCullingVolumeEnabled  = kFirstFlag << 13,
    kDisplayOffLayers      = kFirstFlag << 14,
 
    kLastFlag              = kDisplayOffLayers
  };
  OdGsDCRectArray         m_invalidRects;
  OdUInt32                m_invalidOverlays;
 
  /*
  virtual int invalidatedRectNum(int& max) const;
  virtual void invalidatedRectAt(int i, OdGsDCRect& rect) const;
  virtual void setInvalidatedRectAt(int i, const OdGsDCRect& rect);
  virtual void eraseInvalidatedRectAt(int i);
  virtual void clearInvalidatedRects();
  */
public:
  bool invalid() const { return GETBIT(m_flags, kInvalid); }
  void setValid(bool bFlag);
 
  /** \details
    Must be overridden to return true in child class to inform base implementation that
    child class supports partial update.
  */
public:
  virtual bool supportPartialUpdate() const;
 
  void onViewAdded(OdGsView* pView);
public:
  ODRX_DECLARE_MEMBERS(OdGsBaseVectorizeDevice);
 
  ~OdGsBaseVectorizeDevice();
 
  OdGiContext* userGiContext() const;
  void setUserGiContext(OdGiContext* pUserGiContext);
 
  OdRxDictionaryPtr properties();
  OdGsBaseVectorizeDevice();
 
  /** \details
    Returns the height of this Device object in pixels.
  */
  int height() const;
 
  /** \details
    Returns the width of this Device object in pixels.
  */
  int width() const;
 
  void invalidate();
 
  void invalidate(const OdGsDCRect &screenRect);
 
  void invalidateRegion(const OdGiPathNode& path);
 
  const OdGsDCRectArray& invalidRects() const;
 
  bool isValid() const;
 
  virtual void update(OdGsDCRect* pUpdatedRect);
  virtual void updateGeometry();
  virtual void updateScreen();
 
  void onSize(const OdGsDCRect& outputRect);
 
  const OdGsDCRect& outputRect() const;
  void getSize(OdGsDCRect& outputRect) const;
 
  void onRealizeForegroundPalette();
 
  void onRealizeBackgroundPalette();
 
  void onDisplayChange(
    int bitsPerPixel, 
    int xPixels, 
    int yPixels);
 
  OdGsViewPtr createView(
    const OdGsClientViewInfo* pViewInfo = 0, 
    bool enableLayerVisibilityPerView = false);
 
  void addView(OdGsView* pView);
 
  void insertView(int viewIndex, OdGsView* pView);
 
  bool eraseView(OdGsView* pView);
 
  int numViews() const;
 
  OdGsView* viewAt(int viewIndex);
  const OdGsView* viewAt(int viewIndex) const;
  OdGsViewImpl* viewImplAt(int viewIndex);
  const OdGsViewImpl* viewImplAt(int viewIndex) const;
 
  bool eraseView(int viewIndex);
 
  void eraseAllViews();
 
  bool setBackgroundColor(ODCOLORREF backgroundColor);
 
  ODCOLORREF getBackgroundColor();
 
  void setLogicalPalette(const ODCOLORREF* logicalPalette, int numColors);
 
  /** \details
    Currently not implemented.
  */
  void getSnapShot(OdGiRasterImagePtr &pImage, const OdGsDCRect &region);
 
  /** \details
    Returns the specified color in the logical palette of this Device object.
    \param colorIndex [in]  Color index.
  */
  ODCOLORREF getColor(OdUInt16 colorIndex) const;
 
  /** \details
    Returns background color in the logical palette of this Device object.
  */
  ODCOLORREF getPaletteBackground() const;
 
  /** \details
    Returns the logical palette of this Device object.
  */
  const ODCOLORREF* getPalette() const;
 
  /** \details
    Returns the logical palette of this Device object.
    \param numColors [out]  Returns number of colors inside logical palette.
  */
  const ODCOLORREF* getLogicalPalette(int &numColors) const;
 
  OdGsModelPtr createModel();
  bool isModelCompatible(OdGsModel* pModel) const;
 
  const OdGsView* rootView() const;
 
  // renderTypes support
  bool sortRenderTypes() const;
  void setSortRenderTypes(bool flag);
  virtual OdUInt32 renderTypeWeight(OdGsModel::RenderType renderType) const;
  virtual OdGsModel::RenderType transientRenderType() const;
  // overlays support
  bool supportOverlays() const;
  void setSupportOverlays(bool bFlag);
  virtual OdUInt32 renderTypeOverlay(OdGsModel::RenderType renderType) const;
  bool isOverlayInvalid(OdUInt32 nOverlay) const;
  void setOverlayInvalid(OdUInt32 nOverlay, bool bFlag);
  void resetOverlayFlags(bool bFlag = false);
 
  bool isSpatialIndexDisabled() const;
  void disableSpatialIndex(bool bSet);
 
  bool isCullingVolumeEnabled() const;
  void enableCullingVolume(bool bSet);
 
  bool supportDynamicHighlight() const;
  bool supportDynamicSubhighlight() const;
 
  bool supportBlocks() const;
 
  bool supportComposition() const;
 
  bool compositionEnabled() const;
  void enableComposition(bool bSet);
 
  bool isDisplayOffLayersEnabled() const;
  void enableDisplayOffLayers(bool bSet);
 
  bool isValidViewportId(const OdUInt32 acgiId) const
  {
    return m_slotManager.contains(acgiId);
  }
 
  bool useVpLtypeScaleMult() const { return GETBIT(m_flags, kUseVpLtypeScaleMult); }
  bool useVpFilterFunction() const { return GETBIT(m_flags, kUseVpFilterFunction); }
 
  OdGiSectionGeometryManager *getSectionGeometryManager();
  OdRxObjectPtr getSectionGeometryMap();
  void clearSectionGeometryMap();
  OdRxObject* mtServices() { return m_mtServices; }
 
  OdGiTransientManager *transientManager();
  void setTransientManager(OdGiTransientManager *pManager);
 
  virtual bool isSupportDeviceStateSaving() const;
  bool saveDeviceState(OdGsFiler *pFiler) const;
  bool loadDeviceState(OdGsFiler *pFiler);
  virtual bool saveClientDeviceState(OdGsFiler *pFiler) const;
  virtual bool loadClientDeviceState(OdGsFiler *pFiler);
  virtual bool saveLinkedDeviceState(OdGsFiler *pFiler) const;
  virtual bool loadLinkedDeviceState(OdGsFiler *pFiler);
protected:
  friend class DisplayScheduler;
  virtual bool supportParallelDisplay() const { return false; }
  void initMtServices();
  void viewUpdateScreen(OdGsBaseVectorizeView* pView, bool bUpdate);
 
public:
  GsVectPerformanceData m_vectPerfData;
private:
  OdRxObjectPtr m_mtServices;
  OdRefCounter m_vectThreadIndex;
  OdMutexPtr m_mtInvalidate;
  OdMutexPtr m_mtSectionGeometryMap;
};
 
inline bool OdGsBaseVectorizeDevice::sortRenderTypes() const
{
  return GETBIT(m_flags, kSortRenderTypes);
}
 
inline void OdGsBaseVectorizeDevice::setSortRenderTypes(bool bFlag)
{
  SETBIT(m_flags, kSortRenderTypes, bFlag);
}
 
inline bool OdGsBaseVectorizeDevice::supportOverlays() const
{
  return GETBIT(m_flags, kSupportOverlays);
}
 
inline void OdGsBaseVectorizeDevice::setSupportOverlays(bool bFlag)
{
  SETBIT(m_flags, kSupportOverlays, bFlag);
}
 
inline bool OdGsBaseVectorizeDevice::isOverlayInvalid(OdUInt32 nOverlay) const
{
  return GETBIT(m_invalidOverlays, (1 << nOverlay));
}
 
inline void OdGsBaseVectorizeDevice::setOverlayInvalid(OdUInt32 nOverlay, bool bFlag)
{
  SETBIT(m_invalidOverlays, (1 << nOverlay), bFlag);
}
 
inline void OdGsBaseVectorizeDevice::resetOverlayFlags(bool bFlag)
{
  m_invalidOverlays = (bFlag) ? 0xFFFFFFFF : 0;
}
 
inline bool OdGsBaseVectorizeDevice::isSpatialIndexDisabled() const
{
  return GETBIT(m_flags, kSpatialIndexDisabled);
}
 
inline void OdGsBaseVectorizeDevice::disableSpatialIndex(bool bSet)
{
  SETBIT(m_flags, kSpatialIndexDisabled, bSet);
}
 
inline bool OdGsBaseVectorizeDevice::isCullingVolumeEnabled() const
{
  return GETBIT(m_flags, kCullingVolumeEnabled);
}
 
inline void OdGsBaseVectorizeDevice::enableCullingVolume(bool bSet)
{
  SETBIT(m_flags, kCullingVolumeEnabled, bSet);
}
 
inline bool OdGsBaseVectorizeDevice::supportDynamicHighlight() const
{
  return GETBIT(m_flags, kDynamicHighlight);
}
 
inline bool OdGsBaseVectorizeDevice::supportDynamicSubhighlight() const
{
  return GETBIT(m_flags, kDynamicSubhighlight);
}
 
inline bool OdGsBaseVectorizeDevice::supportBlocks() const
{
  return GETBIT(m_flags, kSupportBlocks);
}
 
inline bool OdGsBaseVectorizeDevice::supportComposition() const
{
  return GETBIT(m_flags, kSupportComposition);
}
 
inline bool OdGsBaseVectorizeDevice::compositionEnabled() const
{
  return GETBIT(m_flags, kEnableComposition);
}
 
inline void OdGsBaseVectorizeDevice::enableComposition(bool bSet)
{
  SETBIT(m_flags, kEnableComposition, bSet);
}
 
inline bool OdGsBaseVectorizeDevice::isDisplayOffLayersEnabled() const
{
  return GETBIT(m_flags, kDisplayOffLayers);
}
 
inline void OdGsBaseVectorizeDevice::enableDisplayOffLayers(bool bSet)
{
  SETBIT(m_flags, kDisplayOffLayers, bSet);
}
 
inline const
OdGsDCRect& OdGsBaseVectorizeDevice::outputRect() const
{
  return m_outputRect;
}
 
inline
void OdGsBaseVectorizeDevice::getSize(OdGsDCRect& outputRect) const
{
  outputRect = this->outputRect();
}
 
inline
ODCOLORREF OdGsBaseVectorizeDevice::getColor(OdUInt16 colorIndex) const
{
  return m_logPalette[colorIndex];
}
 
inline
const ODCOLORREF* OdGsBaseVectorizeDevice::getPalette() const
{
  return m_logPalette.getPtr();
}
 
inline
const ODCOLORREF* OdGsBaseVectorizeDevice::getLogicalPalette(int &numColors) const
{
  numColors = (int)m_logPalette.size();
  return m_logPalette.getPtr();
}
 
inline const OdGsDCRectArray&
OdGsBaseVectorizeDevice::invalidRects() const
{
  return m_invalidRects;
}
 
#include "TD_PackPop.h"
 
#endif // ODGSBASEVECTORIZEDEVICE_INC