-
Notifications
You must be signed in to change notification settings - Fork 1
/
navmesh_render_area_base.hpp
104 lines (82 loc) · 3.06 KB
/
navmesh_render_area_base.hpp
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
#ifndef NAVMESH_RENDER_AREA_BASE_HPP_
#define NAVMESH_RENDER_AREA_BASE_HPP_
#include <Pathfinder/vector.h>
#include <QColor>
#include <QString>
#include <QTimer>
#include <QWidget>
#include <map>
class NavmeshRenderAreaBase : public QWidget {
Q_OBJECT
public:
using QWidget::QWidget;
void resetZoom();
void zoomIn(double zoomDiff);
void zoomOut(double zoomDiff);
bool getDisplayVertices() const;
bool getDisplayNonConstraintEdges() const;
bool getDisplayTriangleLabels() const;
bool getDisplayEdgeLabels() const;
bool getDisplayVertexLabels() const;
virtual double getNavmeshMinX() const = 0;
virtual double getNavmeshMinY() const = 0;
virtual double getNavmeshWidth() const = 0;
virtual double getNavmeshHeight() const = 0;
void setAgentRadius(double agentRadius);
void setPathStartPoint(const pathfinder::Vector &point);
void setPathGoalPoint(const pathfinder::Vector &point);
void addPairsDistance(double x, double y, double distance);
void resetAllPairsDistanceMap();
void resetPathStart();
void resetPathGoal();
virtual void resetPath() = 0;
void setHandleMouseDrag(bool enabled);
void setHandleMouseClick(bool enabled);
protected:
// View data
int widgetBaseWidth_{0}, widgetBaseHeight_{0};
double zoomLevel_{0};
bool handleMouseDrag_{false};
bool handleMouseClick_{false};
// Display configurations
bool displayVertices_{false};
bool displayNonConstraintEdges_{true};
bool displayTriangleLabels_{false};
bool displayEdgeLabels_{false};
bool displayVertexLabels_{false};
bool displayAllPairsNoPathToGoal_{true};
bool displayAllPairsException_{true};
// Pathfinding data
double agentRadius_{0.0};
std::optional<pathfinder::Vector> startPoint_;
std::optional<pathfinder::Vector> goalPoint_;
// Pathfinding all-pairs
double allPairsMaxDistance_{0.0};
std::map<double, std::map<double, double>> allPairsRowToColToDistanceMap_;
QSize currentSize() const;
void resizeForNewZoom();
double getScale() const;
virtual QColor getColorForEdgeMarker(const int marker);
signals:
void draggingMouseOnNavmesh(const pathfinder::Vector &navmeshPoint);
void movingMouseOnNavmesh(const pathfinder::Vector &navmeshPoint);
// void mouseClickedOnNavmesh(const pathfinder::Vector &navmeshPoint);
// Polyanya animation
void animationDataUpdated(int currentIndex, int frameCount);
public slots:
void setDisplayVertices(bool shouldDisplay);
void setDisplayNonConstraintEdges(bool shouldDisplay);
void setDisplayTriangleLabels(bool shouldDisplay);
void setDisplayEdgeLabels(bool shouldDisplay);
void setDisplayVertexLabels(bool shouldDisplay);
void setAllPairsShowNoPathToGoal(bool shouldDisplay);
void setAllPairsShowException(bool shouldDisplay);
// Polyanya animation
virtual void stepBackPlaybackAnimation() = 0;
virtual void startPlaybackAnimation() = 0;
virtual void pausePlaybackAnimation() = 0;
virtual void stopPlaybackAnimation() = 0;
virtual void stepForwardPlaybackAnimation() = 0;
virtual void setFramePlaybackAnimation(const QString &text) = 0;
};
#endif // NAVMESH_RENDER_AREA_BASE_HPP_