2022-06-16 22:42:55 +08:00
|
|
|
|
//
|
|
|
|
|
// Created by ricardo on 2022/6/11.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
#ifndef AUTO_BUS_GUI_MAIN_SCENE_H
|
|
|
|
|
#define AUTO_BUS_GUI_MAIN_SCENE_H
|
|
|
|
|
|
|
|
|
|
#include "QGraphicsScene"
|
|
|
|
|
#include "QGraphicsPixmapItem"
|
2022-06-17 10:33:28 +08:00
|
|
|
|
|
2022-06-27 11:00:00 +08:00
|
|
|
|
/**
|
|
|
|
|
* 储存每个站点位置的类
|
|
|
|
|
*/
|
2022-06-17 10:33:28 +08:00
|
|
|
|
class PosPair{
|
|
|
|
|
|
|
|
|
|
public:
|
2022-06-27 11:00:00 +08:00
|
|
|
|
/*
|
|
|
|
|
* 站点位置的x坐标
|
|
|
|
|
*/
|
2022-06-17 10:33:28 +08:00
|
|
|
|
int pos_x;
|
2022-06-27 11:00:00 +08:00
|
|
|
|
/**
|
|
|
|
|
* 站点位置的y坐标
|
|
|
|
|
*/
|
2022-06-17 10:33:28 +08:00
|
|
|
|
int pos_y;
|
|
|
|
|
|
|
|
|
|
PosPair();
|
|
|
|
|
/**
|
|
|
|
|
* 获取两个站点之间的距离
|
|
|
|
|
* @param stop_number 站点的数量
|
|
|
|
|
* @return 站点之间的距离
|
|
|
|
|
*/
|
|
|
|
|
int GetStopSpaceLength(int stop_number) const;
|
2022-06-27 11:00:00 +08:00
|
|
|
|
|
2022-06-17 10:33:28 +08:00
|
|
|
|
/**
|
|
|
|
|
* 加上一定的距离
|
|
|
|
|
* @param length 需要加上的距离
|
|
|
|
|
*/
|
|
|
|
|
void AddLength(int length);
|
|
|
|
|
|
2022-06-27 11:00:00 +08:00
|
|
|
|
/**
|
|
|
|
|
* 获得该站点公交车停车的位置x坐标
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
int GetBusPosX() const;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获得该站点公交车停车位置的y坐标
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
int GetBusPosY() const;
|
|
|
|
|
|
2022-06-17 10:33:28 +08:00
|
|
|
|
private:
|
|
|
|
|
const int stop_begin_x = 100;
|
|
|
|
|
const int stop_begin_y = 80;
|
|
|
|
|
const int stop_rail_width = 300;
|
|
|
|
|
const int stop_rail_height = 200;
|
2022-06-27 11:00:00 +08:00
|
|
|
|
const int stop_bus_distance = 20;
|
2022-06-17 10:33:28 +08:00
|
|
|
|
|
|
|
|
|
int distance = 0;
|
|
|
|
|
};
|
2022-06-16 22:42:55 +08:00
|
|
|
|
|
|
|
|
|
class SceneManager
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QGraphicsScene *scene;
|
|
|
|
|
|
2022-06-17 10:33:28 +08:00
|
|
|
|
/**
|
|
|
|
|
* 构造函数,同时生成站点
|
|
|
|
|
* @param stop_node_number 站点的数量
|
|
|
|
|
*/
|
2022-06-26 15:02:43 +08:00
|
|
|
|
explicit SceneManager();
|
2022-06-16 22:42:55 +08:00
|
|
|
|
~SceneManager();
|
|
|
|
|
|
2022-06-26 15:02:43 +08:00
|
|
|
|
/**
|
|
|
|
|
* 生成站点画面
|
|
|
|
|
* @param node_number
|
|
|
|
|
*/
|
|
|
|
|
void SetStopScene(int node_number);
|
|
|
|
|
|
2022-06-17 10:33:28 +08:00
|
|
|
|
private:
|
2022-06-16 22:42:55 +08:00
|
|
|
|
/**
|
2022-06-17 10:33:28 +08:00
|
|
|
|
* 显示站点的像素图对象
|
2022-06-16 22:42:55 +08:00
|
|
|
|
*/
|
2022-06-17 10:33:28 +08:00
|
|
|
|
QGraphicsPixmapItem *pixmap_items;
|
2022-06-16 22:42:55 +08:00
|
|
|
|
/**
|
2022-06-17 10:33:28 +08:00
|
|
|
|
* 每个站点的所在位置
|
2022-06-16 22:42:55 +08:00
|
|
|
|
*/
|
2022-06-17 10:33:28 +08:00
|
|
|
|
PosPair *stop_pos_pairs;
|
2022-06-16 22:42:55 +08:00
|
|
|
|
|
2022-06-26 15:02:43 +08:00
|
|
|
|
/**
|
|
|
|
|
* 总共的站点数量
|
|
|
|
|
*/
|
|
|
|
|
int stop_node_number;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 一个矩形的边框
|
|
|
|
|
* 使无论中间存在多少站点,这个scene都能在view的中心
|
|
|
|
|
*/
|
2022-06-17 10:33:28 +08:00
|
|
|
|
QGraphicsRectItem *rect_item;
|
2022-06-26 15:02:43 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 清除画面
|
|
|
|
|
*/
|
|
|
|
|
void ClearScene();
|
2022-06-16 22:42:55 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif //AUTO_BUS_GUI_MAIN_SCENE_H
|