|
|
|
|
|
|
|
|
|
|
|
#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)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>й<EFBFBD><D0B9><EFBFBD>ѡ<EFBFBD>еĶ<D0B5><C4B6><EFBFBD>
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD>ӿ<EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƭ<EFBFBD><C6AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>
|
|
|
|
|
|
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; //ѡ<>ж<EFBFBD><D0B6><EFBFBD><EFBFBD>б<EFBFBD>
|
|
|
|
|
|
std::vector<CXJOSGObject*> m_MapOfObjWithSelTriangles; //<2F>б<EFBFBD>ʰȡ<CAB0><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƭ<EFBFBD><C6AC><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
|
|
osgViewer::Viewer* m_pViewer;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|