108 lines
3.5 KiB
C++
108 lines
3.5 KiB
C++
#ifndef IYBAGTHREADPOSITIONSTATUS_H
|
||
#define IYBAGTHREADPOSITIONSTATUS_H
|
||
|
||
#include <string>
|
||
#include <functional>
|
||
#include <vector>
|
||
#include <QImage>
|
||
#include <QMetaType>
|
||
|
||
// 使用 AppCommon 提供的通用接口和类型
|
||
#include "IVisionApplicationStatus.h"
|
||
|
||
// 使用 AppCommon 的 WorkStatus 枚举
|
||
// WorkStatus, WorkStatusToString 已在 IVisionApplicationStatus.h 中定义
|
||
|
||
// 拆线信息结构体
|
||
struct ThreadInfo {
|
||
// 拆线端部的中心点
|
||
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;
|
||
|
||
// 默认构造函数
|
||
ThreadInfo() = default;
|
||
|
||
// 带参构造函数
|
||
ThreadInfo(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) {}
|
||
|
||
// 拷贝构造函数和赋值运算符
|
||
ThreadInfo(const ThreadInfo&) = default;
|
||
ThreadInfo& operator=(const ThreadInfo&) = default;
|
||
};
|
||
|
||
// 位置类型枚举
|
||
enum class ThreadPosType {
|
||
ThreadHead = 0, // 线头位置
|
||
OperatePos = 1 // 下刀位置
|
||
};
|
||
|
||
// 拆线位置结构体(继承自 PositionData 模板)
|
||
struct ThreadPosition : public PositionData<double> {
|
||
ThreadPosType type = ThreadPosType::OperatePos; // 位置类型
|
||
int groupIndex = 0; // 所属组序号(同一条线的线头和下刀属于同一组)
|
||
|
||
// 默认构造函数
|
||
ThreadPosition() : PositionData<double>() {}
|
||
|
||
// 带参构造函数
|
||
ThreadPosition(double _x, double _y, double _z, double _roll, double _pitch, double _yaw,
|
||
ThreadPosType _type = ThreadPosType::OperatePos, int _groupIndex = 0)
|
||
: PositionData<double>(_x, _y, _z, _roll, _pitch, _yaw)
|
||
, type(_type), groupIndex(_groupIndex) {}
|
||
|
||
// 拷贝构造函数和赋值运算符
|
||
ThreadPosition(const ThreadPosition&) = default;
|
||
ThreadPosition& operator=(const ThreadPosition&) = default;
|
||
|
||
// 从 PositionData 拷贝构造
|
||
ThreadPosition(const PositionData<double>& pos)
|
||
: PositionData<double>(pos) {}
|
||
};
|
||
|
||
// 检测结果结构体(继承自 DetectionResultData 模板)
|
||
struct DetectionResult : public DetectionResultData<ThreadPosition> {
|
||
// 拆线信息列表
|
||
std::vector<ThreadInfo> threadInfoList;
|
||
|
||
// 额外的结果信息
|
||
bool success = true; // 是否成功
|
||
QString message = "检测成功"; // 结果消息
|
||
|
||
// 默认构造函数
|
||
DetectionResult() = default;
|
||
|
||
// 拷贝构造函数和赋值运算符
|
||
DetectionResult(const DetectionResult&) = default;
|
||
DetectionResult& operator=(const DetectionResult&) = default;
|
||
};
|
||
|
||
// 状态回调接口(继承自 IVisionApplicationStatus 模板)
|
||
// 使用 AppCommon 提供的通用接口,无需重复定义回调方法
|
||
class IYBagThreadPositionStatus : public IVisionApplicationStatus<DetectionResult>
|
||
{
|
||
public:
|
||
virtual ~IYBagThreadPositionStatus() = default;
|
||
};
|
||
|
||
// 声明Qt元类型,使这些结构体能够在信号槽中传递
|
||
Q_DECLARE_METATYPE(ThreadInfo)
|
||
Q_DECLARE_METATYPE(ThreadPosition)
|
||
Q_DECLARE_METATYPE(DetectionResult)
|
||
// WorkStatus 已在 IVisionApplicationStatus.h 中声明
|
||
|
||
#endif // IYBAGTHREADPOSITIONSTATUS_H
|