2023-04-14 19:30:30 +08:00
|
|
|
|
#ifndef REALTIMEFORM_H
|
|
|
|
|
|
#define REALTIMEFORM_H
|
|
|
|
|
|
|
|
|
|
|
|
#include <QWidget>
|
|
|
|
|
|
#include <QGraphicsScene>
|
|
|
|
|
|
#include <QGraphicsView>
|
|
|
|
|
|
#include <QGraphicsItem>
|
|
|
|
|
|
#include <QGraphicsRectItem>
|
|
|
|
|
|
#include <QGraphicsLineItem>
|
|
|
|
|
|
#include <QGraphicsTextItem>
|
2023-04-27 19:48:15 +08:00
|
|
|
|
#include <QGraphicsProxyWidget>
|
2023-04-14 19:30:30 +08:00
|
|
|
|
#include <QKeyEvent>
|
|
|
|
|
|
#include <AddChannel.h>
|
|
|
|
|
|
#include "sqlitedb.h"
|
|
|
|
|
|
#include <QTimer> //定时器类
|
|
|
|
|
|
#include <QAbstractSocket>
|
|
|
|
|
|
#include <QTcpSocket>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class NetMgr;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Ui {
|
|
|
|
|
|
class CRealTimeForm;
|
|
|
|
|
|
}
|
|
|
|
|
|
// 1 创建新的类 MyItem2 继承 QGraphicsPathItem,重新实现点击、悬浮等函数
|
|
|
|
|
|
|
|
|
|
|
|
#include <QGraphicsSceneEvent>
|
|
|
|
|
|
#include <QPen>
|
|
|
|
|
|
|
|
|
|
|
|
// 点击该控件时,调用该函数
|
|
|
|
|
|
typedef void (*ClickHandle)(int type,void *other);
|
|
|
|
|
|
|
|
|
|
|
|
class MyItem2 : public QGraphicsPathItem
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
explicit MyItem2(QGraphicsItem *parent = nullptr);
|
|
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
// 重新实现这些函数
|
|
|
|
|
|
void keyPressEvent(QKeyEvent *event);
|
|
|
|
|
|
void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
|
|
|
|
|
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
|
|
|
|
|
|
void hoverLeaveEvent (QGraphicsSceneHoverEvent * event);
|
|
|
|
|
|
void contextMenuEvent(QGraphicsSceneContextMenuEvent *event);
|
|
|
|
|
|
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
|
|
void setID(int ID);
|
|
|
|
|
|
void setClicKHandle(ClickHandle click,void * other);
|
|
|
|
|
|
QPainterPath path;
|
|
|
|
|
|
private:
|
|
|
|
|
|
int ID;
|
|
|
|
|
|
ClickHandle click;
|
|
|
|
|
|
void * other;
|
|
|
|
|
|
QPen pen;
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class CRealTimeForm : public QWidget //, public MyItem2
|
|
|
|
|
|
{
|
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
explicit CRealTimeForm(QWidget *parent = nullptr);
|
|
|
|
|
|
~CRealTimeForm();
|
|
|
|
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
|
|
void on_graphView_customContextMenuRequested(const QPoint &pos);
|
|
|
|
|
|
|
|
|
|
|
|
void onTaskBoxContextMenuEvent();
|
|
|
|
|
|
void slotDoubleClick(QGraphicsSceneMouseEvent *event);
|
|
|
|
|
|
void on_addchannel(channelBaseInfo channelbaseInfo,QString str);
|
|
|
|
|
|
//网络请求数据响应
|
|
|
|
|
|
void slotNetMgr(QString sAddr,const QVariant& msg);
|
|
|
|
|
|
public slots:
|
|
|
|
|
|
// 接受服务器的数据槽函数
|
|
|
|
|
|
void slotRecieve();
|
|
|
|
|
|
void disConnect();
|
|
|
|
|
|
// 连接状态变化的时候触发
|
|
|
|
|
|
//void slotStateChanged(QAbstractSocket::SocketState state);
|
|
|
|
|
|
signals:
|
|
|
|
|
|
void sigWCStatus(QString&);
|
|
|
|
|
|
void sigDOStatus(QJsonArray&,QJsonArray&);
|
|
|
|
|
|
void sigRPM(QString&);
|
|
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
void keyPressEvent(QKeyEvent *event);
|
|
|
|
|
|
void mouseDoubleClickEvent(QMouseEvent* e);
|
|
|
|
|
|
//void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
|
|
|
|
|
private:
|
|
|
|
|
|
Ui::CRealTimeForm *ui;
|
|
|
|
|
|
QGraphicsScene* m_pGraphicsScene ;
|
|
|
|
|
|
QGraphicsScene* m_pGraphicsScene_2 ;
|
|
|
|
|
|
QAction *pActionVerticalLine ;
|
|
|
|
|
|
QAction *pActionHorizontalLine ;
|
|
|
|
|
|
QAction *pActionRect ;
|
|
|
|
|
|
QAction *pActionPixmap ;
|
|
|
|
|
|
QAction *pActionText ;
|
2023-10-19 14:15:31 +08:00
|
|
|
|
QAction *pActionRect2 ;
|
2023-04-27 19:48:15 +08:00
|
|
|
|
QAction *pActionEdit ;
|
2023-04-14 19:30:30 +08:00
|
|
|
|
QAction *pActionSave ;
|
2024-04-02 19:25:44 +08:00
|
|
|
|
QAction *pActionAlignmentX ;
|
|
|
|
|
|
QAction *pActionAlignmentY ;
|
2023-04-14 19:30:30 +08:00
|
|
|
|
int id1; //定时器1的唯一标示
|
2023-10-19 14:15:31 +08:00
|
|
|
|
int m_RealtimeLog;
|
|
|
|
|
|
int m_MachineStatus;//1 运行 0 停机
|
2023-04-14 19:30:30 +08:00
|
|
|
|
QByteArray m_arrayReady;
|
|
|
|
|
|
|
|
|
|
|
|
QMap<QString,QMap<int,QGraphicsItem*>> mapGrapics;
|
|
|
|
|
|
|
|
|
|
|
|
void InitChannelInfo();
|
|
|
|
|
|
void SetCurDrawType(QString strType);
|
2023-04-27 19:48:15 +08:00
|
|
|
|
void SetEdit();
|
2024-04-02 19:25:44 +08:00
|
|
|
|
void SetAlignmentX();
|
|
|
|
|
|
void SetAlignmentY();
|
2023-10-19 14:15:31 +08:00
|
|
|
|
void LoadGraphicsConfig(int type);//0 正常,1 编辑 2 停机
|
2023-04-14 19:30:30 +08:00
|
|
|
|
void SaveGraphicsConfig();
|
|
|
|
|
|
void UpdateCharacteristic(QVector<_Charateristic>& m_vecCharateristic);
|
|
|
|
|
|
void ParseCharacteristic(QJsonArray& arrayValue);
|
|
|
|
|
|
|
|
|
|
|
|
QTcpSocket *m_pSocket; // 客户端Socket对象
|
|
|
|
|
|
QString m_strServerIp; // 服务端IP
|
|
|
|
|
|
QList<QString> m_strReciveList; // 接受回来的数据放到链表里面
|
|
|
|
|
|
bool m_bConnected; // 连接的标志
|
|
|
|
|
|
int m_nConnectWaitTimes; // 连接的等待时间
|
|
|
|
|
|
int m_nServerPort; // 服务端端口号
|
2023-04-27 19:48:15 +08:00
|
|
|
|
int m_EditMode;
|
2023-04-14 19:30:30 +08:00
|
|
|
|
|
|
|
|
|
|
NetMgr *m_pNetMgr; //HTTP消息类对象
|
|
|
|
|
|
QVector<_Charateristic> m_vecCharateristic;
|
|
|
|
|
|
//重写定时器的事件 虚函数 子类重写父类的虚函数
|
|
|
|
|
|
virtual void timerEvent(QTimerEvent *);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // REALTIMEFORM_H
|