Util 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2008 Robert Osfield
  2. *
  3. * This library is open source and may be redistributed and/or modified under
  4. * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
  5. * (at your option) any later version. The full license is in LICENSE file
  6. * included with this distribution, and on the openscenegraph.org website.
  7. *
  8. * This library is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * OpenSceneGraph Public License for more details.
  12. */
  13. // Code by: Jeremy Moles (cubicool) 2007-2008
  14. #ifndef OSGWIDGET_UTIL
  15. #define OSGWIDGET_UTIL
  16. #include <ctype.h>
  17. #include <cctype>
  18. #include <algorithm>
  19. #include <sstream>
  20. #include <osg/Camera>
  21. #include <osgViewer/Viewer>
  22. #include <osgViewer/CompositeViewer>
  23. #include <osgWidget/Export>
  24. #include <osgWidget/Types>
  25. namespace osgWidget {
  26. // These are NOT OSGWIDGET_EXPORT'd; these are internal only!
  27. inline std::ostream& _notify(osg::NotifySeverity ns = osg::INFO)
  28. {
  29. std::ostream& n = osg::notify(ns);
  30. return n << "osgWidget: ";
  31. }
  32. inline std::ostream& warn()
  33. {
  34. return _notify(osg::WARN);
  35. }
  36. inline std::ostream& info()
  37. {
  38. return _notify();
  39. }
  40. inline char lowerCaseChar(const char in)
  41. {
  42. return (unsigned char)(::tolower((int)((unsigned char)in)));
  43. }
  44. inline std::string lowerCase(const std::string& str)
  45. {
  46. std::string s = str;
  47. // TODO: Why can't I specify std::tolower?
  48. std::transform(s.begin(), s.end(), s.begin(), lowerCaseChar);
  49. return s;
  50. }
  51. // TODO: Is this totally ghetto or what?
  52. template <typename T>
  53. inline bool hasDecimal(T v)
  54. {
  55. return (v - static_cast<T>(static_cast<long>(v))) > 0.0f;
  56. }
  57. class WindowManager;
  58. // These ARE OSGWIDGET_EXPORT'd for your convenience. :)
  59. OSGWIDGET_EXPORT std::string getFilePath (const std::string&);
  60. OSGWIDGET_EXPORT std::string generateRandomName (const std::string&);
  61. OSGWIDGET_EXPORT osg::Camera* createOrthoCamera (matrix_type, matrix_type);
  62. // This function sets up our basic example framework, and optionally sets some root
  63. // scene data.
  64. OSGWIDGET_EXPORT int createExample (osgViewer::Viewer&, WindowManager*, osg::Node* = 0);
  65. OSGWIDGET_EXPORT bool writeWindowManagerNode (WindowManager*);
  66. }
  67. #endif