#ifndef DIALOGDETECTIONCONFIG_H #define DIALOGDETECTIONCONFIG_H #include #include #include #include "IVrConfig.h" class QLineEdit; class HandEyeCalibWidget; class ScrewPositionPresenter; namespace Ui { class DialogDetectionConfig; } /** * @brief 双相机 × (螺杆 / 工具盘) 共 4 套独立配置的编辑对话框 * * UI 由 dialogdetectionconfig.ui 在 Designer 中维护:顶部 (相机, 对象) 选择器, * 中间 QTabWidget(手眼标定 / 算法参数),算法参数 Tab 左右双列。 * 切换 (相机, 对象) 时会先把当前编辑器内容提交到内部工作缓存,再加载新选中那一份。 * 仅在确定 / 应用 时才把全部 4 套写回 ConfigManager 并持久化到 config.xml。 */ class DialogDetectionConfig : public QDialog { Q_OBJECT public: explicit DialogDetectionConfig(QWidget *parent = nullptr); ~DialogDetectionConfig() override; void SetPresenter(ScrewPositionPresenter* presenter); private slots: void onSelectionChanged(); void onOkClicked(); void onCancelClicked(); void onApplyClicked(); void onResetCurrentClicked(); private: struct WorkingSet { int cameraIndex = 1; DetectionType detectionType = DETECTION_TYPE_SCREW; VrHandEyeCalibMatrix handEyeMatrix; VrAlgorithmParams algorithmParams; }; void initNumericEditors(); void initHandEyeCalibTab(); void initNetworkConfigControls(); void loadNetworkConfig(); void rebuildCameraSelector(); void loadFromConfig(); bool commitCurrentEditorsToWorkingSet(QString* errMsg = nullptr); void loadWorkingSetToEditors(int workingIndex); bool saveAllWorkingSetsToConfig(); int findWorkingIndex(int cameraIndex, DetectionType type) const; int currentWorkingIndex() const; static void setDoubleEditorText(QLineEdit* edit, double value); static void setIntEditorText(QLineEdit* edit, int value); bool tryGetDouble(QLineEdit* edit, const QString& label, double& value); bool tryGetInt(QLineEdit* edit, const QString& label, int& value); static QString detectionTypeLabel(DetectionType type); private: Ui::DialogDetectionConfig* ui = nullptr; ScrewPositionPresenter* m_presenter = nullptr; // 嵌入 tabHandEye 的 verticalLayout_handEyeCalibHost 里 HandEyeCalibWidget* m_handEyeCalibWidget = nullptr; // 内部工作缓存:4 条 (camera, type) set std::vector m_workingSets; int m_currentLoadedIndex = -1; // 当前编辑器映射到的 m_workingSets 下标 int m_cameraCount = 1; }; #endif // DIALOGDETECTIONCONFIG_H