PickHandler.hpp 894 B

12345678910111213141516171819202122232425262728293031
  1. #pragma once
  2. // Include modules
  3. #include "MainWindow.hpp"
  4. #include "OSGWidget.hpp"
  5. #include "PointShape.hpp"
  6. // Include dependencies
  7. #include <osgGA/GUIEventHandler>
  8. class PickHandler: public osgGA::GUIEventHandler {
  9. public:
  10. PickHandler(OSGWidget* osgWidget, osg::ref_ptr<osg::Group> root);
  11. osg::Node* getPickerRoot();
  12. virtual bool handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa);
  13. void setSelection(bool addNewPoints);
  14. void updateRenderer();
  15. private:
  16. PointShape* _shape = nullptr;
  17. osg::ref_ptr<osg::Switch> _selectionSwitch;
  18. bool _addNewPoints = true;
  19. bool _clickStartedOnElement = false;
  20. OSGWidget* _osgWidget;
  21. int _selectedPoint = -1;
  22. void moveTo(osg::Vec3f position);
  23. void rotateToNormalVector(osg::Vec3f normal);
  24. void setVisibility(bool mode);
  25. void addPoint(osg::Vec3 point, osg::Vec3 normal);
  26. void invalidateTrackPointColors();
  27. };