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.

74 lines
1.9 KiB
C++

#ifndef SELECTIONMANAGER_H
#define SELECTIONMANAGER_H
#include "XJOSGObject/XJOSGObject.h"
#include <osgViewer/Viewer>
#define HILIGHTCOLOR_TRANSPARENT osg::Vec4(0.7, 0.0, 0.0, 0.5)
#define HILIGHTCOLOR_UNTRANSPARENT osg::Vec4(0.7, 0.0, 0.0, 1.0)
//此类中管理选中的对象
class SelectionManager : public osg::Referenced
{
public:
SelectionManager(osgViewer::Viewer* pViewer = NULL);
~SelectionManager();
// if the object is not yet in the selection List, it will be added.
//otherwise it will not be added. In default, we need to hilight the selected obj;
void AddChild(CXJOSGObject* pobj, bool unhilight = false);
//remove all childeren
void RemoveAllChildren();
//remove obj from list
void RemoveChild(CXJOSGObject* pobj);
//return the number of selected list
int NbSelected();
//return the selected obj by index
CXJOSGObject* GetSelectedObj(int index) const;
//Hilight selected obj with color
void HilightWithColor(CXJOSGObject* pobj, osg::Vec4& color = HILIGHTCOLOR_UNTRANSPARENT);
//unlight selected color;
void UnHilightObj(CXJOSGObject* pobj);
//unselect and unHilight all obj from list
void DeSelectSelList();
//set selected obj's visibility in selList
void InvisibleSelList(bool visible);
//set selected obj's transparency in selList
void TransparentSelList(bool transparent);
//set selected obj's wireframe in selList
void WireframeSelList(bool wireframe);
//添加框选网格面片的网格显示对象
void AddToMeshListWithSelectedFaces(CXJOSGObject* pobj);
std::vector<CXJOSGObject*>& GetMeshListsWithSelectedFaces() {return m_MapOfObjWithSelTriangles;}
protected:
//check if obj is in selected list , if has ,return true, else return false
bool Find(const CXJOSGObject* pobj);
private:
std::vector<CXJOSGObject*> m_selObjList; //选中对象列表
std::vector<CXJOSGObject*> m_MapOfObjWithSelTriangles; //有被拾取到网格面片的显示对象
osgViewer::Viewer* m_pViewer;
};
#endif