ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
ecvPickingHub.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 
10 #include "CVPluginAPI.h"
11 
12 // Local
13 #include "ecvPickingListener.h"
14 
15 // CV_DB_LIB
16 #include <ecvDisplayTools.h>
17 
18 // Qt
19 #include <QObject>
20 
21 // system
22 #include <set>
23 
24 class ccHObject;
25 class QMdiSubWindow;
27 
29 class CVPLUGIN_LIB_API ccPickingHub : public QObject {
30  Q_OBJECT
31 
32 public:
34  ccPickingHub(ecvMainAppInterface* app, QObject* parent = nullptr);
35  ~ccPickingHub() override = default;
36 
38  inline size_t listenerCount() const { return m_listeners.size(); }
39 
41 
48  bool addListener(ccPickingListener* listener,
49  bool exclusive = false,
50  bool autoStartPicking = true,
53 
55 
59  void removeListener(ccPickingListener* listener,
60  bool autoStopPickingIfLast = true);
61 
62  // //! Sets the default picking mode
63  // /** \param mode picking mode
64  // \param autoEnableOnActivatedWindow whether picking mode should
65  // be enabled automatically on newly activated windows (if listeners are
66  // present only)
67  // **/
68  // DGM: too dangerous, we can't change this behavior on the fly
69 
71  void togglePickingMode(bool state);
72 
74  QWidget* activeWindow() const { return m_activeWindow; }
75 
78  bool isLocked() const { return m_exclusive && !m_listeners.empty(); }
79 
80 public slots:
81 
82  void onActiveWindowChanged(QMdiSubWindow*);
83  void onActiveWindowDeleted(QObject*);
84  void processPickedItem(ccHObject*, unsigned, int, int, const CCVector3&);
85 
86 protected:
88  std::set<ccPickingListener*> m_listeners;
89 
92 
94  QWidget* m_activeWindow;
95 
98 
101 
104 };
ccPickingHub::listenerCount
size_t listenerCount() const
Returns the number of currently registered listeners.
Definition: ecvPickingHub.h:38
ccPickingHub::m_autoEnableOnActivatedWindow
bool m_autoEnableOnActivatedWindow
Automatically enables the picking mechanism on activated GL windows.
Definition: ecvPickingHub.h:100
CVPluginAPI.h
CVPLUGIN_LIB_API
#define CVPLUGIN_LIB_API
Definition: CVPluginAPI.h:15
ccPickingHub::m_app
ecvMainAppInterface * m_app
Associated application.
Definition: ecvPickingHub.h:91
ecvDisplayTools.h
ccPickingListener
Point/triangle picking listener interface.
Definition: ecvPickingListener.h:21
ccPickingHub::m_listeners
std::set< ccPickingListener * > m_listeners
Listeners.
Definition: ecvPickingHub.h:88
slots
#define slots
Definition: PythonPlugin.cpp:25
ecvMainAppInterface
Main application interface (for plugins)
Definition: ecvMainAppInterface.h:24
ccPickingHub::m_pickingMode
ecvDisplayTools::PICKING_MODE m_pickingMode
Default picking mode.
Definition: ecvPickingHub.h:97
Vector3Tpl< PointCoordinateType >
ccPickingHub::m_exclusive
bool m_exclusive
Exclusive mode.
Definition: ecvPickingHub.h:103
ecvDisplayTools::POINT_OR_TRIANGLE_PICKING
@ POINT_OR_TRIANGLE_PICKING
Definition: ecvDisplayTools.h:124
ccPickingHub::isLocked
bool isLocked() const
Definition: ecvPickingHub.h:78
ecvPickingListener.h
ecvDisplayTools::PICKING_MODE
PICKING_MODE
Picking mode.
Definition: ecvDisplayTools.h:117
ccPickingHub
Point/triangle picking hub.
Definition: ecvPickingHub.h:29
ccHObject
Hierarchical CLOUDVIEWER Object.
Definition: ecvHObject.h:25
ccPickingHub::activeWindow
QWidget * activeWindow() const
Returns the currently active window.
Definition: ecvPickingHub.h:74
ccPickingHub::m_activeWindow
QWidget * m_activeWindow
Active window.
Definition: ecvPickingHub.h:94