-
Notifications
You must be signed in to change notification settings - Fork 1
/
navmesh_render_area_base.cpp
149 lines (120 loc) · 3.57 KB
/
navmesh_render_area_base.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#include "navmesh_render_area_base.hpp"
#include <absl/log/log.h>
#include <absl/strings/str_format.h>
void NavmeshRenderAreaBase::resetZoom() {
zoomLevel_ = 0;
resizeForNewZoom();
}
void NavmeshRenderAreaBase::zoomIn(double zoomDiff) {
zoomLevel_ += zoomDiff;
resizeForNewZoom();
}
void NavmeshRenderAreaBase::zoomOut(double zoomDiff) {
zoomLevel_ -= zoomDiff;
resizeForNewZoom();
}
bool NavmeshRenderAreaBase::getDisplayVertices() const {
return displayVertices_;
}
bool NavmeshRenderAreaBase::getDisplayNonConstraintEdges() const {
return displayNonConstraintEdges_;
}
bool NavmeshRenderAreaBase::getDisplayTriangleLabels() const {
return displayTriangleLabels_;
}
bool NavmeshRenderAreaBase::getDisplayEdgeLabels() const {
return displayEdgeLabels_;
}
bool NavmeshRenderAreaBase::getDisplayVertexLabels() const {
return displayVertexLabels_;
}
QSize NavmeshRenderAreaBase::currentSize() const {
double scale = getScale();
return QSize(widgetBaseWidth_*scale, widgetBaseHeight_*scale);
}
void NavmeshRenderAreaBase::resizeForNewZoom() {
const auto size = currentSize();
setMinimumSize(size);
resize(size);
updateGeometry();
update();
}
double NavmeshRenderAreaBase::getScale() const {
return qPow(2.0, zoomLevel_);
}
QColor NavmeshRenderAreaBase::getColorForEdgeMarker(const int marker) {
if (marker == 0) {
// Non-constraint edge
return QColor{150,255,150};
}
if (marker == 1) {
// Triangulation-inserted boundary
return QColor{100,100,100};
}
// User defined constraint
return QColor{255,0,0};
}
void NavmeshRenderAreaBase::setAgentRadius(double agentRadius) {
agentRadius_ = agentRadius;
update();
}
void NavmeshRenderAreaBase::setPathStartPoint(const pathfinder::Vector &point) {
startPoint_ = point;
update();
}
void NavmeshRenderAreaBase::setPathGoalPoint(const pathfinder::Vector &point) {
goalPoint_ = point;
update();
}
void NavmeshRenderAreaBase::addPairsDistance(double x, double y, double distance) {
if (distance != std::numeric_limits<double>::max() &&
distance != std::numeric_limits<double>::lowest()) {
allPairsMaxDistance_ = std::max(allPairsMaxDistance_, distance);
}
allPairsRowToColToDistanceMap_[x][y] = distance;
update();
}
void NavmeshRenderAreaBase::resetAllPairsDistanceMap() {
allPairsMaxDistance_ = 0.0;
allPairsRowToColToDistanceMap_.clear();
}
void NavmeshRenderAreaBase::resetPathStart() {
startPoint_.reset();
}
void NavmeshRenderAreaBase::resetPathGoal() {
goalPoint_.reset();
}
void NavmeshRenderAreaBase::setHandleMouseDrag(bool enabled) {
handleMouseDrag_ = enabled;
}
void NavmeshRenderAreaBase::setHandleMouseClick(bool enabled) {
handleMouseClick_ = enabled;
}
void NavmeshRenderAreaBase::setDisplayVertices(bool shouldDisplay) {
displayVertices_ = shouldDisplay;
update();
}
void NavmeshRenderAreaBase::setDisplayNonConstraintEdges(bool shouldDisplay) {
displayNonConstraintEdges_ = shouldDisplay;
update();
}
void NavmeshRenderAreaBase::setDisplayTriangleLabels(bool shouldDisplay) {
displayTriangleLabels_ = shouldDisplay;
update();
}
void NavmeshRenderAreaBase::setDisplayEdgeLabels(bool shouldDisplay) {
displayEdgeLabels_ = shouldDisplay;
update();
}
void NavmeshRenderAreaBase::setDisplayVertexLabels(bool shouldDisplay) {
displayVertexLabels_ = shouldDisplay;
update();
}
void NavmeshRenderAreaBase::setAllPairsShowNoPathToGoal(bool shouldDisplay) {
displayAllPairsNoPathToGoal_ = shouldDisplay;
update();
}
void NavmeshRenderAreaBase::setAllPairsShowException(bool shouldDisplay) {
displayAllPairsException_ = shouldDisplay;
update();
}