GrabBag/AppUtils/UICommon/Inc/NetworkConfigWidget.h

132 lines
3.4 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.

#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=大端序
int longAxisDir = 0; // 目标物长边对应轴0=X轴, 1=Y轴
// 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;
int longAxisDir() const;
private:
void setupUI(bool showPlcConfig, bool showTcpConfig);
void initEulerOrderComboBox();
void initDirVectorInvertComboBox();
void initByteOrderComboBox();
void initLongAxisDirComboBox();
private:
// 通用配置控件
QComboBox* m_comboEulerOrder;
QComboBox* m_comboDirVectorInvert;
QComboBox* m_comboByteOrder;
QComboBox* m_comboLongAxisDir;
// 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