CFx SDK Documentation  2020SP3
GiPalette.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 __ODGIPALETTE_H__
25 #define __ODGIPALETTE_H__
26 
27 #include "TD_PackPush.h"
28 
29 #include "GiExport.h"
30 #include "OdArray.h"
31 #include "SharedPtr.h"
32 
38 struct OdGiIntRGB
39 {
40  OdInt32 r, g, b;
41 
43  : r(_r), g(_g), b(_b)
44  { }
45  OdGiIntRGB() { }
47  {
48  setColor(cref);
49  }
50 
54  OdInt32 red() const { return r; }
58  OdInt32 green() const { return g; }
62  OdInt32 blue() const { return b; }
63 
68  void setRed(OdInt32 _r) { r = _r; }
73  void setGreen(OdInt32 _g) { g = _g; }
78  void setBlue(OdInt32 _b) { b = _b; }
85  void setRGB(OdInt32 _r, OdInt32 _g, OdInt32 _b) { r = _r; g = _g; b = _b; }
86 
91  void setColor(ODCOLORREF cref)
92  {
93  setRGB((OdInt32)ODGETRED(cref), (OdInt32)ODGETGREEN(cref), (OdInt32)ODGETBLUE(cref));
94  }
98  ODCOLORREF color() const
99  {
100  return ODRGB(r, g, b);
101  }
102 };
103 
110 {
111  protected:
118  public:
119  OdGiColorCube(OdGiIntRGB nGridDivs = OdGiIntRGB(2, 2, 2), float fIntensity = 1.0f, OdInt32 nBaseOffset = 0)
120  : m_nBaseOffset(nBaseOffset)
121  , m_nGridDivs(nGridDivs)
122  , m_fIntensity(fIntensity)
123  {
124  validate();
125  }
126 
130  OdInt32 baseOffset() const { return m_nBaseOffset; }
134  const OdGiIntRGB &gridDivisions() const { return m_nGridDivs; }
138  float intensity() const { return m_fIntensity; }
142  OdInt32 gridSize() const { return m_nGridSize; }
146  const OdGiIntRGB &offsets() const { return m_nOffsets; }
150  const OdGiIntRGB &dimensions() const { return m_nDims; }
151 
156  ODCOLORREF color(OdInt32 nColor) const;
157 
163 
165  {
166  OdInt32 m_fitColors[4];
167  OdInt32 m_pattern[4];
168  };
169 
178  protected:
179  void validate();
180 };
181 
188 {
189  protected:
194  public:
195  OdGiGrayRamp(OdInt32 nGridDivs = 2, float fIntensity = 1.0f, OdInt32 nBaseOffset = 0)
196  : m_nBaseOffset(nBaseOffset)
197  , m_nGridDivs(nGridDivs)
198  , m_fIntensity(fIntensity)
199  {
200  validate();
201  }
202 
206  OdInt32 baseOffset() const { return m_nBaseOffset; }
210  OdInt32 gridDivisions() const { return m_nGridDivs; }
214  float intensity() const { return m_fIntensity; }
218  OdInt32 dimension() const { return m_nDim; }
219 
224  ODCOLORREF color(OdInt32 nColor) const;
225 
231  protected:
232  void validate();
233 };
234 
241 {
242  protected:
243  struct PalEntry
244  {
247  };
249  protected:
253  public:
255  : m_palette(256, 1)
256  {
257  initPalette();
258  }
259 
264  ODCOLORREF color(OdUInt32 nColor) const
265  {
266  return m_palette[nColor].m_color;
267  }
273  {
274  return m_palette[nColor].m_entryHelper;
275  }
276 
282  void setColor(OdUInt32 nColor, ODCOLORREF color)
283  {
284  m_palette[nColor].m_color = color;
285  }
291  void setEntryHelper(OdUInt32 nColor, OdInt32 entryHelper)
292  {
293  m_palette[nColor].m_entryHelper = entryHelper;
294  }
295 
299  const OdGiColorCube *colorCube() const
300  {
301  return m_pColorCube.get();
302  }
306  void setColorCube(const OdGiColorCube &colorCube)
307  {
308  resetColorCube(new OdGiColorCube(colorCube));
309  }
314  {
315  resetColorCube(NULL);
316  }
317 
321  const OdGiGrayRamp *grayRamp() const
322  {
323  return m_pGrayRamp.get();
324  }
328  void setGrayRamp(const OdGiGrayRamp &grayRamp)
329  {
330  resetGrayRamp(new OdGiGrayRamp(grayRamp));
331  }
336  {
337  resetGrayRamp(NULL);
338  }
339 
344  bool install(const OdGiColorCube &cb);
349  bool install(const OdGiGrayRamp &gr);
354  bool install(const OdGiPalette &pal2);
355 
361  OdInt32 closestMatch(ODCOLORREF cref, bool bThroughPal = false) const;
362 
368 
373  bool isEqualTo(const OdGiPalette &pal2) const;
378  bool remove(const OdGiPalette &pal2);
379 
383  void clear();
384  protected:
385  void initPalette();
386 
387  void resetColorCube(OdGiColorCube *pColorCube);
388  void resetGrayRamp(OdGiGrayRamp *pGrayRamp);
389 
390  void setColor(OdInt32 nColor, ODCOLORREF color);
391 };
392 
393 #include "TD_PackPop.h"
394 
395 #endif //#ifndef __ODGIPALETTE_H__
OdGiColorCube::baseOffset
OdInt32 baseOffset() const
Definition: GiPalette.h:130
OdGiIntRGB::setRGB
void setRGB(OdInt32 _r, OdInt32 _g, OdInt32 _b)
Definition: GiPalette.h:85
NULL
#define NULL
Definition: GsProperties.h:177
OdGiColorCube::dimensions
const OdGiIntRGB & dimensions() const
Definition: GiPalette.h:150
OdGiColorCube::m_nGridSize
OdInt32 m_nGridSize
Definition: GiPalette.h:115
OdGiGrayRamp::gridDivisions
OdInt32 gridDivisions() const
Definition: GiPalette.h:210
OdGiPalette::entryHelper
OdInt32 entryHelper(OdUInt32 nColor) const
Definition: GiPalette.h:272
OdGiColorCube::gridDivisions
const OdGiIntRGB & gridDivisions() const
Definition: GiPalette.h:134
OdGiIntRGB::red
OdInt32 red() const
Definition: GiPalette.h:54
OdGiPalette::PalEntry::m_color
ODCOLORREF m_color
Definition: GiPalette.h:245
OdGiColorCube::ditheredMatch
OdInt32 ditheredMatch(ODCOLORREF cref, DtMatchResult &results) const
OdGiPalette::setGrayRamp
void setGrayRamp(const OdGiGrayRamp &grayRamp)
Definition: GiPalette.h:328
OdGiIntRGB::r
OdInt32 r
Definition: GiPalette.h:40
OdGiColorCube::m_nDims
OdGiIntRGB m_nDims
Definition: GiPalette.h:117
OdSharedPtr< OdGiColorCube >
OdGiGrayRamp::validate
void validate()
OdGiPalette::PalEntry
Definition: GiPalette.h:244
ODGETBLUE
#define ODGETBLUE(rgb)
Definition: OdPlatform.h:889
OdGiGrayRamp::dimension
OdInt32 dimension() const
Definition: GiPalette.h:218
OdArray
Definition: OdArray.h:591
OdGiPalette::initPalette
void initPalette()
TD_PackPop.h
OdGiPalette::resetColorCube
void resetColorCube(OdGiColorCube *pColorCube)
OdGiGrayRamp::baseOffset
OdInt32 baseOffset() const
Definition: GiPalette.h:206
OdGiIntRGB::OdGiIntRGB
OdGiIntRGB(ODCOLORREF cref)
Definition: GiPalette.h:46
ODRGB
#define ODRGB(r, g, b)
Definition: OdPlatform.h:884
OdUInt32
unsigned int OdUInt32
Definition: OdPlatformSettings.h:783
ODGI_EXPORT
#define ODGI_EXPORT
Definition: GiExport.h:35
OdGiPalette::firstAvailableBlock
OdInt32 firstAvailableBlock(OdInt32 blockSize) const
OdGiPalette::isEqualTo
bool isEqualTo(const OdGiPalette &pal2) const
OdGiColorCube::gridSize
OdInt32 gridSize() const
Definition: GiPalette.h:142
OdGiIntRGB::setRed
void setRed(OdInt32 _r)
Definition: GiPalette.h:68
OdGiPalette::OdGiPalette
OdGiPalette()
Definition: GiPalette.h:254
OdGiIntRGB::OdGiIntRGB
OdGiIntRGB()
Definition: GiPalette.h:45
ODGETRED
#define ODGETRED(rgb)
Definition: OdPlatform.h:887
OdGiPalette
Definition: GiPalette.h:241
OdGiPalette::PalEntry::m_entryHelper
OdInt32 m_entryHelper
Definition: GiPalette.h:246
OdGiColorCube::intensity
float intensity() const
Definition: GiPalette.h:138
OdGiGrayRamp::m_nDim
OdInt32 m_nDim
Definition: GiPalette.h:193
OdGiIntRGB::setGreen
void setGreen(OdInt32 _g)
Definition: GiPalette.h:73
OdArray.h
OdGiPalette::install
bool install(const OdGiGrayRamp &gr)
OdInt32
int OdInt32
Definition: OdPlatformSettings.h:782
OdGiColorCube::OdGiColorCube
OdGiColorCube(OdGiIntRGB nGridDivs=OdGiIntRGB(2, 2, 2), float fIntensity=1.0f, OdInt32 nBaseOffset=0)
Definition: GiPalette.h:119
OdGiGrayRamp::m_nBaseOffset
OdInt32 m_nBaseOffset
Definition: GiPalette.h:190
ODGETGREEN
#define ODGETGREEN(rgb)
Definition: OdPlatform.h:888
OdGiIntRGB
Definition: GiPalette.h:39
OdGiGrayRamp::m_nGridDivs
OdInt32 m_nGridDivs
Definition: GiPalette.h:191
OdGiPalette::resetColorCube
void resetColorCube()
Definition: GiPalette.h:313
OdGiColorCube
Definition: GiPalette.h:110
OdGiIntRGB::blue
OdInt32 blue() const
Definition: GiPalette.h:62
SharedPtr.h
OdGiPalette::install
bool install(const OdGiColorCube &cb)
OdGiPalette::setEntryHelper
void setEntryHelper(OdUInt32 nColor, OdInt32 entryHelper)
Definition: GiPalette.h:291
TD_PackPush.h
OdGiColorCube::closestMatch
OdInt32 closestMatch(ODCOLORREF cref) const
OdGiColorCube::DtMatchResult
Definition: GiPalette.h:165
OdGiIntRGB::g
OdInt32 g
Definition: GiPalette.h:40
OdGiGrayRamp::closestMatch
OdInt32 closestMatch(ODCOLORREF cref) const
OdGiColorCube::color
ODCOLORREF color(OdInt32 nColor) const
OdGiColorCube::validate
void validate()
OdGiGrayRamp
Definition: GiPalette.h:188
OdGiIntRGB::green
OdInt32 green() const
Definition: GiPalette.h:58
OdGiColorCube::m_nGridDivs
OdGiIntRGB m_nGridDivs
Definition: GiPalette.h:113
OdGiColorCube::m_nOffsets
OdGiIntRGB m_nOffsets
Definition: GiPalette.h:116
GiExport.h
OdGiPalette::PalEntryArray
OdArray< PalEntry, OdMemoryAllocator< PalEntry > > PalEntryArray
Definition: GiPalette.h:248
OdGiPalette::color
ODCOLORREF color(OdUInt32 nColor) const
Definition: GiPalette.h:264
OdGiGrayRamp::m_fIntensity
float m_fIntensity
Definition: GiPalette.h:192
OdGiIntRGB::setColor
void setColor(ODCOLORREF cref)
Definition: GiPalette.h:91
OdGiPalette::m_palette
PalEntryArray m_palette
Definition: GiPalette.h:250
OdGiPalette::setColor
void setColor(OdUInt32 nColor, ODCOLORREF color)
Definition: GiPalette.h:282
OdGiPalette::colorCube
const OdGiColorCube * colorCube() const
Definition: GiPalette.h:299
OdGiIntRGB::OdGiIntRGB
OdGiIntRGB(OdInt32 _r, OdInt32 _g, OdInt32 _b)
Definition: GiPalette.h:42
f
GLfloat f
Definition: gles2_ext.h:564
OdGiPalette::resetGrayRamp
void resetGrayRamp()
Definition: GiPalette.h:335
OdGiPalette::closestMatch
OdInt32 closestMatch(ODCOLORREF cref, bool bThroughPal=false) const
ODCOLORREF
#define ODCOLORREF
Definition: OdPlatform.h:883
OdGiPalette::m_pColorCube
OdSharedPtr< OdGiColorCube > m_pColorCube
Definition: GiPalette.h:251
OdGiPalette::setColor
void setColor(OdInt32 nColor, ODCOLORREF color)
OdGiPalette::setColorCube
void setColorCube(const OdGiColorCube &colorCube)
Definition: GiPalette.h:306
OdGiIntRGB::b
OdInt32 b
Definition: GiPalette.h:40
OdGiIntRGB::setBlue
void setBlue(OdInt32 _b)
Definition: GiPalette.h:78
OdGiColorCube::m_nBaseOffset
OdInt32 m_nBaseOffset
Definition: GiPalette.h:112
OdGiPalette::resetGrayRamp
void resetGrayRamp(OdGiGrayRamp *pGrayRamp)
OdGiIntRGB::color
ODCOLORREF color() const
Definition: GiPalette.h:98
OdSharedPtr::get
T * get()
Definition: SharedPtr.h:134
OdGiGrayRamp::OdGiGrayRamp
OdGiGrayRamp(OdInt32 nGridDivs=2, float fIntensity=1.0f, OdInt32 nBaseOffset=0)
Definition: GiPalette.h:195
OdGiColorCube::offsets
const OdGiIntRGB & offsets() const
Definition: GiPalette.h:146
OdGiGrayRamp::color
ODCOLORREF color(OdInt32 nColor) const
OdGiColorCube::m_fIntensity
float m_fIntensity
Definition: GiPalette.h:114
OdGiPalette::grayRamp
const OdGiGrayRamp * grayRamp() const
Definition: GiPalette.h:321
OdGiPalette::install
bool install(const OdGiPalette &pal2)
OdGiPalette::m_pGrayRamp
OdSharedPtr< OdGiGrayRamp > m_pGrayRamp
Definition: GiPalette.h:252
OdGiPalette::remove
bool remove(const OdGiPalette &pal2)
OdGiPalette::clear
void clear()
OdGiGrayRamp::intensity
float intensity() const
Definition: GiPalette.h:214