CFx SDK Documentation 2026 SP0
Loading...
Searching...
No Matches
GiSelectionStyle.h
Go to the documentation of this file.
1
2// Copyright (C) 2002-2024, 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 Open Design Alliance software pursuant to a license
16// agreement with Open Design Alliance.
17// Open Design Alliance Copyright (C) 2002-2024 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 __ODGISELECTIONSTYLE_H__
25#define __ODGISELECTIONSTYLE_H__
26
27#include "TD_PackPush.h"
28
29#include "Gi/Gi.h"
30
37{
38 public:
43 {
44 protected:
47 public:
52
61 const OdCmEntityColor &color() const { return m_color; }
62
73 OdUInt8 transparency() const { return isVisible() ? OdUInt8(m_transparency) : 255; }
74
81
87 bool isVisible() const { return m_transparency < 255; }
93 bool isOpaque() const { return !m_transparency; }
94
99
109 bool operator ==(const ColorMask &cm2) const
110 { return (transparency() == cm2.transparency()) && (!isVisible() || color() == cm2.color()); }
111
121 bool operator !=(const ColorMask &cm2) const
122 { return (transparency() != cm2.transparency()) || (isVisible() && color() != cm2.color()); }
123 };
124
128 {
129 protected:
131 {
132 kDrawElement = (1 << 0), // Enable displaying of edges/faces
133 kPatternElement = (1 << 1), // Apply classic highlighting pattern for edges/faces
134 kMaskElement = (1 << 2), // Apply color mask effect to edges/faces
135 // Global element flags
136 kGOnTopOfDepth = (1 << 3), // Display element on top of depth buffer
137 kGlobalFlags = kGOnTopOfDepth, // List of global flags
138 //
140 };
142 ColorMask m_colorMask; // Color mask effect properties
143 public:
148
153 void setVisible(bool bVisible) { SETBIT(m_nFlags, kDrawElement, bVisible); }
159 bool isVisible() const { return GETBIT(m_nFlags, kDrawElement); }
160
165 void enablePattern(bool bEnable) { SETBIT(m_nFlags, kPatternElement, bEnable); }
172
177 void enableColorMasking(bool bEnable) { SETBIT(m_nFlags, kMaskElement, bEnable); }
184
190 const ColorMask &colorMask() const { return m_colorMask; }
197
203 bool isOnTopOfDepth() const { return GETBIT(m_nFlags, kGOnTopOfDepth); }
204
211 bool hasEffect() const { return isPatternEnabled() || (isColorMaskingEnabled() && colorMask().isVisible()); }
212
220 void setAsDisabled() { m_nFlags = 0; m_colorMask.reset(); }
229
239 bool operator ==(const ElementStyle &secStyle) const
240 { return ((m_nFlags & ~kGlobalFlags) == (secStyle.m_nFlags & ~kGlobalFlags)) && (m_colorMask == secStyle.m_colorMask); }
241
251 bool operator !=(const ElementStyle &secStyle) const
252 { return ((m_nFlags & ~kGlobalFlags) != (secStyle.m_nFlags & ~kGlobalFlags)) || (m_colorMask != secStyle.m_colorMask); }
253 };
254
261 class EdgeStyle : public ElementStyle
262 {
263 public:
267 enum Mode
268 {
269 kExistEdges, // Draw existing edges if they are enabled.
270 kIsolineEdges, // Draw isolines for 3d objects and existing edges for others.
271 kContourEdges // Draw contours for 3d objects and existing edges for others.
272 };
273 protected:
275 {
276 kDrawIsolines = (kLastElementStyleFlag << 1), // Draw isolines for 3d objects
277 kDrawContours = (kLastElementStyleFlag << 2) // Draw contours for 3d objects
278 };
279 OdInt32 m_lineWeightExtension; // Number of pixels for lineweight enlargement
280 public:
285
290 void setMode(Mode edgeMode)
291 { switch (edgeMode) {
295 }
296 }
297
305 Mode mode() const
308 return kExistEdges;
309 }
310
315 void setLineWeightExtension(OdInt32 nLwdExtension) { m_lineWeightExtension = nLwdExtension; }
328 bool hasLineWeightExtension() const { return m_lineWeightExtension != 0; }
329
337
356
366 bool operator ==(const EdgeStyle &secStyle) const
367 { return ElementStyle::operator ==(secStyle) && (m_lineWeightExtension == secStyle.m_lineWeightExtension); }
368
378 bool operator !=(const EdgeStyle &secStyle) const
379 { return ElementStyle::operator !=(secStyle) || (m_lineWeightExtension != secStyle.m_lineWeightExtension); }
380 };
381
385 {
386 protected:
389 public:
401 const EdgeStyle &edgeStyle() const { return m_edgeStyle; }
402
414 const FaceStyle &faceStyle() const { return m_faceStyle; }
415
421 bool isOnTopOfDepth() const
422 { return m_edgeStyle.isOnTopOfDepth() && m_faceStyle.isOnTopOfDepth(); }
423
429 bool isVisible() const { return m_edgeStyle.isVisible() || m_faceStyle.isVisible(); }
436 bool hasEffect() const { return m_edgeStyle.hasEffect() || m_faceStyle.hasEffect(); }
437
441 void setByDefault() { m_edgeStyle.setByDefault(); m_faceStyle.setByDefault(); }
445 void setAsDisabled() { m_edgeStyle.setAsDisabled(); m_faceStyle.setAsDisabled(); }
449 void setForStippling() { m_edgeStyle.setForStippling(); m_faceStyle.setForStippling(); }
454 void setForColorMasking() { m_edgeStyle.setForColorMasking(); m_faceStyle.setForColorMasking(); }
455
461 void setForColorMasking(const OdCmEntityColor &color, OdUInt8 transparency)
462 { setByDefault();
463 m_edgeStyle.enableColorMasking(true); m_edgeStyle.colorMask().setColor(color, transparency);
464 m_faceStyle.enableColorMasking(true); m_faceStyle.colorMask().setColor(color, transparency); }
465
475 bool operator ==(const StyleEntry &secStyle) const
476 { return (m_edgeStyle == secStyle.m_edgeStyle) && (m_faceStyle == secStyle.m_faceStyle); }
477
487 bool operator !=(const StyleEntry &secStyle) const
488 { return (m_edgeStyle != secStyle.m_edgeStyle) || (m_faceStyle != secStyle.m_faceStyle); }
489 };
490 protected:
492 protected:
494 {
495 static OdUInt32 getIntFlags(const ElementStyle &elemStyle)
496 { return static_cast<const GIntAccessor &>(elemStyle).m_nFlags; }
498 { GIntAccessor &gStyle = static_cast<GIntAccessor &>(elemStyle);
499 const OdUInt32 flags = gStyle.m_nFlags & kGlobalFlags; gStyle.m_nFlags &= ~kGlobalFlags;
500 return flags; }
501 static void installIntFlags(ElementStyle &elemStyle, OdUInt32 flags)
502 { GIntAccessor &gStyle = static_cast<GIntAccessor &>(elemStyle);
503 gStyle.m_nFlags = (gStyle.m_nFlags & ~kGlobalFlags) | flags; }
504 static bool isOnTopOfDepth(OdUInt32 flags) { return GETBIT(flags, kGOnTopOfDepth); }
505 static void setOnTopOfDepth(OdUInt32 &flags, bool bSet) { SETBIT(flags, kGOnTopOfDepth, bSet); }
506 };
507 class WrapGIntFlags { StyleEntry *m_pStyle; OdUInt32 m_flags[2];
508 public: WrapGIntFlags(StyleEntry &style, bool bWrap = true) : m_pStyle(bWrap ? &style : NULL)
509 { if (m_pStyle) { m_flags[0] = GIntAccessor::extractIntFlags(style.edgeStyle());
510 m_flags[1] = GIntAccessor::extractIntFlags(style.faceStyle()); }
511 else { m_flags[0] = m_flags[1] = 0; }
512 }
513 ~WrapGIntFlags() { if (m_pStyle) { GIntAccessor::installIntFlags(m_pStyle->edgeStyle(), m_flags[0]);
514 GIntAccessor::installIntFlags(m_pStyle->faceStyle(), m_flags[1]); } }
515 };
516 int makeEntryId(bool bDrawOnTop, bool bDrawIn3d) const { return ((bDrawOnTop) ? 1 : 0) | ((bDrawIn3d) ? 2 : 0); }
517 public:
522
530 StyleEntry &styleFor(bool bDrawOnTop = false, bool bDrawIn3d = false)
531 { return m_styleEntry[makeEntryId(bDrawOnTop, bDrawIn3d)]; }
532
539 const StyleEntry &styleFor(bool bDrawOnTop = false, bool bDrawIn3d = false) const
540 { return m_styleEntry[makeEntryId(bDrawOnTop, bDrawIn3d)]; }
541
545 void sync3d() { WrapGIntFlags _wint(styleFor(true, true));
546 styleFor(false, true) = styleFor(false, false); styleFor(true, true) = styleFor(true, false); }
547
550 void sync2d() { WrapGIntFlags _wint(styleFor(true, true));
551 styleFor(false, false) = styleFor(false, true); styleFor(true, false) = styleFor(true, true); }
552
558 void exchangeTopBottom(bool bFor2d = true, bool bFor3d = true)
559 { StyleEntry tmpEntry; WrapGIntFlags _wint(styleFor(true, true), bFor3d);
560 if (bFor2d) { tmpEntry = styleFor(false, false); styleFor(false, false) = styleFor(true, false); styleFor(true, false) = tmpEntry; }
561 if (bFor3d) { tmpEntry = styleFor(false, true); styleFor(false, true) = styleFor(true, true); styleFor(true, true) = tmpEntry; }
562 }
563
572
577 bool isOnTopOfDepth() const { return styleFor(true, true).isOnTopOfDepth(); }
578
582 void setByDefault() { styleFor(false).setByDefault(); styleFor(true).setAsDisabled(); sync3d(); }
586 void setAsDisabled() { styleFor(false).setAsDisabled(); styleFor(true).setAsDisabled(); sync3d(); }
591 void setForStippling() { styleFor(false).setForStippling(); styleFor(true).setAsDisabled(); sync3d(); }
596 void setForColorMasking() { styleFor(false).setByDefault(); styleFor(false).edgeStyle().setMode(EdgeStyle::kIsolineEdges);
597 styleFor(true).setForColorMasking(); sync3d(); }
598};
599
600#include "TD_PackPop.h"
601
602#endif //__ODGISELECTIONSTYLE_H__
bool operator!=(T left, const OdGiVariant::EnumType right)
Definition GiVariant.h:405
bool operator==(T left, const OdGiVariant::EnumType right)
Definition GiVariant.h:399
unsigned int OdUInt32
int OdInt32
unsigned char OdUInt8
#define SETBIT(flags, bit, value)
Definition OdaDefs.h:516
#define SETBIT_0(flags, bit)
Definition OdaDefs.h:519
#define GETBIT(flags, bit)
Definition OdaDefs.h:517
#define SETBIT_1(flags, bit)
Definition OdaDefs.h:520
#define FIRSTDLL_EXPORT
Definition RootExport.h:39
const OdCmEntityColor & color() const
void setTransparency(OdUInt8 transparency)
void setColor(const OdCmEntityColor &color)
void setColor(const OdCmEntityColor &color, OdUInt8 transparency)
void setLineWeightExtension(OdInt32 nLwdExtension)
const ColorMask & colorMask() const
bool isVisible() const
EdgeStyle m_edgeStyle
bool hasEffect() const
FaceStyle & faceStyle()
void setAsDisabled()
void setForStippling()
EdgeStyle & edgeStyle()
const FaceStyle & faceStyle() const
bool isOnTopOfDepth() const
void setByDefault()
const EdgeStyle & edgeStyle() const
FaceStyle m_faceStyle
void setForColorMasking()
void setForColorMasking(const OdCmEntityColor &color, OdUInt8 transparency)
WrapGIntFlags(StyleEntry &style, bool bWrap=true)
void setOnTopOfDepth(bool bSet)
StyleEntry m_styleEntry[4]
bool isOnTopOfDepth() const
int makeEntryId(bool bDrawOnTop, bool bDrawIn3d) const
void exchangeTopBottom(bool bFor2d=true, bool bFor3d=true)
const StyleEntry & styleFor(bool bDrawOnTop=false, bool bDrawIn3d=false) const
StyleEntry & styleFor(bool bDrawOnTop=false, bool bDrawIn3d=false)
static void installIntFlags(ElementStyle &elemStyle, OdUInt32 flags)
static void setOnTopOfDepth(OdUInt32 &flags, bool bSet)
static OdUInt32 getIntFlags(const ElementStyle &elemStyle)
static OdUInt32 extractIntFlags(ElementStyle &elemStyle)
static bool isOnTopOfDepth(OdUInt32 flags)