ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
ccMouseCircle.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #pragma once
9 
15 #include <ecv2DViewportObject.h>
16 #include <ecvDisplayTools.h>
17 #include <ecvStdPluginInterface.h>
18 
19 // Qt
20 #include <QEvent>
21 #include <QObject>
22 #include <QPoint>
23 
24 class ccMouseCircle : public cc2DViewportObject, public QObject {
25 public:
26  // constructor
27  explicit ccMouseCircle(ecvMainAppInterface* appInterface,
28  QWidget* owner,
29  QString name = QString("MouseCircle"));
30 
31  // deconstructor
33 
34  // get the circle radius in px
35  inline int getRadiusPx() const { return m_radius; }
36 
37  // get the circle radius in world coordinates
38  float getRadiusWorld();
39 
40  // removes the link with the owner (no cleanup)
41  inline void ownerIsDead() { m_owner = nullptr; }
42 
43  // sets whether scroll is allowed or not
44  inline void setAllowScroll(bool state) { m_allowScroll = state; }
45 
46 protected:
47  // draws a circle of radius r around the mouse
48  void draw(CC_DRAW_CONTEXT& context) override;
49 
50 private:
51  ecvMainAppInterface* m_app;
52 
53  QWidget* m_owner;
54 
55  float m_pixelSize;
56 
57  // event to get mouse-move updates & trigger repaint
58  bool eventFilter(QObject* obj, QEvent* event) override;
59 
60  int m_radius;
61  int m_radiusStep;
62  bool m_allowScroll;
63 };
MouseEvent event
std::string name
2D viewport object
void ownerIsDead()
Definition: ccMouseCircle.h:41
void draw(CC_DRAW_CONTEXT &context) override
Draws entity and its children.
ccMouseCircle(ecvMainAppInterface *appInterface, QWidget *owner, QString name=QString("MouseCircle"))
float getRadiusWorld()
int getRadiusPx() const
Definition: ccMouseCircle.h:35
void setAllowScroll(bool state)
Definition: ccMouseCircle.h:44
Main application interface (for plugins)
ImGuiContext * context
Definition: Window.cpp:76
Display context.