GrabBag/AppUtils/UICommon/Inc/NetworkConfigWidget.h

132 lines
3.4 KiB
C
Raw Normal View History

#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