97 lines
3.0 KiB
C
97 lines
3.0 KiB
C
|
|
#ifndef IYSCREWPOSITIONSTATUS_H
|
|||
|
|
#define IYSCREWPOSITIONSTATUS_H
|
|||
|
|
|
|||
|
|
#include <string>
|
|||
|
|
#include <functional>
|
|||
|
|
#include <vector>
|
|||
|
|
#include <QImage>
|
|||
|
|
#include <QMetaType>
|
|||
|
|
|
|||
|
|
// 使用 AppCommon 提供的通用接口和类型
|
|||
|
|
#include "IVisionApplicationStatus.h"
|
|||
|
|
|
|||
|
|
// 使用 AppCommon 的 WorkStatus 枚举
|
|||
|
|
// WorkStatus, WorkStatusToString 已在 IVisionApplicationStatus.h 中定义
|
|||
|
|
|
|||
|
|
// 螺杆信息结构体
|
|||
|
|
struct ScrewInfo {
|
|||
|
|
// 螺杆端部的中心点
|
|||
|
|
double centerX = 0.0;
|
|||
|
|
double centerY = 0.0;
|
|||
|
|
double centerZ = 0.0;
|
|||
|
|
|
|||
|
|
// 轴向方向
|
|||
|
|
double axialDirX = 0.0;
|
|||
|
|
double axialDirY = 0.0;
|
|||
|
|
double axialDirZ = 0.0;
|
|||
|
|
|
|||
|
|
// 旋转角度 (-30 ~ 30度)
|
|||
|
|
double rotateAngle = 0.0;
|
|||
|
|
|
|||
|
|
// 默认构造函数
|
|||
|
|
ScrewInfo() = default;
|
|||
|
|
|
|||
|
|
// 带参构造函数
|
|||
|
|
ScrewInfo(double cx, double cy, double cz,
|
|||
|
|
double ax, double ay, double az,
|
|||
|
|
double angle)
|
|||
|
|
: centerX(cx), centerY(cy), centerZ(cz)
|
|||
|
|
, axialDirX(ax), axialDirY(ay), axialDirZ(az)
|
|||
|
|
, rotateAngle(angle) {}
|
|||
|
|
|
|||
|
|
// 拷贝构造函数和赋值运算符
|
|||
|
|
ScrewInfo(const ScrewInfo&) = default;
|
|||
|
|
ScrewInfo& operator=(const ScrewInfo&) = default;
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
// 螺杆位置结构体(继承自 PositionData 模板)
|
|||
|
|
struct ScrewPosition : public PositionData<double> {
|
|||
|
|
// 默认构造函数
|
|||
|
|
ScrewPosition() : PositionData<double>() {}
|
|||
|
|
|
|||
|
|
// 带参构造函数
|
|||
|
|
ScrewPosition(double _x, double _y, double _z, double _roll, double _pitch, double _yaw)
|
|||
|
|
: PositionData<double>(_x, _y, _z, _roll, _pitch, _yaw) {}
|
|||
|
|
|
|||
|
|
// 拷贝构造函数和赋值运算符
|
|||
|
|
ScrewPosition(const ScrewPosition&) = default;
|
|||
|
|
ScrewPosition& operator=(const ScrewPosition&) = default;
|
|||
|
|
|
|||
|
|
// 从 PositionData 拷贝构造
|
|||
|
|
ScrewPosition(const PositionData<double>& pos)
|
|||
|
|
: PositionData<double>(pos) {}
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
// 检测结果结构体(继承自 DetectionResultData 模板)
|
|||
|
|
struct DetectionResult : public DetectionResultData<ScrewPosition> {
|
|||
|
|
// 螺杆信息列表
|
|||
|
|
std::vector<ScrewInfo> screwInfoList;
|
|||
|
|
|
|||
|
|
// 额外的结果信息
|
|||
|
|
bool success = true; // 是否成功
|
|||
|
|
QString message = "检测成功"; // 结果消息
|
|||
|
|
|
|||
|
|
// 默认构造函数
|
|||
|
|
DetectionResult() = default;
|
|||
|
|
|
|||
|
|
// 拷贝构造函数和赋值运算符
|
|||
|
|
DetectionResult(const DetectionResult&) = default;
|
|||
|
|
DetectionResult& operator=(const DetectionResult&) = default;
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
// 状态回调接口(继承自 IVisionApplicationStatus 模板)
|
|||
|
|
// 使用 AppCommon 提供的通用接口,无需重复定义回调方法
|
|||
|
|
class IYScrewPositionStatus : public IVisionApplicationStatus<DetectionResult>
|
|||
|
|
{
|
|||
|
|
public:
|
|||
|
|
virtual ~IYScrewPositionStatus() = default;
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
// 声明Qt元类型,使这些结构体能够在信号槽中传递
|
|||
|
|
Q_DECLARE_METATYPE(ScrewInfo)
|
|||
|
|
Q_DECLARE_METATYPE(ScrewPosition)
|
|||
|
|
Q_DECLARE_METATYPE(DetectionResult)
|
|||
|
|
// WorkStatus 已在 IVisionApplicationStatus.h 中声明
|
|||
|
|
|
|||
|
|
#endif // IYSCREWPOSITIONSTATUS_H
|