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
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
/////////////////////////////////////////////////////////////////////////////// 
// 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 __ODGICOMMONDRAW_H__
#define __ODGICOMMONDRAW_H__
 
#include "TD_PackPush.h"
 
#include "RxObject.h"
#include "Gi/Gi.h"
 
class OdGiGeometry;
class OdGiContext;
class OdGiSubEntityTraits;
class OdDbStub;
typedef OdRxObject OdDbBaseDatabase;
class OdGePoint3d;
class OdGiDrawable;
class OdGiPathNode;
 
/** \details
  This template class is a specialization of the OdSmartPtr class for OdGiDrawable object pointers.
*/
typedef OdSmartPtr<OdGiDrawable> OdGiDrawablePtr;
 
/** \details
    Viewport regeneration modes. 
*/
typedef enum
{
  eOdGiRegenTypeInvalid         = 0,
  kOdGiStandardDisplay          = 2,
  kOdGiHideOrShadeCommand       = 3,
  kOdGiRenderCommand            = 4,
  kOdGiForExplode               = 5,
  kOdGiSaveWorldDrawForProxy    = 6,
  kOdGiForExtents               = 7
} OdGiRegenType;
 
/** \details
    Deviation types used for tessellation.
*/
typedef enum
{
  kOdGiMaxDevForCircle      = 0,
  kOdGiMaxDevForCurve       = 1,
  kOdGiMaxDevForBoundary    = 2,
  kOdGiMaxDevForIsoline     = 3,
  kOdGiMaxDevForFacet       = 4
} OdGiDeviationType;
 
class OdGiCommonDraw;
class OdGiTextStyle;
class OdPsPlotStyleData;
class OdGiConveyorGeometry;
 
enum // Text vectorization flags
{
  kOdGiIncludeScores    = 2,
  kOdGiRawText          = 4,
  kOdGiIncludePenups    = 8,
  kOdGiDrawShape        = 16,
  kOdGiIgnoreMIF        = 32
};
 
class OdGiSectionGeometryManager;
typedef OdSmartPtr<OdGiSectionGeometryManager> OdGiSectionGeometryManagerPtr;
 
/** \details
    This class defines common operations and properties that are used in the
    Teigha vectorization process.
    
    \remarks
    An instance of an OdGiContext subclass is normally created as a preliminary step in the vectorization process, to be
    used throughout the vectorization.
 
    Most of the virtual functions in this class (the ones that are not pure virtual) are no-ops, serving only to define an interface.
 
    Library: TD_Gi
    
    <group OdGi_Classes> 
*/
class FIRSTDLL_EXPORT OdGiContext : public OdRxObject
{
public:
  ODRX_DECLARE_MEMBERS(OdGiContext);
 
  /** \details
    Returns the database that is currently being vectorized.
  */
  virtual OdDbBaseDatabase* database() const = 0;
 
  /** \details
    Opens for read the specified drawable object belonging to the database associated with this Context object.
    
    \param drawableId [in]  Object ID of the drawable to be opened.
    
    \remarks
    Returns a SmartPointer to the drawable object.
  */
  virtual OdGiDrawablePtr openDrawable(
    OdDbStub* drawableId) = 0;
 
  /** \details
      Returns the default lineweight associated with this Context object.
  */
  virtual OdDb::LineWeight defaultLineWeight() const;
 
  /** \details
    Returns the common LinetypeScale for this Context object.
  */
  virtual double commonLinetypeScale() const;
 
  /** \details
    Returns the default TextStyle associated with this Context object.
    
    \param textStyle [out]  Receives the TextStyle object.
  */
  virtual void getDefaultTextStyle(
    OdGiTextStyle& textStyle);
 
  /** \details
    Vectorizes the specified shape into the specified interface object.
 
    \param pDraw [in]  Pointer to the CommonDraw object.
    \param position [in]  Position of the shape.
    \param shapeNumber [in]  Shape number.
    \param pTextStyle [in]  Pointer to the TextStyle for the shape.
  */
  virtual void drawShape(
    OdGiCommonDraw* pDraw, 
    OdGePoint3d& position, 
    int shapeNumber, 
    const OdGiTextStyle* pTextStyle);
 
  /** \param pDest [in]  Pointer to the Conveyor object.
      \param direction [in]  Baseline direction for the text.
      \param upVector [in]  Up vector for the text.
      \param pExtrusion [in]  Pointer to the Extrusion vector for the text.
  */
  virtual void drawShape(
    OdGiConveyorGeometry* pDest,
    const OdGePoint3d& position,
    const OdGeVector3d& direction, 
    const OdGeVector3d& upVector,
    int shapeNumber, 
    const OdGiTextStyle* pTextStyle,
    const OdGeVector3d* pExtrusion);
 
  /** \details
    Vectorizes the specified text string into the supplied CommonDraw object.
 
    \param pDraw [in]  Pointer to the CommonDraw object.
    \param position [in]  Position of the text.
    \param msg [in]  Text string.
    \param numBytes [in]  Number of bytes in msg (not including the optional null byte).
    \param pTextStyle [in]  Pointer to the TextStyle for msg.
    \param flags [in]  Vectorization flags.
    
    \remarks
    msg must be null terminated if numBytes is not supplied.
  */
  virtual void drawText(
    OdGiCommonDraw* pDraw, 
    OdGePoint3d& position,
    const OdChar* msg, 
    OdInt32 numBytes,
    const OdGiTextStyle* pTextStyle, 
    OdUInt32 flags = 0);
 
  /** \param height [in]  Height of the text.
    \param width [in]  Width of the text.
    \param oblique [in]  Oblique angle of the text.
      
    \note
    All angles are expressed in radians.
    
    As currently implemented, this function ignores width and oblique.
    They will be fully implemented in a future release.
  */
  virtual void drawText(
    OdGiCommonDraw* pDraw, 
    OdGePoint3d& position,
    double height, 
    double width, 
    double oblique, 
    const OdString& msg);
 
  /** \param pDest [in]  Pointer to the Conveyor object.
      \param direction [in]  Baseline direction for the text.
      \param upVector [in]  Up vector for the text.
      \param pExtrusion [in]  Pointer to the extrusion vector for the text.
      \param raw [in]  If and only if true, escape sequences, such as %%P, will not be converted to special characters.
  */
  virtual void drawText(
    OdGiConveyorGeometry* pDest,
    const OdGePoint3d& position,
    const OdGeVector3d& direction, 
    const OdGeVector3d& upVector,
    const OdChar* msg, 
    OdInt32 numBytes, 
    bool raw,
    const OdGiTextStyle* pTextStyle,
    const OdGeVector3d* pExtrusion);
 
  /** \details
    Returns the extents box for the specified text.
       
    \param msg [in]  Text string.
    \param numBytes [in]  Number of bytes in msg (not including the optional null byte).
    \param textStyle [in]  TextStyle for msg.
    \param flags [in]  Vectorization flags.
    \param min [out]  Receives the lower-left corner of the extents box.
    \param max [out]  Receives the upper-right corner of the extents box.
    \param pEndPos [out]  If non-NULL, receives the end position of the text string.
 
  */
  virtual void textExtentsBox(
    const OdGiTextStyle& textStyle, 
    const OdChar* msg, 
    int nLength,
    OdUInt32 flags, 
    OdGePoint3d& min, 
    OdGePoint3d& max, 
    OdGePoint3d* pEndPos = 0);
 
  /** \details
    Returns the extents box for the specified shape.
    
    \param textStyle [in]  TextStyle for the shape.
    \param shapeNumber [in]  Shape number.
    \param min [out]  Receives the lower-left corner of the extents box.
    \param max [out]  Receives the upper-right corner of the extents box.
  */
  virtual void shapeExtentsBox(
    const OdGiTextStyle& textStyle, 
    int shapeNumber, 
    OdGePoint3d& min, 
    OdGePoint3d& max);
 
  /** \details
    Returns the circle zoom percent for this vectorization process.
    
    \param viewportId [in]  Pointer to the Object ID of the Viewport object to be queried.
    
    \remarks
    Returns a value in the range [1,20000]. 100 is the default.
  */
  virtual unsigned int circleZoomPercent(
    OdDbStub* viewportId) const;
 
  /** \details
    Returns true if and only if this vectorization is intended for hard copy output.
  */
  virtual bool isPlotGeneration() const;
 
  /** \details
    Returns palette background color.
  */
  virtual ODCOLORREF paletteBackground() const;
 
  /** \details
    Returns true if and only if TrueType text should be filled during this vectorization.
  */
  virtual bool fillTtf() const;
 
  /** \details
    Returns the number of isolines to be drawn on surfaces during this vectorization.
  */
  virtual OdUInt32 numberOfIsolines() const;
 
  /** \details
    Returns true if and only if shell/mesh geometry primitives should be filled during this vectorization.
  */
  virtual bool fillMode() const;
 
  /** \details
    Returns true if and only if quick text mode enabled for this vectorization process.
  */
  virtual bool quickTextMode() const;
 
  /** \details
    Returns the text quality percent for this vectorization process.
 
    \remarks
    Returns a value in the range [0,100]. 50 is the default.
  */
  virtual OdUInt32 textQuality() const;
 
  enum ImageQuality
  {
    kImageQualityDraft = 0,
    kImageQualityHigh  = 1
  };
 
  /** \details
    Returns the image quality for this vectorization process.
  */
  virtual ImageQuality imageQuality() const;
 
  enum FadingType
  {
    kLockedLayerFade = 0,
    kXrefFade        = 1,
    kRefEditFade     = 2
  };
 
  /** \details
    Fading intensity percentage.
  */
  virtual OdUInt32 fadingIntensityPercentage(FadingType fadingType) const;
 
  enum GlyphType
  {
    kLightGlyph  = 0,
    kCameraGlyph = 1
  };
 
  /** \details
    Returns glyph size for specified glyph type.
 
    \param glyphType [in]  Type of glyph to return glyph size.
 
    \remarks
    Returns a value in the range [0,100].
 
    The default return values is following:
    <table>
    Name         Value
    kLightGlyph  0
    kCameraGlyph 50
    </table>
  */
  virtual OdUInt32 glyphSize(GlyphType glyphType) const;
 
  enum LineWeightStyle
  {
    kPointLineWeight = 0,
    kLineCapStyle    = 1,
    kLineJoinStyle   = 2
  };
 
  /** \details
    Returns line weight display style configuration.
 
    \param styleEntry [in]  Line weight style entry for which current setting will be returned.
 
    \remarks
    For kPointLineWeight style entry 0 will be returned if point line weight is disabled or 1 if enabled.
    For kLineCapStyle style entry will be returned member of OdPs::LineEndStyle enumeration.
    For kLineJoinStyle style entry will be returned member of OdPs::LineJoinStyle enumeration.
  */
  virtual OdUInt32 lineWeightConfiguration(LineWeightStyle styleEntry) const;
 
  enum DrawableFilterInputFlags { kNestedDrawable = 0x1000000 };
  enum DrawableFilterOutputFlags { kSkipVectorization = 1 };
  enum DrawableFilterRanges 
  { 
      kDrawableFilterAppRangeStart = 0x1000000
#if defined(SWIGCSHARP)
    , kDrawableFilterAppRangeMask          = (uint)0xFF000000
#elif defined(SWIGJAVA)
    , kDrawableFilterAppRangeMask          = (long)0xFF000000
#else
    , kDrawableFilterAppRangeMask          = (OdInt32)0xFF000000
#endif
  };
 
  /** \details
    Returns internal drawable filtration function ID.
    
    \param viewportId [in]  Pointer to the Object ID of the Viewport object to be queried.
  */
  virtual OdIntPtr drawableFilterFunctionId(OdDbStub* viewportId) const;
 
  /** \details
    Returns set of flags for drawable filtration function (will be called for each drawable vectorization).
 
    \param functionId [in]  Internal drawable filtration function ID.
    \param pDrawable [in]  Currently vectorizing drawable pointer.
    \param nFlags [in]  Set of input flags.
  */
  virtual OdUInt32 drawableFilterFunction(OdIntPtr functionId, const OdGiDrawable *pDrawable, OdUInt32 nFlags);
 
  /** \details
    Enables smooth contours information output for TrueType fonts.
  */
  virtual bool ttfPolyDraw() const;
 
  /** \details
    Returns true and only if this vectorization process should be aborted.
  */
  virtual bool regenAbort() const;
 
  enum PStyleType
  {
    kPsNone           = 0,
    kPsByColor        = 1,
    kPsByName         = 2
  };
  
  /** \details
    Returns the plot style type of this Context object.
    
    \remarks
    plotStyleType() returns one of the following:
    
    <table>
    Name          Value
    kPsNone       0
    kPsByColor    1
    kPsByName     2
    </table>
  */
  virtual PStyleType plotStyleType() const;
  
  /** \details
    Returns the PaperSpace PlotStyle data for this vectorization.
 
    \param penNumber [in]  Pen number.
    \param plotStyleData [out]  Receives the PlotStyle data.
    \param objectId [in]  Object ID of plot style.
  */
  virtual void plotStyle(
    int penNumber, 
    OdPsPlotStyleData& plotStyleData) const;
 
  virtual void plotStyle(
    OdDbStub* objectId, 
    OdPsPlotStyleData& plotStyleData) const;
 
  /** \details
    Converts object handle into Object ID.
 
    \param objectId [in]  Object handle.
  */
  virtual OdDbStub* getStubByID( OdUInt64 persistentId ) const;
 
  /** \details
    Converts Object ID to object handle (database persistent Id).
 
    \param objectId [in]  Object ID.
  */
  virtual OdUInt64 getIDByStub( OdDbStub* objectId ) const;
 
  /** \details
    Returns the database of Object ID.
 
    \param objectId [in]  Object ID.
  */
  virtual OdDbBaseDatabase *getDatabaseByStub( OdDbStub* objectId ) const;
 
  /** \details
    Returns the Owner Object ID of specified Object ID.
 
    \param objectId [in]  Object ID.
  */
  virtual OdDbStub* getOwnerIDByStub( OdDbStub* objectId ) const;
 
  /** \details
    Converts material name into Object ID.
 
    \param strMatName [in]  Material name.
  */
  virtual OdDbStub* getStubByMatName( const OdString& strMatName ) const;
 
  /** \details
    Controls shell silhouettes displaying on Gi side.
  */
  virtual bool displaySilhouettes() 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
    This class is the base class for entity-level vectorization within Teigha.
 
    \sa
    TD_Gi
 
    <group OdGi_Classes> 
*/
class FIRSTDLL_EXPORT OdGiCommonDraw : public OdRxObject
{
public:
  ODRX_DECLARE_MEMBERS(OdGiCommonDraw);
 
  /** \details
    Returns the regeneration type of the current vectorization process.
 
    \remarks
    regenType() returns one of the following:
    
    <table>
    Name                            Value 
    eOdGiRegenTypeInvalid           0
    kOdGiStandardDisplay            2
    kOdGiHideOrShadeCommand         3
    kOdGiRenderCommand              4
    kOdGiForExplode                 5
    kOdGiSaveWorldDrawForProxy      6
    kOdGiForExtents                 7
    </table>
  */
  virtual OdGiRegenType regenType() const = 0;
 
  /** \details
    Returns true and only if this vectorization process should be aborted.
  */
  virtual bool regenAbort() const = 0;
 
  /** \details
    Provides access to this object's the subentity traits.
 
    \remarks
    This allows the modification of the vectorization attributes such as color, linetype, etc.
  */
  virtual OdGiSubEntityTraits& subEntityTraits() const = 0;
 
  /** \details
    Provides access to this object's "drawing interface".
    
    \remarks
    The "drawing interface" is a set of geometry functions used during the vectorization process.
  */
  virtual OdGiGeometry& rawGeometry() const = 0;
 
  /** \details
    Returns true only if this vectorization process is the result of a "drag" operation.
    
    \remarks
  */
  virtual bool isDragging() const = 0;
  
  /** \details
    Returns the recommended maximum deviation of the
    current vectorization for the specified point on the curve.
 
    \param deviationType [in]  Deviation type.
    \param pointOnCurve [in]  Point on the curve.
        
    \remarks
    This function returns the recommended maximum difference (with respect to the current active viewport) between the actual curve or surface, 
    and the tessellated curve or surface. 
    
    deviationType must be one of the following:
    
    <table>
    Name                       Value
    kOdGiMaxDevForCircle       0      
    kOdGiMaxDevForCurve        1      
    kOdGiMaxDevForBoundary     2      
    kOdGiMaxDevForIsoline      3
    kOdGiMaxDevForFacet        4
    </table>
 
    \note
    This function uses circle zoom percent or FacetRes as appropriate.
  */
  virtual double deviation(
    const OdGiDeviationType deviationType, 
    const OdGePoint3d& pointOnCurve) const = 0;
 
  /** \details
    Returns the number of isolines to be drawn on surfaces during this vectorization.
  */
  virtual OdUInt32 numberOfIsolines() const = 0;
 
  /** \details
      Returns the OdGiContext instance associated with this object.
  */
  virtual OdGiContext* context() const = 0;
 
  /** \details
      Returns current drawable nesting graph.
  */
  virtual const OdGiPathNode* currentGiPath() const;
};
 
/** \details
    Draw flags helper.
    
    \remarks
    Modifies draw flags and restores them back in destructor.
 
    Library: TD_Gi
    
    <group OdGi_Classes> 
*/
class FIRSTDLL_EXPORT OdGiDrawFlagsHelper
{
  protected:
    OdGiSubEntityTraits *m_pTraits;
    OdUInt32 m_prevFlags;
  public:
    OdGiDrawFlagsHelper(OdGiSubEntityTraits &pTraits, OdUInt32 addFlags)
      : m_pTraits(NULL)
    {
      if (addFlags)
      {
        m_prevFlags = pTraits.drawFlags();
        OdUInt32 newFlags = m_prevFlags | addFlags;
        if (m_prevFlags != newFlags)
        {
          pTraits.setDrawFlags(newFlags);
          m_pTraits = &pTraits;
        }
      }
    }
    ~OdGiDrawFlagsHelper()
    {
      if (m_pTraits)
        m_pTraits->setDrawFlags(m_prevFlags);
    }
};
 
#include "TD_PackPop.h"
 
#endif