PickHandler.hpp 928 B

1234567891011121314151617181920212223242526272829303132
  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. double _optiTrackSteamVRLength;
  22. int _selectedPoint = -1;
  23. void moveTo(osg::Vec3f position);
  24. void rotateToNormalVector(osg::Vec3f normal);
  25. void setVisibility(bool mode);
  26. void addPoint(osg::Vec3 point, osg::Vec3 normal);
  27. void invalidateTrackPointColors();
  28. };