OSG  3.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Util.h
Go to the documentation of this file.
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 
14 // Code by: Jeremy Moles (cubicool) 2007-2008
15 
16 #ifndef OSGWIDGET_UTIL
17 #define OSGWIDGET_UTIL
18 
19 #include <ctype.h>
20 #include <cctype>
21 #include <algorithm>
22 #include <sstream>
23 #include <osg/Camera>
24 #include <osgViewer/Viewer>
25 #include <osgViewer/CompositeViewer>
26 
27 #include <osgWidget/Export>
28 #include <osgWidget/Types>
29 
30 namespace osgWidget {
31 
32 // These are NOT OSGWIDGET_EXPORT'd; these are internal only!
33 
34 inline std::ostream& _notify(osg::NotifySeverity ns = osg::INFO)
35 {
36  std::ostream& n = osg::notify(ns);
37 
38  return n << "osgWidget: ";
39 }
40 
41 inline std::ostream& warn()
42 {
43  return _notify(osg::WARN);
44 }
45 
46 inline std::ostream& info()
47 {
48  return _notify();
49 }
50 
51 inline std::string lowerCase(const std::string& str)
52 {
53  std::string s = str;
54 
55  // TODO: Why can't I specify std::tolower?
56  std::transform(s.begin(), s.end(), s.begin(), ::tolower);
57 
58  return s;
59 }
60 
61 // TODO: Is this totally ghetto or what?
62 template <typename T>
63 inline bool hasDecimal(T v)
64 {
65  return (v - static_cast<T>(static_cast<long>(v))) > 0.0f;
66 }
67 
68 class WindowManager;
69 
70 // These ARE OSGWIDGET_EXPORT'd for your convenience. :)
71 
72 OSGWIDGET_EXPORT std::string getFilePath (const std::string&);
73 OSGWIDGET_EXPORT std::string generateRandomName (const std::string&);
75 
76 // This function sets up our basic example framework, and optionally sets some root
77 // scene data.
78 OSGWIDGET_EXPORT int createExample (osgViewer::Viewer&, WindowManager*, osg::Node* = 0);
79 OSGWIDGET_EXPORT bool writeWindowManagerNode (WindowManager*);
80 
81 }
82 
83 #endif
OSGWIDGET_EXPORT int createExample(osgViewer::Viewer &, WindowManager *, osg::Node *=0)
osg::Matrix::value_type matrix_type
Definition: Types.h:39
std::ostream & warn()
Definition: Util.h:41
bool hasDecimal(T v)
Definition: Util.h:63
std::ostream & info()
Definition: Util.h:46
OSGWIDGET_EXPORT std::string generateRandomName(const std::string &)
Definition: Box.h:21
#define OSGWIDGET_EXPORT
Definition: Export.h:42
OSGWIDGET_EXPORT std::string getFilePath(const std::string &)
OSGWIDGET_EXPORT bool writeWindowManagerNode(WindowManager *)
std::ostream & _notify(osg::NotifySeverity ns=osg::INFO)
Definition: Util.h:34
OSGWIDGET_EXPORT osg::Camera * createOrthoCamera(matrix_type, matrix_type)
std::string lowerCase(const std::string &str)
Definition: Util.h:51
Definition: Node.h:71
NotifySeverity
Definition: Notify.h:30
OSG_EXPORT std::ostream & notify(const NotifySeverity severity)