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