CFx SDK Documentation 2024 SP0
Loading...
Searching...
No Matches
TrVisDisplayCodeProc.h
Go to the documentation of this file.
1
2// Copyright (C) 2002-2022, 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-2022 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 {
101 pushMarkers<TArray>(arry, pHlBranch, kTrVisHighlightingBranch);
102 }
106 template <typename TArray>
107 static void pushVsMarkers( TArray &arry, OdTrVisStateBranchPtr pVsBranch )
108 {
109 pushMarkers<TArray>(arry, pVsBranch, kTrVisVisibilityBranch);
110 }
111 // Drawing order
112 template <typename TArray>
113 static void pushDrawOrder(TArray &arry, double drawOrder)
114 { typedef OD_TYPENAME TArray::value_type ValType;
116 arry.push_back(*reinterpret_cast<ValType*>(&drawOrder));
117 }
118 template <typename TArray>
119 static void pushMultiOrder(TArray &arry)
120 {
121 pushDrawOrder<TArray>(arry, OdTrVisRendition::kDisplayMultiDrawOrderMarker);
122 }
123 // Drawing order interval
124 template <typename TArray>
125 static void pushDepthIval(TArray &arry, const OdTrVisIvald &ival)
126 { typedef OD_TYPENAME TArray::value_type ValType;
128 arry.push_back(*reinterpret_cast<const ValType*>(&ival.m_minBound));
129 arry.push_back(*reinterpret_cast<const ValType*>(&ival.m_maxBound));
130 }
131 // Exploded unions
132 template <typename TArray>
133 static void pushExploded(TArray &arry)
134 {
136 }
137 template <typename TArray>
138 static void pushNonExploded(TArray &arry)
139 {
141 }
142 template <typename TArray>
143 static void pushExploded(TArray &arry, bool bExploded)
144 {
146 }
147 // Selection style
148 template <typename TArray>
149 static void pushSelStyle(TArray& arry, OdUInt32 nSelStyle)
150 { typedef OD_TYPENAME TArray::value_type ValType;
152 arry.push_back((ValType)(OdIntPtr)nSelStyle);
153 }
159 template <typename TArray>
160 static void pushSelectionID(TArray &arry, const void *pID)
161 { typedef OD_TYPENAME TArray::value_type ValType;
163 arry.push_back((ValType)(OdIntPtr)pID);
164 }
165};
166
171{
172 public:
173 template <typename TObj>
174 static bool isEqual(const TObj &obj1, const TObj &obj2)
175 {
176 return !::memcmp(&obj1, &obj2, sizeof(TObj));
177 }
178 static bool isIdentity(const OdGeMatrix3d &mtx)
179 {
180 return isEqual(mtx, OdGeMatrix3d::kIdentity);
181 }
182};
183
188{
189 OdTrVisDisplayId *m_pList;
190 OdUInt32 m_nListData, m_nCaret;
191 public:
193 : m_pList(const_cast<OdTrVisDisplayId*>(pList)), m_nListData(nData), m_nCaret(0)
194 {
195 }
196 bool isEOF() const { return m_nCaret >= m_nListData; }
197 bool isCode() const { return m_pList[m_nCaret] < OdTrVisRendition::kDisplayCodeRange; }
200 { OdUInt32 nSteps = 1;
201 switch (dispCode) { case OdTrVisRendition::kDisplayCodePushMatrix: nSteps += sizeof(OdGeMatrix3d) / sizeof(double); break;
202 case OdTrVisRendition::kDisplayCodeDepthIval: nSteps += 2; break;
206 case OdTrVisRendition::kDisplayCodeDrawOrder : nSteps += 1; break; default: break; }
207 return nSteps; }
208 void skipCode() { m_nCaret += skipCodeSize(code()); }
209 OdTrVisDisplayId &cur() { return m_pList[m_nCaret]; }
210 const OdTrVisDisplayId &cur() const { return m_pList[m_nCaret]; }
211 OdTrVisDisplayId &next(OdUInt32 n = 1) { return m_pList[m_nCaret + n]; }
212 const OdTrVisDisplayId &next(OdUInt32 n = 1) const { return m_pList[m_nCaret + n]; }
213 bool step() { if (isCode()) skipCode(); else m_nCaret++; return isEOF(); }
214 // Access extensions
215 const double *codeAsDoublePtr(OdUInt32 n = 1) const { return reinterpret_cast<const double*>(m_pList + (m_nCaret + n)); }
216 const OdGeMatrix3d *codeAsMatrixPtr(OdUInt32 n = 1) const { return reinterpret_cast<const OdGeMatrix3d*>(m_pList + (m_nCaret + n)); }
217 const OdTrVisId *codeAsIdPtr(OdUInt32 n = 1) const { return reinterpret_cast<const OdTrVisId*>(m_pList + (m_nCaret + n)); }
218 const void *codeAsPtr(OdUInt32 n = 1) const { return OdTrVisIdToPtr(const void, m_pList[m_nCaret + n]); }
219 // Debug extensions
220 static void dumpDisplayList(const OdTrVisDisplayId *pList, OdUInt32 nData, void (*pDumpFunc)(const OdString &));
221 //void traceDumpFunc(const OdString &str) { ODA_TRACE(str.c_str()); } // Example dump function
222};
223
224inline void OdTrVisDisplayListIterator::dumpDisplayList(const OdTrVisDisplayId *pList, OdUInt32 nData, void (*pDumpFunc)(const OdString &))
225{ OdTrVisDisplayListIterator it(pList, nData);
226 while (!it.isEOF())
227 {
228 if (it.isCode())
229 {
230 switch (it.code())
231 {
233 pDumpFunc(L"Code Highlight: 1\n");
234 break;
236 pDumpFunc(L"Code UnHighlight: 0\n");
237 break;
239 pDumpFunc(OdString().format(L"Code PushMatrix: { %f, %f, %f, %f }, { %f, %f, %f, %f }, { %f, %f, %f, %f }, { %f, %f, %f, %f }\n",
240 it.codeAsMatrixPtr()->entry[0][0], it.codeAsMatrixPtr()->entry[0][1], it.codeAsMatrixPtr()->entry[0][2], it.codeAsMatrixPtr()->entry[0][3],
241 it.codeAsMatrixPtr()->entry[1][0], it.codeAsMatrixPtr()->entry[1][1], it.codeAsMatrixPtr()->entry[1][2], it.codeAsMatrixPtr()->entry[1][3],
242 it.codeAsMatrixPtr()->entry[2][0], it.codeAsMatrixPtr()->entry[2][1], it.codeAsMatrixPtr()->entry[2][2], it.codeAsMatrixPtr()->entry[2][3],
243 it.codeAsMatrixPtr()->entry[3][0], it.codeAsMatrixPtr()->entry[3][1], it.codeAsMatrixPtr()->entry[3][2], it.codeAsMatrixPtr()->entry[3][3]));
244 break;
246 pDumpFunc(L"Code PopMatrix\n");
247 break;
249 pDumpFunc(OdString().format(L"Code Fade: %u\n", (unsigned)it.next()));
250 break;
252 pDumpFunc(OdString().format(L"Code UnFade: %u\n", (unsigned)it.next()));
253 break;
255 pDumpFunc(OdString().format(L"Code HlMarker: %" PRIu64W L"\n", *it.codeAsIdPtr()));
256 break;
258 pDumpFunc(OdString().format(L"Code VsMarker: %" PRIu64W L"\n", *it.codeAsIdPtr()));
259 break;
261 pDumpFunc(OdString().format(L"Code DrawOrder: %f\n", *it.codeAsDoublePtr()));
262 break;
264 pDumpFunc(OdString().format(L"Code Depth: { %f, %f }\n", it.codeAsDoublePtr()[0], it.codeAsDoublePtr()[1]));
265 break;
267 pDumpFunc(L"Code Exploded: 1\n");
268 break;
270 pDumpFunc(L"Code NonExploded: 0\n");
271 break;
273 pDumpFunc(OdString().format(L"Code SelStyle: %u\n", (unsigned)it.next()));
274 break;
275 }
276 }
277 else
278 {
279 pDumpFunc(OdString().format(L"Metafile: %" PRIu64W L"\n", it.cur()));
280 }
281 it.step();
282 }
283}
284
285#include "TD_PackPop.h"
286
287#endif // ODTRVISDISPLAYCODEPROC
#define OD_TYPENAME
Definition: OdPlatform.h:631
unsigned int OdUInt32
ptrdiff_t OdIntPtr
const void * OdTrVisStateBranchPtr
Definition: TrVisDefs.h:162
OdTrVisStateBranchType
Definition: TrVisDefs.h:155
@ kTrVisVisibilityBranch
Definition: TrVisDefs.h:157
@ kTrVisHighlightingBranch
Definition: TrVisDefs.h:156
#define OdTrVisIdToPtr(ptrType, id)
Definition: TrVisDefs.h:126
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 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