You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

153 lines
4.5 KiB
C

1 month ago
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2011
*
* 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 BASEDRAGGER_H
#define BASEDRAGGER_H
#include <osgManipulator/Translate1DDragger>
#include <osgManipulator/Translate2DDragger>
#include <osgManipulator/RotateCylinderDragger>
#include <osgManipulator/RotateSphereDragger>
#include <osgManipulator/Scale1DDragger>
#include <osg/Node>
//#define OSGDRAGGER_DYNAMIC
//#include "Exports.h"
namespace osgDragger
{
//pointDragger
void setMaterialColorExtend(const osg::Vec4& color, osg::Node& node);
class PointDragger : public osgManipulator::Dragger
{
public:
PointDragger();
META_OSGMANIPULATOR_Object(osgDragger, PointDragger);
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Translate1DDragger<65>µ<EFBFBD>handle()<29><><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD>Command
virtual void dispatch(osgManipulator::MotionCommand& command);
/** Handle pick events on dragger and generate TranslateInLine commands. */
virtual bool handle(const osgManipulator::PointerInfo& pi, const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us);
/** Set/Get color for dragger. */
inline void setColor(const osg::Vec4& color) { _color = color; setMaterialColor(_color,*this); }
inline const osg::Vec4& getColor() const { return _color; }
/** Set/Get pick color for dragger. Pick color is color of the dragger when picked.
It gives a visual feedback to show that the dragger has been picked. */
inline void setPickColor(const osg::Vec4& color) { _pickColor = color; }
inline const osg::Vec4& getPickColor() const { return _pickColor; }
protected:
virtual ~PointDragger() {}
osg::Vec3 _startPickedPt;
osg::Vec4 _color;
osg::Vec4 _pickColor;
};
class Move1DDragger : public osgManipulator::Translate1DDragger
{
public:
Move1DDragger();
Move1DDragger(const osg::Vec3d& s, const osg::Vec3d& e);
META_OSGMANIPULATOR_Object(osgDragger,Move1DDragger);
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Translate1DDragger<65>µ<EFBFBD>handle()<29><><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD>Command
virtual void dispatch(osgManipulator::MotionCommand& command);
/** Handle pick events on dragger and generate TranslateInLine commands. */
virtual bool handle(const osgManipulator::PointerInfo& pi, const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us);
void SetStepLenght(double step){ _translationStep = step;}
private:
double _translationStep;
};
class Move2DDragger : public osgManipulator::Translate2DDragger
{
public:
Move2DDragger();
Move2DDragger(const osg::Plane& plane);
META_OSGMANIPULATOR_Object(osgDragger,Move2DDragger);
virtual void dispatch(osgManipulator::MotionCommand& command);
};
class CylinderDragger : public osgManipulator::RotateCylinderDragger
{
public:
CylinderDragger();
META_OSGMANIPULATOR_Object(osgDragger,CylinderDragger);
void SetStepLenght(double step){ _rotateStep = step;}
protected:
virtual bool handle(const osgManipulator::PointerInfo& pointer, const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa) override;
virtual void dispatch(osgManipulator::MotionCommand& command);
double _rotateStep;
};
class SphereDragger : public osgManipulator::RotateSphereDragger
{
public:
SphereDragger();
META_OSGMANIPULATOR_Object(osgDragger,SphereDragger);
virtual void dispatch(osgManipulator::MotionCommand& command);
};
class BaseDragger : public osgManipulator::CompositeDragger
{
public:
META_OSGMANIPULATOR_Object(osgDragger,BaseDragger)
virtual bool handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa);
virtual bool handle(const osgManipulator::PointerInfo& pi, const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa);
virtual void handlePushMessage(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa){};
virtual void handleDragMessage(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa){};
virtual void handleReleaseMessage(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa);
void setIntersectionCamera(osg::Camera* camera);
protected:
BaseDragger();
virtual ~BaseDragger();
osg::observer_ptr<osg::Camera> _intersectionCamera;
};
} //end namespace
#endif // BASEDRAGGER_H