auto_bus/include/mainScene.h
jackfiled 54c4521fb2 读取配置文件后重绘站点图重设下拉栏
修复了释放轨道链表内存空间时未判断指针是否为空的问题
修复了绘制站点图部分站点位置计算错误的问题
2022-06-26 15:02:43 +08:00

85 lines
1.5 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// 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"
class PosPair{
public:
int pos_x;
int pos_y;
PosPair();
/**
* 获取两个站点之间的距离
* @param stop_number 站点的数量
* @return 站点之间的距离
*/
int GetStopSpaceLength(int stop_number) const;
/**
* 加上一定的距离
* @param length 需要加上的距离
*/
void AddLength(int length);
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;
int distance = 0;
};
class SceneManager
{
public:
QGraphicsScene *scene;
/**
* 构造函数,同时生成站点
* @param stop_node_number 站点的数量
*/
explicit SceneManager();
~SceneManager();
/**
* 生成站点画面
* @param node_number
*/
void SetStopScene(int node_number);
private:
/**
* 显示站点的像素图对象
*/
QGraphicsPixmapItem *pixmap_items;
/**
* 每个站点的所在位置
*/
PosPair *stop_pos_pairs;
/**
* 总共的站点数量
*/
int stop_node_number;
/**
* 一个矩形的边框
* 使无论中间存在多少站点这个scene都能在view的中心
*/
QGraphicsRectItem *rect_item;
/**
* 清除画面
*/
void ClearScene();
};
#endif //AUTO_BUS_GUI_MAIN_SCENE_H