CFx SDK Documentation 2026 SP0
Loading...
Searching...
No Matches
TrVisDisplayCodeProc.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// GLES2 device special display codes processing helpers
24
25#ifndef ODTRVISDISPLAYCODEPROC
26#define ODTRVISDISPLAYCODEPROC
27
28#include "TD_PackPush.h"
29
30#include "TrVisRendition.h"
31
36{
37 public:
38 template <typename TArray>
39 static void pushZero(TArray &arry)
40 {
42 }
43 // Highlighting
44 template <typename TArray>
45 static void pushHighlight(TArray &arry)
46 {
48 }
49 template <typename TArray>
50 static void pushUnhighlight(TArray &arry)
51 {
53 }
54 template <typename TArray>
55 static void pushHighlight(TArray &arry, bool bHighlight)
56 {
58 }
59 // Transform
60 template <typename TArray>
61 static void pushPushMatrix(TArray &arry, const OdGeMatrix3d &mtx)
62 { typedef OD_TYPENAME TArray::value_type ValType;
64 const ValType *pMtxRepresentation = reinterpret_cast<const ValType*>(mtx.entry);
65 arry.insert(arry.end(), pMtxRepresentation, pMtxRepresentation + (sizeof(OdGeMatrix3d) / sizeof(ValType)));
66 }
67 template <typename TArray>
68 static void pushPopMatrix(TArray &arry)
69 {
71 }
72 // Fading
73 template <typename TArray>
74 static void pushFade(TArray &arry, long nFadeSlot)
75 { typedef OD_TYPENAME TArray::value_type ValType;
77 arry.push_back((ValType)(OdIntPtr)nFadeSlot);
78 }
79 template <typename TArray>
80 static void pushUnfade(TArray &arry, long nFadeSlot)
81 { typedef OD_TYPENAME TArray::value_type ValType;
83 arry.push_back((ValType)(OdIntPtr)nFadeSlot);
84 }
85 template <typename TArray>
86 static void pushFade(TArray &arry, long nFadeSlot, bool bFade)
87 {
88 if (bFade) pushFade<TArray>(arry, nFadeSlot);
89 else pushUnfade<TArray>(arry, nFadeSlot);
90 }
91 // Markers
92 template <typename TArray>
93 static void pushMarkers(TArray &arry, OdTrVisStateBranchPtr pBranch, OdTrVisStateBranchType sbType)
94 { typedef OD_TYPENAME TArray::value_type ValType;
95 arry.push_back(OdTrVisRendition::kDisplayCodeHlMarkers + sbType);
96 arry.push_back((ValType)(OdIntPtr)pBranch);
97 }
98 template <typename TArray>
99 static void pushHlMarkers(TArray &arry, OdTrVisStateBranchPtr pHlBranch)
100 { pushMarkers<TArray>(arry, pHlBranch, kTrVisHighlightingBranch); }
101 template <typename TArray>
102 static void pushVsMarkers( TArray &arry, OdTrVisStateBranchPtr pVsBranch )
103 { pushMarkers<TArray>(arry, pVsBranch, kTrVisVisibilityBranch); }
104 template <typename TArray>
105 static void pushTfMarkers(TArray &arry, OdTrVisStateBranchPtr pTfBranch)
106 { pushMarkers<TArray>(arry, pTfBranch, kTrVisTransformBranch); }
107 // Drawing order
108 template <typename TArray>
109 static void pushDrawOrder(TArray &arry, double drawOrder)
110 { typedef OD_TYPENAME TArray::value_type ValType;
112 arry.push_back(*reinterpret_cast<ValType*>(&drawOrder));
113 }
114 template <typename TArray>
119 // Drawing order interval
120 template <typename TArray>
121 static void pushDepthIval(TArray &arry, const OdTrVisIvald &ival)
122 { typedef OD_TYPENAME TArray::value_type ValType;
124 arry.push_back(*reinterpret_cast<const ValType*>(&ival.m_minBound));
125 arry.push_back(*reinterpret_cast<const ValType*>(&ival.m_maxBound));
126 }
127 // Exploded unions
128 template <typename TArray>
129 static void pushExploded(TArray &arry)
130 {
132 }
133 template <typename TArray>
134 static void pushNonExploded(TArray &arry)
135 {
137 }
138 template <typename TArray>
139 static void pushExploded(TArray &arry, bool bExploded)
140 {
142 }
143 // Selection style
144 template <typename TArray>
145 static void pushSelStyle(TArray& arry, OdUInt32 nSelStyle)
146 { typedef OD_TYPENAME TArray::value_type ValType;
148 arry.push_back((ValType)(OdIntPtr)nSelStyle);
149 }
150
155 template <typename TArray>
156 static void pushSelectionID(TArray &arry, const void *pID)
157 { typedef OD_TYPENAME TArray::value_type ValType;
159 arry.push_back((ValType)(OdIntPtr)pID);
160 }
161};
162
167{
168 public:
169 template <typename TObj>
170 static bool isEqual(const TObj &obj1, const TObj &obj2)
171 {
172 return !::memcmp(&obj1, &obj2, sizeof(TObj));
173 }
174 static bool isIdentity(const OdGeMatrix3d &mtx)
175 {
176 return isEqual(mtx, OdGeMatrix3d::kIdentity);
177 }
178};
179
184{
185 OdTrVisDisplayId *m_pList;
186 OdUInt32 m_nListData, m_nCaret;
187 public:
189 : m_pList(const_cast<OdTrVisDisplayId*>(pList)), m_nListData(nData), m_nCaret(0)
190 {
191 }
192 bool isEOF() const { return m_nCaret >= m_nListData; }
193 bool isCode() const { return m_pList[m_nCaret] < OdTrVisRendition::kDisplayCodeRange; }
204 void skipCode() { m_nCaret += skipCodeSize(code()); }
205 OdTrVisDisplayId &cur() { return m_pList[m_nCaret]; }
206 const OdTrVisDisplayId &cur() const { return m_pList[m_nCaret]; }
207 OdTrVisDisplayId &next(OdUInt32 n = 1) { return m_pList[m_nCaret + n]; }
208 const OdTrVisDisplayId &next(OdUInt32 n = 1) const { return m_pList[m_nCaret + n]; }
209 bool step() { if (isCode()) skipCode(); else m_nCaret++; return isEOF(); }
210 // Access extensions
211 const double *codeAsDoublePtr(OdUInt32 n = 1) const { return reinterpret_cast<const double*>(m_pList + (m_nCaret + n)); }
212 const OdGeMatrix3d *codeAsMatrixPtr(OdUInt32 n = 1) const { return reinterpret_cast<const OdGeMatrix3d*>(m_pList + (m_nCaret + n)); }
213 const OdTrVisId *codeAsIdPtr(OdUInt32 n = 1) const { return reinterpret_cast<const OdTrVisId*>(m_pList + (m_nCaret + n)); }
214 const void *codeAsPtr(OdUInt32 n = 1) const { return OdTrVisIdToPtr(const void, m_pList[m_nCaret + n]); }
215 // Debug extensions
216 static void dumpDisplayList(const OdTrVisDisplayId *pList, OdUInt32 nData, void (*pDumpFunc)(const OdString &));
217 //void traceDumpFunc(const OdString &str) { ODA_TRACE(str.c_str()); } // Example dump function
218};
219
220inline void OdTrVisDisplayListIterator::dumpDisplayList(const OdTrVisDisplayId *pList, OdUInt32 nData, void (*pDumpFunc)(const OdString &))
221{ OdTrVisDisplayListIterator it(pList, nData);
222 while (!it.isEOF())
223 {
224 if (it.isCode())
225 {
226 switch (it.code())
227 {
229 pDumpFunc(L"Code Highlight: 1\n");
230 break;
232 pDumpFunc(L"Code UnHighlight: 0\n");
233 break;
235 pDumpFunc(OdString().format(L"Code PushMatrix: { %f, %f, %f, %f }, { %f, %f, %f, %f }, { %f, %f, %f, %f }, { %f, %f, %f, %f }\n",
236 it.codeAsMatrixPtr()->entry[0][0], it.codeAsMatrixPtr()->entry[0][1], it.codeAsMatrixPtr()->entry[0][2], it.codeAsMatrixPtr()->entry[0][3],
237 it.codeAsMatrixPtr()->entry[1][0], it.codeAsMatrixPtr()->entry[1][1], it.codeAsMatrixPtr()->entry[1][2], it.codeAsMatrixPtr()->entry[1][3],
238 it.codeAsMatrixPtr()->entry[2][0], it.codeAsMatrixPtr()->entry[2][1], it.codeAsMatrixPtr()->entry[2][2], it.codeAsMatrixPtr()->entry[2][3],
239 it.codeAsMatrixPtr()->entry[3][0], it.codeAsMatrixPtr()->entry[3][1], it.codeAsMatrixPtr()->entry[3][2], it.codeAsMatrixPtr()->entry[3][3]));
240 break;
242 pDumpFunc(L"Code PopMatrix\n");
243 break;
245 pDumpFunc(OdString().format(L"Code Fade: %u\n", (unsigned)it.next()));
246 break;
248 pDumpFunc(OdString().format(L"Code UnFade: %u\n", (unsigned)it.next()));
249 break;
251 pDumpFunc(OdString().format(L"Code HlMarker: %" PRIu64W L"\n", *it.codeAsIdPtr()));
252 break;
254 pDumpFunc(OdString().format(L"Code VsMarker: %" PRIu64W L"\n", *it.codeAsIdPtr()));
255 break;
257 pDumpFunc(OdString().format(L"Code DrawOrder: %f\n", *it.codeAsDoublePtr()));
258 break;
260 pDumpFunc(OdString().format(L"Code Depth: { %f, %f }\n", it.codeAsDoublePtr()[0], it.codeAsDoublePtr()[1]));
261 break;
263 pDumpFunc(L"Code Exploded: 1\n");
264 break;
266 pDumpFunc(L"Code NonExploded: 0\n");
267 break;
269 pDumpFunc(OdString().format(L"Code SelStyle: %u\n", (unsigned)it.next()));
270 break;
271 }
272 }
273 else
274 {
275 pDumpFunc(OdString().format(L"Metafile: %" PRIu64W L"\n", it.cur()));
276 }
277 it.step();
278 }
279}
280
281#include "TD_PackPop.h"
282
283#endif // ODTRVISDISPLAYCODEPROC
#define OD_TYPENAME
unsigned int OdUInt32
ptrdiff_t OdIntPtr
OdString OdString
Definition OdString.h:1258
const void * OdTrVisStateBranchPtr
Definition TrVisDefs.h:170
OdTrVisStateBranchType
Definition TrVisDefs.h:162
@ kTrVisTransformBranch
Definition TrVisDefs.h:165
@ kTrVisVisibilityBranch
Definition TrVisDefs.h:164
@ kTrVisHighlightingBranch
Definition TrVisDefs.h:163
OdTrVisId OdTrVisDisplayId
Definition TrVisDefs.h:114
#define OdTrVisIdToPtr(ptrType, id)
Definition TrVisDefs.h:133
OdUInt64 OdTrVisId
Definition TrVisDefs.h:101
OdTrVisIvalImpl< double > OdTrVisIvald
Definition TrVisIval.h:175
static GE_STATIC_EXPORT const OdGeMatrix3d kIdentity
Definition GeMatrix3d.h:97
double entry[4][4]
Definition GeMatrix3d.h:852
static void pushMultiOrder(TArray &arry)
static void pushHighlight(TArray &arry, bool bHighlight)
static void pushDrawOrder(TArray &arry, double drawOrder)
static void pushSelStyle(TArray &arry, OdUInt32 nSelStyle)
static void pushFade(TArray &arry, long nFadeSlot)
static void pushVsMarkers(TArray &arry, OdTrVisStateBranchPtr pVsBranch)
static void pushUnfade(TArray &arry, long nFadeSlot)
static void pushMarkers(TArray &arry, OdTrVisStateBranchPtr pBranch, OdTrVisStateBranchType sbType)
static void pushDepthIval(TArray &arry, const OdTrVisIvald &ival)
static void pushPopMatrix(TArray &arry)
static void pushExploded(TArray &arry, bool bExploded)
static void pushFade(TArray &arry, long nFadeSlot, bool bFade)
static void pushExploded(TArray &arry)
static void pushNonExploded(TArray &arry)
static void pushPushMatrix(TArray &arry, const OdGeMatrix3d &mtx)
static void pushTfMarkers(TArray &arry, OdTrVisStateBranchPtr pTfBranch)
static void pushUnhighlight(TArray &arry)
static void pushHlMarkers(TArray &arry, OdTrVisStateBranchPtr pHlBranch)
static void pushHighlight(TArray &arry)
static void pushSelectionID(TArray &arry, const void *pID)
static void pushZero(TArray &arry)
const OdTrVisDisplayId & next(OdUInt32 n=1) const
const void * codeAsPtr(OdUInt32 n=1) const
const OdTrVisId * codeAsIdPtr(OdUInt32 n=1) const
static void dumpDisplayList(const OdTrVisDisplayId *pList, OdUInt32 nData, void(*pDumpFunc)(const OdString &))
const double * codeAsDoublePtr(OdUInt32 n=1) const
OdTrVisRendition::DisplayIdCodes code() const
OdTrVisDisplayListIterator(const OdTrVisDisplayId *pList, OdUInt32 nData)
const OdGeMatrix3d * codeAsMatrixPtr(OdUInt32 n=1) const
OdTrVisDisplayId & next(OdUInt32 n=1)
const OdTrVisDisplayId & cur() const
static OdUInt32 skipCodeSize(OdTrVisRendition::DisplayIdCodes dispCode)
static bool isIdentity(const OdGeMatrix3d &mtx)
static bool isEqual(const TObj &obj1, const TObj &obj2)
static const double kDisplayMultiDrawOrderMarker
GLint GLint GLint GLsizei GLsizei GLenum format
Definition gles2_ext.h:111
DataType m_maxBound
Definition TrVisIval.h:38
DataType m_minBound
Definition TrVisIval.h:38