zjf
2023-03-06 4c74f8a9fb913d0c3db432c65afc4bff7f779522
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
/////////////////////////////////////////////////////////////////////////////// 
// 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.
///////////////////////////////////////////////////////////////////////////////
 
 
 
// RxPlotStyle.h -- interfaces for setting up plotstyles support for rendering
 
#ifndef __OD_RX_PLOT_STYLE__
#define __OD_RX_PLOT_STYLE__
 
 
#include "RxObject.h"
#include "CmColor.h"
#include "RxModule.h"
#include "Ge/GeDoubleArray.h"
#include "StringArray.h"
 
#define STL_USING_MAP
#define STL_USING_ALGORITHM
#include "OdaSTL.h"
 
class OdStreamBuf;
 
#include "TD_PackPush.h"
 
/** \details
 
    <group TD_Namespaces>
*/
namespace OdPs
{
  enum FillStyle
  {
    kFsSolid            = 64,
    kFsCheckerboard     = 65,
    kFsCrosshatch       = 66,
    kFsDiamonds         = 67,
    kFsHorizontalBars   = 68,
    kFsSlantLeft        = 69,
    kFsSlantRight       = 70,
    kFsSquareDots       = 71,
    kFsVerticalBars     = 72,
    kFsUseObject        = 73,
 
    kFsLast             = kFsUseObject
  };
 
  enum LineEndStyle
  {
    kLesButt          = 0,
    kLesSquare        = 1,
    kLesRound         = 2,
    kLesDiamond       = 3,
    kLesUseObject     = 4
  };
  
  enum LineJoinStyle
  {
    kLjsMiter         = 0,
    kLjsBevel         = 1,
    kLjsRound         = 2,
    kLjsDiamond       = 3,
    kLjsUseObject     = 5
  };
  
  // plotstyle's linetype
  
  enum LineType
  {
    kLtpSolid                            = 0,
    kLtpDashed                           = 1,
    kLtpDotted                           = 2,
    kLtpDashDot                          = 3,
    kLtpShortDash                        = 4,
    kLtpMediumDash                       = 5,
    kLtpLongDash                         = 6,
    kLtpShortDashX2                      = 7,
    kLtpMediumDashX2                     = 8,
    kLtpLongDashX2                       = 9,
    kLtpMediumLongDash                   = 10,
    kLtpMediumDashShortDashShortDash     = 11,
    kLtpLongDashShortDash                = 12,
    kLtpLongDashDotDot                   = 13,
    kLtpLongDashDot                      = 14,
    kLtpMediumDashDotShortDashDot        = 15,
    kLtpSparseDot                        = 16,
    kLtpISODash                          = 17,
    kLtpISODashSpace                     = 18,
    kLtpISOLongDashDot                   = 19,
    kLtpISOLongDashDoubleDot             = 20,
    kLtpISOLongDashTripleDot             = 21,
    kLtpISODot                           = 22,
    kLtpISOLongDashShortDash             = 23,
    kLtpISOLongDashDoubleShortDash       = 24,
    kLtpISODashDot                       = 25,
    kLtpISODoubleDashDot                 = 26,
    kLtpISODashDoubleDot                 = 27,
    kLtpISODoubleDashDoubleDot           = 28,
    kLtpISODashTripleDot                 = 29,
    kLtpISODoubleDashTripleDot           = 30,
    kLtpUseObject                        = 31,
 
    kLtpLast = kLtpUseObject
  };
 
}
 
/** \details
    This class represents PlotStyle data for a single color (or object color) in OdPsPlotStyle objects.
 
    Library: PlotStyleSvcs
    <group Other_Classes> 
*/
class OdPsPlotStyleData
{
protected:
  enum ColorPolicy
  {
    kDither       = 1,
    kGrayScale    = 2,
    kNotUseObject = 4
  };
 
  OdCmEntityColor       m_color; 
  OdInt16               m_colorPolicy;
  bool                  m_bAdaptiveLinetype; // not in color policy
  OdInt16               m_screening;
  OdInt16               m_physPenNum;
  OdInt16               m_virtPenNum;
  OdInt16               m_psLt;
  OdInt16               m_fillStyle;
  OdInt16               m_lineEndStyle;
  OdInt16               m_lineJoinStyle;
  double                m_dLinePatSz;
  double                m_lineweight;
 
public:
 
  OdPsPlotStyleData()
    : m_color(255, 255, 255)
    , m_colorPolicy(0)
    , m_bAdaptiveLinetype(false)
    , m_screening(100)
    , m_physPenNum(-1)
    , m_virtPenNum(-1)
    , m_psLt(OdInt16(OdPs::kLtpUseObject))
    , m_fillStyle(OdInt16(OdPs::kFsUseObject))
    , m_lineEndStyle(OdInt16(OdPs::kLesUseObject))
    , m_lineJoinStyle(OdInt16(OdPs::kLjsUseObject))
    , m_dLinePatSz(0.0)
    , m_lineweight(-1)
  {}
 
  FIRSTDLL_EXPORT FIRSTDLL_EXPORT_STATIC static const OdPsPlotStyleData kDefault;
 
   // m_color(255, 255, 255) indicates "UseEntity: in PlotStyles
 
  /** \details
    Equality operator.
  */
  bool operator ==(const OdPsPlotStyleData& other) const
  {
    return (
        m_color             == other.m_color             &&
        m_colorPolicy       == other.m_colorPolicy       &&
        m_bAdaptiveLinetype == other.m_bAdaptiveLinetype &&
        m_screening         == other.m_screening         &&
        m_physPenNum        == other.m_physPenNum        &&
        m_virtPenNum        == other.m_virtPenNum        &&
        m_psLt              == other.m_psLt              &&
        m_fillStyle         == other.m_fillStyle         &&
        m_lineEndStyle      == other.m_lineEndStyle      &&
        m_lineJoinStyle     == other.m_lineJoinStyle     &&
        m_dLinePatSz        == other.m_dLinePatSz        &&
        m_lineweight        == other.m_lineweight        
      );
  }
 
  /** \details
    Inequality operator.
  */
  bool operator !=(const OdPsPlotStyleData& other) const { return !operator ==(other); }
 
  /** \details
    Returns the Color for this PlotStyleData object.
  */
  const OdCmEntityColor&  color() const { return m_color; }
 
  OdInt16 colorPolicy() const { return m_colorPolicy; }
  /** \details
    Returns the Physical Pen Number for this PlotStyleData object.
  */
  OdInt16                 physicalPenNumber() const { return m_physPenNum; }
  /** \details
    Returns the Virtual Pen Number for this PlotStyleData object.
  */
  OdInt16                 virtualPenNumber() const { return m_virtPenNum; }
  
  /** \details
    Returns the Screening for this PlotStyleData object.
    
    \returns
    Returns a value in the range [0.0 .. 100.0].
    * 0 indicates white.
    * 100 indicates colors at their full intensities.
  */
  int                     screening() const { return m_screening; }
 
  /** \details
    Returns the Line Pattern Size for this PlotStyleData object.
  */
  double                  linePatternSize() const { return m_dLinePatSz; }
  /** \details
    Returns the Linetype for this PlotStyleData object.
  */
  OdPs::LineType          linetype() const { return OdPs::LineType(m_psLt); }
 
  /** \details
    Returns true if an only if the Linetype is adaptive for this PlotStyleData object.
  */
  bool                    isAdaptiveLinetype() const { return m_bAdaptiveLinetype; }
  /** \details
    Returns true if an only if Grayscale is on for this PlotStyleData object.
  */
  bool                    isGrayScaleOn() const { return GETBIT(m_colorPolicy, kGrayScale); }
  /** \details
    Returns true if an only if Dither is on for this PlotStyleData object.
  */
  bool                    isDitherOn() const { return GETBIT(m_colorPolicy, kDither); }
  /** \details
    Returns the Lineweight for this PlotStyleData object.
  */
  double                  lineweight() const { return m_lineweight; }
  /** \details
    Returns the Fill Style for this PlotStyleData object.
  */
  OdPs::FillStyle         fillStyle() const { return OdPs::FillStyle(m_fillStyle); }
  /** \details
    Returns the Line End Style for this PlotStyleData object.
  */
  OdPs::LineEndStyle      endStyle()  const { return OdPs::LineEndStyle(m_lineEndStyle); }
  /** \details
    Returns the Line Join Style for this PlotStyleData object.
  */
  OdPs::LineJoinStyle     joinStyle() const { return OdPs::LineJoinStyle(m_lineJoinStyle); }
 
  /** \details
    Sets the Color for this PlotStyleData object.
    \param color [in]  Color.
  */
  void setColor(const OdCmEntityColor& color) 
  { 
    m_color = color;
    SETBIT(m_colorPolicy, kNotUseObject, !(color.red()==255 && color.green()==255 && color.blue()==255));
  }
  
  void setColorPolicy(OdInt16 colorPolicy) { m_colorPolicy = colorPolicy; }
 
  /** \details
    Sets the Physical Pen Number for this PlotStyleData object.
    \param physicalPenNumber [in]  Physical Pen Number.
  */
  void setPhysicalPenNumber(OdInt16 physicalPenNumber) { m_physPenNum = physicalPenNumber; }
  /** \details
    Sets the Virtual Pen Number for this PlotStyleData object.
    \param virtualPenNumber [in]  Virtual Pen Number.
  */
  void setVirtualPenNumber(OdInt16 virtualPenNumber) { m_virtPenNum = virtualPenNumber; }
  /** \details
    Sets the Screening for this PlotStyleData object.
    
    \param screening [in]  Screening.
    
    \remarks
    screening must be in range [0.0 .. 100.0].
    * 0 indicates white.
    * 100 indicates the colors at their full intensities.
  */
  void setScreening(int screening) { m_screening = OdInt16(screening); }
  /** \details
    Sets the Line Pattern Size for this PlotStyleData object.
    \param linePatternSize [in]  Line Pattern Size.
    
  */
  void setLinePatternSize(double linePatternSize) { m_dLinePatSz = linePatternSize; }
  /** \details
    Sets the Linetype for this PlotStyleData object.
    \param linetype [in]  Linetype.
  */
  void setLinetype(OdPs::LineType linetype) { m_psLt = OdInt16(linetype); }
  
  /** \details
    Controls if the Linetype is adaptive for this PlotStyleData object.
    \param adaptiveLinetype [in]  Controls Adaptive Linetype.
  */
  void setAdaptiveLinetype(bool adaptiveLinetype) { m_bAdaptiveLinetype = adaptiveLinetype; }
  /** \details
    Controls if Grayscale is on for this PlotStyleData object.
    \param grayScaleOn [in]  Controls Grayscale On.
  */
  void setGrayScaleOn(bool grayScaleOn) { SETBIT(m_colorPolicy, kGrayScale, grayScaleOn); }
  /** \details
    Controls if Dither is on for this PlotStyleData object.
    \param ditherOn [in]  Controls Dither On.
  */
  void setDitherOn(bool ditherOn) { SETBIT(m_colorPolicy, kDither, ditherOn); }
  /** \details
    Sets the Lineweight for this PlotStyleData object.
    \param lineweight [in]  Lineweight.
  */
  void setLineweight(double lineweight) { m_lineweight = lineweight; }
  /** \details
    Sets the Fill Style for this PlotStyleData object.
    \param fillStyle [in]  Fill Style.
  */
  void setFillStyle(OdPs::FillStyle fillStyle) { m_fillStyle = OdInt16(fillStyle); }
  /** \details
    Sets the LineEndStyle for this PlotStyleData object.
    \param LineEndStyle [in]  LineEndStyle.
  */
  void setEndStyle(OdPs::LineEndStyle lineEndStyle) { m_lineEndStyle = OdInt16(lineEndStyle); }
  /** \details
    Sets the Line Join Style for this PlotStyleData object.
    
    \param lineJoinStyle [in] Line Join Style.
  */
  void setJoinStyle(OdPs::LineJoinStyle lineJoinStyle) { m_lineJoinStyle = OdInt16(lineJoinStyle); }
};
 
/** \details
    This class represents PlotStyle objects.
 
    Library: PlotStyleSvcs
 
    <group Other_Classes>
*/
class FIRSTDLL_EXPORT OdPsPlotStyle : public OdRxObject
{
public:
  ODRX_DECLARE_MEMBERS(OdPsPlotStyle);
 
  /** \details
    Returns the name of this PlotStyle object.
  */
  virtual OdString  name() const = 0;
 
  /** \details
    Returns the description of this PlotStyle object.
  */
  virtual OdString  description() const = 0;
  /** \details
    Returns the PlotStyleData for this PlotStyle object.
    \param data [out]  Receives the data.
  */
  virtual void      getData(OdPsPlotStyleData& data) const = 0;
  /** \details
    Returns the localizedName of this PlotStyle object.
  */
  virtual OdString  localizedName() const = 0;
 
  virtual void      setData(const OdPsPlotStyleData& data) = 0;
 
  virtual void      setDescription(const OdString& desc) = 0;
 
  virtual void      setName(const OdString& name) = 0;
 
  virtual void      setLocalizedName(const OdString& name) = 0;
 
};
 
/** \details
    This template class is a specialization of the OdSmartPtr class for OdPsPlotStyle object pointers.
*/
typedef OdSmartPtr<OdPsPlotStyle> OdPsPlotStylePtr;
 
namespace OdPs
{
 
  // predicate
  class OdPsStrLess : public std::binary_function<OdString, OdString, bool>
  {
  public:
    bool operator()(const OdString& x, const OdString& y) const
    {
      return x.iCompare(y) < 0;
    }
  };
 
} // OdPs
 
typedef std::map<const OdChar*, OdPsPlotStylePtr, OdPs::OdPsStrLess> OdPsPlotStylesMap;
typedef OdArray<OdPsPlotStylePtr> OdPsPlotStylesArray;
 
/** \details
    This class implements Plot Style Tables.
 
    Library: PlotStyleSvcs
 
    <group Other_Classes>
*/
class FIRSTDLL_EXPORT OdPsPlotStyleTable : public OdRxObject
{
public:  
  ODRX_DECLARE_MEMBERS(OdPsPlotStyleTable);
 
  virtual OdRxObjectPtr clone() const = 0;
 
  virtual void copyFrom(const OdRxObject* pSource) = 0;
 
  /** \details
    Returns true if and only if the global scale factor is to be applied to non-ISO linetypes
    for this PlotStyleTable object.
  */
  virtual bool      isApplyScaleFactor() const = 0;
 
  /** \details
    Returns the description of this PlotStyleTable object.
  */
  virtual OdString  description() const = 0;
 
  /** \details
    Returns the global scale factor to be applied to non-ISO linetypes for this PlotStyleTable object.
  */
  virtual double    scaleFactor() const = 0;
 
  /** \details
    Returns true if and only if Custom Lineweight Units are to be displayed for this PlotStyleTable object.
  */
  virtual bool      isDisplayCustomLineweightUnits() const = 0;
 
  /** \details
    Returns the lineweight for the specified entry in this PlotStyleTable object.
    \param index [in]  PlotStyle index.
  */
  virtual double    getLineweightAt(OdUInt32 index) const = 0;
 
  /** \details
    Returns the specified PlotStyle in this PlotStyleTable object.
    \param name [in]  Plot Style name.
  */
  virtual OdPsPlotStylePtr plotStyleAt(const OdString& name) const = 0;
 
  /** \param index [in]  PlotStyle index.
  */
  virtual OdPsPlotStylePtr plotStyleAt(int index) const = 0;
 
  /** \details
    Returns the logical length of this PlotStyle
  */
  virtual unsigned int plotStyleSize() const = 0;
 
  virtual unsigned int lineweightSize() const = 0;
 
  virtual bool isAciTableAvailable() const = 0;
 
  virtual OdPsPlotStylePtr addNewPlotStyle(const OdString& styleName) = 0;
 
  virtual OdPsPlotStylePtr delPlotStyle(OdPsPlotStylePtr pPsPtr) = 0;
 
  virtual void setDescription(const OdString& desc) = 0;
 
  virtual void setScaleFactor(double scFac) = 0;
 
  virtual void setApplyScaleFactor(bool flag) = 0;
 
  virtual void setDisplayCustomLineweightUnits(bool flag) = 0;
 
  virtual void setLineweightAt(double value, OdUInt32 index) = 0;
 
  virtual void setLineweights(const OdGeDoubleArray& lineweights) = 0;
 
  // Methods added in 2.7.0
 
  virtual void setAciTableAvailable(bool flag) = 0;
 
  virtual void setPlotStylesIndexed(const OdPsPlotStylesArray plotStylesIndexed) = 0;
 
  virtual void setPlotStyles(const OdPsPlotStylesMap plotStyles) = 0;
 
  virtual void addPlotStyle(OdPsPlotStyle* pPs) = 0;
 
  virtual void setOrdering(const OdStringArray& order) = 0;
 
  virtual OdPsPlotStylesMap plotStyles() const = 0;
 
  virtual OdPsPlotStylesArray plotStylesIndexed() const = 0;
};
/** \details
    This template class is a specialization of the OdPsPlotStyleTable class for OdAveScene object pointers.
*/
typedef OdSmartPtr<OdPsPlotStyleTable> OdPsPlotStyleTablePtr;
 
/** \details
    This class is the base class for classes that provide platform-dependent loading of PlotStyle (CTB/STB) files
    for Teigha.
    Library: PlotStyleSvcs
    <group Other_Classes>
*/
class FIRSTDLL_EXPORT OdPsPlotStyleServices : public OdRxModule
{
public:
  ODRX_DECLARE_MEMBERS(OdPsPlotStyleServices);
 
  /** \details
    Loads a plot style table.
 
    \param pStreamBuf [in]  Pointer to the StreamBuf object from which the data are to be read.
    \remarks
    Returns a SmartPointer to the newly loaded PlotStyleTable object.   
  */
  virtual OdPsPlotStyleTablePtr createPlotStyleTable() = 0;
  virtual OdPsPlotStyleTablePtr loadPlotStyleTable(OdStreamBuf* pStreamBuf) = 0;
  virtual void                  savePlotStyleTable(OdStreamBuf* pBuf, OdPsPlotStyleTablePtr pPSTab) = 0;
 
};
/** \details
    This template class is a specialization of the OdSmartPtr class for OdPsPlotStyleServices object pointers.
*/
typedef OdSmartPtr<OdPsPlotStyleServices> OdPsPlotStyleServicesPtr;
 
#include "TD_PackPop.h"
 
#endif // __OD_RX_PLOT_STYLE__