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