添加了站点编号
This commit is contained in:
parent
2a5b4b3841
commit
3ab2edf65c
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include "QGraphicsScene"
|
||||
#include "QGraphicsPixmapItem"
|
||||
#include "QGraphicsSimpleTextItem"
|
||||
|
||||
#include "PosPair.h"
|
||||
#include "BusWidget.h"
|
||||
|
@ -18,7 +19,6 @@ public:
|
|||
|
||||
/**
|
||||
* 构造函数,同时生成站点
|
||||
* @param stop_node_number 站点的数量
|
||||
*/
|
||||
explicit SceneManager();
|
||||
~SceneManager();
|
||||
|
@ -42,6 +42,8 @@ private:
|
|||
*/
|
||||
QGraphicsPixmapItem *pixmap_items;
|
||||
|
||||
QGraphicsSimpleTextItem *name_items;
|
||||
|
||||
/**
|
||||
* 每个站点的所在位置
|
||||
*/
|
||||
|
|
|
@ -61,7 +61,8 @@ int PosPair::GetBusPosX() const
|
|||
}
|
||||
else if(pos_x >= stop_begin_x + stop_rail_width)
|
||||
{
|
||||
result = pos_x + stop_bus_distance;
|
||||
// 最下面一行得加上站点图片的高度
|
||||
result = pos_x + stop_bus_distance + 100;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -81,7 +82,8 @@ int PosPair::GetBusPosY() const
|
|||
}
|
||||
else if(pos_y >= stop_begin_y + stop_rail_width)
|
||||
{
|
||||
result = pos_y + stop_bus_distance;
|
||||
// 最右边一行得加上站点图片的宽度
|
||||
result = pos_y + stop_bus_distance + 30;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -10,6 +10,7 @@ SceneManager::SceneManager()
|
|||
stop_node_number = 0;
|
||||
pixmap_items = nullptr;
|
||||
stop_pos_pairs = nullptr;
|
||||
name_items = nullptr;
|
||||
rect_item = new QGraphicsRectItem;
|
||||
bus = new BusWidget;
|
||||
|
||||
|
@ -38,6 +39,7 @@ void SceneManager::SetStopScene(int node_number)
|
|||
stop_node_number = node_number;
|
||||
pixmap_items = new QGraphicsPixmapItem[stop_node_number];
|
||||
stop_pos_pairs = new PosPair[stop_node_number];
|
||||
name_items = new QGraphicsSimpleTextItem[stop_node_number];
|
||||
|
||||
int stop_space_length = stop_pos_pairs->GetStopSpaceLength(stop_node_number);
|
||||
double stop_scale = 0.15;
|
||||
|
@ -65,6 +67,14 @@ void SceneManager::SetStopScene(int node_number)
|
|||
pixmap_items[i].setPos(stop_pos_pairs[i].pos_x, stop_pos_pairs[i].pos_y);
|
||||
}
|
||||
|
||||
for(int i = 0; i < stop_node_number; i++)
|
||||
{
|
||||
name_items[i].setText(QString::number(i + 1));
|
||||
name_items[i].setPos(stop_pos_pairs[i].pos_x + 30, stop_pos_pairs[i].pos_y);
|
||||
|
||||
scene->addItem(&name_items[i]);
|
||||
}
|
||||
|
||||
// 设置公交车图像
|
||||
bus->ResetBusPos(stop_pos_pairs, node_number);
|
||||
scene->addItem(bus->item);
|
||||
|
@ -78,6 +88,12 @@ void SceneManager::ClearStopScene()
|
|||
scene->removeItem(&pixmap_items[i]);
|
||||
}
|
||||
|
||||
for(int i = 0; i < stop_node_number; i++)
|
||||
{
|
||||
scene->removeItem(&name_items[i]);
|
||||
}
|
||||
|
||||
delete []name_items;
|
||||
delete []pixmap_items;
|
||||
delete []stop_pos_pairs;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user