GrabBag/App/DiscHolePose/DiscHolePoseApp/dialogdetectionconfig.h

90 lines
2.8 KiB
C
Raw Normal View History

#ifndef DIALOGDETECTIONCONFIG_H
#define DIALOGDETECTIONCONFIG_H
#include <QDialog>
#include <QString>
#include <vector>
#include "IVrConfig.h"
class QLineEdit;
class HandEyeCalibWidget;
class ToolExtrinsicWidget;
class DiscHolePosePresenter;
namespace Ui {
class DialogDetectionConfig;
}
/**
* @brief 双相机 x (砂轮盘孔 / 砂轮盘架子) 共 4 套独立配置的编辑对话框
*
* UI 由 dialogdetectionconfig.ui 在 Designer 中维护:顶部 (相机, 对象) 选择器,
* 中间 QTabWidget(手眼标定 / 算法参数),底部通信配置。
* 切换 (相机, 对象) 时会先把当前编辑器内容提交到内部工作缓存,再加载新选中那一份。
* 仅在确定 / 应用 时才把全部 4 套写回 ConfigManager 并持久化到配置文件。
*/
class DialogDetectionConfig : public QDialog
{
Q_OBJECT
public:
explicit DialogDetectionConfig(QWidget *parent = nullptr);
~DialogDetectionConfig() override;
void SetPresenter(DiscHolePosePresenter* presenter);
private slots:
void onSelectionChanged();
void onOkClicked();
void onCancelClicked();
void onApplyClicked();
void onResetCurrentClicked();
private:
struct WorkingSet
{
int cameraIndex = 1;
DetectionType detectionType = DETECTION_TYPE_DISC_HOLE;
VrHandEyeCalibMatrix handEyeMatrix;
VrAlgorithmParams algorithmParams;
};
void initNumericEditors();
void initHandEyeCalibTab();
void initToolParamsTab();
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;
DiscHolePosePresenter* m_presenter = nullptr;
// 嵌入 tabHandEye 的 verticalLayout_handEyeCalibHost 里
HandEyeCalibWidget* m_handEyeCalibWidget = nullptr;
// 嵌入 tabTool 的 verticalLayout_toolParamsHost 里
ToolExtrinsicWidget* m_toolParamsWidget = nullptr;
// 内部工作缓存:4 条 (camera, type) set
std::vector<WorkingSet> m_workingSets;
int m_currentLoadedIndex = -1; // 当前编辑器映射到的 m_workingSets 下标
int m_cameraCount = 1;
};
#endif // DIALOGDETECTIONCONFIG_H