-
Notifications
You must be signed in to change notification settings - Fork 0
/
mapwidget.h
73 lines (58 loc) · 1.9 KB
/
mapwidget.h
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
//
// Created by hamlet on 2021/11/8.
//
#ifndef ROBOTCOMMANDER_MAPWIDGET_H
#define ROBOTCOMMANDER_MAPWIDGET_H
#include <QWidget>
#include "settings.h"
class QMenu;
class Command;
class MapWidget : public QWidget {
Q_OBJECT
public:
explicit MapWidget(QWidget *parent = nullptr);
~MapWidget() override;
void infoCurPosition(const QPointF &pos);
void updateSettings(const Settings *settings);
enum ViewForm {
NormalView, SuitableView, FilledView
};
void zoomIn(QPoint center={});
void zoomOut(QPoint center={});
void setViewForm(ViewForm viewForm);
signals:
void sendCommand(std::shared_ptr<Command> command);
void updateViewForm(ViewForm viewForm);
protected slots:
void paintEvent(QPaintEvent *) override;
void resizeEvent(QResizeEvent *) override;
void mousePressEvent(QMouseEvent *) override;
void mouseMoveEvent(QMouseEvent *event) override;
void mouseReleaseEvent(QMouseEvent *event) override;
void wheelEvent(QWheelEvent *event) override;
void keyPressEvent(QKeyEvent *event) override;
void keyReleaseEvent(QKeyEvent *event) override;
private:
const Settings *m_settings = nullptr;
QPixmap m_tmpMap;
QPixmap m_imgMap;
QPoint m_baseP;
ViewForm m_viewForm = SuitableView;
QPixmap m_imgRobotCur;
QPixmap m_imgRobotTar;
QPointF m_curP; // 位置由0到1之间的double类型表示,下同
QPointF m_tarP;
QPointF m_tarPTmp;
inline bool isInside(const QPoint &p);
inline QPointF generateRatio(const QPoint &p);
inline QPoint recoverRatio(const QPointF &ratio);
QPoint m_mouseP;
QPoint m_startP;
bool m_fill_width_or_height=true; // FilledView模式下,铺满width为true,铺满height为false
bool mod_Ctrl=false;
inline void resizePaint();
QMenu *m_menu;
QAction *m_action_send;
std::shared_ptr<Command> m_command;
};
#endif //ROBOTCOMMANDER_MAPWIDGET_H