44 lines
1.1 KiB
C++
44 lines
1.1 KiB
C++
#ifndef MOUSEPICKER_H
|
|
#define MOUSEPICKER_H
|
|
|
|
#include <QtCore>
|
|
#include <QObject>
|
|
#include <osg/Geode>
|
|
#include <osgGA/GUIEventHandler>
|
|
|
|
enum PickingMode{
|
|
PointPicker = 0,
|
|
LinePicker = 1,
|
|
AreaPicker = 2,
|
|
};
|
|
|
|
class MousePicker : public QObject, public osgGA::GUIEventHandler
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
explicit MousePicker(QObject *parent = nullptr);
|
|
void setRoot(osg::ref_ptr<osg::Group> root = nullptr);
|
|
void activate(PickingMode _mode, osg::Node* model);
|
|
bool handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa );
|
|
void disactivate();
|
|
static osg::ref_ptr<osg::Geometry> createPointGeode(const osg::Vec3 &pos);
|
|
|
|
signals:
|
|
void editionDone(PickingMode, osg::ref_ptr<osg::Vec3Array>);
|
|
|
|
private:
|
|
bool isActivated = false;
|
|
bool isDrawing = false;
|
|
PickingMode mode;
|
|
|
|
osg::Vec3 pushPnt;
|
|
osg::ref_ptr<osg::Node> model;
|
|
osg::ref_ptr<osg::Group> drawNodeList = new osg::Group;
|
|
osg::ref_ptr<osg::Geode> currentDrawNode = new osg::Geode;
|
|
osg::ref_ptr<osg::Geometry> lineGeometry;
|
|
osg::ref_ptr<osg::Vec3Array> vertexArray;
|
|
};
|
|
|
|
|
|
#endif // MOUSEPICKER_H
|