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
/////////////////////////////////////////////////////////////////////////////// 
// 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 _ODGI_CONTEXTFORDBDATABASE_INCLUDED_
#define _ODGI_CONTEXTFORDBDATABASE_INCLUDED_
 
#include "GiDefaultContext.h"
#include "DbExport.h"
#include "OdPlatform.h"
#include "StaticRxObject.h"
#include "DbDatabase.h"
#include "DbDatabaseReactor.h"
#include "Ps/PlotStyles.h"
#include "Gi/GiSubEntityTraitsData.h"
#include "Gi/GiLinetyper.h"
 
#include "TD_PackPush.h"
 
struct OdGsClientViewInfo;
class OdGsView;
class OdGiContextualColorsImpl;
 
/** \details
    This class defines the operations and properties that are used in the
    Teigha vectorization of an OdDbDatabase.
 
    Library: TD_Db
 
    <group OdDb_Classes> 
*/
class TOOLKIT_EXPORT OdGiContextForDbDatabase : public OdGiDefaultContext
{
private:
  enum
  {
    kPlotGeneration                  = 1,
    kUseGsModel                      = 2,
    kOdGiZeroTextNormals             = 4,
    kDisableLayoutHelperLinkReactors = 8,
    kTTFPolyDraw                     = 16,
    kTrackDbDestroy                  = 32,
    kManageContextualColors          = 64,
    kKeepPSLayoutHelperView          = 128,
    kErasePSLayoutHelperView         = 256,
    kConstantModelSpaceLineweights   = 512,
    kLastFlag                        = kConstantModelSpaceLineweights
  };
 
  OdUInt32              m_fflags;
 
  class TOOLKIT_EXPORT DatabaseHolder : public OdStaticRxObject<OdDbDatabaseReactor>
  {
  public:
    DatabaseHolder();
    ~DatabaseHolder();
 
    OdDbDatabase* m_pDb;
 
    void setDatabase( bool bWasTrackDbDestroy, OdDbDatabase* pDb, bool bTrackDbDestroy );
 
    void goodbye(const OdDbDatabase* pDb);
  }
  m_DbHolder;
 
protected:
  ODCOLORREF            m_paletteBackground;
  OdPsPlotStyleTablePtr m_pPlotStyleTable;
 
  OdGiContextForDbDatabase();
 
public:
 
  ODRX_DECLARE_MEMBERS(OdGiContextForDbDatabase);
 
  ~OdGiContextForDbDatabase();
 
  // OdGiContext overridden functions
 
  virtual OdDbBaseDatabase* database() const;
  virtual OdGiDrawablePtr openDrawable(OdDbStub* drawableId);
  virtual OdUInt32 numberOfIsolines() const;
  virtual double commonLinetypeScale() const;
  virtual OdDb::LineWeight defaultLineWeight() const;
  virtual bool quickTextMode() const;
  virtual OdUInt32 textQuality() const;
  virtual ImageQuality imageQuality() const;
  virtual OdUInt32 fadingIntensityPercentage(FadingType fadingType) const;
  virtual bool ttfPolyDraw() const;
 
  /** \details
    Sets the database to be vectorized.
 
    \param pDb [in]  Pointer to the database.
    \param bTrackDbDestroy [in]  if to the database is not NULL then
    this parameter specifies if implementation should track database lifetime
    (by adding reactor to the database and processing OdDbDatabaseReactor::goodbye() event)
    and to clear pointer to the database if it will be destroyed. If you sure that lifetime of this object
    is shorter then lifetime of the database you may set this parameter to false
    to turn off unnecessary database lifetime tracking.
  */
  void setDatabase( OdDbDatabase* pDb, bool bTrackDbDestroy = true );
 
  /** \details
    Returns the database that is currently being vectorized.
  */
  OdDbDatabase* getDatabase() const;
 
  /** \details
    Returns the OdGsClientViewInfo for the specified viewport.
    \param vpId [in]  Object ID of the viewport.
    \param viewInfo [out]  Receives the client view info.
  */
  virtual void fillGsClientViewInfo(const OdDbObjectId& vpId, OdGsClientViewInfo& viewInfo);
 
  /** \details
  Returns the OdDbStub for the specified handle id.
  \param objectId [in]  Object ID of the object.
  Returns the pointer to OdDbStub.
  */
  virtual OdDbStub* getStubByID( OdUInt64 objectId ) const;
 
  virtual OdDbStub* getStubByMatName(const OdString& strMatName) const;
 
  virtual void getDefaultTextStyle(OdGiTextStyle& textStyle);
 
  unsigned int circleZoomPercent(OdDbStub* viewportId) const;
 
  virtual OdIntPtr drawableFilterFunctionId(OdDbStub* viewportId) const;
  virtual OdUInt32 drawableFilterFunction(OdIntPtr functionId, const OdGiDrawable *pDrawable, OdUInt32 nFlags);
 
  /** \details
    Returns true if and only the GsModel flag of this Context Object is set..
  */
  bool useGsModel() const;
 
  /** \details
    Controls the GsModel flag of this Context Object.
    \param enable [in]  Controls the Gs Model.
  */
  void enableGsModel(bool enable);
 
  /** \details
    Returns true if and only the PlotGeneration flag of this Context Object is set.
  */
  bool isPlotGeneration() const;
 
  /** \details
    Controls the PlotGeneration flag of this Context Object.
    \param plotGeneration [in]  Controls plot generation.
  */
  void setPlotGeneration(bool plotGeneration);
 
  /** \details
    Returns true if and only the kOdGiZeroTextNormals flag of this Context Object is set.
  */
  virtual bool isZeroTextNormals() const;
 
  /** \details
    Controls the ZeroTextNormals flag of this Context Object.
    \param bZeroTextNormals [in]  Controls text normals generation.
  */
  void setZeroTextNormals(bool bZeroTextNormals);
 
  /** \details
    Returns true if and only the kDisableLayoutHelperLinkReactors flag of this Context Object is set.
  */
  bool isLayoutHelperLinkReactorsDisabled() const;
 
  /** \details
    Controls the kDisableLayoutHelperLinkReactors flag of this Context Object.
    \param bDisableLinkReactors [in]  Controls layout link reactors flag.
  */
  void disableLayoutHelperLinkReactors(bool bDisableLinkReactors);
 
  /** \details
    Returns true if and only the kManageContextualColors flag of this Context Object is set.
  */
  bool isContextualColorsManagementEnabled() const;
 
  /** \details
    Controls the kManageContextualColors flag of this Context Object.
    \param bEnable [in]  Controls contextual colors management flag.
  */
  void enableContextualColorsManagement(bool bEnable);
 
  /** \details
    Update view contextual colors after view changes.
    \param pView [in]  View pointer for update contextual colors.
  */
  virtual void updateContextualColors(OdGsView *pView);
 
  /** \details
    Initialize contextual colors container by contextual colors values.
    \param pCtxColors [in]  Pointer to contextual colors container.
  */
  virtual void fillContextualColors(OdGiContextualColorsImpl *pCtxColors);
 
  /** \details
    Enables TrueType text contours info output.
    \param bPolyDraw [in]  Controls kTTFPolyDraw flag of this Context Object.
  */
  void setTtfPolyDrawMode(bool bPolyDraw);
 
  /** \details
    Returns true if and only if the kKeepPSLayoutHelperView flag of this Context Object is set.
  */
  bool isKeepPSLayoutHelperViewEnabled() const;
 
  /** \details
    Controls the kKeepPSLayoutHelperView flag of this Context Object.
    \param bEnable [in]  Controls PaperSpace layout helper view management flag.
  */
  void enableKeepPSLayoutHelperView(bool bEnable);
 
  /** \details
    Returns true if and only if the kErasePSLayoutHelperView flag of this Context Object is set.
  */
  bool erasePSLayoutHelperView() const;
 
  /** \details
    Controls the kErasePSLayoutHelperView flag of this Context Object.
    \param bEnable [in]  Controls PaperSpace layout helper view management flag.
  */
  void setErasePSLayoutHelperView(bool bOn);
 
  /** \details
    Returns currents behavior of ModelSpace lineweights.
  */
  bool isConstantModelSpaceLineweightsEnabled() const;
 
  /** \details
    Controls behavior of ModelSpace lineweights.
    \param bEnable [in]  Enable contant ModelSpace lineweights.
  */
  void enableConstantModelSpaceLineweights(bool bEnable);
 
  /** \details
    Returns true if and only if filling of TrueType fonts is enabled.
  */
  bool fillTtf() const;
 
  /** \details
    Returns true if and only if shell/mesh geometry primitives should be filled during this vectorization.
  */
  bool fillMode() const;
 
  /** \details
    Returns the palette background color for this Context object.
  */
  ODCOLORREF paletteBackground() const { return m_paletteBackground; }
  /** \details
    Sets the palette background color for this Context object.
    \param paletteBackground [in]  Palette background.
  */
  void setPaletteBackground(ODCOLORREF paletteBackground) { m_paletteBackground = paletteBackground; }
 
  /** \details
    Loads the specified plot style table for this Context object.
    \param pStreamBuf [in]  Pointer to the StreamBuf object from which the data are to be read.
  */
  void loadPlotStyleTable(OdStreamBuf* pStreamBuf);
  
  /** \details
    Returns the plot style type for this Context object.
  */
  virtual PStyleType plotStyleType() const;
 
  /** \details
    Returns the plot style data for the specified pen number or object Id.
    \param penNumber [in]  Pen number.
    \param psNameId [in]  Object id of the plot style name.
    \param plotStyleData [out]  Receives the plot style data.
  */
  virtual void plotStyle(int penNumber, OdPsPlotStyleData& plotStyleData) const;
 
  virtual void plotStyle(OdDbStub* psNameId, OdPsPlotStyleData& plotStyleData) const;
 
  /** \details
    Returns an interface for access section geometry functionality.
  */
  virtual OdGiSectionGeometryManagerPtr getSectionGeometryManager();
 
  /** \details
    Controls rendering anti-aliasing.
  */
  virtual OdUInt32 antiAliasingMode() const;
 
  /** \details
    Controls Xref properties overriding.
  */
  virtual bool xrefPropertiesOverride() const;
 
  /** \details
  Returns SolidHatchAsPolygonMode set for this Context Object.
  */
  SolidHatchAsPolygonMode hatchAsPolygon() const;
 
  /** \details
  Controls SolidHatchAsPolygonMode of this Context Object.
  \param bOn [in]  Controls hatch as polygon generation.
  */
  void setHatchAsPolygon(SolidHatchAsPolygonMode mode);
};
 
/** \details
    This template class is a specialization of the OdSmartPtr class for OdGiContextForDbDatabase object pointers.
*/
typedef OdSmartPtr<OdGiContextForDbDatabase> OdGiContextForDbDatabasePtr;
 
 
#include "TD_PackPop.h"
 
#endif //_ODGI_CONTEXTFORDBDATABASE_INCLUDED_