ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
ccTopologyTool.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 "ccTopologyTool.h"
9 
10 #include "ccCompass.h"
11 
13 
15 
17 
18 // called when the selection is changed while this tool is active
20  const ccHObject::Container& selectedEntities) {
21  if (selectedEntities.size() == 0) return;
22 
23  // is selection a geoObject?
24  ccGeoObject* o = ccGeoObject::getGeoObjectParent(selectedEntities[0]);
25  if (o) {
26  // yes it is a GeoObject - have we got a first point?
28  if (!first) // no... this is the first point (m_firstPick is invalid)
29  {
30  m_firstPick = o->getUniqueID();
31 
32  // write instructions to screen
34  "Select second (younger) GeoObject.",
36  } else // yes.. this is the second pick
37  {
38  ccGeoObject* g1 = static_cast<ccGeoObject*>(
39  first); // n.b. this *should* always be a GeoObject....
40 
41  // add topology relation!
43 
44  // reset...
45  accept();
46  }
47  } else {
48  // no - throw error
49  m_app->dispToConsole("[ccCompass] Please select a GeoObject",
51  }
52 }
53 
54 // called when the tool is set to active (for initialization)
56  // display instructions
57  ecvDisplayTools::DisplayNewMessage("Select first (older) GeoObject.",
59 }
60 
61 // called when the tool is set to disactive (for cleanup)
63  m_firstPick = -1; // reset
64 }
65 
66 // called when "Return" or "Space" is pressed, or the "Accept Button" is clicked
68  // Reset the tool
70 
71  // restart picking mode
72  toolActivated();
73 }
74 
75 // called when the "Escape" is pressed, or the "Cancel" button is clicked
static ccGeoObject * getGeoObjectParent(ccHObject *object)
ccTopologyRelation * addRelationTo(ccGeoObject *obj2, int type, ecvMainAppInterface *app)
Hierarchical CLOUDVIEWER Object.
Definition: ecvHObject.h:25
ccHObject * find(unsigned uniqueID)
Finds an entity in this object hierarchy.
std::vector< ccHObject * > Container
Standard instances container (for children, etc.)
Definition: ecvHObject.h:337
virtual unsigned getUniqueID() const
Returns object unique ID.
Definition: ecvObject.h:86
Definition: ccTool.h:18
ecvMainAppInterface * m_app
Definition: ccTool.h:67
static const int YOUNGER_THAN
void cancel() override
static int RELATIONSHIP
virtual void toolActivated() override
virtual ~ccTopologyTool()
virtual void onNewSelection(const ccHObject::Container &selectedEntities) override
void accept() override
virtual void toolDisactivated() override
static void DisplayNewMessage(const QString &message, MessagePosition pos, bool append=false, int displayMaxDelay_sec=2, MessageType type=CUSTOM_MESSAGE)
Displays a status message in the bottom-left corner.
virtual ccHObject * dbRootObject()=0
Returns DB root (as a ccHObject)
virtual void dispToConsole(QString message, ConsoleMessageLevel level=STD_CONSOLE_MESSAGE)=0