ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
ccNoteTool.cpp
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 #include "ccNoteTool.h"
9 
11 
13 
14 // called when a point in a point cloud gets picked while this tool is active
16  unsigned itemIdx,
17  ccPointCloud* cloud,
18  const CCVector3& P) {
19  // get note text
20  QString note = QInputDialog::getText(m_app->getMainWindow(), "Note",
21  "Contents:", QLineEdit::Normal,
22  "Write note here.");
23 
24  if (note == "") {
25  return;
26  }
27 
28  // create a 1-point lineation object (highlights note-location)
29  ccPointPair* l = new ccNote(cloud);
30  l->setName(note);
31  l->addPointIndex(itemIdx);
32 
33  // find insert point
34  ccHObject* notesFolder = nullptr;
35  for (unsigned i = 0; i < m_app->dbRootObject()->getChildrenNumber(); i++) {
36  if (m_app->dbRootObject()->getChild(i)->getName() == "notes") {
37  notesFolder = m_app->dbRootObject()->getChild(i);
38  } else {
39  // also search first-level children of root node (when files are
40  // re-loaded this is where things will sit)
41  for (unsigned c = 0;
42  c < m_app->dbRootObject()->getChild(i)->getChildrenNumber();
43  c++) {
44  if (m_app->dbRootObject()
45  ->getChild(i)
46  ->getChild(c)
47  ->getName() == "notes") {
48  notesFolder =
50  break;
51  }
52  }
53  }
54  if (notesFolder) // found one :)
55  {
56  break;
57  }
58  }
59  if (!notesFolder) {
60  notesFolder = new ccHObject("notes");
61  m_app->dbRootObject()->addChild(notesFolder);
62  m_app->addToDB(notesFolder, false, false, false, false);
63  }
64 
65  // add to scene graph
66  notesFolder->addChild(l);
67  m_app->addToDB(l);
68 }
69 
70 // called when the tool is set to active (for initialization)
72  // donothing
73 }
74 
75 // called when the tool is set to disactive (for cleanup)
77  // donothing
78 }
Hierarchical CLOUDVIEWER Object.
Definition: ecvHObject.h:25
virtual bool addChild(ccHObject *child, int dependencyFlags=DP_PARENT_OF_OTHER, int insertIndex=-1)
Adds a child.
ccHObject * getChild(unsigned childPos) const
Returns the ith child.
Definition: ecvHObject.h:325
virtual ~ccNoteTool()
Definition: ccNoteTool.cpp:12
virtual void toolActivated() override
Definition: ccNoteTool.cpp:71
virtual void toolDisactivated() override
Definition: ccNoteTool.cpp:76
void pointPicked(ccHObject *insertPoint, unsigned itemIdx, ccPointCloud *cloud, const CCVector3 &P) override
Definition: ccNoteTool.cpp:15
Definition: ccNote.h:17
virtual QString getName() const
Returns object name.
Definition: ecvObject.h:72
virtual void setName(const QString &name)
Sets object name.
Definition: ecvObject.h:75
A 3D cloud and its associated features (color, normals, scalar fields, etc.)
Definition: ccTool.h:18
ecvMainAppInterface * m_app
Definition: ccTool.h:67
virtual bool addPointIndex(unsigned globalIndex)
Point global index insertion mechanism.
virtual ccHObject * dbRootObject()=0
Returns DB root (as a ccHObject)
virtual QMainWindow * getMainWindow()=0
Returns main window.
virtual void addToDB(ccHObject *obj, bool updateZoom=false, bool autoExpandDBTree=true, bool checkDimensions=false, bool autoRedraw=true)=0