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.

86 lines
2.0 KiB
C++

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#pragma once
#include <osgViewer/ViewerEventHandlers>
#include <osg/MatrixTransform>
#include "../XJOSGObject/XJOSGObject.h"
//对象高亮颜色
const osg::Vec4 HIGHTLIGHT_COLOR = osg::Vec4(0.8, 0.0, 0.0, 1.0);
const osg::Vec4 PICKPOINT_COLOR = osg::Vec4(0.0, 0.0, 1.0, 1.0);
// PickHandler用于实现用户选择的GUIEventHandler 派生类。
//现在这个类是没用的
class CXJOSGPickHandler : public osgGA::GUIEventHandler
{
public:
CXJOSGPickHandler();
enum pickMode
{
PICK_OBJECT = 0,
PICK_POINT = 1
};
bool handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa );
// 执行用户选择的操作。
bool pick( const double x, const double y, osgViewer::Viewer* viewer );
//设置选择对象的类型(点还是对象)
void SetPickMode(int pickType) {m_pickType = pickType;}
//获得选中对象上的点
osg::Vec3 GetPickPoint(){return m_pickPoint;}
//判断是否选中对象
bool GetPickResult(){return m_pickResult;}
//获得选中的显示对象
CXJOSGObject * GetPickObject(){return m_pickObject;}
protected:
// 保存鼠标按下和移动时的XY 坐标。
float _mX,_mY;
bool m_pickResult;
osg::Vec3 m_pickPoint;
CXJOSGObject* m_pickObject;
int m_pickType;
};
/**键盘响应事件,用于处理键盘按下时触发的命令*/
class PromptionHandler : public osgGA::GUIEventHandler
{
public:
PromptionHandler(osg::ApplicationUsage* au = 0);
enum HUDCameraType
{
LEFT_UP = 0,
RIGHT_UP = 1,
LEFT_DOWN = 2
};
//用于存储提示信息的容器
typedef std::vector<std::string> PromptionList;
void setKeyEventTogglesOnScreenHelp(int key) { _keyEventTogglesOnScreenHelp = key; }
int getKeyEventTogglesOnScreenHelp() const { return _keyEventTogglesOnScreenHelp; }
void reset();
bool handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa);
void setHUDTextNode(osg::Node* node) {_HUDNode = node;}
protected:
int _keyEventTogglesOnScreenHelp;
bool _promptEnabled;
bool _initialized;
osg::Node* _HUDNode;
};