CFx SDK Documentation 2024 SP0
Loading...
Searching...
No Matches
TrRndSgSettingsUI.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// Scene Graph settings user interface component
24
25#ifndef ODTRRNDSGSCENEGRAPHSETTINGSUI
26#define ODTRRNDSGSCENEGRAPHSETTINGSUI
27
28#include "../extbar/ExtBar.h"
29
30#include "TD_PackPush.h"
31
32/* @@@TODO: Currently we have duplication of OdTrRndSgSceneGraphGlobalSettings and
33 OdTrRndSgRootConfig data structures here. I think more generic part
34 of headers must be moved to public area in future. Moreover
35 Scene Graph can be used for custom renderer building as part of
36 TrRenderBase static library. */
37
42{
43 public:
44 // Global settings definitions
46 {
51 };
53 {
54 kNoBalancing = 0, // Disable balancing at all
55 kSimpleBalancing, // Enable balancing for compatible geometries only
56 kWeightedBalancing, // Enable weighted balancing (balancing depends from weight of geometries)
57 kChaoticBalancing // Enable balancing without additional checks (helpful for performance measurements)
58 };
59 protected:
60 enum Flags
61 {
62 // Global settings flags
63 kDisplayFPS = (1 << 0),
64 kDisplayStats = (1 << 1),
65 kFadeUnions = (1 << 2),
66 kColorDataExt = (1 << 3),
69 kFlattenTtfTexts = (1 << 6),
72 kEmbedOrdering = (1 << 9),
74 // Roots configuration flags
75 kVisualizeRenders = (1 << 0), // Display renders
76 kVisualizeTreeStructure = (1 << 1), // Display tree structure
77 kVisualizeRenderExtents = (1 << 2) // Display render extents
78 };
79 protected:
81 {
114 };
115 protected:
116 OdUInt16 m_ngsFlags; // Global settings flags
117 OdUInt16 m_nrcFlags; // Root configuration flags
118 // Global settings
119 SceneTreeType m_sceneTreeType; // Tree structure, which will be used to store scene contents
120 SceneTreeType m_auxTreeType; // Tree structure, which will be used to store auxiliary graphics
121 BalancingMode m_balancingMode; // Rendering speed balancing mode
122 OdUInt16 m_prcMinWeight; // Minimal balancing weight for weighted balancing mode
123 OdUInt16 m_prcMinDepth; // Minimal balancing tree level (in percents of entire tree depth)
124 OdUInt16 m_prcMergeDepth; // Merging inclusion childs depth (in percents of entire tree depth)
125 OdUInt16 m_nThreadsMax; // Maximal number of utilizeable threads (can be null to disable multithreading)
126 OdUInt32 m_nMaxUnionSize; // Maximal length of unionized data stream
127 OdUInt32 m_nLineStripsLim; // Maximal number of vertex in line strips/loops which can be exploded into set of simple lines
128 OdUInt32 m_nTrgStripsLim; // Maximal number of vertex in triangle strips/fans which can be exploded into set of simple triangles
129 OdUInt32 m_nBlkRefExpLim; // Maximal number of nested block reference metafiles for explode inside primary scene graph
130 // Roots configuration
131 OdUInt32 m_nMaxTreeDepth; // Maximal tree depth (maximal number of tree branches subdivision)
132 OdUInt32 m_nMaxObjectsSubdivide; // Maximal number of objects onto tree leafs before subdivision (best between 8-16)
133 double m_fMinTreeNodeSize; // Minimal tree node size (should be small-enough)
134 double m_fNodeFittingRatio; // Coefficient between 1 (disabled) and 2 (maximal). Enlarges tree nodes area to overlap nearest nodes.
135 double m_fInitialNodeMult; // First tree node extents multiplier (actual for Octree)
136 public:
138 { reset(); }
139 void reset()
140 {
143 // Global settings
147 m_prcMinWeight = 50;
148 m_prcMinDepth = 10;
149 m_prcMergeDepth = 15;
150 m_nThreadsMax = 4;
151 m_nMaxUnionSize = 0xFA00000; // 250 Mb
152 m_nLineStripsLim = 512;
153 m_nTrgStripsLim = 342;
154 m_nBlkRefExpLim = 128;
155 // Roots configuration
156 m_nMaxTreeDepth = 30;
158 m_fMinTreeNodeSize = 1.e-4;
160 m_fInitialNodeMult = 10.0;
161 }
162
163 // Global settings
164
165 void setDisplayFPS(bool bEnable) { SETBIT(m_ngsFlags, kDisplayFPS, bEnable); }
166 bool displayFPS() const { return GETBIT(m_ngsFlags, kDisplayFPS); }
167
168 void setDisplayStatistics(bool bEnable) { SETBIT(m_ngsFlags, kDisplayStats, bEnable); }
170
171 void setUnionsFading(bool bEnable) { SETBIT(m_ngsFlags, kFadeUnions, bEnable); }
172 bool fadeUnions() const { return GETBIT(m_ngsFlags, kFadeUnions); }
173
174 void setColorDataExtensible(bool bEnable) { SETBIT(m_ngsFlags, kColorDataExt, bEnable); }
176
177 void setLineStripsExplode(bool bEnable) { SETBIT(m_ngsFlags, kLineStripsExplode, bEnable); }
179
182
183 void setTtfTextsFlattening(bool bEnable) { SETBIT(m_ngsFlags, kFlattenTtfTexts, bEnable); }
185
186 void setBlockRefsExploding(bool bEnable) { SETBIT(m_ngsFlags, kExplodeBlockRefs, bEnable); }
188
191
192 void setDrawOrderEmbedding(bool bEnable) { SETBIT(m_ngsFlags, kEmbedOrdering, bEnable); }
194
197
198 void setSceneTreeType(SceneTreeType treeType) { m_sceneTreeType = treeType; }
200
201 void setAuxiliaryTreeType(SceneTreeType treeType) { m_auxTreeType = treeType; }
203
206
207 void setWeightedBalancingLimit(OdUInt32 weightLimit) { m_prcMinWeight = (OdUInt16)weightLimit; }
209
210 void setBalancingLevelLimit(OdUInt32 minDepthLimit) { m_prcMinDepth = (OdUInt16)minDepthLimit; }
212
213 void setBalancingMergeDepth(OdUInt32 mergeDepth) { m_prcMergeDepth = (OdUInt16)mergeDepth; }
215
218
221
224
227
228 void setThreadsMaximum(OdUInt32 nThreadsMax) { m_nThreadsMax = (OdUInt16)nThreadsMax; }
230
231 // Roots configuration
232
235
238
241
243 void setMaxTreeDepth(OdUInt32 nMaxTreeDepth) { m_nMaxTreeDepth = nMaxTreeDepth; }
244
246 void setMaxObjectsSubdivide(OdUInt32 nMaxObjectSubdivide) { m_nMaxObjectsSubdivide = nMaxObjectSubdivide; }
247
248 double minTreeNodeSize() const { return m_fMinTreeNodeSize; }
249 void setMinTreeNodeSize(double fMinTreeNodeSize) { m_fMinTreeNodeSize = fMinTreeNodeSize; }
250
251 double nodeFittingRatio() const { return m_fNodeFittingRatio; }
252 void setNodeFittingRatio(double fNodeFittingRatio) { m_fNodeFittingRatio = fNodeFittingRatio; }
253
255 void setFirstNodeExtraMultiplier(double fInitialNodeMult) { m_fInitialNodeMult = fInitialNodeMult; }
256
257 // Cloning/Copying ability
258
259 template <typename TypeTo, typename TypeFrom>
260 static void copyGlobalSettings(TypeTo &to, const TypeFrom &from)
261 {
262 to.setDisplayFPS(from.displayFPS());
263 to.setDisplayStatistics(from.displayStatistics());
264 to.setUnionsFading(from.fadeUnions());
265 to.setColorDataExtensible(from.colorDataExtensible());
266 to.setLineStripsExplode(from.explodeLineStrips());
267 to.setTriangleStripsExplode(from.explodeTriangleStrips());
268 to.setTtfTextsFlattening(from.flattenTtfTexts());
269 to.setBlockRefsExploding(from.explodeBlockRefs());
270 to.setAllowNestedSceneGraphs(from.allowNestedSceneGraphs());
271 to.setDrawOrderEmbedding(from.embedDrawOrder());
272 to.setPurgeGrouppedRenders(from.purgeGrouppedRenders());
273 to.setSceneTreeType((OD_TYPENAME TypeTo::SceneTreeType)from.sceneTreeType());
274 to.setAuxiliaryTreeType((OD_TYPENAME TypeTo::SceneTreeType)from.auxiliaryTreeType());
275 to.setBalancingMode((OD_TYPENAME TypeTo::BalancingMode)from.balancingMode());
276 to.setWeightedBalancingLimit(from.weightedBalancingLimit());
277 to.setBalancingLevelLimit(from.balancingLevelLimit());
278 to.setBalancingMergeDepth(from.balancingMergeDepth());
279 to.setMaximalUnionSize(from.maximalUnionSize());
280 to.setLineStripsExplodeLimit(from.lineStripsExplodeLimit());
281 to.setTriangleStripsExplodeLimit(from.triangleStripsExplodeLimit());
282 to.setBlockRefsExplodeLimit(from.blockRefsExplodeLimit());
283 to.setThreadsMaximum(from.threadsMaximum());
284 }
285 template <typename TypeTo, typename TypeFrom>
286 static void copyRootsConfig(TypeTo &to, const TypeFrom &from)
287 {
288 to.setVisualizeRenders(from.visualizeRenders());
289 to.setVisualizeTreeStructure(from.visualizeTreeStructure());
290 to.setVisualizeRenderExtents(from.visualizeRenderExtents());
291 to.setMaxTreeDepth(from.maxTreeDepth());
292 to.setMaxObjectsSubdivide(from.maxObjectsSubdivide());
293 to.setMinTreeNodeSize(from.minTreeNodeSize());
294 to.setNodeFittingRatio(from.nodeFittingRatio());
295 to.setFirstNodeExtraMultiplier(from.firstNodeExtraMultiplier());
296 }
298 {
299 copyGlobalSettings(*this, uiSets);
300 copyRootsConfig(*this, uiSets);
301 return *this;
302 }
303
304 // ExtBar interface
305
306 virtual void fillExtBar(ExtBar *pExtBar)
307 { // Initialize Global Settings
309 ExtBar::TextElement::cast(pGroup)->setText(OD_T("Global Settings"));
310 // Display FPS
311 pExtBar->createCheckBox(kUIDisplayFPSCheckBox, pGroup, ExtBar::k8d8, displayFPS())->setText(OD_T("Display FPS"));
312 // Display Statistics
313 pExtBar->createCheckBox(kUIDisplayStatsCheckBox, pGroup, ExtBar::k8d8, displayStatistics())->setText(OD_T("Display Statistics and Measurements"));
314 // Display Unions Faded
315 pExtBar->createCheckBox(kUIUnionsFadingCheckBox, pGroup, ExtBar::k8d8, fadeUnions())->setText(OD_T("Display Unions Faded"));
316 // Color Data Extensible
317 pExtBar->createCheckBox(kUIColorDataExtCheckBox, pGroup, ExtBar::k8d8, colorDataExtensible())->setText(OD_T("Extend Color Data if Possible"));
318 // Line Strips Explode
319 pExtBar->createCheckBox(kUILineStripsExpCheckBox, pGroup, ExtBar::k8d8, explodeLineStrips())->setText(OD_T("Explode Line Strips/Loops"));
320 // Triangle Strips Explode
321 pExtBar->createCheckBox(kUITrgStripsExpCheckBox, pGroup, ExtBar::k8d8, explodeTriangleStrips())->setText(OD_T("Explode Triangle Strips/Fans"));
322 // TrueType Texts Flattening
323 pExtBar->createCheckBox(kUIFlattenTtfCheckBox, pGroup, ExtBar::k8d8, flattenTtfTexts())->setText(OD_T("Flatten TrueType Texts"));
324 // Block References Exploding
325 pExtBar->createCheckBox(kUIExplodeBlockRefsCheckBox, pGroup, ExtBar::k8d8, explodeBlockRefs())->setText(OD_T("Explode Block References"));
326 // Nested Scene Graphs
327 pExtBar->createCheckBox(kUINestedGraphsCheckBox, pGroup, ExtBar::k8d8, allowNestedSceneGraphs())->setText(OD_T("Nested Scene Graphs"));
328 // Draw Order Embedding
329 pExtBar->createCheckBox(kUIEmbedOrderingCheckBox, pGroup, ExtBar::k8d8, embedDrawOrder())->setText(OD_T("Enable Draw Order Embedding"));
330 // Groupped Renders Purging
331 pExtBar->createCheckBox(kUIPurgeGrouppedCheckBox, pGroup, ExtBar::k8d8, purgeGrouppedRenders())->setText(OD_T("Purge Groupped Renders"));
332 // Scene Tree Type
333 pExtBar->createText(kUISceneTreeTypeText, pGroup, ExtBar::k8d8)->setText(OD_T("Scene Tree Type:"));
335 pList->addString(OD_T("Flat List")); pList->addString(OD_T("Spatial Index"));
336 pList->addString(OD_T("Octree")); pList->addString(OD_T("KdTree"));
337 pList->setSelString((int)sceneTreeType()); }
338 // Auxiliary Tree Type
339 pExtBar->createText(kUIAuxTreeTypeText, pGroup, ExtBar::k8d8)->setText(OD_T("Auxiliary Tree Type:"));
340 { ExtBar::ListElement *pList = pExtBar->createComboBox(kUIAuxTreeTypeComboBox, pGroup);
341 pList->addString(OD_T("Flat List")); pList->addString(OD_T("Spatial Index"));
342 pList->addString(OD_T("Octree")); pList->addString(OD_T("KdTree"));
343 pList->setSelString((int)auxiliaryTreeType()); }
344 // Balancing Mode
345 pExtBar->createText(kUIBalancingModeText, pGroup, ExtBar::k8d8)->setText(OD_T("Balancing Mode:"));
347 pList->addString(OD_T("No Balancing")); pList->addString(OD_T("Simple Balancing"));
348 pList->addString(OD_T("Weighted Balancing")); pList->addString(OD_T("Chaotic Balancing"));
349 pList->setSelString((int)balancingMode()); }
350 // Weighted Balancing Limit
351 pExtBar->createText(kUIWeightLimitText, pGroup, ExtBar::k6d8)->setText(OD_T("Weighted Balancing Limit (%):"));
353 // Balancing Level Limit
354 pExtBar->createText(kUIBalancingLimitText, pGroup, ExtBar::k6d8)->setText(OD_T("Balancing Level Limit (%):"));
356 // Balancing Merge Depth
357 pExtBar->createText(kUIBalancingDepthText, pGroup, ExtBar::k6d8)->setText(OD_T("Balancing Merge Depth (%):"));
359 // Maximal unionized stream length
360 pExtBar->createText(kUIMaxUnionSizeText, pGroup, ExtBar::k6d8)->setText(OD_T("Maximal Union Size (Bytes):"));
361 pExtBar->createRangeBox(kUIMaxUnionSizeRangeBox, pGroup, ExtBar::k2d8)->setUInt(maximalUnionSize(), 0x100000, 0xFFFFFFFF);
362 // Line Strips Exploding Limit
363 pExtBar->createText(kUILineStripsLimText, pGroup, ExtBar::k6d8)->setText(OD_T("Line Strips Explode Limit:"));
365 // Triangle Strips Exploding Limit
366 pExtBar->createText(kUITrgStripsLimText, pGroup, ExtBar::k6d8)->setText(OD_T("Triangle Strips Explode Limit:"));
368 // Block References Exploding Limit
369 pExtBar->createText(kUIBlkRefExpLimText, pGroup, ExtBar::k6d8)->setText(OD_T("Block References Explode Limit:"));
371 // Number of Working Threads
372 pExtBar->createText(kUINumThreadsText, pGroup, ExtBar::k6d8)->setText(OD_T("Number of Working Threads:"));
374 // Roots configuration
375 pGroup = pExtBar->createGroup(kUIRootConfigGroup);
376 ExtBar::TextElement::cast(pGroup)->setText(OD_T("Roots Configuration"));
377 // Visualize Renders
378 pExtBar->createCheckBox(kUIVisualizeRendersCheckBox, pGroup, ExtBar::k8d8, visualizeRenders())->setText(OD_T("Visualize Renders"));
379 // Visualize Tree Structure
380 pExtBar->createCheckBox(kUIVisualizeTreesCheckBox, pGroup, ExtBar::k8d8, visualizeTreeStructure())->setText(OD_T("Visualize Tree Structure"));
381 // Visualize Render Extents
382 pExtBar->createCheckBox(kUIVisualizeExtentsCheckBox, pGroup, ExtBar::k8d8, visualizeRenderExtents())->setText(OD_T("Visualize Renders and Unions Extents"));
383 // Maximal Tree Depth
384 pExtBar->createText(kUIMaxTreeDepthText, pGroup, ExtBar::k6d8)->setText(OD_T("Maximal Tree Depth:"));
386 // Maximal Objects Subdivide
387 pExtBar->createText(kUIMaxNodeObjectsText, pGroup, ExtBar::k6d8)->setText(OD_T("Maximal Tree Node Objects before Subdivide:"));
389 // Minimal Tree Node Size
390 pExtBar->createText(kUIMinNodeSizeText, pGroup, ExtBar::k6d8)->setText(OD_T("Minimal Tree Node Size:"));
391 pExtBar->createRangeBox(kUIMinNodeSizeRangeBox, pGroup, ExtBar::k2d8, false, true)->setFP(minTreeNodeSize(), 1.e-10, 1.e+10, 1.e-3);
392 // Node Fitting Ratio
393 pExtBar->createText(kUINodeFittingRatioText, pGroup, ExtBar::k6d8)->setText(OD_T("Tree Node Fitting Ratio:"));
394 pExtBar->createRangeBox(kUINodeFittingRatioRangeBox, pGroup, ExtBar::k2d8, false, true)->setFP(nodeFittingRatio(), 1.0, 2.0, 0.01);
395 // First Node Extra Multiplier
396 pExtBar->createText(kUIFirstNodeMultText, pGroup, ExtBar::k6d8)->setText(OD_T("Initial Tree Node Extra Extents Multiplier:"));
397 pExtBar->createRangeBox(kUIFirstNodeMultRangeBox, pGroup, ExtBar::k2d8, false, true)->setFP(firstNodeExtraMultiplier(), 1.e-2, 1.e+4, 0.01);
398 }
399 virtual void closeExtBar(ExtBar *pExtBar, int nReason)
400 { if (!nReason) return;
401 // Grab Global Settings
424 // Grab Roots Configuration
433 }
434 virtual void elementChanged(ExtBar::Element * /*pElem*/) { /* if some element will require special handling */ }
435};
436
437#include "TD_PackPop.h"
438
439#endif // ODTRRNDSGSCENEGRAPHSETTINGSUI
#define OD_TYPENAME
Definition: OdPlatform.h:631
#define OD_T(x)
unsigned int OdUInt32
unsigned short OdUInt16
#define SETBIT(flags, bit, value)
Definition: OdaDefs.h:516
#define GETBIT(flags, bit)
Definition: OdaDefs.h:517
Definition: ExtBar.h:37
virtual RangeElement * createRangeBox(OdUInt32 nElementId, GroupElement *pGroup=NULL, ElementSize size=k8d8, bool bSigned=false, bool bFP=false)=0
virtual Element * getElement(OdUInt32 nElementId) const =0
virtual ListElement * createComboBox(OdUInt32 nElementId, GroupElement *pGroup=NULL, OdUInt32 nOpenLines=4)=0
virtual TextElement * createText(OdUInt32 nElementId, GroupElement *pGroup=NULL, ElementSize size=k8d8, OdUInt32 nStrings=1, bool bBorder=false, ODCOLORREF color=ODRGB(0, 0, 0))=0
@ k6d8
Definition: ExtBar.h:91
@ k2d8
Definition: ExtBar.h:93
@ k8d8
Definition: ExtBar.h:90
virtual GroupElement * createGroup(OdUInt32 nElementId, bool bExpandeable=true, bool bExpanded=true)=0
virtual TextElement * createCheckBox(OdUInt32 nElementId, GroupElement *pGroup=NULL, ElementSize size=k8d8, bool bChecked=false, bool bLText=false)=0
void setThreadsMaximum(OdUInt32 nThreadsMax)
BalancingMode balancingMode() const
OdUInt32 blockRefsExplodeLimit() const
static void copyRootsConfig(TypeTo &to, const TypeFrom &from)
void setUnionsFading(bool bEnable)
virtual void elementChanged(ExtBar::Element *)
void setAuxiliaryTreeType(SceneTreeType treeType)
void setColorDataExtensible(bool bEnable)
void setTriangleStripsExplodeLimit(OdUInt32 expLimit)
void setFirstNodeExtraMultiplier(double fInitialNodeMult)
void setBalancingMode(BalancingMode balancingMode)
void setLineStripsExplodeLimit(OdUInt32 expLimit)
virtual void closeExtBar(ExtBar *pExtBar, int nReason)
void setBalancingLevelLimit(OdUInt32 minDepthLimit)
SceneTreeType sceneTreeType() const
void setVisualizeRenderExtents(bool bSet)
void setTriangleStripsExplode(bool bEnable)
void setMaxTreeDepth(OdUInt32 nMaxTreeDepth)
void setMaxObjectsSubdivide(OdUInt32 nMaxObjectSubdivide)
void setNodeFittingRatio(double fNodeFittingRatio)
void setVisualizeTreeStructure(bool bSet)
OdUInt32 weightedBalancingLimit() const
OdUInt32 lineStripsExplodeLimit() const
SceneTreeType auxiliaryTreeType() const
void setDisplayStatistics(bool bEnable)
void setBalancingMergeDepth(OdUInt32 mergeDepth)
void setLineStripsExplode(bool bEnable)
void setMinTreeNodeSize(double fMinTreeNodeSize)
void setBlockRefsExploding(bool bEnable)
void setPurgeGrouppedRenders(bool bEnable)
void setSceneTreeType(SceneTreeType treeType)
OdTrRndSgSceneGraphSettingsUI & operator=(const OdTrRndSgSceneGraphSettingsUI &uiSets)
OdUInt32 triangleStripsExplodeLimit() const
static void copyGlobalSettings(TypeTo &to, const TypeFrom &from)
void setBlockRefsExplodeLimit(OdUInt32 nLimit)
void setDrawOrderEmbedding(bool bEnable)
virtual void fillExtBar(ExtBar *pExtBar)
void setWeightedBalancingLimit(OdUInt32 weightLimit)
void setMaximalUnionSize(OdUInt32 nBytes)
void setAllowNestedSceneGraphs(bool bEnable)
void setTtfTextsFlattening(bool bEnable)
static CheckElement * cast(Element *pIface)
Definition: ExtBar.h:129
virtual bool isChecked() const =0
virtual void setSelString(int nString)=0
virtual int getSelString() const =0
virtual void addString(const OdString &string)=0
static ListElement * cast(Element *pIface)
Definition: ExtBar.h:147
virtual void setFP(double fPos=0.0, double fMin=DBL_MIN, double fMax=DBL_MAX, double fDelta=0.01)=0
virtual void setUInt(OdUInt32 nPos=0, OdUInt32 nMin=0, OdUInt32 nMax=UINT_MAX, OdInt32 nDelta=1)=0
virtual double getPosFP() const =0
static RangeElement * cast(Element *pIface)
Definition: ExtBar.h:186
virtual OdUInt32 getPosUInt() const =0
static TextElement * cast(Element *pIface)
Definition: ExtBar.h:113
virtual void setText(const OdString &text)=0