Files
OpenSceneGraph/include/osgGA/StateSetManipulator
Robert Osfield ba7d27c9b2 From Chris Hanson, "These changes break out the implementation of the fill/wireframe/point, texture,
lighting and backface culling settings from the event handling code in StatesetManipulator
into public methods. The event handler now calls the public methods. This allows user code
to invoke this same functionality from non-keyboard event inputs without clashing with the
keyboard-invoked functionality."

From Robert Osfield, tweaks to the above to kepp the coding style the same as the rest of the OSG, also
made getPolygonMode() const, and updated the wrappers.
2006-10-01 19:19:31 +00:00

92 lines
2.9 KiB
C++

/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 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 OSGGA_GEOSTATE_MANIPULATOR
#define OSGGA_GEOSTATE_MANIPULATOR 1
#include <osgGA/Export>
#include <osgGA/GUIEventAdapter>
#include <osgGA/GUIActionAdapter>
#include <osgGA/GUIEventHandler>
#include <osg/StateSet>
#include <osg/PolygonMode>
namespace osgGA{
/**
Experimental class, not been looked at for a while, but which will
be returned to at some point :-\
*/
class OSGGA_EXPORT StateSetManipulator : public GUIEventHandler
{
public:
StateSetManipulator();
virtual ~StateSetManipulator();
virtual const char* className() const { return "StateSetManipulator"; }
/** attach a geostate to the manipulator to be used for specifying view.*/
virtual void setStateSet(osg::StateSet*);
/** get the attached a geostate.*/
virtual osg::StateSet * getStateSet();
/** get the attached a geostate.*/
virtual const osg::StateSet * getStateSet() const;
/** Handle events, return true if handled, false otherwise.*/
virtual bool handle(const GUIEventAdapter& ea,GUIActionAdapter& us);
/** Handle visitations */
virtual void accept(GUIEventHandlerVisitor&);
/** Get the keyboard and mouse usage of this manipulator.*/
virtual void getUsage(osg::ApplicationUsage& usage) const;
void setMaximumNumOfTextureUnits(unsigned int i) { _maxNumOfTextureUnits = i; }
unsigned int getMaximumNumOfTextureUnits() const { return _maxNumOfTextureUnits; }
void setBackfaceEnabled(bool newbackface);
bool getBackfaceEnabled() const {return _backface;};
void setLightingEnabled(bool newlighting);
bool getLightingEnabled() const {return _lighting;};
void setTextureEnabled(bool newtexture);
bool getTextureEnabled() const {return _texture;};
void setPolygonMode(osg::PolygonMode::Mode newpolygonmode);
osg::PolygonMode::Mode getPolygonMode() const;
void cyclePolygonMode();
protected:
// Reference pointer to a geostate
osg::ref_ptr<osg::StateSet> _drawState;
bool _backface;
bool _lighting;
bool _texture;
unsigned int _maxNumOfTextureUnits;
osg::PolygonMode* getOrCreatePolygonMode();
};
}
#endif