fixed: gcc8 compile issues
[opensg.git] / Source / Contrib / ComplexSceneManager / Helper / OSGCSMStatisticsForeground.cpp
blob47f819c819840c6d9462d5d7e756a7ad0e7ca9e7
1 /*---------------------------------------------------------------------------*\
2 * OpenSG *
3 * *
4 * *
5 * Copyright (C) 2000-2006 by the OpenSG Forum *
6 * *
7 * www.opensg.org *
8 * *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
10 * *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
13 * License *
14 * *
15 * This library is free software; you can redistribute it and/or modify it *
16 * under the terms of the GNU Library General Public License as published *
17 * by the Free Software Foundation, version 2. *
18 * *
19 * This library is distributed in the hope that it will be useful, but *
20 * WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
22 * Library General Public License for more details. *
23 * *
24 * You should have received a copy of the GNU Library General Public *
25 * License along with this library; if not, write to the Free Software *
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
27 * *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
30 * Changes *
31 * *
32 * *
33 * *
34 * *
35 * *
36 * *
37 \*---------------------------------------------------------------------------*/
39 //---------------------------------------------------------------------------
40 // Includes
41 //---------------------------------------------------------------------------
43 #include <cstdlib>
44 #include <cstdio>
46 #include "OSGConfig.h"
48 #include "OSGCSMStatisticsForeground.h"
49 #include "OSGSimpleStatisticsForeground.h"
51 #include "OSGRenderAction.h"
52 #include "OSGPointLight.h"
53 #include "OSGSpotLight.h"
54 #include "OSGDirectionalLight.h"
56 OSG_BEGIN_NAMESPACE
58 // Documentation for this class is emitted in the
59 // OSGCSMStatisticsForegroundBase.cpp file.
60 // To modify it, please change the .fcd file (OSGCSMStatisticsForeground.fcd)
61 // and regenerate the base file.
63 /***************************************************************************\
64 * Class variables *
65 \***************************************************************************/
67 /***************************************************************************\
68 * Class methods *
69 \***************************************************************************/
71 void CSMStatisticsForeground::initMethod(InitPhase ePhase)
73 Inherited::initMethod(ePhase);
75 if(ePhase == TypeObject::SystemPost)
81 /***************************************************************************\
82 * Instance methods *
83 \***************************************************************************/
85 /*-------------------------------------------------------------------------*\
86 - private -
87 \*-------------------------------------------------------------------------*/
89 /*----------------------- constructors & destructors ----------------------*/
91 CSMStatisticsForeground::CSMStatisticsForeground(void) :
92 Inherited( ),
93 _pStatFG (NULL)
97 CSMStatisticsForeground::CSMStatisticsForeground(
98 const CSMStatisticsForeground &source) :
100 Inherited(source),
101 _pStatFG (NULL )
105 CSMStatisticsForeground::~CSMStatisticsForeground(void)
109 void CSMStatisticsForeground::draw(DrawEnv *)
113 void CSMStatisticsForeground::addElement(
114 SimpleStatisticsForeground *pStatFG,
115 const std::string &szStatObj,
116 const std::string &szStatElem,
117 const std::string &szFormat )
119 #if !defined(OSG_OGL_COREONLY) || defined(OSG_CHECK_COREONLY)
120 if(szStatObj.compare("Text") == 0)
122 if(szStatElem.compare("freetext") == 0)
124 pStatFG->addText(szFormat.c_str());
126 else
128 fprintf(stderr, "Unknown stat elem %s for %s\n",
129 szStatElem.c_str(),
130 szStatObj.c_str());
133 else if(szStatObj.compare("RenderAction") == 0)
135 if(szStatElem.compare("statDrawTime") == 0)
137 pStatFG->addElement(RenderAction::statDrawTime,
138 szFormat.c_str());
140 else if(szStatElem.compare("statTravTime") == 0)
142 pStatFG->addElement(RenderAction::statTravTime,
143 szFormat.c_str());
145 else if(szStatElem.compare("statNMatrices") == 0)
147 pStatFG->addElement(RenderAction::statNMatrices,
148 szFormat.c_str());
150 else if(szStatElem.compare("statNStates") == 0)
152 pStatFG->addElement(RenderAction::statNStates,
153 szFormat.c_str());
155 else if(szStatElem.compare("statNChunks") == 0)
157 pStatFG->addElement(RenderAction::statNChunks,
158 szFormat.c_str());
160 else if(szStatElem.compare("statNShaders") == 0)
162 pStatFG->addElement(RenderAction::statNShaders,
163 szFormat.c_str());
165 else if(szStatElem.compare("statNShaderParams") == 0)
167 pStatFG->addElement(RenderAction::statNShaderParams,
168 szFormat.c_str());
170 else
172 fprintf(stderr, "Unknown stat elem %s for %s\n",
173 szStatElem.c_str(),
174 szStatObj.c_str());
177 else if(szStatObj.compare("PointLight") == 0)
179 if(szStatElem.compare("statNPointLights") == 0)
181 pStatFG->addElement(PointLight::statNPointLights,
182 szFormat.c_str());
184 else
186 fprintf(stderr, "Unknown stat elem %s for %s\n",
187 szStatElem.c_str(),
188 szStatObj.c_str());
191 else if(szStatObj.compare("DirectionalLight") == 0)
193 if(szStatElem.compare("statNDirectionalLights") == 0)
195 pStatFG->addElement(DirectionalLight::statNDirectionalLights,
196 szFormat.c_str());
198 else
200 fprintf(stderr, "Unknown stat elem %s for %s\n",
201 szStatElem.c_str(),
202 szStatObj.c_str());
205 else if(szStatObj.compare("SpotLight") == 0)
207 if(szStatElem.compare("statNSpotLights") == 0)
209 pStatFG->addElement(SpotLight::statNSpotLights,
210 szFormat.c_str());
212 else
214 fprintf(stderr, "Unknown stat elem %s for %s\n",
215 szStatElem.c_str(),
216 szStatObj.c_str());
219 else if(szStatObj.compare("Drawable") == 0)
221 if(szStatElem.compare("statNTriangles") == 0)
223 pStatFG->addElement(Drawable::statNTriangles,
224 szFormat.c_str());
226 else if(szStatElem.compare("statNLines") == 0)
228 pStatFG->addElement(Drawable::statNLines,
229 szFormat.c_str());
231 else if(szStatElem.compare("statNPoints") == 0)
233 pStatFG->addElement(Drawable::statNPoints,
234 szFormat.c_str());
236 else if(szStatElem.compare("statNVertices") == 0)
238 pStatFG->addElement(Drawable::statNVertices,
239 szFormat.c_str());
241 else if(szStatElem.compare("statNPrimitives") == 0)
243 pStatFG->addElement(Drawable::statNPrimitives,
244 szFormat.c_str());
246 else if(szStatElem.compare("statNGeoBytes") == 0)
248 pStatFG->addElement(Drawable::statNGeoBytes,
249 szFormat.c_str());
251 else if(szStatElem.compare("statNDrawFunctors") == 0)
253 pStatFG->addElement(Drawable::statNDrawFunctors,
254 szFormat.c_str());
256 else
258 fprintf(stderr, "Unknown stat elem %s for %s\n",
259 szStatElem.c_str(),
260 szStatObj.c_str());
263 else if(szStatObj.compare("TextureObjChunk") == 0)
265 if(szStatElem.compare("statNTextures") == 0)
267 pStatFG->addElement(TextureObjChunk::statNTextures,
268 szFormat.c_str());
270 else if(szStatElem.compare("statNTexBytes") == 0)
272 pStatFG->addElement(TextureObjChunk::statNTexBytes,
273 szFormat.c_str());
275 else
277 fprintf(stderr, "Unknown stat elem %s for %s\n",
278 szStatElem.c_str(),
279 szStatObj.c_str());
282 else if(szStatObj.compare("ChangeList") == 0)
284 if(szStatElem.compare("statNChangedStoreSize") == 0)
286 pStatFG->addElement(ChangeList::statNChangedStoreSize,
287 szFormat.c_str());
289 else if(szStatElem.compare("statNCreatedStoreSize") == 0)
291 pStatFG->addElement(ChangeList::statNCreatedStoreSize,
292 szFormat.c_str());
294 else if(szStatElem.compare("statNUnCommittedStoreSize") == 0)
296 pStatFG->addElement(ChangeList::statNUnCommittedStoreSize,
297 szFormat.c_str());
299 else if(szStatElem.compare("statNPoolSize") == 0)
301 pStatFG->addElement(ChangeList::statNPoolSize,
302 szFormat.c_str());
304 else
306 fprintf(stderr, "Unknown stat elem %s for %s\n",
307 szStatElem.c_str(),
308 szStatObj.c_str());
311 else if(szStatObj.compare("Partition") == 0)
313 if(szStatElem.compare("statCullTestedNodes") == 0)
315 pStatFG->addElement(RenderPartition::statCullTestedNodes,
316 szFormat.c_str());
318 else if(szStatElem.compare("statCulledNodes") == 0)
320 pStatFG->addElement(RenderPartition::statCulledNodes,
321 szFormat.c_str());
323 else
325 fprintf(stderr, "Unknown stat elem %s for %s\n",
326 szStatElem.c_str(),
327 szStatObj.c_str());
330 else
332 fprintf(stderr, "Unknown stat object %s\n",
333 szStatObj.c_str());
335 #endif
338 bool CSMStatisticsForeground::init(CSMWindow *pCSMWin)
340 #if !defined(OSG_OGL_COREONLY) || defined(OSG_CHECK_COREONLY)
341 SimpleStatisticsForegroundUnrecPtr pStatFG =
342 OSG::SimpleStatisticsForeground::create();
344 pStatFG->setActive (this->getActive ());
345 pStatFG->setSize (this->getSize ());
346 pStatFG->setColor (this->getColor ());
347 pStatFG->setBgColor(this->getBgColor());
349 _pStatFG = pStatFG;
351 if(_mfElements.size() != 0)
353 std::string szSep("::");
355 for(SizeT i = 0; i < _mfElements.size(); ++i)
357 SizeT uiPos = _mfElements[i].rfind(szSep);
359 if(uiPos != std::string::npos)
361 std::string szElem = _mfElements[i].substr(0,
362 uiPos );
363 std::string szFormat = _mfElements[i].substr(uiPos + 2,
364 std::string::npos);
366 if(szElem.size() == 0 || szFormat.size() == 0)
367 continue;
369 uiPos = szElem.rfind(szSep);
371 if(uiPos != std::string::npos)
373 std::string szStatObj = szElem.substr(0,
374 uiPos );
375 std::string szStatElem = szElem.substr(uiPos + 2,
376 std::string::npos);
378 if(szStatObj.size() == 0 || szStatElem.size() == 0)
379 continue;
381 addElement(pStatFG,
382 szStatObj,
383 szStatElem,
384 szFormat );
390 // pStatFG->addElement(RenderAction::statDrawTime, "Draw FPS: %r.3f");
391 // pStatFG->addElement(RenderAction::statDrawTime, "DrawTime: %.3f s");
392 #endif
394 return true;
397 StatisticsForeground *CSMStatisticsForeground::getOSGForeground(void)
399 return _pStatFG;
402 void CSMStatisticsForeground::resolveLinks(void)
404 _pStatFG = NULL;
406 Inherited::resolveLinks();
409 /*----------------------------- class specific ----------------------------*/
411 void CSMStatisticsForeground::changed(ConstFieldMaskArg whichField,
412 UInt32 origin,
413 BitVector details)
415 Inherited::changed(whichField, origin, details);
418 void CSMStatisticsForeground::dump( UInt32 ,
419 const BitVector ) const
421 SLOG << "Dump CSMStatisticsForeground NI" << std::endl;
424 OSG_END_NAMESPACE