CFx SDK Documentation  2020SP3
GiLineweightOverride.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 #ifndef _ODGILINEWEIGHTOVERRIDE_INCLUDED_
25 #define _ODGILINEWEIGHTOVERRIDE_INCLUDED_
26 
27 #include "Gi/Gi.h"
28 #include "Ps/PlotStyles.h"
29 
30 #include "TD_PackPush.h"
31 
41 {
42  protected:
43  enum Flags
44  {
45  kLwdOverrideScale = (1 << 0),
46  kLwdOverrideStyle = (1 << 1)
47  };
49  double m_dLwdScale;
50  double m_dPixScale;
53  public:
55  : m_uFlags(0)
56  , m_dLwdScale(1.0)
57  , m_dPixScale(1.0)
60  { }
61  // Scale override
62  void setScaleOverride(double dLwdScale)
63  {
65  m_dLwdScale = m_dPixScale = dLwdScale;
66  }
68  {
70  m_dLwdScale = m_dPixScale = 1.0;
71  }
72  bool hasScaleOverride() const
73  {
75  }
76  double scaleOverride() const
77  {
78  return m_dLwdScale;
79  }
80  // Helpers
81  void setPixelScale(double dPixScale)
82  {
83  m_dPixScale = dPixScale;
84  }
85  double pixelScale() const
86  {
87  return m_dPixScale;
88  }
89  // Style override
90  void setStyleOverride(OdPs::LineEndStyle lineCapStyle, OdPs::LineJoinStyle lineJoinStyle)
91  {
93  m_lineCapStyle = lineCapStyle;
94  m_lineJoinStyle = lineJoinStyle;
95  }
97  {
101  }
102  bool hasStyleOverride() const
103  {
105  }
107  {
108  return m_lineCapStyle;
109  }
111  {
112  return m_lineJoinStyle;
113  }
114  // Helpers
115  bool hasOverrides() const
116  {
117  return m_uFlags != 0;
118  }
119  bool operator ==(const OdGiLineweightOverride &lwdO2) const
120  {
121  if (lwdO2.m_uFlags != m_uFlags)
122  return false;
123  if (hasScaleOverride())
124  {
125  if (!OdEqual(lwdO2.m_dLwdScale, m_dLwdScale))
126  return false;
127  }
128  if (hasStyleOverride())
129  {
130  if (lwdO2.m_lineCapStyle != m_lineCapStyle ||
132  return false;
133  }
134  return true;
135  }
136  bool operator !=(const OdGiLineweightOverride &lwdO2) const
137  {
138  if (lwdO2.m_uFlags != m_uFlags)
139  return true;
140  if (hasScaleOverride())
141  {
142  if (!OdEqual(lwdO2.m_dLwdScale, m_dLwdScale))
143  return true;
144  }
145  if (hasStyleOverride())
146  {
147  if (lwdO2.m_lineCapStyle != m_lineCapStyle ||
149  return true;
150  }
151  return false;
152  }
153 };
154 
164 {
165  protected:
167  public:
170  { setLineweightOverride(pTraits, pOverride); }
172  {
173  if (m_pTraits)
174  m_pTraits->popLineweightOverride();
175  }
177  {
178  m_pTraits = &pTraits;
179  m_pTraits->pushLineweightOverride(&pOverride);
180  }
181 };
182 
183 #include "TD_PackPop.h"
184 
185 #endif //_ODGILINEWEIGHTOVERRIDE_INCLUDED_
GETBIT
#define GETBIT(flags, bit)
Definition: OdaDefs.h:498
OdGiLineweightOverrideHelper::OdGiLineweightOverrideHelper
OdGiLineweightOverrideHelper(OdGiSubEntityTraits &pTraits, const OdGiLineweightOverride &pOverride)
Definition: GiLineweightOverride.h:169
OdEqual
bool OdEqual(double x, double y, double tol=1.e-10)
Definition: OdaDefs.h:523
OdGiLineweightOverride::resetScaleOverride
void resetScaleOverride()
Definition: GiLineweightOverride.h:67
NULL
#define NULL
Definition: GsProperties.h:177
OdGiLineweightOverrideHelper::~OdGiLineweightOverrideHelper
~OdGiLineweightOverrideHelper()
Definition: GiLineweightOverride.h:171
OdPs::kLjsRound
@ kLjsRound
Definition: PlotStyles.h:81
SETBIT_1
#define SETBIT_1(flags, bit)
Definition: OdaDefs.h:501
PlotStyles.h
OdGiLineweightOverrideHelper::setLineweightOverride
void setLineweightOverride(OdGiSubEntityTraits &pTraits, const OdGiLineweightOverride &pOverride)
Definition: GiLineweightOverride.h:176
OdGiLineweightOverride::m_dLwdScale
double m_dLwdScale
Definition: GiLineweightOverride.h:49
TD_PackPop.h
OdGiLineweightOverride::joinStyleOverride
OdPs::LineJoinStyle joinStyleOverride() const
Definition: GiLineweightOverride.h:110
OdUInt32
unsigned int OdUInt32
Definition: OdPlatformSettings.h:783
ODGI_EXPORT
#define ODGI_EXPORT
Definition: GiExport.h:35
OdGiLineweightOverride::scaleOverride
double scaleOverride() const
Definition: GiLineweightOverride.h:76
OdPs
Definition: PlotStyles.h:51
OdGiLineweightOverride::setPixelScale
void setPixelScale(double dPixScale)
Definition: GiLineweightOverride.h:81
SETBIT_0
#define SETBIT_0(flags, bit)
Definition: OdaDefs.h:500
OdGiLineweightOverrideHelper
Definition: GiLineweightOverride.h:164
OdGiLineweightOverride::m_lineCapStyle
OdPs::LineEndStyle m_lineCapStyle
Definition: GiLineweightOverride.h:51
OdGiLineweightOverride::kLwdOverrideStyle
@ kLwdOverrideStyle
Definition: GiLineweightOverride.h:46
OdGiLineweightOverride::hasStyleOverride
bool hasStyleOverride() const
Definition: GiLineweightOverride.h:102
OdGiLineweightOverride::m_uFlags
OdUInt32 m_uFlags
Definition: GiLineweightOverride.h:48
OdGiLineweightOverride::resetStyleOverride
void resetStyleOverride()
Definition: GiLineweightOverride.h:96
OdGiLineweightOverrideHelper::OdGiLineweightOverrideHelper
OdGiLineweightOverrideHelper()
Definition: GiLineweightOverride.h:168
TD_PackPush.h
OdGiSubEntityTraits
Definition: Gi.h:94
OdGiLineweightOverride::endStyleOverride
OdPs::LineEndStyle endStyleOverride() const
Definition: GiLineweightOverride.h:106
OdGiLineweightOverride::Flags
Flags
Definition: GiLineweightOverride.h:44
OdGiSubEntityTraits::pushLineweightOverride
virtual bool pushLineweightOverride(const OdGiLineweightOverride *pOverride)
OdPs::LineJoinStyle
LineJoinStyle
Definition: PlotStyles.h:78
OdGiLineweightOverride
Definition: GiLineweightOverride.h:41
OdGiLineweightOverride::m_lineJoinStyle
OdPs::LineJoinStyle m_lineJoinStyle
Definition: GiLineweightOverride.h:52
OdGiSubEntityTraits::popLineweightOverride
virtual void popLineweightOverride()
OdGiLineweightOverride::operator!=
bool operator!=(const OdGiLineweightOverride &lwdO2) const
Definition: GiLineweightOverride.h:136
OdGiLineweightOverride::hasScaleOverride
bool hasScaleOverride() const
Definition: GiLineweightOverride.h:72
OdGiLineweightOverride::kLwdOverrideScale
@ kLwdOverrideScale
Definition: GiLineweightOverride.h:45
OdPs::LineEndStyle
LineEndStyle
Definition: PlotStyles.h:69
OdPs::kLesRound
@ kLesRound
Definition: PlotStyles.h:72
OdGiLineweightOverride::setScaleOverride
void setScaleOverride(double dLwdScale)
Definition: GiLineweightOverride.h:62
OdGiLineweightOverride::OdGiLineweightOverride
OdGiLineweightOverride()
Definition: GiLineweightOverride.h:54
OdGiLineweightOverride::pixelScale
double pixelScale() const
Definition: GiLineweightOverride.h:85
OdGiLineweightOverride::operator==
bool operator==(const OdGiLineweightOverride &lwdO2) const
Definition: GiLineweightOverride.h:119
OdGiLineweightOverride::hasOverrides
bool hasOverrides() const
Definition: GiLineweightOverride.h:115
OdGiLineweightOverrideHelper::m_pTraits
OdGiSubEntityTraits * m_pTraits
Definition: GiLineweightOverride.h:166
OdGiLineweightOverride::m_dPixScale
double m_dPixScale
Definition: GiLineweightOverride.h:50
OdGiLineweightOverride::setStyleOverride
void setStyleOverride(OdPs::LineEndStyle lineCapStyle, OdPs::LineJoinStyle lineJoinStyle)
Definition: GiLineweightOverride.h:90
Gi.h