ccMouseCircle.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #pragma once
  2. //##########################################################################
  3. //# #
  4. //# CLOUDCOMPARE PLUGIN: ccCompass #
  5. //# #
  6. //# This program is free software; you can redistribute it and/or modify #
  7. //# it under the terms of the GNU General Public License as published by #
  8. //# the Free Software Foundation; version 2 of the License. #
  9. //# #
  10. //# This program is distributed in the hope that it will be useful, #
  11. //# but WITHOUT ANY WARRANTY; without even the implied warranty of #
  12. //# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
  13. //# GNU General Public License for more details. #
  14. //# #
  15. //# COPYRIGHT: Sam Thiele 2017 #
  16. //# #
  17. //##########################################################################
  18. /**
  19. This is a custom 2DViewportLabel which takes up the entire viewport but is entirely transparent,
  20. except for a circle with radius r around the mouse.
  21. */
  22. #include <ccGLWindowInterface.h>
  23. #include <cc2DViewportObject.h>
  24. class QEvent;
  25. //Qt
  26. #include <QObject>
  27. class ccMouseCircle : public cc2DViewportObject, public QObject
  28. {
  29. public:
  30. //constructor
  31. explicit ccMouseCircle(ccGLWindowInterface* owner, QString name = QString("MouseCircle"));
  32. //deconstructor
  33. ~ccMouseCircle() override;
  34. //get the circle radius in px
  35. inline int getRadiusPx() const { return m_radius; }
  36. //sets whether scroll is allowed or not
  37. inline void setAllowScroll(bool state) { m_allowScroll = state; }
  38. protected:
  39. //draws a circle of radius r around the mouse
  40. void draw(CC_DRAW_CONTEXT& context) override;
  41. private:
  42. //event to get mouse-move updates & trigger repaint
  43. bool eventFilter(QObject* obj, QEvent* event) override;
  44. private:
  45. //ccGLWindowInterface this overlay is attached to -> used to get mouse position & events
  46. ccGLWindowInterface* m_owner;
  47. float m_pixelSize;
  48. int m_radius;
  49. int m_radiusStep;
  50. bool m_allowScroll;
  51. };