完善了注释
This commit is contained in:
parent
a9c1d2dbf8
commit
8cd607ec75
|
@ -32,9 +32,11 @@ public:
|
||||||
class BusWidget
|
class BusWidget
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
/**
|
||||||
|
* 真正的公交车显示对象
|
||||||
|
*/
|
||||||
BusItem *item;
|
BusItem *item;
|
||||||
|
|
||||||
|
|
||||||
explicit BusWidget();
|
explicit BusWidget();
|
||||||
|
|
||||||
~BusWidget();
|
~BusWidget();
|
||||||
|
@ -54,10 +56,24 @@ public:
|
||||||
void StartAnimation(int direction, int duration);
|
void StartAnimation(int direction, int duration);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
/**
|
||||||
|
* 存储各个站点位置对的数组
|
||||||
|
*/
|
||||||
PosPair *pos_pairs = nullptr;
|
PosPair *pos_pairs = nullptr;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 动画对象
|
||||||
|
*/
|
||||||
QPropertyAnimation *animation;
|
QPropertyAnimation *animation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 公交车所在的站点
|
||||||
|
*/
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 站点总数
|
||||||
|
*/
|
||||||
int node_num = 0;
|
int node_num = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@ public:
|
||||||
int pos_y;
|
int pos_y;
|
||||||
|
|
||||||
PosPair();
|
PosPair();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取两个站点之间的距离
|
* 获取两个站点之间的距离
|
||||||
* @param stop_number 站点的数量
|
* @param stop_number 站点的数量
|
||||||
|
@ -47,10 +48,29 @@ public:
|
||||||
int GetBusPosY() const;
|
int GetBusPosY() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
/**
|
||||||
|
* 设定的轨道开始坐标x
|
||||||
|
*/
|
||||||
const int stop_begin_x = 100;
|
const int stop_begin_x = 100;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设定的轨道开始坐标y
|
||||||
|
*/
|
||||||
const int stop_begin_y = 80;
|
const int stop_begin_y = 80;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 轨道的宽度
|
||||||
|
*/
|
||||||
const int stop_rail_width = 300;
|
const int stop_rail_width = 300;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 轨道的高度
|
||||||
|
*/
|
||||||
const int stop_rail_height = 200;
|
const int stop_rail_height = 200;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 公交车到站点的距离
|
||||||
|
*/
|
||||||
const int stop_bus_distance = 30;
|
const int stop_bus_distance = 30;
|
||||||
|
|
||||||
int distance = 0;
|
int distance = 0;
|
||||||
|
|
|
@ -15,6 +15,11 @@
|
||||||
class StrategyFactory
|
class StrategyFactory
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
/**
|
||||||
|
* 生成控制器的工厂函数
|
||||||
|
* @param file_name 配置文件的名称
|
||||||
|
* @return 控制器对象
|
||||||
|
*/
|
||||||
static BusStrategyBase *GetStrategy(const QString& file_name);
|
static BusStrategyBase *GetStrategy(const QString& file_name);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
#define BUS_SSTF 1 // 最短寻找时间优先
|
#define BUS_SSTF 1 // 最短寻找时间优先
|
||||||
#define BUS_SCAN 2 // 顺便服务
|
#define BUS_SCAN 2 // 顺便服务
|
||||||
#define BUS_RUNNING 0
|
#define BUS_RUNNING 0
|
||||||
#define BUS_PAUSING 1
|
|
||||||
#define BUS_END 2
|
#define BUS_END 2
|
||||||
|
|
||||||
#endif //AUTO_BUS_GUI_DEFINE_H
|
#endif //AUTO_BUS_GUI_DEFINE_H
|
||||||
|
|
|
@ -12,15 +12,22 @@
|
||||||
#include "PosPair.h"
|
#include "PosPair.h"
|
||||||
#include "BusWidget.h"
|
#include "BusWidget.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 控制画图的管理类
|
||||||
|
*/
|
||||||
class SceneManager
|
class SceneManager
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
/**
|
||||||
|
* 场景对象
|
||||||
|
*/
|
||||||
QGraphicsScene *scene;
|
QGraphicsScene *scene;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 构造函数,同时生成站点
|
* 构造函数,同时生成站点
|
||||||
*/
|
*/
|
||||||
explicit SceneManager();
|
explicit SceneManager();
|
||||||
|
|
||||||
~SceneManager();
|
~SceneManager();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -29,6 +36,9 @@ public:
|
||||||
*/
|
*/
|
||||||
void SetStopScene(int node_number);
|
void SetStopScene(int node_number);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 重设公交车的位置
|
||||||
|
*/
|
||||||
void ResetBus();
|
void ResetBus();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -44,6 +54,9 @@ private:
|
||||||
*/
|
*/
|
||||||
QGraphicsPixmapItem *pixmap_items;
|
QGraphicsPixmapItem *pixmap_items;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 站点名称的对象数组
|
||||||
|
*/
|
||||||
QGraphicsSimpleTextItem *name_items;
|
QGraphicsSimpleTextItem *name_items;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -11,6 +11,9 @@
|
||||||
|
|
||||||
#include "define.h"
|
#include "define.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 请求列表中显示请求的控件
|
||||||
|
*/
|
||||||
class QueryListItem : public QWidget
|
class QueryListItem : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -19,8 +22,14 @@ public:
|
||||||
|
|
||||||
void SetColumnName();
|
void SetColumnName();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 请求的类别
|
||||||
|
*/
|
||||||
int query_type;
|
int query_type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 目标的站点id
|
||||||
|
*/
|
||||||
int target_node_id;
|
int target_node_id;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -11,14 +11,17 @@ struct bus_query {
|
||||||
* 请求产生的时间
|
* 请求产生的时间
|
||||||
*/
|
*/
|
||||||
int time;
|
int time;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 请求的类型
|
* 请求的类型
|
||||||
*/
|
*/
|
||||||
int type;
|
int type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 请求产生/指向的站点
|
* 请求产生/指向的站点
|
||||||
*/
|
*/
|
||||||
rail_node_t *node;
|
rail_node_t *node;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 指向下一个请求的指针
|
* 指向下一个请求的指针
|
||||||
*/
|
*/
|
||||||
|
@ -32,10 +35,6 @@ class QueryModel
|
||||||
public:
|
public:
|
||||||
bus_query_t *queries = nullptr;
|
bus_query_t *queries = nullptr;
|
||||||
|
|
||||||
/**
|
|
||||||
* 析构函数
|
|
||||||
* 负责释放内存
|
|
||||||
*/
|
|
||||||
~QueryModel();
|
~QueryModel();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -11,18 +11,22 @@ struct rail_node{
|
||||||
* 站点的编号
|
* 站点的编号
|
||||||
*/
|
*/
|
||||||
int id;
|
int id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 距离上一个站点的距离
|
* 距离上一个站点的距离
|
||||||
*/
|
*/
|
||||||
int last_node_distance;
|
int last_node_distance;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 距离下一个站点的距离
|
* 距离下一个站点的距离
|
||||||
*/
|
*/
|
||||||
int next_node_distance;
|
int next_node_distance;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 指向上一个站点的指针
|
* 指向上一个站点的指针
|
||||||
*/
|
*/
|
||||||
struct rail_node* last_node;
|
struct rail_node* last_node;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 指向下一个站点的指针
|
* 指向下一个站点的指针
|
||||||
*/
|
*/
|
||||||
|
@ -45,6 +49,9 @@ public:
|
||||||
*/
|
*/
|
||||||
int node_num;
|
int node_num;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 轨道的总长度
|
||||||
|
*/
|
||||||
int total_distance;
|
int total_distance;
|
||||||
|
|
||||||
explicit RailsModel();
|
explicit RailsModel();
|
||||||
|
|
|
@ -65,7 +65,8 @@ public slots:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理删除一个请求的槽函数
|
* 处理删除一个请求的槽函数
|
||||||
* @param query 请求指针
|
* @param query_type 请求的类型
|
||||||
|
* @param node_id 请求的站点id
|
||||||
*/
|
*/
|
||||||
void DeleteQueryItemSlot(int query_type, int node_id);
|
void DeleteQueryItemSlot(int query_type, int node_id);
|
||||||
|
|
||||||
|
@ -80,6 +81,12 @@ public slots:
|
||||||
*/
|
*/
|
||||||
void PrintStateSlot(const QString& string);
|
void PrintStateSlot(const QString& string);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 开始公交车动画的槽函数
|
||||||
|
* 实际上就是将公交车移动到上一个或者下一个站点
|
||||||
|
* @param direction 公交车前进的方向
|
||||||
|
* @param duration 动画需要持续的时间
|
||||||
|
*/
|
||||||
void BeginBusAnimationSlot(int direction, int duration);
|
void BeginBusAnimationSlot(int direction, int duration);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -93,6 +100,9 @@ private:
|
||||||
*/
|
*/
|
||||||
SceneManager *scene_manager;
|
SceneManager *scene_manager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 控制器
|
||||||
|
*/
|
||||||
BusStrategyBase *controller = nullptr;
|
BusStrategyBase *controller = nullptr;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -123,6 +133,7 @@ private:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置站点选择下拉栏
|
* 设置站点选择下拉栏
|
||||||
|
* @param 站点的个数
|
||||||
*/
|
*/
|
||||||
void SetRailsComboBox(int node_num);
|
void SetRailsComboBox(int node_num);
|
||||||
|
|
||||||
|
|
|
@ -79,6 +79,11 @@ public slots:
|
||||||
*/
|
*/
|
||||||
void OneTickSlot();
|
void OneTickSlot();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 开始公交车行驶计时器的槽函数
|
||||||
|
* @param direction 公交车前进的防线 此处不需要
|
||||||
|
* @param duration 持续的时间
|
||||||
|
*/
|
||||||
void BeginBusTimerSlot([[maybe_unused]] int direction, int duration);
|
void BeginBusTimerSlot([[maybe_unused]] int direction, int duration);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -97,15 +102,27 @@ private:
|
||||||
*/
|
*/
|
||||||
CentralWidget *central_widget;
|
CentralWidget *central_widget;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 控制器工作的线程
|
||||||
|
*/
|
||||||
QThread *worker_thread;
|
QThread *worker_thread;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 控制器指针
|
||||||
|
*/
|
||||||
BusStrategyBase *controller;
|
BusStrategyBase *controller;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 时刻计时器
|
||||||
|
* 每隔一个tick发出一个时钟信号
|
||||||
|
*/
|
||||||
QTimer *tick_timer;
|
QTimer *tick_timer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 公交车计时器
|
||||||
|
*/
|
||||||
QTimer *bus_timer;
|
QTimer *bus_timer;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置菜单栏的相关连接
|
* 设置菜单栏的相关连接
|
||||||
*/
|
*/
|
||||||
|
@ -116,6 +133,9 @@ private:
|
||||||
*/
|
*/
|
||||||
void SetControlConnection();
|
void SetControlConnection();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 开始多线程
|
||||||
|
*/
|
||||||
void BeginThread();
|
void BeginThread();
|
||||||
};
|
};
|
||||||
#endif //AUTO_BUS_GUI_MAIN_WINDOW_H
|
#endif //AUTO_BUS_GUI_MAIN_WINDOW_H
|
||||||
|
|
Loading…
Reference in New Issue
Block a user