auto_bus/include/BusWidget.h

84 lines
1.5 KiB
C
Raw Normal View History

//
// Created by ricardo on 2022/6/28.
//
#ifndef AUTO_BUS_GUI_BUS_WIDGET_H
#define AUTO_BUS_GUI_BUS_WIDGET_H
#include "QGraphicsPixmapItem"
#include "QTransform"
2022-06-28 12:23:55 +08:00
#include "QPropertyAnimation"
#include "PosPair.h"
2022-06-28 12:23:55 +08:00
#include "define.h"
/**
*
* QObject QGraphicsPixmapItem
* 使qt的动画框架
*/
class BusItem: public QObject, public QGraphicsPixmapItem
{
// 调用这个宏使其qt对象化
Q_OBJECT
// 注册了一个QPointF类型的变量pos
// 读取这个变量通过 pos()函数
// 写入这个变量通过 setPos()函数
Q_PROPERTY(QPointF pos READ pos WRITE setPos)
public:
explicit BusItem(const QPixmap& pixmap);
};
2022-07-09 10:11:35 +08:00
/**
*
*/
class BusWidget
{
public:
2022-06-29 17:25:33 +08:00
/**
*
*/
2022-06-28 12:23:55 +08:00
BusItem *item;
explicit BusWidget();
~BusWidget();
2022-06-28 12:23:55 +08:00
/**
*
* @param s
* @param num
*/
void ResetBusPos(PosPair *s, int num);
/**
*
* @param direction
* @param duration ms
*/
void StartAnimation(int direction, int duration);
private:
2022-06-29 17:25:33 +08:00
/**
*
*/
PosPair *pos_pairs = nullptr;
2022-06-29 17:25:33 +08:00
/**
*
*/
2022-06-28 12:23:55 +08:00
QPropertyAnimation *animation;
2022-06-29 17:25:33 +08:00
/**
*
*/
2022-06-28 12:23:55 +08:00
int pos = 0;
2022-06-29 17:25:33 +08:00
/**
*
*/
2022-06-28 12:23:55 +08:00
int node_num = 0;
};
#endif //AUTO_BUS_GUI_BUS_WIDGET_H