ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
ccLineationTool.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 "ccLineationTool.h"
9 
10 #include "ccCompass.h"
11 
13 
15 
16 // called when the tool is set to disactive (for cleanup)
18 
19 // called when a point in a point cloud gets picked while this tool is active
21  unsigned itemIdx,
22  ccPointCloud* cloud,
23  const CCVector3& P) {
24  // try retrieve active lineation (will fail if there isn't one)
25  ccLineation* l = dynamic_cast<ccLineation*>(
27  if (!l) // make a new one
28  {
29  // no active trace -> make a new one
30  l = new ccLineation(cloud);
32 
33  // set drawing properties
34  // l->setDisplay(m_window);
35  l->setVisible(true);
36  l->setName("Lineation");
37  // l->prepareDisplayForRefresh_recursive();
38 
39  // add to DB Tree
40  insertPoint->addChild(l);
41  m_app->addToDB(l, false, false, false, false);
42  }
43 
44  // add point
45  int index = l->addPointIndex(itemIdx);
46 
47  // is this the end point?
48  if (l->size() == 2) {
49  l->updateMetadata(); // calculate orientation & store. Also changes the
50  // name.
52 
53  // report orientation to console for convenience
54  m_app->dispToConsole(QString("[ccCompass] Lineation = " + l->getName()),
56 
57  // start new lineation
58  m_lineation_id = -1;
59  }
60 }
61 
62 // called when "Return" or "Space" is pressed, or the "Accept Button" is clicked
64  cancel(); // removes any incomplete lineations
65 }
66 
67 // called when the "Escape" is pressed, or the "Cancel" button is clicked
69  if (m_lineation_id != -1) // there is an active lineation
70  {
71  ccPointPair* l = dynamic_cast<ccPointPair*>(
73  if (l && l->size() < 2) {
74  m_app->removeFromDB(l); // remove incomplete lineation
75  m_lineation_id = -1;
76  }
77  }
78 }
static bool drawName
Definition: ccCompass.h:258
virtual void setVisible(bool state)
Sets entity visibility.
virtual void showNameIn3D(bool state)
Sets whether name should be displayed in 3D.
Hierarchical CLOUDVIEWER Object.
Definition: ecvHObject.h:25
ccHObject * find(unsigned uniqueID)
Finds an entity in this object hierarchy.
virtual bool addChild(ccHObject *child, int dependencyFlags=DP_PARENT_OF_OTHER, int insertIndex=-1)
Adds a child.
void pointPicked(ccHObject *insertPoint, unsigned itemIdx, ccPointCloud *cloud, const CCVector3 &P) override
void cancel() override
void toolDisactivated() override
virtual ~ccLineationTool()
void accept() override
void updateMetadata() override
Definition: ccLineation.cpp:20
virtual QString getName() const
Returns object name.
Definition: ecvObject.h:72
virtual unsigned getUniqueID() const
Returns object unique ID.
Definition: ecvObject.h:86
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.
unsigned size() const override
Returns the number of points.
virtual ccHObject * dbRootObject()=0
Returns DB root (as a ccHObject)
virtual void addToDB(ccHObject *obj, bool updateZoom=false, bool autoExpandDBTree=true, bool checkDimensions=false, bool autoRedraw=true)=0
virtual void dispToConsole(QString message, ConsoleMessageLevel level=STD_CONSOLE_MESSAGE)=0
virtual void removeFromDB(ccHObject *obj, bool autoDelete=true)=0
Removes an entity from main db tree.