openscenegraph
Util
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
30namespace osgWidget {
31
32// These are NOT OSGWIDGET_EXPORT'd; these are internal only!
33
34inline std::ostream& _notify(osg::NotifySeverity ns = osg::INFO)
35{
36 std::ostream& n = osg::notify(ns);
37
38 return n << "osgWidget: ";
39}
40
41inline std::ostream& warn()
42{
43 return _notify(osg::WARN);
44}
45
46inline std::ostream& info()
47{
48 return _notify();
49}
50
51inline char lowerCaseChar(const char in)
52{
53 return (unsigned char)(::tolower((int)((unsigned char)in)));
54}
55
56inline std::string lowerCase(const std::string& str)
57{
58 std::string s = str;
59
60 // TODO: Why can't I specify std::tolower?
61 std::transform(s.begin(), s.end(), s.begin(), lowerCaseChar);
62
63 return s;
64}
65
66// TODO: Is this totally ghetto or what?
67template <typename T>
68inline bool hasDecimal(T v)
69{
70 return (v - static_cast<T>(static_cast<long>(v))) > 0.0f;
71}
72
73class WindowManager;
74
75// These ARE OSGWIDGET_EXPORT'd for your convenience. :)
76
77OSGWIDGET_EXPORT std::string getFilePath (const std::string&);
78OSGWIDGET_EXPORT std::string generateRandomName (const std::string&);
79OSGWIDGET_EXPORT osg::Camera* createOrthoCamera (matrix_type, matrix_type);
80
81// This function sets up our basic example framework, and optionally sets some root
82// scene data.
83OSGWIDGET_EXPORT int createExample (osgViewer::Viewer&, WindowManager*, osg::Node* = 0);
84OSGWIDGET_EXPORT bool writeWindowManagerNode (WindowManager*);
85
86}
87
88#endif