2026-03-22 17:31:41 +08:00
|
|
|
|
#ifndef NETWORKCONFIGWIDGET_H
|
|
|
|
|
|
#define NETWORKCONFIGWIDGET_H
|
|
|
|
|
|
|
|
|
|
|
|
#include <QWidget>
|
|
|
|
|
|
#include <QComboBox>
|
|
|
|
|
|
#include <QLabel>
|
|
|
|
|
|
#include <QLineEdit>
|
|
|
|
|
|
#include <QGroupBox>
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @brief 网络配置数据结构
|
|
|
|
|
|
*/
|
|
|
|
|
|
struct NetworkConfigData
|
|
|
|
|
|
{
|
|
|
|
|
|
int eulerOrder = 11; // 欧拉角旋转顺序,默认11=外旋ZYX
|
|
|
|
|
|
int dirVectorInvert = 0; // 方向向量反向,默认0=不反向
|
|
|
|
|
|
int byteOrder = 0; // 字节序,默认0=大端序
|
2026-03-29 20:37:36 +08:00
|
|
|
|
int longAxisDir = 0; // 目标物长边对应轴:0=X轴, 1=Y轴
|
2026-03-22 17:31:41 +08:00
|
|
|
|
|
|
|
|
|
|
// PLC服务端配置(可选)
|
|
|
|
|
|
QString plcServerIp = "192.168.0.88";
|
|
|
|
|
|
int plcServerPort = 502;
|
|
|
|
|
|
int addrPhotoRequest = 1001;
|
|
|
|
|
|
int addrDataComplete = 1003;
|
|
|
|
|
|
int addrCoordDataStart = 2002;
|
|
|
|
|
|
|
|
|
|
|
|
// TCP服务端端口(可选)
|
|
|
|
|
|
int tcpServerPort = 5020;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// 欧拉角旋转顺序常量
|
|
|
|
|
|
enum NetworkEulerOrder
|
|
|
|
|
|
{
|
|
|
|
|
|
EULER_ORDER_XYZ = 10, // 外旋XYZ
|
|
|
|
|
|
EULER_ORDER_ZYX = 11, // 外旋ZYX(最常用)
|
|
|
|
|
|
EULER_ORDER_ZXY = 12, // 外旋ZXY
|
|
|
|
|
|
EULER_ORDER_YXZ = 13, // 外旋YXZ
|
|
|
|
|
|
EULER_ORDER_YZX = 14, // 外旋YZX
|
|
|
|
|
|
EULER_ORDER_XZY = 15 // 外旋XZY
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// 方向向量反向常量
|
|
|
|
|
|
enum NetworkDirVectorInvert
|
|
|
|
|
|
{
|
|
|
|
|
|
NET_DIR_INVERT_NONE = 0, // 不反向
|
|
|
|
|
|
NET_DIR_INVERT_XY = 1, // X和Y方向反向
|
|
|
|
|
|
NET_DIR_INVERT_XZ = 2, // X和Z方向反向
|
|
|
|
|
|
NET_DIR_INVERT_YZ = 3 // Y和Z方向反向
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// 字节序常量
|
|
|
|
|
|
enum NetworkByteOrder
|
|
|
|
|
|
{
|
|
|
|
|
|
NET_BYTE_ORDER_BIG = 0, // 大端序 (ABCD)
|
|
|
|
|
|
NET_BYTE_ORDER_LITTLE = 1 // 小端序 (DCBA)
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @brief 网络配置共享控件
|
|
|
|
|
|
*
|
|
|
|
|
|
* 提供统一的网络参数配置界面,包含:
|
|
|
|
|
|
* - 欧拉角旋转顺序
|
|
|
|
|
|
* - 方向向量反向
|
|
|
|
|
|
* - 数据字节序
|
|
|
|
|
|
* - (可选)PLC服务端配置
|
|
|
|
|
|
* - (可选)TCP服务端端口配置
|
|
|
|
|
|
*
|
|
|
|
|
|
* 纯 QWidget,代码构建 UI(无 .ui 文件),可嵌入任意 tab/layout。
|
|
|
|
|
|
*/
|
|
|
|
|
|
class NetworkConfigWidget : public QWidget
|
|
|
|
|
|
{
|
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @brief 构造函数
|
|
|
|
|
|
* @param showPlcConfig 是否显示PLC服务端配置
|
|
|
|
|
|
* @param showTcpConfig 是否显示TCP服务端配置
|
|
|
|
|
|
* @param parent 父控件
|
|
|
|
|
|
*/
|
|
|
|
|
|
explicit NetworkConfigWidget(bool showPlcConfig = true,
|
|
|
|
|
|
bool showTcpConfig = false,
|
|
|
|
|
|
QWidget *parent = nullptr);
|
|
|
|
|
|
~NetworkConfigWidget();
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @brief 设置配置数据
|
|
|
|
|
|
*/
|
|
|
|
|
|
void setConfig(const NetworkConfigData& config);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @brief 获取配置数据
|
|
|
|
|
|
*/
|
|
|
|
|
|
NetworkConfigData getConfig() const;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @brief 获取各个配置值
|
|
|
|
|
|
*/
|
|
|
|
|
|
int eulerOrder() const;
|
|
|
|
|
|
int dirVectorInvert() const;
|
|
|
|
|
|
int byteOrder() const;
|
2026-03-29 20:37:36 +08:00
|
|
|
|
int longAxisDir() const;
|
2026-03-22 17:31:41 +08:00
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
void setupUI(bool showPlcConfig, bool showTcpConfig);
|
|
|
|
|
|
void initEulerOrderComboBox();
|
|
|
|
|
|
void initDirVectorInvertComboBox();
|
|
|
|
|
|
void initByteOrderComboBox();
|
2026-03-29 20:37:36 +08:00
|
|
|
|
void initLongAxisDirComboBox();
|
2026-03-22 17:31:41 +08:00
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
// 通用配置控件
|
|
|
|
|
|
QComboBox* m_comboEulerOrder;
|
|
|
|
|
|
QComboBox* m_comboDirVectorInvert;
|
|
|
|
|
|
QComboBox* m_comboByteOrder;
|
2026-03-29 20:37:36 +08:00
|
|
|
|
QComboBox* m_comboLongAxisDir;
|
2026-03-22 17:31:41 +08:00
|
|
|
|
|
|
|
|
|
|
// PLC服务端配置控件(可选)
|
|
|
|
|
|
QGroupBox* m_groupPlc;
|
|
|
|
|
|
QLineEdit* m_editPlcIp;
|
|
|
|
|
|
QLineEdit* m_editPlcPort;
|
|
|
|
|
|
QLineEdit* m_editAddrPhotoRequest;
|
|
|
|
|
|
QLineEdit* m_editAddrDataComplete;
|
|
|
|
|
|
QLineEdit* m_editAddrCoordDataStart;
|
|
|
|
|
|
|
|
|
|
|
|
// TCP服务端配置控件(可选)
|
|
|
|
|
|
QGroupBox* m_groupTcp;
|
|
|
|
|
|
QLineEdit* m_editTcpPort;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // NETWORKCONFIGWIDGET_H
|