CFx SDK Documentation  2022 SP0
PlotStyles.h
Go to the documentation of this file.
1 // Copyright (C) 2002-2017, Open Design Alliance (the "Alliance").
3 // All rights reserved.
4 //
5 // This software and its documentation and related materials are owned by
6 // the Alliance. The software may only be incorporated into application
7 // programs owned by members of the Alliance, subject to a signed
8 // Membership Agreement and Supplemental Software License Agreement with the
9 // Alliance. The structure and organization of this software are the valuable
10 // trade secrets of the Alliance and its suppliers. The software is also
11 // protected by copyright law and international treaty provisions. Application
12 // programs incorporating this software must include the following statement
13 // with their copyright notices:
14 //
15 // This application incorporates Teigha(R) software pursuant to a license
16 // agreement with Open Design Alliance.
17 // Teigha(R) Copyright (C) 2002-2017 by Open Design Alliance.
18 // All rights reserved.
19 //
20 // By use of this software, its documentation or related materials, you
21 // acknowledge and accept the above terms.
23 
24 
25 
26 // RxPlotStyle.h -- interfaces for setting up plotstyles support for rendering
27 
28 #ifndef __OD_RX_PLOT_STYLE__
29 #define __OD_RX_PLOT_STYLE__
30 
31 
32 #include "RxObject.h"
33 #include "CmColorBase.h"
34 #include "RxModule.h"
35 #include "Ge/GeDoubleArray.h"
36 #include "StringArray.h"
37 
38 #define STL_USING_MAP
39 #define STL_USING_ALGORITHM
40 #include "OdaSTL.h"
41 
42 class OdStreamBuf;
43 
44 #include "TD_PackPush.h"
45 
50 namespace OdPs
51 {
52  enum FillStyle
53  {
54  kFsSolid = 64,
64 
66  };
67 
69  {
70  kLesButt = 0,
72  kLesRound = 2,
74  kLesUseObject = 4
75  };
76 
78  {
79  kLjsMiter = 0,
80  kLjsBevel = 1,
81  kLjsRound = 2,
83  kLjsUseObject = 5
84  };
85 
86  // plotstyle's linetype
87 
88  enum LineType
89  {
90  kLtpSolid = 0,
122 
124  };
125 
126 }
127 
135 {
136 public:
138  {
139  kDither = 1,
141  kNotUseObject = 4
142  };
143 
144 protected:
147  bool m_bAdaptiveLinetype; // not in color policy
155  double m_dLinePatSz;
156  double m_lineweight;
157 
158 public:
159 
161  : m_color(255, 255, 255)
162  , m_colorPolicy(0)
164  , m_screening(100)
165  , m_physPenNum(-1)
166  , m_virtPenNum(-1)
171  , m_dLinePatSz(0.0)
172  , m_lineweight(-1)
173  {}
174 
176 
177  // m_color(255, 255, 255) indicates "UseEntity: in PlotStyles
178 
182  bool operator ==(const OdPsPlotStyleData& other) const
183  {
184  return (
185  m_color == other.m_color &&
186  m_colorPolicy == other.m_colorPolicy &&
188  m_screening == other.m_screening &&
189  m_physPenNum == other.m_physPenNum &&
190  m_virtPenNum == other.m_virtPenNum &&
191  m_psLt == other.m_psLt &&
192  m_fillStyle == other.m_fillStyle &&
193  m_lineEndStyle == other.m_lineEndStyle &&
194  m_lineJoinStyle == other.m_lineJoinStyle &&
195  m_dLinePatSz == other.m_dLinePatSz &&
196  m_lineweight == other.m_lineweight
197  );
198  }
199 
203  bool operator !=(const OdPsPlotStyleData& other) const { return !operator ==(other); }
204 
208  const OdCmEntityColor& color() const { return m_color; }
209 
210  OdInt16 colorPolicy() const { return m_colorPolicy; }
219 
228  int screening() const { return m_screening; }
229 
233  double linePatternSize() const { return m_dLinePatSz; }
238 
242  bool isAdaptiveLinetype() const { return m_bAdaptiveLinetype; }
246  bool isGrayScaleOn() const { return GETBIT(m_colorPolicy, kGrayScale); }
250  bool isDitherOn() const { return GETBIT(m_colorPolicy, kDither); }
254  double lineweight() const { return m_lineweight; }
267 
273  {
274  m_color = color;
275  SETBIT(m_colorPolicy, kNotUseObject, !(color.red() == 255 && color.green() == 255 && color.blue() == 255));
276  // #CORE-11537 : turn off kNotUseObject bit if kGrayScale bit is set
279  }
280 
282 
315 
320  void setAdaptiveLinetype(bool adaptiveLinetype) { m_bAdaptiveLinetype = adaptiveLinetype; }
325  void setGrayScaleOn(bool grayScaleOn)
326  {
327  if (grayScaleOn)
328  {
329  // #CORE-11537 : turn off kNotUseObject bit
331  }
332  else
333  {
334  // #CORE-11537 : turn on kNotUseObject bit if m_color is not white
335  SETBIT(m_colorPolicy, kNotUseObject, !(m_color.red() == 255 && m_color.green() == 255 && m_color.blue() == 255));
336  }
337  SETBIT(m_colorPolicy, kGrayScale, grayScaleOn);
338  }
343  void setDitherOn(bool ditherOn) { SETBIT(m_colorPolicy, kDither, ditherOn); }
358  void setEndStyle(OdPs::LineEndStyle lineEndStyle) { m_lineEndStyle = OdInt16(lineEndStyle); }
364  void setJoinStyle(OdPs::LineJoinStyle lineJoinStyle) { m_lineJoinStyle = OdInt16(lineJoinStyle); }
365 };
366 
375 {
376 public:
378 
382  virtual OdString name() const = 0;
383 
387  virtual OdString description() const = 0;
392  virtual void getData(OdPsPlotStyleData& data) const = 0;
396  virtual OdString localizedName() const = 0;
397 
398  virtual void setData(const OdPsPlotStyleData& data) = 0;
399 
400  virtual void setDescription(const OdString& desc) = 0;
401 
402  virtual void setName(const OdString& name) = 0;
403 
404  virtual void setLocalizedName(const OdString& name) = 0;
405 
406 };
407 
412 
413 namespace OdPs
414 {
415 
416  // predicate
417  class OdPsStrLess : public std::binary_function<OdString, OdString, bool>
418  {
419  public:
420  bool operator()(const OdString& x, const OdString& y) const
421  {
422  return x.iCompare(y) < 0;
423  }
424  };
425 
426 } // OdPs
427 
428 typedef std::map<const OdChar*, OdPsPlotStylePtr, OdPs::OdPsStrLess> OdPsPlotStylesMap;
430 
439 {
440 public:
442 
443  virtual OdRxObjectPtr clone() const = 0;
444 
445  virtual void copyFrom(const OdRxObject* pSource) = 0;
446 
451  virtual bool isApplyScaleFactor() const = 0;
452 
456  virtual OdString description() const = 0;
457 
461  virtual double scaleFactor() const = 0;
462 
466  virtual bool isDisplayCustomLineweightUnits() const = 0;
467 
472  virtual double getLineweightAt(OdUInt32 index) const = 0;
473 
478  virtual OdPsPlotStylePtr plotStyleAt(const OdString& name) const = 0;
479 
486  virtual OdPsPlotStylePtr plotStyleAt(int index) const = 0;
487 
491  virtual unsigned int plotStyleSize() const = 0;
492 
493  virtual unsigned int lineweightSize() const = 0;
494 
495  virtual bool isAciTableAvailable() const = 0;
496 
497  virtual OdPsPlotStylePtr addNewPlotStyle(const OdString& styleName) = 0;
498 
500 
501  virtual void setDescription(const OdString& desc) = 0;
502 
503  virtual void setScaleFactor(double scFac) = 0;
504 
505  virtual void setApplyScaleFactor(bool flag) = 0;
506 
507  virtual void setDisplayCustomLineweightUnits(bool flag) = 0;
508 
509  virtual void setLineweightAt(double value, OdUInt32 index) = 0;
510 
511  virtual void setLineweights(const OdGeDoubleArray& lineweights) = 0;
512 
513  // Methods added in 2.7.0
514 
515  virtual void setAciTableAvailable(bool flag) = 0;
516 
517  virtual void setPlotStylesIndexed(const OdPsPlotStylesArray plotStylesIndexed) = 0;
518 
519  virtual void setPlotStyles(const OdPsPlotStylesMap plotStyles) = 0;
520 
521  virtual void addPlotStyle(OdPsPlotStyle* pPs) = 0;
522 
523  virtual void setOrdering(const OdStringArray& order) = 0;
524 
525  virtual OdPsPlotStylesMap plotStyles() const = 0;
526 
528 };
533 
541 {
542 public:
544 
554  virtual void savePlotStyleTable(OdStreamBuf* pBuf, OdPsPlotStyleTablePtr pPSTab) = 0;
555 
556 };
561 
562 #include "TD_PackPop.h"
563 
564 #endif // __OD_RX_PLOT_STYLE__
false
Definition: DimVarDefs.h:165
unsigned int OdUInt32
short OdInt16
#define SETBIT(flags, bit, value)
Definition: OdaDefs.h:497
#define SETBIT_0(flags, bit)
Definition: OdaDefs.h:500
#define GETBIT(flags, bit)
Definition: OdaDefs.h:498
std::map< const OdChar *, OdPsPlotStylePtr, OdPs::OdPsStrLess > OdPsPlotStylesMap
Definition: PlotStyles.h:428
OdSmartPtr< OdPsPlotStyleTable > OdPsPlotStyleTablePtr
Definition: PlotStyles.h:532
OdSmartPtr< OdPsPlotStyleServices > OdPsPlotStyleServicesPtr
Definition: PlotStyles.h:560
OdSmartPtr< OdPsPlotStyle > OdPsPlotStylePtr
Definition: PlotStyles.h:411
OdArray< OdPsPlotStylePtr > OdPsPlotStylesArray
Definition: PlotStyles.h:429
#define FIRSTDLL_EXPORT
Definition: RootExport.h:39
#define FIRSTDLL_EXPORT_STATIC
Definition: RootExport.h:40
OdUInt8 blue() const
Definition: CmColorBase.h:461
OdUInt8 green() const
Definition: CmColorBase.h:450
OdUInt8 red() const
Definition: CmColorBase.h:439
bool operator()(const OdString &x, const OdString &y) const
Definition: PlotStyles.h:420
OdInt16 physicalPenNumber() const
Definition: PlotStyles.h:214
OdInt16 virtualPenNumber() const
Definition: PlotStyles.h:218
double lineweight() const
Definition: PlotStyles.h:254
void setLineweight(double lineweight)
Definition: PlotStyles.h:348
void setAdaptiveLinetype(bool adaptiveLinetype)
Definition: PlotStyles.h:320
FIRSTDLL_EXPORT static FIRSTDLL_EXPORT_STATIC const OdPsPlotStyleData kDefault
Definition: PlotStyles.h:175
OdPs::LineEndStyle endStyle() const
Definition: PlotStyles.h:262
double linePatternSize() const
Definition: PlotStyles.h:233
bool isAdaptiveLinetype() const
Definition: PlotStyles.h:242
OdPs::FillStyle fillStyle() const
Definition: PlotStyles.h:258
bool isGrayScaleOn() const
Definition: PlotStyles.h:246
OdInt16 m_physPenNum
Definition: PlotStyles.h:149
OdPs::LineJoinStyle joinStyle() const
Definition: PlotStyles.h:266
OdInt16 colorPolicy() const
Definition: PlotStyles.h:210
OdInt16 m_lineEndStyle
Definition: PlotStyles.h:153
void setPhysicalPenNumber(OdInt16 physicalPenNumber)
Definition: PlotStyles.h:287
void setColor(const OdCmEntityColor &color)
Definition: PlotStyles.h:272
OdInt16 m_lineJoinStyle
Definition: PlotStyles.h:154
void setColorPolicy(OdInt16 colorPolicy)
Definition: PlotStyles.h:281
bool operator==(const OdPsPlotStyleData &other) const
Definition: PlotStyles.h:182
OdInt16 m_virtPenNum
Definition: PlotStyles.h:150
bool isDitherOn() const
Definition: PlotStyles.h:250
void setLinePatternSize(double linePatternSize)
Definition: PlotStyles.h:309
void setJoinStyle(OdPs::LineJoinStyle lineJoinStyle)
Definition: PlotStyles.h:364
void setEndStyle(OdPs::LineEndStyle lineEndStyle)
Definition: PlotStyles.h:358
void setDitherOn(bool ditherOn)
Definition: PlotStyles.h:343
OdInt16 m_screening
Definition: PlotStyles.h:148
int screening() const
Definition: PlotStyles.h:228
const OdCmEntityColor & color() const
Definition: PlotStyles.h:208
bool operator!=(const OdPsPlotStyleData &other) const
Definition: PlotStyles.h:203
void setLinetype(OdPs::LineType linetype)
Definition: PlotStyles.h:314
void setGrayScaleOn(bool grayScaleOn)
Definition: PlotStyles.h:325
bool m_bAdaptiveLinetype
Definition: PlotStyles.h:147
void setFillStyle(OdPs::FillStyle fillStyle)
Definition: PlotStyles.h:353
OdCmEntityColor m_color
Definition: PlotStyles.h:145
void setVirtualPenNumber(OdInt16 virtualPenNumber)
Definition: PlotStyles.h:292
OdInt16 m_colorPolicy
Definition: PlotStyles.h:146
OdInt16 m_fillStyle
Definition: PlotStyles.h:152
OdPs::LineType linetype() const
Definition: PlotStyles.h:237
void setScreening(int screening)
Definition: PlotStyles.h:303
virtual void setName(const OdString &name)=0
virtual void setData(const OdPsPlotStyleData &data)=0
virtual OdString description() const =0
virtual void getData(OdPsPlotStyleData &data) const =0
virtual OdString name() const =0
virtual void setDescription(const OdString &desc)=0
ODRX_DECLARE_MEMBERS(OdPsPlotStyle)
virtual OdString localizedName() const =0
virtual void setLocalizedName(const OdString &name)=0
ODRX_DECLARE_MEMBERS(OdPsPlotStyleServices)
virtual void savePlotStyleTable(OdStreamBuf *pBuf, OdPsPlotStyleTablePtr pPSTab)=0
virtual OdPsPlotStyleTablePtr createPlotStyleTable()=0
virtual OdPsPlotStyleTablePtr loadPlotStyleTable(OdStreamBuf *pStreamBuf)=0
virtual void setAciTableAvailable(bool flag)=0
virtual unsigned int plotStyleSize() const =0
virtual void setDescription(const OdString &desc)=0
virtual OdPsPlotStylePtr plotStyleAt(const OdString &name) const =0
virtual void setDisplayCustomLineweightUnits(bool flag)=0
virtual double scaleFactor() const =0
virtual void addPlotStyle(OdPsPlotStyle *pPs)=0
virtual void setPlotStylesIndexed(const OdPsPlotStylesArray plotStylesIndexed)=0
virtual OdPsPlotStylesMap plotStyles() const =0
virtual bool isApplyScaleFactor() const =0
virtual OdPsPlotStylesArray plotStylesIndexed() const =0
virtual OdPsPlotStylePtr addNewPlotStyle(const OdString &styleName)=0
virtual unsigned int lineweightSize() const =0
virtual OdString description() const =0
virtual bool isDisplayCustomLineweightUnits() const =0
virtual void setApplyScaleFactor(bool flag)=0
virtual OdPsPlotStylePtr plotStyleAt(int index) const =0
virtual bool isAciTableAvailable() const =0
virtual void copyFrom(const OdRxObject *pSource)=0
virtual void setScaleFactor(double scFac)=0
virtual OdPsPlotStylePtr delPlotStyle(OdPsPlotStylePtr pPsPtr)=0
virtual void setLineweights(const OdGeDoubleArray &lineweights)=0
virtual void setOrdering(const OdStringArray &order)=0
virtual void setLineweightAt(double value, OdUInt32 index)=0
ODRX_DECLARE_MEMBERS(OdPsPlotStyleTable)
virtual void setPlotStyles(const OdPsPlotStylesMap plotStyles)=0
virtual double getLineweightAt(OdUInt32 index) const =0
virtual OdRxObjectPtr clone() const =0
GLint GLenum GLsizei GLsizei GLint GLsizei const void * data
Definition: gles2_ext.h:110
GLuint index
Definition: gles2_ext.h:265
GLuint const GLchar * name
Definition: gles2_ext.h:265
GLfloat x
Definition: gles2_ext.h:314
GLfloat GLfloat y
Definition: gles2_ext.h:316
GLsizei const GLfloat * value
Definition: gles2_ext.h:302
LineType
Definition: PlotStyles.h:89
@ kLtpDashed
Definition: PlotStyles.h:91
@ kLtpISODashSpace
Definition: PlotStyles.h:108
@ kLtpShortDashX2
Definition: PlotStyles.h:97
@ kLtpISODash
Definition: PlotStyles.h:107
@ kLtpISODashTripleDot
Definition: PlotStyles.h:119
@ kLtpLongDashDotDot
Definition: PlotStyles.h:103
@ kLtpISOLongDashDoubleDot
Definition: PlotStyles.h:110
@ kLtpLongDashShortDash
Definition: PlotStyles.h:102
@ kLtpSolid
Definition: PlotStyles.h:90
@ kLtpMediumDashShortDashShortDash
Definition: PlotStyles.h:101
@ kLtpDotted
Definition: PlotStyles.h:92
@ kLtpMediumDashDotShortDashDot
Definition: PlotStyles.h:105
@ kLtpISODashDot
Definition: PlotStyles.h:115
@ kLtpMediumLongDash
Definition: PlotStyles.h:100
@ kLtpISODoubleDashDot
Definition: PlotStyles.h:116
@ kLtpISODashDoubleDot
Definition: PlotStyles.h:117
@ kLtpISOLongDashTripleDot
Definition: PlotStyles.h:111
@ kLtpISOLongDashDot
Definition: PlotStyles.h:109
@ kLtpLongDashX2
Definition: PlotStyles.h:99
@ kLtpISOLongDashDoubleShortDash
Definition: PlotStyles.h:114
@ kLtpLongDash
Definition: PlotStyles.h:96
@ kLtpSparseDot
Definition: PlotStyles.h:106
@ kLtpLast
Definition: PlotStyles.h:123
@ kLtpISODoubleDashDoubleDot
Definition: PlotStyles.h:118
@ kLtpISOLongDashShortDash
Definition: PlotStyles.h:113
@ kLtpShortDash
Definition: PlotStyles.h:94
@ kLtpDashDot
Definition: PlotStyles.h:93
@ kLtpMediumDash
Definition: PlotStyles.h:95
@ kLtpISODot
Definition: PlotStyles.h:112
@ kLtpLongDashDot
Definition: PlotStyles.h:104
@ kLtpMediumDashX2
Definition: PlotStyles.h:98
@ kLtpISODoubleDashTripleDot
Definition: PlotStyles.h:120
@ kLtpUseObject
Definition: PlotStyles.h:121
FillStyle
Definition: PlotStyles.h:53
@ kFsLast
Definition: PlotStyles.h:65
@ kFsVerticalBars
Definition: PlotStyles.h:62
@ kFsDiamonds
Definition: PlotStyles.h:57
@ kFsSquareDots
Definition: PlotStyles.h:61
@ kFsSlantLeft
Definition: PlotStyles.h:59
@ kFsHorizontalBars
Definition: PlotStyles.h:58
@ kFsCrosshatch
Definition: PlotStyles.h:56
@ kFsCheckerboard
Definition: PlotStyles.h:55
@ kFsSlantRight
Definition: PlotStyles.h:60
@ kFsUseObject
Definition: PlotStyles.h:63
@ kFsSolid
Definition: PlotStyles.h:54
LineJoinStyle
Definition: PlotStyles.h:78
@ kLjsDiamond
Definition: PlotStyles.h:82
@ kLjsUseObject
Definition: PlotStyles.h:83
@ kLjsBevel
Definition: PlotStyles.h:80
@ kLjsMiter
Definition: PlotStyles.h:79
@ kLjsRound
Definition: PlotStyles.h:81
LineEndStyle
Definition: PlotStyles.h:69
@ kLesDiamond
Definition: PlotStyles.h:73
@ kLesSquare
Definition: PlotStyles.h:71
@ kLesUseObject
Definition: PlotStyles.h:74
@ kLesButt
Definition: PlotStyles.h:70
@ kLesRound
Definition: PlotStyles.h:72