ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
ccTool.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 <ecvDisplayTools.h>
11 #include <ecvHObject.h>
12 #include <ecvMainAppInterface.h>
13 #include <ecvPointCloud.h>
14 
15 /*
16 Template class that defining the basic functionality of qCompass "tools".
17 */
18 class ccTool {
19 public:
20  virtual ~ccTool() {}
21 
23  m_app = app; // store copy of app
25  }
26 
27  // called when the tool is set to active (for initialization)
28  virtual void toolActivated() {}
29 
30  // called when the tool is set to disactive (for cleanup)
31  virtual void toolDisactivated() {}
32 
33  // called when a point in a point cloud gets picked while this tool is
34  // active
35  virtual void pointPicked(ccHObject* insertPoint,
36  unsigned itemIdx,
37  ccHObject* pickedObject,
38  const CCVector3& P) {}
39 
40  // called when a point in a point cloud gets picked while this tool is
41  // active
42  virtual void pointPicked(ccHObject* insertPoint,
43  unsigned itemIdx,
44  ccPointCloud* cloud,
45  const CCVector3& P) {}
46 
47  // called when the selection is changed while this tool is active
48  virtual void onNewSelection(const ccHObject::Container& selectedEntities) {}
49 
50  // called when "Return" or "Space" is pressed, or the "Accept Button" is
51  // clicked
52  virtual void accept() {}
53 
54  // called when the "Escape" is pressed, or the "Cancel" button is clicked
55  virtual void cancel() {}
56 
57  // if this returns true, the undo button is enabled in the gui
58  virtual bool canUndo() { return false; }
59 
60  // called when the undo button is clicked
61  virtual void undo() {}
62 
63 protected:
64  ccTool() : m_app(nullptr), m_window(nullptr) {}
65 
66  // link to the main plugin interface
68 
69  // link to the active openGLWindow
70  QWidget* m_window;
71 };
Hierarchical CLOUDVIEWER Object.
Definition: ecvHObject.h:25
std::vector< ccHObject * > Container
Standard instances container (for children, etc.)
Definition: ecvHObject.h:337
A 3D cloud and its associated features (color, normals, scalar fields, etc.)
Definition: ccTool.h:18
virtual bool canUndo()
Definition: ccTool.h:58
virtual void onNewSelection(const ccHObject::Container &selectedEntities)
Definition: ccTool.h:48
ecvMainAppInterface * m_app
Definition: ccTool.h:67
virtual void toolActivated()
Definition: ccTool.h:28
virtual void undo()
Definition: ccTool.h:61
QWidget * m_window
Definition: ccTool.h:70
virtual void accept()
Definition: ccTool.h:52
virtual void pointPicked(ccHObject *insertPoint, unsigned itemIdx, ccHObject *pickedObject, const CCVector3 &P)
Definition: ccTool.h:35
virtual void toolDisactivated()
Definition: ccTool.h:31
virtual void cancel()
Definition: ccTool.h:55
void initializeTool(ecvMainAppInterface *app)
Definition: ccTool.h:22
virtual void pointPicked(ccHObject *insertPoint, unsigned itemIdx, ccPointCloud *cloud, const CCVector3 &P)
Definition: ccTool.h:42
virtual ~ccTool()
Definition: ccTool.h:20
ccTool()
Definition: ccTool.h:64
static QWidget * GetCurrentScreen()
Main application interface (for plugins)