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
12
int
ccTopologyTool::RELATIONSHIP
=
ccTopologyRelation::YOUNGER_THAN
;
13
14
ccTopologyTool::ccTopologyTool
() :
ccTool
() {}
15
16
ccTopologyTool::~ccTopologyTool
() {}
17
18
// called when the selection is changed while this tool is active
19
void
ccTopologyTool::onNewSelection
(
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?
27
ccHObject
* first =
m_app
->
dbRootObject
()->
find
(
m_firstPick
);
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
33
ecvDisplayTools::DisplayNewMessage
(
34
"Select second (younger) GeoObject."
,
35
ecvDisplayTools::LOWER_LEFT_MESSAGE
);
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!
42
g1->
addRelationTo
(o,
ccTopologyTool::RELATIONSHIP
,
m_app
);
43
44
// reset...
45
accept
();
46
}
47
}
else
{
48
// no - throw error
49
m_app
->
dispToConsole
(
"[ccCompass] Please select a GeoObject"
,
50
ecvMainAppInterface::ERR_CONSOLE_MESSAGE
);
51
}
52
}
53
54
// called when the tool is set to active (for initialization)
55
void
ccTopologyTool::toolActivated
() {
56
// display instructions
57
ecvDisplayTools::DisplayNewMessage
(
"Select first (older) GeoObject."
,
58
ecvDisplayTools::LOWER_LEFT_MESSAGE
);
59
}
60
61
// called when the tool is set to disactive (for cleanup)
62
void
ccTopologyTool::toolDisactivated
() {
63
m_firstPick
= -1;
// reset
64
}
65
66
// called when "Return" or "Space" is pressed, or the "Accept Button" is clicked
67
void
ccTopologyTool::accept
() {
68
// Reset the tool
69
toolDisactivated
();
70
71
// restart picking mode
72
toolActivated
();
73
}
74
75
// called when the "Escape" is pressed, or the "Cancel" button is clicked
76
void
ccTopologyTool::cancel
() {
toolDisactivated
(); }
ccCompass.h
ccTopologyTool.h
ccGeoObject
Definition:
ccGeoObject.h:26
ccGeoObject::getGeoObjectParent
static ccGeoObject * getGeoObjectParent(ccHObject *object)
Definition:
ccGeoObject.cpp:382
ccGeoObject::addRelationTo
ccTopologyRelation * addRelationTo(ccGeoObject *obj2, int type, ecvMainAppInterface *app)
Definition:
ccGeoObject.cpp:162
ccHObject
Hierarchical CLOUDVIEWER Object.
Definition:
ecvHObject.h:25
ccHObject::find
ccHObject * find(unsigned uniqueID)
Finds an entity in this object hierarchy.
ccHObject::Container
std::vector< ccHObject * > Container
Standard instances container (for children, etc.)
Definition:
ecvHObject.h:337
ccObject::getUniqueID
virtual unsigned getUniqueID() const
Returns object unique ID.
Definition:
ecvObject.h:86
ccTool
Definition:
ccTool.h:18
ccTool::m_app
ecvMainAppInterface * m_app
Definition:
ccTool.h:67
ccTopologyRelation::YOUNGER_THAN
static const int YOUNGER_THAN
Definition:
ccTopologyRelation.h:61
ccTopologyTool::cancel
void cancel() override
Definition:
ccTopologyTool.cpp:76
ccTopologyTool::RELATIONSHIP
static int RELATIONSHIP
Definition:
ccTopologyTool.h:45
ccTopologyTool::toolActivated
virtual void toolActivated() override
Definition:
ccTopologyTool.cpp:55
ccTopologyTool::m_firstPick
int m_firstPick
Definition:
ccTopologyTool.h:43
ccTopologyTool::~ccTopologyTool
virtual ~ccTopologyTool()
Definition:
ccTopologyTool.cpp:16
ccTopologyTool::onNewSelection
virtual void onNewSelection(const ccHObject::Container &selectedEntities) override
Definition:
ccTopologyTool.cpp:19
ccTopologyTool::ccTopologyTool
ccTopologyTool()
Definition:
ccTopologyTool.cpp:14
ccTopologyTool::accept
void accept() override
Definition:
ccTopologyTool.cpp:67
ccTopologyTool::toolDisactivated
virtual void toolDisactivated() override
Definition:
ccTopologyTool.cpp:62
ecvDisplayTools::LOWER_LEFT_MESSAGE
@ LOWER_LEFT_MESSAGE
Definition:
ecvDisplayTools.h:176
ecvDisplayTools::DisplayNewMessage
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.
ecvMainAppInterface::dbRootObject
virtual ccHObject * dbRootObject()=0
Returns DB root (as a ccHObject)
ecvMainAppInterface::ERR_CONSOLE_MESSAGE
@ ERR_CONSOLE_MESSAGE
Definition:
ecvMainAppInterface.h:119
ecvMainAppInterface::dispToConsole
virtual void dispToConsole(QString message, ConsoleMessageLevel level=STD_CONSOLE_MESSAGE)=0
plugins
core
Standard
qCompass
src
ccTopologyTool.cpp
Generated on Wed Jan 28 2026 09:01:07 for ACloudViewer by
1.9.1