CFx SDK Documentation 2026 SP0
Loading...
Searching...
No Matches
TrVisBackgroundDef.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// Viewport background definition
24
25#ifndef ODTRVISBACKGROUNDDEF
26#define ODTRVISBACKGROUNDDEF
27
28#include "TrVisMetafileDef.h"
29
30#include "TD_PackPush.h"
31
36{
37 // Flags
38 enum Flags
39 {
40 // Enable background.
42 // Link background to camera.
44 // Background invoke materials.
46 // Camera angle override enabled.
47 kFOVOverride = (1 << 3)
48 };
49 // Background flags
51 // Background stream
53 // Background shading program
55 // Background rotation (camera backgrounds)
57 // Camera field of view (camera backgrounds)
59
60 void resetFlags(OdUInt16 nFlags = 0)
61 {
62 m_flags = nFlags;
63 }
65 {
66 resetFlags();
67 m_pStream = nullptr;
69 m_longRot = m_latRot = 0.0;
70 m_fovAngle = OdaToRadian(45.0);
71 m_bkgndRad = 0.0;
72 }
73
74 void enableBackground(bool bSet) { SETBIT(m_flags, kEnableBackground, bSet); }
76
79
82
83 void enableFOVOverride(bool bSet) { SETBIT(m_flags, kFOVOverride, bSet); }
84 bool isFOVOverridden() const { return GETBIT(m_flags, kFOVOverride); }
85
88 bool hasBackgroundStream() const { return !m_pStream.isNull(); }
89
92 bool hasBaseProgramId() const { return ::isValidTrVisId(m_baseProgramId); }
93
94 void setCameraRotationAngles(double longRot, double latRot) { m_longRot = longRot; m_latRot = latRot; }
95 void cameraRotationAngles(double &longRot, double &latRot) const { longRot = m_longRot; latRot = m_latRot; }
96 double longitudeRotationAngle() const { return m_longRot; }
97 double latitudeRotationAngle() const { return m_latRot; }
98
99 void setFOVOverrideAngle(double fovAngle) { m_fovAngle = fovAngle; }
100 double fovOverrideAngle() const { return m_fovAngle; }
101
102 void setBackgroundRadius(double bkgndRad) { m_bkgndRad = bkgndRad; }
103 double backgroundRadius() const { return m_bkgndRad; }
104
105 bool operator ==(const OdTrVisBackgroundDef &bkgnd) const
106 {
108 return false;
109 if (!isBackgroundEnabled())
110 return true;
112 (isShadedBackground() == bkgnd.isShadedBackground()) &&
113 (isFOVOverridden() == bkgnd.isFOVOverridden()) &&
114 (backgroundStream().get() == bkgnd.backgroundStream().get()) &&
115 (baseProgramId() == bkgnd.baseProgramId()) &&
120 }
121 bool operator !=(const OdTrVisBackgroundDef &bkgnd) const
122 {
124 return true;
125 if (!isBackgroundEnabled())
126 return false;
128 (isShadedBackground() != bkgnd.isShadedBackground()) ||
129 (isFOVOverridden() != bkgnd.isFOVOverridden()) ||
130 (backgroundStream().get() != bkgnd.backgroundStream().get()) ||
131 (baseProgramId() != bkgnd.baseProgramId()) ||
136 }
137
138 static bool compareNoStream(const OdTrVisBackgroundDef &bkgnd1, const OdTrVisBackgroundDef &bkgnd2)
139 { OdTrVisFlatMetafileContainerPtr pStream1 = bkgnd1.backgroundStream(), pStream2 = bkgnd2.backgroundStream();
140 const_cast<OdTrVisBackgroundDef&>(bkgnd1).setBackgroundStream(NULL); const_cast<OdTrVisBackgroundDef&>(bkgnd2).setBackgroundStream(NULL);
141 const bool bRVal = bkgnd1 == bkgnd2;
142 const_cast<OdTrVisBackgroundDef&>(bkgnd1).setBackgroundStream(pStream1); const_cast<OdTrVisBackgroundDef&>(bkgnd2).setBackgroundStream(pStream2);
143 return bRVal;
144 }
145};
146
147#include "TD_PackPop.h"
148
149#endif // ODTRVISBACKGROUNDDEF
unsigned short OdUInt16
#define OdaToRadian(deg)
Definition OdaCommon.h:68
bool OdEqual(double x, double y, double tol=1.e-10)
Definition OdaDefs.h:542
#define SETBIT(flags, bit, value)
Definition OdaDefs.h:516
#define GETBIT(flags, bit)
Definition OdaDefs.h:517
const OdTrVisId kTrVisNegativeId
Definition TrVisDefs.h:135
OdTrVisId OdTrVisProgramId
Definition TrVisDefs.h:112
OdSharedPtr< OdTrVisFlatMetafileContainer > OdTrVisFlatMetafileContainerPtr
void resetFlags(OdUInt16 nFlags=0)
void enableFOVOverride(bool bSet)
OdTrVisProgramId m_baseProgramId
bool hasBackgroundStream() const
bool isBackgroundLinkedToCamera() const
void setShadedBackground(bool bSet)
OdTrVisFlatMetafileContainerPtr m_pStream
double backgroundRadius() const
void setBackgroundRadius(double bkgndRad)
void setFOVOverrideAngle(double fovAngle)
void setCameraRotationAngles(double longRot, double latRot)
bool operator!=(const OdTrVisBackgroundDef &bkgnd) const
bool isShadedBackground() const
double fovOverrideAngle() const
double longitudeRotationAngle() const
void enableBackground(bool bSet)
static bool compareNoStream(const OdTrVisBackgroundDef &bkgnd1, const OdTrVisBackgroundDef &bkgnd2)
bool operator==(const OdTrVisBackgroundDef &bkgnd) const
OdTrVisFlatMetafileContainerPtr backgroundStream() const
void setBackgroundStream(const OdTrVisFlatMetafileContainerPtr pStream)
double latitudeRotationAngle() const
void linkBackgroundToCamera(bool bSet)
OdTrVisProgramId baseProgramId() const
void setBaseProgramId(OdTrVisProgramId baseProgramId)
void cameraRotationAngles(double &longRot, double &latRot) const
bool isBackgroundEnabled() const