osgUI/Widget
Go to the documentation of this file.
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2014 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
#ifndef OSGUI_WIDGET
#define OSGUI_WIDGET
#include <osg/Group>
#include <osg/BoundingBox>
#include <osg/ScriptEngine>
#include <osgGA/Event>
#include <osgGA/EventVisitor>
#include <osgUI/Style>
namespace osgUI
{
class OSGUI_EXPORT Widget : public osg::Group
{
public:
Widget();
Widget(const Widget& widget, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
META_Node(osgUI, Widget);
virtual void traverse(osg::NodeVisitor& nv);
virtual void traverseImplementation(osg::NodeVisitor& nv);
virtual bool handle(osgGA::EventVisitor* ev, osgGA::Event* event);
virtual bool handleImplementation(osgGA::EventVisitor* ev, osgGA::Event* event);
typedef std::vector<osgUtil::LineSegmentIntersector::Intersection> Intersections;
virtual bool computeIntersections(osgGA::EventVisitor* ev, osgGA::GUIEventAdapter* event, Intersections& intersections, osg::Node::NodeMask traversalMask = 0xffffffff) const;
virtual bool computePositionInLocalCoordinates(osgGA::EventVisitor* ev, osgGA::GUIEventAdapter* event, osg::Vec3d& localPosition) const;
virtual bool computeExtentsPositionInLocalCoordinates(osgGA::EventVisitor* ev, osgGA::GUIEventAdapter* event, osg::Vec3d& localPosition, bool withinExtents=true) const;
virtual void dirty();
typedef std::map<int, osg::ref_ptr<osg::Node> > GraphicsSubgraphMap;
void setGraphicsSubgraph(int orderNum, osg::Node* node) { _graphicsSubgraphMap[orderNum] = node; _graphicsInitialized = true; }
osg::Node* getGraphicsSubgraph(int orderNum) { GraphicsSubgraphMap::iterator itr = _graphicsSubgraphMap.find(orderNum); return (itr!=_graphicsSubgraphMap.end()) ? itr->second.get() : 0; }
const osg::Node* getGraphicsSubgraph(int orderNum) const { GraphicsSubgraphMap::const_iterator itr = _graphicsSubgraphMap.find(orderNum); return (itr!=_graphicsSubgraphMap.end()) ? itr->second.get() : 0; }
void setGraphicsSubgraphMap(const GraphicsSubgraphMap& gsm) { _graphicsSubgraphMap = gsm; _graphicsInitialized = true; }
GraphicsSubgraphMap& getGraphicsSubgraphMap() { return _graphicsSubgraphMap; }
const GraphicsSubgraphMap& getGraphicsSubgraphMap() const { return _graphicsSubgraphMap; }
void setWidgetStateSet(osg::StateSet* stateset) { _widgetStateSet = stateset; }
osg::StateSet* getWidgetStateSet() { return _widgetStateSet.get(); }
const osg::StateSet* getWidgetStateSet() const { return _widgetStateSet.get(); }
osg::StateSet* getOrCreateWidgetStateSet() { if (!_widgetStateSet) _widgetStateSet = new osg::StateSet; return _widgetStateSet.get(); }
virtual void createGraphics();
virtual void createGraphicsImplementation();
virtual void setExtents(const osg::BoundingBoxf& bb);
const osg::BoundingBoxf& getExtents() const { return _extents; }
void setStyle(Style* style) { _style = style; }
Style* getStyle() { return _style.get(); }
const Style* getStyle() const { return _style.get(); }
void setAlignmentSettings(AlignmentSettings* alignmentSettings) { _alignmentSettings = alignmentSettings; }
AlignmentSettings* getAlignmentSettings() { return _alignmentSettings.get(); }
const AlignmentSettings* getAlignmentSettings() const { return _alignmentSettings.get(); }
void setFrameSettings(FrameSettings* textSettings) { _frameSettings = textSettings; }
FrameSettings* getFrameSettings() { return _frameSettings.get(); }
const FrameSettings* getFrameSettings() const { return _frameSettings.get(); }
void setTextSettings(TextSettings* textSettings) { _textSettings = textSettings; }
TextSettings* getTextSettings() { return _textSettings.get(); }
const TextSettings* getTextSettings() const { return _textSettings.get(); }
virtual void setAutoFillBackground(bool enabled) { _autoFillBackground = enabled; }
virtual bool getAutoFillBackground() const { return _autoFillBackground; }
virtual void setVisible(bool visible) { _visible = visible; }
virtual bool getVisible() const { return _visible; }
virtual void setEnabled(bool enabled) { _enabled = enabled; }
virtual bool getEnabled() const { return _enabled; }
enum FocusBehaviour
{
CLICK_TO_FOCUS,
FOCUS_FOLLOWS_POINTER,
EVENT_DRIVEN_FOCUS_DISABLED
};
void setFocusBehaviour(FocusBehaviour behaviour) { _focusBehaviour = behaviour; }
FocusBehaviour getFocusBehaviour() const { return _focusBehaviour; }
virtual void updateFocus(osg::NodeVisitor& nv);
virtual void setHasEventFocus(bool focus);
virtual bool getHasEventFocus() const;
bool runCallbacks(const std::string& name, osg::Parameters& inputParameters, osg::Parameters& outputParameters) { return osg::runNamedCallbackObjects(this, name, inputParameters, outputParameters); }
bool runCallbacks(const std::string& name) { osg::Parameters inputParameters, outputParameters; return osg::runNamedCallbackObjects(this, name, inputParameters, outputParameters); }
virtual osg::BoundingSphere computeBound() const;
virtual void enter();
virtual void enterImplementation();
virtual void leave();
virtual void leaveImplementation();
virtual void resizeGLObjectBuffers(unsigned int maxSize);
virtual void releaseGLObjects(osg::State* = 0) const;
protected:
virtual ~Widget() {}
FocusBehaviour _focusBehaviour;
bool _hasEventFocus;
bool _graphicsInitialized;
GraphicsSubgraphMap _graphicsSubgraphMap;
osg::ref_ptr<osg::StateSet> _widgetStateSet;
osg::BoundingBoxf _extents;
osg::ref_ptr<Style> _style;
osg::ref_ptr<AlignmentSettings> _alignmentSettings;
osg::ref_ptr<FrameSettings> _frameSettings;
osg::ref_ptr<TextSettings> _textSettings;
bool _autoFillBackground;
bool _visible;
bool _enabled;
};
}
#endif
BoundingBox
EventVisitor
Event
Group
osgGA::EventVisitor
Definition EventVisitor:42
osgGA::Event
Definition Event:27
osgGA::GUIEventAdapter
Definition GUIEventAdapter:82
osgUI::AlignmentSettings
Definition AlignmentSettings:26
osgUI::FrameSettings
Definition FrameSettings:25
osgUI::Style
Definition osgUI/Style:32
osgUI::TextSettings
Definition TextSettings:26
osgUI::Widget::dirty
virtual void dirty()
osgUI::Widget::getWidgetStateSet
const osg::StateSet * getWidgetStateSet() const
Definition osgUI/Widget:67
osgUI::Widget::Intersections
std::vector< osgUtil::LineSegmentIntersector::Intersection > Intersections
Definition osgUI/Widget:41
osgUI::Widget::traverse
virtual void traverse(osg::NodeVisitor &nv)
osgUI::Widget::_alignmentSettings
osg::ref_ptr< AlignmentSettings > _alignmentSettings
Definition osgUI/Widget:169
osgUI::Widget::releaseGLObjects
virtual void releaseGLObjects(osg::State *=0) const
osgUI::Widget::leaveImplementation
virtual void leaveImplementation()
osgUI::Widget::setWidgetStateSet
void setWidgetStateSet(osg::StateSet *stateset)
Definition osgUI/Widget:65
osgUI::Widget::_hasEventFocus
bool _hasEventFocus
Definition osgUI/Widget:159
osgUI::Widget::computeBound
virtual osg::BoundingSphere computeBound() const
osgUI::Widget::traverseImplementation
virtual void traverseImplementation(osg::NodeVisitor &nv)
osgUI::Widget::setFrameSettings
void setFrameSettings(FrameSettings *textSettings)
Definition osgUI/Widget:89
osgUI::Widget::enter
virtual void enter()
osgUI::Widget::setVisible
virtual void setVisible(bool visible)
Definition osgUI/Widget:103
osgUI::Widget::getExtents
const osg::BoundingBoxf & getExtents() const
Definition osgUI/Widget:79
osgUI::Widget::_style
osg::ref_ptr< Style > _style
Definition osgUI/Widget:167
osgUI::Widget::getAlignmentSettings
const AlignmentSettings * getAlignmentSettings() const
Definition osgUI/Widget:87
osgUI::Widget::setAutoFillBackground
virtual void setAutoFillBackground(bool enabled)
Definition osgUI/Widget:98
osgUI::Widget::getFrameSettings
FrameSettings * getFrameSettings()
Definition osgUI/Widget:90
osgUI::Widget::GraphicsSubgraphMap
std::map< int, osg::ref_ptr< osg::Node > > GraphicsSubgraphMap
Definition osgUI/Widget:48
osgUI::Widget::setExtents
virtual void setExtents(const osg::BoundingBoxf &bb)
osgUI::Widget::_textSettings
osg::ref_ptr< TextSettings > _textSettings
Definition osgUI/Widget:171
osgUI::Widget::_visible
bool _visible
Definition osgUI/Widget:174
osgUI::Widget::getVisible
virtual bool getVisible() const
Definition osgUI/Widget:105
osgUI::Widget::setStyle
void setStyle(Style *style)
Definition osgUI/Widget:81
osgUI::Widget::getGraphicsSubgraph
const osg::Node * getGraphicsSubgraph(int orderNum) const
Definition osgUI/Widget:55
osgUI::Widget::setAlignmentSettings
void setAlignmentSettings(AlignmentSettings *alignmentSettings)
Definition osgUI/Widget:85
osgUI::Widget::getOrCreateWidgetStateSet
osg::StateSet * getOrCreateWidgetStateSet()
Definition osgUI/Widget:68
osgUI::Widget::handleImplementation
virtual bool handleImplementation(osgGA::EventVisitor *ev, osgGA::Event *event)
osgUI::Widget::getFrameSettings
const FrameSettings * getFrameSettings() const
Definition osgUI/Widget:91
osgUI::Widget::runCallbacks
bool runCallbacks(const std::string &name, osg::Parameters &inputParameters, osg::Parameters &outputParameters)
Definition osgUI/Widget:133
osgUI::Widget::_extents
osg::BoundingBoxf _extents
Definition osgUI/Widget:165
osgUI::Widget::setEnabled
virtual void setEnabled(bool enabled)
Definition osgUI/Widget:108
osgUI::Widget::Widget
Widget(const Widget &widget, const osg::CopyOp &copyop=osg::CopyOp::SHALLOW_COPY)
osgUI::Widget::getFocusBehaviour
FocusBehaviour getFocusBehaviour() const
Definition osgUI/Widget:120
osgUI::Widget::getEnabled
virtual bool getEnabled() const
Definition osgUI/Widget:110
osgUI::Widget::computePositionInLocalCoordinates
virtual bool computePositionInLocalCoordinates(osgGA::EventVisitor *ev, osgGA::GUIEventAdapter *event, osg::Vec3d &localPosition) const
osgUI::Widget::getStyle
Style * getStyle()
Definition osgUI/Widget:82
osgUI::Widget::setFocusBehaviour
void setFocusBehaviour(FocusBehaviour behaviour)
Definition osgUI/Widget:119
osgUI::Widget::_autoFillBackground
bool _autoFillBackground
Definition osgUI/Widget:172
osgUI::Widget::getGraphicsSubgraphMap
GraphicsSubgraphMap & getGraphicsSubgraphMap()
Definition osgUI/Widget:58
osgUI::Widget::leave
virtual void leave()
osgUI::Widget::FocusBehaviour
FocusBehaviour
Definition osgUI/Widget:113
osgUI::Widget::FOCUS_FOLLOWS_POINTER
@ FOCUS_FOLLOWS_POINTER
Definition osgUI/Widget:115
osgUI::Widget::CLICK_TO_FOCUS
@ CLICK_TO_FOCUS
Definition osgUI/Widget:114
osgUI::Widget::EVENT_DRIVEN_FOCUS_DISABLED
@ EVENT_DRIVEN_FOCUS_DISABLED
Definition osgUI/Widget:116
osgUI::Widget::setHasEventFocus
virtual void setHasEventFocus(bool focus)
osgUI::Widget::getStyle
const Style * getStyle() const
Definition osgUI/Widget:83
osgUI::Widget::setGraphicsSubgraphMap
void setGraphicsSubgraphMap(const GraphicsSubgraphMap &gsm)
Definition osgUI/Widget:57
osgUI::Widget::_graphicsInitialized
bool _graphicsInitialized
Definition osgUI/Widget:160
osgUI::Widget::getAutoFillBackground
virtual bool getAutoFillBackground() const
Definition osgUI/Widget:100
osgUI::Widget::Widget
Widget()
osgUI::Widget::handle
virtual bool handle(osgGA::EventVisitor *ev, osgGA::Event *event)
osgUI::Widget::updateFocus
virtual void updateFocus(osg::NodeVisitor &nv)
osgUI::Widget::getGraphicsSubgraph
osg::Node * getGraphicsSubgraph(int orderNum)
Definition osgUI/Widget:53
osgUI::Widget::_enabled
bool _enabled
Definition osgUI/Widget:175
osgUI::Widget::_widgetStateSet
osg::ref_ptr< osg::StateSet > _widgetStateSet
Definition osgUI/Widget:163
osgUI::Widget::_focusBehaviour
FocusBehaviour _focusBehaviour
Definition osgUI/Widget:158
osgUI::Widget::getGraphicsSubgraphMap
const GraphicsSubgraphMap & getGraphicsSubgraphMap() const
Definition osgUI/Widget:59
osgUI::Widget::getTextSettings
TextSettings * getTextSettings()
Definition osgUI/Widget:94
osgUI::Widget::enterImplementation
virtual void enterImplementation()
osgUI::Widget::runCallbacks
bool runCallbacks(const std::string &name)
Definition osgUI/Widget:136
osgUI::Widget::getHasEventFocus
virtual bool getHasEventFocus() const
osgUI::Widget::_graphicsSubgraphMap
GraphicsSubgraphMap _graphicsSubgraphMap
Definition osgUI/Widget:162
osgUI::Widget::createGraphicsImplementation
virtual void createGraphicsImplementation()
osgUI::Widget::createGraphics
virtual void createGraphics()
osgUI::Widget::computeIntersections
virtual bool computeIntersections(osgGA::EventVisitor *ev, osgGA::GUIEventAdapter *event, Intersections &intersections, osg::Node::NodeMask traversalMask=0xffffffff) const
osgUI::Widget::~Widget
virtual ~Widget()
Definition osgUI/Widget:156
osgUI::Widget::setTextSettings
void setTextSettings(TextSettings *textSettings)
Definition osgUI/Widget:93
osgUI::Widget::getAlignmentSettings
AlignmentSettings * getAlignmentSettings()
Definition osgUI/Widget:86
osgUI::Widget::META_Node
META_Node(osgUI, Widget)
osgUI::Widget::computeExtentsPositionInLocalCoordinates
virtual bool computeExtentsPositionInLocalCoordinates(osgGA::EventVisitor *ev, osgGA::GUIEventAdapter *event, osg::Vec3d &localPosition, bool withinExtents=true) const
osgUI::Widget::_frameSettings
osg::ref_ptr< FrameSettings > _frameSettings
Definition osgUI/Widget:170
osgUI::Widget::resizeGLObjectBuffers
virtual void resizeGLObjectBuffers(unsigned int maxSize)
osgUI::Widget::getWidgetStateSet
osg::StateSet * getWidgetStateSet()
Definition osgUI/Widget:66
osgUI::Widget::getTextSettings
const TextSettings * getTextSettings() const
Definition osgUI/Widget:95
osgUI::Widget::setGraphicsSubgraph
void setGraphicsSubgraph(int orderNum, osg::Node *node)
Definition osgUI/Widget:51
osg::CopyOp
Definition CopyOp:41
osg::CopyOp::SHALLOW_COPY
@ SHALLOW_COPY
Definition CopyOp:47
osg::Group
Definition Group:29
osg::NodeVisitor
Definition NodeVisitor:82
osg::Node
Definition Node:72
osg::Node::NodeMask
unsigned int NodeMask
Definition Node:363
osg::StateSet
Definition StateSet:46
osg::State
Definition State:80
osg::Vec3d
Definition Vec3d:30
osg::ref_ptr
Definition ref_ptr:32
osgUI
Definition AlignmentSettings:23
osg::runNamedCallbackObjects
bool runNamedCallbackObjects(osg::Object *object, const std::string &name, osg::Parameters &inputParameters, osg::Parameters &outputParameters)
Definition Callback:187
osg::BoundingBoxf
BoundingBoxImpl< Vec3f > BoundingBoxf
Definition BoundingBox:251
osg::BoundingSphere
BoundingSphered BoundingSphere
Definition BoundingSphere:314
osg::Parameters
std::vector< osg::ref_ptr< osg::Object > > Parameters
Definition Callback:130
OSGUI_EXPORT
#define OSGUI_EXPORT
Definition osgUI/Export:40
Style
ScriptEngine