Compare commits
26 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3521a7f225 | |||
| 6111634eff | |||
| 4d42314a84 | |||
| 6456232114 | |||
| 525b39851a | |||
| 5f965f0d8e | |||
| 3568495aa9 | |||
| 410da482bc | |||
| 43acd5ba01 | |||
| 5dc589aee0 | |||
| e8ae6aa3b9 | |||
| 304a1aa28b | |||
| b2ed6e9c73 | |||
| dcce0a6665 | |||
| eda0a01098 | |||
| e43d60e264 | |||
| 24d34f39be | |||
| d326dabff7 | |||
| 5009832b3a | |||
| 5350d9431a | |||
| 87d9a7fe01 | |||
| fa6ce1a606 | |||
| e3a778919a | |||
| 486a9defc1 | |||
| ea1a666619 | |||
| 50989bcd5b |
102
HPPA/AppSettings.cpp
Normal file
102
HPPA/AppSettings.cpp
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
#include "AppSettings.h"
|
||||||
|
#include <QCoreApplication>
|
||||||
|
|
||||||
|
const QString AppSettings::kDefaultDataFolder = QStringLiteral("C:\\HPPA_image");
|
||||||
|
const QString AppSettings::kDefaultFileName = QStringLiteral("test_image");
|
||||||
|
const int AppSettings::kDefaultFrameRate = 20;
|
||||||
|
const int AppSettings::kDefaultIntegrationTime = 1;
|
||||||
|
const int AppSettings::kDefaultGain = 0;
|
||||||
|
const QString AppSettings::kDefaultSLRDataFolder = QString();
|
||||||
|
const QString AppSettings::kDefaultDepthCameraDataFolder = QString();
|
||||||
|
|
||||||
|
AppSettings::AppSettings()
|
||||||
|
: m_settings(QSettings::IniFormat, QSettings::UserScope,
|
||||||
|
QStringLiteral("IRIS"), QStringLiteral("HPPA"))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
AppSettings& AppSettings::instance()
|
||||||
|
{
|
||||||
|
static AppSettings s;
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString AppSettings::dataFolder() const
|
||||||
|
{
|
||||||
|
return m_settings.value("General/DataFolder", kDefaultDataFolder).toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
void AppSettings::setDataFolder(const QString& path)
|
||||||
|
{
|
||||||
|
m_settings.setValue("General/DataFolder", path);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString AppSettings::fileName() const
|
||||||
|
{
|
||||||
|
return m_settings.value("General/FileName", kDefaultFileName).toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
void AppSettings::setFileName(const QString& path)
|
||||||
|
{
|
||||||
|
m_settings.setValue("General/FileName", path);
|
||||||
|
}
|
||||||
|
|
||||||
|
int AppSettings::frameRate() const
|
||||||
|
{
|
||||||
|
return m_settings.value("CameraParams/FrameRate", kDefaultFrameRate).toInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
void AppSettings::setFrameRate(int value)
|
||||||
|
{
|
||||||
|
m_settings.setValue("CameraParams/FrameRate", value);
|
||||||
|
}
|
||||||
|
|
||||||
|
int AppSettings::integrationTime() const
|
||||||
|
{
|
||||||
|
return m_settings.value("CameraParams/IntegrationTime", kDefaultIntegrationTime).toInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
void AppSettings::setIntegrationTime(int value)
|
||||||
|
{
|
||||||
|
m_settings.setValue("CameraParams/IntegrationTime", value);
|
||||||
|
}
|
||||||
|
|
||||||
|
int AppSettings::gain() const
|
||||||
|
{
|
||||||
|
return m_settings.value("CameraParams/Gain", kDefaultGain).toInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
void AppSettings::setGain(int value)
|
||||||
|
{
|
||||||
|
m_settings.setValue("CameraParams/Gain", value);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString AppSettings::slrDataFolder() const
|
||||||
|
{
|
||||||
|
QString path = m_settings.value("General/SLRDataFolder").toString();
|
||||||
|
if (path.isEmpty())
|
||||||
|
{
|
||||||
|
return QCoreApplication::applicationDirPath() + "/CapturedImages/";
|
||||||
|
}
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AppSettings::setSlrDataFolder(const QString& path)
|
||||||
|
{
|
||||||
|
m_settings.setValue("General/SLRDataFolder", path);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString AppSettings::depthCameraDataFolder() const
|
||||||
|
{
|
||||||
|
QString path = m_settings.value("General/DepthCameraDataFolder").toString();
|
||||||
|
if (path.isEmpty())
|
||||||
|
{
|
||||||
|
return QCoreApplication::applicationDirPath() + "/CapturedDepthImages/";
|
||||||
|
}
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AppSettings::setDepthCameraDataFolder(const QString& path)
|
||||||
|
{
|
||||||
|
m_settings.setValue("General/DepthCameraDataFolder", path);
|
||||||
|
}
|
||||||
54
HPPA/AppSettings.h
Normal file
54
HPPA/AppSettings.h
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QSettings>
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
|
class AppSettings
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static AppSettings& instance();
|
||||||
|
|
||||||
|
// 数据路径
|
||||||
|
QString dataFolder() const;
|
||||||
|
void setDataFolder(const QString& path);
|
||||||
|
|
||||||
|
QString fileName() const;
|
||||||
|
void setFileName(const QString& path);
|
||||||
|
|
||||||
|
// 帧率
|
||||||
|
int frameRate() const;
|
||||||
|
void setFrameRate(int value);
|
||||||
|
|
||||||
|
// 积分时间
|
||||||
|
int integrationTime() const;
|
||||||
|
void setIntegrationTime(int value);
|
||||||
|
|
||||||
|
// 增益
|
||||||
|
int gain() const;
|
||||||
|
void setGain(int value);
|
||||||
|
|
||||||
|
// 单反相机数据保存路径
|
||||||
|
QString slrDataFolder() const;
|
||||||
|
void setSlrDataFolder(const QString& path);
|
||||||
|
|
||||||
|
// 深度相机数据保存路径
|
||||||
|
QString depthCameraDataFolder() const;
|
||||||
|
void setDepthCameraDataFolder(const QString& path);
|
||||||
|
// 在此处添加更多参数的 getter/setter ...
|
||||||
|
|
||||||
|
private:
|
||||||
|
AppSettings();
|
||||||
|
AppSettings(const AppSettings&) = delete;
|
||||||
|
AppSettings& operator=(const AppSettings&) = delete;
|
||||||
|
|
||||||
|
QSettings m_settings;
|
||||||
|
|
||||||
|
// 默认值
|
||||||
|
static const QString kDefaultDataFolder;
|
||||||
|
static const QString kDefaultFileName;
|
||||||
|
static const int kDefaultFrameRate;
|
||||||
|
static const int kDefaultIntegrationTime;
|
||||||
|
static const int kDefaultGain;
|
||||||
|
static const QString kDefaultSLRDataFolder;
|
||||||
|
static const QString kDefaultDepthCameraDataFolder;
|
||||||
|
};
|
||||||
@ -2,11 +2,9 @@
|
|||||||
|
|
||||||
TwoMotionCaptureCoordinator::TwoMotionCaptureCoordinator(
|
TwoMotionCaptureCoordinator::TwoMotionCaptureCoordinator(
|
||||||
IrisMultiMotorController* motorCtrl,
|
IrisMultiMotorController* motorCtrl,
|
||||||
ImagerOperationBase* cameraCtrl,
|
|
||||||
QObject* parent)
|
QObject* parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
, m_motorCtrl(motorCtrl)
|
, m_motorCtrl(motorCtrl)
|
||||||
, m_cameraCtrl(cameraCtrl)
|
|
||||||
, m_isRunning(false)
|
, m_isRunning(false)
|
||||||
{
|
{
|
||||||
//这些信号槽是按照逻辑顺序的
|
//这些信号槽是按照逻辑顺序的
|
||||||
@ -20,35 +18,6 @@ TwoMotionCaptureCoordinator::TwoMotionCaptureCoordinator(
|
|||||||
this, &TwoMotionCaptureCoordinator::handlePositionReached);
|
this, &TwoMotionCaptureCoordinator::handlePositionReached);
|
||||||
//connect(m_motorCtrl, &IrisMultiMotorController::moveFailed,
|
//connect(m_motorCtrl, &IrisMultiMotorController::moveFailed,
|
||||||
// this, &TwoMotionCaptureCoordinator::handleError);
|
// this, &TwoMotionCaptureCoordinator::handleError);
|
||||||
|
|
||||||
connect(this, &TwoMotionCaptureCoordinator::startRecordHSISignal,
|
|
||||||
m_cameraCtrl, &ImagerOperationBase::start_record);
|
|
||||||
connect(this, &TwoMotionCaptureCoordinator::stopRecordHSISignal,
|
|
||||||
m_cameraCtrl, &ImagerOperationBase::stop_record);
|
|
||||||
connect(m_cameraCtrl, &ImagerOperationBase::RecordFinishedSignal_WhenFrameNumberMeet,
|
|
||||||
this, &TwoMotionCaptureCoordinator::handleCaptureCompleteWhenFrameNumberMeet);
|
|
||||||
//connect(m_cameraCtrl, &ImagerOperationBase::RecordFinishedSignal_WhenFrameNumberNotMeet,
|
|
||||||
// this, &TwoMotionCaptureCoordinator::handleCaptureCompleteWhenFrameNumberNotMeet);
|
|
||||||
//connect(m_cameraCtrl, &ImagerOperationBase::captureFailed,
|
|
||||||
// this, &TwoMotionCaptureCoordinator::handleError);
|
|
||||||
}
|
|
||||||
|
|
||||||
TwoMotionCaptureCoordinator::TwoMotionCaptureCoordinator(
|
|
||||||
IrisMultiMotorController* motorCtrl,
|
|
||||||
QObject* parent)
|
|
||||||
: QObject(parent)
|
|
||||||
, m_motorCtrl(motorCtrl)
|
|
||||||
, m_isRunning(false)
|
|
||||||
{
|
|
||||||
connect(this, SIGNAL(moveTo(int, double, double, int)),
|
|
||||||
m_motorCtrl, SLOT(moveTo(int, double, double, int)));
|
|
||||||
connect(this, SIGNAL(moveTo(const std::vector<double>, const std::vector<double>, int)),
|
|
||||||
m_motorCtrl, SLOT(moveTo(const std::vector<double>, const std::vector<double>, int)));
|
|
||||||
|
|
||||||
connect(m_motorCtrl, &IrisMultiMotorController::motorStopSignal,
|
|
||||||
this, &TwoMotionCaptureCoordinator::handlePositionReached);
|
|
||||||
//connect(m_motorCtrl, &IrisMultiMotorController::moveFailed,
|
|
||||||
// this, &TwoMotionCaptureCoordinator::handleError);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TwoMotionCaptureCoordinator::~TwoMotionCaptureCoordinator()
|
TwoMotionCaptureCoordinator::~TwoMotionCaptureCoordinator()
|
||||||
@ -97,15 +66,12 @@ void TwoMotionCaptureCoordinator::stop()
|
|||||||
std::cout << "The user manually stops the collection! " << std::endl;
|
std::cout << "The user manually stops the collection! " << std::endl;
|
||||||
savePathLinesToCsv();
|
savePathLinesToCsv();
|
||||||
|
|
||||||
emit sequenceComplete(1);
|
|
||||||
emit finishRecordLineNumSignal(m_numCurrentPathLine);
|
emit finishRecordLineNumSignal(m_numCurrentPathLine);
|
||||||
//emit stopRecordHSISignal(m_numCurrentPathLine);
|
emit stopRecordHSISignal(m_numCurrentPathLine);
|
||||||
if (m_cameraCtrl != nullptr)
|
|
||||||
{
|
|
||||||
m_cameraCtrl->stop_record();
|
|
||||||
}
|
|
||||||
|
|
||||||
move2LocBeforeStart();
|
move2LocBeforeStart();
|
||||||
|
|
||||||
|
emit sequenceComplete(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TwoMotionCaptureCoordinator::getLocBeforeStart()
|
void TwoMotionCaptureCoordinator::getLocBeforeStart()
|
||||||
@ -323,11 +289,7 @@ void TwoMotionCaptureCoordinator::handlePositionReached(int motorID, double pos)
|
|||||||
|
|
||||||
//停止采集高光谱数据
|
//停止采集高光谱数据
|
||||||
emit finishRecordLineNumSignal(m_numCurrentPathLine);
|
emit finishRecordLineNumSignal(m_numCurrentPathLine);
|
||||||
//emit stopRecordHSISignal(m_numCurrentPathLine);
|
emit stopRecordHSISignal(m_numCurrentPathLine);
|
||||||
if (m_cameraCtrl!=nullptr)
|
|
||||||
{
|
|
||||||
m_cameraCtrl->stop_record();
|
|
||||||
}
|
|
||||||
|
|
||||||
m_isMoving2XMax = false;
|
m_isMoving2XMax = false;
|
||||||
m_isImagerFrameNumberMeet = false;
|
m_isImagerFrameNumberMeet = false;
|
||||||
@ -471,7 +433,8 @@ OneMotionCaptureCoordinator::OneMotionCaptureCoordinator(
|
|||||||
|
|
||||||
OneMotionCaptureCoordinator::~OneMotionCaptureCoordinator()
|
OneMotionCaptureCoordinator::~OneMotionCaptureCoordinator()
|
||||||
{
|
{
|
||||||
|
disconnect(m_motorCtrl, &IrisMultiMotorController::motorStopSignal,
|
||||||
|
this, &OneMotionCaptureCoordinator::handleMotorStoped);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OneMotionCaptureCoordinator::startStepMotion(OneMotionCapturePathLine pathLine)
|
void OneMotionCaptureCoordinator::startStepMotion(OneMotionCapturePathLine pathLine)
|
||||||
@ -585,6 +548,10 @@ void OneMotionCaptureCoordinator::handleMotorStoped(int motorID, double pos)
|
|||||||
m_cameraCtrl->stop_record();
|
m_cameraCtrl->stop_record();
|
||||||
}
|
}
|
||||||
move2LocBeforeStart();
|
move2LocBeforeStart();
|
||||||
|
|
||||||
|
// emit sequenceComplete last: the slot connected to it may delete this object,
|
||||||
|
// so no member access is allowed after this point.
|
||||||
|
emit sequenceComplete(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OneMotionCaptureCoordinator::handleCaptureComplete(double index)
|
void OneMotionCaptureCoordinator::handleCaptureComplete(double index)
|
||||||
|
|||||||
@ -38,9 +38,6 @@ class TwoMotionCaptureCoordinator : public QObject
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
TwoMotionCaptureCoordinator(IrisMultiMotorController* motorCtrl,
|
|
||||||
ImagerOperationBase* cameraCtrl,
|
|
||||||
QObject* parent = nullptr);
|
|
||||||
TwoMotionCaptureCoordinator(IrisMultiMotorController* motorCtrl,
|
TwoMotionCaptureCoordinator(IrisMultiMotorController* motorCtrl,
|
||||||
QObject* parent = nullptr);
|
QObject* parent = nullptr);
|
||||||
~TwoMotionCaptureCoordinator();
|
~TwoMotionCaptureCoordinator();
|
||||||
@ -62,13 +59,15 @@ signals:
|
|||||||
|
|
||||||
void recordState(bool state);
|
void recordState(bool state);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void handleCaptureCompleteWhenFrameNumberMeet();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void start(QVector<PathLine> pathLines);
|
void start(QVector<PathLine> pathLines);
|
||||||
void stop();
|
void stop();
|
||||||
void getRecordState();
|
void getRecordState();
|
||||||
|
|
||||||
void handlePositionReached(int motorID, double pos);
|
void handlePositionReached(int motorID, double pos);
|
||||||
void handleCaptureCompleteWhenFrameNumberMeet();
|
|
||||||
void handleError(const QString& error);
|
void handleError(const QString& error);
|
||||||
|
|
||||||
void move2LocBeforeStart();
|
void move2LocBeforeStart();
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
@ -40,13 +40,13 @@ private:
|
|||||||
QString m_nomalQSS;
|
QString m_nomalQSS;
|
||||||
QString m_lockedQSS;
|
QString m_lockedQSS;
|
||||||
|
|
||||||
// ״ֵ̬
|
// 状态值
|
||||||
int m_currentIndex;
|
int m_currentIndex;
|
||||||
bool m_isPlaying;
|
bool m_isPlaying;
|
||||||
bool m_isLocked;
|
bool m_isLocked;
|
||||||
int m_lockedIndex;
|
int m_lockedIndex;
|
||||||
|
|
||||||
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
// 参数
|
||||||
int m_playInterval;
|
int m_playInterval;
|
||||||
int m_intervalButtonSize;
|
int m_intervalButtonSize;
|
||||||
|
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
#include "Corning410Imager.h"
|
#include "Corning410Imager.h"
|
||||||
|
|
||||||
Corning410Imager::Corning410Imager()
|
Corning410Imager::Corning410Imager()
|
||||||
{
|
{
|
||||||
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD>У<EFBFBD><EFBFBD>ʹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
|
//配置文件:如果没有,就创建配置文件
|
||||||
string CfgFile = getPathofEXE() + "\\corning410.cfg";
|
string CfgFile = getPathofEXE() + "\\corning410.cfg";
|
||||||
m_configfile.setConfigfilePath(CfgFile);
|
m_configfile.setConfigfilePath(CfgFile);
|
||||||
if (!m_configfile.isConfigfileExist())
|
if (!m_configfile.isConfigfileExist())
|
||||||
@ -18,7 +18,7 @@ Corning410Imager::~Corning410Imager()
|
|||||||
{
|
{
|
||||||
if (buffer != nullptr)
|
if (buffer != nullptr)
|
||||||
{
|
{
|
||||||
std::cout << "<EFBFBD>ͷŶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD>" << std::endl;
|
std::cout << "释放堆上内存" << std::endl;
|
||||||
free(buffer);
|
free(buffer);
|
||||||
free(dark);
|
free(dark);
|
||||||
free(white);
|
free(white);
|
||||||
@ -70,7 +70,7 @@ void Corning410Imager::connectImager(const char* camera_sn)
|
|||||||
{
|
{
|
||||||
m_imager.connect();
|
m_imager.connect();
|
||||||
|
|
||||||
//<EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ò<EFBFBD><EFBFBD><EFBFBD>
|
//读取配置文件参数,并为相机设置参数
|
||||||
bool ret, ret1, ret2;
|
bool ret, ret1, ret2;
|
||||||
|
|
||||||
int spatialBin;
|
int spatialBin;
|
||||||
@ -82,8 +82,8 @@ void Corning410Imager::connectImager(const char* camera_sn)
|
|||||||
bool haha = m_imager.setSpectralBin(spectralBin);
|
bool haha = m_imager.setSpectralBin(spectralBin);
|
||||||
bool haha2 = m_imager.setSpatialBin(spatialBin);
|
bool haha2 = m_imager.setSpatialBin(spatialBin);
|
||||||
|
|
||||||
std::cout << "spectralBin<EFBFBD><EFBFBD>" << spectralBin << std::endl;
|
std::cout << "spectralBin:" << spectralBin << std::endl;
|
||||||
std::cout << "spatialBin<EFBFBD><EFBFBD>" << spatialBin << std::endl;
|
std::cout << "spatialBin:" << spatialBin << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
float gain, offset;
|
float gain, offset;
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <opencv2/core/core.hpp>
|
#include <opencv2/core/core.hpp>
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
#include "CustomDockWidgetBase.h"
|
#include "CustomDockWidgetBase.h"
|
||||||
|
|
||||||
CustomDockWidgetBase::CustomDockWidgetBase(QMainWindow* parent)
|
CustomDockWidgetBase::CustomDockWidgetBase(QMainWindow* parent)
|
||||||
: QDockWidget(parent),
|
: QDockWidget(parent),
|
||||||
@ -55,7 +55,7 @@ void CustomDockWidgetBase::initialize()
|
|||||||
border-top: 1px solid #2c586b;
|
border-top: 1px solid #2c586b;
|
||||||
border-left: 1px solid #2c586b;
|
border-left: 1px solid #2c586b;
|
||||||
border-right: 1px solid #2c586b;
|
border-right: 1px solid #2c586b;
|
||||||
border-bottom: none; /* ȡ<EFBFBD><EFBFBD><EFBFBD>ײ<EFBFBD><EFBFBD>߿<EFBFBD> */
|
border-bottom: none; /* 取消底部边框 */
|
||||||
|
|
||||||
border-top-left-radius: 5px;
|
border-top-left-radius: 5px;
|
||||||
border-top-right-radius: 5px;
|
border-top-right-radius: 5px;
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <QDockWidget>
|
#include <QDockWidget>
|
||||||
#include <QToolButton>
|
#include <QToolButton>
|
||||||
#include <QStyle>
|
#include <QStyle>
|
||||||
|
|||||||
205
HPPA/DepthCamera.ui
Normal file
205
HPPA/DepthCamera.ui
Normal file
@ -0,0 +1,205 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>DepthCameraClass</class>
|
||||||
|
<widget class="QDialog" name="DepthCameraClass">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>857</width>
|
||||||
|
<height>477</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>DepthCamera</string>
|
||||||
|
</property>
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true">QGroupBox
|
||||||
|
{
|
||||||
|
border: 12px solid transparent;
|
||||||
|
/*border-top: 12px solid transparent;
|
||||||
|
border-right: 0px solid transparent;
|
||||||
|
border-bottom: 0px solid transparent;
|
||||||
|
border-left: 0px solid transparent;*/
|
||||||
|
color: #ACCDFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
QPushButton
|
||||||
|
{
|
||||||
|
/*width: 172px;
|
||||||
|
height: 56px;*/
|
||||||
|
font: 19pt "新宋体";
|
||||||
|
background-color: qlineargradient(
|
||||||
|
spread:pad,
|
||||||
|
x1:0.5, y1:0, x2:0.5, y2:1,
|
||||||
|
stop:0 #283D86,
|
||||||
|
stop:1 #0F1A40
|
||||||
|
);
|
||||||
|
color: white;
|
||||||
|
border: none;
|
||||||
|
padding: 8px 16px;
|
||||||
|
border-radius: 4px;
|
||||||
|
}
|
||||||
|
QPushButton:hover
|
||||||
|
{
|
||||||
|
background-color: qlineargradient(
|
||||||
|
spread:pad,
|
||||||
|
x1:0, y1:0, x2:1, y2:0,
|
||||||
|
stop:0 #3A4875,
|
||||||
|
stop:1 #5F6B91
|
||||||
|
);
|
||||||
|
}
|
||||||
|
/* 按下时的效果 */
|
||||||
|
QPushButton:pressed
|
||||||
|
{
|
||||||
|
background-color: qlineargradient(
|
||||||
|
spread:pad,
|
||||||
|
x1:0, y1:0, x2:1, y2:0,
|
||||||
|
stop:0 #1A254F,
|
||||||
|
stop:1 #3A466B
|
||||||
|
);
|
||||||
|
/* 可选:添加下压效果 */
|
||||||
|
padding-top: 9px;
|
||||||
|
padding-bottom: 7px;
|
||||||
|
}</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout_2">
|
||||||
|
<item row="0" column="1">
|
||||||
|
<spacer name="verticalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>18</width>
|
||||||
|
<height>100</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QPushButton" name="closeDepthCamera_btn">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>关 闭</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QPushButton" name="openDepthCamera_btn">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>打 开</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<spacer name="horizontalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>135</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="2">
|
||||||
|
<spacer name="horizontalSpacer_2">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>135</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="1">
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true">QLabel {
|
||||||
|
color: rgb(255, 255, 255);
|
||||||
|
}</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>数据路径</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLineEdit" name="dataFolderLineEdit">
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true">QLineEdit {
|
||||||
|
background-color: #142D7F;
|
||||||
|
color: #e6eeff;
|
||||||
|
border: 1px solid #2f6bff;
|
||||||
|
border-radius: 6px;
|
||||||
|
padding: 4px 8px;
|
||||||
|
min-width: 70px;
|
||||||
|
min-height: 20px;
|
||||||
|
font-size: 13px;
|
||||||
|
}</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>./CapturedImages</string>
|
||||||
|
</property>
|
||||||
|
<property name="readOnly">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="dataFolderBtn">
|
||||||
|
<property name="text">
|
||||||
|
<string>...</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="1">
|
||||||
|
<spacer name="verticalSpacer_3">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>18</width>
|
||||||
|
<height>100</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<layoutdefault spacing="6" margin="11"/>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
||||||
341
HPPA/DepthCameraWindow.cpp
Normal file
341
HPPA/DepthCameraWindow.cpp
Normal file
@ -0,0 +1,341 @@
|
|||||||
|
#include "DepthCameraWindow.h"
|
||||||
|
|
||||||
|
DepthCameraWindow::DepthCameraWindow(QWidget* parent)
|
||||||
|
: QDialog(parent)
|
||||||
|
{
|
||||||
|
ui.setupUi(this);
|
||||||
|
|
||||||
|
m_DepthCameraThread = new QThread();
|
||||||
|
m_DepthCameraOperation = new DepthCameraOperation();
|
||||||
|
m_DepthCameraOperation->moveToThread(m_DepthCameraThread);
|
||||||
|
m_DepthCameraThread->start();
|
||||||
|
|
||||||
|
connect(ui.openDepthCamera_btn, &QPushButton::clicked, this, &DepthCameraWindow::openDepthCamera);
|
||||||
|
connect(ui.closeDepthCamera_btn, &QPushButton::clicked, this, &DepthCameraWindow::closeDepthCamera);
|
||||||
|
|
||||||
|
connect(this, &DepthCameraWindow::openDepthCameraSignal, m_DepthCameraOperation, &DepthCameraOperation::OpenDepthCamera);
|
||||||
|
|
||||||
|
connect(m_DepthCameraOperation, &DepthCameraOperation::CamOpenedSignal, this, &DepthCameraWindow::onCamOpened);
|
||||||
|
connect(m_DepthCameraOperation, &DepthCameraOperation::CamClosedSignal, this, &DepthCameraWindow::onCamClosed);
|
||||||
|
|
||||||
|
connect(m_DepthCameraOperation, &DepthCameraOperation::PlotSignal, this, &DepthCameraWindow::PlotDepthImageSignal);
|
||||||
|
connect(m_DepthCameraOperation, &DepthCameraOperation::CamClosedSignal, this, &DepthCameraWindow::DepthCamClosedSignal);
|
||||||
|
|
||||||
|
connect(this->ui.dataFolderBtn, SIGNAL(clicked()), this, SLOT(onSelectDataFolder()));
|
||||||
|
|
||||||
|
// 初始化数据保存路径显示(从 AppSettings 恢复或使用默认)
|
||||||
|
ui.dataFolderLineEdit->setText(AppSettings::instance().depthCameraDataFolder());
|
||||||
|
}
|
||||||
|
|
||||||
|
DepthCameraWindow::~DepthCameraWindow()
|
||||||
|
{
|
||||||
|
m_DepthCameraThread->quit();
|
||||||
|
m_DepthCameraThread->wait();
|
||||||
|
delete m_DepthCameraOperation;
|
||||||
|
m_DepthCameraOperation = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DepthCameraWindow::onSelectDataFolder()
|
||||||
|
{
|
||||||
|
QString dir = QFileDialog::getExistingDirectory(this,
|
||||||
|
QString::fromLocal8Bit("选择数据保存路径"),
|
||||||
|
ui.dataFolderLineEdit->text());
|
||||||
|
|
||||||
|
if (!dir.isEmpty())
|
||||||
|
{
|
||||||
|
ui.dataFolderLineEdit->setText(dir);
|
||||||
|
AppSettings::instance().setDepthCameraDataFolder(dir);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DepthCameraWindow::openDepthCamera()
|
||||||
|
{
|
||||||
|
if (!m_DepthCameraOperation->getRecordStatus())
|
||||||
|
{
|
||||||
|
emit openDepthCameraSignal();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DepthCameraWindow::onCamOpened()
|
||||||
|
{
|
||||||
|
ui.openDepthCamera_btn->setEnabled(false);
|
||||||
|
ui.closeDepthCamera_btn->setEnabled(true);
|
||||||
|
|
||||||
|
ui.openDepthCamera_btn->setText(QString::fromLocal8Bit("已打开"));
|
||||||
|
}
|
||||||
|
|
||||||
|
void DepthCameraWindow::closeDepthCamera()
|
||||||
|
{
|
||||||
|
m_DepthCameraOperation->CloseDepthCamera();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DepthCameraWindow::onCamClosed()
|
||||||
|
{
|
||||||
|
ui.openDepthCamera_btn->setEnabled(true);
|
||||||
|
ui.closeDepthCamera_btn->setEnabled(false);
|
||||||
|
|
||||||
|
ui.openDepthCamera_btn->setText(QString::fromLocal8Bit("打 开"));
|
||||||
|
}
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
DepthCameraOperation::DepthCameraOperation()
|
||||||
|
{
|
||||||
|
m_pipe = nullptr;
|
||||||
|
m_func = nullptr;
|
||||||
|
record = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
DepthCameraOperation::~DepthCameraOperation()
|
||||||
|
{
|
||||||
|
if (m_pipe)
|
||||||
|
{
|
||||||
|
m_pipe->stop();
|
||||||
|
|
||||||
|
delete m_pipe;
|
||||||
|
m_pipe = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DepthCameraOperation::OpenDepthCamera()
|
||||||
|
{
|
||||||
|
if (m_pipe)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
m_pipe = new ob::Pipeline();
|
||||||
|
|
||||||
|
std::shared_ptr<ob::Config> config = std::make_shared<ob::Config>();
|
||||||
|
|
||||||
|
// Get device from pipeline.
|
||||||
|
auto device = m_pipe->getDevice();
|
||||||
|
auto devInfo = device->getDeviceInfo();
|
||||||
|
auto pid = devInfo->getPid();
|
||||||
|
auto vid = devInfo->getVid();
|
||||||
|
|
||||||
|
//// Get sensorList from device.
|
||||||
|
//auto sensorList = device->getSensorList();
|
||||||
|
|
||||||
|
//for (uint32_t index = 0; index < sensorList->getCount(); index++) {
|
||||||
|
// // Query all supported infrared sensor type and enable the infrared stream.
|
||||||
|
// // For dual infrared device, enable the left and right infrared streams.
|
||||||
|
// // For single infrared device, enable the infrared stream.
|
||||||
|
// OBSensorType sensorType = sensorList->getSensorType(index);
|
||||||
|
// std::cout << "Supported Sensor type: " << sensorType << std::endl;
|
||||||
|
|
||||||
|
// // Enable the stream for the sensor type.
|
||||||
|
// config->enableStream(sensorType);
|
||||||
|
//}
|
||||||
|
|
||||||
|
config->enableVideoStream(OB_STREAM_DEPTH, 640, 480, 15, OB_FORMAT_Y16);
|
||||||
|
config->enableVideoStream(OB_STREAM_COLOR, 640, 480, 15, OB_FORMAT_YUYV);
|
||||||
|
config->enableAccelStream();
|
||||||
|
config->enableGyroStream();
|
||||||
|
config->setFrameAggregateOutputMode(OB_FRAME_AGGREGATE_OUTPUT_ALL_TYPE_FRAME_REQUIRE);
|
||||||
|
config->setAlignMode(ALIGN_D2C_HW_MODE);
|
||||||
|
|
||||||
|
m_pipe->enableFrameSync();
|
||||||
|
|
||||||
|
// Create a format converter filter.
|
||||||
|
auto formatConverter = std::make_shared<ob::FormatConvertFilter>();
|
||||||
|
|
||||||
|
m_pipe->start(config);
|
||||||
|
|
||||||
|
// Drop several frames
|
||||||
|
for (int i = 0; i < 15; ++i) {
|
||||||
|
auto lost = m_pipe->waitForFrameset(100);
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pointCloud = std::make_shared<ob::PointCloudFilter>();
|
||||||
|
|
||||||
|
int frameIndex = 0;
|
||||||
|
record = true;
|
||||||
|
QString fileNamePrefix = AppSettings::instance().depthCameraDataFolder() + QDir::separator() + AppSettings::instance().fileName();
|
||||||
|
QString imuFilePath = fileNamePrefix + "_IMU.txt";
|
||||||
|
std::ofstream imuFile(imuFilePath.toStdString(), std::ios::out | std::ios::trunc);
|
||||||
|
while (record)
|
||||||
|
{
|
||||||
|
if(frameIndex==0)
|
||||||
|
{
|
||||||
|
emit CamOpenedSignal();
|
||||||
|
std::cout << "Start recording..." << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto frameSet = m_pipe->waitForFrameset(100);
|
||||||
|
if (frameSet == nullptr)
|
||||||
|
{
|
||||||
|
std::cout << "No frames received in 100ms..." << std::endl;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cout << "DepthCamera frameIndex:"<< frameIndex << std::endl;
|
||||||
|
|
||||||
|
// 彩色和深度图像
|
||||||
|
auto depthFrame = frameSet->getFrame(OB_FRAME_DEPTH)->as<ob::DepthFrame>();
|
||||||
|
auto colorFrame = frameSet->getFrame(OB_FRAME_COLOR)->as<ob::ColorFrame>();
|
||||||
|
|
||||||
|
// Convert the color frame to RGB format.
|
||||||
|
if (colorFrame->format() != OB_FORMAT_RGB) {
|
||||||
|
if (colorFrame->format() == OB_FORMAT_MJPG) {
|
||||||
|
formatConverter->setFormatConvertType(FORMAT_MJPG_TO_RGB);
|
||||||
|
}
|
||||||
|
else if (colorFrame->format() == OB_FORMAT_UYVY) {
|
||||||
|
formatConverter->setFormatConvertType(FORMAT_UYVY_TO_RGB);
|
||||||
|
}
|
||||||
|
else if (colorFrame->format() == OB_FORMAT_YUYV) {
|
||||||
|
formatConverter->setFormatConvertType(FORMAT_YUYV_TO_RGB);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
std::cout << "Color format is not support!" << std::endl;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
colorFrame = formatConverter->process(colorFrame)->as<ob::ColorFrame>();
|
||||||
|
}
|
||||||
|
// Processed the color frames to BGR format, use OpenCV to save to disk.
|
||||||
|
formatConverter->setFormatConvertType(FORMAT_RGB_TO_BGR);
|
||||||
|
colorFrame = formatConverter->process(colorFrame)->as<ob::ColorFrame>();
|
||||||
|
|
||||||
|
saveDepthFrame(depthFrame, frameIndex, fileNamePrefix.toStdString());
|
||||||
|
saveColorFrame(colorFrame, frameIndex, fileNamePrefix.toStdString());
|
||||||
|
|
||||||
|
cv::Mat colorMat(colorFrame->height(), colorFrame->width(), CV_8UC3, colorFrame->data());
|
||||||
|
cv::Mat rgbMat;
|
||||||
|
cv::cvtColor(colorMat, rgbMat, cv::COLOR_BGR2RGB);
|
||||||
|
m_colorImage = QImage(rgbMat.data, rgbMat.cols, rgbMat.rows, static_cast<int>(rgbMat.step), QImage::Format_RGB888).copy();
|
||||||
|
|
||||||
|
cv::Mat depthMat(depthFrame->height(), depthFrame->width(), CV_16UC1, depthFrame->data());
|
||||||
|
cv::Mat depthMat8U;
|
||||||
|
depthMat.convertTo(depthMat8U, CV_8UC1, 255.0 / 4096.0);
|
||||||
|
cv::Mat depthColorMap;
|
||||||
|
cv::applyColorMap(depthMat8U, depthColorMap, cv::COLORMAP_JET);
|
||||||
|
cv::Mat depthRgbMat;
|
||||||
|
cv::cvtColor(depthColorMap, depthRgbMat, cv::COLOR_BGR2RGB);
|
||||||
|
m_depthImage = QImage(depthRgbMat.data, depthRgbMat.cols, depthRgbMat.rows, static_cast<int>(depthRgbMat.step), QImage::Format_RGB888).copy();
|
||||||
|
//m_depthImage = QImage(depthMat.data, depthMat.cols, depthMat.rows, static_cast<int>(depthMat.step), QImage::Format_Grayscale16).copy();
|
||||||
|
|
||||||
|
emit PlotSignal();
|
||||||
|
|
||||||
|
//点云
|
||||||
|
pointCloud->setCreatePointFormat(OB_FORMAT_RGB_POINT);
|
||||||
|
std::shared_ptr<ob::Frame> frame = pointCloud->process(frameSet);
|
||||||
|
|
||||||
|
QString plyPath = fileNamePrefix + "_"+ QString::number(frameIndex) + ".ply";
|
||||||
|
ob::PointCloudHelper::savePointcloudToPly(plyPath.toStdString().c_str(), frame, false, false, 50);
|
||||||
|
|
||||||
|
//惯导数据
|
||||||
|
auto accelFrameRaw = frameSet->getFrame(OB_FRAME_ACCEL);
|
||||||
|
auto accelFrame = accelFrameRaw->as<ob::AccelFrame>();
|
||||||
|
auto accelIndex = accelFrame->getIndex();
|
||||||
|
auto accelTimeStampUs = accelFrame->getTimeStampUs();
|
||||||
|
auto accelTemperature = accelFrame->getTemperature();
|
||||||
|
auto accelType = accelFrame->getType();
|
||||||
|
//if (frameIndex % 50 == 0)
|
||||||
|
//{ // print information every 50 frames.
|
||||||
|
// auto accelValue = accelFrame->getValue();
|
||||||
|
// printImuValue(accelValue, accelIndex, accelTimeStampUs, accelTemperature, accelType, "m/s^2");
|
||||||
|
//}
|
||||||
|
//auto accelValue = accelFrame->getValue();
|
||||||
|
//printImuValue(accelValue, accelIndex, accelTimeStampUs, accelTemperature, accelType, "m/s^2");
|
||||||
|
|
||||||
|
auto gyroFrameRaw = frameSet->getFrame(OB_FRAME_GYRO);
|
||||||
|
auto gyroFrame = gyroFrameRaw->as<ob::GyroFrame>();
|
||||||
|
auto gyroIndex = gyroFrame->getIndex();
|
||||||
|
auto gyroTimeStampUs = gyroFrame->getTimeStampUs();
|
||||||
|
auto gyroTemperature = gyroFrame->getTemperature();
|
||||||
|
auto gyroType = gyroFrame->getType();
|
||||||
|
//if (frameIndex % 50 == 0) { // print information every 50 frames.
|
||||||
|
// auto gyroValue = gyroFrame->getValue();
|
||||||
|
// printImuValue(gyroValue, gyroIndex, gyroTimeStampUs, gyroTemperature, gyroType, "rad/s");
|
||||||
|
//}
|
||||||
|
//auto gyroValue = gyroFrame->getValue();
|
||||||
|
//printImuValue(gyroValue, gyroIndex, gyroTimeStampUs, gyroTemperature, gyroType, "rad/s");
|
||||||
|
|
||||||
|
saveImuData(imuFile, accelFrame, gyroFrame);
|
||||||
|
|
||||||
|
frameIndex++;
|
||||||
|
}
|
||||||
|
|
||||||
|
imuFile.close();
|
||||||
|
|
||||||
|
m_pipe->stop();
|
||||||
|
|
||||||
|
delete m_pipe;
|
||||||
|
m_pipe = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DepthCameraOperation::saveDepthFrame(const std::shared_ptr<ob::DepthFrame> depthFrame, const uint32_t frameIndex, std::string fileNamePrefix_)
|
||||||
|
{
|
||||||
|
std::vector<int> params;
|
||||||
|
params.push_back(cv::IMWRITE_PNG_COMPRESSION);
|
||||||
|
params.push_back(0);
|
||||||
|
params.push_back(cv::IMWRITE_PNG_STRATEGY);
|
||||||
|
params.push_back(cv::IMWRITE_PNG_STRATEGY_DEFAULT);
|
||||||
|
std::string depthName = fileNamePrefix_ + "_Depth_" + std::to_string(depthFrame->width()) + "x" + std::to_string(depthFrame->height()) + "_" + std::to_string(frameIndex) + "_"
|
||||||
|
+ std::to_string(depthFrame->timeStamp()) + "ms.png";
|
||||||
|
cv::Mat depthMat(depthFrame->height(), depthFrame->width(), CV_16UC1, depthFrame->data());
|
||||||
|
cv::imwrite(depthName, depthMat, params);
|
||||||
|
//std::cout << "Depth saved:" << depthName << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DepthCameraOperation::saveColorFrame(const std::shared_ptr<ob::ColorFrame> colorFrame, const uint32_t frameIndex, std::string fileNamePrefix_)
|
||||||
|
{
|
||||||
|
std::vector<int> params;
|
||||||
|
params.push_back(cv::IMWRITE_PNG_COMPRESSION);
|
||||||
|
params.push_back(0);
|
||||||
|
params.push_back(cv::IMWRITE_PNG_STRATEGY);
|
||||||
|
params.push_back(cv::IMWRITE_PNG_STRATEGY_DEFAULT);
|
||||||
|
std::string colorName = fileNamePrefix_ + "_Color_" + std::to_string(colorFrame->width()) + "x" + std::to_string(colorFrame->height()) + "_" + std::to_string(frameIndex) + "_"
|
||||||
|
+ std::to_string(colorFrame->timeStamp()) + "ms.png";
|
||||||
|
cv::Mat depthMat(colorFrame->height(), colorFrame->width(), CV_8UC3, colorFrame->data());
|
||||||
|
cv::imwrite(colorName, depthMat, params);
|
||||||
|
//std::cout << "Color saved:" << colorName << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DepthCameraOperation::printImuValue(OBFloat3D obFloat3d, uint64_t index, uint64_t timeStampUs, float temperature, OBFrameType type, const std::string& unitStr)
|
||||||
|
{
|
||||||
|
std::cout << "frame index: " << index << std::endl;
|
||||||
|
auto typeStr = ob::TypeHelper::convertOBFrameTypeToString(type);
|
||||||
|
std::cout << typeStr << " Frame: \n\r{\n\r"
|
||||||
|
<< " tsp = " << timeStampUs << "\n\r"
|
||||||
|
<< " temperature = " << temperature << "\n\r"
|
||||||
|
<< " " << typeStr << ".x = " << obFloat3d.x << unitStr << "\n\r"
|
||||||
|
<< " " << typeStr << ".y = " << obFloat3d.y << unitStr << "\n\r"
|
||||||
|
<< " " << typeStr << ".z = " << obFloat3d.z << unitStr << "\n\r"
|
||||||
|
<< "}\n\r" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DepthCameraOperation::saveImuData(std::ofstream& imuFile, const std::shared_ptr<ob::AccelFrame>& accelFrame, const std::shared_ptr<ob::GyroFrame>& gyroFrame)
|
||||||
|
{
|
||||||
|
if (!imuFile.is_open())
|
||||||
|
return;
|
||||||
|
|
||||||
|
auto accelValue = accelFrame->getValue();
|
||||||
|
auto gyroValue = gyroFrame->getValue();
|
||||||
|
|
||||||
|
// position (acceleration): ax, ay, az
|
||||||
|
// attitude (angular velocity): gx, gy, gz
|
||||||
|
imuFile << accelFrame->getIndex() << ","
|
||||||
|
<< accelFrame->getTimeStampUs() << ","
|
||||||
|
<< accelValue.x << "," << accelValue.y << "," << accelValue.z << ","
|
||||||
|
<< gyroFrame->getIndex() << ","
|
||||||
|
<< gyroFrame->getTimeStampUs() << ","
|
||||||
|
<< gyroValue.x << "," << gyroValue.y << "," << gyroValue.z << "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
void DepthCameraOperation::OpenDepthCamera_callback()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void DepthCameraOperation::setCallback(void(*func)())
|
||||||
|
{
|
||||||
|
m_func = func;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DepthCameraOperation::CloseDepthCamera()
|
||||||
|
{
|
||||||
|
std::cout << "DepthCameraOperation::CloseDepthCamera,关闭深度相机" << std::endl;
|
||||||
|
|
||||||
|
record = false;
|
||||||
|
|
||||||
|
emit CamClosedSignal();
|
||||||
|
}
|
||||||
88
HPPA/DepthCameraWindow.h
Normal file
88
HPPA/DepthCameraWindow.h
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QDialog>
|
||||||
|
#include <QNetworkRequest>
|
||||||
|
#include <QNetworkReply>
|
||||||
|
#include <QNetworkAccessManager>
|
||||||
|
#include <QImage>
|
||||||
|
#include <Qthread>
|
||||||
|
#include <QDir>
|
||||||
|
//#include <QLabel>
|
||||||
|
#include <QFileDialog>
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include "ui_DepthCamera.h"
|
||||||
|
#include "AppSettings.h"
|
||||||
|
|
||||||
|
#include <fstream>
|
||||||
|
#include <opencv2/opencv.hpp>
|
||||||
|
#include <libobsensor/ObSensor.hpp>
|
||||||
|
#include "libobsensor/hpp/Utils.hpp"
|
||||||
|
typedef void(*func)();
|
||||||
|
|
||||||
|
class DepthCameraOperation :public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
DepthCameraOperation();
|
||||||
|
~DepthCameraOperation();
|
||||||
|
|
||||||
|
QImage m_colorImage;
|
||||||
|
QImage m_depthImage;
|
||||||
|
void setCallback(void(*func)());
|
||||||
|
bool getRecordStatus() const { return record; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
ob::Pipeline* m_pipe;
|
||||||
|
cv::Mat frame;
|
||||||
|
|
||||||
|
func m_func;
|
||||||
|
|
||||||
|
void saveDepthFrame(const std::shared_ptr<ob::DepthFrame> depthFrame, const uint32_t frameIndex, std::string fileNamePrefix_);
|
||||||
|
void saveColorFrame(const std::shared_ptr<ob::ColorFrame> colorFrame, const uint32_t frameIndex, std::string fileNamePrefix_);
|
||||||
|
void printImuValue(OBFloat3D obFloat3d, uint64_t index, uint64_t timeStampUs, float temperature, OBFrameType type, const std::string& unitStr);
|
||||||
|
void saveImuData(std::ofstream& imuFile, const std::shared_ptr<ob::AccelFrame>& accelFrame, const std::shared_ptr<ob::GyroFrame>& gyroFrame);
|
||||||
|
|
||||||
|
bool record;
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void OpenDepthCamera();
|
||||||
|
void OpenDepthCamera_callback();//不使用信号而使用回调函数来通知界面刷新视频
|
||||||
|
void CloseDepthCamera();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void PlotSignal();
|
||||||
|
|
||||||
|
void CamOpenedSignal();
|
||||||
|
void CamClosedSignal();
|
||||||
|
};
|
||||||
|
|
||||||
|
class DepthCameraWindow : public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
DepthCameraWindow(QWidget* parent = nullptr);
|
||||||
|
~DepthCameraWindow();
|
||||||
|
|
||||||
|
DepthCameraOperation* m_DepthCameraOperation;
|
||||||
|
|
||||||
|
public Q_SLOTS:
|
||||||
|
void openDepthCamera();
|
||||||
|
void onCamOpened();
|
||||||
|
void closeDepthCamera();
|
||||||
|
void onCamClosed();
|
||||||
|
|
||||||
|
void onSelectDataFolder();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void openDepthCameraSignal();
|
||||||
|
void PlotDepthImageSignal();
|
||||||
|
void DepthCamClosedSignal();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::DepthCameraClass ui;
|
||||||
|
QThread* m_DepthCameraThread;
|
||||||
|
|
||||||
|
};
|
||||||
46
HPPA/FileNameLineEdit.cpp
Normal file
46
HPPA/FileNameLineEdit.cpp
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
#include "FileNameLineEdit.h"
|
||||||
|
|
||||||
|
FileNameLineEdit::FileNameLineEdit(QWidget* parent)
|
||||||
|
: QLineEdit(parent)
|
||||||
|
{
|
||||||
|
setText(AppSettings::instance().fileName());
|
||||||
|
connect(this, &QLineEdit::textChanged, this, &FileNameLineEdit::onTextChanged);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FileNameLineEdit::keyPressEvent(QKeyEvent* event)
|
||||||
|
{
|
||||||
|
if (event->key() == Qt::Key_Space)
|
||||||
|
{
|
||||||
|
event->ignore();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
QLineEdit::keyPressEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FileNameLineEdit::inputMethodEvent(QInputMethodEvent* event)
|
||||||
|
{
|
||||||
|
QString commitString = event->commitString();
|
||||||
|
if (commitString.contains(' '))
|
||||||
|
{
|
||||||
|
commitString.remove(' ');
|
||||||
|
QInputMethodEvent filtered(event->preeditString(), event->attributes());
|
||||||
|
filtered.setCommitString(commitString);
|
||||||
|
QLineEdit::inputMethodEvent(&filtered);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
QLineEdit::inputMethodEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FileNameLineEdit::onTextChanged(const QString& text)
|
||||||
|
{
|
||||||
|
QString cleaned = text;
|
||||||
|
if (cleaned.contains(' '))
|
||||||
|
{
|
||||||
|
int pos = cursorPosition();
|
||||||
|
cleaned.remove(' ');
|
||||||
|
setText(cleaned);
|
||||||
|
setCursorPosition(qMin(pos, cleaned.length()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
AppSettings::instance().setFileName(cleaned);
|
||||||
|
}
|
||||||
21
HPPA/FileNameLineEdit.h
Normal file
21
HPPA/FileNameLineEdit.h
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QLineEdit>
|
||||||
|
#include <QKeyEvent>
|
||||||
|
#include "AppSettings.h"
|
||||||
|
|
||||||
|
class FileNameLineEdit : public QLineEdit
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit FileNameLineEdit(QWidget* parent = nullptr);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void keyPressEvent(QKeyEvent* event) override;
|
||||||
|
|
||||||
|
void inputMethodEvent(QInputMethodEvent* event) override;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void onTextChanged(const QString& text);
|
||||||
|
};
|
||||||
861
HPPA/HPPA - 副本 (2).ui
Normal file
861
HPPA/HPPA - 副本 (2).ui
Normal file
@ -0,0 +1,861 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>HPPAClass</class>
|
||||||
|
<widget class="QMainWindow" name="HPPAClass">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>1486</width>
|
||||||
|
<height>898</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Spectral Insight</string>
|
||||||
|
</property>
|
||||||
|
<property name="windowIcon">
|
||||||
|
<iconset resource="HPPA.qrc">
|
||||||
|
<normaloff>:/ico/resources/icons/ico/Spectral_Insight_128.ico</normaloff>:/ico/resources/icons/ico/Spectral_Insight_128.ico</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true"/>
|
||||||
|
</property>
|
||||||
|
<widget class="QWidget" name="centralWidget"/>
|
||||||
|
<widget class="QMenuBar" name="menuBar">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>1486</width>
|
||||||
|
<height>30</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<pointsize>-1</pointsize>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true">QMenuBar{
|
||||||
|
background:#F0F0F0;
|
||||||
|
color:rgb(0,0,0);
|
||||||
|
font-size:14px;
|
||||||
|
padding:1px;
|
||||||
|
border:1px solid rgb(165,171,184);
|
||||||
|
}
|
||||||
|
|
||||||
|
QMenuBar::item{
|
||||||
|
background:#F0F0F0;
|
||||||
|
width:30px;
|
||||||
|
height:15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
QMenuBar::item:selected{
|
||||||
|
background:rgb(185,196,221);
|
||||||
|
}
|
||||||
|
|
||||||
|
QMenu{
|
||||||
|
background:rgb(255,255,255);
|
||||||
|
color:rgb(0,0,0);
|
||||||
|
border:1px solid rgb(165,171,184);
|
||||||
|
}
|
||||||
|
|
||||||
|
QMenu::item:selected{
|
||||||
|
background:rgb(69,123,255);
|
||||||
|
color:white;
|
||||||
|
}
|
||||||
|
</string>
|
||||||
|
</property>
|
||||||
|
<widget class="QMenu" name="file">
|
||||||
|
<property name="title">
|
||||||
|
<string>文件</string>
|
||||||
|
</property>
|
||||||
|
<addaction name="mActionOpenImg"/>
|
||||||
|
<addaction name="separator"/>
|
||||||
|
<addaction name="mSetting"/>
|
||||||
|
<addaction name="action_exit"/>
|
||||||
|
</widget>
|
||||||
|
<widget class="QMenu" name="menuspectrometer">
|
||||||
|
<property name="title">
|
||||||
|
<string>光谱仪</string>
|
||||||
|
</property>
|
||||||
|
<widget class="QMenu" name="menu">
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<family>宋体</family>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="title">
|
||||||
|
<string>选择相机类型</string>
|
||||||
|
</property>
|
||||||
|
<addaction name="mActionPica_L"/>
|
||||||
|
<addaction name="mActionPica_NIR"/>
|
||||||
|
<addaction name="mActionPika_XC2"/>
|
||||||
|
<addaction name="separator"/>
|
||||||
|
<addaction name="mActionCorning_410"/>
|
||||||
|
</widget>
|
||||||
|
<addaction name="menu"/>
|
||||||
|
<addaction name="action_connect_imager"/>
|
||||||
|
<addaction name="separator"/>
|
||||||
|
<addaction name="action_auto_exposure"/>
|
||||||
|
<addaction name="action_focus"/>
|
||||||
|
<addaction name="action_dark"/>
|
||||||
|
<addaction name="action_reference"/>
|
||||||
|
<addaction name="separator"/>
|
||||||
|
<addaction name="action_start_recording"/>
|
||||||
|
<addaction name="separator"/>
|
||||||
|
<addaction name="actionOpenDirectory"/>
|
||||||
|
</widget>
|
||||||
|
<widget class="QMenu" name="menuhelp">
|
||||||
|
<property name="title">
|
||||||
|
<string>帮助</string>
|
||||||
|
</property>
|
||||||
|
<addaction name="action_about"/>
|
||||||
|
</widget>
|
||||||
|
<widget class="QMenu" name="mWindowsMenu">
|
||||||
|
<property name="title">
|
||||||
|
<string>窗口</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QMenu" name="menu_2">
|
||||||
|
<property name="title">
|
||||||
|
<string>扫描平台</string>
|
||||||
|
</property>
|
||||||
|
<addaction name="mAction_is_no_motor"/>
|
||||||
|
<addaction name="mAction_1AxisMotor"/>
|
||||||
|
<addaction name="mAction_2AxisMotor_new"/>
|
||||||
|
<addaction name="separator"/>
|
||||||
|
<addaction name="mAction_RobotArm"/>
|
||||||
|
</widget>
|
||||||
|
<widget class="QMenu" name="mMenuScenario">
|
||||||
|
<property name="title">
|
||||||
|
<string>应用场景</string>
|
||||||
|
</property>
|
||||||
|
<addaction name="mActionOneMotorScenario"/>
|
||||||
|
<addaction name="mActionPlantPhenotypeScenario"/>
|
||||||
|
</widget>
|
||||||
|
<widget class="QMenu" name="menu_4">
|
||||||
|
<property name="title">
|
||||||
|
<string>数据处理</string>
|
||||||
|
</property>
|
||||||
|
<addaction name="action_4"/>
|
||||||
|
<addaction name="action_5"/>
|
||||||
|
<addaction name="action_13"/>
|
||||||
|
</widget>
|
||||||
|
<addaction name="file"/>
|
||||||
|
<addaction name="menuspectrometer"/>
|
||||||
|
<addaction name="mMenuScenario"/>
|
||||||
|
<addaction name="menu_4"/>
|
||||||
|
<addaction name="menu_2"/>
|
||||||
|
<addaction name="mWindowsMenu"/>
|
||||||
|
<addaction name="menuhelp"/>
|
||||||
|
</widget>
|
||||||
|
<widget class="QToolBar" name="mainToolBar">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<family>宋体</family>
|
||||||
|
<pointsize>2</pointsize>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>相机控制</string>
|
||||||
|
</property>
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true">QToolBar{
|
||||||
|
|
||||||
|
background-color: #f5f5f5;
|
||||||
|
color:rgb(0,0,0);
|
||||||
|
}
|
||||||
|
QToolBar QToolButton {
|
||||||
|
background: #f5f5f5; /* 按钮背景颜色 */
|
||||||
|
font-size:15px;
|
||||||
|
border-radius: 3px; /* 按钮圆角 */
|
||||||
|
padding: 4px; /* 按钮内边距 */
|
||||||
|
}
|
||||||
|
QToolBar QToolButton:hover {
|
||||||
|
background: rgb(185,196,221); /* 按钮悬停背景颜色 */
|
||||||
|
color: white; /* 按钮悬停文字颜色 */
|
||||||
|
}
|
||||||
|
</string>
|
||||||
|
</property>
|
||||||
|
<attribute name="toolBarArea">
|
||||||
|
<enum>TopToolBarArea</enum>
|
||||||
|
</attribute>
|
||||||
|
<attribute name="toolBarBreak">
|
||||||
|
<bool>false</bool>
|
||||||
|
</attribute>
|
||||||
|
<addaction name="action_connect_imager"/>
|
||||||
|
<addaction name="action_auto_exposure"/>
|
||||||
|
<addaction name="action_focus"/>
|
||||||
|
<addaction name="action_dark"/>
|
||||||
|
<addaction name="action_reference"/>
|
||||||
|
<addaction name="action_start_recording"/>
|
||||||
|
<addaction name="actionOpenDirectory"/>
|
||||||
|
<addaction name="mActionPan"/>
|
||||||
|
<addaction name="mActionSpectral"/>
|
||||||
|
</widget>
|
||||||
|
<widget class="QStatusBar" name="statusBar">
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true">QStatusBar
|
||||||
|
{
|
||||||
|
background-color: #0D1233;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
QStatusBar::item
|
||||||
|
{
|
||||||
|
border: none;
|
||||||
|
}</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="CustomDockWidgetBase" name="mDockWidgetSimulator">
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true"/>
|
||||||
|
</property>
|
||||||
|
<property name="features">
|
||||||
|
<set>QDockWidget::AllDockWidgetFeatures</set>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>3D模型</string>
|
||||||
|
</property>
|
||||||
|
<attribute name="dockWidgetArea">
|
||||||
|
<number>1</number>
|
||||||
|
</attribute>
|
||||||
|
<widget class="QWidget" name="dockWidgetContents_2">
|
||||||
|
<layout class="QGridLayout" name="gridLayout_7">
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="verticalSpacing">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
<widget class="CustomDockWidgetHideAbove" name="mDockWidgetSpectrometer">
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true"/>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>控制</string>
|
||||||
|
</property>
|
||||||
|
<attribute name="dockWidgetArea">
|
||||||
|
<number>2</number>
|
||||||
|
</attribute>
|
||||||
|
<widget class="QWidget" name="controlContents">
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true">QWidget #controlContents
|
||||||
|
{
|
||||||
|
background-color: #0E1C4C;
|
||||||
|
|
||||||
|
border-top: 1px solid #2c586b;
|
||||||
|
border-left: 1px solid #2c586b;
|
||||||
|
border-right: 1px solid #2c586b;
|
||||||
|
border-bottom: 1px solid #2c586b;
|
||||||
|
|
||||||
|
border-top-left-radius: 0px;
|
||||||
|
border-top-right-radius: 0px;
|
||||||
|
border-bottom-left-radius: 10px;
|
||||||
|
border-bottom-right-radius: 10px;
|
||||||
|
}
|
||||||
|
</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout_5">
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>2</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>2</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>2</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>2</number>
|
||||||
|
</property>
|
||||||
|
<property name="horizontalSpacing">
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QTabWidget" name="controlTabWidget">
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true">QTabBar::tab {
|
||||||
|
background: #0E1C4C;
|
||||||
|
color: white;
|
||||||
|
padding: 6px 12px;
|
||||||
|
border: none;
|
||||||
|
border-top: 1px solid #27376C;
|
||||||
|
height: 41;
|
||||||
|
}
|
||||||
|
|
||||||
|
QTabBar::tab:selected {
|
||||||
|
background: #0D1233;
|
||||||
|
color: white;
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*QTabBar::tab:hover {
|
||||||
|
background: #141A45;
|
||||||
|
}*/
|
||||||
|
|
||||||
|
QTabWidget::pane {
|
||||||
|
border: none;
|
||||||
|
border-top: 1px solid #27376C;
|
||||||
|
background: #0D1233;
|
||||||
|
top: -1px;
|
||||||
|
}
|
||||||
|
</string>
|
||||||
|
</property>
|
||||||
|
<property name="tabPosition">
|
||||||
|
<enum>QTabWidget::South</enum>
|
||||||
|
</property>
|
||||||
|
<property name="tabShape">
|
||||||
|
<enum>QTabWidget::Rounded</enum>
|
||||||
|
</property>
|
||||||
|
<property name="currentIndex">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="elideMode">
|
||||||
|
<enum>Qt::ElideNone</enum>
|
||||||
|
</property>
|
||||||
|
<widget class="QWidget" name="rgbCameraWidget">
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true">QGroupBox
|
||||||
|
{
|
||||||
|
border: 12px solid transparent;
|
||||||
|
color: #ACCDFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
QPushButton
|
||||||
|
{
|
||||||
|
/*width: 172px;
|
||||||
|
height: 56px;*/
|
||||||
|
font: 19pt "新宋体";
|
||||||
|
background-color: qlineargradient(
|
||||||
|
spread:pad,
|
||||||
|
x1:0.5, y1:0, x2:0.5, y2:1,
|
||||||
|
stop:0 #283D86,
|
||||||
|
stop:1 #0F1A40
|
||||||
|
);
|
||||||
|
color: white;
|
||||||
|
border: none;
|
||||||
|
padding: 8px 16px;
|
||||||
|
border-radius: 4px;
|
||||||
|
}
|
||||||
|
QPushButton:hover
|
||||||
|
{
|
||||||
|
background-color: qlineargradient(
|
||||||
|
spread:pad,
|
||||||
|
x1:0, y1:0, x2:1, y2:0,
|
||||||
|
stop:0 #3A4875,
|
||||||
|
stop:1 #5F6B91
|
||||||
|
);
|
||||||
|
}
|
||||||
|
/* 按下时的效果 */
|
||||||
|
QPushButton:pressed
|
||||||
|
{
|
||||||
|
background-color: qlineargradient(
|
||||||
|
spread:pad,
|
||||||
|
x1:0, y1:0, x2:1, y2:0,
|
||||||
|
stop:0 #1A254F,
|
||||||
|
stop:1 #3A466B
|
||||||
|
);
|
||||||
|
/* 可选:添加下压效果 */
|
||||||
|
padding-top: 9px;
|
||||||
|
padding-bottom: 7px;
|
||||||
|
}</string>
|
||||||
|
</property>
|
||||||
|
<attribute name="title">
|
||||||
|
<string>rgb相机</string>
|
||||||
|
</attribute>
|
||||||
|
<layout class="QGridLayout" name="gridLayout_4" rowstretch="2,4,2" columnstretch="1,3,1">
|
||||||
|
<item row="0" column="1">
|
||||||
|
<spacer name="verticalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>174</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<spacer name="horizontalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>115</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<layout class="QGridLayout" name="gridLayout_3" columnstretch="1,1">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>20</number>
|
||||||
|
</property>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QPushButton" name="take_video_btn">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>录制视频</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QPushButton" name="take_photo_btn">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>拍照</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QPushButton" name="close_rgb_camera_btn">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>关闭</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QPushButton" name="open_rgb_camera_btn">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>打开</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="2">
|
||||||
|
<spacer name="horizontalSpacer_2">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>115</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<spacer name="verticalSpacer_2">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>173</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
<widget class="QToolBar" name="toolBar">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>toolBar</string>
|
||||||
|
</property>
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true">QToolBar {
|
||||||
|
background: #040125;/*transparent*/
|
||||||
|
border: 1px solid #040125;
|
||||||
|
}</string>
|
||||||
|
</property>
|
||||||
|
<property name="movable">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<attribute name="toolBarArea">
|
||||||
|
<enum>LeftToolBarArea</enum>
|
||||||
|
</attribute>
|
||||||
|
<attribute name="toolBarBreak">
|
||||||
|
<bool>false</bool>
|
||||||
|
</attribute>
|
||||||
|
</widget>
|
||||||
|
<widget class="QToolBar" name="toolBar_2">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>toolBar_2</string>
|
||||||
|
</property>
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true">QToolBar {
|
||||||
|
background: #040125;/*transparent*/
|
||||||
|
border: 1px solid #040125;
|
||||||
|
}</string>
|
||||||
|
</property>
|
||||||
|
<property name="movable">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<attribute name="toolBarArea">
|
||||||
|
<enum>RightToolBarArea</enum>
|
||||||
|
</attribute>
|
||||||
|
<attribute name="toolBarBreak">
|
||||||
|
<bool>false</bool>
|
||||||
|
</attribute>
|
||||||
|
</widget>
|
||||||
|
<widget class="QToolBar" name="toolBar_3">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>toolBar_3</string>
|
||||||
|
</property>
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true">QToolBar {
|
||||||
|
background: #040125;/*transparent*/
|
||||||
|
border: 1px solid #040125;
|
||||||
|
}</string>
|
||||||
|
</property>
|
||||||
|
<property name="movable">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<attribute name="toolBarArea">
|
||||||
|
<enum>BottomToolBarArea</enum>
|
||||||
|
</attribute>
|
||||||
|
<attribute name="toolBarBreak">
|
||||||
|
<bool>false</bool>
|
||||||
|
</attribute>
|
||||||
|
</widget>
|
||||||
|
<action name="action_exit">
|
||||||
|
<property name="text">
|
||||||
|
<string>退出</string>
|
||||||
|
</property>
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<family>Adobe Devanagari</family>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="action_open">
|
||||||
|
<property name="text">
|
||||||
|
<string>open</string>
|
||||||
|
</property>
|
||||||
|
<property name="iconText">
|
||||||
|
<string>open</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionpreference">
|
||||||
|
<property name="text">
|
||||||
|
<string>preference...</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="action_start_recording">
|
||||||
|
<property name="text">
|
||||||
|
<string>采集</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="action_focus">
|
||||||
|
<property name="text">
|
||||||
|
<string>调焦</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="action_auto_exposure">
|
||||||
|
<property name="text">
|
||||||
|
<string>曝光</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="action_dark">
|
||||||
|
<property name="text">
|
||||||
|
<string>暗电流</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="action_reference">
|
||||||
|
<property name="text">
|
||||||
|
<string>白板</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="action_connect_imager">
|
||||||
|
<property name="text">
|
||||||
|
<string>连接相机</string>
|
||||||
|
</property>
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<family>宋体</family>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionOpenDirectory">
|
||||||
|
<property name="text">
|
||||||
|
<string>打开文件夹</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="mActionPica_L">
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Pika L</string>
|
||||||
|
</property>
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<family>宋体</family>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="mActionCorning_410">
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Corning 410</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="mActionPika_XC2">
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Pika XC2</string>
|
||||||
|
</property>
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<family>宋体</family>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="action_about">
|
||||||
|
<property name="text">
|
||||||
|
<string>关于</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="mActionPica_NIR">
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Pika NIR</string>
|
||||||
|
</property>
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<family>宋体</family>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionpanel">
|
||||||
|
<property name="text">
|
||||||
|
<string>面板</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="action">
|
||||||
|
<property name="text">
|
||||||
|
<string>工具栏</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="action_2">
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>马达</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="mAction_is_no_motor">
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>无</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="mAction_2AxisMotor">
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>2 轴线性马达</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="mAction_RobotArm">
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>机械臂</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="mAction_1AxisMotor">
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>1 轴线性马达</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="mActionOneMotorScenario">
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>室内1轴线性平台</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="action_4">
|
||||||
|
<property name="text">
|
||||||
|
<string>辐亮度</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="action_5">
|
||||||
|
<property name="text">
|
||||||
|
<string>反射率</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="action_6">
|
||||||
|
<property name="text">
|
||||||
|
<string>机械臂</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="action_7">
|
||||||
|
<property name="text">
|
||||||
|
<string>显微镜</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="action_8">
|
||||||
|
<property name="text">
|
||||||
|
<string>三脚架(旋转平台)</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="mActionOpenImg">
|
||||||
|
<property name="text">
|
||||||
|
<string>打开影像</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="action_10">
|
||||||
|
<property name="text">
|
||||||
|
<string>关闭影像</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="mSetting">
|
||||||
|
<property name="text">
|
||||||
|
<string>设置</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="action_13">
|
||||||
|
<property name="text">
|
||||||
|
<string>拼接</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="mActionPlantPhenotypeScenario">
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>植物表型</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="action2">
|
||||||
|
<property name="text">
|
||||||
|
<string>2轴旋转平台</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="mAction_2AxisMotor_new">
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>2 轴线性马达</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="mActionPan">
|
||||||
|
<property name="text">
|
||||||
|
<string>漫游</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="mActionSpectral">
|
||||||
|
<property name="text">
|
||||||
|
<string>光谱</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
</widget>
|
||||||
|
<layoutdefault spacing="6" margin="11"/>
|
||||||
|
<customwidgets>
|
||||||
|
<customwidget>
|
||||||
|
<class>CustomDockWidgetBase</class>
|
||||||
|
<extends>QDockWidget</extends>
|
||||||
|
<header>customdockwidgetbase.h</header>
|
||||||
|
<container>1</container>
|
||||||
|
</customwidget>
|
||||||
|
<customwidget>
|
||||||
|
<class>CustomDockWidgetHideAbove</class>
|
||||||
|
<extends>QDockWidget</extends>
|
||||||
|
<header>CustomDockWidgetBase.h</header>
|
||||||
|
<container>1</container>
|
||||||
|
</customwidget>
|
||||||
|
</customwidgets>
|
||||||
|
<resources>
|
||||||
|
<include location="HPPA.qrc"/>
|
||||||
|
</resources>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
||||||
1043
HPPA/HPPA.cpp
1043
HPPA/HPPA.cpp
File diff suppressed because it is too large
Load Diff
51
HPPA/HPPA.h
51
HPPA/HPPA.h
@ -73,6 +73,18 @@
|
|||||||
|
|
||||||
#include "recordFrameCounter.h"
|
#include "recordFrameCounter.h"
|
||||||
|
|
||||||
|
#include "setWindow.h"
|
||||||
|
#include "AppSettings.h"
|
||||||
|
#include "FileNameLineEdit.h"
|
||||||
|
|
||||||
|
#include "rgbCameraWindow.h"
|
||||||
|
#include "DepthCameraWindow.h"
|
||||||
|
#include "SingleLensReflexCameraWindow.h"
|
||||||
|
|
||||||
|
#include "LayerTreeImageNode.h"
|
||||||
|
|
||||||
|
#include "TimedDataCollection.h"
|
||||||
|
|
||||||
#define PI 3.1415926
|
#define PI 3.1415926
|
||||||
|
|
||||||
QT_CHARTS_USE_NAMESPACE//QChartView 使用 需要加宏, 否则无法使用
|
QT_CHARTS_USE_NAMESPACE//QChartView 使用 需要加宏, 否则无法使用
|
||||||
@ -206,7 +218,7 @@ private:
|
|||||||
QWidget* tmp(QWidget* a);
|
QWidget* tmp(QWidget* a);
|
||||||
|
|
||||||
QLineEdit * frame_number;
|
QLineEdit * frame_number;
|
||||||
QLineEdit * m_FilenameLineEdit;
|
FileNameLineEdit * m_FilenameLineEdit;
|
||||||
QLabel * xmotor_state_label1;
|
QLabel * xmotor_state_label1;
|
||||||
QLabel * ymotor_state_label1;
|
QLabel * ymotor_state_label1;
|
||||||
|
|
||||||
@ -217,7 +229,7 @@ private:
|
|||||||
int m_RecordState;//用来控制相机采集流程,取2的余数,1 → 正在采集,0 → 停止采集
|
int m_RecordState;//用来控制相机采集流程,取2的余数,1 → 正在采集,0 → 停止采集
|
||||||
|
|
||||||
QThread * m_RecordThread;//影像采集线程
|
QThread * m_RecordThread;//影像采集线程
|
||||||
QThread * m_RgbCameraThread;//rgb相机获取图像线程
|
|
||||||
QThread * m_CopyFileThread;//影像文件复制线程
|
QThread * m_CopyFileThread;//影像文件复制线程
|
||||||
FileOperation * m_FileOperation;
|
FileOperation * m_FileOperation;
|
||||||
|
|
||||||
@ -239,7 +251,7 @@ private:
|
|||||||
|
|
||||||
//
|
//
|
||||||
int m_TabWidgetCurrentIndex;//当手动选择TabWidget的标签时,记录变化后的tab index
|
int m_TabWidgetCurrentIndex;//当手动选择TabWidget的标签时,记录变化后的tab index
|
||||||
RgbCameraOperation *m_RgbCamera;
|
|
||||||
|
|
||||||
void getRequest(QString str);
|
void getRequest(QString str);
|
||||||
|
|
||||||
@ -264,13 +276,18 @@ private:
|
|||||||
|
|
||||||
MyCarousel* m_carousel;
|
MyCarousel* m_carousel;
|
||||||
QLabel* m_cam_label;
|
QLabel* m_cam_label;
|
||||||
|
QLabel* m_SingleLensReflexCamera_label;
|
||||||
|
QLabel* m_depthCamera_label;
|
||||||
QPushButton* m_open_rgb_camera_btn;
|
QPushButton* m_open_rgb_camera_btn;
|
||||||
QPushButton* m_close_rgb_camera_btn;
|
QPushButton* m_close_rgb_camera_btn;
|
||||||
|
|
||||||
TabManager* m_tabManager;
|
TabManager* m_tabManager;
|
||||||
|
|
||||||
HyperImagerControl* m_hic;
|
HyperImagerControl* m_hic;
|
||||||
|
rgbCameraWindow* m_rgbCameraControlWindow;
|
||||||
ImageControl* m_ic;
|
ImageControl* m_ic;
|
||||||
|
DepthCameraWindow* m_depthCameraWindow;
|
||||||
|
SingleLensReflexCameraWindow* m_singleLensReflexCameraWindow;
|
||||||
adjustTable* m_adt;
|
adjustTable* m_adt;
|
||||||
PowerControl* m_pc;
|
PowerControl* m_pc;
|
||||||
RobotArmControl* m_rac;
|
RobotArmControl* m_rac;
|
||||||
@ -295,10 +312,15 @@ private:
|
|||||||
QWidget* m_focusTab=nullptr;
|
QWidget* m_focusTab=nullptr;
|
||||||
|
|
||||||
recordFrameCounter* m_recordFrameCounter = nullptr;
|
recordFrameCounter* m_recordFrameCounter = nullptr;
|
||||||
|
|
||||||
|
bool testImagerVality();
|
||||||
|
void showMessageBox(QString msg, QString title= QString::fromLocal8Bit("提示"));
|
||||||
|
bool showResultMessageBox(QString title, QString msg);
|
||||||
|
void disconnectImagerAndCleanup();
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void onPlotHyperspectralImageRgbImage(int fileNumber, int frameNumber, QString filePath);
|
void onPlotHyperspectralImageRgbImage(int fileNumber, int frameNumber, QString filePath);
|
||||||
void PlotSpectral(int state);
|
void focusPlotSpectralImg(int state);
|
||||||
void onRecordFinishedSignal_WhenFrameNumberMeet();
|
void onRecordFinishedSignal_WhenFrameNumberMeet();
|
||||||
void onRecordFinishedSignal_WhenFrameNumberNotMeet();
|
void onRecordFinishedSignal_WhenFrameNumberNotMeet();
|
||||||
void onsequenceComplete();
|
void onsequenceComplete();
|
||||||
@ -313,6 +335,7 @@ public Q_SLOTS:
|
|||||||
void onFocus2(int command);
|
void onFocus2(int command);
|
||||||
void onFocusWindowClosed();
|
void onFocusWindowClosed();
|
||||||
void onAbout();
|
void onAbout();
|
||||||
|
void settingWindow();
|
||||||
void onDark();
|
void onDark();
|
||||||
void recordDarkFinish();
|
void recordDarkFinish();
|
||||||
void onReference();
|
void onReference();
|
||||||
@ -336,8 +359,13 @@ public Q_SLOTS:
|
|||||||
void OnSendLogToCallClass(QString str);
|
void OnSendLogToCallClass(QString str);
|
||||||
|
|
||||||
void onPlotRgbImage();
|
void onPlotRgbImage();
|
||||||
void onCloseRgbCamera();
|
void onPlotDepthImage();
|
||||||
|
|
||||||
|
void onLiveViewImageReady(const QImage& image);
|
||||||
|
void HPPA::onLiveViewStopped();
|
||||||
|
|
||||||
void onClearLabel();
|
void onClearLabel();
|
||||||
|
void onClearDepthLabel();
|
||||||
|
|
||||||
void onCopyFinished();
|
void onCopyFinished();
|
||||||
|
|
||||||
@ -347,12 +375,19 @@ public Q_SLOTS:
|
|||||||
|
|
||||||
void createOneMotorScenario();
|
void createOneMotorScenario();
|
||||||
void createPlantPhenotypeScenario();
|
void createPlantPhenotypeScenario();
|
||||||
|
void create3DPlantPhenotypeScenario();
|
||||||
void onCreated3DModelPlantPhenotype();
|
void onCreated3DModelPlantPhenotype();
|
||||||
|
void onCreated3DModelMicroscopicMotion();
|
||||||
|
void createMicroscopicMotionControlScenario();
|
||||||
void onCreated3DModelOneMotor();
|
void onCreated3DModelOneMotor();
|
||||||
|
|
||||||
void addLayer(const QString& baseName, const QString& filePath, bool refresh);
|
void addLayer(const QString& baseName, const QString& filePath, bool refresh, bool isAddImage = true);
|
||||||
|
void newImage(RasterLayer* ml, RasterImageLayer::RendererType, LayerTreeNode* parent, bool refresh=true);
|
||||||
void onLayerCreatedFromFile(const QString& baseName, const QString& filePath, int fileIndex);
|
void onLayerCreatedFromFile(const QString& baseName, const QString& filePath, int fileIndex);
|
||||||
void removeLayerByTreeIndex();
|
void removeLayerByTreeIndex();
|
||||||
|
void removeLayerByNode(LayerTreeNode* node);
|
||||||
|
void showColorImageByTreeIndex();
|
||||||
|
void removeImageByTreeIndex();
|
||||||
void removeAllLayersInRasterGroup();
|
void removeAllLayersInRasterGroup();
|
||||||
|
|
||||||
void onLayerTreeSelectionChanged(const QItemSelection& selected, const QItemSelection& deselected);
|
void onLayerTreeSelectionChanged(const QItemSelection& selected, const QItemSelection& deselected);
|
||||||
@ -370,4 +405,6 @@ signals:
|
|||||||
|
|
||||||
void RecordWhiteSignal();
|
void RecordWhiteSignal();
|
||||||
void RecordDarlSignal();
|
void RecordDarlSignal();
|
||||||
|
|
||||||
|
void updateRecordingFileInfoSignal(const QString& filePath, const QString& baseName, int frameNumber);
|
||||||
};
|
};
|
||||||
|
|||||||
135
HPPA/HPPA.ui
135
HPPA/HPPA.ui
@ -72,7 +72,7 @@ color:white;
|
|||||||
</property>
|
</property>
|
||||||
<addaction name="mActionOpenImg"/>
|
<addaction name="mActionOpenImg"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
<addaction name="action_11"/>
|
<addaction name="mSetting"/>
|
||||||
<addaction name="action_exit"/>
|
<addaction name="action_exit"/>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QMenu" name="menuspectrometer">
|
<widget class="QMenu" name="menuspectrometer">
|
||||||
@ -133,6 +133,8 @@ color:white;
|
|||||||
</property>
|
</property>
|
||||||
<addaction name="mActionOneMotorScenario"/>
|
<addaction name="mActionOneMotorScenario"/>
|
||||||
<addaction name="mActionPlantPhenotypeScenario"/>
|
<addaction name="mActionPlantPhenotypeScenario"/>
|
||||||
|
<addaction name="mActionMicroscopicMotionControlScenario"/>
|
||||||
|
<addaction name="mAction3DPlantPhenotypeScenario"/>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QMenu" name="menu_4">
|
<widget class="QMenu" name="menu_4">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
@ -383,119 +385,6 @@ QPushButton:pressed
|
|||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
<string>rgb相机</string>
|
<string>rgb相机</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
<layout class="QGridLayout" name="gridLayout_4" rowstretch="2,4,2" columnstretch="1,3,1">
|
|
||||||
<item row="0" column="1">
|
|
||||||
<spacer name="verticalSpacer">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Vertical</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>20</width>
|
|
||||||
<height>174</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="0">
|
|
||||||
<spacer name="horizontalSpacer">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>115</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="1">
|
|
||||||
<layout class="QGridLayout" name="gridLayout_3" columnstretch="1,1">
|
|
||||||
<property name="spacing">
|
|
||||||
<number>20</number>
|
|
||||||
</property>
|
|
||||||
<item row="1" column="0">
|
|
||||||
<widget class="QPushButton" name="take_video_btn">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>录制视频</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="1">
|
|
||||||
<widget class="QPushButton" name="take_photo_btn">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>拍照</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="1">
|
|
||||||
<widget class="QPushButton" name="close_rgb_camera_btn">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>关闭</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="0">
|
|
||||||
<widget class="QPushButton" name="open_rgb_camera_btn">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>打开</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="2">
|
|
||||||
<spacer name="horizontalSpacer_2">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>115</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="1">
|
|
||||||
<spacer name="verticalSpacer_2">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Vertical</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>20</width>
|
|
||||||
<height>173</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@ -797,7 +686,7 @@ QPushButton:pressed
|
|||||||
<string>关闭影像</string>
|
<string>关闭影像</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="action_11">
|
<action name="mSetting">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>设置</string>
|
<string>设置</string>
|
||||||
</property>
|
</property>
|
||||||
@ -838,6 +727,22 @@ QPushButton:pressed
|
|||||||
<string>光谱</string>
|
<string>光谱</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="mActionMicroscopicMotionControlScenario">
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>显微运动控制台</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="mAction3DPlantPhenotypeScenario">
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>3D植物表型</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<layoutdefault spacing="6" margin="11"/>
|
<layoutdefault spacing="6" margin="11"/>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
|
|||||||
@ -55,18 +55,18 @@
|
|||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
<PropertyGroup Label="UserMacros" />
|
<PropertyGroup Label="UserMacros" />
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||||
<IncludePath>D:\cpp_library\gdal2.2.3_vs2017\include;C:\Program Files\ResononAPI\include;D:\cpp_library\opencv3.4.11\opencv\build\include;D:\cpp_library\opencv3.4.11\opencv\build\include\opencv;D:\cpp_library\opencv3.4.11\opencv\build\include\opencv2;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL\SDKs\PCOMM\Include;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL\SDKs\PortControl;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL;D:\cpp_project_vs2022\HPPA\HPPA;D:\cpp_library\libconfig-1.7.3\lib;D:\cpp_project_vs2022\HPPA\vincecontrol;D:\cpp_library\vincecontrol_vs2017;C:\XIMEA\API\xiAPI;D:\cpp_project_vs2022\HPPA\IrisMultiMotorController\IrisMultiMotorController;D:\cpp_library\eigen-3.4-rc1;$(IncludePath)</IncludePath>
|
<IncludePath>D:\cpp_library\gdal2.2.3_vs2017\include;C:\Program Files\ResononAPI\include;D:\cpp_library\opencv3.4.11\opencv\build\include;D:\cpp_library\opencv3.4.11\opencv\build\include\opencv;D:\cpp_library\opencv3.4.11\opencv\build\include\opencv2;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL\SDKs\PCOMM\Include;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL\SDKs\PortControl;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL;D:\cpp_project_vs2022\HPPA\HPPA;D:\cpp_library\libconfig-1.7.3\lib;D:\cpp_project_vs2022\HPPA\vincecontrol;D:\cpp_library\vincecontrol_vs2017;C:\XIMEA\API\xiAPI;D:\cpp_project_vs2022\HPPA\IrisMultiMotorController\IrisMultiMotorController;D:\cpp_library\eigen-3.4-rc1;C:\Program Files\OrbbecSDK 2.7.6\include;D:\cpp_library\EDSDK132010CD(13.20.10)\Windows\EDSDK_64\Header;$(IncludePath)</IncludePath>
|
||||||
<LibraryPath>D:\cpp_library\opencv3.4.11\opencv\build\x64\vc15\lib;D:\cpp_library\gdal2.2.3_vs2017\lib;C:\Program Files\ResononAPI\lib64;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\x64\Debug;D:\cpp_library\libconfig-1.7.3\build\x64;D:\cpp_project_vs2022\HPPA\x64\Debug;C:\XIMEA\API\xiAPI;D:\cpp_project_vs2022\HPPA\IrisMultiMotorController\x64\Debug;$(LibraryPath)</LibraryPath>
|
<LibraryPath>D:\cpp_library\opencv3.4.11\opencv\build\x64\vc15\lib;D:\cpp_library\gdal2.2.3_vs2017\lib;C:\Program Files\ResononAPI\lib64;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\x64\Debug;D:\cpp_library\libconfig-1.7.3\build\x64;D:\cpp_project_vs2022\HPPA\x64\Debug;C:\XIMEA\API\xiAPI;D:\cpp_project_vs2022\HPPA\IrisMultiMotorController\x64\Debug;C:\Program Files\OrbbecSDK 2.7.6\lib;D:\cpp_library\EDSDK132010CD(13.20.10)\Windows\EDSDK_64\Library;$(LibraryPath)</LibraryPath>
|
||||||
<TargetName>Spectral Insight</TargetName>
|
<TargetName>Spectral Insight</TargetName>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||||
<IncludePath>D:\cpp_library\gdal2.2.3_vs2017\include;C:\Program Files\ResononAPI\include;D:\cpp_library\opencv3.4.11\opencv\build\include;D:\cpp_library\opencv3.4.11\opencv\build\include\opencv;D:\cpp_library\opencv3.4.11\opencv\build\include\opencv2;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL\SDKs\PCOMM\Include;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL\SDKs\PortControl;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL;D:\cpp_project_vs2022\HPPA\HPPA;D:\cpp_library\libconfig-1.7.3\lib;D:\cpp_project_vs2022\HPPA\vincecontrol;C:\XIMEA\API\xiAPI;D:\cpp_project_vs2022\HPPA\IrisMultiMotorController\IrisMultiMotorController;D:\cpp_library\eigen-3.4-rc1;$(IncludePath)</IncludePath>
|
<IncludePath>D:\cpp_library\gdal2.2.3_vs2017\include;C:\Program Files\ResononAPI\include;D:\cpp_library\opencv3.4.11\opencv\build\include;D:\cpp_library\opencv3.4.11\opencv\build\include\opencv;D:\cpp_library\opencv3.4.11\opencv\build\include\opencv2;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL\SDKs\PCOMM\Include;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL\SDKs\PortControl;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL;D:\cpp_project_vs2022\HPPA\HPPA;D:\cpp_library\libconfig-1.7.3\lib;D:\cpp_project_vs2022\HPPA\vincecontrol;C:\XIMEA\API\xiAPI;D:\cpp_project_vs2022\HPPA\IrisMultiMotorController\IrisMultiMotorController;D:\cpp_library\eigen-3.4-rc1;C:\Program Files\OrbbecSDK 2.7.6\include;D:\cpp_library\EDSDK132010CD(13.20.10)\Windows\EDSDK_64\Header;$(IncludePath)</IncludePath>
|
||||||
<LibraryPath>D:\cpp_library\opencv3.4.11\opencv\build\x64\vc15\lib;D:\cpp_library\vincecontrol_vs2017_release;D:\cpp_library\gdal2.2.3_vs2017\lib;C:\Program Files\ResononAPI\lib64;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\x64\Release;D:\cpp_library\libconfig-1.7.3\build\x64;D:\cpp_project_vs2022\IrisMultiMotorController\x64\Release;C:\XIMEA\API\xiAPI;$(LibraryPath)</LibraryPath>
|
<LibraryPath>D:\cpp_library\opencv3.4.11\opencv\build\x64\vc15\lib;D:\cpp_library\vincecontrol_vs2017_release;D:\cpp_library\gdal2.2.3_vs2017\lib;C:\Program Files\ResononAPI\lib64;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\x64\Release;D:\cpp_library\libconfig-1.7.3\build\x64;D:\cpp_project_vs2022\IrisMultiMotorController\x64\Release;C:\XIMEA\API\xiAPI;C:\Program Files\OrbbecSDK 2.7.6\lib;D:\cpp_library\EDSDK132010CD(13.20.10)\Windows\EDSDK_64\Library;$(LibraryPath)</LibraryPath>
|
||||||
<TargetName>Spectral Insight</TargetName>
|
<TargetName>Spectral Insight</TargetName>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
<Link>
|
<Link>
|
||||||
<AdditionalDependencies>opencv_world3411.lib;opencv_world3411d.lib;gdal_i.lib;resonon-basler.lib;AutoFocus_InspireLinearMotor_DLL.lib;libconfig++d.lib;vincecontrol.lib;resonon-allied.lib;xiapi64.lib;IrisMultiMotorController.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>opencv_world3411.lib;opencv_world3411d.lib;gdal_i.lib;resonon-basler.lib;AutoFocus_InspireLinearMotor_DLL.lib;libconfig++d.lib;vincecontrol.lib;resonon-allied.lib;xiapi64.lib;IrisMultiMotorController.lib;OrbbecSDK.lib;EDSDK.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
<AdditionalLibraryDirectories>D:\cpp_project_vs2022\HPPA\x64\Debug;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
<AdditionalLibraryDirectories>D:\cpp_project_vs2022\HPPA\x64\Debug;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
</Link>
|
</Link>
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
@ -75,7 +75,7 @@
|
|||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
<Link>
|
<Link>
|
||||||
<AdditionalDependencies>opencv_world3411.lib;vincecontrol.lib;gdal_i.lib;resonon-basler.lib;resonon-allied.lib;AutoFocus_InspireLinearMotor_DLL.lib;libconfig++.lib;xiapi64.lib;IrisMultiMotorController.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>opencv_world3411.lib;vincecontrol.lib;gdal_i.lib;resonon-basler.lib;resonon-allied.lib;AutoFocus_InspireLinearMotor_DLL.lib;libconfig++.lib;xiapi64.lib;IrisMultiMotorController.lib;OrbbecSDK.lib;EDSDK.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
<AdditionalLibraryDirectories>D:\cpp_project_vs2022\HPPA\x64\Release;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
<AdditionalLibraryDirectories>D:\cpp_project_vs2022\HPPA\x64\Release;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
@ -108,11 +108,14 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="aboutWindow.cpp" />
|
<ClCompile Include="aboutWindow.cpp" />
|
||||||
<ClCompile Include="adjustTable.cpp" />
|
<ClCompile Include="adjustTable.cpp" />
|
||||||
|
<ClCompile Include="AppSettings.cpp" />
|
||||||
<ClCompile Include="AspectRatioLabel.cpp" />
|
<ClCompile Include="AspectRatioLabel.cpp" />
|
||||||
<ClCompile Include="CaptureCoordinator.cpp" />
|
<ClCompile Include="CaptureCoordinator.cpp" />
|
||||||
<ClCompile Include="Carousel.cpp" />
|
<ClCompile Include="Carousel.cpp" />
|
||||||
<ClCompile Include="Corning410Imager.cpp" />
|
<ClCompile Include="Corning410Imager.cpp" />
|
||||||
<ClCompile Include="CustomDockWidgetBase.cpp" />
|
<ClCompile Include="CustomDockWidgetBase.cpp" />
|
||||||
|
<ClCompile Include="DepthCameraWindow.cpp" />
|
||||||
|
<ClCompile Include="FileNameLineEdit.cpp" />
|
||||||
<ClCompile Include="hppaConfigFile.cpp" />
|
<ClCompile Include="hppaConfigFile.cpp" />
|
||||||
<ClCompile Include="HyperImagerControl.cpp" />
|
<ClCompile Include="HyperImagerControl.cpp" />
|
||||||
<ClCompile Include="imageControl.cpp" />
|
<ClCompile Include="imageControl.cpp" />
|
||||||
@ -121,6 +124,7 @@
|
|||||||
<ClCompile Include="irisximeaimager.cpp" />
|
<ClCompile Include="irisximeaimager.cpp" />
|
||||||
<ClCompile Include="LayerTree.cpp" />
|
<ClCompile Include="LayerTree.cpp" />
|
||||||
<ClCompile Include="LayerTreeGroupNode.cpp" />
|
<ClCompile Include="LayerTreeGroupNode.cpp" />
|
||||||
|
<ClCompile Include="LayerTreeImageNode.cpp" />
|
||||||
<ClCompile Include="LayerTreeLayerNode.cpp" />
|
<ClCompile Include="LayerTreeLayerNode.cpp" />
|
||||||
<ClCompile Include="LayerTreeModel.cpp" />
|
<ClCompile Include="LayerTreeModel.cpp" />
|
||||||
<ClCompile Include="LayerTreeNode.cpp" />
|
<ClCompile Include="LayerTreeNode.cpp" />
|
||||||
@ -132,6 +136,7 @@
|
|||||||
<ClCompile Include="MapToolPan.cpp" />
|
<ClCompile Include="MapToolPan.cpp" />
|
||||||
<ClCompile Include="MapTools.cpp" />
|
<ClCompile Include="MapTools.cpp" />
|
||||||
<ClCompile Include="MapToolSpectral.cpp" />
|
<ClCompile Include="MapToolSpectral.cpp" />
|
||||||
|
<ClCompile Include="MotorWindowBase.cpp" />
|
||||||
<ClCompile Include="OneMotorControl.cpp" />
|
<ClCompile Include="OneMotorControl.cpp" />
|
||||||
<ClCompile Include="path_tc.cpp" />
|
<ClCompile Include="path_tc.cpp" />
|
||||||
<ClCompile Include="PowerControl.cpp" />
|
<ClCompile Include="PowerControl.cpp" />
|
||||||
@ -139,17 +144,25 @@
|
|||||||
<ClCompile Include="QMotorDoubleSlider.cpp" />
|
<ClCompile Include="QMotorDoubleSlider.cpp" />
|
||||||
<ClCompile Include="RasterDataProvider.cpp" />
|
<ClCompile Include="RasterDataProvider.cpp" />
|
||||||
<ClCompile Include="RasterLayer.cpp" />
|
<ClCompile Include="RasterLayer.cpp" />
|
||||||
<ClCompile Include="RasterRenderer.cpp" />
|
<ClCompile Include="MultibandRasterRenderer.cpp" />
|
||||||
|
<ClCompile Include="RasterRendererBase.cpp" />
|
||||||
|
<ClCompile Include="RasterImageLayer.cpp" />
|
||||||
|
<ClCompile Include="SinglebandRasterRenderer.cpp" />
|
||||||
<ClCompile Include="recordFrameCounter.cpp" />
|
<ClCompile Include="recordFrameCounter.cpp" />
|
||||||
<ClCompile Include="resononImager.cpp" />
|
<ClCompile Include="resononImager.cpp" />
|
||||||
<ClCompile Include="ResononNirImager.cpp" />
|
<ClCompile Include="ResononNirImager.cpp" />
|
||||||
<ClCompile Include="RgbCameraOperation.cpp" />
|
<ClCompile Include="RgbCameraOperation.cpp" />
|
||||||
|
<ClCompile Include="rgbCameraWindow.cpp" />
|
||||||
<ClCompile Include="RobotArmControl.cpp" />
|
<ClCompile Include="RobotArmControl.cpp" />
|
||||||
|
<ClCompile Include="setWindow.cpp" />
|
||||||
|
<ClCompile Include="SingleLensReflexCameraWindow.cpp" />
|
||||||
<ClCompile Include="stdafx.cpp">
|
<ClCompile Include="stdafx.cpp">
|
||||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
|
||||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="TabManager.cpp" />
|
<ClCompile Include="TabManager.cpp" />
|
||||||
|
<ClCompile Include="TimedDataCollection.cpp" />
|
||||||
|
<ClCompile Include="TimedDataCollectionDataStructures.cpp" />
|
||||||
<ClCompile Include="TwoMotorControl.cpp" />
|
<ClCompile Include="TwoMotorControl.cpp" />
|
||||||
<ClCompile Include="utility_tc.cpp" />
|
<ClCompile Include="utility_tc.cpp" />
|
||||||
<ClCompile Include="View3D.cpp" />
|
<ClCompile Include="View3D.cpp" />
|
||||||
@ -157,6 +170,7 @@
|
|||||||
<QtRcc Include="HPPA.qrc" />
|
<QtRcc Include="HPPA.qrc" />
|
||||||
<QtUic Include="about.ui" />
|
<QtUic Include="about.ui" />
|
||||||
<QtUic Include="adjustTable.ui" />
|
<QtUic Include="adjustTable.ui" />
|
||||||
|
<QtUic Include="DepthCamera.ui" />
|
||||||
<QtUic Include="FocusDialog.ui" />
|
<QtUic Include="FocusDialog.ui" />
|
||||||
<QtUic Include="HPPA.ui" />
|
<QtUic Include="HPPA.ui" />
|
||||||
<QtMoc Include="HPPA.h" />
|
<QtMoc Include="HPPA.h" />
|
||||||
@ -177,7 +191,11 @@
|
|||||||
<QtUic Include="PowerControl.ui" />
|
<QtUic Include="PowerControl.ui" />
|
||||||
<QtUic Include="RadianceConversion.ui" />
|
<QtUic Include="RadianceConversion.ui" />
|
||||||
<QtUic Include="ReflectanceConversion.ui" />
|
<QtUic Include="ReflectanceConversion.ui" />
|
||||||
|
<QtUic Include="rgbCamera.ui" />
|
||||||
<QtUic Include="RobotArmControl.ui" />
|
<QtUic Include="RobotArmControl.ui" />
|
||||||
|
<QtUic Include="set.ui" />
|
||||||
|
<QtUic Include="SingleLensReflexCamera.ui" />
|
||||||
|
<QtUic Include="TimedDataCollection_ui.ui" />
|
||||||
<QtUic Include="twoMotorControl.ui" />
|
<QtUic Include="twoMotorControl.ui" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@ -202,6 +220,9 @@
|
|||||||
<QtMoc Include="imageControl.h" />
|
<QtMoc Include="imageControl.h" />
|
||||||
<QtMoc Include="AspectRatioLabel.h" />
|
<QtMoc Include="AspectRatioLabel.h" />
|
||||||
<QtMoc Include="HyperImagerControl.h" />
|
<QtMoc Include="HyperImagerControl.h" />
|
||||||
|
<ClInclude Include="AppSettings.h" />
|
||||||
|
<QtMoc Include="FileNameLineEdit.h" />
|
||||||
|
<QtMoc Include="DepthCameraWindow.h" />
|
||||||
<ClInclude Include="imager_base.h" />
|
<ClInclude Include="imager_base.h" />
|
||||||
<ClInclude Include="irisximeaimager.h" />
|
<ClInclude Include="irisximeaimager.h" />
|
||||||
<QtMoc Include="OneMotorControl.h" />
|
<QtMoc Include="OneMotorControl.h" />
|
||||||
@ -215,15 +236,25 @@
|
|||||||
<QtMoc Include="MapLayer.h" />
|
<QtMoc Include="MapLayer.h" />
|
||||||
<QtMoc Include="RasterLayer.h" />
|
<QtMoc Include="RasterLayer.h" />
|
||||||
<QtMoc Include="MapLayerStore.h" />
|
<QtMoc Include="MapLayerStore.h" />
|
||||||
|
<QtMoc Include="LayerTreeImageNode.h" />
|
||||||
<ClInclude Include="LayerTreeView.h" />
|
<ClInclude Include="LayerTreeView.h" />
|
||||||
<QtMoc Include="LayerTreeViewMenuProvider.h" />
|
<QtMoc Include="LayerTreeViewMenuProvider.h" />
|
||||||
<QtMoc Include="MapTool.h" />
|
<QtMoc Include="MapTool.h" />
|
||||||
<QtMoc Include="MapToolPan.h" />
|
<QtMoc Include="MapToolPan.h" />
|
||||||
<QtMoc Include="MapToolSpectral.h" />
|
<QtMoc Include="MapToolSpectral.h" />
|
||||||
<QtMoc Include="MapTools.h" />
|
<QtMoc Include="MapTools.h" />
|
||||||
|
<ClInclude Include="MotorWindowBase.h" />
|
||||||
<ClInclude Include="RasterDataProvider.h" />
|
<ClInclude Include="RasterDataProvider.h" />
|
||||||
<ClInclude Include="RasterRenderer.h" />
|
<ClInclude Include="MultibandRasterRenderer.h" />
|
||||||
|
<ClInclude Include="RasterImageLayer.h" />
|
||||||
|
<ClInclude Include="RasterRendererBase.h" />
|
||||||
|
<ClInclude Include="SinglebandRasterRenderer.h" />
|
||||||
<QtMoc Include="recordFrameCounter.h" />
|
<QtMoc Include="recordFrameCounter.h" />
|
||||||
|
<QtMoc Include="setWindow.h" />
|
||||||
|
<QtMoc Include="rgbCameraWindow.h" />
|
||||||
|
<QtMoc Include="SingleLensReflexCameraWindow.h" />
|
||||||
|
<QtMoc Include="TimedDataCollection.h" />
|
||||||
|
<ClInclude Include="TimedDataCollectionDataStructures.h" />
|
||||||
<ClInclude Include="utility_tc.h" />
|
<ClInclude Include="utility_tc.h" />
|
||||||
<QtMoc Include="aboutWindow.h" />
|
<QtMoc Include="aboutWindow.h" />
|
||||||
<ClInclude Include="hppaConfigFile.h" />
|
<ClInclude Include="hppaConfigFile.h" />
|
||||||
|
|||||||
@ -160,10 +160,16 @@
|
|||||||
<ClCompile Include="RasterLayer.cpp">
|
<ClCompile Include="RasterLayer.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="RasterImageLayer.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
<ClCompile Include="RasterDataProvider.cpp">
|
<ClCompile Include="RasterDataProvider.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="RasterRenderer.cpp">
|
<ClCompile Include="MultibandRasterRenderer.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="SinglebandRasterRenderer.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="MapLayerStore.cpp">
|
<ClCompile Include="MapLayerStore.cpp">
|
||||||
@ -199,6 +205,39 @@
|
|||||||
<ClCompile Include="recordFrameCounter.cpp">
|
<ClCompile Include="recordFrameCounter.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="setWindow.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="AppSettings.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="FileNameLineEdit.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="MotorWindowBase.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="rgbCameraWindow.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="DepthCameraWindow.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="SingleLensReflexCameraWindow.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="LayerTreeImageNode.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="RasterRendererBase.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="TimedDataCollection.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="TimedDataCollectionDataStructures.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<QtMoc Include="fileOperation.h">
|
<QtMoc Include="fileOperation.h">
|
||||||
@ -324,6 +363,27 @@
|
|||||||
<QtMoc Include="recordFrameCounter.h">
|
<QtMoc Include="recordFrameCounter.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</QtMoc>
|
</QtMoc>
|
||||||
|
<QtMoc Include="setWindow.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</QtMoc>
|
||||||
|
<QtMoc Include="FileNameLineEdit.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</QtMoc>
|
||||||
|
<QtMoc Include="rgbCameraWindow.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</QtMoc>
|
||||||
|
<QtMoc Include="DepthCameraWindow.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</QtMoc>
|
||||||
|
<QtMoc Include="SingleLensReflexCameraWindow.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</QtMoc>
|
||||||
|
<QtMoc Include="LayerTreeImageNode.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</QtMoc>
|
||||||
|
<QtMoc Include="TimedDataCollection.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</QtMoc>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="imageProcessor.h">
|
<ClInclude Include="imageProcessor.h">
|
||||||
@ -359,12 +419,30 @@
|
|||||||
<ClInclude Include="RasterDataProvider.h">
|
<ClInclude Include="RasterDataProvider.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="RasterRenderer.h">
|
<ClInclude Include="MultibandRasterRenderer.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="RasterImageLayer.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="RasterRendererBase.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="SinglebandRasterRenderer.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="LayerTreeView.h">
|
<ClInclude Include="LayerTreeView.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="AppSettings.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="MotorWindowBase.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="TimedDataCollectionDataStructures.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<QtUic Include="FocusDialog.ui">
|
<QtUic Include="FocusDialog.ui">
|
||||||
@ -403,6 +481,21 @@
|
|||||||
<QtUic Include="hyperImagerControl.ui">
|
<QtUic Include="hyperImagerControl.ui">
|
||||||
<Filter>Form Files</Filter>
|
<Filter>Form Files</Filter>
|
||||||
</QtUic>
|
</QtUic>
|
||||||
|
<QtUic Include="set.ui">
|
||||||
|
<Filter>Form Files</Filter>
|
||||||
|
</QtUic>
|
||||||
|
<QtUic Include="rgbCamera.ui">
|
||||||
|
<Filter>Form Files</Filter>
|
||||||
|
</QtUic>
|
||||||
|
<QtUic Include="DepthCamera.ui">
|
||||||
|
<Filter>Form Files</Filter>
|
||||||
|
</QtUic>
|
||||||
|
<QtUic Include="SingleLensReflexCamera.ui">
|
||||||
|
<Filter>Form Files</Filter>
|
||||||
|
</QtUic>
|
||||||
|
<QtUic Include="TimedDataCollection_ui.ui">
|
||||||
|
<Filter>Form Files</Filter>
|
||||||
|
</QtUic>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="cpp.hint" />
|
<None Include="cpp.hint" />
|
||||||
|
|||||||
@ -83,6 +83,7 @@ void HyperImagerControl::setFrameRate(double frameRate)
|
|||||||
ui.FramerateSlider->setValue(frameRate);
|
ui.FramerateSlider->setValue(frameRate);
|
||||||
|
|
||||||
updateIntegrationTimeRange(frameRate);
|
updateIntegrationTimeRange(frameRate);
|
||||||
|
AppSettings::instance().setFrameRate(frameRate);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HyperImagerControl::setIntegrationTime(double integrationTime)
|
void HyperImagerControl::setIntegrationTime(double integrationTime)
|
||||||
@ -91,12 +92,15 @@ void HyperImagerControl::setIntegrationTime(double integrationTime)
|
|||||||
ui.IntegratioinTimeSlider->setValue(integrationTime);
|
ui.IntegratioinTimeSlider->setValue(integrationTime);
|
||||||
|
|
||||||
updateFramerateRange(integrationTime);
|
updateFramerateRange(integrationTime);
|
||||||
|
AppSettings::instance().setIntegrationTime(integrationTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HyperImagerControl::setGain(double gain)
|
void HyperImagerControl::setGain(double gain)
|
||||||
{
|
{
|
||||||
ui.gain_spinBox->setValue(gain);
|
ui.gain_spinBox->setValue(gain);
|
||||||
ui.GainSlider->setValue(gain);
|
ui.GainSlider->setValue(gain);
|
||||||
|
|
||||||
|
AppSettings::instance().setGain(gain);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HyperImagerControl::onFramerateSpinBoxEditingFinished()
|
void HyperImagerControl::onFramerateSpinBoxEditingFinished()
|
||||||
@ -161,7 +165,7 @@ void HyperImagerControl::onGainSliderReleased()
|
|||||||
|
|
||||||
void HyperImagerControl::updateIntegrationTimeRange(double frameRate)
|
void HyperImagerControl::updateIntegrationTimeRange(double frameRate)
|
||||||
{
|
{
|
||||||
double maxIntegrationTime = 1.0 / frameRate * 1000.0; // 毫秒
|
double maxIntegrationTime = 1.0 / frameRate * 999.0; // 毫秒
|
||||||
|
|
||||||
ui.IntegratioinTimeSlider->blockSignals(true);
|
ui.IntegratioinTimeSlider->blockSignals(true);
|
||||||
ui.IntegratioinTimeSlider->setMaximum(maxIntegrationTime);
|
ui.IntegratioinTimeSlider->setMaximum(maxIntegrationTime);
|
||||||
@ -176,7 +180,7 @@ void HyperImagerControl::updateIntegrationTimeRange(double frameRate)
|
|||||||
|
|
||||||
void HyperImagerControl::updateFramerateRange(double integrationTime)
|
void HyperImagerControl::updateFramerateRange(double integrationTime)
|
||||||
{
|
{
|
||||||
double maxFramerate = 1.0 / (integrationTime / 1000.0); // 积分时间(毫秒)转帧率
|
double maxFramerate = 1.0 / (integrationTime / 999.0); // 积分时间(毫秒)转帧率
|
||||||
|
|
||||||
if(maxFramerate > m_frameRateLimit)
|
if(maxFramerate > m_frameRateLimit)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -5,6 +5,7 @@
|
|||||||
#include "ui_hyperImagerControl.h"
|
#include "ui_hyperImagerControl.h"
|
||||||
|
|
||||||
#include "AspectRatioLabel.h"
|
#include "AspectRatioLabel.h"
|
||||||
|
#include "AppSettings.h"
|
||||||
|
|
||||||
class QDoubleSlider;
|
class QDoubleSlider;
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include "ImageReaderWriter.h"
|
#include "ImageReaderWriter.h"
|
||||||
@ -11,11 +11,11 @@ ImageReaderWriter::ImageReaderWriter(const char * fileName)
|
|||||||
m_poDataset = (GDALDataset *)GDALOpen(fileName, GA_ReadOnly);
|
m_poDataset = (GDALDataset *)GDALOpen(fileName, GA_ReadOnly);
|
||||||
if (m_poDataset == NULL)
|
if (m_poDataset == NULL)
|
||||||
{
|
{
|
||||||
std::cout << "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӱ<EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>" << std::endl;
|
std::cout << "打开影像失败!" << std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//<EFBFBD><EFBFBD>ȡӰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
//获取影像信息
|
||||||
m_DataType = m_poDataset->GetRasterBand(1)->GetRasterDataType();
|
m_DataType = m_poDataset->GetRasterBand(1)->GetRasterDataType();
|
||||||
m_iBands = m_poDataset->GetRasterCount();
|
m_iBands = m_poDataset->GetRasterCount();
|
||||||
m_iXCount = m_poDataset->GetRasterXSize();
|
m_iXCount = m_poDataset->GetRasterXSize();
|
||||||
@ -47,11 +47,11 @@ float * ImageReaderWriter::ReadImage(int nXOff, int nYOff, int nXSize, int nYSiz
|
|||||||
float *pDataBuffer = (float*)CPLMalloc(sizeof(float)*(1)*(1)*(m_iBands));
|
float *pDataBuffer = (float*)CPLMalloc(sizeof(float)*(1)*(1)*(m_iBands));
|
||||||
memset(pDataBuffer, 0, 1 * 1 * m_iBands * sizeof(float));
|
memset(pDataBuffer, 0, 1 * 1 * m_iBands * sizeof(float));
|
||||||
|
|
||||||
CPLErr status = m_poDataset->RasterIO(GF_Read, nXOff, nYOff, nXSize, nYSize, pDataBuffer, xBuff, yBuff, GDT_Float32, m_iBands, NULL, 0, 0, 0); //<EFBFBD>ȸߺ<EFBFBD><EFBFBD><EFBFBD>
|
CPLErr status = m_poDataset->RasterIO(GF_Read, nXOff, nYOff, nXSize, nYSize, pDataBuffer, xBuff, yBuff, GDT_Float32, m_iBands, NULL, 0, 0, 0); //先高后宽
|
||||||
|
|
||||||
if (status != CE_None)
|
if (status != CE_None)
|
||||||
{
|
{
|
||||||
std::cout << "<EFBFBD><EFBFBD>ȡӰ<EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>" << std::endl;
|
std::cout << "读取影像失败!" << std::endl;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
#ifndef IMAGE_READER_WRITER
|
#ifndef IMAGE_READER_WRITER
|
||||||
#define IMAGE_READER_WRITER
|
#define IMAGE_READER_WRITER
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "gdal_priv.h"
|
#include "gdal_priv.h"
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
@ -6,7 +6,7 @@
|
|||||||
#include <QPoint>
|
#include <QPoint>
|
||||||
|
|
||||||
#include "ImageViewer.h"
|
#include "ImageViewer.h"
|
||||||
#include "RasterLayer.h"
|
#include "RasterImageLayer.h"
|
||||||
#include "MapTool.h"
|
#include "MapTool.h"
|
||||||
|
|
||||||
|
|
||||||
@ -20,7 +20,7 @@ Mapcavas::Mapcavas(QWidget* pParent) :QGraphicsView(pParent)
|
|||||||
setRenderHint(QPainter::SmoothPixmapTransform);
|
setRenderHint(QPainter::SmoothPixmapTransform);
|
||||||
setDragMode(QGraphicsView::ScrollHandDrag);
|
setDragMode(QGraphicsView::ScrollHandDrag);
|
||||||
|
|
||||||
// ʹ<EFBFBD><EFBFBD> Qt Ĭ<EFBFBD><EFBFBD> anchor <EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
// 使用 Qt 默认 anchor 行为以外的配置
|
||||||
setTransformationAnchor(QGraphicsView::NoAnchor);
|
setTransformationAnchor(QGraphicsView::NoAnchor);
|
||||||
setResizeAnchor(QGraphicsView::NoAnchor);
|
setResizeAnchor(QGraphicsView::NoAnchor);
|
||||||
|
|
||||||
@ -264,35 +264,22 @@ qreal Mapcavas::zoomDelta() const
|
|||||||
return m_zoomDelta;
|
return m_zoomDelta;
|
||||||
}
|
}
|
||||||
|
|
||||||
// new: set associated raster layer
|
// set associated raster image layer
|
||||||
void Mapcavas::setLayers(RasterLayer* layer)
|
void Mapcavas::setImageLayer(RasterImageLayer* layer)
|
||||||
{
|
{
|
||||||
m_rasterLayer = layer;
|
m_imageLayer = layer;
|
||||||
}
|
}
|
||||||
|
|
||||||
RasterLayer* Mapcavas::rasterLayer() const
|
RasterImageLayer* Mapcavas::imageLayer() const
|
||||||
{
|
{
|
||||||
return m_rasterLayer;
|
return m_imageLayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
// new: refresh the map by rendering using the RasterLayer's render method
|
|
||||||
void Mapcavas::freshmap()
|
void Mapcavas::freshmap()
|
||||||
{
|
{
|
||||||
if (!m_rasterLayer) return;
|
if (!m_imageLayer) return;
|
||||||
|
|
||||||
RasterLayer::RenderParams params = m_rasterLayer->currentRenderParams();
|
QImage img = m_imageLayer->render();
|
||||||
QImage img = m_rasterLayer->render(params);
|
|
||||||
if (img.isNull()) return;
|
|
||||||
|
|
||||||
QPixmap pm = QPixmap::fromImage(img);
|
|
||||||
SetImage(&pm);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Mapcavas::freshmap(const RasterLayer::RenderParams& params)
|
|
||||||
{
|
|
||||||
if (!m_rasterLayer) return;
|
|
||||||
|
|
||||||
QImage img = m_rasterLayer->render(params);
|
|
||||||
if (img.isNull()) return;
|
if (img.isNull()) return;
|
||||||
|
|
||||||
QPixmap pm = QPixmap::fromImage(img);
|
QPixmap pm = QPixmap::fromImage(img);
|
||||||
|
|||||||
@ -1,10 +1,11 @@
|
|||||||
#ifndef MAPCAVAS_H
|
#ifndef MAPCAVAS_H
|
||||||
#define MAPCAVAS_H
|
#define MAPCAVAS_H
|
||||||
|
|
||||||
#include "QGraphicsView"
|
#include "QGraphicsView"
|
||||||
#include "qlabel.h"
|
#include "qlabel.h"
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
#include "RasterLayer.h"
|
|
||||||
|
class RasterImageLayer;
|
||||||
|
|
||||||
class MapTool;
|
class MapTool;
|
||||||
|
|
||||||
@ -16,7 +17,7 @@ public:
|
|||||||
Mapcavas(QWidget* pParent = NULL);
|
Mapcavas(QWidget* pParent = NULL);
|
||||||
~Mapcavas();
|
~Mapcavas();
|
||||||
|
|
||||||
|
|
||||||
void DisplayFrameNumber(int frameNumber);
|
void DisplayFrameNumber(int frameNumber);
|
||||||
|
|
||||||
|
|
||||||
@ -35,24 +36,23 @@ public:
|
|||||||
void wheelEvent(QWheelEvent *event) Q_DECL_OVERRIDE;
|
void wheelEvent(QWheelEvent *event) Q_DECL_OVERRIDE;
|
||||||
void scaling(qreal scaleFactor);
|
void scaling(qreal scaleFactor);
|
||||||
|
|
||||||
void zoomIn(); // <EFBFBD>Ŵ<EFBFBD>
|
void zoomIn(); // 放大
|
||||||
void zoomOut(); // <EFBFBD><EFBFBD>С
|
void zoomOut(); // 缩小
|
||||||
void zoom(float scaleFactor); // <EFBFBD><EFBFBD><EFBFBD><EFBFBD> - scaleFactor<EFBFBD><EFBFBD><EFBFBD>ŵı<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
void zoom(float scaleFactor); // 缩放 - scaleFactor缩放的比例因子
|
||||||
|
|
||||||
// ƽ<EFBFBD><EFBFBD><EFBFBD>ٶ<EFBFBD>
|
// 平移速度
|
||||||
void setTranslateSpeed(qreal speed);
|
void setTranslateSpeed(qreal speed);
|
||||||
qreal translateSpeed() const;
|
qreal translateSpeed() const;
|
||||||
|
|
||||||
// <EFBFBD><EFBFBD><EFBFBD>ŵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
// 缩放的增量
|
||||||
void setZoomDelta(qreal delta);
|
void setZoomDelta(qreal delta);
|
||||||
qreal zoomDelta() const;
|
qreal zoomDelta() const;
|
||||||
|
|
||||||
// new: set raster layer and refresh map
|
// set raster image layer and refresh map
|
||||||
void setLayers(RasterLayer* layer);
|
void setImageLayer(RasterImageLayer* layer);
|
||||||
void freshmap();
|
void freshmap();
|
||||||
void freshmap(const RasterLayer::RenderParams& params);
|
|
||||||
|
|
||||||
RasterLayer* rasterLayer() const;
|
RasterImageLayer* imageLayer() const;
|
||||||
|
|
||||||
// MapTool management
|
// MapTool management
|
||||||
void setMapTool(MapTool* tool);
|
void setMapTool(MapTool* tool);
|
||||||
@ -63,16 +63,16 @@ protected:
|
|||||||
QGraphicsScene *m_qtGraphicsScene;
|
QGraphicsScene *m_qtGraphicsScene;
|
||||||
private:
|
private:
|
||||||
QGraphicsPixmapItem *m_GraphicsPixmapItemHandle;
|
QGraphicsPixmapItem *m_GraphicsPixmapItemHandle;
|
||||||
QLabel *m_framNumberLabel;//<EFBFBD><EFBFBD>ʾʵʱ<EFBFBD>ɼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֡<EFBFBD><EFBFBD>
|
QLabel *m_framNumberLabel;//显示实时采集到的帧数
|
||||||
|
|
||||||
RasterLayer* m_rasterLayer = nullptr; // associated raster layer
|
RasterImageLayer* m_imageLayer = nullptr; // associated raster image layer
|
||||||
MapTool* m_mapTool = nullptr; // current active map tool
|
MapTool* m_mapTool = nullptr; // current active map tool
|
||||||
|
|
||||||
qreal m_translateSpeed; // ƽ<EFBFBD><EFBFBD><EFBFBD>ٶ<EFBFBD>
|
qreal m_translateSpeed; // 平移速度
|
||||||
qreal m_zoomDelta; // <EFBFBD><EFBFBD><EFBFBD>ŵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
qreal m_zoomDelta; // 缩放的增量
|
||||||
bool m_bMouseTranslate; // ƽ<EFBFBD>Ʊ<EFBFBD>ʶ
|
bool m_bMouseTranslate; // 平移标识
|
||||||
QPoint m_lastMousePos; // <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD>λ<EFBFBD><EFBFBD>
|
QPoint m_lastMousePos; // 鼠标最后按下的位置
|
||||||
qreal m_scale; // <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
|
qreal m_scale; // 缩放值
|
||||||
|
|
||||||
double m_CrosshairHalfLen = 10.0;
|
double m_CrosshairHalfLen = 10.0;
|
||||||
QGraphicsLineItem* m_hLine = nullptr; // horizontal line
|
QGraphicsLineItem* m_hLine = nullptr; // horizontal line
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
#include "ImagerOperationBase.h"
|
#include "ImagerOperationBase.h"
|
||||||
|
#include <QDir>
|
||||||
|
|
||||||
ImagerOperationBase::ImagerOperationBase()
|
ImagerOperationBase::ImagerOperationBase()
|
||||||
{
|
{
|
||||||
@ -44,11 +45,11 @@ void ImagerOperationBase::connect_imager(int frameNumber)
|
|||||||
|
|
||||||
double ImagerOperationBase::auto_exposure()
|
double ImagerOperationBase::auto_exposure()
|
||||||
{
|
{
|
||||||
//<EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ع<EFBFBD>ʱ<EFBFBD><EFBFBD>Ϊ<EFBFBD>ڵ<EFBFBD>ǰ֡<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
//第一步:先设置曝光时间为在当前帧率情况下最大
|
||||||
double x = 1 / getFramerate() * 1000;//<EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ع<EFBFBD>ʱ<EFBFBD><EFBFBD>
|
double x = 1 / getFramerate() * 1000;//获取最大毫秒曝光时间
|
||||||
setIntegrationTime(x);
|
setIntegrationTime(x);
|
||||||
|
|
||||||
//<EFBFBD>ڶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><EFBFBD>ѭ<EFBFBD><EFBFBD>Ѱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ع<EFBFBD>ʱ<EFBFBD><EFBFBD>
|
//第二步:通过循环寻找最佳曝光时间
|
||||||
imagerStartCollect();
|
imagerStartCollect();
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
@ -57,7 +58,7 @@ double ImagerOperationBase::auto_exposure()
|
|||||||
if (GetMaxValue(buffer, m_FrameSize) >= 4094)
|
if (GetMaxValue(buffer, m_FrameSize) >= 4094)
|
||||||
{
|
{
|
||||||
setIntegrationTime(getIntegrationTime() * 0.95);
|
setIntegrationTime(getIntegrationTime() * 0.95);
|
||||||
std::cout << "<EFBFBD>Զ<EFBFBD><EFBFBD>ع<EFBFBD>-----------" << std::endl;
|
std::cout << "自动曝光-----------" << std::endl;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -69,7 +70,7 @@ double ImagerOperationBase::auto_exposure()
|
|||||||
|
|
||||||
emit autoExposureSignal();
|
emit autoExposureSignal();
|
||||||
|
|
||||||
//std::cout << "<EFBFBD>Զ<EFBFBD><EFBFBD>ع⣺" << getIntegrationTime() << std::endl;
|
//std::cout << "自动曝光:" << getIntegrationTime() << std::endl;
|
||||||
|
|
||||||
return getIntegrationTime();
|
return getIntegrationTime();
|
||||||
}
|
}
|
||||||
@ -79,7 +80,7 @@ void ImagerOperationBase::focus()
|
|||||||
m_iFocusFramesNumber = 0;
|
m_iFocusFramesNumber = 0;
|
||||||
|
|
||||||
m_iFocusFrameCounter = 1;
|
m_iFocusFrameCounter = 1;
|
||||||
//std::cout << "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>-----------" << std::endl;
|
//std::cout << "调焦-----------" << std::endl;
|
||||||
|
|
||||||
double tmpFrmerate = getFramerate();
|
double tmpFrmerate = getFramerate();
|
||||||
double tmpIntegrationTime = getIntegrationTime();
|
double tmpIntegrationTime = getIntegrationTime();
|
||||||
@ -87,7 +88,7 @@ void ImagerOperationBase::focus()
|
|||||||
|
|
||||||
setFramerate(5);
|
setFramerate(5);
|
||||||
auto_exposure();
|
auto_exposure();
|
||||||
std::cout << "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD><EFBFBD>ع<EFBFBD>ʱ<EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>" << getIntegrationTime() << std::endl;
|
std::cout << "调焦获得的曝光时间为:" << getIntegrationTime() << std::endl;
|
||||||
|
|
||||||
int iWidth, iHeight;
|
int iWidth, iHeight;
|
||||||
GetFrameSize(iWidth, iHeight);
|
GetFrameSize(iWidth, iHeight);
|
||||||
@ -99,7 +100,7 @@ void ImagerOperationBase::focus()
|
|||||||
m_bFocusControlState = true;
|
m_bFocusControlState = true;
|
||||||
while (m_bFocusControlState)
|
while (m_bFocusControlState)
|
||||||
{
|
{
|
||||||
////<EFBFBD><EFBFBD>֡ƽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֡<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
////多帧平均,减弱单帧跳动
|
||||||
//memset((void*)buffer, 0, m_FrameSize * sizeof(unsigned short));
|
//memset((void*)buffer, 0, m_FrameSize * sizeof(unsigned short));
|
||||||
//int fn = 5;
|
//int fn = 5;
|
||||||
//for (int i = 0; i < fn; i++)
|
//for (int i = 0; i < fn; i++)
|
||||||
@ -123,7 +124,7 @@ void ImagerOperationBase::focus()
|
|||||||
|
|
||||||
double focusIndex = calcFocusIndexSobelPrivate(buffer);
|
double focusIndex = calcFocusIndexSobelPrivate(buffer);
|
||||||
emit FocusIndexSobelSignal(focusIndex);
|
emit FocusIndexSobelSignal(focusIndex);
|
||||||
std::cout << "focusIndex<EFBFBD><EFBFBD>" << focusIndex << std::endl;
|
std::cout << "focusIndex:" << focusIndex << std::endl;
|
||||||
|
|
||||||
emit SpectralSignal(1);
|
emit SpectralSignal(1);
|
||||||
|
|
||||||
@ -140,7 +141,7 @@ void ImagerOperationBase::focus()
|
|||||||
|
|
||||||
void ImagerOperationBase::record_dark()
|
void ImagerOperationBase::record_dark()
|
||||||
{
|
{
|
||||||
std::cout << "<EFBFBD>ɼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>" << std::endl;
|
std::cout << "采集暗电流!!!!!!!!!" << std::endl;
|
||||||
imagerStartCollect();
|
imagerStartCollect();
|
||||||
|
|
||||||
unsigned int* dark_tmp = new unsigned int[m_FrameSize];
|
unsigned int* dark_tmp = new unsigned int[m_FrameSize];
|
||||||
@ -172,7 +173,7 @@ void ImagerOperationBase::record_dark()
|
|||||||
|
|
||||||
void ImagerOperationBase::record_white()
|
void ImagerOperationBase::record_white()
|
||||||
{
|
{
|
||||||
std::cout << "<EFBFBD>ɼ<EFBFBD><EFBFBD>װ壡<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>" << std::endl;
|
std::cout << "采集白板!!!!!!!!!" << std::endl;
|
||||||
imagerStartCollect();
|
imagerStartCollect();
|
||||||
|
|
||||||
unsigned int* white_tmp = new unsigned int[m_FrameSize];
|
unsigned int* white_tmp = new unsigned int[m_FrameSize];
|
||||||
@ -197,7 +198,7 @@ void ImagerOperationBase::record_white()
|
|||||||
|
|
||||||
imagerStopCollect();
|
imagerStopCollect();
|
||||||
|
|
||||||
//<EFBFBD>װ<EFBFBD><EFBFBD>۰<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
//白板扣暗电流
|
||||||
if (m_HasDark)
|
if (m_HasDark)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < m_FrameSize; i++)
|
for (size_t i = 0; i < m_FrameSize; i++)
|
||||||
@ -225,17 +226,17 @@ void ImagerOperationBase::start_record()
|
|||||||
//std::cout << "------------------------------------------------------" << std::endl;
|
//std::cout << "------------------------------------------------------" << std::endl;
|
||||||
|
|
||||||
m_iFrameCounter = 0;
|
m_iFrameCounter = 0;
|
||||||
m_RgbImage->m_iFrameCounter = 0;//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>rgbͼ<EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD>0<EFBFBD><EFBFBD>
|
m_RgbImage->m_iFrameCounter = 0;//设置填充rgb图像的第0行
|
||||||
m_bRecordControlState = true;
|
m_bRecordControlState = true;
|
||||||
|
|
||||||
//<EFBFBD>ж<EFBFBD><EFBFBD>ڴ<EFBFBD>buffer<EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
//判断内存buffer是否正常分配
|
||||||
if (buffer == 0)
|
if (buffer == 0)
|
||||||
{
|
{
|
||||||
std::cerr << "Error: memory could not be allocated for datacube";
|
std::cerr << "Error: memory could not be allocated for datacube";
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// <EFBFBD>ڿ<EFBFBD>ʼ<EFBFBD>ɼ<EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD>UI <20><><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD> MapLayer <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
// 在开始采集时仅发出文件信息,UI 层自行创建 MapLayer 并管理生命周期
|
||||||
// prepare file name that will be used for saving
|
// prepare file name that will be used for saving
|
||||||
m_FileName2Save2 = m_FileName2Save + "_" + std::to_string(m_FileSavedCounter) + ".bil";
|
m_FileName2Save2 = m_FileName2Save + "_" + std::to_string(m_FileSavedCounter) + ".bil";
|
||||||
QString baseName = QString::fromStdString(getFileNameFromPath(m_FileName2Save2));
|
QString baseName = QString::fromStdString(getFileNameFromPath(m_FileName2Save2));
|
||||||
@ -250,6 +251,7 @@ void ImagerOperationBase::start_record()
|
|||||||
string timesFile = removeFileExtension(m_FileName2Save2) + ".times";
|
string timesFile = removeFileExtension(m_FileName2Save2) + ".times";
|
||||||
FILE* hTimesFile = fopen(timesFile.c_str(), "w+");
|
FILE* hTimesFile = fopen(timesFile.c_str(), "w+");
|
||||||
|
|
||||||
|
|
||||||
imagerStartCollect();
|
imagerStartCollect();
|
||||||
while (m_bRecordControlState)
|
while (m_bRecordControlState)
|
||||||
{
|
{
|
||||||
@ -257,8 +259,9 @@ void ImagerOperationBase::start_record()
|
|||||||
|
|
||||||
getFrame(buffer);
|
getFrame(buffer);
|
||||||
long long timeOs = getNanosecondsSinceMidnight();
|
long long timeOs = getNanosecondsSinceMidnight();
|
||||||
|
//qDebug() << "time ns-------------------: " << timeOs;
|
||||||
//<2F><>ȥ<EFBFBD><C8A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӦΪbuffer<65><72>dark<72><6B><EFBFBD><EFBFBD>unsigned short<72><74><EFBFBD><EFBFBD><EFBFBD>Ե<EFBFBD>dark>bufferʱ<72><CAB1>buffer-dark=65535
|
|
||||||
|
//减去暗电流,应为buffer和dark都是unsigned short,所以当dark>buffer时,buffer-dark=65535
|
||||||
if (m_HasDark)
|
if (m_HasDark)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < m_FrameSize; i++)
|
for (size_t i = 0; i < m_FrameSize; i++)
|
||||||
@ -276,12 +279,12 @@ void ImagerOperationBase::start_record()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//ת<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
//转反射率
|
||||||
if (m_HasWhite)
|
if (m_HasWhite)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < m_FrameSize; i++)
|
for (size_t i = 0; i < m_FrameSize; i++)
|
||||||
{
|
{
|
||||||
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>װ壩Ϊ0<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
//处理除数(白板)为0的情况
|
||||||
if (white[i] != 0)
|
if (white[i] != 0)
|
||||||
{
|
{
|
||||||
pixelValueTmp = buffer[i];
|
pixelValueTmp = buffer[i];
|
||||||
@ -297,14 +300,14 @@ void ImagerOperationBase::start_record()
|
|||||||
}
|
}
|
||||||
|
|
||||||
x = fwrite(buffer, 2, m_FrameSize, m_fImage);
|
x = fwrite(buffer, 2, m_FrameSize, m_fImage);
|
||||||
fprintf(hTimesFile, "%d\n", timeOs);
|
fprintf(hTimesFile, "%ll\n", timeOs);
|
||||||
|
|
||||||
//<EFBFBD><EFBFBD>rgb<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><EFBFBD>ڽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
|
//将rgb波段提取出来,以便在界面中显示
|
||||||
m_RgbImage->FillRgbImage(buffer);//??????????????????????????????????????????????????????????????????????????????????????????????????????
|
m_RgbImage->FillRgbImage(buffer);//??????????????????????????????????????????????????????????????????????????????????????????????????????
|
||||||
|
|
||||||
//std::cout << "<EFBFBD><EFBFBD>" << m_iFrameCounter << "֡д<EFBFBD><EFBFBD>" << x << "<EFBFBD><EFBFBD>unsigned short<EFBFBD><EFBFBD>" << std::endl;
|
//std::cout << "第" << m_iFrameCounter << "帧写了" << x << "个unsigned short。" << std::endl;
|
||||||
|
|
||||||
//ÿ<EFBFBD><EFBFBD>1s<EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>ν<EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD>λ<EFBFBD><EFBFBD><EFBFBD>
|
//每隔1s进行一次界面图形绘制
|
||||||
if (m_iFrameCounter % (int)getFramerate() == 0)
|
if (m_iFrameCounter % (int)getFramerate() == 0)
|
||||||
{
|
{
|
||||||
emit PlotSignal(m_FileSavedCounter, m_iFrameCounter, filePath);
|
emit PlotSignal(m_FileSavedCounter, m_iFrameCounter, filePath);
|
||||||
@ -318,15 +321,15 @@ void ImagerOperationBase::start_record()
|
|||||||
}
|
}
|
||||||
imagerStopCollect();
|
imagerStopCollect();
|
||||||
|
|
||||||
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>λ<EFBFBD>ͼǰ<EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
//在最后一次画图前需要进行一次拉伸
|
||||||
//m_RgbImage
|
//m_RgbImage
|
||||||
emit PlotSignal(m_FileSavedCounter, -1, filePath);
|
emit PlotSignal(m_FileSavedCounter, -1, filePath);//采集完成后进行一次画图,以防采集帧数不是帧率的倍数时,画图不全
|
||||||
|
|
||||||
m_bRecordControlState = false;
|
m_bRecordControlState = false;
|
||||||
WriteHdr();
|
WriteHdr();
|
||||||
|
|
||||||
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD> ImageFileSaved <EFBFBD>źţ<EFBFBD>֪ͨ UI <20><><EFBFBD>Ѹ<EFBFBD><D1B8>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
// 发射 ImageFileSaved 信号,通知 UI 层把该文件加入图层管理器
|
||||||
// m_FileName2Save2 <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˱<EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><EFBFBD><EFBFBD><EFBFBD> .bil <20>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> "tmp_image_0.bil"<EFBFBD><EFBFBD>
|
// m_FileName2Save2 保存了本次写入的 .bil 文件名(例如 "tmp_image_0.bil")
|
||||||
emit ImageFileSaved(QString::fromStdString(m_FileName2Save2), m_FileSavedCounter);
|
emit ImageFileSaved(QString::fromStdString(m_FileName2Save2), m_FileSavedCounter);
|
||||||
|
|
||||||
m_FileSavedCounter++;
|
m_FileSavedCounter++;
|
||||||
@ -357,6 +360,14 @@ void ImagerOperationBase::setFileName2Save(string FileName)
|
|||||||
m_FileSavedCounter = 0;
|
m_FileSavedCounter = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ImagerOperationBase::updateRecordingFileInfo(const QString& filePath, const QString& baseName, int frameNumber)
|
||||||
|
{
|
||||||
|
m_FileName2Save = (filePath + QDir::separator() + baseName).toStdString();
|
||||||
|
m_FileSavedCounter = 0;
|
||||||
|
|
||||||
|
setFrameNumber(frameNumber);
|
||||||
|
}
|
||||||
|
|
||||||
void ImagerOperationBase::setFocusControlState(bool FocusControlState)
|
void ImagerOperationBase::setFocusControlState(bool FocusControlState)
|
||||||
{
|
{
|
||||||
m_bFocusControlState = FocusControlState;
|
m_bFocusControlState = FocusControlState;
|
||||||
@ -397,7 +408,7 @@ double ImagerOperationBase::calcFocusIndexSobelPrivate(void* pvData)
|
|||||||
unsigned short* psData;
|
unsigned short* psData;
|
||||||
psData = (unsigned short*)pvData;
|
psData = (unsigned short*)pvData;
|
||||||
|
|
||||||
cv::Mat gray(iHeight, iWidth, CV_16UC1, psData);//<EFBFBD><EFBFBD><EFBFBD><EFBFBD>֤<EFBFBD><EFBFBD>gray.data<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݺ<EFBFBD>psDataһ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
cv::Mat gray(iHeight, iWidth, CV_16UC1, psData);//经验证,gray.data的数据和psData一样;
|
||||||
/*string rgbFilePathNoStrech = "E:\\hppa\\delete\\focusImg_";
|
/*string rgbFilePathNoStrech = "E:\\hppa\\delete\\focusImg_";
|
||||||
string tmp1 = std::to_string(m_iFocusFramesNumber);
|
string tmp1 = std::to_string(m_iFocusFramesNumber);
|
||||||
string tmp2 = ".png";*/
|
string tmp2 = ".png";*/
|
||||||
@ -407,7 +418,7 @@ double ImagerOperationBase::calcFocusIndexSobelPrivate(void* pvData)
|
|||||||
//cv::imwrite(rgbFilePathNoStrech, gray);
|
//cv::imwrite(rgbFilePathNoStrech, gray);
|
||||||
m_iFocusFramesNumber++;
|
m_iFocusFramesNumber++;
|
||||||
|
|
||||||
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˲<EFBFBD>
|
//进行滤波
|
||||||
//cv::Mat outputImage;
|
//cv::Mat outputImage;
|
||||||
//cv::Size kernelSize(5, 5);
|
//cv::Size kernelSize(5, 5);
|
||||||
//double sigmaX = 1.5;
|
//double sigmaX = 1.5;
|
||||||
@ -417,7 +428,7 @@ double ImagerOperationBase::calcFocusIndexSobelPrivate(void* pvData)
|
|||||||
|
|
||||||
cv::Mat gradX, gradY, absGradX, absGradY;
|
cv::Mat gradX, gradY, absGradX, absGradY;
|
||||||
|
|
||||||
cv::Sobel(outputImage, gradX, CV_32F, 1, 0);//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ΪCV_16S<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>cv::magnitude<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
cv::Sobel(outputImage, gradX, CV_32F, 1, 0);//如果参数为CV_16S,则函数cv::magnitude报错
|
||||||
cv::Sobel(outputImage, gradY, CV_32F, 0, 1);
|
cv::Sobel(outputImage, gradY, CV_32F, 0, 1);
|
||||||
cv::convertScaleAbs(gradX, absGradX);
|
cv::convertScaleAbs(gradX, absGradX);
|
||||||
cv::convertScaleAbs(gradY, absGradY);
|
cv::convertScaleAbs(gradY, absGradY);
|
||||||
@ -426,7 +437,7 @@ double ImagerOperationBase::calcFocusIndexSobelPrivate(void* pvData)
|
|||||||
|
|
||||||
cv::Mat magnitude, direction;
|
cv::Mat magnitude, direction;
|
||||||
cv::magnitude(gradX, gradY, magnitude);//
|
cv::magnitude(gradX, gradY, magnitude);//
|
||||||
cv::phase(gradX, gradY, direction, true); // true<EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD>ؽǶȶ<EFBFBD><EFBFBD>ǻ<EFBFBD><EFBFBD><EFBFBD>
|
cv::phase(gradX, gradY, direction, true); // true表示返回角度而非弧度
|
||||||
|
|
||||||
|
|
||||||
return cv::mean(magnitude)[0];
|
return cv::mean(magnitude)[0];
|
||||||
@ -479,23 +490,23 @@ int ImagerOperationBase::getFocusFrameCounter() const
|
|||||||
|
|
||||||
void ImagerOperationBase::set_buffer()
|
void ImagerOperationBase::set_buffer()
|
||||||
{
|
{
|
||||||
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
//如果
|
||||||
if (buffer != nullptr)
|
if (buffer != nullptr)
|
||||||
{
|
{
|
||||||
std::cout << "<EFBFBD>ͷŶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD>" << std::endl;
|
std::cout << "释放堆上内存" << std::endl;
|
||||||
free(buffer);
|
free(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_FrameSize = getBandCount() * getSampleCount();
|
m_FrameSize = getBandCount() * getSampleCount();
|
||||||
//std::cout << "m_FrameSize<EFBFBD><EFBFBD>СΪ" << m_FrameSize << std::endl;
|
//std::cout << "m_FrameSize大小为" << m_FrameSize << std::endl;
|
||||||
|
|
||||||
buffer = new unsigned short[m_FrameSize];
|
buffer = new unsigned short[m_FrameSize];
|
||||||
dark = new unsigned short[m_FrameSize];
|
dark = new unsigned short[m_FrameSize];
|
||||||
white = new unsigned short[m_FrameSize];
|
white = new unsigned short[m_FrameSize];
|
||||||
|
|
||||||
std::cout << "buffer<EFBFBD>ڴ<EFBFBD><EFBFBD><EFBFBD>ַ" << buffer << std::endl;
|
std::cout << "buffer内存地址" << buffer << std::endl;
|
||||||
std::cout << "dark<EFBFBD>ڴ<EFBFBD><EFBFBD><EFBFBD>ַ" << dark << std::endl;
|
std::cout << "dark内存地址" << dark << std::endl;
|
||||||
std::cout << "white<EFBFBD>ڴ<EFBFBD><EFBFBD><EFBFBD>ַ" << white << std::endl;
|
std::cout << "white内存地址" << white << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImagerOperationBase::WriteHdr()
|
void ImagerOperationBase::WriteHdr()
|
||||||
@ -540,6 +551,6 @@ unsigned short ImagerOperationBase::GetMaxValue(unsigned short* dark, int number
|
|||||||
max = dark[i];
|
max = dark[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//std::cout << "<EFBFBD><EFBFBD>֡<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵΪ" << max << std::endl;
|
//std::cout << "本帧最大值为" << max << std::endl;
|
||||||
return max;
|
return max;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ public:
|
|||||||
int getFrameCounter() const;
|
int getFrameCounter() const;
|
||||||
int getFocusFrameCounter() const;
|
int getFocusFrameCounter() const;
|
||||||
|
|
||||||
unsigned short* buffer;//<EFBFBD>洢<EFBFBD>ɼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>м<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD>д<EFBFBD>뵽Ӳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
unsigned short* buffer;//存储采集到的影像的中间变量,下一步写入到硬盘中
|
||||||
void set_buffer();
|
void set_buffer();
|
||||||
void setFileName2Save(string FileName);
|
void setFileName2Save(string FileName);
|
||||||
|
|
||||||
@ -60,25 +60,25 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
CImage* m_RgbImage;//<EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD>rgbͼ<EFBFBD><EFBFBD>
|
CImage* m_RgbImage;//显示的rgb图像
|
||||||
bool m_bRecordControlState;//<EFBFBD>ɼ<EFBFBD>״̬<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD><EFBFBD>ֹͣ<EFBFBD>ɼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
bool m_bRecordControlState;//采集状态;可用于执行停止采集操作
|
||||||
int m_iFrameCounter;//<EFBFBD><EFBFBD>¼<EFBFBD>ɼ<EFBFBD><EFBFBD><EFBFBD>֡<EFBFBD><EFBFBD>
|
int m_iFrameCounter;//记录采集的帧数
|
||||||
int m_iFocusFrameCounter;//<EFBFBD><EFBFBD>¼<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>ɼ<EFBFBD><EFBFBD><EFBFBD>֡<EFBFBD><EFBFBD>
|
int m_iFocusFrameCounter;//记录调焦时采集的帧数
|
||||||
int m_FrameSize;//<EFBFBD><EFBFBD>ʾһ֡<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><EFBFBD>ٸ<EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD>m_FrameSize = m_imager.get_band_count()*m_imager.get_sample_count();
|
int m_FrameSize;//表示一帧代表有多少个数值:m_FrameSize = m_imager.get_band_count()*m_imager.get_sample_count();
|
||||||
int m_iFrameNumber;//<EFBFBD><EFBFBD>Ҫ<EFBFBD>ɼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֡<EFBFBD><EFBFBD>
|
int m_iFrameNumber;//需要采集的总帧数
|
||||||
|
|
||||||
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڸ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӱ<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
//以下两个参数用于给保存的影像文件命名
|
||||||
string m_FileName2Save;//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӱ<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>
|
string m_FileName2Save;//保存的影像文件名
|
||||||
string m_FileName2Save2;
|
string m_FileName2Save2;
|
||||||
int m_FileSavedCounter;//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˼<EFBFBD><EFBFBD><EFBFBD>Ӱ<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
|
int m_FileSavedCounter;//保存了几个影像文件
|
||||||
|
|
||||||
bool m_HasDark;//<EFBFBD><EFBFBD><EFBFBD>ɼ<EFBFBD><EFBFBD>˰<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֮<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊtrue
|
bool m_HasDark;//当采集了暗电流之后,设置为true
|
||||||
bool m_HasWhite;//<EFBFBD><EFBFBD><EFBFBD>ɼ<EFBFBD><EFBFBD>˰װ<EFBFBD>֮<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊtrue
|
bool m_HasWhite;//当采集了白板之后,设置为true
|
||||||
|
|
||||||
unsigned short* dark;//<EFBFBD>洢<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
unsigned short* dark;//存储暗电流
|
||||||
unsigned short* white;//<EFBFBD>洢<EFBFBD>װ<EFBFBD>
|
unsigned short* white;//存储白板
|
||||||
|
|
||||||
bool m_bFocusControlState;//<EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
bool m_bFocusControlState;//控制调焦结束
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -92,7 +92,7 @@ private:
|
|||||||
double calcFocusIndexSobelPrivate(void* pvData);
|
double calcFocusIndexSobelPrivate(void* pvData);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
virtual void connect_imager(int frameNumber);//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٻ<EFBFBD><EFBFBD><EFBFBD>
|
virtual void connect_imager(int frameNumber);//连接相机、开辟缓存
|
||||||
virtual double auto_exposure();
|
virtual double auto_exposure();
|
||||||
virtual void focus();
|
virtual void focus();
|
||||||
virtual void start_record();
|
virtual void start_record();
|
||||||
@ -101,11 +101,14 @@ public slots:
|
|||||||
virtual void record_white();
|
virtual void record_white();
|
||||||
|
|
||||||
void getFocusIndexSobel();
|
void getFocusIndexSobel();
|
||||||
|
|
||||||
|
void updateRecordingFileInfo(const QString& filePath, const QString& baseName, int frameNumber);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void PlotSignal(int, int, QString);//<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӱ<EFBFBD><EFBFBD><EFBFBD>źţ<EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڼ<EFBFBD><EFBFBD><EFBFBD>Ӱ<EFBFBD>ڶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֡<EFBFBD><EFBFBD><EFBFBD><EFBFBD>-1<><31><EFBFBD><EFBFBD><EFBFBD>˴βɼ<CEB2><C9BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>λ<EFBFBD><CEBB><EFBFBD>
|
void PlotSignal(int, int, QString);//绘制影像信号,第一个参数:第几个影像;第二个参数:采集到的帧数,-1代表此次采集的最后一次绘制
|
||||||
void RecordFinishedSignal_WhenFrameNumberMeet();//<EFBFBD>ɼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>źţ<EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>ɼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֡<EFBFBD><EFBFBD><EFBFBD><EFBFBD>m_iFrameNumber<EFBFBD><EFBFBD><EFBFBD>ɼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
void RecordFinishedSignal_WhenFrameNumberMeet();//采集完成信号:需要采集的总帧数(m_iFrameNumber)采集完成
|
||||||
void RecordFinishedSignal_WhenFrameNumberNotMeet();//<EFBFBD>ɼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>źţ<EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>ɼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֡<EFBFBD><EFBFBD><EFBFBD><EFBFBD>m_iFrameNumber<EFBFBD><EFBFBD>û<EFBFBD>вɼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɣ<EFBFBD><EFBFBD><EFBFBD>;ֹͣ<EFBFBD>ɼ<EFBFBD>
|
void RecordFinishedSignal_WhenFrameNumberNotMeet();//采集完成信号:需要采集的总帧数(m_iFrameNumber)没有采集完成,中途停止采集
|
||||||
void SpectralSignal(int);//<EFBFBD><EFBFBD><EFBFBD><EFBFBD>1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƹ<EFBFBD><EFBFBD>ף<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0<EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɣ<EFBFBD>
|
void SpectralSignal(int);//发射1代表正在调焦,绘制光谱,发射0表示调焦完成;
|
||||||
|
|
||||||
void RecordWhiteFinishSignal();
|
void RecordWhiteFinishSignal();
|
||||||
void RecordDarlFinishSignal();
|
void RecordDarlFinishSignal();
|
||||||
@ -113,12 +116,12 @@ signals:
|
|||||||
void FocusIndexSobelSignal(double);
|
void FocusIndexSobelSignal(double);
|
||||||
|
|
||||||
|
|
||||||
void testImagerStatus();//<EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD>Բ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬<EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
void testImagerStatus();//表示可以测试相机连接状态:是否连接,并反映到界面上
|
||||||
void autoExposureSignal();
|
void autoExposureSignal();
|
||||||
|
|
||||||
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD>Ӱ<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>.bil/.hdr<64><72>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD>ɺ<C9BA><F3B7A2B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӳɼ<D3B2><C9BC>̷߳<DFB3><CCB7><EFBFBD><EFBFBD><EFBFBD>Qt <20><><EFBFBD><EFBFBD> queued connection<EFBFBD><EFBFBD>
|
// 新增:当一组影像文件(.bil/.hdr)写入完成后发出(会从采集线程发出,Qt 会做 queued connection)
|
||||||
void ImageFileSaved(const QString& path, int fileIndex);
|
void ImageFileSaved(const QString& path, int fileIndex);
|
||||||
|
|
||||||
// <EFBFBD>ģ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD>ӷ<EFBFBD><EFBFBD><EFBFBD> MapLayer*<2A><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>·<EFBFBD><C2B7><EFBFBD><EFBFBD>UI <20>㸺<EFBFBD><EFBFBD> MapLayer <20><><EFBFBD><EFBFBD><F3B2A2B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
// 修改:不再直接发送 MapLayer*,而是发送文件名与文件路径,UI 层负责创建 MapLayer 对象并管理生命周期
|
||||||
void LayerFileCreated(const QString& baseName, const QString& filePath, int fileIndex);
|
void LayerFileCreated(const QString& baseName, const QString& filePath, int fileIndex);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
|
|
||||||
#include "ImagerPositionSimulation.h"
|
#include "ImagerPositionSimulation.h"
|
||||||
|
|
||||||
@ -61,7 +61,7 @@ void ImagerPositionSimulation::mouseReleaseEvent(QMouseEvent *event)
|
|||||||
{
|
{
|
||||||
QPoint viewPos = event->pos();
|
QPoint viewPos = event->pos();
|
||||||
|
|
||||||
////<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
////输出类型
|
||||||
//const type_info &x = typeid(imager);
|
//const type_info &x = typeid(imager);
|
||||||
//qDebug() << "---------------type_info: " << x.name() << x.raw_name() << x.hash_code();
|
//qDebug() << "---------------type_info: " << x.name() << x.raw_name() << x.hash_code();
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
#ifndef IMAGER_POSITION_SIMULATION
|
#ifndef IMAGER_POSITION_SIMULATION
|
||||||
#define IMAGER_POSITION_SIMULATION
|
#define IMAGER_POSITION_SIMULATION
|
||||||
#include <QGraphicsView>
|
#include <QGraphicsView>
|
||||||
#include <QGraphicsScene>
|
#include <QGraphicsScene>
|
||||||
@ -16,7 +16,7 @@ public:
|
|||||||
|
|
||||||
void drawX();
|
void drawX();
|
||||||
|
|
||||||
void setSceneRect();//<EFBFBD><EFBFBD>QGraphicsView<EFBFBD><EFBFBD>viewport<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ΪsceneRect
|
void setSceneRect();//将QGraphicsView的viewport设置为sceneRect
|
||||||
|
|
||||||
QRectF sceneRect();
|
QRectF sceneRect();
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
#include "LayerTree.h"
|
#include "LayerTree.h"
|
||||||
|
|
||||||
LayerTree::LayerTree(QObject* parent)
|
LayerTree::LayerTree(QObject* parent)
|
||||||
: LayerTreeGroup("__root__", parent)
|
: LayerTreeGroup("__root__", parent)
|
||||||
|
|||||||
@ -1,14 +1,14 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "LayerTreeGroupNode.h"
|
#include "LayerTreeGroupNode.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* LayerTree<EFBFBD><EFBFBD>ͼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD>
|
* LayerTree:图层树根节点
|
||||||
* - <EFBFBD>̳<EFBFBD><EFBFBD><EFBFBD> LayerTreeGroup<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĸ<EFBFBD><EFBFBD>ڵ<EFBFBD>
|
* - 继承自 LayerTreeGroup,本身就是树的根节点
|
||||||
* - <EFBFBD>ṩ<EFBFBD>ɼ<EFBFBD><EFBFBD>Լ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>븸<EFBFBD>ڵ<EFBFBD><EFBFBD><EFBFBD>̬<EFBFBD><EFBFBD><EFBFBD>µľ<EFBFBD>̬<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
* - 提供可见性级联与父节点三态更新的静态工具
|
||||||
*
|
*
|
||||||
* ע<EFBFBD>⣺beginInsertRows/endInsertRows <EFBFBD><EFBFBD> Qt Model <EFBFBD><EFBFBD><EFBFBD><EFBFBD>֪ͨӦ<EFBFBD><EFBFBD> Model <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ã<EFBFBD>
|
* 注意:beginInsertRows/endInsertRows 等 Qt Model 变更通知应由 Model 驱动调用,
|
||||||
* LayerTree ֻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ά<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݽṹ<EFBFBD><EFBFBD>ȷ<EFBFBD>ԡ<EFBFBD>
|
* LayerTree 只负责维护数据结构正确性。
|
||||||
*/
|
*/
|
||||||
class LayerTree : public LayerTreeGroup
|
class LayerTree : public LayerTreeGroup
|
||||||
{
|
{
|
||||||
@ -20,7 +20,7 @@ public:
|
|||||||
LayerTree(const LayerTree&) = delete;
|
LayerTree(const LayerTree&) = delete;
|
||||||
LayerTree& operator=(const LayerTree&) = delete;
|
LayerTree& operator=(const LayerTree&) = delete;
|
||||||
|
|
||||||
// <EFBFBD>ɼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Model <EFBFBD><EFBFBD><EFBFBD>ã<EFBFBD>
|
// 可见性逻辑(供 Model 调用)
|
||||||
static void setChildrenVisible(LayerTreeNode* n, Qt::CheckState state);
|
static void setChildrenVisible(LayerTreeNode* n, Qt::CheckState state);
|
||||||
static void updateParentVisibleFromChildren(LayerTreeNode* parent);
|
static void updateParentVisibleFromChildren(LayerTreeNode* parent);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
#include "LayerTreeGroupNode.h"
|
#include "LayerTreeGroupNode.h"
|
||||||
#include "LayerTreeLayerNode.h"
|
#include "LayerTreeLayerNode.h"
|
||||||
|
|
||||||
LayerTreeGroup::LayerTreeGroup(const QString& name, QObject* parent)
|
LayerTreeGroup::LayerTreeGroup(const QString& name, QObject* parent)
|
||||||
|
|||||||
@ -1,12 +1,12 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "LayerTreeNode.h"
|
#include "LayerTreeNode.h"
|
||||||
|
|
||||||
class LayerTreeLayer;
|
class LayerTreeLayer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* LayerTreeGroup<EFBFBD><EFBFBD>ͼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD>
|
* LayerTreeGroup:图层组节点
|
||||||
* - <EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ LayerTreeNode
|
* - 基类为 LayerTreeNode
|
||||||
* - <EFBFBD>ṩ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><EFBFBD><EFBFBD>ڵ㣨LayerTreeLayer<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><EFBFBD><EFBFBD>飨LayerTreeGroup<EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
* - 提供插入图层节点(LayerTreeLayer)或图层组(LayerTreeGroup)的便利方法
|
||||||
*/
|
*/
|
||||||
class LayerTreeGroup : public LayerTreeNode
|
class LayerTreeGroup : public LayerTreeNode
|
||||||
{
|
{
|
||||||
@ -17,28 +17,28 @@ public:
|
|||||||
|
|
||||||
Type type() const override { return Type::Group; }
|
Type type() const override { return Type::Group; }
|
||||||
|
|
||||||
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
// 便利方法:插入子组
|
||||||
LayerTreeGroup* insertGroup(int index, const QString& name);
|
LayerTreeGroup* insertGroup(int index, const QString& name);
|
||||||
LayerTreeGroup* addGroup(const QString& name);
|
LayerTreeGroup* addGroup(const QString& name);
|
||||||
|
|
||||||
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD>
|
// 便利方法:插入图层节点
|
||||||
LayerTreeLayer* insertLayer(int index, LayerTreeLayer* layer);
|
LayerTreeLayer* insertLayer(int index, LayerTreeLayer* layer);
|
||||||
LayerTreeLayer* addLayer(LayerTreeLayer* layer);
|
LayerTreeLayer* addLayer(LayerTreeLayer* layer);
|
||||||
|
|
||||||
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD>
|
// 插入任意节点
|
||||||
void insertChildNode(int index, LayerTreeNode* node);
|
void insertChildNode(int index, LayerTreeNode* node);
|
||||||
void addChildNode(LayerTreeNode* node);
|
void addChildNode(LayerTreeNode* node);
|
||||||
|
|
||||||
// <EFBFBD>Ƴ<EFBFBD><EFBFBD>ӽڵ㣨<EFBFBD><EFBFBD> delete<74><65><EFBFBD><EFBFBD><EFBFBD>ر<EFBFBD><D8B1>Ƴ<EFBFBD><C6B3>ڵ㣩
|
// 移除子节点(不 delete,返回被移除节点)
|
||||||
LayerTreeNode* removeChildNode(LayerTreeNode* node);
|
LayerTreeNode* removeChildNode(LayerTreeNode* node);
|
||||||
|
|
||||||
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
// 查找
|
||||||
LayerTreeLayer* findLayer(const QString& name) const;
|
LayerTreeLayer* findLayer(const QString& name) const;
|
||||||
QList<LayerTreeLayer*> findLayers() const;
|
QList<LayerTreeLayer*> findLayers() const;
|
||||||
QList<LayerTreeGroup*> findGroups() const;
|
QList<LayerTreeGroup*> findGroups() const;
|
||||||
|
|
||||||
// <EFBFBD>Ժ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>չ<EFBFBD><EFBFBD>collapsed / groupOpacity <EFBFBD><EFBFBD>
|
// 以后可扩展:collapsed / groupOpacity 等
|
||||||
};
|
};
|
||||||
|
|
||||||
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
// 保持向后兼容
|
||||||
using LayerTreeGroupNode = LayerTreeGroup;
|
using LayerTreeGroupNode = LayerTreeGroup;
|
||||||
|
|||||||
31
HPPA/LayerTreeImageNode.cpp
Normal file
31
HPPA/LayerTreeImageNode.cpp
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
#include "LayerTreeImageNode.h"
|
||||||
|
#include "RasterImageLayer.h"
|
||||||
|
|
||||||
|
LayerTreeImageNode::LayerTreeImageNode(RasterImageLayer* imageLayer,
|
||||||
|
const QString& name,
|
||||||
|
QWidget* widget,
|
||||||
|
QObject* parent)
|
||||||
|
: LayerTreeNode(name, parent)
|
||||||
|
, m_imageLayer(imageLayer)
|
||||||
|
, m_widget(widget)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
LayerTreeImageNode::~LayerTreeImageNode()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
LayerTreeNode::Type LayerTreeImageNode::type() const
|
||||||
|
{
|
||||||
|
return Type::Image;
|
||||||
|
}
|
||||||
|
|
||||||
|
QWidget* LayerTreeImageNode::widget() const
|
||||||
|
{
|
||||||
|
return m_widget;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LayerTreeImageNode::setWidget(QWidget* widget)
|
||||||
|
{
|
||||||
|
m_widget = widget;
|
||||||
|
}
|
||||||
30
HPPA/LayerTreeImageNode.h
Normal file
30
HPPA/LayerTreeImageNode.h
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "LayerTreeNode.h"
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
class QWidget;
|
||||||
|
class RasterImageLayer;
|
||||||
|
|
||||||
|
class LayerTreeImageNode : public LayerTreeNode
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit LayerTreeImageNode(RasterImageLayer* imageLayer,
|
||||||
|
const QString& name,
|
||||||
|
QWidget* widget = nullptr,
|
||||||
|
QObject* parent = nullptr);
|
||||||
|
|
||||||
|
~LayerTreeImageNode();
|
||||||
|
|
||||||
|
Type type() const override;
|
||||||
|
|
||||||
|
RasterImageLayer* imageLayer() const { return m_imageLayer; }
|
||||||
|
QWidget* widget() const;
|
||||||
|
void setWidget(QWidget* widget);
|
||||||
|
|
||||||
|
private:
|
||||||
|
RasterImageLayer* m_imageLayer;
|
||||||
|
QWidget* m_widget = nullptr;
|
||||||
|
};
|
||||||
|
|
||||||
@ -1,7 +1,7 @@
|
|||||||
#include "LayerTreeLayerNode.h"
|
#include "LayerTreeLayerNode.h"
|
||||||
|
|
||||||
LayerTreeLayer::LayerTreeLayer(MapLayer* layer, QObject* parent)
|
LayerTreeLayer::LayerTreeLayer(MapLayer* layer, QObject* parent)
|
||||||
: LayerTreeNode(layer ? layer->name() : QString(), parent), m_layer(layer)
|
: LayerTreeGroup(layer ? layer->name() : QString(), parent), m_layer(layer)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -10,7 +10,7 @@ LayerTreeNode::Type LayerTreeLayer::type() const
|
|||||||
return Type::Layer;
|
return Type::Layer;
|
||||||
}
|
}
|
||||||
|
|
||||||
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD> MapLayer ָ<EFBFBD>루<EFBFBD><EFBFBD>ӵ<EFBFBD>У<EFBFBD>
|
// 持有一个 MapLayer 指针(不拥有)
|
||||||
void LayerTreeLayer::setMapLayer(MapLayer* layer)
|
void LayerTreeLayer::setMapLayer(MapLayer* layer)
|
||||||
{
|
{
|
||||||
m_layer = layer;
|
m_layer = layer;
|
||||||
|
|||||||
@ -1,19 +1,19 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "LayerTreeNode.h"
|
#include "LayerTreeGroupNode.h"
|
||||||
#include "MapLayer.h"
|
#include "MapLayer.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* LayerTreeLayer<EFBFBD><EFBFBD>ͼ<EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD>
|
* LayerTreeLayer:图层节点
|
||||||
* - <EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ LayerTreeNode
|
* - 基类为 LayerTreeNode
|
||||||
* - <EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD> MapLayer ָ<EFBFBD>루<EFBFBD><EFBFBD>ӵ<EFBFBD>У<EFBFBD>
|
* - 持有一个 MapLayer 指针(不拥有)
|
||||||
*/
|
*/
|
||||||
class LayerTreeLayer : public LayerTreeNode
|
class LayerTreeLayer : public LayerTreeGroup
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit LayerTreeLayer(MapLayer* layer, QObject* parent = nullptr);
|
explicit LayerTreeLayer(MapLayer* layer, QObject* parent = nullptr);
|
||||||
|
|
||||||
Type type() const override;
|
Type type() const;
|
||||||
|
|
||||||
void setMapLayer(MapLayer* layer);
|
void setMapLayer(MapLayer* layer);
|
||||||
MapLayer* mapLayer() const;
|
MapLayer* mapLayer() const;
|
||||||
@ -21,8 +21,8 @@ public:
|
|||||||
private:
|
private:
|
||||||
MapLayer* m_layer = nullptr;
|
MapLayer* m_layer = nullptr;
|
||||||
|
|
||||||
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD>չ<EFBFBD><EFBFBD>layerId / pointer / legendItems <EFBFBD><EFBFBD>
|
// 可扩展:layerId / pointer / legendItems 等
|
||||||
};
|
};
|
||||||
|
|
||||||
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
// 保持向后兼容
|
||||||
using LayerTreeLayerNode = LayerTreeLayer;
|
using LayerTreeLayerNode = LayerTreeLayer;
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
#include "LayerTreeModel.h"
|
#include "LayerTreeModel.h"
|
||||||
#include "LayerTreeGroupNode.h"
|
#include "LayerTreeGroupNode.h"
|
||||||
#include "LayerTreeLayerNode.h"
|
#include "LayerTreeLayerNode.h"
|
||||||
|
|
||||||
@ -90,15 +90,15 @@ bool LayerTreeModel::setData(const QModelIndex& index, const QVariant& value, in
|
|||||||
|
|
||||||
n->setVisible(newState);
|
n->setVisible(newState);
|
||||||
|
|
||||||
// 1) <EFBFBD><EFBFBD> -> <EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
// 1) 父 -> 子 级联
|
||||||
if (m_cascadeCheck) {
|
if (m_cascadeCheck) {
|
||||||
LayerTree::setChildrenVisible(n, newState);
|
LayerTree::setChildrenVisible(n, newState);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2) <EFBFBD><EFBFBD> -> <EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> PartiallyChecked
|
// 2) 子 -> 父 更新 PartiallyChecked
|
||||||
LayerTree::updateParentVisibleFromChildren(n->parentNode());
|
LayerTree::updateParentVisibleFromChildren(n->parentNode());
|
||||||
|
|
||||||
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˢ<EFBFBD>£<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>滻Ϊ<EFBFBD><EFBFBD> dataChanged<EFBFBD><EFBFBD>
|
// 简化:整体刷新(你后续可替换为精准 dataChanged)
|
||||||
emit layoutChanged();
|
emit layoutChanged();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -133,7 +133,7 @@ LayerTreeNode* LayerTreeModel::addGroup(LayerTreeNode* parent, const QString& na
|
|||||||
return g;
|
return g;
|
||||||
}
|
}
|
||||||
|
|
||||||
LayerTreeNode* LayerTreeModel::addLayer(LayerTreeNode* parent, LayerTreeLayer* layerNode, const QIcon& icon)
|
LayerTreeNode* LayerTreeModel::addLayer(LayerTreeNode* parent, LayerTreeNode* layerNode, const QIcon& icon)
|
||||||
{
|
{
|
||||||
if (!parent) parent = m_tree;
|
if (!parent) parent = m_tree;
|
||||||
if (!layerNode) return nullptr;
|
if (!layerNode) return nullptr;
|
||||||
@ -156,7 +156,7 @@ bool LayerTreeModel::cascadeCheckEnabled() const
|
|||||||
return m_cascadeCheck;
|
return m_cascadeCheck;
|
||||||
}
|
}
|
||||||
|
|
||||||
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD>֣<EFBFBD><EFBFBD>Ƴ<EFBFBD><EFBFBD>ӽڵ㲢<EFBFBD><EFBFBD> model <EFBFBD>Ϸ<EFBFBD><EFBFBD><EFBFBD> begin/endRemoveRows
|
// 新增实现:移除子节点并在 model 上发出 begin/endRemoveRows
|
||||||
LayerTreeNode* LayerTreeModel::removeNode(LayerTreeNode* parent, int row)
|
LayerTreeNode* LayerTreeModel::removeNode(LayerTreeNode* parent, int row)
|
||||||
{
|
{
|
||||||
if (!parent) parent = m_tree;
|
if (!parent) parent = m_tree;
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QAbstractItemModel>
|
#include <QAbstractItemModel>
|
||||||
#include "LayerTree.h"
|
#include "LayerTree.h"
|
||||||
@ -6,9 +6,9 @@
|
|||||||
class LayerTreeLayer; // forward declare
|
class LayerTreeLayer; // forward declare
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* LayerTreeModel<EFBFBD><EFBFBD>Qt <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>㣨<EFBFBD><EFBFBD><EFBFBD>ٹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
* LayerTreeModel:Qt 适配层(不再管理树)
|
||||||
* - 1 <EFBFBD>У<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƣ<EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD>꣩+ checkbox
|
* - 1 列:名称(带图标)+ checkbox
|
||||||
* - <EFBFBD><EFBFBD>ѡ<EFBFBD>ɼ<EFBFBD><EFBFBD>ԣ<EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD>
|
* - 勾选可见性(可选级联勾选)
|
||||||
*/
|
*/
|
||||||
class LayerTreeModel : public QAbstractItemModel
|
class LayerTreeModel : public QAbstractItemModel
|
||||||
{
|
{
|
||||||
@ -19,7 +19,7 @@ public:
|
|||||||
bool cascadeCheck = true);
|
bool cascadeCheck = true);
|
||||||
~LayerTreeModel() override = default;
|
~LayerTreeModel() override = default;
|
||||||
|
|
||||||
// QAbstractItemModel <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӿ<EFBFBD>
|
// QAbstractItemModel 必须接口
|
||||||
QModelIndex index(int row, int column,
|
QModelIndex index(int row, int column,
|
||||||
const QModelIndex& parent = QModelIndex()) const override;
|
const QModelIndex& parent = QModelIndex()) const override;
|
||||||
QModelIndex parent(const QModelIndex& child) const override;
|
QModelIndex parent(const QModelIndex& child) const override;
|
||||||
@ -30,16 +30,16 @@ public:
|
|||||||
bool setData(const QModelIndex& index, const QVariant& value, int role) override;
|
bool setData(const QModelIndex& index, const QVariant& value, int role) override;
|
||||||
Qt::ItemFlags flags(const QModelIndex& index) const override;
|
Qt::ItemFlags flags(const QModelIndex& index) const override;
|
||||||
|
|
||||||
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD> API<50><49><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD> begin/endInsertRows<EFBFBD><EFBFBD>
|
// 对外 API:构建树(内部会正确调用 begin/endInsertRows)
|
||||||
LayerTreeNode* root() const;
|
LayerTreeNode* root() const;
|
||||||
|
|
||||||
LayerTreeNode* addGroup(LayerTreeNode* parent, const QString& name, const QIcon& icon = QIcon());
|
LayerTreeNode* addGroup(LayerTreeNode* parent, const QString& name, const QIcon& icon = QIcon());
|
||||||
LayerTreeNode* addLayer(LayerTreeNode* parent, LayerTreeLayer* layerNode, const QIcon& icon = QIcon());
|
LayerTreeNode* addLayer(LayerTreeNode* parent, LayerTreeNode* layerNode, const QIcon& icon = QIcon());
|
||||||
|
|
||||||
void setCascadeCheckEnabled(bool enabled);
|
void setCascadeCheckEnabled(bool enabled);
|
||||||
bool cascadeCheckEnabled() const;
|
bool cascadeCheckEnabled() const;
|
||||||
|
|
||||||
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӹ<EFBFBD><EFBFBD>ڵ<EFBFBD><EFBFBD>Ƴ<EFBFBD><EFBFBD>ӽڵ㣨<EFBFBD><EFBFBD>װ LayerTree::removeNode <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> model ֪ͨ<EFBFBD><EFBFBD>
|
// 新增:从父节点移除子节点(包装 LayerTree::removeNode 并发出 model 通知)
|
||||||
LayerTreeNode* removeNode(LayerTreeNode* parent, int row);
|
LayerTreeNode* removeNode(LayerTreeNode* parent, int row);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
#include "LayerTreeNode.h"
|
#include "LayerTreeNode.h"
|
||||||
|
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
|
|
||||||
@ -55,7 +55,7 @@ LayerTreeNode* LayerTreeNode::parentNode() const
|
|||||||
void LayerTreeNode::setParentNode(LayerTreeNode* p)
|
void LayerTreeNode::setParentNode(LayerTreeNode* p)
|
||||||
{
|
{
|
||||||
m_parentNode = p;
|
m_parentNode = p;
|
||||||
// <EFBFBD><EFBFBD> QObject <EFBFBD><EFBFBD> parent Ҳ<EFBFBD><EFBFBD><EFBFBD>棨<EFBFBD><EFBFBD><EFBFBD><EFBFBD> Qt <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ι<EFBFBD><CEB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҳ<EFBFBD><D2B2><EFBFBD>Ӱ<EFBFBD><D3B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD> delete children<EFBFBD><EFBFBD>
|
// 让 QObject 的 parent 也跟随(便于 Qt 对象层次管理,且不会影响我们手动 delete children)
|
||||||
if (p) this->setParent(p);
|
if (p) this->setParent(p);
|
||||||
else this->setParent(nullptr);
|
else this->setParent(nullptr);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
@ -6,20 +6,20 @@
|
|||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* LayerTreeNode<EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ࣨ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
* LayerTreeNode:节点基类(抽象)
|
||||||
* - <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>/ͼ<><CDBC>/<2F>ɼ<EFBFBD><C9BC><EFBFBD>/<2F><><EFBFBD>ӹ<EFBFBD>ϵ
|
* - 仅包含通用属性:名称/图标/可见性/父子关系
|
||||||
* - Group / Layer <EFBFBD>ڵ<EFBFBD>ͨ<EFBFBD><EFBFBD><EFBFBD>̳<EFBFBD>ʵ<EFBFBD><EFBFBD>
|
* - Group / Layer 节点通过继承实现
|
||||||
* - <EFBFBD>ṩ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>/ɾ<><C9BE><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD>ź<EFBFBD>֪ͨ
|
* - 提供插入/删除节点的信号通知
|
||||||
*
|
*
|
||||||
* ˵<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
* 说明:
|
||||||
* - <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬʱά<EFBFBD><EFBFBD>"<22><><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>"<22><>m_parentNode<EFBFBD><EFBFBD><EFBFBD><EFBFBD> QObject parent<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD>
|
* - 这里同时维护"树父指针"(m_parentNode)与 QObject parent(可选)
|
||||||
* - children <EFBFBD>ɽڵ<EFBFBD><EFBFBD>Լ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>в<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷţ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ delete children<EFBFBD><EFBFBD>
|
* - children 由节点自己持有并负责释放(析构时 delete children)
|
||||||
*/
|
*/
|
||||||
class LayerTreeNode : public QObject
|
class LayerTreeNode : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
enum class Type { Group, Layer };
|
enum class Type { Group, Layer, Image };
|
||||||
|
|
||||||
explicit LayerTreeNode(const QString& name,
|
explicit LayerTreeNode(const QString& name,
|
||||||
QObject* parent = nullptr);
|
QObject* parent = nullptr);
|
||||||
@ -52,8 +52,8 @@ public:
|
|||||||
void appendChild(LayerTreeNode* child);
|
void appendChild(LayerTreeNode* child);
|
||||||
void insertChild(int row, LayerTreeNode* child);
|
void insertChild(int row, LayerTreeNode* child);
|
||||||
|
|
||||||
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD> QgsLayerTreeNode::removeChildrenPrivate <EFBFBD>Ľ<EFBFBD>
|
// 基于 QgsLayerTreeNode::removeChildrenPrivate 改进
|
||||||
// from: <EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>, count: <EFBFBD>Ƴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, destroy: true <EFBFBD><EFBFBD> delete <EFBFBD><EFBFBD><EFBFBD>Ƴ<EFBFBD><EFBFBD>ڵ<EFBFBD>
|
// from: 起始索引, count: 移除数量, destroy: true 则 delete 被移除节点
|
||||||
void removeChild(int from, int count, bool destroy = true);
|
void removeChild(int from, int count, bool destroy = true);
|
||||||
|
|
||||||
// ---- static type helpers ----
|
// ---- static type helpers ----
|
||||||
@ -68,11 +68,11 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
// <EFBFBD>ڲ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӽڵ<EFBFBD>֮ǰ/֮<><EFBFBD>
|
// 在插入子节点之前/之后发出
|
||||||
void willAddChildren(LayerTreeNode* node, int indexFrom, int indexTo);
|
void willAddChildren(LayerTreeNode* node, int indexFrom, int indexTo);
|
||||||
void addedChildren(LayerTreeNode* node, int indexFrom, int indexTo);
|
void addedChildren(LayerTreeNode* node, int indexFrom, int indexTo);
|
||||||
|
|
||||||
// <EFBFBD><EFBFBD><EFBFBD>Ƴ<EFBFBD><EFBFBD>ӽڵ<EFBFBD>֮ǰ/֮<><EFBFBD>
|
// 在移除子节点之前/之后发出
|
||||||
void willRemoveChildren(LayerTreeNode* node, int indexFrom, int indexTo);
|
void willRemoveChildren(LayerTreeNode* node, int indexFrom, int indexTo);
|
||||||
void removedChildren(LayerTreeNode* node, int indexFrom, int indexTo);
|
void removedChildren(LayerTreeNode* node, int indexFrom, int indexTo);
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
#include "LayerTreeView.h"
|
#include "LayerTreeView.h"
|
||||||
#include "LayerTreeViewMenuProvider.h"
|
#include "LayerTreeViewMenuProvider.h"
|
||||||
#include <QContextMenuEvent>
|
#include <QContextMenuEvent>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QTreeView>
|
#include <QTreeView>
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
#include "LayerTreeViewMenuProvider.h"
|
#include "LayerTreeViewMenuProvider.h"
|
||||||
#include "LayerTreeView.h"
|
#include "LayerTreeView.h"
|
||||||
#include "LayerTreeModel.h"
|
#include "LayerTreeModel.h"
|
||||||
#include "LayerTreeNode.h"
|
#include "LayerTreeNode.h"
|
||||||
@ -36,16 +36,27 @@ QMenu* LayerTreeViewMenuProvider::createContextMenu()
|
|||||||
|
|
||||||
if (node->type() == LayerTreeNode::Type::Layer)
|
if (node->type() == LayerTreeNode::Type::Layer)
|
||||||
{
|
{
|
||||||
QAction* removeAction = new QAction(QStringLiteral("<EFBFBD>Ƴ<EFBFBD>ͼ<EFBFBD><EFBFBD>"), menu);
|
QAction* removeLayerAction = new QAction(QStringLiteral("移除图层"), menu);
|
||||||
connect(removeAction, &QAction::triggered, HPPA::instance(), &HPPA::removeLayerByTreeIndex);
|
connect(removeLayerAction, &QAction::triggered, HPPA::instance(), &HPPA::removeLayerByTreeIndex);
|
||||||
menu->addAction(removeAction);
|
|
||||||
|
QAction* showColorImageAction = new QAction(QStringLiteral("显示彩色图像"), menu);
|
||||||
|
connect(showColorImageAction, &QAction::triggered, HPPA::instance(), &HPPA::showColorImageByTreeIndex);
|
||||||
|
|
||||||
|
menu->addAction(removeLayerAction);
|
||||||
|
menu->addAction(showColorImageAction);
|
||||||
|
}
|
||||||
|
else if (node->type() == LayerTreeNode::Type::Image)
|
||||||
|
{
|
||||||
|
QAction* removeImageAction = new QAction(QStringLiteral("移除图像"), menu);
|
||||||
|
connect(removeImageAction, &QAction::triggered, HPPA::instance(), &HPPA::removeImageByTreeIndex);
|
||||||
|
menu->addAction(removeImageAction);
|
||||||
}
|
}
|
||||||
else if (node->type() == LayerTreeNode::Type::Group)
|
else if (node->type() == LayerTreeNode::Type::Group)
|
||||||
{
|
{
|
||||||
HPPA* app = HPPA::instance();
|
HPPA* app = HPPA::instance();
|
||||||
if (app && node == app->rasterGroupNode())
|
if (app && node == app->rasterGroupNode())
|
||||||
{
|
{
|
||||||
QAction* removeAllAction = new QAction(QStringLiteral("<EFBFBD>Ƴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><EFBFBD>"), menu);
|
QAction* removeAllAction = new QAction(QStringLiteral("移除所有图层"), menu);
|
||||||
connect(removeAllAction, &QAction::triggered, app, &HPPA::removeAllLayersInRasterGroup);
|
connect(removeAllAction, &QAction::triggered, app, &HPPA::removeAllLayersInRasterGroup);
|
||||||
menu->addAction(removeAllAction);
|
menu->addAction(removeAllAction);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
@ -15,7 +15,7 @@ public:
|
|||||||
explicit LayerTreeViewMenuProvider(LayerTreeView* view, QObject* parent = nullptr);
|
explicit LayerTreeViewMenuProvider(LayerTreeView* view, QObject* parent = nullptr);
|
||||||
~LayerTreeViewMenuProvider() override = default;
|
~LayerTreeViewMenuProvider() override = default;
|
||||||
|
|
||||||
// <EFBFBD><EFBFBD><EFBFBD>ݸ<EFBFBD><EFBFBD><EFBFBD> index <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>˵<EFBFBD><CBB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߸<EFBFBD><DFB8><EFBFBD>ɾ<EFBFBD><C9BE><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD> QMenu*
|
// 根据给定 index 创建一个菜单,调用者负责删除返回的 QMenu*
|
||||||
QMenu* createContextMenu();
|
QMenu* createContextMenu();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
#include "MapLayer.h"
|
#include "MapLayer.h"
|
||||||
|
|
||||||
MapLayer::MapLayer(const QString& name, const QString& uri)
|
MapLayer::MapLayer(const QString& name, const QString& uri)
|
||||||
: QObject(nullptr), m_name(name), m_uri(uri)
|
: QObject(nullptr), m_name(name), m_uri(uri)
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|||||||
@ -1,60 +1,137 @@
|
|||||||
#include "MapLayerStore.h"
|
#include "MapLayerStore.h"
|
||||||
#include "MapLayer.h"
|
#include "MapLayer.h"
|
||||||
|
#include "RasterImageLayer.h"
|
||||||
|
#include <QFileInfo>
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
MapLayerStore::MapLayerStore(QObject* parent)
|
MapLayerStore::MapLayerStore(QObject* parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
{
|
{
|
||||||
int a = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapLayerStore::addLayer(MapLayer* layer, QWidget* widget)
|
void MapLayerStore::addLayer(MapLayer* layer)
|
||||||
{
|
{
|
||||||
if (!layer) return;
|
if (!layer) return;
|
||||||
MapLayer* raw = layer;
|
|
||||||
m_layers.emplace_back(std::shared_ptr<MapLayer>(layer));
|
int index = (int)m_layers.size();
|
||||||
if (widget)
|
LayerEntry entry;
|
||||||
m_layerWidgets[raw] = widget;
|
entry.mapLayer.reset(layer);
|
||||||
emit layerAdded(raw);
|
|
||||||
|
m_layers.push_back(std::move(entry));
|
||||||
|
m_mapLayerIndex[layer] = index;
|
||||||
|
|
||||||
|
emit layerAdded(layer);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MapLayerStore::addImageLayer(MapLayer* mapLayer, RasterImageLayer* imageLayer, QWidget* widget)
|
||||||
|
{
|
||||||
|
if (!mapLayer || !imageLayer) return;
|
||||||
|
|
||||||
|
LayerEntry* entry = findLayerEntry(mapLayer);
|
||||||
|
if (!entry) return;
|
||||||
|
|
||||||
|
entry->imageLayers.push_back({std::unique_ptr<RasterImageLayer>(imageLayer), widget});
|
||||||
|
emit imageLayerAdded(imageLayer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapLayerStore::removeLayer(MapLayer* layer)
|
void MapLayerStore::removeLayer(MapLayer* layer)
|
||||||
{
|
{
|
||||||
if (!layer) return;
|
if (!layer) return;
|
||||||
for (auto it = m_layers.begin(); it != m_layers.end(); ++it) {
|
|
||||||
if (it->get() == layer) {
|
auto it = m_mapLayerIndex.find(layer);
|
||||||
emit layerAboutToBeRemoved(layer);
|
if (it == m_mapLayerIndex.end()) return;
|
||||||
m_layers.erase(it);
|
|
||||||
m_layerWidgets.erase(layer);
|
int index = it->second;
|
||||||
return;
|
if (index < 0 || index >= (int)m_layers.size()) return;
|
||||||
|
|
||||||
|
LayerEntry& entry = m_layers[index];
|
||||||
|
|
||||||
|
// Delete all associated widgets
|
||||||
|
for (auto& imgEntry : entry.imageLayers) {
|
||||||
|
if (imgEntry.widget) {
|
||||||
|
delete imgEntry.widget;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
entry.imageLayers.clear();
|
||||||
|
|
||||||
|
emit layerAboutToBeRemoved(layer);
|
||||||
|
|
||||||
|
m_layers.erase(m_layers.begin() + index);//?????????????????????
|
||||||
|
m_mapLayerIndex.erase(it);
|
||||||
|
|
||||||
|
// Rebuild index for layers after removed one
|
||||||
|
for (int i = index; i < (int)m_layers.size(); ++i) {
|
||||||
|
m_mapLayerIndex[m_layers[i].mapLayer.get()] = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MapLayerStore::removeImageLayer(RasterImageLayer* imageLayer)//可以优化:RasterImageLayer包含一个指向所属MapLayer的指针,这样就不需要遍历所有图层来找到它了
|
||||||
|
{
|
||||||
|
if (!imageLayer) return;
|
||||||
|
|
||||||
|
for (auto& entry : m_layers) {
|
||||||
|
for (auto it = entry.imageLayers.begin(); it != entry.imageLayers.end(); ++it) {
|
||||||
|
if (it->imageLayer.get() == imageLayer) {
|
||||||
|
emit imageLayerAboutToBeRemoved(imageLayer);
|
||||||
|
if (it->widget) {
|
||||||
|
//delete it->widget;//在调用此函数的地方已经删除了widget了,这里不需要再删除一次了
|
||||||
|
}
|
||||||
|
entry.imageLayers.erase(it);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapLayerStore::removeLayerByName(const QString& name)
|
void MapLayerStore::removeLayerByName(const QString& name)
|
||||||
{
|
{
|
||||||
for (auto it = m_layers.begin(); it != m_layers.end(); ++it) {
|
for (auto& entry : m_layers) {
|
||||||
if ((*it)->name() == name) {
|
if (entry.mapLayer->name() == name) {
|
||||||
MapLayer* raw = it->get();
|
removeLayer(entry.mapLayer.get());
|
||||||
emit layerAboutToBeRemoved(raw);
|
|
||||||
m_layers.erase(it);
|
|
||||||
m_layerWidgets.erase(raw);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool MapLayerStore::containsLayer(const QString& url, bool isAbsolutePath) const
|
||||||
|
{
|
||||||
|
QFileInfo fi(url);
|
||||||
|
QString fileName = fi.completeBaseName();
|
||||||
|
|
||||||
|
if (!isAbsolutePath) {
|
||||||
|
return getLayer(fileName) != nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const auto& entry : m_layers) {
|
||||||
|
if (entry.mapLayer->dataPath() == url)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
MapLayer* MapLayerStore::getLayer(const QString& name) const
|
MapLayer* MapLayerStore::getLayer(const QString& name) const
|
||||||
{
|
{
|
||||||
for (const auto& l : m_layers) {
|
for (const auto& entry : m_layers) {
|
||||||
if (l->name() == name) return l.get();
|
if (entry.mapLayer->name() == name)
|
||||||
|
return entry.mapLayer.get();
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
MapLayer* MapLayerStore::getLayerAt(int index) const
|
MapLayer* MapLayerStore::getLayerAt(int index) const
|
||||||
{
|
{
|
||||||
if (index < 0 || index >= (int)m_layers.size()) return nullptr;
|
if (index < 0 || index >= (int)m_layers.size())
|
||||||
return m_layers[index].get();
|
return nullptr;
|
||||||
|
return m_layers[index].mapLayer.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
MapLayer* MapLayerStore::getLayerByAbsolutePath(const QString& absolutePath) const
|
||||||
|
{
|
||||||
|
for (const auto& entry : m_layers) {
|
||||||
|
if (entry.mapLayer->dataPath() == absolutePath)
|
||||||
|
return entry.mapLayer.get();
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
int MapLayerStore::layerCount() const
|
int MapLayerStore::layerCount() const
|
||||||
@ -62,31 +139,129 @@ int MapLayerStore::layerCount() const
|
|||||||
return (int)m_layers.size();
|
return (int)m_layers.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget* MapLayerStore::widgetForLayer(MapLayer* layer) const
|
RasterImageLayer* MapLayerStore::getImageLayer(MapLayer* mapLayer, int index) const
|
||||||
{
|
{
|
||||||
auto it = m_layerWidgets.find(layer);
|
const LayerEntry* entry = findLayerEntry(mapLayer);
|
||||||
if (it == m_layerWidgets.end()) return nullptr;
|
if (!entry) return nullptr;
|
||||||
return it->second;
|
|
||||||
|
if (index < 0 || index >= (int)entry->imageLayers.size())
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
return entry->imageLayers[index].imageLayer.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
int MapLayerStore::imageLayerCount(MapLayer* mapLayer) const
|
||||||
|
{
|
||||||
|
const LayerEntry* entry = findLayerEntry(mapLayer);
|
||||||
|
if (!entry) return 0;
|
||||||
|
return (int)entry->imageLayers.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<RasterImageLayer*> MapLayerStore::getAllImageLayers() const
|
||||||
|
{
|
||||||
|
std::vector<RasterImageLayer*> result;
|
||||||
|
for (const auto& entry : m_layers) {
|
||||||
|
for (const auto& imgEntry : entry.imageLayers) {
|
||||||
|
if (imgEntry.imageLayer)
|
||||||
|
result.push_back(imgEntry.imageLayer.get());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
QWidget* MapLayerStore::widgetForImageLayer(RasterImageLayer* imageLayer) const
|
||||||
|
{
|
||||||
|
for (const auto& entry : m_layers) {
|
||||||
|
for (const auto& imgEntry : entry.imageLayers) {
|
||||||
|
if (imgEntry.imageLayer.get() == imageLayer)
|
||||||
|
return imgEntry.widget;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
QWidget* MapLayerStore::widgetForLayer(MapLayer* layer) const//需要修改??????????????????????????????????????????????
|
||||||
|
{
|
||||||
|
const LayerEntry* entry = findLayerEntry(layer);
|
||||||
|
if (!entry || entry->imageLayers.empty())
|
||||||
|
return nullptr;
|
||||||
|
return entry->imageLayers.front().widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget* MapLayerStore::widgetForLayer(const QString& absolutePath) const
|
QWidget* MapLayerStore::widgetForLayer(const QString& absolutePath) const
|
||||||
{
|
{
|
||||||
for (const auto& sp : m_layers) {
|
for (const auto& entry : m_layers) {
|
||||||
if (sp && sp->dataPath() == absolutePath) {
|
if (entry.mapLayer->dataPath() == absolutePath) {
|
||||||
MapLayer* raw = sp.get();
|
if (!entry.imageLayers.empty())
|
||||||
auto it = m_layerWidgets.find(raw);
|
return entry.imageLayers.front().widget;
|
||||||
if (it != m_layerWidgets.end()) return it->second;
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
MapLayer* MapLayerStore::layerForWidget(QWidget* widget) const
|
std::vector<QWidget*> MapLayerStore::widgetsForMapLayer(MapLayer* mapLayer) const
|
||||||
{
|
{
|
||||||
if (!widget) return nullptr;
|
std::vector<QWidget*> result;
|
||||||
for (const auto& kv : m_layerWidgets) {
|
const LayerEntry* entry = findLayerEntry(mapLayer);
|
||||||
if (kv.second == widget) return kv.first;
|
if (!entry) return result;
|
||||||
|
|
||||||
|
for (const auto& imgEntry : entry->imageLayers) {
|
||||||
|
if (imgEntry.widget)
|
||||||
|
result.push_back(imgEntry.widget);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
MapLayer* MapLayerStore::mapLayerForImageLayer(RasterImageLayer* imageLayer) const
|
||||||
|
{
|
||||||
|
for (const auto& entry : m_layers) {
|
||||||
|
for (const auto& imgEntry : entry.imageLayers) {
|
||||||
|
if (imgEntry.imageLayer.get() == imageLayer)
|
||||||
|
return entry.mapLayer.get();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MapLayer* MapLayerStore::mapLayerForWidget(QWidget* widget) const
|
||||||
|
{
|
||||||
|
if (!widget) return nullptr;
|
||||||
|
for (const auto& entry : m_layers) {
|
||||||
|
for (const auto& imgEntry : entry.imageLayers) {
|
||||||
|
if (imgEntry.widget == widget)
|
||||||
|
return entry.mapLayer.get();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
RasterImageLayer* MapLayerStore::imageLayerForWidget(QWidget* widget) const
|
||||||
|
{
|
||||||
|
if (!widget) return nullptr;
|
||||||
|
for (const auto& entry : m_layers) {
|
||||||
|
for (const auto& imgEntry : entry.imageLayers) {
|
||||||
|
if (imgEntry.widget == widget)
|
||||||
|
return imgEntry.imageLayer.get();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
MapLayerStore::LayerEntry* MapLayerStore::findLayerEntry(MapLayer* mapLayer)
|
||||||
|
{
|
||||||
|
auto it = m_mapLayerIndex.find(mapLayer);
|
||||||
|
if (it == m_mapLayerIndex.end()) return nullptr;
|
||||||
|
int index = it->second;
|
||||||
|
if (index < 0 || index >= (int)m_layers.size()) return nullptr;
|
||||||
|
return &m_layers[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
const MapLayerStore::LayerEntry* MapLayerStore::findLayerEntry(MapLayer* mapLayer) const
|
||||||
|
{
|
||||||
|
auto it = m_mapLayerIndex.find(mapLayer);
|
||||||
|
if (it == m_mapLayerIndex.end()) return nullptr;
|
||||||
|
int index = it->second;
|
||||||
|
if (index < 0 || index >= (int)m_layers.size()) return nullptr;
|
||||||
|
return &m_layers[index];
|
||||||
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
@ -7,45 +7,66 @@
|
|||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
class MapLayer;
|
class MapLayer;
|
||||||
|
class RasterImageLayer;
|
||||||
class QWidget;
|
class QWidget;
|
||||||
|
|
||||||
class MapLayerStore : public QObject
|
class MapLayerStore : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
struct ImageLayerEntry {
|
||||||
|
std::unique_ptr<RasterImageLayer> imageLayer;
|
||||||
|
QWidget* widget;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct LayerEntry {
|
||||||
|
std::unique_ptr<MapLayer> mapLayer;
|
||||||
|
std::vector<ImageLayerEntry> imageLayers;
|
||||||
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit MapLayerStore(QObject* parent = nullptr);
|
explicit MapLayerStore(QObject* parent = nullptr);
|
||||||
~MapLayerStore() override = default;
|
~MapLayerStore() override = default;
|
||||||
|
|
||||||
// Take ownership of the layer (store will own and manage its lifetime)
|
// Layer management
|
||||||
// Now also accept the associated QWidget so UI widget can be retrieved by layer pointer
|
void addLayer(MapLayer* layer);
|
||||||
void addLayer(MapLayer* layer, QWidget* widget = nullptr);
|
|
||||||
|
|
||||||
// Remove by pointer or by name. Destruction happens when removed from store.
|
|
||||||
public slots:
|
|
||||||
void removeLayer(MapLayer* layer);
|
void removeLayer(MapLayer* layer);
|
||||||
void removeLayerByName(const QString& name);
|
void removeLayerByName(const QString& name);
|
||||||
|
bool containsLayer(const QString& url, bool isAbsolutePath = true) const;
|
||||||
|
|
||||||
// Queries
|
|
||||||
MapLayer* getLayer(const QString& name) const;
|
MapLayer* getLayer(const QString& name) const;
|
||||||
|
MapLayer* getLayerByAbsolutePath(const QString& absolutePath) const;
|
||||||
MapLayer* getLayerAt(int index) const;
|
MapLayer* getLayerAt(int index) const;
|
||||||
int layerCount() const;
|
int layerCount() const;
|
||||||
|
|
||||||
// Get associated widget for a layer (or nullptr if none)
|
// ImageLayer management
|
||||||
QWidget* widgetForLayer(MapLayer* layer) const;
|
void addImageLayer(MapLayer* mapLayer, RasterImageLayer* imageLayer, QWidget* widget);
|
||||||
// Get associated widget by layer absolute data path
|
void removeImageLayer(RasterImageLayer* imageLayer);
|
||||||
QWidget* widgetForLayer(const QString& absolutePath) const;
|
RasterImageLayer* getImageLayer(MapLayer* mapLayer, int index) const;
|
||||||
|
int imageLayerCount(MapLayer* mapLayer) const;
|
||||||
|
std::vector<RasterImageLayer*> getAllImageLayers() const;
|
||||||
|
|
||||||
// Reverse lookup: find the MapLayer associated with a given widget (or nullptr)
|
// Widget queries
|
||||||
MapLayer* layerForWidget(QWidget* widget) const;
|
QWidget* widgetForImageLayer(RasterImageLayer* imageLayer) const;
|
||||||
|
QWidget* widgetForLayer(MapLayer* layer) const;
|
||||||
|
QWidget* widgetForLayer(const QString& absolutePath) const;
|
||||||
|
std::vector<QWidget*> widgetsForMapLayer(MapLayer* mapLayer) const;
|
||||||
|
|
||||||
|
// Reverse lookups
|
||||||
|
MapLayer* mapLayerForImageLayer(RasterImageLayer* imageLayer) const;
|
||||||
|
MapLayer* mapLayerForWidget(QWidget* widget) const;
|
||||||
|
RasterImageLayer* imageLayerForWidget(QWidget* widget) const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void layerAdded(MapLayer* layer);
|
void layerAdded(MapLayer* layer);
|
||||||
// Emitted just before the layer is destroyed/removed from store
|
|
||||||
void layerAboutToBeRemoved(MapLayer* layer);
|
void layerAboutToBeRemoved(MapLayer* layer);
|
||||||
|
void imageLayerAdded(RasterImageLayer* imageLayer);
|
||||||
|
void imageLayerAboutToBeRemoved(RasterImageLayer* imageLayer);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// store shared ownership so other parts can keep raw pointers safely (or use QPointer)
|
LayerEntry* findLayerEntry(MapLayer* mapLayer);
|
||||||
std::vector<std::shared_ptr<MapLayer>> m_layers;
|
const LayerEntry* findLayerEntry(MapLayer* mapLayer) const;
|
||||||
// mapping from raw MapLayer pointer to associated QWidget*
|
|
||||||
std::unordered_map<MapLayer*, QWidget*> m_layerWidgets;
|
std::vector<LayerEntry> m_layers;
|
||||||
|
std::unordered_map<MapLayer*, int> m_mapLayerIndex;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -41,10 +41,10 @@ void MapToolSpectral::canvasMousePressEvent(QMouseEvent* e)
|
|||||||
const int x = static_cast<int>(std::floor(scenePt.x()));
|
const int x = static_cast<int>(std::floor(scenePt.x()));
|
||||||
const int y = static_cast<int>(std::floor(scenePt.y()));
|
const int y = static_cast<int>(std::floor(scenePt.y()));
|
||||||
|
|
||||||
RasterLayer* rl = canvas()->rasterLayer();
|
auto* imageLayer = canvas()->imageLayer();
|
||||||
|
RasterLayer* rl = imageLayer ? imageLayer->layer() : nullptr;
|
||||||
if (rl && rl->isValidPixel(x, y))
|
if (rl && rl->isValidPixel(x, y))
|
||||||
{
|
{
|
||||||
// Place crosshair at pixel center
|
|
||||||
canvas()->updateCrosshair(x + 0.5, y + 0.5);
|
canvas()->updateCrosshair(x + 0.5, y + 0.5);
|
||||||
|
|
||||||
QVector<double> wavelengths;
|
QVector<double> wavelengths;
|
||||||
|
|||||||
@ -4,6 +4,8 @@
|
|||||||
#include "MapTool.h"
|
#include "MapTool.h"
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
|
|
||||||
|
#include "RasterImageLayer.h"
|
||||||
|
|
||||||
class QGraphicsLineItem;
|
class QGraphicsLineItem;
|
||||||
|
|
||||||
class MapToolSpectral : public MapTool
|
class MapToolSpectral : public MapTool
|
||||||
|
|||||||
11
HPPA/MotorWindowBase.cpp
Normal file
11
HPPA/MotorWindowBase.cpp
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#include "MotorWindowBase.h"
|
||||||
|
|
||||||
|
MotorWindowBase::MotorWindowBase()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
MotorWindowBase::~MotorWindowBase()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
15
HPPA/MotorWindowBase.h
Normal file
15
HPPA/MotorWindowBase.h
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
class MotorWindowBase
|
||||||
|
{
|
||||||
|
|
||||||
|
public:
|
||||||
|
MotorWindowBase();
|
||||||
|
~MotorWindowBase();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual bool getMotorsConnectionStatus()=0;
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
};
|
||||||
@ -1,30 +1,32 @@
|
|||||||
#include "RasterRenderer.h"
|
#include "MultibandRasterRenderer.h"
|
||||||
#include "RasterDataProvider.h"
|
#include "RasterDataProvider.h"
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
RasterRenderer::RasterRenderer(RasterDataProvider* provider)
|
MultibandRasterRenderer::MultibandRasterRenderer(RasterDataProvider* provider)
|
||||||
: m_provider(provider)
|
: RasterRendererBase(provider)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void RasterRenderer::stretchTo8bit(const std::vector<float>& in, std::vector<unsigned char>& out, float minVal, float maxVal)
|
void MultibandRasterRenderer::stretchTo8bit(const std::vector<float>& in, std::vector<unsigned char>& out, float minVal, float maxVal)
|
||||||
{
|
{
|
||||||
size_t n = in.size();
|
size_t n = in.size();
|
||||||
out.resize(n);
|
out.resize(n);
|
||||||
if (maxVal <= minVal) {
|
if (maxVal <= minVal)
|
||||||
|
{
|
||||||
std::fill(out.begin(), out.end(), 0);
|
std::fill(out.begin(), out.end(), 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
float denom = 1.0f / (maxVal - minVal);
|
float denom = 1.0f / (maxVal - minVal);
|
||||||
for (size_t i = 0; i < n; ++i) {
|
for (size_t i = 0; i < n; ++i)
|
||||||
|
{
|
||||||
float v = (in[i] - minVal) * denom;
|
float v = (in[i] - minVal) * denom;
|
||||||
v = std::min(std::max(v, 0.0f), 1.0f);
|
v = std::min(std::max(v, 0.0f), 1.0f);
|
||||||
out[i] = static_cast<unsigned char>(v * 255.0f);
|
out[i] = static_cast<unsigned char>(v * 255.0f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QImage RasterRenderer::render(const Params& params)
|
QImage MultibandRasterRenderer::render()
|
||||||
{
|
{
|
||||||
if (!m_provider) return QImage();
|
if (!m_provider) return QImage();
|
||||||
int bands = m_provider->bandCount();
|
int bands = m_provider->bandCount();
|
||||||
@ -38,7 +40,7 @@ QImage RasterRenderer::render(const Params& params)
|
|||||||
auto chooseBandIndexForWave = [&](double wave)->int {
|
auto chooseBandIndexForWave = [&](double wave)->int {
|
||||||
if (wavelengths.empty()) {
|
if (wavelengths.empty()) {
|
||||||
// fallback: select R,G,B as first three bands
|
// fallback: select R,G,B as first three bands
|
||||||
if (bands >= 3) return (wave==params.rWave?0:(wave==params.gWave?1:2));
|
if (bands >= 3) return (wave==m_params.rWave?0:(wave==m_params.gWave?1:2));
|
||||||
if (bands >= 1) return 0;
|
if (bands >= 1) return 0;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -53,9 +55,9 @@ QImage RasterRenderer::render(const Params& params)
|
|||||||
return std::min(2, bands-1);
|
return std::min(2, bands-1);
|
||||||
};
|
};
|
||||||
|
|
||||||
int rIdx = chooseBandIndexForWave(params.rWave);
|
int rIdx = chooseBandIndexForWave(m_params.rWave);
|
||||||
int gIdx = chooseBandIndexForWave(params.gWave);
|
int gIdx = chooseBandIndexForWave(m_params.gWave);
|
||||||
int bIdx = chooseBandIndexForWave(params.bWave);
|
int bIdx = chooseBandIndexForWave(m_params.bWave);
|
||||||
|
|
||||||
std::vector<float> rbuf, gbuf, bbuf;
|
std::vector<float> rbuf, gbuf, bbuf;
|
||||||
if (rIdx >= 0) m_provider->readBandAsFloat(rIdx, rbuf);
|
if (rIdx >= 0) m_provider->readBandAsFloat(rIdx, rbuf);
|
||||||
@ -63,8 +65,8 @@ QImage RasterRenderer::render(const Params& params)
|
|||||||
if (bIdx >= 0) m_provider->readBandAsFloat(bIdx, bbuf);
|
if (bIdx >= 0) m_provider->readBandAsFloat(bIdx, bbuf);
|
||||||
|
|
||||||
std::vector<unsigned char> r8, g8, b8;
|
std::vector<unsigned char> r8, g8, b8;
|
||||||
float minV = static_cast<float>(params.minValue);
|
float minV = static_cast<float>(m_params.minValue);
|
||||||
float maxV = static_cast<float>(params.maxValue);
|
float maxV = static_cast<float>(m_params.maxValue);
|
||||||
if (!rbuf.empty()) stretchTo8bit(rbuf, r8, minV, maxV);
|
if (!rbuf.empty()) stretchTo8bit(rbuf, r8, minV, maxV);
|
||||||
if (!gbuf.empty()) stretchTo8bit(gbuf, g8, minV, maxV);
|
if (!gbuf.empty()) stretchTo8bit(gbuf, g8, minV, maxV);
|
||||||
if (!bbuf.empty()) stretchTo8bit(bbuf, b8, minV, maxV);
|
if (!bbuf.empty()) stretchTo8bit(bbuf, b8, minV, maxV);
|
||||||
26
HPPA/MultibandRasterRenderer.h
Normal file
26
HPPA/MultibandRasterRenderer.h
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "RasterRendererBase.h"
|
||||||
|
#include "RasterRenderParams.h"
|
||||||
|
#include <vector>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
class RasterDataProvider;
|
||||||
|
|
||||||
|
class MultibandRasterRenderer : public RasterRendererBase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit MultibandRasterRenderer(RasterDataProvider* provider);
|
||||||
|
|
||||||
|
QImage render() override;
|
||||||
|
|
||||||
|
// Parameter access
|
||||||
|
MultibandRenderParams params() const { return m_params; }
|
||||||
|
void setParams(const MultibandRenderParams& params) { m_params = params; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
MultibandRenderParams m_params;
|
||||||
|
|
||||||
|
// Helper to map float buffer to 8-bit with min/max stretch
|
||||||
|
static void stretchTo8bit(const std::vector<float>& in, std::vector<unsigned char>& out, float minVal, float maxVal);
|
||||||
|
};
|
||||||
@ -1,4 +1,4 @@
|
|||||||
#include "OneMotorControl.h"
|
#include "OneMotorControl.h"
|
||||||
|
|
||||||
OneMotorControl::OneMotorControl(QWidget* parent) : QDialog(parent)
|
OneMotorControl::OneMotorControl(QWidget* parent) : QDialog(parent)
|
||||||
{
|
{
|
||||||
@ -6,6 +6,16 @@ OneMotorControl::OneMotorControl(QWidget* parent) : QDialog(parent)
|
|||||||
|
|
||||||
connect(this->ui.connect_btn, SIGNAL(pressed()), this, SLOT(onConnectMotor()));
|
connect(this->ui.connect_btn, SIGNAL(pressed()), this, SLOT(onConnectMotor()));
|
||||||
|
|
||||||
|
connect(this->ui.right_btn, SIGNAL(pressed()), this, SLOT(onxMotorRight()));
|
||||||
|
connect(this->ui.right_btn, SIGNAL(released()), this, SLOT(onxMotorStop()));
|
||||||
|
connect(this->ui.left_btn, SIGNAL(pressed()), this, SLOT(onxMotorLeft()));
|
||||||
|
connect(this->ui.left_btn, SIGNAL(released()), this, SLOT(onxMotorStop()));
|
||||||
|
|
||||||
|
connect(this->ui.move2loc_pushButton, SIGNAL(pressed()), this, SLOT(onxMove2Loc()));
|
||||||
|
|
||||||
|
connect(this->ui.zero_start_btn, SIGNAL(released()), this, SLOT(zeroStart()));
|
||||||
|
|
||||||
|
connect(this->ui.rangeMeasurement_btn, SIGNAL(pressed()), this, SLOT(onx_rangeMeasurement()));
|
||||||
}
|
}
|
||||||
|
|
||||||
OneMotorControl::~OneMotorControl()
|
OneMotorControl::~OneMotorControl()
|
||||||
@ -16,6 +26,31 @@ OneMotorControl::~OneMotorControl()
|
|||||||
|
|
||||||
void OneMotorControl::onConnectMotor()
|
void OneMotorControl::onConnectMotor()
|
||||||
{
|
{
|
||||||
|
if (getMotorsConnectionStatus())
|
||||||
|
{
|
||||||
|
QMessageBox msgBox;
|
||||||
|
msgBox.setText(QString::fromLocal8Bit("马达已连接!"));
|
||||||
|
msgBox.exec();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_multiAxisController != nullptr)
|
||||||
|
{
|
||||||
|
disconnect(m_multiAxisController, SIGNAL(broadcastLocationSignal(std::vector<double>)), this, SLOT(display_x_loc(std::vector<double>)));
|
||||||
|
disconnect(this, SIGNAL(moveSignal(int, bool, double, int)), m_multiAxisController, SLOT(move(int, bool, double, int)));
|
||||||
|
disconnect(this, SIGNAL(move2LocSignal(int, double, double, int)), m_multiAxisController, SLOT(moveTo(int, double, double, int)));
|
||||||
|
disconnect(this, SIGNAL(stopSignal(int)), m_multiAxisController, SLOT(stop(int)));
|
||||||
|
disconnect(this, SIGNAL(zeroStartSignal(int)), m_multiAxisController, SLOT(zeroStart(int)));
|
||||||
|
disconnect(this, SIGNAL(rangeMeasurement(int, double, int)), m_multiAxisController, SLOT(rangeMeasurement(int, double, int)));
|
||||||
|
disconnect(this, SIGNAL(testConnectivitySignal(int, int)), m_multiAxisController, SLOT(testConnectivity(int, int)));
|
||||||
|
disconnect(m_multiAxisController, SIGNAL(broadcastConnectivity(std::vector<int>)), this, SLOT(display_motors_connectivity(std::vector<int>)));
|
||||||
|
|
||||||
|
m_motorThread.quit();
|
||||||
|
m_motorThread.wait();
|
||||||
|
m_multiAxisController = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
FileOperation* fileOperation = new FileOperation();
|
FileOperation* fileOperation = new FileOperation();
|
||||||
@ -27,35 +62,27 @@ void OneMotorControl::onConnectMotor()
|
|||||||
catch (std::exception const& e)
|
catch (std::exception const& e)
|
||||||
{
|
{
|
||||||
QMessageBox msgBox;
|
QMessageBox msgBox;
|
||||||
msgBox.setText(QString::fromLocal8Bit("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"));
|
msgBox.setText(QString::fromLocal8Bit("请连接马达!"));
|
||||||
msgBox.exec();
|
msgBox.exec();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_multiAxisController->moveToThread(&m_motorThread);
|
m_multiAxisController->moveToThread(&m_motorThread);
|
||||||
connect(&m_motorThread, SIGNAL(finished()), m_multiAxisController, SLOT(deleteLater()));
|
connect(&m_motorThread, SIGNAL(finished()), m_multiAxisController, SLOT(deleteLater()));
|
||||||
|
|
||||||
connect(this->ui.right_btn, SIGNAL(pressed()), this, SLOT(onxMotorRight()));
|
|
||||||
connect(this->ui.right_btn, SIGNAL(released()), this, SLOT(onxMotorStop()));
|
|
||||||
connect(this->ui.left_btn, SIGNAL(pressed()), this, SLOT(onxMotorLeft()));
|
|
||||||
connect(this->ui.left_btn, SIGNAL(released()), this, SLOT(onxMotorStop()));
|
|
||||||
|
|
||||||
connect(this->ui.move2loc_pushButton, SIGNAL(pressed()), this, SLOT(onxMove2Loc()));
|
|
||||||
|
|
||||||
connect(m_multiAxisController, SIGNAL(broadcastLocationSignal(std::vector<double>)), this, SLOT(display_x_loc(std::vector<double>)));
|
connect(m_multiAxisController, SIGNAL(broadcastLocationSignal(std::vector<double>)), this, SLOT(display_x_loc(std::vector<double>)));
|
||||||
|
|
||||||
connect(this, SIGNAL(moveSignal(int, bool, double, int)), m_multiAxisController, SLOT(move(int, bool, double, int)));
|
connect(this, SIGNAL(moveSignal(int, bool, double, int)), m_multiAxisController, SLOT(move(int, bool, double, int)));
|
||||||
connect(this, SIGNAL(move2LocSignal(int, double, double, int)), m_multiAxisController, SLOT(moveTo(int, double, double, int)));
|
connect(this, SIGNAL(move2LocSignal(int, double, double, int)), m_multiAxisController, SLOT(moveTo(int, double, double, int)));
|
||||||
connect(this, SIGNAL(stopSignal(int)), m_multiAxisController, SLOT(stop(int)));
|
connect(this, SIGNAL(stopSignal(int)), m_multiAxisController, SLOT(stop(int)));
|
||||||
|
|
||||||
connect(this->ui.zero_start_btn, SIGNAL(released()), this, SLOT(zeroStart()));
|
|
||||||
connect(this, SIGNAL(zeroStartSignal(int)), m_multiAxisController, SLOT(zeroStart(int)));
|
connect(this, SIGNAL(zeroStartSignal(int)), m_multiAxisController, SLOT(zeroStart(int)));
|
||||||
|
|
||||||
connect(this->ui.rangeMeasurement_btn, SIGNAL(pressed()), this, SLOT(onx_rangeMeasurement()));
|
|
||||||
connect(this, SIGNAL(rangeMeasurement(int, double, int)), m_multiAxisController, SLOT(rangeMeasurement(int, double, int)));
|
connect(this, SIGNAL(rangeMeasurement(int, double, int)), m_multiAxisController, SLOT(rangeMeasurement(int, double, int)));
|
||||||
|
|
||||||
connect(this, SIGNAL(testConnectivitySignal(int, int)), m_multiAxisController, SLOT(testConnectivity(int, int)));
|
connect(this, SIGNAL(testConnectivitySignal(int, int)), m_multiAxisController, SLOT(testConnectivity(int, int)));
|
||||||
connect(m_multiAxisController, SIGNAL(broadcastConnectivity(std::vector<int>)), this, SLOT(display_motors_connectivity(std::vector<int>)));
|
connect(m_multiAxisController, SIGNAL(broadcastConnectivity(std::vector<int>)), this, SLOT(display_motors_connectivity(std::vector<int>)));
|
||||||
|
|
||||||
m_motorThread.start();
|
m_motorThread.start();
|
||||||
emit testConnectivitySignal(0, 1000);
|
emit testConnectivitySignal(0, 1000);
|
||||||
}
|
}
|
||||||
@ -73,11 +100,36 @@ void OneMotorControl::display_motors_connectivity(std::vector<int> connectivity)
|
|||||||
//std::cout << "-----------------------------------"<<connectivity.size()<< std::endl;
|
//std::cout << "-----------------------------------"<<connectivity.size()<< std::endl;
|
||||||
if (connectivity[0])
|
if (connectivity[0])
|
||||||
{
|
{
|
||||||
this->ui.motor_state_label->setStyleSheet("QLabel{background-color:rgb(0,255,0);}");
|
m_xMotorConnectionStatus = true;
|
||||||
|
|
||||||
|
this->ui.motor_state_label->setStyleSheet(R"(
|
||||||
|
QLabel
|
||||||
|
{
|
||||||
|
background-color: #08FACE;
|
||||||
|
border-radius: 4px;
|
||||||
|
}
|
||||||
|
)");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this->ui.motor_state_label->setStyleSheet("QLabel{background-color:rgb(255,0,0);}");
|
m_xMotorConnectionStatus = false;
|
||||||
|
|
||||||
|
this->ui.motor_state_label->setStyleSheet(R"(
|
||||||
|
QLabel
|
||||||
|
{
|
||||||
|
background-color: red;
|
||||||
|
border-radius: 4px;
|
||||||
|
}
|
||||||
|
)");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getMotorsConnectionStatus())
|
||||||
|
{
|
||||||
|
this->ui.connect_btn->setText(QString::fromLocal8Bit("已连接"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this->ui.connect_btn->setText(QString::fromLocal8Bit("重新连接"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -150,15 +202,12 @@ void OneMotorControl::record_white()
|
|||||||
|
|
||||||
void OneMotorControl::run()
|
void OneMotorControl::run()
|
||||||
{
|
{
|
||||||
if (m_coordinator == nullptr)
|
qRegisterMetaType<OneMotionCapturePathLine>("OneMotionCapturePathLine");
|
||||||
{
|
m_coordinator = new OneMotionCaptureCoordinator(m_multiAxisController, m_Imager);
|
||||||
qRegisterMetaType<OneMotionCapturePathLine>("OneMotionCapturePathLine");
|
connect(this, SIGNAL(start(OneMotionCapturePathLine)), m_coordinator, SLOT(startStepMotion(OneMotionCapturePathLine)));
|
||||||
m_coordinator = new OneMotionCaptureCoordinator(m_multiAxisController, m_Imager);
|
connect(this, SIGNAL(stopStepMotionSignal()), m_coordinator, SLOT(stopStepMotion()));
|
||||||
connect(this, SIGNAL(start(OneMotionCapturePathLine)), m_coordinator, SLOT(startStepMotion(OneMotionCapturePathLine)));
|
|
||||||
connect(this, SIGNAL(stopStepMotionSignal()), m_coordinator, SLOT(stopStepMotion()));
|
|
||||||
|
|
||||||
connect(m_coordinator, SIGNAL(sequenceComplete(int)), this, SLOT(onSequenceComplete()));
|
connect(m_coordinator, SIGNAL(sequenceComplete(int)), this, SLOT(onSequenceComplete(int)));
|
||||||
}
|
|
||||||
|
|
||||||
OneMotionCapturePathLine tmp;
|
OneMotionCapturePathLine tmp;
|
||||||
tmp.speedRecord = ui.speed_lineEdit->text().toDouble();
|
tmp.speedRecord = ui.speed_lineEdit->text().toDouble();
|
||||||
@ -172,7 +221,22 @@ void OneMotorControl::stop()
|
|||||||
emit stopStepMotionSignal();
|
emit stopStepMotionSignal();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OneMotorControl::onSequenceComplete()
|
void OneMotorControl::onSequenceComplete(int state)
|
||||||
{
|
{
|
||||||
emit sequenceComplete();
|
emit sequenceComplete();
|
||||||
|
|
||||||
|
disconnect(this, SIGNAL(start(OneMotionCapturePathLine)), m_coordinator, SLOT(startStepMotion(OneMotionCapturePathLine)));
|
||||||
|
disconnect(this, SIGNAL(stopStepMotionSignal()), m_coordinator, SLOT(stopStepMotion()));
|
||||||
|
disconnect(m_coordinator, SIGNAL(sequenceComplete(int)), this, SLOT(onSequenceComplete(int)));
|
||||||
|
|
||||||
|
// Use deleteLater() instead of delete: this slot may have been called directly
|
||||||
|
// from OneMotionCaptureCoordinator's call stack (direct connection), so deleting
|
||||||
|
// the object here would cause a crash when execution returns to the destroyed object.
|
||||||
|
m_coordinator->deleteLater();
|
||||||
|
m_coordinator = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool OneMotorControl::getMotorsConnectionStatus()
|
||||||
|
{
|
||||||
|
return m_xMotorConnectionStatus;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
|
||||||
@ -7,8 +7,9 @@
|
|||||||
#include "IrisMultiMotorController.h"
|
#include "IrisMultiMotorController.h"
|
||||||
#include "fileOperation.h"
|
#include "fileOperation.h"
|
||||||
#include "CaptureCoordinator.h"
|
#include "CaptureCoordinator.h"
|
||||||
|
#include "MotorWindowBase.h"
|
||||||
|
|
||||||
class OneMotorControl : public QDialog
|
class OneMotorControl : public QDialog, public MotorWindowBase
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@ -24,6 +25,7 @@ public:
|
|||||||
void record_dark();
|
void record_dark();
|
||||||
void record_white();
|
void record_white();
|
||||||
|
|
||||||
|
bool getMotorsConnectionStatus();
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void onConnectMotor();
|
void onConnectMotor();
|
||||||
@ -38,7 +40,7 @@ public Q_SLOTS:
|
|||||||
void onxMotorLeft();
|
void onxMotorLeft();
|
||||||
void onxMotorStop();
|
void onxMotorStop();
|
||||||
|
|
||||||
void onSequenceComplete();
|
void onSequenceComplete(int state);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void moveSignal(int, bool, double, int);
|
void moveSignal(int, bool, double, int);
|
||||||
@ -61,11 +63,13 @@ private:
|
|||||||
Ui::OneMotorControl_UI ui;
|
Ui::OneMotorControl_UI ui;
|
||||||
|
|
||||||
QThread m_motorThread;
|
QThread m_motorThread;
|
||||||
IrisMultiMotorController* m_multiAxisController;
|
IrisMultiMotorController* m_multiAxisController = nullptr;
|
||||||
|
|
||||||
OneMotionCaptureCoordinator* m_coordinator = nullptr;
|
OneMotionCaptureCoordinator* m_coordinator = nullptr;
|
||||||
ImagerOperationBase* m_Imager;
|
ImagerOperationBase* m_Imager;
|
||||||
|
|
||||||
DarkAndWhiteCaptureCoordinator* m_darkCaptureCoordinator = nullptr;
|
DarkAndWhiteCaptureCoordinator* m_darkCaptureCoordinator = nullptr;
|
||||||
DarkAndWhiteCaptureCoordinator* m_whiteCaptureCoordinator = nullptr;
|
DarkAndWhiteCaptureCoordinator* m_whiteCaptureCoordinator = nullptr;
|
||||||
|
|
||||||
|
bool m_xMotorConnectionStatus = false;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
#include "PowerControl.h"
|
#include "PowerControl.h"
|
||||||
|
|
||||||
PowerControl::PowerControl(QWidget *parent)
|
PowerControl::PowerControl(QWidget *parent)
|
||||||
: QDialog(parent)
|
: QDialog(parent)
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <QNetworkRequest>
|
#include <QNetworkRequest>
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "qDoubleSlider.h"
|
#include "qDoubleSlider.h"
|
||||||
QDoubleSlider::QDoubleSlider(QWidget* pParent /*= NULL*/) :
|
QDoubleSlider::QDoubleSlider(QWidget* pParent /*= NULL*/) :
|
||||||
QSlider(pParent),
|
QSlider(pParent),
|
||||||
@ -6,20 +6,21 @@ m_Multiplier(100.0)
|
|||||||
{
|
{
|
||||||
connect(this, SIGNAL(valueChanged(int)), this, SLOT(notifyValueChanged(int)));
|
connect(this, SIGNAL(valueChanged(int)), this, SLOT(notifyValueChanged(int)));
|
||||||
|
|
||||||
setSingleStep(1);
|
setSingleStep(0);
|
||||||
|
setPageStep(0);
|
||||||
setRange(1, 500);
|
setRange(1, 500);
|
||||||
|
|
||||||
setOrientation(Qt::Horizontal);
|
setOrientation(Qt::Horizontal);
|
||||||
setFocusPolicy(Qt::NoFocus);
|
setFocusPolicy(Qt::NoFocus);
|
||||||
}
|
}
|
||||||
|
|
||||||
//<EFBFBD><EFBFBD><EFBFBD>ⷢ<EFBFBD><EFBFBD>
|
//向外发射
|
||||||
void QDoubleSlider::notifyValueChanged(int Value)
|
void QDoubleSlider::notifyValueChanged(int Value)
|
||||||
{
|
{
|
||||||
emit valueChanged((double)Value / m_Multiplier);
|
emit valueChanged((double)Value / m_Multiplier);
|
||||||
}
|
}
|
||||||
|
|
||||||
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
//接收外边
|
||||||
void QDoubleSlider::setValue(double Value, bool BlockSignals)
|
void QDoubleSlider::setValue(double Value, bool BlockSignals)
|
||||||
{
|
{
|
||||||
QSlider::blockSignals(BlockSignals);
|
QSlider::blockSignals(BlockSignals);
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
#ifndef Q_DOUBLE_SLIDER_H
|
#ifndef Q_DOUBLE_SLIDER_H
|
||||||
#define Q_DOUBLE_SLIDER_H
|
#define Q_DOUBLE_SLIDER_H
|
||||||
#include <QtGui/QtGui>
|
#include <QtGui/QtGui>
|
||||||
#include <QSlider>
|
#include <QSlider>
|
||||||
@ -17,14 +17,14 @@ public:
|
|||||||
double value() const;
|
double value() const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void notifyValueChanged(int value);//<EFBFBD>ź<EFBFBD>valueChanged(int)<EFBFBD><EFBFBD>wrap
|
void notifyValueChanged(int value);//信号valueChanged(int)的wrap
|
||||||
void setValue(double Value, bool BlockSignals = true);//QSlider::setValue<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>wrap
|
void setValue(double Value, bool BlockSignals = true);//QSlider::setValue函数的wrap
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
signals :
|
signals :
|
||||||
void valueChanged(double Value);//QSlider<EFBFBD><EFBFBD>valueChanged<EFBFBD>źŵIJ<EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
void valueChanged(double Value);//QSlider的valueChanged信号的参数为整型
|
||||||
void rangeChanged(double Min, double Max);//QSlider<EFBFBD><EFBFBD>rangeChanged<EFBFBD>źŵIJ<EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
void rangeChanged(double Min, double Max);//QSlider的rangeChanged信号的参数为整型
|
||||||
|
|
||||||
private:
|
private:
|
||||||
double m_Multiplier;
|
double m_Multiplier;
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "QMotorDoubleSlider.h"
|
#include "QMotorDoubleSlider.h"
|
||||||
QMotorDoubleSlider::QMotorDoubleSlider(QWidget* pParent /*= NULL*/) :QSlider(pParent)
|
QMotorDoubleSlider::QMotorDoubleSlider(QWidget* pParent /*= NULL*/) :QSlider(pParent)
|
||||||
{
|
{
|
||||||
@ -14,9 +14,9 @@ QMotorDoubleSlider::QMotorDoubleSlider(QWidget* pParent /*= NULL*/) :QSlider(pPa
|
|||||||
|
|
||||||
void QMotorDoubleSlider::setMultiplier(float lead, float stepAnglemar, float scaleFactor, int subdivisionParam)
|
void QMotorDoubleSlider::setMultiplier(float lead, float stepAnglemar, float scaleFactor, int subdivisionParam)
|
||||||
{
|
{
|
||||||
//<EFBFBD><EFBFBD><EFBFBD>ݹ<EFBFBD>ʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>廻<EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD>룺1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(m_Multiplier)=<EFBFBD><EFBFBD><EFBFBD><EFBFBD>/(360/<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*ϸ<>ֱ<EFBFBD><D6B1><EFBFBD>)<29><><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7>https://wenku.baidu.com/view/4b2ea88bd0d233d4b14e69b8.html
|
//根据公式将脉冲换算为距离:1脉冲距离(m_Multiplier)=导程/(360/步距角*细分倍数);网址:https://wenku.baidu.com/view/4b2ea88bd0d233d4b14e69b8.html
|
||||||
//m_Multiplier(0.00054496986),//<EFBFBD>Ϻ<EFBFBD>ũ<EFBFBD><EFBFBD>Ժ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD>0.00052734375/5=0.00010546875<EFBFBD><EFBFBD><EFBFBD>ĺ<EFBFBD>ȷֵΪ0.000544969862759644<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ0.00054496986/5=0.000108993972<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>и<EFBFBD><EFBFBD><EFBFBD>еװ<EFBFBD><EFBFBD>1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>5<EFBFBD><EFBFBD>
|
//m_Multiplier(0.00054496986),//上海农科院,修改前:0.00052734375/5=0.00010546875;修改后准确值为0.000544969862759644,近似为0.00054496986/5=0.000108993972,因为有个机械装置1脉冲距离需要除以5;
|
||||||
//m_Multiplier(0.00054496986)//<EFBFBD>˰<EFBFBD><EFBFBD><EFBFBD>ũ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
//m_Multiplier(0.00054496986)//兴安盟农研所
|
||||||
m_Multiplier = lead / (360 / stepAnglemar * getValidSubdivision(subdivisionParam)) * scaleFactor;
|
m_Multiplier = lead / (360 / stepAnglemar * getValidSubdivision(subdivisionParam)) * scaleFactor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,13 +38,13 @@ int QMotorDoubleSlider::getValidSubdivision(int subdivisionParam)
|
|||||||
return 256;
|
return 256;
|
||||||
}
|
}
|
||||||
|
|
||||||
//<EFBFBD><EFBFBD><EFBFBD>ⷢ<EFBFBD><EFBFBD>
|
//向外发射
|
||||||
void QMotorDoubleSlider::notifyValueChanged(int Value)
|
void QMotorDoubleSlider::notifyValueChanged(int Value)
|
||||||
{
|
{
|
||||||
emit valueChanged((double)Value * m_Multiplier);//////////
|
emit valueChanged((double)Value * m_Multiplier);//////////
|
||||||
}
|
}
|
||||||
|
|
||||||
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
//接收外边
|
||||||
void QMotorDoubleSlider::setValue(double Value, bool BlockSignals)
|
void QMotorDoubleSlider::setValue(double Value, bool BlockSignals)
|
||||||
{
|
{
|
||||||
QSlider::blockSignals(BlockSignals);
|
QSlider::blockSignals(BlockSignals);
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
#ifndef Q_MOTOR_DOUBLE_SLIDER_H
|
#ifndef Q_MOTOR_DOUBLE_SLIDER_H
|
||||||
#define Q_MOTOR_DOUBLE_SLIDER_H
|
#define Q_MOTOR_DOUBLE_SLIDER_H
|
||||||
#include <QtGui/QtGui>
|
#include <QtGui/QtGui>
|
||||||
#include <QSlider>
|
#include <QSlider>
|
||||||
@ -15,7 +15,7 @@ public:
|
|||||||
void setMultiplier(float lead, float stepAnglemar, float scaleFactor, int subdivisionParam);
|
void setMultiplier(float lead, float stepAnglemar, float scaleFactor, int subdivisionParam);
|
||||||
int getValidSubdivision(int subdivisionParam);
|
int getValidSubdivision(int subdivisionParam);
|
||||||
|
|
||||||
double m_Multiplier;//<EFBFBD><EFBFBD><EFBFBD>ݹ<EFBFBD>ʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>廻<EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD>룺1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(m_Multiplier)=<EFBFBD><EFBFBD><EFBFBD><EFBFBD>/(360/<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*ϸ<>ֱ<EFBFBD><D6B1><EFBFBD>)<29><><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7>https://wenku.baidu.com/view/4b2ea88bd0d233d4b14e69b8.html
|
double m_Multiplier;//根据公式将脉冲换算为距离:1脉冲距离(m_Multiplier)=导程/(360/步距角*细分倍数);网址:https://wenku.baidu.com/view/4b2ea88bd0d233d4b14e69b8.html
|
||||||
|
|
||||||
void setRange(double Min, double Max);
|
void setRange(double Min, double Max);
|
||||||
void setMinimum(double Min);
|
void setMinimum(double Min);
|
||||||
@ -23,13 +23,13 @@ public:
|
|||||||
void setMaximum(double Max);
|
void setMaximum(double Max);
|
||||||
double maximum() const;
|
double maximum() const;
|
||||||
double value() const;
|
double value() const;
|
||||||
double OriginalValue() const;//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫʵ<EFBFBD>ʵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ǿ<EFBFBD><EFBFBD><EFBFBD>
|
double OriginalValue() const;//返回脉冲值:马达需要实际的脉冲值,而不是距离
|
||||||
long getPositionPulse(double position);//<EFBFBD><EFBFBD><EFBFBD>ݴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ľ<EFBFBD><EFBFBD>뷵<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
|
long getPositionPulse(double position);//根据传入的距离返回脉冲值
|
||||||
double getDistanceFromPulse(int pulse);
|
double getDistanceFromPulse(int pulse);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void notifyValueChanged(int value);//<EFBFBD>ź<EFBFBD>valueChanged(int)<EFBFBD><EFBFBD>wrap
|
void notifyValueChanged(int value);//信号valueChanged(int)的wrap
|
||||||
void setValue(double Value, bool BlockSignals = true);//QSlider::setValue<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>wrap
|
void setValue(double Value, bool BlockSignals = true);//QSlider::setValue函数的wrap
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void valueChanged(double Value);
|
void valueChanged(double Value);
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
#include "RasterDataProvider.h"
|
#include "RasterDataProvider.h"
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|||||||
81
HPPA/RasterImageLayer.cpp
Normal file
81
HPPA/RasterImageLayer.cpp
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
#include "RasterImageLayer.h"
|
||||||
|
#include "RasterLayer.h"
|
||||||
|
#include "RasterDataProvider.h"
|
||||||
|
#include "RasterRendererBase.h"
|
||||||
|
#include "MultibandRasterRenderer.h"
|
||||||
|
#include "SinglebandRasterRenderer.h"
|
||||||
|
|
||||||
|
RasterImageLayer::RasterImageLayer(RasterLayer* layer, RendererType type)
|
||||||
|
: m_layer(layer)
|
||||||
|
, m_rendererType(type)
|
||||||
|
, m_rendererInitialized(false)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void RasterImageLayer::ensureRenderer()
|
||||||
|
{
|
||||||
|
if (m_rendererInitialized) return;
|
||||||
|
if (!m_layer) return;
|
||||||
|
|
||||||
|
RasterDataProvider* provider = nullptr;
|
||||||
|
if (m_layer->dataProvider())
|
||||||
|
{
|
||||||
|
provider = m_layer->dataProvider();
|
||||||
|
}
|
||||||
|
else if (m_layer->openDataProvider())
|
||||||
|
{
|
||||||
|
provider = m_layer->dataProvider();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!provider) return;
|
||||||
|
|
||||||
|
switch (m_rendererType)
|
||||||
|
{
|
||||||
|
case RendererType::Multiband:
|
||||||
|
{
|
||||||
|
auto* multiRenderer = new MultibandRasterRenderer(provider);
|
||||||
|
m_renderer.reset(multiRenderer);
|
||||||
|
multiRenderer->setParams(m_multibandParams);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case RendererType::Singleband:
|
||||||
|
{
|
||||||
|
auto* singleRenderer = new SinglebandRasterRenderer(provider);
|
||||||
|
m_renderer.reset(singleRenderer);
|
||||||
|
singleRenderer->setParams(m_singlebandParams);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_rendererInitialized = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
RasterImageLayer::~RasterImageLayer()
|
||||||
|
{
|
||||||
|
m_renderer.reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
QImage RasterImageLayer::render()
|
||||||
|
{
|
||||||
|
ensureRenderer();
|
||||||
|
if (!m_renderer) return QImage();
|
||||||
|
return m_renderer->render();
|
||||||
|
}
|
||||||
|
|
||||||
|
void RasterImageLayer::setMultibandParams(const MultibandRenderParams& params)
|
||||||
|
{
|
||||||
|
m_multibandParams = params;
|
||||||
|
if (m_rendererInitialized && m_rendererType == RendererType::Multiband) {
|
||||||
|
auto* r = static_cast<MultibandRasterRenderer*>(m_renderer.get());
|
||||||
|
r->setParams(params);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void RasterImageLayer::setSinglebandParams(const SinglebandRenderParams& params)
|
||||||
|
{
|
||||||
|
m_singlebandParams = params;
|
||||||
|
if (m_rendererInitialized && m_rendererType == RendererType::Singleband) {
|
||||||
|
auto* r = static_cast<SinglebandRasterRenderer*>(m_renderer.get());
|
||||||
|
r->setParams(params);
|
||||||
|
}
|
||||||
|
}
|
||||||
46
HPPA/RasterImageLayer.h
Normal file
46
HPPA/RasterImageLayer.h
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
#include <QImage>
|
||||||
|
|
||||||
|
#include "RasterRendererBase.h"
|
||||||
|
#include "RasterRenderParams.h"
|
||||||
|
|
||||||
|
class RasterLayer;
|
||||||
|
class RasterRendererBase;
|
||||||
|
class MultibandRasterRenderer;
|
||||||
|
class SinglebandRasterRenderer;
|
||||||
|
|
||||||
|
class RasterImageLayer
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
enum class RendererType {
|
||||||
|
Multiband,
|
||||||
|
Singleband
|
||||||
|
};
|
||||||
|
|
||||||
|
RasterImageLayer(RasterLayer* layer, RendererType type);
|
||||||
|
~RasterImageLayer();
|
||||||
|
|
||||||
|
void ensureRenderer();
|
||||||
|
QImage render();
|
||||||
|
|
||||||
|
RasterLayer* layer() const { return m_layer; }
|
||||||
|
RasterRendererBase* renderer() const { return m_renderer.get(); }
|
||||||
|
RendererType rendererType() const { return m_rendererType; }
|
||||||
|
|
||||||
|
// Type-safe params access
|
||||||
|
MultibandRenderParams multibandParams() const { return m_multibandParams; }
|
||||||
|
SinglebandRenderParams singlebandParams() const { return m_singlebandParams; }
|
||||||
|
|
||||||
|
void setMultibandParams(const MultibandRenderParams& params);
|
||||||
|
void setSinglebandParams(const SinglebandRenderParams& params);
|
||||||
|
|
||||||
|
private:
|
||||||
|
RasterLayer* m_layer;
|
||||||
|
RendererType m_rendererType;
|
||||||
|
std::unique_ptr<RasterRendererBase> m_renderer;
|
||||||
|
MultibandRenderParams m_multibandParams;
|
||||||
|
SinglebandRenderParams m_singlebandParams;
|
||||||
|
bool m_rendererInitialized = false;
|
||||||
|
};
|
||||||
@ -1,21 +1,18 @@
|
|||||||
#include "RasterLayer.h"
|
#include "RasterLayer.h"
|
||||||
#include "RasterDataProvider.h"
|
#include "RasterDataProvider.h"
|
||||||
#include "RasterRenderer.h"
|
|
||||||
#include <algorithm>
|
|
||||||
|
|
||||||
RasterLayer::RasterLayer(const QString& name, const QString& uri)
|
RasterLayer::RasterLayer(const QString& name, const QString& uri)
|
||||||
: MapLayer(name, uri)
|
: MapLayer(name, uri)
|
||||||
{
|
{
|
||||||
// lazy creation
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RasterLayer::~RasterLayer()
|
RasterLayer::~RasterLayer()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
MapLayer::LayerType RasterLayer::layerType() const
|
MapLayer::LayerType RasterLayer::layerType() const
|
||||||
{
|
{
|
||||||
return MapLayer::LayerType::Raster;
|
return MapLayer::LayerType::Raster;
|
||||||
}
|
}
|
||||||
|
|
||||||
RasterDataProvider* RasterLayer::dataProvider() const
|
RasterDataProvider* RasterLayer::dataProvider() const
|
||||||
@ -23,18 +20,11 @@ RasterDataProvider* RasterLayer::dataProvider() const
|
|||||||
return m_provider ? m_provider.get() : nullptr;
|
return m_provider ? m_provider.get() : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
RasterRenderer* RasterLayer::renderer() const
|
|
||||||
{
|
|
||||||
return m_renderer ? m_renderer.get() : nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool RasterLayer::openDataProvider()
|
bool RasterLayer::openDataProvider()
|
||||||
{
|
{
|
||||||
if (!m_provider) m_provider = std::make_unique<RasterDataProvider>(dataPath());
|
if (!m_provider) m_provider = std::make_unique<RasterDataProvider>(dataPath());
|
||||||
if (!m_provider) return false;
|
if (!m_provider) return false;
|
||||||
bool ok = m_provider->open();
|
return m_provider->open();
|
||||||
if (ok && !m_renderer) m_renderer = std::make_unique<RasterRenderer>(m_provider.get());
|
|
||||||
return ok;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RasterLayer::isValidPixel(int x, int y)
|
bool RasterLayer::isValidPixel(int x, int y)
|
||||||
@ -71,31 +61,6 @@ bool RasterLayer::readPixelSpectrum(int x, int y, QVector<double>& wavelengths,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QImage RasterLayer::render(const RenderParams& params)
|
|
||||||
{
|
|
||||||
if (!m_provider) {
|
|
||||||
if (!openDataProvider()) return QImage();
|
|
||||||
}
|
|
||||||
if (!m_renderer) m_renderer = std::make_unique<RasterRenderer>(m_provider.get());
|
|
||||||
RasterRenderer::Params p;
|
|
||||||
p.rWave = params.rWave;
|
|
||||||
p.gWave = params.gWave;
|
|
||||||
p.bWave = params.bWave;
|
|
||||||
p.minValue = params.minValue;
|
|
||||||
p.maxValue = params.maxValue;
|
|
||||||
return m_renderer->render(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
RasterLayer::RenderParams RasterLayer::currentRenderParams() const
|
|
||||||
{
|
|
||||||
return m_currentParams;
|
|
||||||
}
|
|
||||||
|
|
||||||
void RasterLayer::setCurrentRenderParams(const RenderParams& params)
|
|
||||||
{
|
|
||||||
m_currentParams = params;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool RasterLayer::wavelengthRange(double& minWave, double& maxWave) const
|
bool RasterLayer::wavelengthRange(double& minWave, double& maxWave) const
|
||||||
{
|
{
|
||||||
auto wl = bandWavelengths();
|
auto wl = bandWavelengths();
|
||||||
@ -108,9 +73,26 @@ bool RasterLayer::wavelengthRange(double& minWave, double& maxWave) const
|
|||||||
std::vector<double> RasterLayer::bandWavelengths() const
|
std::vector<double> RasterLayer::bandWavelengths() const
|
||||||
{
|
{
|
||||||
if (!m_provider) {
|
if (!m_provider) {
|
||||||
// need to open provider to read wavelengths - cast away const for lazy init
|
|
||||||
auto* self = const_cast<RasterLayer*>(this);
|
auto* self = const_cast<RasterLayer*>(this);
|
||||||
if (!self->openDataProvider()) return {};
|
if (!self->openDataProvider()) return {};
|
||||||
}
|
}
|
||||||
return m_provider->bandWavelengths();
|
return m_provider->bandWavelengths();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int RasterLayer::width() const
|
||||||
|
{
|
||||||
|
if (!m_provider) {
|
||||||
|
auto* self = const_cast<RasterLayer*>(this);
|
||||||
|
if (!self->openDataProvider()) return 0;
|
||||||
|
}
|
||||||
|
return m_provider->width();
|
||||||
|
}
|
||||||
|
|
||||||
|
int RasterLayer::height() const
|
||||||
|
{
|
||||||
|
if (!m_provider) {
|
||||||
|
auto* self = const_cast<RasterLayer*>(this);
|
||||||
|
if (!self->openDataProvider()) return 0;
|
||||||
|
}
|
||||||
|
return m_provider->height();
|
||||||
|
}
|
||||||
|
|||||||
@ -1,12 +1,11 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "MapLayer.h"
|
#include "MapLayer.h"
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <QImage>
|
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
class RasterDataProvider;
|
class RasterDataProvider;
|
||||||
class RasterRenderer;
|
|
||||||
|
|
||||||
class RasterLayer : public MapLayer
|
class RasterLayer : public MapLayer
|
||||||
{
|
{
|
||||||
@ -17,9 +16,8 @@ public:
|
|||||||
|
|
||||||
LayerType layerType() const override;
|
LayerType layerType() const override;
|
||||||
|
|
||||||
// Access provider/renderer
|
// Access provider
|
||||||
RasterDataProvider* dataProvider() const;
|
RasterDataProvider* dataProvider() const;
|
||||||
RasterRenderer* renderer() const;
|
|
||||||
|
|
||||||
// Create or open provider based on this layer's uri
|
// Create or open provider based on this layer's uri
|
||||||
bool openDataProvider();
|
bool openDataProvider();
|
||||||
@ -27,29 +25,16 @@ public:
|
|||||||
bool isValidPixel(int x, int y);
|
bool isValidPixel(int x, int y);
|
||||||
bool readPixelSpectrum(int x, int y, QVector<double>& wavelengths, QVector<double>& spectrum);
|
bool readPixelSpectrum(int x, int y, QVector<double>& wavelengths, QVector<double>& spectrum);
|
||||||
|
|
||||||
struct RenderParams {
|
|
||||||
double rWave = 665.0; // default wavelengths (nm)
|
|
||||||
double gWave = 560.0;
|
|
||||||
double bWave = 490.0;
|
|
||||||
double minValue = 0.0; // optional stretch
|
|
||||||
double maxValue = 4095.0;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Render the raster using current provider and renderer. Returns an empty QImage on failure.
|
|
||||||
QImage render(const RenderParams& params);
|
|
||||||
|
|
||||||
// Current render params stored per layer
|
|
||||||
RenderParams currentRenderParams() const;
|
|
||||||
void setCurrentRenderParams(const RenderParams& params);
|
|
||||||
|
|
||||||
// Get wavelength range from data provider (min, max). Returns false if unavailable.
|
// Get wavelength range from data provider (min, max). Returns false if unavailable.
|
||||||
bool wavelengthRange(double& minWave, double& maxWave) const;
|
bool wavelengthRange(double& minWave, double& maxWave) const;
|
||||||
|
|
||||||
// Get all band wavelengths
|
// Get all band wavelengths
|
||||||
std::vector<double> bandWavelengths() const;
|
std::vector<double> bandWavelengths() const;
|
||||||
|
|
||||||
private:
|
// Get dimensions
|
||||||
|
int width() const;
|
||||||
|
int height() const;
|
||||||
|
|
||||||
|
protected:
|
||||||
std::unique_ptr<RasterDataProvider> m_provider;
|
std::unique_ptr<RasterDataProvider> m_provider;
|
||||||
std::unique_ptr<RasterRenderer> m_renderer;
|
|
||||||
RenderParams m_currentParams;
|
|
||||||
};
|
};
|
||||||
|
|||||||
19
HPPA/RasterRenderParams.h
Normal file
19
HPPA/RasterRenderParams.h
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
// Common base struct for all render parameters
|
||||||
|
struct RasterRenderParamsBase {
|
||||||
|
double minValue = 0.0;
|
||||||
|
double maxValue = 4095.0;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Parameters for multiband rendering (RGB with wavelengths)
|
||||||
|
struct MultibandRenderParams : RasterRenderParamsBase {
|
||||||
|
double rWave = 665.0;
|
||||||
|
double gWave = 560.0;
|
||||||
|
double bWave = 490.0;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Parameters for singleband rendering (wavelength)
|
||||||
|
struct SinglebandRenderParams : RasterRenderParamsBase {
|
||||||
|
double wavelength = 550.0;
|
||||||
|
};
|
||||||
@ -1,29 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <QImage>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
class RasterDataProvider;
|
|
||||||
|
|
||||||
class RasterRenderer
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
struct Params {
|
|
||||||
double rWave = 665.0;
|
|
||||||
double gWave = 560.0;
|
|
||||||
double bWave = 490.0;
|
|
||||||
double minValue = 0.0;
|
|
||||||
double maxValue = 255.0;
|
|
||||||
};
|
|
||||||
|
|
||||||
explicit RasterRenderer(RasterDataProvider* provider);
|
|
||||||
|
|
||||||
// Render to an 8-bit RGB image. Returns empty image on failure.
|
|
||||||
QImage render(const Params& params);
|
|
||||||
|
|
||||||
private:
|
|
||||||
RasterDataProvider* m_provider;
|
|
||||||
|
|
||||||
// helper to map float buffer to 8-bit with min/max stretch
|
|
||||||
static void stretchTo8bit(const std::vector<float>& in, std::vector<unsigned char>& out, float minVal, float maxVal);
|
|
||||||
};
|
|
||||||
6
HPPA/RasterRendererBase.cpp
Normal file
6
HPPA/RasterRendererBase.cpp
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#include "RasterRendererBase.h"
|
||||||
|
|
||||||
|
RasterRendererBase::RasterRendererBase(RasterDataProvider* provider)
|
||||||
|
: m_provider(provider)
|
||||||
|
{
|
||||||
|
}
|
||||||
25
HPPA/RasterRendererBase.h
Normal file
25
HPPA/RasterRendererBase.h
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QImage>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
class RasterDataProvider;
|
||||||
|
|
||||||
|
class RasterRendererBase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
//struct Params {
|
||||||
|
// virtual ~Params() = default;
|
||||||
|
//};
|
||||||
|
|
||||||
|
virtual ~RasterRendererBase() = default;
|
||||||
|
|
||||||
|
virtual QImage render() = 0;
|
||||||
|
|
||||||
|
RasterDataProvider* dataProvider() const { return m_provider; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
explicit RasterRendererBase(RasterDataProvider* provider);
|
||||||
|
|
||||||
|
RasterDataProvider* m_provider = nullptr;
|
||||||
|
};
|
||||||
@ -1,4 +1,4 @@
|
|||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
@ -14,7 +14,7 @@ ResononNirImager::~ResononNirImager()
|
|||||||
{
|
{
|
||||||
if (buffer != nullptr)
|
if (buffer != nullptr)
|
||||||
{
|
{
|
||||||
std::cout << "<EFBFBD>ͷŶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD>" << std::endl;
|
std::cout << "释放堆上内存" << std::endl;
|
||||||
free(buffer);
|
free(buffer);
|
||||||
free(dark);
|
free(dark);
|
||||||
free(white);
|
free(white);
|
||||||
@ -40,12 +40,12 @@ double ResononNirImager::getIntegrationTime()
|
|||||||
double ResononNirImager::getGain()
|
double ResononNirImager::getGain()
|
||||||
{
|
{
|
||||||
//return m_ResononNirImager.get_gain();
|
//return m_ResononNirImager.get_gain();
|
||||||
return 0.0;//nir<EFBFBD><EFBFBD>֧<EFBFBD><EFBFBD>gian
|
return 0.0;//nir不支持gian
|
||||||
}
|
}
|
||||||
|
|
||||||
void ResononNirImager::setGain(const double gain)
|
void ResononNirImager::setGain(const double gain)
|
||||||
{
|
{
|
||||||
//m_ResononNirImager.set_gain(gain);//nir<EFBFBD><EFBFBD>֧<EFBFBD><EFBFBD>gian
|
//m_ResononNirImager.set_gain(gain);//nir不支持gian
|
||||||
}
|
}
|
||||||
|
|
||||||
void ResononNirImager::setFramerate(const double frames_per_second)
|
void ResononNirImager::setFramerate(const double frames_per_second)
|
||||||
@ -103,12 +103,12 @@ void ResononNirImager::setSpectraBin(int new_spectral_bin)
|
|||||||
|
|
||||||
double ResononNirImager::auto_exposure()
|
double ResononNirImager::auto_exposure()
|
||||||
{
|
{
|
||||||
//<EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ع<EFBFBD>ʱ<EFBFBD><EFBFBD>Ϊ<EFBFBD>ڵ<EFBFBD>ǰ֡<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
//第一步:先设置曝光时间为在当前帧率情况下最大
|
||||||
double x = 1 / getFramerate() * 1000;//<EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ع<EFBFBD>ʱ<EFBFBD><EFBFBD>
|
double x = 1 / getFramerate() * 1000;//获取最大毫秒曝光时间
|
||||||
reConnectImage();
|
reConnectImage();
|
||||||
setIntegrationTime(x);
|
setIntegrationTime(x);
|
||||||
|
|
||||||
//<EFBFBD>ڶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><EFBFBD>ѭ<EFBFBD><EFBFBD>Ѱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ع<EFBFBD>ʱ<EFBFBD><EFBFBD>
|
//第二步:通过循环寻找最佳曝光时间
|
||||||
imagerStartCollect();
|
imagerStartCollect();
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
@ -117,7 +117,7 @@ double ResononNirImager::auto_exposure()
|
|||||||
if (GetMaxValue(buffer, m_FrameSize) >= 4095)
|
if (GetMaxValue(buffer, m_FrameSize) >= 4095)
|
||||||
{
|
{
|
||||||
setIntegrationTime(getIntegrationTime() * 0.8);
|
setIntegrationTime(getIntegrationTime() * 0.8);
|
||||||
std::cout << "<EFBFBD>Զ<EFBFBD><EFBFBD>ع<EFBFBD>-----------" << std::endl;
|
std::cout << "自动曝光-----------" << std::endl;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -128,7 +128,7 @@ double ResononNirImager::auto_exposure()
|
|||||||
reConnectImage();
|
reConnectImage();
|
||||||
//imagerStopCollect();
|
//imagerStopCollect();
|
||||||
|
|
||||||
//std::cout << "<EFBFBD>Զ<EFBFBD><EFBFBD>ع⣺" << getIntegrationTime() << std::endl;
|
//std::cout << "自动曝光:" << getIntegrationTime() << std::endl;
|
||||||
|
|
||||||
return getIntegrationTime();
|
return getIntegrationTime();
|
||||||
}
|
}
|
||||||
@ -151,7 +151,7 @@ int ResononNirImager::getSampleCount()
|
|||||||
void ResononNirImager::focus()
|
void ResononNirImager::focus()
|
||||||
{
|
{
|
||||||
m_iFocusFrameCounter = 1;
|
m_iFocusFrameCounter = 1;
|
||||||
//std::cout << "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>-----------" << std::endl;
|
//std::cout << "调焦-----------" << std::endl;
|
||||||
|
|
||||||
double tmpFrmerate = getFramerate();
|
double tmpFrmerate = getFramerate();
|
||||||
double tmpIntegrationTime = getIntegrationTime();
|
double tmpIntegrationTime = getIntegrationTime();
|
||||||
@ -159,7 +159,7 @@ void ResononNirImager::focus()
|
|||||||
|
|
||||||
setFramerate(5);
|
setFramerate(5);
|
||||||
auto_exposure();
|
auto_exposure();
|
||||||
std::cout << "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD><EFBFBD>ع<EFBFBD>ʱ<EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>" << getIntegrationTime() << std::endl;
|
std::cout << "调焦获得的曝光时间为:" << getIntegrationTime() << std::endl;
|
||||||
|
|
||||||
reConnectImage();
|
reConnectImage();
|
||||||
imagerStartCollect();
|
imagerStartCollect();
|
||||||
@ -183,12 +183,12 @@ void ResononNirImager::focus()
|
|||||||
reConnectImage();
|
reConnectImage();
|
||||||
setIntegrationTime(tmpIntegrationTime);
|
setIntegrationTime(tmpIntegrationTime);
|
||||||
|
|
||||||
setFramerate(tmpFrmerate);//<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
setFramerate(tmpFrmerate);//必须要放在这里,如果不放这里,这行代码就要出错。。。。。。
|
||||||
}
|
}
|
||||||
|
|
||||||
void ResononNirImager::record_dark()
|
void ResononNirImager::record_dark()
|
||||||
{
|
{
|
||||||
std::cout << "<EFBFBD>ɼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>" << std::endl;
|
std::cout << "采集暗电流!!!!!!!!!" << std::endl;
|
||||||
reConnectImage();
|
reConnectImage();
|
||||||
imagerStartCollect();
|
imagerStartCollect();
|
||||||
|
|
||||||
@ -221,7 +221,7 @@ void ResononNirImager::record_dark()
|
|||||||
|
|
||||||
void ResononNirImager::record_white()
|
void ResononNirImager::record_white()
|
||||||
{
|
{
|
||||||
std::cout << "<EFBFBD>ɼ<EFBFBD><EFBFBD>װ壡<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>" << std::endl;
|
std::cout << "采集白板!!!!!!!!!" << std::endl;
|
||||||
reConnectImage();
|
reConnectImage();
|
||||||
imagerStartCollect();
|
imagerStartCollect();
|
||||||
|
|
||||||
@ -247,7 +247,7 @@ void ResononNirImager::record_white()
|
|||||||
|
|
||||||
imagerStopCollect();
|
imagerStopCollect();
|
||||||
|
|
||||||
//<EFBFBD>װ<EFBFBD><EFBFBD>۰<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
//白板扣暗电流
|
||||||
if (m_HasDark)
|
if (m_HasDark)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < m_FrameSize; i++)
|
for (size_t i = 0; i < m_FrameSize; i++)
|
||||||
@ -275,18 +275,23 @@ void ResononNirImager::start_record()
|
|||||||
//std::cout << "------------------------------------------------------" << std::endl;
|
//std::cout << "------------------------------------------------------" << std::endl;
|
||||||
|
|
||||||
m_iFrameCounter = 0;
|
m_iFrameCounter = 0;
|
||||||
m_RgbImage->m_iFrameCounter = 0;//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>rgbͼ<EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD>0<EFBFBD><EFBFBD>
|
m_RgbImage->m_iFrameCounter = 0;//设置填充rgb图像的第0行
|
||||||
m_bRecordControlState = true;
|
m_bRecordControlState = true;
|
||||||
|
|
||||||
//<EFBFBD>ж<EFBFBD><EFBFBD>ڴ<EFBFBD>buffer<EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
//判断内存buffer是否正常分配
|
||||||
if (buffer == 0)
|
if (buffer == 0)
|
||||||
{
|
{
|
||||||
std::cerr << "Error: memory could not be allocated for datacube";
|
std::cerr << "Error: memory could not be allocated for datacube";
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 在开始采集时仅发出文件信息,UI 层自行创建 MapLayer 并管理生命周期
|
||||||
|
// prepare file name that will be used for saving
|
||||||
m_FileName2Save2 = m_FileName2Save + "_" + std::to_string(m_FileSavedCounter) + ".bil";
|
m_FileName2Save2 = m_FileName2Save + "_" + std::to_string(m_FileSavedCounter) + ".bil";
|
||||||
|
QString baseName = QString::fromStdString(getFileNameFromPath(m_FileName2Save2));
|
||||||
QString filePath = QString::fromStdString(m_FileName2Save2);
|
QString filePath = QString::fromStdString(m_FileName2Save2);
|
||||||
|
emit LayerFileCreated(baseName, filePath, m_FileSavedCounter);
|
||||||
|
|
||||||
FILE* m_fImage = fopen(m_FileName2Save2.c_str(), "w+b");
|
FILE* m_fImage = fopen(m_FileName2Save2.c_str(), "w+b");
|
||||||
|
|
||||||
size_t x;
|
size_t x;
|
||||||
@ -295,7 +300,7 @@ void ResononNirImager::start_record()
|
|||||||
string timesFile = removeFileExtension(m_FileName2Save2) + ".times";
|
string timesFile = removeFileExtension(m_FileName2Save2) + ".times";
|
||||||
FILE* hTimesFile = fopen(timesFile.c_str(), "w+");
|
FILE* hTimesFile = fopen(timesFile.c_str(), "w+");
|
||||||
|
|
||||||
reConnectImage();//nir<EFBFBD>ڶ<EFBFBD><EFBFBD>βɼ<EFBFBD>ʱ<EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>imagerStartCollect()<EFBFBD>ᱨ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
reConnectImage();//nir第二次采集时需要重新连接相机,否则函数imagerStartCollect()会报错。。。。。。
|
||||||
imagerStartCollect();
|
imagerStartCollect();
|
||||||
while (m_bRecordControlState)
|
while (m_bRecordControlState)
|
||||||
{
|
{
|
||||||
@ -305,7 +310,7 @@ void ResononNirImager::start_record()
|
|||||||
long long timeOs = getNanosecondsSinceMidnight();
|
long long timeOs = getNanosecondsSinceMidnight();
|
||||||
//qDebug() << "time ns-------------------: " << timeOs;
|
//qDebug() << "time ns-------------------: " << timeOs;
|
||||||
|
|
||||||
//<EFBFBD><EFBFBD>ȥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӦΪbuffer<EFBFBD><EFBFBD>dark<EFBFBD><EFBFBD><EFBFBD><EFBFBD>unsigned short<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ե<EFBFBD>dark>bufferʱ<EFBFBD><EFBFBD>buffer-dark=65535
|
//减去暗电流,应为buffer和dark都是unsigned short,所以当dark>buffer时,buffer-dark=65535
|
||||||
if (m_HasDark)
|
if (m_HasDark)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < m_FrameSize; i++)
|
for (size_t i = 0; i < m_FrameSize; i++)
|
||||||
@ -323,12 +328,12 @@ void ResononNirImager::start_record()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//ת<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
//转反射率
|
||||||
if (m_HasWhite)
|
if (m_HasWhite)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < m_FrameSize; i++)
|
for (size_t i = 0; i < m_FrameSize; i++)
|
||||||
{
|
{
|
||||||
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>װ壩Ϊ0<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
//处理除数(白板)为0的情况
|
||||||
if (white[i] != 0)
|
if (white[i] != 0)
|
||||||
{
|
{
|
||||||
pixelValueTmp = buffer[i];
|
pixelValueTmp = buffer[i];
|
||||||
@ -344,14 +349,14 @@ void ResononNirImager::start_record()
|
|||||||
}
|
}
|
||||||
|
|
||||||
x = fwrite(buffer, 2, m_FrameSize, m_fImage);
|
x = fwrite(buffer, 2, m_FrameSize, m_fImage);
|
||||||
fprintf(hTimesFile, "%lld\n", timeOs);
|
fprintf(hTimesFile, "%ll\n", timeOs);
|
||||||
|
|
||||||
//<EFBFBD><EFBFBD>rgb<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><EFBFBD>ڽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
|
//将rgb波段提取出来,以便在界面中显示
|
||||||
m_RgbImage->FillRgbImage(buffer);//??????????????????????????????????????????????????????????????????????????????????????????????????????
|
m_RgbImage->FillRgbImage(buffer);//??????????????????????????????????????????????????????????????????????????????????????????????????????
|
||||||
|
|
||||||
//std::cout << "<EFBFBD><EFBFBD>" << m_iFrameCounter << "֡д<EFBFBD><EFBFBD>" << x << "<EFBFBD><EFBFBD>unsigned short<EFBFBD><EFBFBD>" << std::endl;
|
//std::cout << "第" << m_iFrameCounter << "帧写了" << x << "个unsigned short。" << std::endl;
|
||||||
|
|
||||||
//ÿ<EFBFBD><EFBFBD>1s<EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>ν<EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD>λ<EFBFBD><EFBFBD><EFBFBD>
|
//每隔1s进行一次界面图形绘制
|
||||||
if (m_iFrameCounter % (int)getFramerate() == 0)
|
if (m_iFrameCounter % (int)getFramerate() == 0)
|
||||||
{
|
{
|
||||||
emit PlotSignal(m_FileSavedCounter, m_iFrameCounter, filePath);
|
emit PlotSignal(m_FileSavedCounter, m_iFrameCounter, filePath);
|
||||||
@ -360,18 +365,22 @@ void ResononNirImager::start_record()
|
|||||||
if (m_iFrameCounter >= m_iFrameNumber)
|
if (m_iFrameCounter >= m_iFrameNumber)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
//qDebug() << "<22><><EFBFBD><EFBFBD>ֹͣ<CDA3>ɼ<EFBFBD><C9BC><EFBFBD>֡<EFBFBD><D6A1><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD><C6B5>";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
imagerStopCollect();
|
imagerStopCollect();
|
||||||
|
|
||||||
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>λ<EFBFBD>ͼǰ<EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
//在最后一次画图前需要进行一次拉伸
|
||||||
//m_RgbImage
|
//m_RgbImage
|
||||||
emit PlotSignal(m_FileSavedCounter, -1, filePath);//<EFBFBD>ɼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɺ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>λ<EFBFBD>ͼ<EFBFBD><EFBFBD><EFBFBD>Է<EFBFBD><EFBFBD>ɼ<EFBFBD>֡<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֡<EFBFBD>ʵı<EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><EFBFBD>ȫ
|
emit PlotSignal(m_FileSavedCounter, -1, filePath);//采集完成后进行一次画图,以防采集帧数不是帧率的倍数时,画图不全
|
||||||
|
|
||||||
m_bRecordControlState = false;
|
m_bRecordControlState = false;
|
||||||
WriteHdr();
|
WriteHdr();
|
||||||
|
|
||||||
|
// 发射 ImageFileSaved 信号,通知 UI 层把该文件加入图层管理器
|
||||||
|
// m_FileName2Save2 保存了本次写入的 .bil 文件名(例如 "tmp_image_0.bil")
|
||||||
|
emit ImageFileSaved(QString::fromStdString(m_FileName2Save2), m_FileSavedCounter);
|
||||||
|
|
||||||
m_FileSavedCounter++;
|
m_FileSavedCounter++;
|
||||||
|
|
||||||
if (m_iFrameCounter >= m_iFrameNumber)
|
if (m_iFrameCounter >= m_iFrameNumber)
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <opencv2/core/core.hpp>
|
#include <opencv2/core/core.hpp>
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "RgbCameraOperation.h"
|
#include "RgbCameraOperation.h"
|
||||||
|
|
||||||
RgbCameraOperation::RgbCameraOperation()
|
RgbCameraOperation::RgbCameraOperation()
|
||||||
@ -14,14 +14,14 @@ RgbCameraOperation::~RgbCameraOperation()
|
|||||||
|
|
||||||
void RgbCameraOperation::OpenCamera()
|
void RgbCameraOperation::OpenCamera()
|
||||||
{
|
{
|
||||||
std::cout << "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ+++++++++++++++++++++++++++++++++++++++++++" << std::endl;
|
std::cout << "打开摄像头+++++++++++++++++++++++++++++++++++++++++++" << std::endl;
|
||||||
cam = new cv::VideoCapture(0);
|
cam = new cv::VideoCapture(0);
|
||||||
|
|
||||||
record = true;
|
record = true;
|
||||||
|
|
||||||
while (record)
|
while (record)
|
||||||
{
|
{
|
||||||
//std::cout << "<EFBFBD>ɼ<EFBFBD>Ӱ<EFBFBD><EFBFBD>+++++++++++++++++++++++++++++++++++++++++++" << std::endl;
|
//std::cout << "采集影像+++++++++++++++++++++++++++++++++++++++++++" << std::endl;
|
||||||
cam->read(frame);
|
cam->read(frame);
|
||||||
m_qImage = m_ImageProcessor->Mat2QImage(frame);
|
m_qImage = m_ImageProcessor->Mat2QImage(frame);
|
||||||
|
|
||||||
@ -30,20 +30,20 @@ void RgbCameraOperation::OpenCamera()
|
|||||||
|
|
||||||
cam->release();
|
cam->release();
|
||||||
|
|
||||||
emit CamClosed();
|
emit CamOpenedSignal();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RgbCameraOperation::OpenCamera_callback()
|
void RgbCameraOperation::OpenCamera_callback()
|
||||||
{
|
{
|
||||||
std::cout << "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ+++++++++++++++++++++++++++++++++++++++++++" << std::endl;
|
std::cout << "打开摄像头+++++++++++++++++++++++++++++++++++++++++++" << std::endl;
|
||||||
cam = new cv::VideoCapture(0);
|
cam = new cv::VideoCapture(0);
|
||||||
|
|
||||||
record = true;
|
record = true;
|
||||||
|
|
||||||
while (record)
|
while (record)
|
||||||
{
|
{
|
||||||
//std::cout << "<EFBFBD>ɼ<EFBFBD>Ӱ<EFBFBD><EFBFBD>+++++++++++++++++++++++++++++++++++++++++++" << std::endl;
|
//std::cout << "采集影像+++++++++++++++++++++++++++++++++++++++++++" << std::endl;
|
||||||
cam->read(frame);
|
cam->read(frame);
|
||||||
m_qImage = m_ImageProcessor->Mat2QImage(frame);
|
m_qImage = m_ImageProcessor->Mat2QImage(frame);
|
||||||
|
|
||||||
@ -62,7 +62,9 @@ void RgbCameraOperation::setCallback(void(*func)())
|
|||||||
|
|
||||||
void RgbCameraOperation::CloseCamera()
|
void RgbCameraOperation::CloseCamera()
|
||||||
{
|
{
|
||||||
std::cout << "<EFBFBD>ر<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ+++++++++++++++++++++++++++++++++++++++++++" << std::endl;
|
std::cout << "关闭摄像头+++++++++++++++++++++++++++++++++++++++++++" << std::endl;
|
||||||
|
|
||||||
record = false;
|
record = false;
|
||||||
|
|
||||||
|
emit CamClosedSignal();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#ifndef RGBCAMERAOPERATION_H
|
#ifndef RGBCAMERAOPERATION_H
|
||||||
#define RGBCAMERAOPERATION_H
|
#define RGBCAMERAOPERATION_H
|
||||||
|
|
||||||
@ -36,12 +36,13 @@ private:
|
|||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void OpenCamera();
|
void OpenCamera();
|
||||||
void OpenCamera_callback();//<EFBFBD><EFBFBD>ʹ<EFBFBD><EFBFBD><EFBFBD>źŶ<EFBFBD>ʹ<EFBFBD>ûص<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֪ͨ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˢ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƶ
|
void OpenCamera_callback();//不使用信号而使用回调函数来通知界面刷新视频
|
||||||
void CloseCamera();
|
void CloseCamera();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void PlotSignal();
|
void PlotSignal();
|
||||||
|
|
||||||
void CamClosed();
|
void CamOpenedSignal();
|
||||||
|
void CamClosedSignal();
|
||||||
};
|
};
|
||||||
#endif // !RGBCAMERAOPERATION_H
|
#endif // !RGBCAMERAOPERATION_H
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
#include "RobotArmControl.h"
|
#include "RobotArmControl.h"
|
||||||
|
|
||||||
RobotArmControl::RobotArmControl(QWidget* parent): QDialog(parent)
|
RobotArmControl::RobotArmControl(QWidget* parent): QDialog(parent)
|
||||||
{
|
{
|
||||||
@ -82,7 +82,7 @@ void RobotArmControl::getTaskList()
|
|||||||
files.append(line.trimmed());
|
files.append(line.trimmed());
|
||||||
}
|
}
|
||||||
|
|
||||||
////<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD>Ȼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
////先清除数据,然后添加数据
|
||||||
//for (size_t i = 0; i < files.length(); i++)
|
//for (size_t i = 0; i < files.length(); i++)
|
||||||
//{
|
//{
|
||||||
// int row = m_pModel->rowCount();
|
// int row = m_pModel->rowCount();
|
||||||
@ -112,7 +112,7 @@ void RobotArmControl::executeTaskWithHyperImager()
|
|||||||
QModelIndex index = ui.taskList_listView->currentIndex();
|
QModelIndex index = ui.taskList_listView->currentIndex();
|
||||||
if (-1 == index.row())
|
if (-1 == index.row())
|
||||||
{
|
{
|
||||||
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD>û<EFBFBD>ѡ<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
|
//弹窗提示用户选择文件
|
||||||
ui.textEdit->append("Please select file on the left!");
|
ui.textEdit->append("Please select file on the left!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -148,7 +148,7 @@ void RobotArmControl::executeTaskWithoutHyperImager()
|
|||||||
QModelIndex index = ui.taskList_listView->currentIndex();
|
QModelIndex index = ui.taskList_listView->currentIndex();
|
||||||
if (-1 == index.row())
|
if (-1 == index.row())
|
||||||
{
|
{
|
||||||
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD>û<EFBFBD>ѡ<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
|
//弹窗提示用户选择文件
|
||||||
ui.textEdit->append("Please select file on the left!");
|
ui.textEdit->append("Please select file on the left!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -290,7 +290,7 @@ bool RobotController::processResponse_getJbiState(QJsonObject response, QString&
|
|||||||
void RobotController::getPoint()
|
void RobotController::getPoint()
|
||||||
{
|
{
|
||||||
QJsonObject response;
|
QJsonObject response;
|
||||||
getJbiState(response);//0 ֹͣ״̬,1 <20><>ͣ״̬,2 <20><>ͣ״̬,3 <20><><EFBFBD><EFBFBD>״̬,4 <20><><EFBFBD><EFBFBD>״̬
|
getJbiState(response);//0 停止状态,1 暂停状态,2 急停状态,3 运行状态,4 错误状态
|
||||||
QString result;
|
QString result;
|
||||||
bool x = processResponse_getJbiState(response, result);
|
bool x = processResponse_getJbiState(response, result);
|
||||||
//qDebug() << "getJbiState:" << result;
|
//qDebug() << "getJbiState:" << result;
|
||||||
@ -302,7 +302,7 @@ void RobotController::getPoint()
|
|||||||
m_iCurrentJbiJobLine = 0;
|
m_iCurrentJbiJobLine = 0;
|
||||||
m_iFileCounter = 0;
|
m_iFileCounter = 0;
|
||||||
|
|
||||||
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>źţ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֹͣ<EFBFBD>ɼ<EFBFBD>
|
//发射信号,相机停止采集
|
||||||
emit hsiRecordSignal(-1);
|
emit hsiRecordSignal(-1);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -321,12 +321,12 @@ void RobotController::getPoint()
|
|||||||
m_iFileCounter++;
|
m_iFileCounter++;
|
||||||
|
|
||||||
qDebug() << "Changed! CurrentJobLine:" << m_iCurrentJbiJobLine_tmp;
|
qDebug() << "Changed! CurrentJobLine:" << m_iCurrentJbiJobLine_tmp;
|
||||||
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>źţ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֹͣ<EFBFBD>ɼ<EFBFBD>
|
//发射信号,相机停止采集
|
||||||
emit hsiRecordSignal(-1);
|
emit hsiRecordSignal(-1);
|
||||||
|
|
||||||
m_iCurrentJbiJobLine = m_iCurrentJbiJobLine_tmp;
|
m_iCurrentJbiJobLine = m_iCurrentJbiJobLine_tmp;
|
||||||
|
|
||||||
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>źţ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD>ɼ<EFBFBD>
|
//发射信号,相机开始采集
|
||||||
emit hsiRecordSignal(m_iFileCounter);
|
emit hsiRecordSignal(m_iFileCounter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -421,7 +421,7 @@ bool RobotController::getRobotMode(QJsonObject& re)
|
|||||||
bool RobotController::checkJbiExist(const QString& jbiFilename, QJsonObject& re)
|
bool RobotController::checkJbiExist(const QString& jbiFilename, QJsonObject& re)
|
||||||
{
|
{
|
||||||
QJsonObject paramsRunJbi;
|
QJsonObject paramsRunJbi;
|
||||||
paramsRunJbi["filename"] = jbiFilename;//ʹ<EFBFBD>ö<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ṹ
|
paramsRunJbi["filename"] = jbiFilename;//使用对象结构
|
||||||
|
|
||||||
sendCommand("checkJbiExist", paramsRunJbi);
|
sendCommand("checkJbiExist", paramsRunJbi);
|
||||||
socket->waitForReadyRead(m_iTimeout);
|
socket->waitForReadyRead(m_iTimeout);
|
||||||
@ -432,7 +432,7 @@ bool RobotController::checkJbiExist(const QString& jbiFilename, QJsonObject& re)
|
|||||||
bool RobotController::setServoStatus(int status, QJsonObject& re)
|
bool RobotController::setServoStatus(int status, QJsonObject& re)
|
||||||
{
|
{
|
||||||
QJsonObject params_set_servo_status;
|
QJsonObject params_set_servo_status;
|
||||||
params_set_servo_status["status"] = status;//ʹ<EFBFBD>ö<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ṹ
|
params_set_servo_status["status"] = status;//使用对象结构
|
||||||
|
|
||||||
sendCommand("set_servo_status", params_set_servo_status);
|
sendCommand("set_servo_status", params_set_servo_status);
|
||||||
socket->waitForReadyRead(m_iTimeout);
|
socket->waitForReadyRead(m_iTimeout);
|
||||||
@ -443,7 +443,7 @@ bool RobotController::setServoStatus(int status, QJsonObject& re)
|
|||||||
bool RobotController::runJbi(const QString& jbiFilename, QJsonObject& re, bool isRecordHsi)
|
bool RobotController::runJbi(const QString& jbiFilename, QJsonObject& re, bool isRecordHsi)
|
||||||
{
|
{
|
||||||
QJsonObject paramsRunJbi;
|
QJsonObject paramsRunJbi;
|
||||||
paramsRunJbi["filename"] = jbiFilename;//ʹ<EFBFBD>ö<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ṹ
|
paramsRunJbi["filename"] = jbiFilename;//使用对象结构
|
||||||
|
|
||||||
sendCommand("runJbi", paramsRunJbi);
|
sendCommand("runJbi", paramsRunJbi);
|
||||||
socket->waitForReadyRead(m_iTimeout);
|
socket->waitForReadyRead(m_iTimeout);
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <qdialog.h>
|
#include <qdialog.h>
|
||||||
#include <QTcpSocket>
|
#include <QTcpSocket>
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
@ -26,33 +26,33 @@ struct ECData
|
|||||||
quint32 msgSize;
|
quint32 msgSize;
|
||||||
quint64 timeStamp;
|
quint64 timeStamp;
|
||||||
quint8 auto_cycle;
|
quint8 auto_cycle;
|
||||||
double machinePos[8];//<EFBFBD>ؽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
double machinePos[8];//关节坐标
|
||||||
double machinePose[6];//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
double machinePose[6];//基座坐标
|
||||||
double machineUserPose[6];//<EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
double machineUserPose[6];//用户坐标
|
||||||
double torque[8];//<EFBFBD>ؽڶ<EFBFBD><EFBFBD><EFBFBD>ذٷֱ<EFBFBD>
|
double torque[8];//关节额定力矩百分比
|
||||||
quint32 robotState;//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬
|
quint32 robotState;//机器人状态
|
||||||
quint32 servoReady;//<EFBFBD>ŷ<EFBFBD>ʹ<EFBFBD><EFBFBD>״̬
|
quint32 servoReady;//伺服使能状态
|
||||||
quint32 can_motor_run;//ͬ<EFBFBD><EFBFBD>״̬
|
quint32 can_motor_run;//同步状态
|
||||||
qint32 motor_speed[8];//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><EFBFBD>
|
qint32 motor_speed[8];//各轴电机转速
|
||||||
quint32 robotMode;//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ
|
quint32 robotMode;//机器人模式
|
||||||
double analog_ioInput[3];//ģ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
double analog_ioInput[3];//模拟量输入口数据
|
||||||
double analog_ioOutput[5];//ģ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
double analog_ioOutput[5];//模拟量输出口数据
|
||||||
quint64 digital_ioInput;//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵĶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ
|
quint64 digital_ioInput;//数字量输入口数据的二进制形式
|
||||||
quint64 digital_ioOutput;//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵĶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ
|
quint64 digital_ioOutput;//数字量输出口数据的二进制形式
|
||||||
quint8 collision;//<EFBFBD><EFBFBD>ײ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬
|
quint8 collision;//碰撞报警状态
|
||||||
double machineFlangePose[6];//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD>µķ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD>
|
double machineFlangePose[6];//基座坐标系下的法兰盘中心位姿
|
||||||
double machineUserFlangePose[6];//<EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD>µķ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD>
|
double machineUserFlangePose[6];//用户坐标系下的法兰盘中心位姿
|
||||||
quint8 emergencyStopState;//<EFBFBD><EFBFBD>ǰ<EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڼ<EFBFBD>ͣ״̬
|
quint8 emergencyStopState;//当前是否处于急停状态
|
||||||
double tcpSpeed;//tcp<EFBFBD>˶<EFBFBD><EFBFBD>ٶ<EFBFBD>
|
double tcpSpeed;//tcp运动速度
|
||||||
double joIntSpeed[8];//<EFBFBD>ؽ<EFBFBD><EFBFBD>˶<EFBFBD><EFBFBD>¸<EFBFBD><EFBFBD>ؽ<EFBFBD><EFBFBD>˶<EFBFBD><EFBFBD>ٶ<EFBFBD>
|
double joIntSpeed[8];//关节运动下各关节运动速度
|
||||||
double tcpAcc;//tcp<EFBFBD><EFBFBD><EFBFBD>ٶ<EFBFBD>
|
double tcpAcc;//tcp加速度
|
||||||
double joIntAcc[8];//<EFBFBD>ؽ<EFBFBD><EFBFBD>˶<EFBFBD><EFBFBD>¸<EFBFBD><EFBFBD>ؽڼ<EFBFBD><EFBFBD>ٶ<EFBFBD>
|
double joIntAcc[8];//关节运动下各关节加速度
|
||||||
double joIntTemperature[6];//<EFBFBD>¶<EFBFBD>
|
double joIntTemperature[6];//温度
|
||||||
double joIntTorque[6];//<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ť<EFBFBD><EFBFBD>
|
double joIntTorque[6];//输出扭矩
|
||||||
double extJoIntTorques[6];//<EFBFBD>ⲿ<EFBFBD>ؽ<EFBFBD>Ť<EFBFBD><EFBFBD>ֵ
|
double extJoIntTorques[6];//外部关节扭矩值
|
||||||
double exTcpForceIntool[6];//<EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD>µ<EFBFBD><EFBFBD>ⲿĩ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>/<2F><><EFBFBD>ع<EFBFBD><D8B9><EFBFBD>ֵ
|
double exTcpForceIntool[6];//当前工具坐标系下的外部末端力/力矩估计值
|
||||||
quint8 dragState;//<EFBFBD>϶<EFBFBD>ʹ<EFBFBD><EFBFBD>״̬
|
quint8 dragState;//拖动使能状态
|
||||||
quint8 sensor_connected_state;//<EFBFBD><EFBFBD><EFBFBD>ش<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬
|
quint8 sensor_connected_state;//力控传感器连接状态
|
||||||
quint8 reserved;
|
quint8 reserved;
|
||||||
quint32 matchingWord;
|
quint32 matchingWord;
|
||||||
};
|
};
|
||||||
@ -98,10 +98,10 @@ public:
|
|||||||
bool processResponse_getJbiState(QJsonObject response, QString& result);
|
bool processResponse_getJbiState(QJsonObject response, QString& result);
|
||||||
|
|
||||||
bool getRobotPose(QJsonObject& re);
|
bool getRobotPose(QJsonObject& re);
|
||||||
bool getRobotState(QJsonObject& re);//ֹͣ״̬ 0<><30><EFBFBD><EFBFBD>ͣ״̬ 1<><31><EFBFBD><EFBFBD>ͣ״̬ 2<><32><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬ 3<><33><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬ 4<><34><EFBFBD><EFBFBD>ײ״̬ 5
|
bool getRobotState(QJsonObject& re);//停止状态 0,暂停状态 1,急停状态 2,运行状态 3,报警状态 4,碰撞状态 5
|
||||||
bool getJbiState(QJsonObject& re);//0 ֹͣ״̬,1 <20><>ͣ״̬,2 <20><>ͣ״̬,3 <20><><EFBFBD><EFBFBD>״̬,4 <20><><EFBFBD><EFBFBD>״̬
|
bool getJbiState(QJsonObject& re);//0 停止状态,1 暂停状态,2 急停状态,3 运行状态,4 错误状态
|
||||||
bool getCurrentJobLine(QJsonObject& re);
|
bool getCurrentJobLine(QJsonObject& re);
|
||||||
bool getRobotMode(QJsonObject& re);//ʾ<EFBFBD><EFBFBD>ģʽ 0<><30><EFBFBD>Զ<EFBFBD>ģʽ 1<><31>Զ<EFBFBD><D4B6>ģʽ 2
|
bool getRobotMode(QJsonObject& re);//示教模式 0,自动模式 1,远程模式 2
|
||||||
bool checkJbiExist(const QString& jbiFilename, QJsonObject& re);
|
bool checkJbiExist(const QString& jbiFilename, QJsonObject& re);
|
||||||
bool setServoStatus(int status, QJsonObject& re);
|
bool setServoStatus(int status, QJsonObject& re);
|
||||||
bool runJbi(const QString& jbiFilename, QJsonObject& re, bool isRecordHsi);
|
bool runJbi(const QString& jbiFilename, QJsonObject& re, bool isRecordHsi);
|
||||||
|
|||||||
240
HPPA/SingleLensReflexCamera.ui
Normal file
240
HPPA/SingleLensReflexCamera.ui
Normal file
@ -0,0 +1,240 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>SingleLensReflexCameraClass</class>
|
||||||
|
<widget class="QDialog" name="SingleLensReflexCameraClass">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>855</width>
|
||||||
|
<height>481</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>SingleLensReflexCamera</string>
|
||||||
|
</property>
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true">QGroupBox
|
||||||
|
{
|
||||||
|
border: 12px solid transparent;
|
||||||
|
/*border-top: 12px solid transparent;
|
||||||
|
border-right: 0px solid transparent;
|
||||||
|
border-bottom: 0px solid transparent;
|
||||||
|
border-left: 0px solid transparent;*/
|
||||||
|
color: #ACCDFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
QPushButton
|
||||||
|
{
|
||||||
|
/*width: 172px;
|
||||||
|
height: 56px;*/
|
||||||
|
font: 19pt "新宋体";
|
||||||
|
background-color: qlineargradient(
|
||||||
|
spread:pad,
|
||||||
|
x1:0.5, y1:0, x2:0.5, y2:1,
|
||||||
|
stop:0 #283D86,
|
||||||
|
stop:1 #0F1A40
|
||||||
|
);
|
||||||
|
color: white;
|
||||||
|
border: none;
|
||||||
|
padding: 8px 16px;
|
||||||
|
border-radius: 4px;
|
||||||
|
}
|
||||||
|
QPushButton:hover
|
||||||
|
{
|
||||||
|
background-color: qlineargradient(
|
||||||
|
spread:pad,
|
||||||
|
x1:0, y1:0, x2:1, y2:0,
|
||||||
|
stop:0 #3A4875,
|
||||||
|
stop:1 #5F6B91
|
||||||
|
);
|
||||||
|
}
|
||||||
|
/* 按下时的效果 */
|
||||||
|
QPushButton:pressed
|
||||||
|
{
|
||||||
|
background-color: qlineargradient(
|
||||||
|
spread:pad,
|
||||||
|
x1:0, y1:0, x2:1, y2:0,
|
||||||
|
stop:0 #1A254F,
|
||||||
|
stop:1 #3A466B
|
||||||
|
);
|
||||||
|
/* 可选:添加下压效果 */
|
||||||
|
padding-top: 9px;
|
||||||
|
padding-bottom: 7px;
|
||||||
|
}</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<item row="0" column="1">
|
||||||
|
<spacer name="verticalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>18</width>
|
||||||
|
<height>100</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<spacer name="horizontalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>135</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="openSLRCamera_btn">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>打 开</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="closeSLRCamera_btn">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>关 闭</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="2">
|
||||||
|
<spacer name="horizontalSpacer_2">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>135</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="1">
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true">QLabel {
|
||||||
|
color: rgb(255, 255, 255);
|
||||||
|
}</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>数据路径</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLineEdit" name="dataFolderLineEdit">
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true">QLineEdit {
|
||||||
|
background-color: #142D7F;
|
||||||
|
color: #e6eeff;
|
||||||
|
border: 1px solid #2f6bff;
|
||||||
|
border-radius: 6px;
|
||||||
|
padding: 4px 8px;
|
||||||
|
min-width: 70px;
|
||||||
|
min-height: 20px;
|
||||||
|
font-size: 13px;
|
||||||
|
}</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>./CapturedImages</string>
|
||||||
|
</property>
|
||||||
|
<property name="readOnly">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="dataFolderBtn">
|
||||||
|
<property name="text">
|
||||||
|
<string>...</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="1">
|
||||||
|
<spacer name="verticalSpacer_3">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>18</width>
|
||||||
|
<height>100</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="takePhoto_btn">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>拍 摄</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="stopTakePhoto_btn">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>停 拍</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
<zorder>dataFolderLineEdit</zorder>
|
||||||
|
<zorder>dataFolderBtn</zorder>
|
||||||
|
<zorder>label</zorder>
|
||||||
|
<zorder>openSLRCamera_btn</zorder>
|
||||||
|
<zorder>layoutWidget</zorder>
|
||||||
|
</widget>
|
||||||
|
<layoutdefault spacing="6" margin="11"/>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
||||||
918
HPPA/SingleLensReflexCameraWindow.cpp
Normal file
918
HPPA/SingleLensReflexCameraWindow.cpp
Normal file
@ -0,0 +1,918 @@
|
|||||||
|
#include "SingleLensReflexCameraWindow.h"
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QCoreApplication>
|
||||||
|
#include <QBuffer>
|
||||||
|
|
||||||
|
// 全局变量用于回调函数访问
|
||||||
|
static SingleLensReflexCameraOperation* g_cameraOperation = nullptr;
|
||||||
|
|
||||||
|
SingleLensReflexCameraWindow::SingleLensReflexCameraWindow(QWidget* parent)
|
||||||
|
: QDialog(parent)
|
||||||
|
, m_isCapturing(false)
|
||||||
|
{
|
||||||
|
ui.setupUi(this);
|
||||||
|
|
||||||
|
m_SLRCameraThread = new QThread();
|
||||||
|
m_SingleLensReflexCameraOperation = new SingleLensReflexCameraOperation();
|
||||||
|
m_SingleLensReflexCameraOperation->moveToThread(m_SLRCameraThread);
|
||||||
|
m_SLRCameraThread->start();
|
||||||
|
|
||||||
|
// 基本连接
|
||||||
|
connect(ui.openSLRCamera_btn, &QPushButton::clicked, this, &SingleLensReflexCameraWindow::openSLRCamera);
|
||||||
|
connect(this, &SingleLensReflexCameraWindow::openSLRCameraSignal, m_SingleLensReflexCameraOperation, &SingleLensReflexCameraOperation::OpenSLRCamera);
|
||||||
|
connect(ui.closeSLRCamera_btn, &QPushButton::clicked, this, &SingleLensReflexCameraWindow::closeSLRCamera);
|
||||||
|
connect(this, &SingleLensReflexCameraWindow::closeSLRCameraSignal, m_SingleLensReflexCameraOperation, &SingleLensReflexCameraOperation::CloseSLRCamera);
|
||||||
|
|
||||||
|
connect(ui.takePhoto_btn, &QPushButton::clicked, this, &SingleLensReflexCameraWindow::takePhoto);
|
||||||
|
connect(this, &SingleLensReflexCameraWindow::takePhotoSignal, m_SingleLensReflexCameraOperation, &SingleLensReflexCameraOperation::takePhoto);
|
||||||
|
connect(ui.stopTakePhoto_btn, &QPushButton::clicked, this, &SingleLensReflexCameraWindow::stopTakePhoto);
|
||||||
|
connect(this, &SingleLensReflexCameraWindow::stopTakePhotoSignal, m_SingleLensReflexCameraOperation, &SingleLensReflexCameraOperation::stopTakePhoto);
|
||||||
|
|
||||||
|
connect(m_SingleLensReflexCameraOperation, &SingleLensReflexCameraOperation::CamOpenedSignal, this, &SingleLensReflexCameraWindow::onCamOpened);
|
||||||
|
connect(m_SingleLensReflexCameraOperation, &SingleLensReflexCameraOperation::CamClosedSignal, this, &SingleLensReflexCameraWindow::onCamClosed);
|
||||||
|
|
||||||
|
connect(m_SingleLensReflexCameraOperation, &SingleLensReflexCameraOperation::PlotSignal, this, &SingleLensReflexCameraWindow::PlotSLRImageSignal);
|
||||||
|
connect(m_SingleLensReflexCameraOperation, &SingleLensReflexCameraOperation::CamClosedSignal, this, &SingleLensReflexCameraWindow::SLRCamClosedSignal);
|
||||||
|
|
||||||
|
connect(this->ui.dataFolderBtn, SIGNAL(clicked()), this, SLOT(onSelectDataFolder()));
|
||||||
|
|
||||||
|
// 新增信号连接
|
||||||
|
connect(m_SingleLensReflexCameraOperation, &SingleLensReflexCameraOperation::ImageCapturedSignal, this, &SingleLensReflexCameraWindow::onImageCaptured);
|
||||||
|
connect(m_SingleLensReflexCameraOperation, &SingleLensReflexCameraOperation::ErrorSignal, this, &SingleLensReflexCameraWindow::onError);
|
||||||
|
|
||||||
|
// 实时取景信号连接
|
||||||
|
connect(m_SingleLensReflexCameraOperation, &SingleLensReflexCameraOperation::LiveViewImageReady, this, &SingleLensReflexCameraWindow::LiveViewImageReady, Qt::QueuedConnection);
|
||||||
|
connect(m_SingleLensReflexCameraOperation, &SingleLensReflexCameraOperation::LiveViewStarted, this, &SingleLensReflexCameraWindow::LiveViewStarted);
|
||||||
|
connect(m_SingleLensReflexCameraOperation, &SingleLensReflexCameraOperation::LiveViewStopped, this, &SingleLensReflexCameraWindow::LiveViewStopped);
|
||||||
|
|
||||||
|
// 拍照状态信号连接
|
||||||
|
connect(m_SingleLensReflexCameraOperation, &SingleLensReflexCameraOperation::CaptureStartedSignal, this, &SingleLensReflexCameraWindow::onCaptureStarted);
|
||||||
|
connect(m_SingleLensReflexCameraOperation, &SingleLensReflexCameraOperation::CaptureStoppedSignal, this, &SingleLensReflexCameraWindow::onCaptureStopped);
|
||||||
|
|
||||||
|
// 拍照控制信号连接
|
||||||
|
connect(this, &SingleLensReflexCameraWindow::startCaptureSignal, m_SingleLensReflexCameraOperation, &SingleLensReflexCameraOperation::startCapture);
|
||||||
|
connect(this, &SingleLensReflexCameraWindow::stopCaptureSignal, m_SingleLensReflexCameraOperation, &SingleLensReflexCameraOperation::stopCapture);
|
||||||
|
connect(this, &SingleLensReflexCameraWindow::captureOnceSignal, m_SingleLensReflexCameraOperation, &SingleLensReflexCameraOperation::captureOnce);
|
||||||
|
|
||||||
|
// 初始化按钮状态
|
||||||
|
ui.closeSLRCamera_btn->setEnabled(false);
|
||||||
|
|
||||||
|
// 初始化数据保存路径显示(从 AppSettings 恢复或使用默认)
|
||||||
|
ui.dataFolderLineEdit->setText(AppSettings::instance().slrDataFolder());
|
||||||
|
}
|
||||||
|
|
||||||
|
SingleLensReflexCameraWindow::~SingleLensReflexCameraWindow()
|
||||||
|
{
|
||||||
|
// 先停止拍照
|
||||||
|
if (m_SingleLensReflexCameraOperation->getRecordStatus())
|
||||||
|
{
|
||||||
|
m_SingleLensReflexCameraOperation->CloseSLRCamera();
|
||||||
|
}
|
||||||
|
|
||||||
|
m_SLRCameraThread->quit();
|
||||||
|
m_SLRCameraThread->wait();
|
||||||
|
delete m_SingleLensReflexCameraOperation;
|
||||||
|
m_SingleLensReflexCameraOperation = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SingleLensReflexCameraWindow::onSelectDataFolder()
|
||||||
|
{
|
||||||
|
QString dir = QFileDialog::getExistingDirectory(this,
|
||||||
|
QString::fromLocal8Bit("选择数据保存路径"),
|
||||||
|
ui.dataFolderLineEdit->text());
|
||||||
|
|
||||||
|
if (!dir.isEmpty())
|
||||||
|
{
|
||||||
|
ui.dataFolderLineEdit->setText(dir);
|
||||||
|
|
||||||
|
m_SingleLensReflexCameraOperation->setSavePath(dir);
|
||||||
|
|
||||||
|
// 保存路径到 AppSettings
|
||||||
|
AppSettings::instance().setSlrDataFolder(dir);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SingleLensReflexCameraWindow::openSLRCamera()
|
||||||
|
{
|
||||||
|
if (!m_SingleLensReflexCameraOperation->getRecordStatus())
|
||||||
|
{
|
||||||
|
emit openSLRCameraSignal();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SingleLensReflexCameraWindow::takePhoto()
|
||||||
|
{
|
||||||
|
if (m_SingleLensReflexCameraOperation->getRecordStatus())
|
||||||
|
{
|
||||||
|
emit takePhotoSignal();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SingleLensReflexCameraWindow::stopTakePhoto()
|
||||||
|
{
|
||||||
|
if (m_SingleLensReflexCameraOperation->getRecordStatus())
|
||||||
|
{
|
||||||
|
emit stopTakePhotoSignal();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SingleLensReflexCameraWindow::onCamOpened()
|
||||||
|
{
|
||||||
|
ui.openSLRCamera_btn->setEnabled(false);
|
||||||
|
ui.closeSLRCamera_btn->setEnabled(true);
|
||||||
|
ui.openSLRCamera_btn->setText(QString::fromLocal8Bit("已打开"));
|
||||||
|
}
|
||||||
|
|
||||||
|
void SingleLensReflexCameraWindow::closeSLRCamera()
|
||||||
|
{
|
||||||
|
emit closeSLRCameraSignal();
|
||||||
|
//m_SingleLensReflexCameraOperation->CloseSLRCamera();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SingleLensReflexCameraWindow::onCamClosed()
|
||||||
|
{
|
||||||
|
ui.openSLRCamera_btn->setEnabled(true);
|
||||||
|
ui.closeSLRCamera_btn->setEnabled(false);
|
||||||
|
ui.openSLRCamera_btn->setText(QString::fromLocal8Bit("打 开"));
|
||||||
|
m_isCapturing = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SingleLensReflexCameraWindow::onCaptureStarted()
|
||||||
|
{
|
||||||
|
ui.takePhoto_btn->setEnabled(false);
|
||||||
|
ui.stopTakePhoto_btn->setEnabled(true);
|
||||||
|
|
||||||
|
m_btnOldText = ui.takePhoto_btn->text();
|
||||||
|
ui.takePhoto_btn->setText(QString::fromLocal8Bit("采集中"));
|
||||||
|
}
|
||||||
|
|
||||||
|
void SingleLensReflexCameraWindow::onCaptureStopped()
|
||||||
|
{
|
||||||
|
ui.takePhoto_btn->setEnabled(true);
|
||||||
|
ui.stopTakePhoto_btn->setEnabled(false);
|
||||||
|
ui.takePhoto_btn->setText(m_btnOldText);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SingleLensReflexCameraWindow::onImageCaptured(const QString& filePath)
|
||||||
|
{
|
||||||
|
std::cout << "Image captured: " << filePath.toStdString() << std::endl;
|
||||||
|
// 可以在这里更新UI显示最新拍摄的图片
|
||||||
|
}
|
||||||
|
|
||||||
|
void SingleLensReflexCameraWindow::onError(const QString& errorMsg)
|
||||||
|
{
|
||||||
|
QMessageBox::warning(this, QString::fromLocal8Bit("相机错误"), errorMsg);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SingleLensReflexCameraWindow::onStartCapture()
|
||||||
|
{
|
||||||
|
if (!m_isCapturing)
|
||||||
|
{
|
||||||
|
m_isCapturing = true;
|
||||||
|
emit startCaptureSignal();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SingleLensReflexCameraWindow::onStopCapture()
|
||||||
|
{
|
||||||
|
if (m_isCapturing)
|
||||||
|
{
|
||||||
|
m_isCapturing = false;
|
||||||
|
emit stopCaptureSignal();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SingleLensReflexCameraWindow::onCaptureOnce()
|
||||||
|
{
|
||||||
|
emit captureOnceSignal();
|
||||||
|
}
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
// SingleLensReflexCameraOperation 实现
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
SingleLensReflexCameraOperation::SingleLensReflexCameraOperation()
|
||||||
|
{
|
||||||
|
m_func = nullptr;
|
||||||
|
m_isRecord = false;
|
||||||
|
m_camera = nullptr;
|
||||||
|
m_isSDKInitialized = false;
|
||||||
|
m_isSessionOpen = false;
|
||||||
|
m_isLiveViewActive = false;
|
||||||
|
m_imageCounter = 0;
|
||||||
|
|
||||||
|
// 设置保存路径(从 AppSettings 获取,如果为空则使用默认的 CapturedImages 目录)
|
||||||
|
m_savePath = AppSettings::instance().slrDataFolder();
|
||||||
|
|
||||||
|
// 创建保存目录
|
||||||
|
QDir dir;
|
||||||
|
if (!dir.exists(m_savePath))
|
||||||
|
{
|
||||||
|
dir.mkpath(m_savePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 创建定时器
|
||||||
|
m_captureTimer = new QTimer(this);
|
||||||
|
connect(m_captureTimer, &QTimer::timeout, this, &SingleLensReflexCameraOperation::onCaptureTimer);
|
||||||
|
|
||||||
|
m_liveViewTimer = new QTimer(this);
|
||||||
|
connect(m_liveViewTimer, &QTimer::timeout, this, &SingleLensReflexCameraOperation::onLiveViewTimer);
|
||||||
|
|
||||||
|
g_cameraOperation = this;
|
||||||
|
}
|
||||||
|
|
||||||
|
SingleLensReflexCameraOperation::~SingleLensReflexCameraOperation()
|
||||||
|
{
|
||||||
|
if (m_isRecord)
|
||||||
|
{
|
||||||
|
CloseSLRCamera();
|
||||||
|
}
|
||||||
|
g_cameraOperation = nullptr;
|
||||||
|
|
||||||
|
// 销毁定时器
|
||||||
|
if (m_captureTimer)
|
||||||
|
{
|
||||||
|
m_captureTimer->stop();
|
||||||
|
m_captureTimer->deleteLater();
|
||||||
|
m_captureTimer = nullptr;
|
||||||
|
}
|
||||||
|
if (m_liveViewTimer)
|
||||||
|
{
|
||||||
|
m_liveViewTimer->stop();
|
||||||
|
m_liveViewTimer->deleteLater();
|
||||||
|
m_liveViewTimer = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SingleLensReflexCameraOperation::setSavePath(const QString& path)
|
||||||
|
{
|
||||||
|
m_savePath = path;
|
||||||
|
if (!m_savePath.endsWith('/') && !m_savePath.endsWith('\\'))
|
||||||
|
{
|
||||||
|
m_savePath += '/';
|
||||||
|
}
|
||||||
|
|
||||||
|
QDir dir;
|
||||||
|
if (!dir.exists(m_savePath))
|
||||||
|
{
|
||||||
|
dir.mkpath(m_savePath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QImage SingleLensReflexCameraOperation::getCurrentLiveViewImage()
|
||||||
|
{
|
||||||
|
QMutexLocker locker(&m_liveViewMutex);
|
||||||
|
return m_liveViewImage.copy();
|
||||||
|
}
|
||||||
|
|
||||||
|
EdsError SingleLensReflexCameraOperation::initializeSDK()
|
||||||
|
{
|
||||||
|
EdsError err = EdsInitializeSDK();
|
||||||
|
if (err == EDS_ERR_OK)
|
||||||
|
{
|
||||||
|
m_isSDKInitialized = true;
|
||||||
|
std::cout << "EDSDK initialized successfully" << std::endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::cout << "Failed to initialize EDSDK, error: " << err << std::endl;
|
||||||
|
}
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
EdsError SingleLensReflexCameraOperation::terminateSDK()
|
||||||
|
{
|
||||||
|
if (m_isSDKInitialized)
|
||||||
|
{
|
||||||
|
EdsError err = EdsTerminateSDK();
|
||||||
|
m_isSDKInitialized = false;
|
||||||
|
std::cout << "EDSDK terminated" << std::endl;
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
return EDS_ERR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
EdsError SingleLensReflexCameraOperation::openCamera()
|
||||||
|
{
|
||||||
|
EdsError err = EDS_ERR_OK;
|
||||||
|
EdsCameraListRef cameraList = nullptr;
|
||||||
|
EdsUInt32 count = 0;
|
||||||
|
|
||||||
|
// 获取相机列表
|
||||||
|
err = EdsGetCameraList(&cameraList);
|
||||||
|
if (err != EDS_ERR_OK)
|
||||||
|
{
|
||||||
|
std::cout << "Failed to get camera list, error: " << err << std::endl;
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取相机数量
|
||||||
|
err = EdsGetChildCount(cameraList, &count);
|
||||||
|
if (err != EDS_ERR_OK || count == 0)
|
||||||
|
{
|
||||||
|
std::cout << "No camera found" << std::endl;
|
||||||
|
EdsRelease(cameraList);
|
||||||
|
return EDS_ERR_DEVICE_NOT_FOUND;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cout << "Found " << count << " camera(s)" << std::endl;
|
||||||
|
|
||||||
|
// 获取第一台相机
|
||||||
|
err = EdsGetChildAtIndex(cameraList, 0, &m_camera);
|
||||||
|
if (err != EDS_ERR_OK)
|
||||||
|
{
|
||||||
|
std::cout << "Failed to get camera, error: " << err << std::endl;
|
||||||
|
EdsRelease(cameraList);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 释放相机列表
|
||||||
|
EdsRelease(cameraList);
|
||||||
|
|
||||||
|
// 设置事件回调
|
||||||
|
err = EdsSetObjectEventHandler(m_camera, kEdsObjectEvent_All, handleObjectEvent, this);
|
||||||
|
if (err != EDS_ERR_OK)
|
||||||
|
{
|
||||||
|
std::cout << "Failed to set object event handler, error: " << err << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
err = EdsSetPropertyEventHandler(m_camera, kEdsPropertyEvent_All, handlePropertyEvent, this);
|
||||||
|
if (err != EDS_ERR_OK)
|
||||||
|
{
|
||||||
|
std::cout << "Failed to set property event handler, error: " << err << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
err = EdsSetCameraStateEventHandler(m_camera, kEdsStateEvent_All, handleStateEvent, this);
|
||||||
|
if (err != EDS_ERR_OK)
|
||||||
|
{
|
||||||
|
std::cout << "Failed to set state event handler, error: " << err << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 打开会话
|
||||||
|
err = EdsOpenSession(m_camera);
|
||||||
|
if (err != EDS_ERR_OK)
|
||||||
|
{
|
||||||
|
std::cout << "Failed to open session, error: " << err << std::endl;
|
||||||
|
EdsRelease(m_camera);
|
||||||
|
m_camera = nullptr;
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_isSessionOpen = true;
|
||||||
|
std::cout << "Camera session opened successfully" << std::endl;
|
||||||
|
|
||||||
|
return EDS_ERR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
EdsError SingleLensReflexCameraOperation::closeCamera()
|
||||||
|
{
|
||||||
|
EdsError err = EDS_ERR_OK;
|
||||||
|
|
||||||
|
if (m_isSessionOpen && m_camera != nullptr)
|
||||||
|
{
|
||||||
|
err = EdsCloseSession(m_camera);
|
||||||
|
m_isSessionOpen = false;
|
||||||
|
std::cout << "Camera session closed" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_camera != nullptr)
|
||||||
|
{
|
||||||
|
EdsRelease(m_camera);
|
||||||
|
m_camera = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
EdsError SingleLensReflexCameraOperation::setupSaveToHost()
|
||||||
|
{
|
||||||
|
EdsError err = EDS_ERR_OK;
|
||||||
|
|
||||||
|
// 设置保存到PC
|
||||||
|
EdsUInt32 saveTo = kEdsSaveTo_Host;
|
||||||
|
err = EdsSetPropertyData(m_camera, kEdsPropID_SaveTo, 0, sizeof(saveTo), &saveTo);
|
||||||
|
if (err != EDS_ERR_OK)
|
||||||
|
{
|
||||||
|
std::cout << "Failed to set SaveTo property, error: " << err << std::endl;
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置PC容量(告诉相机PC有足够空间)
|
||||||
|
EdsCapacity capacity;
|
||||||
|
capacity.numberOfFreeClusters = 0x7FFFFFFF;
|
||||||
|
capacity.bytesPerSector = 0x1000;
|
||||||
|
capacity.reset = true;
|
||||||
|
err = EdsSetCapacity(m_camera, capacity);
|
||||||
|
if (err != EDS_ERR_OK)
|
||||||
|
{
|
||||||
|
std::cout << "Failed to set capacity, error: " << err << std::endl;
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cout << "Save to host configured successfully" << std::endl;
|
||||||
|
return EDS_ERR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
EdsError SingleLensReflexCameraOperation::startLiveView()
|
||||||
|
{
|
||||||
|
EdsError err = EDS_ERR_OK;
|
||||||
|
|
||||||
|
if (m_camera == nullptr || !m_isSessionOpen)
|
||||||
|
{
|
||||||
|
return EDS_ERR_DEVICE_NOT_FOUND;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取当前输出设备设置
|
||||||
|
EdsUInt32 device = 0;
|
||||||
|
err = EdsGetPropertyData(m_camera, kEdsPropID_Evf_OutputDevice, 0, sizeof(device), &device);
|
||||||
|
if (err != EDS_ERR_OK)
|
||||||
|
{
|
||||||
|
std::cout << "Failed to get Evf_OutputDevice, error: " << err << std::endl;
|
||||||
|
// 某些相机可能不支持获取,继续尝试设置
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置PC为实时取景输出设备
|
||||||
|
device |= kEdsEvfOutputDevice_PC;
|
||||||
|
err = EdsSetPropertyData(m_camera, kEdsPropID_Evf_OutputDevice, 0, sizeof(device), &device);
|
||||||
|
if (err != EDS_ERR_OK)
|
||||||
|
{
|
||||||
|
std::cout << "Failed to set Evf_OutputDevice, error: " << err << std::endl;
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_isLiveViewActive = true;
|
||||||
|
std::cout << "Live view started" << std::endl;
|
||||||
|
|
||||||
|
emit LiveViewStarted();
|
||||||
|
|
||||||
|
return EDS_ERR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
EdsError SingleLensReflexCameraOperation::stopLiveView()
|
||||||
|
{
|
||||||
|
EdsError err = EDS_ERR_OK;
|
||||||
|
|
||||||
|
if (m_camera == nullptr || !m_isSessionOpen)
|
||||||
|
{
|
||||||
|
m_isLiveViewActive = false;
|
||||||
|
return EDS_ERR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取当前输出设备设置
|
||||||
|
EdsUInt32 device = 0;
|
||||||
|
err = EdsGetPropertyData(m_camera, kEdsPropID_Evf_OutputDevice, 0, sizeof(device), &device);
|
||||||
|
if (err != EDS_ERR_OK)
|
||||||
|
{
|
||||||
|
std::cout << "Failed to get Evf_OutputDevice, error: " << err << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 从输出设备中移除PC
|
||||||
|
device &= ~kEdsEvfOutputDevice_PC;
|
||||||
|
err = EdsSetPropertyData(m_camera, kEdsPropID_Evf_OutputDevice, 0, sizeof(device), &device);
|
||||||
|
if (err != EDS_ERR_OK)
|
||||||
|
{
|
||||||
|
std::cout << "Failed to clear Evf_OutputDevice, error: " << err << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_isLiveViewActive = false;
|
||||||
|
std::cout << "Live view stopped" << std::endl;
|
||||||
|
|
||||||
|
emit LiveViewStopped();
|
||||||
|
|
||||||
|
return EDS_ERR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
EdsError SingleLensReflexCameraOperation::downloadEvfImage()
|
||||||
|
{
|
||||||
|
EdsError err = EDS_ERR_OK;
|
||||||
|
EdsStreamRef stream = nullptr;
|
||||||
|
EdsEvfImageRef evfImage = nullptr;
|
||||||
|
|
||||||
|
if (m_camera == nullptr || !m_isLiveViewActive)
|
||||||
|
{
|
||||||
|
return EDS_ERR_DEVICE_NOT_FOUND;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 创建内存流
|
||||||
|
err = EdsCreateMemoryStream(0, &stream);
|
||||||
|
if (err != EDS_ERR_OK)
|
||||||
|
{
|
||||||
|
std::cout << "Failed to create memory stream, error: " << err << std::endl;
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 创建实时取景图像引用
|
||||||
|
err = EdsCreateEvfImageRef(stream, &evfImage);
|
||||||
|
if (err != EDS_ERR_OK)
|
||||||
|
{
|
||||||
|
std::cout << "Failed to create evf image ref, error: " << err << std::endl;
|
||||||
|
EdsRelease(stream);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 下载实时取景图像
|
||||||
|
err = EdsDownloadEvfImage(m_camera, evfImage);
|
||||||
|
if (err != EDS_ERR_OK)
|
||||||
|
{
|
||||||
|
// EDS_ERR_OBJECT_NOTREADY 是正常的,表示图像还没准备好
|
||||||
|
if (err != EDS_ERR_OBJECT_NOTREADY)
|
||||||
|
{
|
||||||
|
std::cout << "Failed to download evf image, error: " << err << std::endl;
|
||||||
|
}
|
||||||
|
EdsRelease(evfImage);
|
||||||
|
EdsRelease(stream);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取流数据
|
||||||
|
EdsVoid* pData = nullptr;
|
||||||
|
EdsUInt64 length = 0;
|
||||||
|
|
||||||
|
err = EdsGetPointer(stream, &pData);
|
||||||
|
if (err != EDS_ERR_OK)
|
||||||
|
{
|
||||||
|
EdsRelease(evfImage);
|
||||||
|
EdsRelease(stream);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
err = EdsGetLength(stream, &length);
|
||||||
|
if (err != EDS_ERR_OK || length == 0)
|
||||||
|
{
|
||||||
|
EdsRelease(evfImage);
|
||||||
|
EdsRelease(stream);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 将JPEG数据转换为QImage
|
||||||
|
QImage image;
|
||||||
|
if (image.loadFromData(static_cast<const uchar*>(pData), static_cast<int>(length), "JPEG"))
|
||||||
|
{
|
||||||
|
QMutexLocker locker(&m_liveViewMutex);
|
||||||
|
m_liveViewImage = image.copy();
|
||||||
|
locker.unlock();
|
||||||
|
|
||||||
|
// 发送信号通知图像已准备好
|
||||||
|
emit LiveViewImageReady(image);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 释放资源
|
||||||
|
EdsRelease(evfImage);
|
||||||
|
EdsRelease(stream);
|
||||||
|
|
||||||
|
return EDS_ERR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
EdsError SingleLensReflexCameraOperation::takePicture()
|
||||||
|
{
|
||||||
|
EdsError err = EDS_ERR_OK;
|
||||||
|
|
||||||
|
if (m_camera == nullptr || !m_isSessionOpen)
|
||||||
|
{
|
||||||
|
return EDS_ERR_DEVICE_NOT_FOUND;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 按下快门
|
||||||
|
err = EdsSendCommand(m_camera, kEdsCameraCommand_PressShutterButton, kEdsCameraCommand_ShutterButton_Completely);
|
||||||
|
if (err != EDS_ERR_OK)
|
||||||
|
{
|
||||||
|
std::cout << "Failed to press shutter button, error: " << err << std::endl;
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 释放快门
|
||||||
|
err = EdsSendCommand(m_camera, kEdsCameraCommand_PressShutterButton, kEdsCameraCommand_ShutterButton_OFF);
|
||||||
|
if (err != EDS_ERR_OK)
|
||||||
|
{
|
||||||
|
std::cout << "Failed to release shutter button, error: " << err << std::endl;
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cout << "Picture taken" << std::endl;
|
||||||
|
return EDS_ERR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
EdsError SingleLensReflexCameraOperation::downloadImage(EdsDirectoryItemRef directoryItem)
|
||||||
|
{
|
||||||
|
EdsError err = EDS_ERR_OK;
|
||||||
|
EdsStreamRef stream = nullptr;
|
||||||
|
EdsDirectoryItemInfo dirItemInfo;
|
||||||
|
|
||||||
|
// 获取文件信息
|
||||||
|
err = EdsGetDirectoryItemInfo(directoryItem, &dirItemInfo);
|
||||||
|
if (err != EDS_ERR_OK)
|
||||||
|
{
|
||||||
|
std::cout << "Failed to get directory item info, error: " << err << std::endl;
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 生成保存文件名(使用时间戳)
|
||||||
|
QString timestamp = QDateTime::currentDateTime().toString("yyyyMMdd_HHmmss_zzz");
|
||||||
|
QString fileName = m_savePath + QDir::separator() + "IMG_" + timestamp + "_" + QString::fromLocal8Bit(dirItemInfo.szFileName);
|
||||||
|
|
||||||
|
std::cout << "Downloading image to: " << fileName.toStdString() << std::endl;
|
||||||
|
|
||||||
|
// 创建文件流
|
||||||
|
err = EdsCreateFileStream(fileName.toLocal8Bit().constData(),
|
||||||
|
kEdsFileCreateDisposition_CreateAlways,
|
||||||
|
kEdsAccess_ReadWrite, &stream);
|
||||||
|
if (err != EDS_ERR_OK)
|
||||||
|
{
|
||||||
|
std::cout << "Failed to create file stream, error: " << err << std::endl;
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 下载图像
|
||||||
|
err = EdsDownload(directoryItem, dirItemInfo.size, stream);
|
||||||
|
if (err != EDS_ERR_OK)
|
||||||
|
{
|
||||||
|
std::cout << "Failed to download image, error: " << err << std::endl;
|
||||||
|
EdsRelease(stream);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 通知下载完成
|
||||||
|
err = EdsDownloadComplete(directoryItem);
|
||||||
|
if (err != EDS_ERR_OK)
|
||||||
|
{
|
||||||
|
std::cout << "Failed to complete download, error: " << err << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 释放流
|
||||||
|
EdsRelease(stream);
|
||||||
|
|
||||||
|
std::cout << "Image downloaded successfully: " << fileName.toStdString() << std::endl;
|
||||||
|
|
||||||
|
// 发送信号通知图片已保存
|
||||||
|
emit ImageCapturedSignal(fileName);
|
||||||
|
|
||||||
|
return EDS_ERR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 静态回调函数实现
|
||||||
|
EdsError EDSCALLBACK SingleLensReflexCameraOperation::handleObjectEvent(EdsObjectEvent event, EdsBaseRef object, EdsVoid* context)
|
||||||
|
{
|
||||||
|
SingleLensReflexCameraOperation* pThis = static_cast<SingleLensReflexCameraOperation*>(context);
|
||||||
|
|
||||||
|
switch (event)
|
||||||
|
{
|
||||||
|
case kEdsObjectEvent_DirItemRequestTransfer:
|
||||||
|
// 有图像需要传输
|
||||||
|
if (pThis != nullptr)
|
||||||
|
{
|
||||||
|
pThis->downloadImage(object);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case kEdsObjectEvent_DirItemCreated:
|
||||||
|
std::cout << "New file created on camera" << std::endl;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 释放对象
|
||||||
|
if (object)
|
||||||
|
{
|
||||||
|
EdsRelease(object);
|
||||||
|
}
|
||||||
|
|
||||||
|
return EDS_ERR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
EdsError EDSCALLBACK SingleLensReflexCameraOperation::handlePropertyEvent(EdsPropertyEvent event, EdsPropertyID property, EdsUInt32 param, EdsVoid* context)
|
||||||
|
{
|
||||||
|
switch (event)
|
||||||
|
{
|
||||||
|
case kEdsPropertyEvent_PropertyChanged:
|
||||||
|
// 属性已更改
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return EDS_ERR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
EdsError EDSCALLBACK SingleLensReflexCameraOperation::handleStateEvent(EdsStateEvent event, EdsUInt32 parameter, EdsVoid* context)
|
||||||
|
{
|
||||||
|
SingleLensReflexCameraOperation* pThis = static_cast<SingleLensReflexCameraOperation*>(context);
|
||||||
|
|
||||||
|
switch (event)
|
||||||
|
{
|
||||||
|
case kEdsStateEvent_Shutdown:
|
||||||
|
std::cout << "Camera disconnected" << std::endl;
|
||||||
|
if (pThis != nullptr && pThis->m_isRecord)
|
||||||
|
{
|
||||||
|
pThis->CloseSLRCamera();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case kEdsStateEvent_WillSoonShutDown:
|
||||||
|
// 相机即将自动关机,延长计时器
|
||||||
|
if (pThis != nullptr && pThis->m_camera != nullptr)
|
||||||
|
{
|
||||||
|
EdsSendCommand(pThis->m_camera, kEdsCameraCommand_ExtendShutDownTimer, 0);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return EDS_ERR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SingleLensReflexCameraOperation::OpenSLRCamera()
|
||||||
|
{
|
||||||
|
std::cout << "SingleLensReflexCameraOperation::OpenSLRCamera, 打开单反相机" << std::endl;
|
||||||
|
|
||||||
|
EdsError err = EDS_ERR_OK;
|
||||||
|
|
||||||
|
// 初始化SDK
|
||||||
|
err = initializeSDK();
|
||||||
|
if (err != EDS_ERR_OK)
|
||||||
|
{
|
||||||
|
emit ErrorSignal(QString::fromLocal8Bit("初始化SDK失败,错误码: %1").arg(err));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 打开相机
|
||||||
|
err = openCamera();
|
||||||
|
if (err != EDS_ERR_OK)
|
||||||
|
{
|
||||||
|
terminateSDK();
|
||||||
|
emit ErrorSignal(QString::fromLocal8Bit("打开相机失败,错误码: %1").arg(err));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置保存到PC
|
||||||
|
err = setupSaveToHost();
|
||||||
|
if (err != EDS_ERR_OK)
|
||||||
|
{
|
||||||
|
closeCamera();
|
||||||
|
terminateSDK();
|
||||||
|
emit ErrorSignal(QString::fromLocal8Bit("设置保存位置失败,错误码: %1").arg(err));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 启动实时取景
|
||||||
|
err = startLiveView();
|
||||||
|
if (err != EDS_ERR_OK)
|
||||||
|
{
|
||||||
|
std::cout << "Warning: Failed to start live view, error: " << err << std::endl;
|
||||||
|
// 实时取景启动失败不是致命错误,继续执行
|
||||||
|
}
|
||||||
|
|
||||||
|
m_isRecord = true;
|
||||||
|
|
||||||
|
// 启动实时取景定时器(约30fps)
|
||||||
|
if (m_liveViewTimer && !m_liveViewTimer->isActive()) {
|
||||||
|
m_liveViewTimer->start(33); // 约30fps
|
||||||
|
}
|
||||||
|
|
||||||
|
emit CamOpenedSignal();
|
||||||
|
|
||||||
|
std::cout << "Camera opened, live view started." << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SingleLensReflexCameraOperation::takePhoto()
|
||||||
|
{
|
||||||
|
// 启动拍照定时器(每3秒拍一张)
|
||||||
|
if (m_captureTimer && !m_captureTimer->isActive())
|
||||||
|
{
|
||||||
|
m_captureTimer->start(3000);
|
||||||
|
std::cout << "capture timer started (1 photo 3 second)" << std::endl;
|
||||||
|
|
||||||
|
emit CaptureStartedSignal();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SingleLensReflexCameraOperation::stopTakePhoto()
|
||||||
|
{
|
||||||
|
if (m_captureTimer && m_captureTimer->isActive())
|
||||||
|
{
|
||||||
|
m_captureTimer->stop();
|
||||||
|
std::cout << "capture timer stopped" << std::endl;
|
||||||
|
|
||||||
|
emit CaptureStoppedSignal();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SingleLensReflexCameraOperation::OpenSLRCamera_callback()
|
||||||
|
{
|
||||||
|
// 不使用信号而使用回调函数来通知界面刷新视频
|
||||||
|
}
|
||||||
|
|
||||||
|
void SingleLensReflexCameraOperation::setCallback(void(*func)())
|
||||||
|
{
|
||||||
|
m_func = func;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SingleLensReflexCameraOperation::onLiveViewTimer()
|
||||||
|
{
|
||||||
|
if (!m_isRecord || !m_isLiveViewActive)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理相机事件
|
||||||
|
EdsGetEvent();
|
||||||
|
|
||||||
|
// 下载实时取景图像
|
||||||
|
downloadEvfImage();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SingleLensReflexCameraOperation::onCaptureTimer()
|
||||||
|
{
|
||||||
|
if (!m_isRecord)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QMutexLocker locker(&m_mutex);
|
||||||
|
|
||||||
|
// 拍照
|
||||||
|
EdsError err = takePicture();
|
||||||
|
if (err != EDS_ERR_OK)
|
||||||
|
{
|
||||||
|
std::cout << "Failed to take picture, error: " << err << std::endl;
|
||||||
|
// 如果是设备忙,不发送错误信号,等待下次重试
|
||||||
|
if (err != EDS_ERR_DEVICE_BUSY)
|
||||||
|
{
|
||||||
|
emit ErrorSignal(QString::fromLocal8Bit("拍照失败,错误码: %1").arg(err));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_imageCounter++;
|
||||||
|
std::cout << "Total pictures taken: " << m_imageCounter << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SingleLensReflexCameraOperation::startCapture()
|
||||||
|
{
|
||||||
|
if (m_captureTimer && !m_captureTimer->isActive())
|
||||||
|
{
|
||||||
|
m_captureTimer->start(1000);
|
||||||
|
std::cout << "Capture timer started" << std::endl;
|
||||||
|
emit CaptureStartedSignal();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SingleLensReflexCameraOperation::stopCapture()
|
||||||
|
{
|
||||||
|
if (m_captureTimer && m_captureTimer->isActive())
|
||||||
|
{
|
||||||
|
m_captureTimer->stop();
|
||||||
|
std::cout << "Capture timer stopped" << std::endl;
|
||||||
|
emit CaptureStoppedSignal();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SingleLensReflexCameraOperation::captureOnce()
|
||||||
|
{
|
||||||
|
if (m_isRecord)
|
||||||
|
{
|
||||||
|
QMutexLocker locker(&m_mutex);
|
||||||
|
takePicture();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SingleLensReflexCameraOperation::CloseSLRCamera()
|
||||||
|
{
|
||||||
|
std::cout << "SingleLensReflexCameraOperation::CloseSLRCamera,关闭单反相机" << std::endl;
|
||||||
|
|
||||||
|
QMutexLocker locker(&m_mutex);
|
||||||
|
|
||||||
|
m_isRecord = false;
|
||||||
|
|
||||||
|
// 停止定时器
|
||||||
|
if (m_captureTimer != nullptr)
|
||||||
|
{
|
||||||
|
m_captureTimer->stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_liveViewTimer != nullptr)
|
||||||
|
{
|
||||||
|
m_liveViewTimer->stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 停止实时取景
|
||||||
|
stopLiveView();
|
||||||
|
|
||||||
|
// 处理剩余事件
|
||||||
|
for (int i = 0; i < 10; i++)
|
||||||
|
{
|
||||||
|
EdsGetEvent();
|
||||||
|
QThread::msleep(100);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 关闭相机
|
||||||
|
closeCamera();
|
||||||
|
|
||||||
|
// 终止SDK
|
||||||
|
terminateSDK();
|
||||||
|
|
||||||
|
std::cout << "Camera closed, total pictures: " << m_imageCounter << std::endl;
|
||||||
|
m_imageCounter = 0;
|
||||||
|
|
||||||
|
emit CamClosedSignal();
|
||||||
|
}
|
||||||
178
HPPA/SingleLensReflexCameraWindow.h
Normal file
178
HPPA/SingleLensReflexCameraWindow.h
Normal file
@ -0,0 +1,178 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QDialog>
|
||||||
|
#include <QNetworkRequest>
|
||||||
|
#include <QNetworkReply>
|
||||||
|
#include <QNetworkAccessManager>
|
||||||
|
#include <QImage>
|
||||||
|
#include <QThread>
|
||||||
|
#include <QDir>
|
||||||
|
#include <QTimer>
|
||||||
|
#include <QMutex>
|
||||||
|
#include <QDateTime>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QFileDialog>
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include "ui_SingleLensReflexCamera.h"
|
||||||
|
#include "AppSettings.h"
|
||||||
|
|
||||||
|
#include <fstream>
|
||||||
|
#include <opencv2/opencv.hpp>
|
||||||
|
|
||||||
|
// 包含Canon EDSDK头文件
|
||||||
|
#include "EDSDK.h"
|
||||||
|
#include "EDSDKTypes.h"
|
||||||
|
#include "EDSDKErrors.h"
|
||||||
|
|
||||||
|
typedef void(*func)();
|
||||||
|
|
||||||
|
class SingleLensReflexCameraOperation : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
SingleLensReflexCameraOperation();
|
||||||
|
~SingleLensReflexCameraOperation();
|
||||||
|
|
||||||
|
QImage m_colorImage;
|
||||||
|
QImage m_depthImage;
|
||||||
|
void setCallback(void(*func)());
|
||||||
|
bool getRecordStatus() const { return m_isRecord; }
|
||||||
|
|
||||||
|
// 设置保存路径
|
||||||
|
void setSavePath(const QString& path);
|
||||||
|
|
||||||
|
// 获取当前实时取景图像
|
||||||
|
QImage getCurrentLiveViewImage();
|
||||||
|
|
||||||
|
private:
|
||||||
|
cv::Mat frame;
|
||||||
|
func m_func;
|
||||||
|
bool m_isRecord;
|
||||||
|
|
||||||
|
// Canon EDSDK相关成员
|
||||||
|
EdsCameraRef m_camera;
|
||||||
|
bool m_isSDKInitialized;
|
||||||
|
bool m_isSessionOpen;
|
||||||
|
bool m_isLiveViewActive;
|
||||||
|
|
||||||
|
QTimer* m_captureTimer; // 拍照定时器
|
||||||
|
QTimer* m_liveViewTimer; // 实时取景定时器
|
||||||
|
|
||||||
|
QString m_savePath;
|
||||||
|
int m_imageCounter;
|
||||||
|
QMutex m_mutex;
|
||||||
|
QMutex m_liveViewMutex;
|
||||||
|
|
||||||
|
QImage m_liveViewImage; // 当前实时取景图像
|
||||||
|
|
||||||
|
// EDSDK辅助函数
|
||||||
|
EdsError initializeSDK();
|
||||||
|
EdsError terminateSDK();
|
||||||
|
EdsError openCamera();
|
||||||
|
EdsError closeCamera();
|
||||||
|
EdsError takePicture();
|
||||||
|
EdsError setupSaveToHost();
|
||||||
|
|
||||||
|
// 实时取景相关函数
|
||||||
|
EdsError startLiveView();
|
||||||
|
EdsError stopLiveView();
|
||||||
|
EdsError downloadEvfImage();
|
||||||
|
|
||||||
|
// 静态回调函数
|
||||||
|
static EdsError EDSCALLBACK handleObjectEvent(EdsObjectEvent event, EdsBaseRef object, EdsVoid* context);
|
||||||
|
static EdsError EDSCALLBACK handlePropertyEvent(EdsPropertyEvent event, EdsPropertyID property, EdsUInt32 param, EdsVoid* context);
|
||||||
|
static EdsError EDSCALLBACK handleStateEvent(EdsStateEvent event, EdsUInt32 parameter, EdsVoid* context);
|
||||||
|
|
||||||
|
// 下载图像
|
||||||
|
EdsError downloadImage(EdsDirectoryItemRef directoryItem);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void OpenSLRCamera();
|
||||||
|
void takePhoto();
|
||||||
|
void stopTakePhoto();
|
||||||
|
void OpenSLRCamera_callback();
|
||||||
|
void CloseSLRCamera();
|
||||||
|
void onCaptureTimer();
|
||||||
|
void onLiveViewTimer();
|
||||||
|
|
||||||
|
// 控制拍照
|
||||||
|
void startCapture(); // 开始定时拍照
|
||||||
|
void stopCapture(); // 停止定时拍照
|
||||||
|
void captureOnce(); // 拍一张照片
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void PlotSignal();
|
||||||
|
void CamOpenedSignal();
|
||||||
|
void CamClosedSignal();
|
||||||
|
void ImageCapturedSignal(const QString& filePath);
|
||||||
|
void ErrorSignal(const QString& errorMsg);
|
||||||
|
|
||||||
|
// 实时取景信号
|
||||||
|
void LiveViewImageReady(const QImage& image);
|
||||||
|
void LiveViewStarted();
|
||||||
|
void LiveViewStopped();
|
||||||
|
|
||||||
|
void CaptureStartedSignal();
|
||||||
|
void CaptureStoppedSignal();
|
||||||
|
};
|
||||||
|
|
||||||
|
class SingleLensReflexCameraWindow : public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
SingleLensReflexCameraWindow(QWidget* parent = nullptr);
|
||||||
|
~SingleLensReflexCameraWindow();
|
||||||
|
|
||||||
|
SingleLensReflexCameraOperation* m_SingleLensReflexCameraOperation;
|
||||||
|
|
||||||
|
public Q_SLOTS:
|
||||||
|
void onSelectDataFolder();
|
||||||
|
|
||||||
|
void openSLRCamera();
|
||||||
|
void takePhoto();
|
||||||
|
void stopTakePhoto();
|
||||||
|
void onCamOpened();
|
||||||
|
void closeSLRCamera();
|
||||||
|
void onCamClosed();
|
||||||
|
void onImageCaptured(const QString& filePath);
|
||||||
|
void onError(const QString& errorMsg);
|
||||||
|
|
||||||
|
// 拍照控制
|
||||||
|
void onStartCapture();
|
||||||
|
void onStopCapture();
|
||||||
|
void onCaptureOnce();
|
||||||
|
|
||||||
|
void onCaptureStarted();
|
||||||
|
void onCaptureStopped();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void openSLRCameraSignal();
|
||||||
|
void takePhotoSignal();
|
||||||
|
void stopTakePhotoSignal();
|
||||||
|
void closeSLRCameraSignal();
|
||||||
|
void PlotSLRImageSignal();
|
||||||
|
void SLRCamClosedSignal();
|
||||||
|
|
||||||
|
// 控制信号
|
||||||
|
void startCaptureSignal();
|
||||||
|
void stopCaptureSignal();
|
||||||
|
void captureOnceSignal();
|
||||||
|
|
||||||
|
// 实时取景信号
|
||||||
|
void LiveViewImageReady(const QImage& image);
|
||||||
|
void LiveViewStarted();
|
||||||
|
void LiveViewStopped();
|
||||||
|
private:
|
||||||
|
Ui::SingleLensReflexCameraClass ui;
|
||||||
|
QThread* m_SLRCameraThread;
|
||||||
|
|
||||||
|
// 用于显示实时取景的标签(如果UI中没有,可以动态创建)
|
||||||
|
QLabel* m_liveViewLabel;
|
||||||
|
|
||||||
|
QString m_btnOldText; // 存储拍照按钮的原始文本
|
||||||
|
|
||||||
|
bool m_isCapturing; // 是否正在定时拍照
|
||||||
|
};
|
||||||
85
HPPA/SinglebandRasterRenderer.cpp
Normal file
85
HPPA/SinglebandRasterRenderer.cpp
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
#include "SinglebandRasterRenderer.h"
|
||||||
|
#include "RasterDataProvider.h"
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
|
SinglebandRasterRenderer::SinglebandRasterRenderer(RasterDataProvider* provider)
|
||||||
|
: RasterRendererBase(provider)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void SinglebandRasterRenderer::stretchTo8bit(const std::vector<float>& in, std::vector<unsigned char>& out, float minVal, float maxVal)
|
||||||
|
{
|
||||||
|
size_t n = in.size();
|
||||||
|
out.resize(n);
|
||||||
|
if (maxVal <= minVal) {
|
||||||
|
std::fill(out.begin(), out.end(), 0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
float denom = 1.0f / (maxVal - minVal);
|
||||||
|
for (size_t i = 0; i < n; ++i) {
|
||||||
|
float v = (in[i] - minVal) * denom;
|
||||||
|
v = std::min(std::max(v, 0.0f), 1.0f);
|
||||||
|
out[i] = static_cast<unsigned char>(v * 255.0f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int SinglebandRasterRenderer::nearestBandIndex(double wave) const
|
||||||
|
{
|
||||||
|
if (!m_provider) return -1;
|
||||||
|
|
||||||
|
int bands = m_provider->bandCount();
|
||||||
|
if (bands <= 0) return -1;
|
||||||
|
|
||||||
|
std::vector<double> wavelengths = m_provider->bandWavelengths();
|
||||||
|
if (wavelengths.empty()) {
|
||||||
|
// No wavelengths available, fallback to first band
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int best = -1;
|
||||||
|
double bestDiff = 1e12;
|
||||||
|
for (int i = 0; i < (int)wavelengths.size(); ++i) {
|
||||||
|
if (wavelengths[i] < 0) continue;
|
||||||
|
double d = std::abs(wavelengths[i] - wave);
|
||||||
|
if (d < bestDiff) {
|
||||||
|
bestDiff = d;
|
||||||
|
best = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (best >= 0) ? best : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
QImage SinglebandRasterRenderer::render()
|
||||||
|
{
|
||||||
|
if (!m_provider) return QImage();
|
||||||
|
|
||||||
|
int w = m_provider->width();
|
||||||
|
int h = m_provider->height();
|
||||||
|
if (w <= 0 || h <= 0) return QImage();
|
||||||
|
|
||||||
|
int bandIdx = nearestBandIndex(m_params.wavelength);
|
||||||
|
if (bandIdx < 0 || bandIdx >= m_provider->bandCount()) {
|
||||||
|
bandIdx = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<float> buf;
|
||||||
|
m_provider->readBandAsFloat(bandIdx, buf);
|
||||||
|
|
||||||
|
std::vector<unsigned char> gray8;
|
||||||
|
float minV = static_cast<float>(m_params.minValue);
|
||||||
|
float maxV = static_cast<float>(m_params.maxValue);
|
||||||
|
if (!buf.empty()) {
|
||||||
|
stretchTo8bit(buf, gray8, minV, maxV);
|
||||||
|
}
|
||||||
|
|
||||||
|
QImage out(w, h, QImage::Format_Grayscale8);
|
||||||
|
for (int y = 0; y < h; ++y) {
|
||||||
|
unsigned char* scan = out.scanLine(y);
|
||||||
|
for (int x = 0; x < w; ++x) {
|
||||||
|
int idx = y * w + x;
|
||||||
|
scan[x] = (gray8.size() > (size_t)idx) ? gray8[idx] : 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
27
HPPA/SinglebandRasterRenderer.h
Normal file
27
HPPA/SinglebandRasterRenderer.h
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "RasterRendererBase.h"
|
||||||
|
#include "RasterRenderParams.h"
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
class RasterDataProvider;
|
||||||
|
|
||||||
|
class SinglebandRasterRenderer : public RasterRendererBase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit SinglebandRasterRenderer(RasterDataProvider* provider);
|
||||||
|
|
||||||
|
QImage render() override;
|
||||||
|
|
||||||
|
// Parameter access
|
||||||
|
SinglebandRenderParams params() const { return m_params; }
|
||||||
|
void setParams(const SinglebandRenderParams& params) { m_params = params; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
SinglebandRenderParams m_params;
|
||||||
|
|
||||||
|
int nearestBandIndex(double wave) const;
|
||||||
|
|
||||||
|
// Helper to map float buffer to 8-bit with min/max stretch
|
||||||
|
static void stretchTo8bit(const std::vector<float>& in, std::vector<unsigned char>& out, float minVal, float maxVal);
|
||||||
|
};
|
||||||
@ -1,4 +1,4 @@
|
|||||||
#include "TabManager.h"
|
#include "TabManager.h"
|
||||||
|
|
||||||
TabManager::TabManager(QTabWidget* tabWidget, QObject* parent)
|
TabManager::TabManager(QTabWidget* tabWidget, QObject* parent)
|
||||||
: QObject(parent),
|
: QObject(parent),
|
||||||
@ -7,6 +7,24 @@ TabManager::TabManager(QTabWidget* tabWidget, QObject* parent)
|
|||||||
Q_ASSERT(m_tabWidget);
|
Q_ASSERT(m_tabWidget);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TabManager::hideAllTabs()
|
||||||
|
{
|
||||||
|
int tabNumber = m_tabWidget->count();
|
||||||
|
for (size_t i = 0; i < tabNumber; i++)
|
||||||
|
{
|
||||||
|
int idx = 0;
|
||||||
|
|
||||||
|
TabInfo info;
|
||||||
|
info.index = idx;
|
||||||
|
info.text = m_tabWidget->tabText(idx);
|
||||||
|
info.icon = m_tabWidget->tabIcon(idx);
|
||||||
|
info.toolTip = m_tabWidget->tabToolTip(idx);
|
||||||
|
|
||||||
|
m_hiddenTabs.insert(m_tabWidget->widget(idx), info);
|
||||||
|
m_tabWidget->removeTab(idx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void TabManager::hideTab(QWidget* page)
|
void TabManager::hideTab(QWidget* page)
|
||||||
{
|
{
|
||||||
if (!page || !m_tabWidget)
|
if (!page || !m_tabWidget)
|
||||||
@ -27,7 +45,7 @@ void TabManager::hideTab(QWidget* page)
|
|||||||
|
|
||||||
m_hiddenTabs.insert(page, info);
|
m_hiddenTabs.insert(page, info);
|
||||||
|
|
||||||
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD><EFBFBD>ǵ<EFBFBD>ǰҳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>л<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>հ<EFBFBD>
|
// 如果隐藏的是当前页,先切换,避免空白
|
||||||
if (m_tabWidget->currentIndex() == index)
|
if (m_tabWidget->currentIndex() == index)
|
||||||
{
|
{
|
||||||
int next = (index > 0) ? index - 1 : 0;
|
int next = (index > 0) ? index - 1 : 0;
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QTabWidget>
|
#include <QTabWidget>
|
||||||
@ -10,6 +10,7 @@ class TabManager : public QObject
|
|||||||
public:
|
public:
|
||||||
explicit TabManager(QTabWidget* tabWidget, QObject* parent = nullptr);
|
explicit TabManager(QTabWidget* tabWidget, QObject* parent = nullptr);
|
||||||
|
|
||||||
|
void hideAllTabs();
|
||||||
void hideTab(QWidget* page);
|
void hideTab(QWidget* page);
|
||||||
void showTab(QWidget* page);
|
void showTab(QWidget* page);
|
||||||
bool isHidden(QWidget* page) const;
|
bool isHidden(QWidget* page) const;
|
||||||
|
|||||||
120
HPPA/TimedDataCollection.cpp
Normal file
120
HPPA/TimedDataCollection.cpp
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
#include "TimedDataCollection.h"
|
||||||
|
#include <QDateTime>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
|
TimedDataCollection::TimedDataCollection(QWidget* parent)
|
||||||
|
: QDialog(parent)
|
||||||
|
{
|
||||||
|
ui.setupUi(this);
|
||||||
|
|
||||||
|
ui.treeWidget->setDragEnabled(true); // 启用拖拽
|
||||||
|
ui.treeWidget->setAcceptDrops(true); // 接受拖放
|
||||||
|
ui.treeWidget->setDropIndicatorShown(true); // 显示插入位置指示线
|
||||||
|
ui.treeWidget->setDragDropMode(QAbstractItemView::InternalMove); // 内部移动
|
||||||
|
|
||||||
|
//writeRead();
|
||||||
|
readTimedTaskFromFile("D:/0tmp/3Dtest/task.json");
|
||||||
|
|
||||||
|
connect(ui.run_btn, SIGNAL(clicked()), this, SLOT(run()));
|
||||||
|
|
||||||
|
connect(ui.run_btn, &QPushButton::clicked, this, &TimedDataCollection::run);
|
||||||
|
}
|
||||||
|
|
||||||
|
TimedDataCollection::~TimedDataCollection()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void TimedDataCollection::run()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void TimedDataCollection::readTimedTaskFromFile(const QString& filePath)
|
||||||
|
{
|
||||||
|
// 从文件读取
|
||||||
|
if (TimedDataCollectionDataStructuresReaderWriter::loadTasksFromFile(filePath, m_loadedTasks)) {
|
||||||
|
qDebug() << "Tasks loaded successfully, count:" << m_loadedTasks.size();
|
||||||
|
for (const auto& t : m_loadedTasks) {
|
||||||
|
qDebug() << " Task ID:" << t.id << "SubTasks:" << t.subTasks.size();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
qDebug() << "Failed to load tasks from:" << filePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
int a = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TimedDataCollection::writeRead()
|
||||||
|
{
|
||||||
|
// 创建2个定时任务测试
|
||||||
|
QVector<TimedTask> tasks;
|
||||||
|
|
||||||
|
for (int i = 0; i < 2; ++i) {
|
||||||
|
TimedTask task;
|
||||||
|
task.id = i + 1;
|
||||||
|
task.scheduledTime = QDateTime::currentDateTime().addDays(i + 1);
|
||||||
|
task.savePath = QString("D:/0tmp/data");
|
||||||
|
task.status = TaskStatus::Waiting;
|
||||||
|
|
||||||
|
// 创建4种子任务
|
||||||
|
QVector<SubTaskType> types = {
|
||||||
|
SubTaskType::HyperSpectual400_1000nm,
|
||||||
|
SubTaskType::HyperSpectual1000_1700nm,
|
||||||
|
SubTaskType::SingleLensReflex,
|
||||||
|
SubTaskType::DepthCamera
|
||||||
|
};
|
||||||
|
|
||||||
|
for (int j = 0; j < types.size(); ++j) {
|
||||||
|
SubTask subTask;
|
||||||
|
subTask.type = types[j];
|
||||||
|
subTask.startTime = task.scheduledTime.addSecs(j * 3600);
|
||||||
|
subTask.endTime = subTask.startTime.addSecs(1800);
|
||||||
|
subTask.durationSeconds = 1800;
|
||||||
|
subTask.estimatedDurationSeconds = 1800;
|
||||||
|
subTask.pathLineFilePath = QString("D:/0tmp/3Dtest/pathLine/%1.RecordLine3").arg(j);
|
||||||
|
subTask.status = TaskStatus::Waiting;
|
||||||
|
|
||||||
|
// 根据类型设置特有属性
|
||||||
|
if (subTask.type == SubTaskType::HyperSpectual400_1000nm ||
|
||||||
|
subTask.type == SubTaskType::HyperSpectual1000_1700nm) {
|
||||||
|
subTask.frameRate = 30.0;
|
||||||
|
subTask.exposureTime = 1;
|
||||||
|
}
|
||||||
|
if (subTask.type == SubTaskType::HyperSpectual1000_1700nm) {
|
||||||
|
subTask.defaultRenderBand = 1200;
|
||||||
|
}
|
||||||
|
if (subTask.type == SubTaskType::SingleLensReflex ||
|
||||||
|
subTask.type == SubTaskType::DepthCamera) {
|
||||||
|
subTask.captureIntervalSeconds = 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
task.subTasks.append(subTask);
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.append(task);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 保存到文件
|
||||||
|
QString filePath = "D:/0tmp/3Dtest/task.json";
|
||||||
|
if (TimedDataCollectionDataStructuresReaderWriter::saveTasksToFile(filePath, tasks)) {
|
||||||
|
qDebug() << "Tasks saved to:" << filePath;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
qDebug() << "Failed to save tasks to:" << filePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 从文件读取
|
||||||
|
QVector<TimedTask> loadedTasks;
|
||||||
|
if (TimedDataCollectionDataStructuresReaderWriter::loadTasksFromFile(filePath, loadedTasks)) {
|
||||||
|
qDebug() << "Tasks loaded successfully, count:" << loadedTasks.size();
|
||||||
|
for (const auto& t : loadedTasks) {
|
||||||
|
qDebug() << " Task ID:" << t.id << "SubTasks:" << t.subTasks.size();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
qDebug() << "Failed to load tasks from:" << filePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
int a = 1;
|
||||||
|
}
|
||||||
30
HPPA/TimedDataCollection.h
Normal file
30
HPPA/TimedDataCollection.h
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QDialog>
|
||||||
|
#include <QNetworkRequest>
|
||||||
|
#include <QNetworkReply>
|
||||||
|
#include <QNetworkAccessManager>
|
||||||
|
|
||||||
|
#include "ui_TimedDataCollection_ui.h"
|
||||||
|
#include "TimedDataCollectionDataStructures.h"
|
||||||
|
|
||||||
|
class TimedDataCollection : public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
TimedDataCollection(QWidget* parent = nullptr);
|
||||||
|
~TimedDataCollection();
|
||||||
|
|
||||||
|
void readTimedTaskFromFile(const QString& filePath);
|
||||||
|
|
||||||
|
public Q_SLOTS:
|
||||||
|
void run();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::TimedDataCollection_ui ui;
|
||||||
|
|
||||||
|
void writeRead();
|
||||||
|
|
||||||
|
QVector<TimedTask> m_loadedTasks;
|
||||||
|
};
|
||||||
196
HPPA/TimedDataCollectionDataStructures.cpp
Normal file
196
HPPA/TimedDataCollectionDataStructures.cpp
Normal file
@ -0,0 +1,196 @@
|
|||||||
|
#include "TimedDataCollectionDataStructures.h"
|
||||||
|
#include <QJsonDocument>
|
||||||
|
#include <QJsonObject>
|
||||||
|
#include <QJsonArray>
|
||||||
|
#include <QFile>
|
||||||
|
#include <QTextStream>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
|
// ==================== 公共接口实现 ====================
|
||||||
|
|
||||||
|
bool TimedDataCollectionDataStructuresReaderWriter::saveTasksToFile(const QString& filePath, const QVector<TimedTask>& tasks)
|
||||||
|
{
|
||||||
|
QJsonObject root;
|
||||||
|
root["version"] = "1.0";
|
||||||
|
root["taskCount"] = tasks.size();
|
||||||
|
|
||||||
|
QJsonArray tasksArray;
|
||||||
|
for (const auto& task : tasks) {
|
||||||
|
tasksArray.append(timedTaskToJson(task));
|
||||||
|
}
|
||||||
|
root["tasks"] = tasksArray;
|
||||||
|
|
||||||
|
QJsonDocument doc(root);
|
||||||
|
QFile file(filePath);
|
||||||
|
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||||
|
qWarning() << "Failed to open file for writing:" << filePath;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
QTextStream out(&file);
|
||||||
|
//out.setEncoding(QStringConverter::Utf8);
|
||||||
|
out << doc.toJson(QJsonDocument::Indented);
|
||||||
|
file.close();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TimedDataCollectionDataStructuresReaderWriter::loadTasksFromFile(const QString& filePath, QVector<TimedTask>& tasks)
|
||||||
|
{
|
||||||
|
QFile file(filePath);
|
||||||
|
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||||
|
qWarning() << "Failed to open file for reading:" << filePath;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
QByteArray jsonData = file.readAll();
|
||||||
|
file.close();
|
||||||
|
|
||||||
|
QJsonParseError parseError;
|
||||||
|
QJsonDocument doc = QJsonDocument::fromJson(jsonData, &parseError);
|
||||||
|
if (parseError.error != QJsonParseError::NoError) {
|
||||||
|
qWarning() << "JSON parse error:" << parseError.errorString();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!doc.isObject()) {
|
||||||
|
qWarning() << "Invalid JSON root object";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
QJsonObject root = doc.object();
|
||||||
|
QJsonArray tasksArray = root["tasks"].toArray();
|
||||||
|
tasks.clear();
|
||||||
|
tasks.reserve(tasksArray.size());
|
||||||
|
|
||||||
|
for (const auto& taskValue : tasksArray) {
|
||||||
|
if (!taskValue.isObject()) continue;
|
||||||
|
TimedTask task;
|
||||||
|
if (jsonToTimedTask(taskValue.toObject(), task)) {
|
||||||
|
tasks.append(task);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ==================== 枚举转换函数 ====================
|
||||||
|
|
||||||
|
QString TimedDataCollectionDataStructuresReaderWriter::taskStatusToString(TaskStatus status)
|
||||||
|
{
|
||||||
|
switch (status) {
|
||||||
|
case TaskStatus::Waiting: return "Waiting";
|
||||||
|
case TaskStatus::Running: return "Running";
|
||||||
|
case TaskStatus::Finished: return "Finished";
|
||||||
|
default: return "Waiting";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TaskStatus TimedDataCollectionDataStructuresReaderWriter::stringToTaskStatus(const QString& str)
|
||||||
|
{
|
||||||
|
if (str == "Running") return TaskStatus::Running;
|
||||||
|
if (str == "Finished") return TaskStatus::Finished;
|
||||||
|
return TaskStatus::Waiting;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString TimedDataCollectionDataStructuresReaderWriter::subTaskTypeToString(SubTaskType type)
|
||||||
|
{
|
||||||
|
switch (type) {
|
||||||
|
case SubTaskType::HyperSpectual400_1000nm: return "HyperSpectual400_1000nm";
|
||||||
|
case SubTaskType::HyperSpectual1000_1700nm: return "HyperSpectual1000_1700nm";
|
||||||
|
case SubTaskType::SingleLensReflex: return "SingleLensReflex";
|
||||||
|
case SubTaskType::DepthCamera: return "DepthCamera";
|
||||||
|
default: return "Unknown";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SubTaskType TimedDataCollectionDataStructuresReaderWriter::stringToSubTaskType(const QString& str)
|
||||||
|
{
|
||||||
|
if (str == "HyperSpectual400_1000nm") return SubTaskType::HyperSpectual400_1000nm;
|
||||||
|
if (str == "HyperSpectual1000_1700nm") return SubTaskType::HyperSpectual1000_1700nm;
|
||||||
|
if (str == "SingleLensReflex") return SubTaskType::SingleLensReflex;
|
||||||
|
if (str == "DepthCamera") return SubTaskType::DepthCamera;
|
||||||
|
return SubTaskType::SingleLensReflex;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ==================== SubTask序列化 ====================
|
||||||
|
|
||||||
|
QJsonObject TimedDataCollectionDataStructuresReaderWriter::subTaskToJson(const SubTask& subTask)
|
||||||
|
{
|
||||||
|
QJsonObject obj;
|
||||||
|
obj["type"] = subTaskTypeToString(subTask.type);
|
||||||
|
obj["startTime"] = subTask.startTime.toString(Qt::ISODate);
|
||||||
|
obj["endTime"] = subTask.endTime.toString(Qt::ISODate);
|
||||||
|
obj["durationSeconds"] = subTask.durationSeconds;
|
||||||
|
obj["estimatedDurationSeconds"] = subTask.estimatedDurationSeconds;
|
||||||
|
obj["pathLineFilePath"] = subTask.pathLineFilePath;
|
||||||
|
obj["status"] = taskStatusToString(subTask.status);
|
||||||
|
obj["frameRate"] = subTask.frameRate;
|
||||||
|
obj["exposureTime"] = subTask.exposureTime;
|
||||||
|
obj["defaultRenderBand"] = subTask.defaultRenderBand;
|
||||||
|
obj["captureIntervalSeconds"] = subTask.captureIntervalSeconds;
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TimedDataCollectionDataStructuresReaderWriter::jsonToSubTask(const QJsonObject& json, SubTask& subTask)
|
||||||
|
{
|
||||||
|
subTask.type = stringToSubTaskType(json["type"].toString());
|
||||||
|
subTask.startTime = QDateTime::fromString(json["startTime"].toString(), Qt::ISODate);
|
||||||
|
subTask.endTime = QDateTime::fromString(json["endTime"].toString(), Qt::ISODate);
|
||||||
|
subTask.durationSeconds = json["durationSeconds"].toInt();
|
||||||
|
subTask.estimatedDurationSeconds = json["estimatedDurationSeconds"].toInt();
|
||||||
|
subTask.pathLineFilePath = json["pathLineFilePath"].toString();
|
||||||
|
subTask.status = stringToTaskStatus(json["status"].toString());
|
||||||
|
subTask.frameRate = json["frameRate"].toDouble();
|
||||||
|
subTask.exposureTime = json["exposureTime"].toDouble();
|
||||||
|
subTask.defaultRenderBand = json["defaultRenderBand"].toInt();
|
||||||
|
subTask.captureIntervalSeconds = json["captureIntervalSeconds"].toInt();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ==================== TimedTask序列化 ====================
|
||||||
|
|
||||||
|
QJsonObject TimedDataCollectionDataStructuresReaderWriter::timedTaskToJson(const TimedTask& task)
|
||||||
|
{
|
||||||
|
QJsonObject obj;
|
||||||
|
obj["id"] = task.id;
|
||||||
|
obj["scheduledTime"] = task.scheduledTime.toString(Qt::ISODate);
|
||||||
|
obj["startTime"] = task.startTime.toString(Qt::ISODate);
|
||||||
|
obj["endTime"] = task.endTime.toString(Qt::ISODate);
|
||||||
|
obj["durationSeconds"] = task.durationSeconds;
|
||||||
|
obj["savePath"] = task.savePath;
|
||||||
|
obj["status"] = taskStatusToString(task.status);
|
||||||
|
|
||||||
|
QJsonArray subTasksArray;
|
||||||
|
for (const auto& subTask : task.subTasks) {
|
||||||
|
subTasksArray.append(subTaskToJson(subTask));
|
||||||
|
}
|
||||||
|
obj["subTasks"] = subTasksArray;
|
||||||
|
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TimedDataCollectionDataStructuresReaderWriter::jsonToTimedTask(const QJsonObject& json, TimedTask& task)
|
||||||
|
{
|
||||||
|
task.id = json["id"].toInt();
|
||||||
|
task.scheduledTime = QDateTime::fromString(json["scheduledTime"].toString(), Qt::ISODate);
|
||||||
|
task.startTime = QDateTime::fromString(json["startTime"].toString(), Qt::ISODate);
|
||||||
|
task.endTime = QDateTime::fromString(json["endTime"].toString(), Qt::ISODate);
|
||||||
|
task.durationSeconds = json["durationSeconds"].toInt();
|
||||||
|
task.savePath = json["savePath"].toString();
|
||||||
|
task.status = stringToTaskStatus(json["status"].toString());
|
||||||
|
|
||||||
|
QJsonArray subTasksArray = json["subTasks"].toArray();
|
||||||
|
task.subTasks.clear();
|
||||||
|
task.subTasks.reserve(subTasksArray.size());
|
||||||
|
|
||||||
|
for (const auto& subTaskValue : subTasksArray) {
|
||||||
|
if (!subTaskValue.isObject()) continue;
|
||||||
|
SubTask subTask;
|
||||||
|
if (jsonToSubTask(subTaskValue.toObject(), subTask)) {
|
||||||
|
task.subTasks.append(subTask);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
104
HPPA/TimedDataCollectionDataStructures.h
Normal file
104
HPPA/TimedDataCollectionDataStructures.h
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QDateTime>
|
||||||
|
#include <QString>
|
||||||
|
#include <QVector>
|
||||||
|
#include <QMetaType>
|
||||||
|
|
||||||
|
// ==================== 枚举定义 ====================
|
||||||
|
|
||||||
|
// 任务状态
|
||||||
|
enum class TaskStatus {
|
||||||
|
Waiting, // 等待
|
||||||
|
Running, // 运行中
|
||||||
|
Finished // 结束
|
||||||
|
};
|
||||||
|
|
||||||
|
// 子任务类型
|
||||||
|
enum class SubTaskType {
|
||||||
|
HyperSpectual400_1000nm, // 400nm-1000nm高光谱相机
|
||||||
|
HyperSpectual1000_1700nm, // 1000nm-1700nm高光谱相机
|
||||||
|
SingleLensReflex, // 单反相机
|
||||||
|
DepthCamera // 深度相机
|
||||||
|
};
|
||||||
|
|
||||||
|
// ==================== 统一子任务封装 ====================
|
||||||
|
|
||||||
|
struct SubTask {
|
||||||
|
SubTaskType type; // 子任务类型
|
||||||
|
|
||||||
|
// 共享属性
|
||||||
|
QDateTime startTime;
|
||||||
|
QDateTime endTime;
|
||||||
|
int durationSeconds = 0;
|
||||||
|
int estimatedDurationSeconds = 0;
|
||||||
|
QString pathLineFilePath;
|
||||||
|
TaskStatus status = TaskStatus::Waiting;
|
||||||
|
|
||||||
|
// 类型特有属性(根据type选择使用)
|
||||||
|
double frameRate = 0.0; // 高光谱相机用
|
||||||
|
double exposureTime = 0.0; // 高光谱相机用
|
||||||
|
int defaultRenderBand = 550; // 1000-1700nm高光谱用
|
||||||
|
int captureIntervalSeconds = 5; // 单反/深度相机用
|
||||||
|
};
|
||||||
|
|
||||||
|
// ==================== 定时任务 ====================
|
||||||
|
|
||||||
|
struct TimedTask {
|
||||||
|
int id = 0; // 任务ID
|
||||||
|
QDateTime scheduledTime; // 计划时间
|
||||||
|
QDateTime startTime; // 开始时间
|
||||||
|
QDateTime endTime; // 结束时间
|
||||||
|
int durationSeconds = 0; // 耗时(秒)
|
||||||
|
QString savePath; // 数据保存路径
|
||||||
|
QVector<SubTask> subTasks; // 子任务列表
|
||||||
|
TaskStatus status = TaskStatus::Waiting; // 状态
|
||||||
|
|
||||||
|
// 计算所有子任务的预计总时间
|
||||||
|
int totalEstimatedDuration() const {
|
||||||
|
int total = 0;
|
||||||
|
for (const auto& subTask : subTasks) {
|
||||||
|
total += subTask.estimatedDurationSeconds;
|
||||||
|
}
|
||||||
|
return total;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取子任务数量
|
||||||
|
int subTaskCount() const {
|
||||||
|
return subTasks.size();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// ==================== Qt元类型声明 ====================
|
||||||
|
Q_DECLARE_METATYPE(TaskStatus)
|
||||||
|
Q_DECLARE_METATYPE(SubTaskType)
|
||||||
|
Q_DECLARE_METATYPE(SubTask)
|
||||||
|
Q_DECLARE_METATYPE(TimedTask)
|
||||||
|
|
||||||
|
// ==================== 任务文件读写类 ====================
|
||||||
|
|
||||||
|
class TimedDataCollectionDataStructuresReaderWriter
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
// 保存任务到文件
|
||||||
|
static bool saveTasksToFile(const QString& filePath, const QVector<TimedTask>& tasks);
|
||||||
|
|
||||||
|
// 从文件读取任务
|
||||||
|
static bool loadTasksFromFile(const QString& filePath, QVector<TimedTask>& tasks);
|
||||||
|
|
||||||
|
private:
|
||||||
|
// SubTask序列化
|
||||||
|
static QJsonObject subTaskToJson(const SubTask& subTask);
|
||||||
|
static bool jsonToSubTask(const QJsonObject& json, SubTask& subTask);
|
||||||
|
|
||||||
|
// TimedTask序列化
|
||||||
|
static QJsonObject timedTaskToJson(const TimedTask& task);
|
||||||
|
static bool jsonToTimedTask(const QJsonObject& json, TimedTask& task);
|
||||||
|
|
||||||
|
// 枚举转换
|
||||||
|
static QString taskStatusToString(TaskStatus status);
|
||||||
|
static TaskStatus stringToTaskStatus(const QString& str);
|
||||||
|
|
||||||
|
static QString subTaskTypeToString(SubTaskType type);
|
||||||
|
static SubTaskType stringToSubTaskType(const QString& str);
|
||||||
|
};
|
||||||
320
HPPA/TimedDataCollection_ui.ui
Normal file
320
HPPA/TimedDataCollection_ui.ui
Normal file
@ -0,0 +1,320 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>TimedDataCollection_ui</class>
|
||||||
|
<widget class="QDialog" name="TimedDataCollection_ui">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>970</width>
|
||||||
|
<height>456</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Dialog</string>
|
||||||
|
</property>
|
||||||
|
<widget class="QTreeWidget" name="treeWidget">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>9</x>
|
||||||
|
<y>9</y>
|
||||||
|
<width>491</width>
|
||||||
|
<height>281</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="allColumnsShowFocus">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<attribute name="headerVisible">
|
||||||
|
<bool>true</bool>
|
||||||
|
</attribute>
|
||||||
|
<column>
|
||||||
|
<property name="text">
|
||||||
|
<string>任务</string>
|
||||||
|
</property>
|
||||||
|
</column>
|
||||||
|
<column>
|
||||||
|
<property name="text">
|
||||||
|
<string>计划时间</string>
|
||||||
|
</property>
|
||||||
|
</column>
|
||||||
|
<column>
|
||||||
|
<property name="text">
|
||||||
|
<string>开始时间</string>
|
||||||
|
</property>
|
||||||
|
</column>
|
||||||
|
<column>
|
||||||
|
<property name="text">
|
||||||
|
<string>结束时间</string>
|
||||||
|
</property>
|
||||||
|
</column>
|
||||||
|
<column>
|
||||||
|
<property name="text">
|
||||||
|
<string>耗时</string>
|
||||||
|
</property>
|
||||||
|
</column>
|
||||||
|
<column>
|
||||||
|
<property name="text">
|
||||||
|
<string>状态</string>
|
||||||
|
</property>
|
||||||
|
</column>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>1</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>a</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>b</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>2</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>a</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>b</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>3</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>a</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>b</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>4</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>a</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>b</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>5</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>a</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>b</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
</item>
|
||||||
|
</widget>
|
||||||
|
<widget class="QPushButton" name="addToptask_btn">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>40</x>
|
||||||
|
<y>310</y>
|
||||||
|
<width>101</width>
|
||||||
|
<height>23</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>添加总计划任务</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QPushButton" name="addSubtask_btn">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>40</x>
|
||||||
|
<y>370</y>
|
||||||
|
<width>101</width>
|
||||||
|
<height>23</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>添加子任务</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QComboBox" name="comboBox">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>170</x>
|
||||||
|
<y>370</y>
|
||||||
|
<width>69</width>
|
||||||
|
<height>22</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QPushButton" name="delSubtask_btn">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>40</x>
|
||||||
|
<y>410</y>
|
||||||
|
<width>101</width>
|
||||||
|
<height>23</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>删除子任务</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QPushButton" name="delToptask_btn">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>40</x>
|
||||||
|
<y>340</y>
|
||||||
|
<width>101</width>
|
||||||
|
<height>23</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>删除总计划任务</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QStackedWidget" name="stackedWidget">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>520</x>
|
||||||
|
<y>20</y>
|
||||||
|
<width>381</width>
|
||||||
|
<height>261</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="currentIndex">
|
||||||
|
<number>1</number>
|
||||||
|
</property>
|
||||||
|
<widget class="QWidget" name="page"/>
|
||||||
|
<widget class="QWidget" name="page_2"/>
|
||||||
|
</widget>
|
||||||
|
<widget class="QPushButton" name="run_btn">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>850</x>
|
||||||
|
<y>420</y>
|
||||||
|
<width>101</width>
|
||||||
|
<height>23</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>运行</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
||||||
@ -18,6 +18,22 @@ TwoMotorControl::TwoMotorControl(QWidget* parent) : QDialog(parent)
|
|||||||
connect(ui.deleteRecordLine_btn, SIGNAL(clicked()), this, SLOT(onDeleteRecordLine_btn()));
|
connect(ui.deleteRecordLine_btn, SIGNAL(clicked()), this, SLOT(onDeleteRecordLine_btn()));
|
||||||
connect(ui.saveRecordLine2File_btn, SIGNAL(clicked()), this, SLOT(onSaveRecordLine2File_btn()));
|
connect(ui.saveRecordLine2File_btn, SIGNAL(clicked()), this, SLOT(onSaveRecordLine2File_btn()));
|
||||||
connect(ui.readRecordLineFile_btn, SIGNAL(clicked()), this, SLOT(onReadRecordLineFile_btn()));
|
connect(ui.readRecordLineFile_btn, SIGNAL(clicked()), this, SLOT(onReadRecordLineFile_btn()));
|
||||||
|
|
||||||
|
connect(this->ui.xmotor_right_btn, SIGNAL(pressed()), this, SLOT(onxMotorRight()));
|
||||||
|
connect(this->ui.xmotor_right_btn, SIGNAL(released()), this, SLOT(onxMotorStop()));
|
||||||
|
connect(this->ui.xmotor_left_btn, SIGNAL(pressed()), this, SLOT(onxMotorLeft()));
|
||||||
|
connect(this->ui.xmotor_left_btn, SIGNAL(released()), this, SLOT(onxMotorStop()));
|
||||||
|
|
||||||
|
connect(this->ui.ymotor_forward_btn, SIGNAL(pressed()), this, SLOT(onyMotorforward()));
|
||||||
|
connect(this->ui.ymotor_forward_btn, SIGNAL(released()), this, SLOT(onyMotorStop()));
|
||||||
|
connect(this->ui.ymotor_backward_btn, SIGNAL(pressed()), this, SLOT(onyMotorbackward()));
|
||||||
|
connect(this->ui.ymotor_backward_btn, SIGNAL(released()), this, SLOT(onyMotorStop()));
|
||||||
|
|
||||||
|
connect(this->ui.move2loc_x_pushButton, SIGNAL(pressed()), this, SLOT(onxMove2Loc()));
|
||||||
|
connect(this->ui.move2loc_y_pushButton, SIGNAL(pressed()), this, SLOT(onyMove2Loc()));
|
||||||
|
|
||||||
|
connect(this->ui.zero_start_btn, SIGNAL(released()), this, SLOT(zeroStart()));
|
||||||
|
connect(this->ui.rangeMeasurement_btn, SIGNAL(pressed()), this, SLOT(on_rangeMeasurement()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TwoMotorControl::setImager(ImagerOperationBase* imager)
|
void TwoMotorControl::setImager(ImagerOperationBase* imager)
|
||||||
@ -34,6 +50,9 @@ void TwoMotorControl::setPosFileName(QString posFileName)
|
|||||||
|
|
||||||
bool TwoMotorControl::getState()
|
bool TwoMotorControl::getState()
|
||||||
{
|
{
|
||||||
|
if (m_coordinator == nullptr)
|
||||||
|
return false;
|
||||||
|
|
||||||
QEventLoop loop;
|
QEventLoop loop;
|
||||||
bool tmp = false;
|
bool tmp = false;
|
||||||
bool received = false;
|
bool received = false;
|
||||||
@ -86,29 +105,39 @@ void TwoMotorControl::record_white()
|
|||||||
|
|
||||||
void TwoMotorControl::run()
|
void TwoMotorControl::run()
|
||||||
{
|
{
|
||||||
if (m_coordinator==nullptr)
|
|
||||||
{
|
|
||||||
qRegisterMetaType<QVector<PathLine>>("QVector<PathLine>");
|
|
||||||
m_coordinator = new TwoMotionCaptureCoordinator(m_multiAxisController, m_Imager);
|
|
||||||
m_coordinator->moveToThread(&m_coordinatorThread);
|
|
||||||
connect(&m_coordinatorThread, SIGNAL(finished()), m_coordinator, SLOT(deleteLater()));
|
|
||||||
connect(this, SIGNAL(start(QVector<PathLine>)), m_coordinator, SLOT(start(QVector<PathLine>)));
|
|
||||||
connect(this, SIGNAL(stopSignal()), m_coordinator, SLOT(stop()));
|
|
||||||
connect(m_coordinator, SIGNAL(startRecordLineNumSignal(int)), this, SLOT(receiveStartRecordLineNum(int)));
|
|
||||||
connect(m_coordinator, SIGNAL(finishRecordLineNumSignal(int)), this, SLOT(receiveFinishRecordLineNum(int)));
|
|
||||||
connect(m_coordinator, SIGNAL(sequenceComplete(int)), this, SLOT(onSequenceComplete()));
|
|
||||||
m_coordinatorThread.start();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getState())
|
if (getState())
|
||||||
{
|
{
|
||||||
//std::cout << "已经开始运行,请勿重复点击!!!!!!!!" << std::endl;
|
QMessageBox::information(this, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("已经开始运行,请勿重复点击!"));
|
||||||
QMessageBox::information(this, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("已经开始运行,请勿重复点击!!!!!!!!!"));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVector<PathLine> pathLines;
|
|
||||||
int rowCount = ui.recordLine_tableWidget->rowCount();
|
int rowCount = ui.recordLine_tableWidget->rowCount();
|
||||||
|
if(rowCount == 0)
|
||||||
|
{
|
||||||
|
QMessageBox::information(this, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("请至少添加一行采集线!"));
|
||||||
|
|
||||||
|
emit sequenceComplete();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
qRegisterMetaType<QVector<PathLine>>("QVector<PathLine>");
|
||||||
|
m_coordinator = new TwoMotionCaptureCoordinator(m_multiAxisController);
|
||||||
|
m_coordinator->moveToThread(&m_coordinatorThread);
|
||||||
|
connect(&m_coordinatorThread, SIGNAL(finished()), m_coordinator, SLOT(deleteLater()));
|
||||||
|
connect(this, SIGNAL(start(QVector<PathLine>)), m_coordinator, SLOT(start(QVector<PathLine>)));
|
||||||
|
|
||||||
|
connect(this, SIGNAL(stopSignal()), m_coordinator, SLOT(stop()));
|
||||||
|
connect(m_coordinator, SIGNAL(startRecordLineNumSignal(int)), this, SLOT(receiveStartRecordLineNum(int)));
|
||||||
|
connect(m_coordinator, SIGNAL(finishRecordLineNumSignal(int)), this, SLOT(receiveFinishRecordLineNum(int)));
|
||||||
|
connect(m_coordinator, SIGNAL(sequenceComplete(int)), this, SLOT(onSequenceComplete()));
|
||||||
|
|
||||||
|
connect(m_coordinator, &TwoMotionCaptureCoordinator::startRecordHSISignal, m_Imager, &ImagerOperationBase::start_record);
|
||||||
|
connect(m_coordinator, &TwoMotionCaptureCoordinator::stopRecordHSISignal, this, &TwoMotorControl::stop_record);
|
||||||
|
connect(m_Imager, &ImagerOperationBase::RecordFinishedSignal_WhenFrameNumberMeet, m_coordinator, &TwoMotionCaptureCoordinator::handleCaptureCompleteWhenFrameNumberMeet);
|
||||||
|
|
||||||
|
m_coordinatorThread.start();
|
||||||
|
|
||||||
|
QVector<PathLine> pathLines;
|
||||||
//int columnCount = ui.recordLine_tableWidget->columnCount();
|
//int columnCount = ui.recordLine_tableWidget->columnCount();
|
||||||
for (size_t i = 0; i < rowCount; i++)
|
for (size_t i = 0; i < rowCount; i++)
|
||||||
{
|
{
|
||||||
@ -128,13 +157,18 @@ void TwoMotorControl::run()
|
|||||||
{
|
{
|
||||||
for (size_t j = 0; j < ui.recordLine_tableWidget->columnCount(); j++)
|
for (size_t j = 0; j < ui.recordLine_tableWidget->columnCount(); j++)
|
||||||
{
|
{
|
||||||
ui.recordLine_tableWidget->item(i, j)->setBackgroundColor(QColor(240, 240, 240));
|
ui.recordLine_tableWidget->item(i, j)->setBackgroundColor(QColor("#0E1C4C"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
emit start(pathLines);
|
emit start(pathLines);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TwoMotorControl::stop_record()
|
||||||
|
{
|
||||||
|
m_Imager->stop_record();
|
||||||
|
}
|
||||||
|
|
||||||
void TwoMotorControl::stop()
|
void TwoMotorControl::stop()
|
||||||
{
|
{
|
||||||
emit stopSignal();
|
emit stopSignal();
|
||||||
@ -151,6 +185,30 @@ TwoMotorControl::~TwoMotorControl()
|
|||||||
|
|
||||||
void TwoMotorControl::onConnectMotor()
|
void TwoMotorControl::onConnectMotor()
|
||||||
{
|
{
|
||||||
|
if (getMotorsConnectionStatus())
|
||||||
|
{
|
||||||
|
QMessageBox msgBox;
|
||||||
|
msgBox.setText(QString::fromLocal8Bit("马达已连接!"));
|
||||||
|
msgBox.exec();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_multiAxisController != nullptr)
|
||||||
|
{
|
||||||
|
disconnect(m_multiAxisController, SIGNAL(broadcastLocationSignal(std::vector<double>)), this, SLOT(displayRealTimeLoc(std::vector<double>)));
|
||||||
|
disconnect(this, SIGNAL(moveSignal(int, bool, double, int)), m_multiAxisController, SLOT(move(int, bool, double, int)));
|
||||||
|
disconnect(this, SIGNAL(move2LocSignal(int, double, double, int)), m_multiAxisController, SLOT(moveTo(int, double, double, int)));
|
||||||
|
disconnect(this, SIGNAL(stopSignal(int)), m_multiAxisController, SLOT(stop(int)));
|
||||||
|
disconnect(this, SIGNAL(zeroStartSignal(int)), m_multiAxisController, SLOT(zeroStart(int)));
|
||||||
|
disconnect(this, SIGNAL(rangeMeasurement(int, double, int)), m_multiAxisController, SLOT(rangeMeasurement(int, double, int)));
|
||||||
|
disconnect(this, SIGNAL(testConnectivitySignal(int, int)), m_multiAxisController, SLOT(testConnectivity(int, int)));
|
||||||
|
disconnect(m_multiAxisController, SIGNAL(broadcastConnectivity(std::vector<int>)), this, SLOT(display_motors_connectivity(std::vector<int>)));
|
||||||
|
|
||||||
|
m_motorThread.quit();
|
||||||
|
m_motorThread.wait();
|
||||||
|
m_multiAxisController = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
FileOperation* fileOperation = new FileOperation();
|
FileOperation* fileOperation = new FileOperation();
|
||||||
@ -164,34 +222,20 @@ void TwoMotorControl::onConnectMotor()
|
|||||||
QMessageBox msgBox;
|
QMessageBox msgBox;
|
||||||
msgBox.setText(QString::fromLocal8Bit("请连接马达!"));
|
msgBox.setText(QString::fromLocal8Bit("请连接马达!"));
|
||||||
msgBox.exec();
|
msgBox.exec();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_multiAxisController->moveToThread(&m_motorThread);
|
m_multiAxisController->moveToThread(&m_motorThread);
|
||||||
connect(&m_motorThread, SIGNAL(finished()), m_multiAxisController, SLOT(deleteLater()));
|
connect(&m_motorThread, SIGNAL(finished()), m_multiAxisController, SLOT(deleteLater()));
|
||||||
|
|
||||||
connect(this->ui.xmotor_right_btn, SIGNAL(pressed()), this, SLOT(onxMotorRight()));
|
|
||||||
connect(this->ui.xmotor_right_btn, SIGNAL(released()), this, SLOT(onxMotorStop()));
|
|
||||||
connect(this->ui.xmotor_left_btn, SIGNAL(pressed()), this, SLOT(onxMotorLeft()));
|
|
||||||
connect(this->ui.xmotor_left_btn, SIGNAL(released()), this, SLOT(onxMotorStop()));
|
|
||||||
|
|
||||||
connect(this->ui.ymotor_forward_btn, SIGNAL(pressed()), this, SLOT(onyMotorforward()));
|
|
||||||
connect(this->ui.ymotor_forward_btn, SIGNAL(released()), this, SLOT(onyMotorStop()));
|
|
||||||
connect(this->ui.ymotor_backward_btn, SIGNAL(pressed()), this, SLOT(onyMotorbackward()));
|
|
||||||
connect(this->ui.ymotor_backward_btn, SIGNAL(released()), this, SLOT(onyMotorStop()));
|
|
||||||
|
|
||||||
connect(this->ui.move2loc_x_pushButton, SIGNAL(pressed()), this, SLOT(onxMove2Loc()));
|
|
||||||
connect(this->ui.move2loc_y_pushButton, SIGNAL(pressed()), this, SLOT(onyMove2Loc()));
|
|
||||||
|
|
||||||
connect(m_multiAxisController, SIGNAL(broadcastLocationSignal(std::vector<double>)), this, SLOT(displayRealTimeLoc(std::vector<double>)));
|
connect(m_multiAxisController, SIGNAL(broadcastLocationSignal(std::vector<double>)), this, SLOT(displayRealTimeLoc(std::vector<double>)));
|
||||||
|
|
||||||
connect(this, SIGNAL(moveSignal(int, bool, double, int)), m_multiAxisController, SLOT(move(int, bool, double, int)));
|
connect(this, SIGNAL(moveSignal(int, bool, double, int)), m_multiAxisController, SLOT(move(int, bool, double, int)));
|
||||||
connect(this, SIGNAL(move2LocSignal(int, double, double, int)), m_multiAxisController, SLOT(moveTo(int, double, double, int)));
|
connect(this, SIGNAL(move2LocSignal(int, double, double, int)), m_multiAxisController, SLOT(moveTo(int, double, double, int)));
|
||||||
connect(this, SIGNAL(stopSignal(int)), m_multiAxisController, SLOT(stop(int)));
|
connect(this, SIGNAL(stopSignal(int)), m_multiAxisController, SLOT(stop(int)));
|
||||||
|
|
||||||
connect(this->ui.zero_start_btn, SIGNAL(released()), this, SLOT(zeroStart()));
|
|
||||||
connect(this, SIGNAL(zeroStartSignal(int)), m_multiAxisController, SLOT(zeroStart(int)));
|
connect(this, SIGNAL(zeroStartSignal(int)), m_multiAxisController, SLOT(zeroStart(int)));
|
||||||
|
|
||||||
connect(this->ui.rangeMeasurement_btn, SIGNAL(pressed()), this, SLOT(on_rangeMeasurement()));
|
|
||||||
connect(this, SIGNAL(rangeMeasurement(int, double, int)), m_multiAxisController, SLOT(rangeMeasurement(int, double, int)));
|
connect(this, SIGNAL(rangeMeasurement(int, double, int)), m_multiAxisController, SLOT(rangeMeasurement(int, double, int)));
|
||||||
|
|
||||||
connect(this, SIGNAL(testConnectivitySignal(int, int)), m_multiAxisController, SLOT(testConnectivity(int, int)));
|
connect(this, SIGNAL(testConnectivitySignal(int, int)), m_multiAxisController, SLOT(testConnectivity(int, int)));
|
||||||
@ -223,15 +267,26 @@ void TwoMotorControl::onSequenceComplete()
|
|||||||
{
|
{
|
||||||
isWritePosFile = false;
|
isWritePosFile = false;
|
||||||
fclose(m_posFileHandle);
|
fclose(m_posFileHandle);
|
||||||
|
|
||||||
|
m_coordinatorThread.quit();
|
||||||
|
m_coordinatorThread.wait();
|
||||||
|
m_coordinator = nullptr;
|
||||||
|
|
||||||
emit sequenceComplete();
|
emit sequenceComplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool TwoMotorControl::getMotorsConnectionStatus()
|
||||||
|
{
|
||||||
|
return m_xMotorConnectionStatus && m_yMotorConnectionStatus;
|
||||||
|
}
|
||||||
|
|
||||||
void TwoMotorControl::display_motors_connectivity(std::vector<int> connectivity)
|
void TwoMotorControl::display_motors_connectivity(std::vector<int> connectivity)
|
||||||
{
|
{
|
||||||
//std::cout << "-----------------------------------"<<connectivity.size()<< std::endl;
|
//std::cout << "-----------------------------------"<<connectivity.size()<< std::endl;
|
||||||
if (connectivity[0])
|
if (connectivity[0])
|
||||||
{
|
{
|
||||||
|
m_xMotorConnectionStatus = true;
|
||||||
|
|
||||||
this->ui.xMotorStateLabel->setStyleSheet(R"(
|
this->ui.xMotorStateLabel->setStyleSheet(R"(
|
||||||
QLabel
|
QLabel
|
||||||
{
|
{
|
||||||
@ -242,6 +297,8 @@ void TwoMotorControl::display_motors_connectivity(std::vector<int> connectivity)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
m_xMotorConnectionStatus = false;
|
||||||
|
|
||||||
this->ui.xMotorStateLabel->setStyleSheet(R"(
|
this->ui.xMotorStateLabel->setStyleSheet(R"(
|
||||||
QLabel
|
QLabel
|
||||||
{
|
{
|
||||||
@ -253,6 +310,8 @@ void TwoMotorControl::display_motors_connectivity(std::vector<int> connectivity)
|
|||||||
|
|
||||||
if (connectivity[1])
|
if (connectivity[1])
|
||||||
{
|
{
|
||||||
|
m_yMotorConnectionStatus = true;
|
||||||
|
|
||||||
this->ui.yMotorStateLabel->setStyleSheet(R"(
|
this->ui.yMotorStateLabel->setStyleSheet(R"(
|
||||||
QLabel
|
QLabel
|
||||||
{
|
{
|
||||||
@ -263,6 +322,8 @@ void TwoMotorControl::display_motors_connectivity(std::vector<int> connectivity)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
m_yMotorConnectionStatus = false;
|
||||||
|
|
||||||
this->ui.yMotorStateLabel->setStyleSheet(R"(
|
this->ui.yMotorStateLabel->setStyleSheet(R"(
|
||||||
QLabel
|
QLabel
|
||||||
{
|
{
|
||||||
@ -271,6 +332,15 @@ void TwoMotorControl::display_motors_connectivity(std::vector<int> connectivity)
|
|||||||
}
|
}
|
||||||
)");
|
)");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(getMotorsConnectionStatus())
|
||||||
|
{
|
||||||
|
this->ui.connect_btn->setText(QString::fromLocal8Bit("已连接"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this->ui.connect_btn->setText(QString::fromLocal8Bit("重新连接"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TwoMotorControl::onxMotorRight()
|
void TwoMotorControl::onxMotorRight()
|
||||||
|
|||||||
@ -8,12 +8,11 @@
|
|||||||
#include "IrisMultiMotorController.h"
|
#include "IrisMultiMotorController.h"
|
||||||
#include "fileOperation.h"
|
#include "fileOperation.h"
|
||||||
#include "CaptureCoordinator.h"
|
#include "CaptureCoordinator.h"
|
||||||
|
#include "MotorWindowBase.h"
|
||||||
|
|
||||||
#define PI 3.1415926
|
#define PI 3.1415926
|
||||||
|
|
||||||
|
class TwoMotorControl : public QDialog, public MotorWindowBase
|
||||||
|
|
||||||
class TwoMotorControl : public QDialog
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@ -26,6 +25,8 @@ public:
|
|||||||
|
|
||||||
void record_dark();
|
void record_dark();
|
||||||
void record_white();
|
void record_white();
|
||||||
|
|
||||||
|
bool getMotorsConnectionStatus();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ImagerOperationBase* m_Imager;
|
ImagerOperationBase* m_Imager;
|
||||||
@ -35,6 +36,8 @@ private:
|
|||||||
QString m_posFileName;
|
QString m_posFileName;
|
||||||
FILE* m_posFileHandle;
|
FILE* m_posFileHandle;
|
||||||
|
|
||||||
|
bool m_xMotorConnectionStatus = false;
|
||||||
|
bool m_yMotorConnectionStatus = false;
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void onConnectMotor();
|
void onConnectMotor();
|
||||||
@ -67,6 +70,8 @@ public Q_SLOTS:
|
|||||||
void receiveFinishRecordLineNum(int lineNum);
|
void receiveFinishRecordLineNum(int lineNum);
|
||||||
void onSequenceComplete();
|
void onSequenceComplete();
|
||||||
|
|
||||||
|
void stop_record();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void moveSignal(int, bool, double, int);
|
void moveSignal(int, bool, double, int);
|
||||||
void move2LocSignal(int, double, double, int);
|
void move2LocSignal(int, double, double, int);
|
||||||
@ -94,5 +99,5 @@ private:
|
|||||||
DarkAndWhiteCaptureCoordinator* m_whiteCaptureCoordinator = nullptr;
|
DarkAndWhiteCaptureCoordinator* m_whiteCaptureCoordinator = nullptr;
|
||||||
|
|
||||||
QThread m_motorThread;
|
QThread m_motorThread;
|
||||||
IrisMultiMotorController* m_multiAxisController;
|
IrisMultiMotorController* m_multiAxisController = nullptr;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -372,4 +372,18 @@ void View3DLinearStage::setLoc(std::vector<double> loc)
|
|||||||
double x = round(loc[0] * 100) / 100;
|
double x = round(loc[0] * 100) / 100;
|
||||||
|
|
||||||
m_armTransform->setTranslation(QVector3D(x, 0, 0));
|
m_armTransform->setTranslation(QVector3D(x, 0, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
View3DMicroscopicMotionModel::View3DMicroscopicMotionModel(const QString& baseModelPath, const QString& armModelPath, QWidget* parent)
|
||||||
|
:View3DBase(baseModelPath, armModelPath, parent)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void View3DMicroscopicMotionModel::setLoc(std::vector<double> loc)
|
||||||
|
{
|
||||||
|
double x = round(loc[0] * 100) / 100;
|
||||||
|
double y = round(loc[1] * 100) / 100;
|
||||||
|
|
||||||
|
m_armTransform->setTranslation(QVector3D(x, y, 0));
|
||||||
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
#ifndef VIEW3D_H
|
#ifndef VIEW3D_H
|
||||||
#define VIEW3D_H
|
#define VIEW3D_H
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
@ -106,6 +106,24 @@ private:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
public Q_SLOTS:
|
||||||
|
void setLoc(std::vector<double> loc);
|
||||||
|
};
|
||||||
|
|
||||||
|
class View3DMicroscopicMotionModel : public View3DBase
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
View3DMicroscopicMotionModel(const QString& baseModelPath,
|
||||||
|
const QString& armModelPath,
|
||||||
|
QWidget* parent = nullptr);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void setLoc(std::vector<double> loc);
|
void setLoc(std::vector<double> loc);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
#include "View3DModelManager.h"
|
#include "View3DModelManager.h"
|
||||||
|
|
||||||
View3DModelManager::View3DModelManager(QWidget* parent)
|
View3DModelManager::View3DModelManager(QWidget* parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
@ -13,15 +13,21 @@ View3DModelManager::View3DModelManager(QWidget* parent)
|
|||||||
|
|
||||||
void View3DModelManager::switchScenario(ScenarioType type)
|
void View3DModelManager::switchScenario(ScenarioType type)
|
||||||
{
|
{
|
||||||
if (type == ScenarioType::PlantPhenotype) {
|
if (type == ScenarioType::PlantPhenotype)
|
||||||
|
{
|
||||||
ensurePlantPhenotypeView();
|
ensurePlantPhenotypeView();
|
||||||
m_stackedWidget->setCurrentWidget(m_viewPlant);
|
m_stackedWidget->setCurrentWidget(m_viewPlant);
|
||||||
}
|
}
|
||||||
else {
|
if (type == ScenarioType::OneMotor)
|
||||||
|
{
|
||||||
ensureOneMotorView();
|
ensureOneMotorView();
|
||||||
m_stackedWidget->setCurrentWidget(m_viewMotor);
|
m_stackedWidget->setCurrentWidget(m_viewMotor);
|
||||||
}
|
}
|
||||||
|
if (type == ScenarioType::MicroscopicMotionControl)
|
||||||
|
{
|
||||||
|
ensureMicroscopicMotionControlView();
|
||||||
|
m_stackedWidget->setCurrentWidget(m_viewMicroscopicMotionControlModel);
|
||||||
|
}
|
||||||
emit scenarioChanged(type);
|
emit scenarioChanged(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,6 +52,27 @@ void View3DModelManager::ensurePlantPhenotypeView()
|
|||||||
emit created3DModelPlantPhenotype();
|
emit created3DModelPlantPhenotype();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void View3DModelManager::ensureMicroscopicMotionControlView()
|
||||||
|
{
|
||||||
|
if (m_viewMicroscopicMotionControlModel)
|
||||||
|
return;
|
||||||
|
|
||||||
|
QString basePath = QCoreApplication::applicationDirPath();
|
||||||
|
|
||||||
|
m_viewMicroscopicMotionControlModel = new View3DMicroscopicMotionModel(
|
||||||
|
basePath + "/3DModel/MicroscopicMotionModel_static.obj",
|
||||||
|
basePath + "/3DModel/MicroscopicMotionModel_moving.obj",
|
||||||
|
m_stackedWidget
|
||||||
|
);
|
||||||
|
|
||||||
|
m_viewMicroscopicMotionControlModel->setViewCenter(1000, 1000, -1000);
|
||||||
|
m_viewMicroscopicMotionControlModel->setDistance(5000);
|
||||||
|
|
||||||
|
m_stackedWidget->addWidget(m_viewMicroscopicMotionControlModel);
|
||||||
|
|
||||||
|
emit created3DModelMicroscopicMotion();
|
||||||
|
}
|
||||||
|
|
||||||
void View3DModelManager::ensureOneMotorView()
|
void View3DModelManager::ensureOneMotorView()
|
||||||
{
|
{
|
||||||
if (m_viewMotor)
|
if (m_viewMotor)
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QStackedWidget>
|
#include <QStackedWidget>
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
@ -16,7 +16,8 @@ class View3DModelManager : public QWidget
|
|||||||
public:
|
public:
|
||||||
enum class ScenarioType {
|
enum class ScenarioType {
|
||||||
PlantPhenotype,
|
PlantPhenotype,
|
||||||
OneMotor
|
OneMotor,
|
||||||
|
MicroscopicMotionControl
|
||||||
};
|
};
|
||||||
|
|
||||||
explicit View3DModelManager(QWidget* parent = nullptr);
|
explicit View3DModelManager(QWidget* parent = nullptr);
|
||||||
@ -25,14 +26,17 @@ public:
|
|||||||
|
|
||||||
View3DPlantPhenotype* m_viewPlant = nullptr;
|
View3DPlantPhenotype* m_viewPlant = nullptr;
|
||||||
View3DLinearStage* m_viewMotor = nullptr;
|
View3DLinearStage* m_viewMotor = nullptr;
|
||||||
|
View3DMicroscopicMotionModel* m_viewMicroscopicMotionControlModel = nullptr;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void scenarioChanged(ScenarioType type);
|
void scenarioChanged(ScenarioType type);
|
||||||
void created3DModelPlantPhenotype();
|
void created3DModelPlantPhenotype();
|
||||||
void created3DModelOneMotor();
|
void created3DModelOneMotor();
|
||||||
|
void created3DModelMicroscopicMotion();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void ensurePlantPhenotypeView();
|
void ensurePlantPhenotypeView();
|
||||||
|
void ensureMicroscopicMotionControlView();
|
||||||
void ensureOneMotorView();
|
void ensureOneMotorView();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@ -288,7 +288,7 @@ QPushButton:pressed
|
|||||||
}</string>
|
}</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>版本:3.0.0</string>
|
<string>版本:3.0.2</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
#include "aboutWindow.h"
|
#include "aboutWindow.h"
|
||||||
#include <QSvgRenderer>
|
#include <QSvgRenderer>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
|
||||||
@ -6,7 +6,7 @@ aboutWindow::aboutWindow(QWidget* parent)
|
|||||||
{
|
{
|
||||||
ui.setupUi(this);
|
ui.setupUi(this);
|
||||||
|
|
||||||
ui.companylname_label->setOpenExternalLinks(true);//<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊtrue<EFBFBD><EFBFBD><EFBFBD>ܴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҳ
|
ui.companylname_label->setOpenExternalLinks(true);//设置为true才能打开网页
|
||||||
QString text = ui.companylname_label->text();
|
QString text = ui.companylname_label->text();
|
||||||
ui.companylname_label->setText("<a style='color: green; text-decoration: none' href = http://www.iris-rs.cn/pr.jsp?_jcp=3_10>" + text);
|
ui.companylname_label->setText("<a style='color: green; text-decoration: none' href = http://www.iris-rs.cn/pr.jsp?_jcp=3_10>" + text);
|
||||||
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user