ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
ccPinchNodeTool.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 "ccPinchNodeTool.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 insert-point if there is an active GeoObject
20  ccGeoObject* geoObj = ccGeoObject::getGeoObjectParent(insertPoint);
21  if (geoObj) // there is an active GeoObject
22  {
23  insertPoint = geoObj->getRegion(
24  ccGeoObject::INTERIOR); // add pinch-points to GeoObject
25  // interior
26  } else {
27  // throw error
29  "[Compass] PinchNodes can only be added to GeoObjects. Please "
30  "select one!",
32  return;
33  }
34 
35  // create a 1-point lineation object (highlights node-location)
36  ccPointPair* l = new ccPinchNode(cloud);
37  l->setName("tip");
38  l->showNameIn3D(false);
39  l->addPointIndex(itemIdx);
40 
41  // add to scene graph
42  insertPoint->addChild(l);
43  m_app->addToDB(l);
44 }
45 
46 // called when the tool is set to active (for initialization)
48  // donothing
49 }
50 
51 // called when the tool is set to disactive (for cleanup)
53  // donothing
54 }
virtual void showNameIn3D(bool state)
Sets whether name should be displayed in 3D.
static ccGeoObject * getGeoObjectParent(ccHObject *object)
static const int INTERIOR
Definition: ccGeoObject.h:54
ccHObject * getRegion(int mappingRegion)
Definition: ccGeoObject.cpp:73
Hierarchical CLOUDVIEWER Object.
Definition: ecvHObject.h:25
virtual bool addChild(ccHObject *child, int dependencyFlags=DP_PARENT_OF_OTHER, int insertIndex=-1)
Adds a child.
virtual void setName(const QString &name)
Sets object name.
Definition: ecvObject.h:75
virtual void toolActivated() override
void pointPicked(ccHObject *insertPoint, unsigned itemIdx, ccPointCloud *cloud, const CCVector3 &P) override
virtual ~ccPinchNodeTool()
virtual void toolDisactivated() override
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 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