CFx SDK Documentation  2023 SP0
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_
#define ODGI_EXPORT
Definition: GiExport.h:35
#define NULL
Definition: GsProperties.h:177
unsigned int OdUInt32
bool OdEqual(double x, double y, double tol=1.e-10)
Definition: OdaDefs.h:525
#define SETBIT_0(flags, bit)
Definition: OdaDefs.h:502
#define GETBIT(flags, bit)
Definition: OdaDefs.h:500
#define SETBIT_1(flags, bit)
Definition: OdaDefs.h:503
void setLineweightOverride(OdGiSubEntityTraits &pTraits, const OdGiLineweightOverride &pOverride)
OdGiLineweightOverrideHelper(OdGiSubEntityTraits &pTraits, const OdGiLineweightOverride &pOverride)
virtual void popLineweightOverride()
virtual bool pushLineweightOverride(const OdGiLineweightOverride *pOverride)
LineJoinStyle
Definition: PlotStyles.h:78
@ kLjsRound
Definition: PlotStyles.h:81
LineEndStyle
Definition: PlotStyles.h:69
@ kLesRound
Definition: PlotStyles.h:72
OdPs::LineJoinStyle m_lineJoinStyle
OdPs::LineJoinStyle joinStyleOverride() const
bool operator==(const OdGiLineweightOverride &lwdO2) const
OdPs::LineEndStyle m_lineCapStyle
OdPs::LineEndStyle endStyleOverride() const
void setPixelScale(double dPixScale)
void setStyleOverride(OdPs::LineEndStyle lineCapStyle, OdPs::LineJoinStyle lineJoinStyle)
bool operator!=(const OdGiLineweightOverride &lwdO2) const
void setScaleOverride(double dLwdScale)