-
Notifications
You must be signed in to change notification settings - Fork 0
/
topologymanager.cpp
88 lines (71 loc) · 2.79 KB
/
topologymanager.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#include "topologymanager.h"
TopologyManager::TopologyManager()
{
}
TopologyManager* TopologyManager::manager = nullptr;
TopologyManager* TopologyManager::getManager() {
if (manager == nullptr) manager = new TopologyManager;
return manager;
}
void TopologyManager::setSelectedEntity(Entity* entity) {
this->selected_entity = entity;
}
Entity* TopologyManager::getSelectedEntity() {
return selected_entity;
}
void TopologyManager::setTopologyCondition(TopologyCondition condition) {
this->topology_condition = condition;
}
TopologyCondition TopologyManager::getTopologyCondition() {
return topology_condition;
}
void TopologyManager::setDrawingStage(DrawingStage stage) {
this->drawing_stage = stage;
}
DrawingStage TopologyManager::getDrawingStage() {
return drawing_stage;
}
bool TopologyManager::isAcceptedTopology(LineEntity* entity) {
qDebug() << __FUNCTION__ << "(Line)";
if (topology_condition == TopologyCondition::NoTopology) return true;
Entity* selected_entity = getSelectedEntity();
if (selected_entity == nullptr) return true;
TopologyCheckResult res = selected_entity->checkTopologyCondition(entity);
if (res == TopologyCheckResult::Rejected) return false;
return true;
}
bool TopologyManager::isAcceptedTopology(PointEntity* entity) {
qDebug() << __FUNCTION__ << "(Point)";
if (topology_condition == TopologyCondition::NoTopology) return true;
Entity* selected_entity = getSelectedEntity();
if (selected_entity == nullptr) return true;
TopologyCheckResult res = selected_entity->checkTopologyCondition(entity);
if (res == TopologyCheckResult::Rejected) return false;
return true;
}
bool TopologyManager::isAcceptedTopology(PolygonEntity* entity) {
qDebug() << __FUNCTION__ << "(Polygon)";
if (topology_condition == TopologyCondition::NoTopology) return true;
Entity* selected_entity = getSelectedEntity();
if (selected_entity == nullptr) return true;
TopologyCheckResult res = selected_entity->checkTopologyCondition(entity);
if (res == TopologyCheckResult::Rejected) return false;
return true;
}
bool TopologyManager::isAcceptedTopology(PolylineEntity* entity) {
qDebug() << __FUNCTION__ << "(Polyline)";
if (topology_condition == TopologyCondition::NoTopology) return true;
Entity* selected_entity = getSelectedEntity();
qDebug() << selected_entity;
if (selected_entity == nullptr) return true;
qDebug() << selected_entity;
TopologyCheckResult res = selected_entity->checkTopologyCondition(entity);
if (res == TopologyCheckResult::Rejected) return false;
return true;
}
int TopologyManager::getNeighbourhoodThreshold() {
return neighbourhood_threshhold;
}
void TopologyManager::setNeighbourhoodThreshold(int threshold) {
this->neighbourhood_threshhold = threshold;
}