Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3521a7f225 | |||
| 6111634eff | |||
| 4d42314a84 | |||
| 6456232114 | |||
| 525b39851a | |||
| 5f965f0d8e | |||
| 3568495aa9 | |||
| 410da482bc | |||
| 43acd5ba01 | |||
| 5dc589aee0 | |||
| e8ae6aa3b9 | |||
| 304a1aa28b | |||
| b2ed6e9c73 | |||
| dcce0a6665 | |||
| eda0a01098 |
@ -1,10 +1,13 @@
|
|||||||
#include "AppSettings.h"
|
#include "AppSettings.h"
|
||||||
|
#include <QCoreApplication>
|
||||||
|
|
||||||
const QString AppSettings::kDefaultDataFolder = QStringLiteral("C:\\HPPA_image");
|
const QString AppSettings::kDefaultDataFolder = QStringLiteral("C:\\HPPA_image");
|
||||||
const QString AppSettings::kDefaultFileName = QStringLiteral("test_image");
|
const QString AppSettings::kDefaultFileName = QStringLiteral("test_image");
|
||||||
const int AppSettings::kDefaultFrameRate = 20;
|
const int AppSettings::kDefaultFrameRate = 20;
|
||||||
const int AppSettings::kDefaultIntegrationTime = 1;
|
const int AppSettings::kDefaultIntegrationTime = 1;
|
||||||
const int AppSettings::kDefaultGain = 0;
|
const int AppSettings::kDefaultGain = 0;
|
||||||
|
const QString AppSettings::kDefaultSLRDataFolder = QString();
|
||||||
|
const QString AppSettings::kDefaultDepthCameraDataFolder = QString();
|
||||||
|
|
||||||
AppSettings::AppSettings()
|
AppSettings::AppSettings()
|
||||||
: m_settings(QSettings::IniFormat, QSettings::UserScope,
|
: m_settings(QSettings::IniFormat, QSettings::UserScope,
|
||||||
@ -32,6 +35,7 @@ QString AppSettings::fileName() const
|
|||||||
{
|
{
|
||||||
return m_settings.value("General/FileName", kDefaultFileName).toString();
|
return m_settings.value("General/FileName", kDefaultFileName).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppSettings::setFileName(const QString& path)
|
void AppSettings::setFileName(const QString& path)
|
||||||
{
|
{
|
||||||
m_settings.setValue("General/FileName", path);
|
m_settings.setValue("General/FileName", path);
|
||||||
@ -41,6 +45,7 @@ int AppSettings::frameRate() const
|
|||||||
{
|
{
|
||||||
return m_settings.value("CameraParams/FrameRate", kDefaultFrameRate).toInt();
|
return m_settings.value("CameraParams/FrameRate", kDefaultFrameRate).toInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppSettings::setFrameRate(int value)
|
void AppSettings::setFrameRate(int value)
|
||||||
{
|
{
|
||||||
m_settings.setValue("CameraParams/FrameRate", value);
|
m_settings.setValue("CameraParams/FrameRate", value);
|
||||||
@ -50,6 +55,7 @@ int AppSettings::integrationTime() const
|
|||||||
{
|
{
|
||||||
return m_settings.value("CameraParams/IntegrationTime", kDefaultIntegrationTime).toInt();
|
return m_settings.value("CameraParams/IntegrationTime", kDefaultIntegrationTime).toInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppSettings::setIntegrationTime(int value)
|
void AppSettings::setIntegrationTime(int value)
|
||||||
{
|
{
|
||||||
m_settings.setValue("CameraParams/IntegrationTime", value);
|
m_settings.setValue("CameraParams/IntegrationTime", value);
|
||||||
@ -59,7 +65,38 @@ int AppSettings::gain() const
|
|||||||
{
|
{
|
||||||
return m_settings.value("CameraParams/Gain", kDefaultGain).toInt();
|
return m_settings.value("CameraParams/Gain", kDefaultGain).toInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppSettings::setGain(int value)
|
void AppSettings::setGain(int value)
|
||||||
{
|
{
|
||||||
m_settings.setValue("CameraParams/Gain", 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);
|
||||||
|
}
|
||||||
|
|||||||
@ -26,6 +26,14 @@ public:
|
|||||||
// 增益
|
// 增益
|
||||||
int gain() const;
|
int gain() const;
|
||||||
void setGain(int value);
|
void setGain(int value);
|
||||||
|
|
||||||
|
// 单反相机数据保存路径
|
||||||
|
QString slrDataFolder() const;
|
||||||
|
void setSlrDataFolder(const QString& path);
|
||||||
|
|
||||||
|
// 深度相机数据保存路径
|
||||||
|
QString depthCameraDataFolder() const;
|
||||||
|
void setDepthCameraDataFolder(const QString& path);
|
||||||
// 在此处添加更多参数的 getter/setter ...
|
// 在此处添加更多参数的 getter/setter ...
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -41,4 +49,6 @@ private:
|
|||||||
static const int kDefaultFrameRate;
|
static const int kDefaultFrameRate;
|
||||||
static const int kDefaultIntegrationTime;
|
static const int kDefaultIntegrationTime;
|
||||||
static const int kDefaultGain;
|
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()
|
||||||
@ -98,11 +67,7 @@ void TwoMotionCaptureCoordinator::stop()
|
|||||||
savePathLinesToCsv();
|
savePathLinesToCsv();
|
||||||
|
|
||||||
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();
|
||||||
|
|
||||||
@ -324,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;
|
||||||
|
|||||||
@ -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();
|
||||||
|
|||||||
@ -6,8 +6,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>416</width>
|
<width>857</width>
|
||||||
<height>219</height>
|
<height>477</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
@ -83,19 +83,6 @@ QPushButton:pressed
|
|||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</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">
|
<item row="1" column="1">
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item row="0" column="1">
|
<item row="0" column="1">
|
||||||
@ -126,7 +113,20 @@ QPushButton:pressed
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="2">
|
<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">
|
<spacer name="horizontalSpacer_2">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
@ -139,7 +139,52 @@ QPushButton:pressed
|
|||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="1">
|
<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">
|
<spacer name="verticalSpacer_3">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Vertical</enum>
|
<enum>Qt::Vertical</enum>
|
||||||
|
|||||||
@ -20,6 +20,11 @@ DepthCameraWindow::DepthCameraWindow(QWidget* parent)
|
|||||||
|
|
||||||
connect(m_DepthCameraOperation, &DepthCameraOperation::PlotSignal, this, &DepthCameraWindow::PlotDepthImageSignal);
|
connect(m_DepthCameraOperation, &DepthCameraOperation::PlotSignal, this, &DepthCameraWindow::PlotDepthImageSignal);
|
||||||
connect(m_DepthCameraOperation, &DepthCameraOperation::CamClosedSignal, this, &DepthCameraWindow::DepthCamClosedSignal);
|
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()
|
DepthCameraWindow::~DepthCameraWindow()
|
||||||
@ -30,6 +35,19 @@ DepthCameraWindow::~DepthCameraWindow()
|
|||||||
m_DepthCameraOperation = nullptr;
|
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()
|
void DepthCameraWindow::openDepthCamera()
|
||||||
{
|
{
|
||||||
if (!m_DepthCameraOperation->getRecordStatus())
|
if (!m_DepthCameraOperation->getRecordStatus())
|
||||||
@ -131,7 +149,7 @@ void DepthCameraOperation::OpenDepthCamera()
|
|||||||
|
|
||||||
int frameIndex = 0;
|
int frameIndex = 0;
|
||||||
record = true;
|
record = true;
|
||||||
QString fileNamePrefix = AppSettings::instance().dataFolder() + QDir::separator() + AppSettings::instance().fileName();
|
QString fileNamePrefix = AppSettings::instance().depthCameraDataFolder() + QDir::separator() + AppSettings::instance().fileName();
|
||||||
QString imuFilePath = fileNamePrefix + "_IMU.txt";
|
QString imuFilePath = fileNamePrefix + "_IMU.txt";
|
||||||
std::ofstream imuFile(imuFilePath.toStdString(), std::ios::out | std::ios::trunc);
|
std::ofstream imuFile(imuFilePath.toStdString(), std::ios::out | std::ios::trunc);
|
||||||
while (record)
|
while (record)
|
||||||
|
|||||||
@ -7,6 +7,8 @@
|
|||||||
#include <QImage>
|
#include <QImage>
|
||||||
#include <Qthread>
|
#include <Qthread>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
//#include <QLabel>
|
||||||
|
#include <QFileDialog>
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "ui_DepthCamera.h"
|
#include "ui_DepthCamera.h"
|
||||||
@ -72,6 +74,8 @@ public Q_SLOTS:
|
|||||||
void closeDepthCamera();
|
void closeDepthCamera();
|
||||||
void onCamClosed();
|
void onCamClosed();
|
||||||
|
|
||||||
|
void onSelectDataFolder();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void openDepthCameraSignal();
|
void openDepthCameraSignal();
|
||||||
void PlotDepthImageSignal();
|
void PlotDepthImageSignal();
|
||||||
|
|||||||
427
HPPA/HPPA.cpp
427
HPPA/HPPA.cpp
@ -2,16 +2,22 @@
|
|||||||
//#include <afx.h>
|
//#include <afx.h>
|
||||||
|
|
||||||
#include <exception>
|
#include <exception>
|
||||||
|
#include <memory>
|
||||||
|
#include <vector>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QFileInfo> // 新增,用于解析路径
|
#include <QFileInfo> // 新增,用于解析路径
|
||||||
|
|
||||||
#include "HPPA.h"
|
#include "HPPA.h"
|
||||||
#include "RasterLayer.h"
|
#include "RasterLayer.h"
|
||||||
|
#include "RasterImageLayer.h"
|
||||||
|
#include "RasterRenderParams.h"
|
||||||
#include "LayerTreeLayerNode.h"
|
#include "LayerTreeLayerNode.h"
|
||||||
#include "MapTool.h"
|
#include "MapTool.h"
|
||||||
#include "MapToolPan.h"
|
#include "MapToolPan.h"
|
||||||
#include "MapToolSpectral.h"
|
#include "MapToolSpectral.h"
|
||||||
#include "MapTools.h"
|
#include "MapTools.h"
|
||||||
|
#include <algorithm>
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
HPPA* HPPA::s_instance = nullptr;
|
HPPA* HPPA::s_instance = nullptr;
|
||||||
|
|
||||||
@ -111,6 +117,7 @@ HPPA::HPPA(QWidget* parent)
|
|||||||
connect(this->ui.action_about, SIGNAL(triggered()), this, SLOT(onAbout()));
|
connect(this->ui.action_about, SIGNAL(triggered()), this, SLOT(onAbout()));
|
||||||
connect(this->ui.mActionOneMotorScenario, SIGNAL(triggered()), this, SLOT(createOneMotorScenario()));
|
connect(this->ui.mActionOneMotorScenario, SIGNAL(triggered()), this, SLOT(createOneMotorScenario()));
|
||||||
connect(this->ui.mActionPlantPhenotypeScenario, SIGNAL(triggered()), this, SLOT(createPlantPhenotypeScenario()));
|
connect(this->ui.mActionPlantPhenotypeScenario, SIGNAL(triggered()), this, SLOT(createPlantPhenotypeScenario()));
|
||||||
|
connect(this->ui.mAction3DPlantPhenotypeScenario, SIGNAL(triggered()), this, SLOT(create3DPlantPhenotypeScenario()));
|
||||||
connect(this->ui.mActionMicroscopicMotionControlScenario, SIGNAL(triggered()), this, SLOT(createMicroscopicMotionControlScenario()));
|
connect(this->ui.mActionMicroscopicMotionControlScenario, SIGNAL(triggered()), this, SLOT(createMicroscopicMotionControlScenario()));
|
||||||
|
|
||||||
delete ui.centralWidget;
|
delete ui.centralWidget;
|
||||||
@ -378,6 +385,7 @@ HPPA::HPPA(QWidget* parent)
|
|||||||
m_carousel = new MyCarousel();
|
m_carousel = new MyCarousel();
|
||||||
m_carousel->setObjectName(QString::fromUtf8("carousel"));
|
m_carousel->setObjectName(QString::fromUtf8("carousel"));
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------
|
||||||
QScrollArea* sa = new QScrollArea();
|
QScrollArea* sa = new QScrollArea();
|
||||||
sa->setObjectName("sa");
|
sa->setObjectName("sa");
|
||||||
sa->setStyleSheet(R"(
|
sa->setStyleSheet(R"(
|
||||||
@ -423,6 +431,29 @@ HPPA::HPPA(QWidget* parent)
|
|||||||
m_carousel->addWidget(sa_depthCamera);
|
m_carousel->addWidget(sa_depthCamera);
|
||||||
m_carousel->setContentsMargins(0, 0, 0, 0);
|
m_carousel->setContentsMargins(0, 0, 0, 0);
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------
|
||||||
|
QScrollArea* sa_SingleLensReflexCamera = new QScrollArea();
|
||||||
|
sa_SingleLensReflexCamera->setObjectName("sa_SingleLensReflexCamera");
|
||||||
|
sa_SingleLensReflexCamera->setStyleSheet(R"(
|
||||||
|
border: none;
|
||||||
|
background-color: #0D1233;
|
||||||
|
)");
|
||||||
|
QGridLayout* gridLayout_sa_SingleLensReflexCamera = new QGridLayout(sa_SingleLensReflexCamera);
|
||||||
|
gridLayout_sa_SingleLensReflexCamera->setSpacing(6);
|
||||||
|
gridLayout_sa_SingleLensReflexCamera->setObjectName(QString::fromUtf8("gridLayout_sa_SingleLensReflexCamera"));
|
||||||
|
gridLayout_sa_SingleLensReflexCamera->setVerticalSpacing(0);
|
||||||
|
gridLayout_sa_SingleLensReflexCamera->setContentsMargins(0, 0, 0, 0);
|
||||||
|
|
||||||
|
m_SingleLensReflexCamera_label = new QLabel();
|
||||||
|
m_SingleLensReflexCamera_label->setAlignment(Qt::AlignHCenter);
|
||||||
|
m_SingleLensReflexCamera_label->setStyleSheet(R"(
|
||||||
|
background-color: #0D1233;
|
||||||
|
)");
|
||||||
|
gridLayout_sa_SingleLensReflexCamera->addWidget(m_SingleLensReflexCamera_label);
|
||||||
|
|
||||||
|
m_carousel->addWidget(sa_SingleLensReflexCamera);
|
||||||
|
m_carousel->setContentsMargins(0, 0, 0, 0);
|
||||||
|
|
||||||
m_carousel->play();
|
m_carousel->play();
|
||||||
|
|
||||||
gridLayout_carouselContainer->addWidget(m_carousel);
|
gridLayout_carouselContainer->addWidget(m_carousel);
|
||||||
@ -777,6 +808,9 @@ void HPPA::initControlTabwidget()
|
|||||||
|
|
||||||
//单反相机
|
//单反相机
|
||||||
m_singleLensReflexCameraWindow = new SingleLensReflexCameraWindow();
|
m_singleLensReflexCameraWindow = new SingleLensReflexCameraWindow();
|
||||||
|
connect(m_singleLensReflexCameraWindow, &SingleLensReflexCameraWindow::LiveViewImageReady, this, &HPPA::onLiveViewImageReady);
|
||||||
|
connect(m_singleLensReflexCameraWindow, &SingleLensReflexCameraWindow::LiveViewStopped, this, &HPPA::onLiveViewStopped);
|
||||||
|
|
||||||
ui.controlTabWidget->addTab(m_singleLensReflexCameraWindow, QString::fromLocal8Bit("单反相机"));
|
ui.controlTabWidget->addTab(m_singleLensReflexCameraWindow, QString::fromLocal8Bit("单反相机"));
|
||||||
|
|
||||||
//rgb相机
|
//rgb相机
|
||||||
@ -818,8 +852,8 @@ void HPPA::initControlTabwidget()
|
|||||||
ui.controlTabWidget->addTab(m_tmc, QString::fromLocal8Bit("2轴控制"));
|
ui.controlTabWidget->addTab(m_tmc, QString::fromLocal8Bit("2轴控制"));
|
||||||
|
|
||||||
// Connect ImageControl band change to re-render (m_ic created in initControlTabwidget)
|
// Connect ImageControl band change to re-render (m_ic created in initControlTabwidget)
|
||||||
connect(m_ic, SIGNAL(bandSelectionChanged(double,double,double)),
|
//connect(m_ic, SIGNAL(bandSelectionChanged(double, double, double)),
|
||||||
this, SLOT(onBandSelectionChanged(double,double,double)));
|
// this, SLOT(onBandSelectionChanged(double, double, double)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void HPPA::recordFromRobotArm(int fileCounter)
|
void HPPA::recordFromRobotArm(int fileCounter)
|
||||||
@ -1007,16 +1041,93 @@ void HPPA::removeLayerByTreeIndex()
|
|||||||
if (!model) return;
|
if (!model) return;
|
||||||
|
|
||||||
LayerTreeNode* node = static_cast<LayerTreeNode*>(currentIndexTmp.internalPointer());
|
LayerTreeNode* node = static_cast<LayerTreeNode*>(currentIndexTmp.internalPointer());
|
||||||
|
if (!node || node->type() != LayerTreeNode::Type::Layer) return;
|
||||||
|
|
||||||
|
removeLayerByNode(node);
|
||||||
|
}
|
||||||
|
|
||||||
|
void HPPA::removeLayerByNode(LayerTreeNode* node)
|
||||||
|
{
|
||||||
if (!node || node->type() != LayerTreeNode::Type::Layer) return;
|
if (!node || node->type() != LayerTreeNode::Type::Layer) return;
|
||||||
|
|
||||||
auto* layerNode = static_cast<LayerTreeLayer*>(node);
|
auto* layerNode = static_cast<LayerTreeLayer*>(node);
|
||||||
MapLayer* mapLayer = layerNode->mapLayer();
|
MapLayer* mapLayer = layerNode->mapLayer();
|
||||||
|
|
||||||
|
if (!mapLayer || !m_MapLayerStore) return;
|
||||||
|
|
||||||
|
// 获取该 mapLayer 对应的所有 widget 并从 tab 中移除
|
||||||
|
std::vector<QWidget*> widgets = m_MapLayerStore->widgetsForMapLayer(mapLayer);
|
||||||
|
for (QWidget* widget : widgets)
|
||||||
|
{
|
||||||
|
if (widget && m_imageViewerTabWidget)
|
||||||
|
{
|
||||||
|
const int tabIndex = m_imageViewerTabWidget->indexOf(widget);
|
||||||
|
if (tabIndex >= 0)
|
||||||
|
{
|
||||||
|
m_imageViewerTabWidget->removeTab(tabIndex);
|
||||||
|
}
|
||||||
|
widget->deleteLater();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!mapLayer || mapLayer->layerType() == MapLayer::LayerType::Raster)
|
||||||
|
{
|
||||||
|
if (m_recordFrameCounter)
|
||||||
|
{
|
||||||
|
m_recordFrameCounter->removeCounter(static_cast<RasterLayer*>(mapLayer));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除 MapLayerStore 中的 mapLayer
|
||||||
|
m_MapLayerStore->removeLayer(mapLayer);
|
||||||
|
|
||||||
|
// 删除树模型中的节点
|
||||||
|
LayerTreeNode* parent = node->parentNode();
|
||||||
|
int row = node->rowInParent();
|
||||||
|
LayerTreeNode* removed = m_LayerTreeModel->removeNode(parent, row);
|
||||||
|
if (removed)
|
||||||
|
{
|
||||||
|
delete removed;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void HPPA::showColorImageByTreeIndex()
|
||||||
|
{
|
||||||
|
QModelIndex currentIndexTmp = m_layerTreeView->currentIndex();
|
||||||
|
if (!currentIndexTmp.isValid()) return;
|
||||||
|
|
||||||
|
LayerTreeModel* model = const_cast<LayerTreeModel*>(static_cast<const LayerTreeModel*>(currentIndexTmp.model()));
|
||||||
|
if (!model) return;
|
||||||
|
|
||||||
|
LayerTreeNode* node = static_cast<LayerTreeNode*>(currentIndexTmp.internalPointer());
|
||||||
|
if (!node || node->type() != LayerTreeNode::Type::Layer) return;
|
||||||
|
|
||||||
|
auto* layerNode = static_cast<LayerTreeLayer*>(node);
|
||||||
|
RasterLayer* mapLayer = static_cast<RasterLayer*>(layerNode->mapLayer());
|
||||||
|
|
||||||
|
newImage(mapLayer, RasterImageLayer::RendererType::Multiband, node);
|
||||||
|
}
|
||||||
|
|
||||||
|
void HPPA::removeImageByTreeIndex()
|
||||||
|
{
|
||||||
|
QModelIndex currentIndexTmp = m_layerTreeView->currentIndex();
|
||||||
|
|
||||||
|
if (!currentIndexTmp.isValid()) return;
|
||||||
|
|
||||||
|
LayerTreeModel* model = const_cast<LayerTreeModel*>(static_cast<const LayerTreeModel*>(currentIndexTmp.model()));
|
||||||
|
if (!model) return;
|
||||||
|
|
||||||
|
LayerTreeNode* node = static_cast<LayerTreeNode*>(currentIndexTmp.internalPointer());
|
||||||
|
if (!node || node->type() != LayerTreeNode::Type::Image) return;
|
||||||
|
|
||||||
|
auto* layerNode = static_cast<LayerTreeImageNode*>(node);
|
||||||
|
RasterImageLayer* rasterImageLayer = layerNode->imageLayer();
|
||||||
QWidget* layerWidget = nullptr;
|
QWidget* layerWidget = nullptr;
|
||||||
|
|
||||||
if (mapLayer && m_MapLayerStore)
|
if (rasterImageLayer && m_MapLayerStore)
|
||||||
{
|
{
|
||||||
layerWidget = m_MapLayerStore->widgetForLayer(mapLayer);
|
layerWidget = m_MapLayerStore->widgetForImageLayer(rasterImageLayer);
|
||||||
m_MapLayerStore->removeLayer(mapLayer);
|
m_MapLayerStore->removeImageLayer(rasterImageLayer);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (layerWidget && m_imageViewerTabWidget)
|
if (layerWidget && m_imageViewerTabWidget)
|
||||||
@ -1024,10 +1135,6 @@ void HPPA::removeLayerByTreeIndex()
|
|||||||
const int tabIndex = m_imageViewerTabWidget->indexOf(layerWidget);
|
const int tabIndex = m_imageViewerTabWidget->indexOf(layerWidget);
|
||||||
if (tabIndex >= 0)
|
if (tabIndex >= 0)
|
||||||
{
|
{
|
||||||
if (m_recordFrameCounter)
|
|
||||||
{
|
|
||||||
m_recordFrameCounter->removeCounter(layerWidget);
|
|
||||||
}
|
|
||||||
m_imageViewerTabWidget->removeTab(tabIndex);
|
m_imageViewerTabWidget->removeTab(tabIndex);
|
||||||
}
|
}
|
||||||
layerWidget->deleteLater();
|
layerWidget->deleteLater();
|
||||||
@ -1058,46 +1165,7 @@ void HPPA::removeAllLayersInRasterGroup()
|
|||||||
pending.pop_back();
|
pending.pop_back();
|
||||||
if (!node) continue;
|
if (!node) continue;
|
||||||
|
|
||||||
for (int i = 0; i < node->childCount(); ++i)
|
removeLayerByNode(node);
|
||||||
{
|
|
||||||
pending.push_back(node->childAt(i));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (node->type() != LayerTreeNode::Type::Layer) continue;
|
|
||||||
|
|
||||||
auto* layerNode = static_cast<LayerTreeLayer*>(node);
|
|
||||||
MapLayer* mapLayer = layerNode->mapLayer();
|
|
||||||
QWidget* layerWidget = nullptr;
|
|
||||||
|
|
||||||
if (mapLayer && m_MapLayerStore)
|
|
||||||
{
|
|
||||||
layerWidget = m_MapLayerStore->widgetForLayer(mapLayer);
|
|
||||||
m_MapLayerStore->removeLayer(mapLayer);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (layerWidget && m_imageViewerTabWidget)
|
|
||||||
{
|
|
||||||
const int tabIndex = m_imageViewerTabWidget->indexOf(layerWidget);
|
|
||||||
if (tabIndex >= 0)
|
|
||||||
{
|
|
||||||
if (m_recordFrameCounter)
|
|
||||||
{
|
|
||||||
m_recordFrameCounter->removeCounter(layerWidget);
|
|
||||||
}
|
|
||||||
m_imageViewerTabWidget->removeTab(tabIndex);
|
|
||||||
}
|
|
||||||
layerWidget->deleteLater();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
while (m_RasterGroup->childCount() > 0)
|
|
||||||
{
|
|
||||||
const int row = m_RasterGroup->childCount() - 1;
|
|
||||||
LayerTreeNode* removed = m_LayerTreeModel->removeNode(m_RasterGroup, row);
|
|
||||||
if (removed)
|
|
||||||
{
|
|
||||||
delete removed;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1193,6 +1261,7 @@ void HPPA::createScenarioActionGroup()
|
|||||||
m_ScenarioActionGroup = new QActionGroup(this);
|
m_ScenarioActionGroup = new QActionGroup(this);
|
||||||
m_ScenarioActionGroup->addAction(ui.mActionOneMotorScenario);
|
m_ScenarioActionGroup->addAction(ui.mActionOneMotorScenario);
|
||||||
m_ScenarioActionGroup->addAction(ui.mActionPlantPhenotypeScenario);
|
m_ScenarioActionGroup->addAction(ui.mActionPlantPhenotypeScenario);
|
||||||
|
m_ScenarioActionGroup->addAction(ui.mAction3DPlantPhenotypeScenario);
|
||||||
m_ScenarioActionGroup->addAction(ui.mActionMicroscopicMotionControlScenario);
|
m_ScenarioActionGroup->addAction(ui.mActionMicroscopicMotionControlScenario);
|
||||||
|
|
||||||
// 读取上次选择的结果
|
// 读取上次选择的结果
|
||||||
@ -1210,6 +1279,11 @@ void HPPA::createScenarioActionGroup()
|
|||||||
ui.mActionPlantPhenotypeScenario->setChecked(true);
|
ui.mActionPlantPhenotypeScenario->setChecked(true);
|
||||||
ui.mActionPlantPhenotypeScenario->trigger();
|
ui.mActionPlantPhenotypeScenario->trigger();
|
||||||
}
|
}
|
||||||
|
else if (lastSelectedAction == "mAction3DPlantPhenotypeScenario")
|
||||||
|
{
|
||||||
|
ui.mAction3DPlantPhenotypeScenario->setChecked(true);
|
||||||
|
ui.mAction3DPlantPhenotypeScenario->trigger();
|
||||||
|
}
|
||||||
else if (lastSelectedAction == "mActionMicroscopicMotionControlScenario")
|
else if (lastSelectedAction == "mActionMicroscopicMotionControlScenario")
|
||||||
{
|
{
|
||||||
ui.mActionMicroscopicMotionControlScenario->setChecked(true);
|
ui.mActionMicroscopicMotionControlScenario->setChecked(true);
|
||||||
@ -1245,14 +1319,10 @@ void HPPA::createOneMotorScenario()
|
|||||||
ui.mAction_1AxisMotor->setChecked(true);
|
ui.mAction_1AxisMotor->setChecked(true);
|
||||||
|
|
||||||
//右下角控制tab
|
//右下角控制tab
|
||||||
m_tabManager->hideTab(m_singleLensReflexCameraWindow);
|
m_tabManager->hideAllTabs();
|
||||||
m_tabManager->hideTab(m_depthCameraWindow);
|
|
||||||
m_tabManager->hideTab(m_rgbCameraControlWindow);
|
|
||||||
m_tabManager->hideTab(m_adt);
|
|
||||||
m_tabManager->hideTab(m_pc);
|
|
||||||
m_tabManager->hideTab(m_rac);
|
|
||||||
m_tabManager->hideTab(m_tmc);
|
|
||||||
|
|
||||||
|
m_tabManager->showTab(m_hic);
|
||||||
|
m_tabManager->showTab(m_ic);
|
||||||
m_tabManager->showTab(m_omc);
|
m_tabManager->showTab(m_omc);
|
||||||
|
|
||||||
m_view3DModelManager->switchScenario(View3DModelManager::ScenarioType::OneMotor);
|
m_view3DModelManager->switchScenario(View3DModelManager::ScenarioType::OneMotor);
|
||||||
@ -1280,12 +1350,37 @@ void HPPA::createPlantPhenotypeScenario()
|
|||||||
ui.mAction_2AxisMotor_new->setChecked(true);
|
ui.mAction_2AxisMotor_new->setChecked(true);
|
||||||
|
|
||||||
//右下角控制tab
|
//右下角控制tab
|
||||||
m_tabManager->hideTab(m_rac);
|
m_tabManager->hideAllTabs();
|
||||||
m_tabManager->hideTab(m_omc);
|
|
||||||
|
|
||||||
|
m_tabManager->showTab(m_hic);
|
||||||
|
m_tabManager->showTab(m_ic);
|
||||||
|
m_tabManager->showTab(m_rgbCameraControlWindow);
|
||||||
|
m_tabManager->showTab(m_adt);
|
||||||
|
m_tabManager->showTab(m_pc);
|
||||||
|
m_tabManager->showTab(m_tmc);
|
||||||
|
|
||||||
|
m_view3DModelManager->switchScenario(View3DModelManager::ScenarioType::PlantPhenotype);
|
||||||
|
|
||||||
|
//右上角轮播
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void HPPA::create3DPlantPhenotypeScenario()
|
||||||
|
{
|
||||||
|
//if (ui.mAction3DPlantPhenotypeScenario->isChecked())
|
||||||
|
// return;
|
||||||
|
|
||||||
|
//在菜单中选择移动平台
|
||||||
|
ui.mAction_2AxisMotor_new->setChecked(true);
|
||||||
|
|
||||||
|
//右下角控制tab
|
||||||
|
m_tabManager->hideAllTabs();
|
||||||
|
|
||||||
|
m_tabManager->showTab(m_hic);
|
||||||
|
m_tabManager->showTab(m_ic);
|
||||||
m_tabManager->showTab(m_depthCameraWindow);
|
m_tabManager->showTab(m_depthCameraWindow);
|
||||||
m_tabManager->showTab(m_singleLensReflexCameraWindow);
|
m_tabManager->showTab(m_singleLensReflexCameraWindow);
|
||||||
m_tabManager->showTab(m_rgbCameraControlWindow);
|
//m_tabManager->showTab(m_rgbCameraControlWindow);
|
||||||
m_tabManager->showTab(m_adt);
|
m_tabManager->showTab(m_adt);
|
||||||
m_tabManager->showTab(m_pc);
|
m_tabManager->showTab(m_pc);
|
||||||
m_tabManager->showTab(m_tmc);
|
m_tabManager->showTab(m_tmc);
|
||||||
@ -1305,14 +1400,10 @@ void HPPA::createMicroscopicMotionControlScenario()
|
|||||||
ui.mAction_2AxisMotor_new->setChecked(true);
|
ui.mAction_2AxisMotor_new->setChecked(true);
|
||||||
|
|
||||||
//右下角控制tab
|
//右下角控制tab
|
||||||
m_tabManager->hideTab(m_singleLensReflexCameraWindow);
|
m_tabManager->hideAllTabs();
|
||||||
m_tabManager->hideTab(m_depthCameraWindow);
|
|
||||||
m_tabManager->hideTab(m_rgbCameraControlWindow);
|
|
||||||
m_tabManager->hideTab(m_adt);
|
|
||||||
m_tabManager->hideTab(m_pc);
|
|
||||||
m_tabManager->hideTab(m_rac);
|
|
||||||
m_tabManager->hideTab(m_omc);
|
|
||||||
|
|
||||||
|
m_tabManager->showTab(m_hic);
|
||||||
|
m_tabManager->showTab(m_ic);
|
||||||
m_tabManager->showTab(m_tmc);
|
m_tabManager->showTab(m_tmc);
|
||||||
|
|
||||||
m_view3DModelManager->switchScenario(View3DModelManager::ScenarioType::MicroscopicMotionControl);
|
m_view3DModelManager->switchScenario(View3DModelManager::ScenarioType::MicroscopicMotionControl);
|
||||||
@ -1432,6 +1523,22 @@ bool HPPA::showResultMessageBox(QString title, QString msg)
|
|||||||
|
|
||||||
void HPPA::onStartRecordStep1()
|
void HPPA::onStartRecordStep1()
|
||||||
{
|
{
|
||||||
|
QAction* checkedScenario = m_ScenarioActionGroup->checkedAction();
|
||||||
|
QString checkedScenarioName = checkedScenario->objectName();
|
||||||
|
if (checkedScenarioName == "mAction3DPlantPhenotypeScenario")//计划采集
|
||||||
|
{
|
||||||
|
TimedDataCollection* tmp = new TimedDataCollection();
|
||||||
|
/*m_ic->setWindowFlags(Qt::Widget);*/
|
||||||
|
tmp->show();
|
||||||
|
//tmp->exec();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (checkedScenarioName == "mActionPlantPhenotypeScenario")
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
//判断移动平台
|
//判断移动平台
|
||||||
QAction* checked = moveplatformActionGroup->checkedAction();
|
QAction* checked = moveplatformActionGroup->checkedAction();
|
||||||
if (!checked)
|
if (!checked)
|
||||||
@ -1610,11 +1717,6 @@ QWidget* HPPA::onCreateTab(QString tabName)
|
|||||||
|
|
||||||
m_imageViewerTabWidget->setCurrentIndex(m_imageViewerTabWidget->count() - 1);
|
m_imageViewerTabWidget->setCurrentIndex(m_imageViewerTabWidget->count() - 1);
|
||||||
|
|
||||||
if (m_recordFrameCounter)
|
|
||||||
{
|
|
||||||
m_recordFrameCounter->addCounter(tabTmp);
|
|
||||||
}
|
|
||||||
|
|
||||||
return tabTmp;
|
return tabTmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1631,7 +1733,11 @@ void HPPA::onTabWidgetCurrentChanged(int index)//代码新建一个tab,会调
|
|||||||
if (m_recordFrameCounter)
|
if (m_recordFrameCounter)
|
||||||
{
|
{
|
||||||
QWidget* currentWidget = m_imageViewerTabWidget->widget(index);
|
QWidget* currentWidget = m_imageViewerTabWidget->widget(index);
|
||||||
m_recordFrameCounter->switchTo(currentWidget);
|
MapLayer* currentMapLayer = m_MapLayerStore->mapLayerForWidget(currentWidget);
|
||||||
|
if (currentMapLayer)
|
||||||
|
{
|
||||||
|
m_recordFrameCounter->switchTo(static_cast<RasterLayer*>(currentMapLayer));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//获取绘图控件
|
//获取绘图控件
|
||||||
@ -1651,7 +1757,7 @@ void HPPA::onTabWidgetCurrentChanged(int index)//代码新建一个tab,会调
|
|||||||
// Sync layer tree view selection with the current tab
|
// Sync layer tree view selection with the current tab
|
||||||
if (m_MapLayerStore && m_layerTreeView && m_LayerTreeModel && m_RasterGroup)
|
if (m_MapLayerStore && m_layerTreeView && m_LayerTreeModel && m_RasterGroup)
|
||||||
{
|
{
|
||||||
MapLayer* layer = m_MapLayerStore->layerForWidget(currentWidget);
|
MapLayer* layer = m_MapLayerStore->mapLayerForWidget(currentWidget);
|
||||||
if (layer)
|
if (layer)
|
||||||
{
|
{
|
||||||
// Find the LayerTreeLayer node in m_RasterGroup that matches this layer
|
// Find the LayerTreeLayer node in m_RasterGroup that matches this layer
|
||||||
@ -1671,10 +1777,9 @@ void HPPA::onTabWidgetCurrentChanged(int index)//代码新建一个tab,会调
|
|||||||
m_layerTreeView->selectionModel()->blockSignals(false);
|
m_layerTreeView->selectionModel()->blockSignals(false);
|
||||||
|
|
||||||
// Manually update ImageControl since we blocked the signal
|
// Manually update ImageControl since we blocked the signal
|
||||||
RasterLayer* rl = qobject_cast<RasterLayer*>(layer);
|
QList<Mapcavas*> mapcavas = currentWidget->findChildren<Mapcavas*>();
|
||||||
if (rl)
|
if (!mapcavas.isEmpty()) {
|
||||||
{
|
m_ic->setActiveLayer(mapcavas[0]->imageLayer());
|
||||||
m_ic->setActiveLayer(rl);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1829,6 +1934,22 @@ void HPPA::onClearLabel()
|
|||||||
m_cam_label->setText("closed");
|
m_cam_label->setText("closed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HPPA::onLiveViewImageReady(const QImage& image)
|
||||||
|
{
|
||||||
|
if (m_SingleLensReflexCamera_label && !image.isNull())
|
||||||
|
{
|
||||||
|
// 缩放图像以适应标签大小
|
||||||
|
QPixmap pixmap = QPixmap::fromImage(image);
|
||||||
|
pixmap = pixmap.scaled(m_SingleLensReflexCamera_label->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||||
|
m_SingleLensReflexCamera_label->setPixmap(pixmap);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void HPPA::onLiveViewStopped()
|
||||||
|
{
|
||||||
|
m_SingleLensReflexCamera_label->clear();
|
||||||
|
}
|
||||||
|
|
||||||
void HPPA::onPlotDepthImage()
|
void HPPA::onPlotDepthImage()
|
||||||
{
|
{
|
||||||
QPixmap pixmap = QPixmap::fromImage(m_depthCameraWindow->m_DepthCameraOperation->m_depthImage);
|
QPixmap pixmap = QPixmap::fromImage(m_depthCameraWindow->m_DepthCameraOperation->m_depthImage);
|
||||||
@ -1922,6 +2043,14 @@ void HPPA::onOpenImg()
|
|||||||
QString baseName = fi.completeBaseName();
|
QString baseName = fi.completeBaseName();
|
||||||
|
|
||||||
addLayer(baseName, uri, true);
|
addLayer(baseName, uri, true);
|
||||||
|
|
||||||
|
// 获取影像行数并更新帧数显示
|
||||||
|
MapLayer* mapLayer = m_MapLayerStore->getLayerByAbsolutePath(uri);
|
||||||
|
if (mapLayer && m_recordFrameCounter)
|
||||||
|
{
|
||||||
|
RasterLayer* rasterLayer = static_cast<RasterLayer*>(mapLayer);
|
||||||
|
m_recordFrameCounter->updateFrameCount(rasterLayer, rasterLayer->height());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void HPPA::disconnectImagerAndCleanup()
|
void HPPA::disconnectImagerAndCleanup()
|
||||||
@ -2342,6 +2471,15 @@ void HPPA::onPlotHyperspectralImageRgbImage(int fileNumber, int frameNumber, QSt
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MapLayer* mapLayer = m_MapLayerStore->getLayerByAbsolutePath(filePath);
|
||||||
|
if (mapLayer && m_recordFrameCounter)
|
||||||
|
{
|
||||||
|
m_recordFrameCounter->updateFrameCount(static_cast<RasterLayer*>(mapLayer), m_Imager->getFrameCounter());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ui.mAction3DPlantPhenotypeScenario->isChecked())
|
||||||
|
return;
|
||||||
|
|
||||||
//return;
|
//return;
|
||||||
//获取绘图控件
|
//获取绘图控件
|
||||||
QWidget* currentWidget = m_MapLayerStore->widgetForLayer(filePath);
|
QWidget* currentWidget = m_MapLayerStore->widgetForLayer(filePath);
|
||||||
@ -2350,11 +2488,6 @@ void HPPA::onPlotHyperspectralImageRgbImage(int fileNumber, int frameNumber, QSt
|
|||||||
QList<Mapcavas*> currentImageViewer = currentWidget->findChildren<Mapcavas*>();
|
QList<Mapcavas*> currentImageViewer = currentWidget->findChildren<Mapcavas*>();
|
||||||
currentImageViewer[0]->DisplayFrameNumber(m_Imager->getFrameCounter());//界面中显示已经采集的帧数
|
currentImageViewer[0]->DisplayFrameNumber(m_Imager->getFrameCounter());//界面中显示已经采集的帧数
|
||||||
|
|
||||||
if (m_recordFrameCounter)
|
|
||||||
{
|
|
||||||
m_recordFrameCounter->updateFrameCount(currentWidget, m_Imager->getFrameCounter());
|
|
||||||
}
|
|
||||||
|
|
||||||
//创建需要显示的图像--opencv版本
|
//创建需要显示的图像--opencv版本
|
||||||
ImageProcessor imageProcessor;
|
ImageProcessor imageProcessor;
|
||||||
//cv::Mat rgbImage(*m_Imager->getRgbImage()->m_matRgbImage, cv::Range(0, m_Imager->getFrameCounter()), cv::Range::all());//2022.3.18重构的
|
//cv::Mat rgbImage(*m_Imager->getRgbImage()->m_matRgbImage, cv::Range(0, m_Imager->getFrameCounter()), cv::Range::all());//2022.3.18重构的
|
||||||
@ -2535,10 +2668,18 @@ void WorkerThread3::run()
|
|||||||
void HPPA::onLayerCreatedFromFile(const QString& baseName, const QString& filePath, int fileIndex)
|
void HPPA::onLayerCreatedFromFile(const QString& baseName, const QString& filePath, int fileIndex)
|
||||||
{
|
{
|
||||||
if (!m_LayerTreeModel || !m_RasterGroup) return;
|
if (!m_LayerTreeModel || !m_RasterGroup) return;
|
||||||
|
|
||||||
|
if (ui.mAction3DPlantPhenotypeScenario->isChecked())
|
||||||
|
{
|
||||||
|
addLayer(baseName, filePath, false, false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
addLayer(baseName, filePath, false);
|
addLayer(baseName, filePath, false);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void HPPA::addLayer(const QString& baseName, const QString& filePath,bool refresh)
|
void HPPA::addLayer(const QString& baseName, const QString& filePath,bool refresh, bool isAddImage)
|
||||||
{
|
{
|
||||||
// Create MapLayer first and attach it to a LayerTreeLayerNode
|
// Create MapLayer first and attach it to a LayerTreeLayerNode
|
||||||
RasterLayer* ml = new RasterLayer(baseName, filePath);
|
RasterLayer* ml = new RasterLayer(baseName, filePath);
|
||||||
@ -2546,10 +2687,40 @@ void HPPA::addLayer(const QString& baseName, const QString& filePath,bool refres
|
|||||||
auto* layerNode = new LayerTreeLayer(ml);
|
auto* layerNode = new LayerTreeLayer(ml);
|
||||||
LayerTreeNode* node = m_LayerTreeModel->addLayer(m_RasterGroup, layerNode);
|
LayerTreeNode* node = m_LayerTreeModel->addLayer(m_RasterGroup, layerNode);
|
||||||
|
|
||||||
QWidget* mapcavasContainer = onCreateTab(baseName);
|
if (m_MapLayerStore) m_MapLayerStore->addLayer(ml);
|
||||||
if (m_MapLayerStore) m_MapLayerStore->addLayer(ml, mapcavasContainer);
|
|
||||||
|
if (m_recordFrameCounter)
|
||||||
|
{
|
||||||
|
m_recordFrameCounter->addCounter(ml);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isAddImage)
|
||||||
|
{
|
||||||
|
newImage(ml, RasterImageLayer::RendererType::Multiband, node, refresh);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void HPPA::newImage(RasterLayer* ml, RasterImageLayer::RendererType type, LayerTreeNode* parent, bool refresh)
|
||||||
|
{
|
||||||
|
QWidget* mapcavasContainer = onCreateTab(ml->name());
|
||||||
|
RasterImageLayer* rasterImageLayer = new RasterImageLayer(ml, type);
|
||||||
QList<Mapcavas*> mapcavas = mapcavasContainer->findChildren<Mapcavas*>();
|
QList<Mapcavas*> mapcavas = mapcavasContainer->findChildren<Mapcavas*>();
|
||||||
mapcavas[0]->setLayers(ml);
|
mapcavas[0]->setImageLayer(rasterImageLayer);
|
||||||
|
|
||||||
|
QString title = ml->name();
|
||||||
|
if (type == RasterImageLayer::RendererType::Multiband)
|
||||||
|
{
|
||||||
|
title = title + "-RGB";
|
||||||
|
}
|
||||||
|
else if(type == RasterImageLayer::RendererType::Singleband)
|
||||||
|
{
|
||||||
|
title = title + "-GreyScale";
|
||||||
|
}
|
||||||
|
|
||||||
|
LayerTreeImageNode* imageNode = new LayerTreeImageNode(rasterImageLayer, title);
|
||||||
|
LayerTreeNode* node2 = m_LayerTreeModel->addLayer(parent, imageNode);
|
||||||
|
|
||||||
|
if (m_MapLayerStore) m_MapLayerStore->addImageLayer(ml, rasterImageLayer, mapcavasContainer);
|
||||||
|
|
||||||
if (refresh)
|
if (refresh)
|
||||||
{
|
{
|
||||||
@ -2559,66 +2730,100 @@ void HPPA::addLayer(const QString& baseName, const QString& filePath,bool refres
|
|||||||
|
|
||||||
void HPPA::onLayerTreeSelectionChanged(const QItemSelection& selected, const QItemSelection& deselected)
|
void HPPA::onLayerTreeSelectionChanged(const QItemSelection& selected, const QItemSelection& deselected)
|
||||||
{
|
{
|
||||||
|
//采集过程中禁用图层树的选择功能
|
||||||
|
if (m_RecordState % 2 == 1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Q_UNUSED(deselected);
|
Q_UNUSED(deselected);
|
||||||
|
|
||||||
if (selected.indexes().isEmpty()) {
|
if (selected.indexes().isEmpty())
|
||||||
|
{
|
||||||
m_ic->setActiveLayer(nullptr);
|
m_ic->setActiveLayer(nullptr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QModelIndex idx = selected.indexes().first();
|
QModelIndex idx = selected.indexes().first();
|
||||||
if (!idx.isValid()) {
|
if (!idx.isValid())
|
||||||
|
{
|
||||||
m_ic->setActiveLayer(nullptr);
|
m_ic->setActiveLayer(nullptr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
LayerTreeNode* node = static_cast<LayerTreeNode*>(idx.internalPointer());
|
LayerTreeNode* node = static_cast<LayerTreeNode*>(idx.internalPointer());
|
||||||
if (!node || node->type() != LayerTreeNode::Type::Layer) {
|
|
||||||
|
if (!node || node->type() == LayerTreeNode::Type::Group)
|
||||||
|
{
|
||||||
m_ic->setActiveLayer(nullptr);
|
m_ic->setActiveLayer(nullptr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* layerNode = static_cast<LayerTreeLayer*>(node);
|
//后续工作:当选择图层树中的图层时,应该显示此图层的元数据
|
||||||
MapLayer* mapLayer = layerNode->mapLayer();
|
if (!node || node->type() == LayerTreeNode::Type::Layer)
|
||||||
|
{
|
||||||
|
m_ic->setActiveLayer(nullptr);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!node || node->type() == LayerTreeNode::Type::Image)
|
||||||
|
{
|
||||||
|
auto* imageNode = static_cast<LayerTreeImageNode*>(node);
|
||||||
|
RasterImageLayer* imageLayer = imageNode->imageLayer();
|
||||||
|
MapLayer* mapLayer = imageLayer->layer();
|
||||||
|
|
||||||
if (!mapLayer || mapLayer->layerType() != MapLayer::LayerType::Raster) {
|
if (!mapLayer || mapLayer->layerType() != MapLayer::LayerType::Raster) {
|
||||||
m_ic->setActiveLayer(nullptr);
|
m_ic->setActiveLayer(nullptr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
RasterLayer* rl = static_cast<RasterLayer*>(mapLayer);
|
if (m_MapLayerStore && m_imageViewerTabWidget)
|
||||||
m_ic->setActiveLayer(rl);
|
{
|
||||||
|
QWidget* widget = m_MapLayerStore->widgetForImageLayer(imageLayer);
|
||||||
// Also switch to the corresponding tab in the image viewer
|
if (widget)
|
||||||
if (m_MapLayerStore && m_imageViewerTabWidget) {
|
{
|
||||||
QWidget* widget = m_MapLayerStore->widgetForLayer(mapLayer);
|
|
||||||
if (widget) {
|
|
||||||
int tabIndex = m_imageViewerTabWidget->indexOf(widget);
|
int tabIndex = m_imageViewerTabWidget->indexOf(widget);
|
||||||
if (tabIndex >= 0) {
|
if (tabIndex >= 0)
|
||||||
|
{
|
||||||
m_imageViewerTabWidget->setCurrentIndex(tabIndex);
|
m_imageViewerTabWidget->setCurrentIndex(tabIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QList<Mapcavas*> mapcavas = widget->findChildren<Mapcavas*>();
|
||||||
|
if (!mapcavas.isEmpty())
|
||||||
|
{
|
||||||
|
m_ic->setActiveLayer(mapcavas[0]->imageLayer());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_ic->setActiveLayer(nullptr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_ic->setActiveLayer(nullptr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void HPPA::onBandSelectionChanged(double rWave, double gWave, double bWave)
|
void HPPA::onBandSelectionChanged(double rWave, double gWave, double bWave)
|
||||||
{
|
{
|
||||||
RasterLayer* rl = m_ic->activeLayer();
|
RasterImageLayer* imageLayer = m_ic->activeLayer();
|
||||||
if (!rl) return;
|
if (!imageLayer) return;
|
||||||
|
|
||||||
|
auto params = imageLayer->multibandParams();
|
||||||
|
params.rWave = rWave;
|
||||||
|
params.gWave = gWave;
|
||||||
|
params.bWave = bWave;
|
||||||
|
imageLayer->setMultibandParams(params);
|
||||||
|
|
||||||
// Find the Mapcavas widget associated with this layer and re-render
|
|
||||||
if (!m_MapLayerStore) return;
|
if (!m_MapLayerStore) return;
|
||||||
|
MapLayer* mapLayer = imageLayer->layer();
|
||||||
QWidget* container = m_MapLayerStore->widgetForLayer(rl);
|
QWidget* container = m_MapLayerStore->widgetForImageLayer(imageLayer);
|
||||||
if (!container) return;
|
if (!container) return;
|
||||||
|
|
||||||
QList<Mapcavas*> mapcavas = container->findChildren<Mapcavas*>();
|
QList<Mapcavas*> mapcavas = container->findChildren<Mapcavas*>();
|
||||||
if (mapcavas.isEmpty()) return;
|
if (mapcavas.isEmpty()) return;
|
||||||
|
|
||||||
RasterLayer::RenderParams params = rl->currentRenderParams();
|
mapcavas[0]->freshmap();
|
||||||
params.rWave = rWave;
|
|
||||||
params.gWave = gWave;
|
|
||||||
params.bWave = bWave;
|
|
||||||
rl->setCurrentRenderParams(params);
|
|
||||||
|
|
||||||
mapcavas[0]->freshmap(params);
|
|
||||||
}
|
}
|
||||||
|
|||||||
15
HPPA/HPPA.h
15
HPPA/HPPA.h
@ -81,6 +81,10 @@
|
|||||||
#include "DepthCameraWindow.h"
|
#include "DepthCameraWindow.h"
|
||||||
#include "SingleLensReflexCameraWindow.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 使用 需要加宏, 否则无法使用
|
||||||
@ -272,6 +276,7 @@ private:
|
|||||||
|
|
||||||
MyCarousel* m_carousel;
|
MyCarousel* m_carousel;
|
||||||
QLabel* m_cam_label;
|
QLabel* m_cam_label;
|
||||||
|
QLabel* m_SingleLensReflexCamera_label;
|
||||||
QLabel* m_depthCamera_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;
|
||||||
@ -356,6 +361,9 @@ public Q_SLOTS:
|
|||||||
void onPlotRgbImage();
|
void onPlotRgbImage();
|
||||||
void onPlotDepthImage();
|
void onPlotDepthImage();
|
||||||
|
|
||||||
|
void onLiveViewImageReady(const QImage& image);
|
||||||
|
void HPPA::onLiveViewStopped();
|
||||||
|
|
||||||
void onClearLabel();
|
void onClearLabel();
|
||||||
void onClearDepthLabel();
|
void onClearDepthLabel();
|
||||||
|
|
||||||
@ -367,14 +375,19 @@ public Q_SLOTS:
|
|||||||
|
|
||||||
void createOneMotorScenario();
|
void createOneMotorScenario();
|
||||||
void createPlantPhenotypeScenario();
|
void createPlantPhenotypeScenario();
|
||||||
|
void create3DPlantPhenotypeScenario();
|
||||||
void onCreated3DModelPlantPhenotype();
|
void onCreated3DModelPlantPhenotype();
|
||||||
void onCreated3DModelMicroscopicMotion();
|
void onCreated3DModelMicroscopicMotion();
|
||||||
void createMicroscopicMotionControlScenario();
|
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);
|
||||||
|
|||||||
@ -134,6 +134,7 @@ color:white;
|
|||||||
<addaction name="mActionOneMotorScenario"/>
|
<addaction name="mActionOneMotorScenario"/>
|
||||||
<addaction name="mActionPlantPhenotypeScenario"/>
|
<addaction name="mActionPlantPhenotypeScenario"/>
|
||||||
<addaction name="mActionMicroscopicMotionControlScenario"/>
|
<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">
|
||||||
@ -734,6 +735,14 @@ QPushButton:pressed
|
|||||||
<string>显微运动控制台</string>
|
<string>显微运动控制台</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</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;C:\Program Files\OrbbecSDK 2.7.6\include;$(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;C:\Program Files\OrbbecSDK 2.7.6\lib;$(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;C:\Program Files\OrbbecSDK 2.7.6\include;$(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;C:\Program Files\OrbbecSDK 2.7.6\lib;$(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;OrbbecSDK.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;OrbbecSDK.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>
|
||||||
@ -124,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" />
|
||||||
@ -143,7 +144,10 @@
|
|||||||
<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" />
|
||||||
@ -157,6 +161,8 @@
|
|||||||
<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" />
|
||||||
@ -189,6 +195,7 @@
|
|||||||
<QtUic Include="RobotArmControl.ui" />
|
<QtUic Include="RobotArmControl.ui" />
|
||||||
<QtUic Include="set.ui" />
|
<QtUic Include="set.ui" />
|
||||||
<QtUic Include="SingleLensReflexCamera.ui" />
|
<QtUic Include="SingleLensReflexCamera.ui" />
|
||||||
|
<QtUic Include="TimedDataCollection_ui.ui" />
|
||||||
<QtUic Include="twoMotorControl.ui" />
|
<QtUic Include="twoMotorControl.ui" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@ -229,6 +236,7 @@
|
|||||||
<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" />
|
||||||
@ -237,11 +245,16 @@
|
|||||||
<QtMoc Include="MapTools.h" />
|
<QtMoc Include="MapTools.h" />
|
||||||
<ClInclude Include="MotorWindowBase.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="setWindow.h" />
|
||||||
<QtMoc Include="rgbCameraWindow.h" />
|
<QtMoc Include="rgbCameraWindow.h" />
|
||||||
<QtMoc Include="SingleLensReflexCameraWindow.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">
|
||||||
@ -220,6 +226,18 @@
|
|||||||
<ClCompile Include="SingleLensReflexCameraWindow.cpp">
|
<ClCompile Include="SingleLensReflexCameraWindow.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</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">
|
||||||
@ -360,6 +378,12 @@
|
|||||||
<QtMoc Include="SingleLensReflexCameraWindow.h">
|
<QtMoc Include="SingleLensReflexCameraWindow.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</QtMoc>
|
</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">
|
||||||
@ -395,7 +419,16 @@
|
|||||||
<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">
|
||||||
@ -407,6 +440,9 @@
|
|||||||
<ClInclude Include="MotorWindowBase.h">
|
<ClInclude Include="MotorWindowBase.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="TimedDataCollectionDataStructures.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<QtUic Include="FocusDialog.ui">
|
<QtUic Include="FocusDialog.ui">
|
||||||
@ -457,6 +493,9 @@
|
|||||||
<QtUic Include="SingleLensReflexCamera.ui">
|
<QtUic Include="SingleLensReflexCamera.ui">
|
||||||
<Filter>Form Files</Filter>
|
<Filter>Form Files</Filter>
|
||||||
</QtUic>
|
</QtUic>
|
||||||
|
<QtUic Include="TimedDataCollection_ui.ui">
|
||||||
|
<Filter>Form Files</Filter>
|
||||||
|
</QtUic>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="cpp.hint" />
|
<None Include="cpp.hint" />
|
||||||
|
|||||||
@ -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"
|
||||||
|
|
||||||
|
|
||||||
@ -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);
|
||||||
|
|||||||
@ -4,7 +4,8 @@
|
|||||||
#include "QGraphicsView"
|
#include "QGraphicsView"
|
||||||
#include "qlabel.h"
|
#include "qlabel.h"
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
#include "RasterLayer.h"
|
|
||||||
|
class RasterImageLayer;
|
||||||
|
|
||||||
class MapTool;
|
class MapTool;
|
||||||
|
|
||||||
@ -47,12 +48,11 @@ public:
|
|||||||
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);
|
||||||
@ -65,7 +65,7 @@ private:
|
|||||||
QGraphicsPixmapItem *m_GraphicsPixmapItemHandle;
|
QGraphicsPixmapItem *m_GraphicsPixmapItemHandle;
|
||||||
QLabel *m_framNumberLabel;//显示实时采集到的帧数
|
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; // 平移速度
|
qreal m_translateSpeed; // 平移速度
|
||||||
|
|||||||
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)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "LayerTreeNode.h"
|
#include "LayerTreeGroupNode.h"
|
||||||
#include "MapLayer.h"
|
#include "MapLayer.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -7,13 +7,13 @@
|
|||||||
* - 基类为 LayerTreeNode
|
* - 基类为 LayerTreeNode
|
||||||
* - 持有一个 MapLayer 指针(不拥有)
|
* - 持有一个 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;
|
||||||
|
|||||||
@ -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;
|
||||||
|
|||||||
@ -34,7 +34,7 @@ public:
|
|||||||
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;
|
||||||
|
|||||||
@ -19,7 +19,7 @@ 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);
|
||||||
|
|||||||
@ -36,9 +36,20 @@ QMenu* LayerTreeViewMenuProvider::createContextMenu()
|
|||||||
|
|
||||||
if (node->type() == LayerTreeNode::Type::Layer)
|
if (node->type() == LayerTreeNode::Type::Layer)
|
||||||
{
|
{
|
||||||
QAction* removeAction = new QAction(QStringLiteral("移除图层"), 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)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,43 +1,93 @@
|
|||||||
#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);
|
||||||
|
if (it == m_mapLayerIndex.end()) return;
|
||||||
|
|
||||||
|
int index = it->second;
|
||||||
|
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);
|
emit layerAboutToBeRemoved(layer);
|
||||||
m_layers.erase(it);
|
|
||||||
m_layerWidgets.erase(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;
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -48,12 +98,12 @@ bool MapLayerStore::containsLayer(const QString& url, bool isAbsolutePath) const
|
|||||||
QFileInfo fi(url);
|
QFileInfo fi(url);
|
||||||
QString fileName = fi.completeBaseName();
|
QString fileName = fi.completeBaseName();
|
||||||
|
|
||||||
if (!isAbsolutePath)
|
if (!isAbsolutePath) {
|
||||||
{
|
|
||||||
return getLayer(fileName) != nullptr;
|
return getLayer(fileName) != nullptr;
|
||||||
}
|
}
|
||||||
for (const auto& l : m_layers) {
|
|
||||||
if (l->dataPath() == url)
|
for (const auto& entry : m_layers) {
|
||||||
|
if (entry.mapLayer->dataPath() == url)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -61,16 +111,27 @@ bool MapLayerStore::containsLayer(const QString& url, bool isAbsolutePath) const
|
|||||||
|
|
||||||
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
|
||||||
@ -78,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];
|
||||||
|
}
|
||||||
|
|||||||
@ -2,53 +2,71 @@
|
|||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QFileInfo>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#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);
|
|
||||||
|
|
||||||
bool containsLayer(const QString& url, bool isAbsolutePath = true) const;
|
|
||||||
|
|
||||||
// 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
|
||||||
|
|||||||
@ -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);
|
||||||
|
};
|
||||||
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,12 +1,9 @@
|
|||||||
#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()
|
||||||
@ -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();
|
||||||
|
}
|
||||||
|
|||||||
@ -2,11 +2,10 @@
|
|||||||
|
|
||||||
#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;
|
||||||
|
};
|
||||||
@ -69,7 +69,7 @@ QPushButton:pressed
|
|||||||
padding-bottom: 7px;
|
padding-bottom: 7px;
|
||||||
}</string>
|
}</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout_2">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item row="0" column="1">
|
<item row="0" column="1">
|
||||||
<spacer name="verticalSpacer">
|
<spacer name="verticalSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
@ -97,21 +97,8 @@ QPushButton:pressed
|
|||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1">
|
<item row="1" column="1">
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
<item row="0" column="1">
|
<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>
|
|
||||||
<item row="0" column="0">
|
|
||||||
<widget class="QPushButton" name="openSLRCamera_btn">
|
<widget class="QPushButton" name="openSLRCamera_btn">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||||
@ -124,9 +111,22 @@ QPushButton:pressed
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</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>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="2">
|
<item row="2" column="2">
|
||||||
<spacer name="horizontalSpacer_2">
|
<spacer name="horizontalSpacer_2">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
@ -139,7 +139,52 @@ QPushButton:pressed
|
|||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="1">
|
<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">
|
<spacer name="verticalSpacer_3">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Vertical</enum>
|
<enum>Qt::Vertical</enum>
|
||||||
@ -152,7 +197,42 @@ QPushButton:pressed
|
|||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</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>
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
<zorder>dataFolderLineEdit</zorder>
|
||||||
|
<zorder>dataFolderBtn</zorder>
|
||||||
|
<zorder>label</zorder>
|
||||||
|
<zorder>openSLRCamera_btn</zorder>
|
||||||
|
<zorder>layoutWidget</zorder>
|
||||||
</widget>
|
</widget>
|
||||||
<layoutdefault spacing="6" margin="11"/>
|
<layoutdefault spacing="6" margin="11"/>
|
||||||
<resources/>
|
<resources/>
|
||||||
|
|||||||
@ -1,7 +1,14 @@
|
|||||||
#include "SingleLensReflexCameraWindow.h"
|
#include "SingleLensReflexCameraWindow.h"
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QCoreApplication>
|
||||||
|
#include <QBuffer>
|
||||||
|
|
||||||
|
// 全局变量用于回调函数访问
|
||||||
|
static SingleLensReflexCameraOperation* g_cameraOperation = nullptr;
|
||||||
|
|
||||||
SingleLensReflexCameraWindow::SingleLensReflexCameraWindow(QWidget* parent)
|
SingleLensReflexCameraWindow::SingleLensReflexCameraWindow(QWidget* parent)
|
||||||
: QDialog(parent)
|
: QDialog(parent)
|
||||||
|
, m_isCapturing(false)
|
||||||
{
|
{
|
||||||
ui.setupUi(this);
|
ui.setupUi(this);
|
||||||
|
|
||||||
@ -10,26 +17,81 @@ SingleLensReflexCameraWindow::SingleLensReflexCameraWindow(QWidget* parent)
|
|||||||
m_SingleLensReflexCameraOperation->moveToThread(m_SLRCameraThread);
|
m_SingleLensReflexCameraOperation->moveToThread(m_SLRCameraThread);
|
||||||
m_SLRCameraThread->start();
|
m_SLRCameraThread->start();
|
||||||
|
|
||||||
|
// 基本连接
|
||||||
connect(ui.openSLRCamera_btn, &QPushButton::clicked, this, &SingleLensReflexCameraWindow::openSLRCamera);
|
connect(ui.openSLRCamera_btn, &QPushButton::clicked, this, &SingleLensReflexCameraWindow::openSLRCamera);
|
||||||
connect(ui.closeSLRCamera_btn, &QPushButton::clicked, this, &SingleLensReflexCameraWindow::closeSLRCamera);
|
|
||||||
|
|
||||||
connect(this, &SingleLensReflexCameraWindow::openSLRCameraSignal, m_SingleLensReflexCameraOperation, &SingleLensReflexCameraOperation::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::CamOpenedSignal, this, &SingleLensReflexCameraWindow::onCamOpened);
|
||||||
connect(m_SingleLensReflexCameraOperation, &SingleLensReflexCameraOperation::CamClosedSignal, this, &SingleLensReflexCameraWindow::onCamClosed);
|
connect(m_SingleLensReflexCameraOperation, &SingleLensReflexCameraOperation::CamClosedSignal, this, &SingleLensReflexCameraWindow::onCamClosed);
|
||||||
|
|
||||||
connect(m_SingleLensReflexCameraOperation, &SingleLensReflexCameraOperation::PlotSignal, this, &SingleLensReflexCameraWindow::PlotSLRImageSignal);
|
connect(m_SingleLensReflexCameraOperation, &SingleLensReflexCameraOperation::PlotSignal, this, &SingleLensReflexCameraWindow::PlotSLRImageSignal);
|
||||||
connect(m_SingleLensReflexCameraOperation, &SingleLensReflexCameraOperation::CamClosedSignal, this, &SingleLensReflexCameraWindow::SLRCamClosedSignal);
|
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()
|
SingleLensReflexCameraWindow::~SingleLensReflexCameraWindow()
|
||||||
{
|
{
|
||||||
|
// 先停止拍照
|
||||||
|
if (m_SingleLensReflexCameraOperation->getRecordStatus())
|
||||||
|
{
|
||||||
|
m_SingleLensReflexCameraOperation->CloseSLRCamera();
|
||||||
|
}
|
||||||
|
|
||||||
m_SLRCameraThread->quit();
|
m_SLRCameraThread->quit();
|
||||||
m_SLRCameraThread->wait();
|
m_SLRCameraThread->wait();
|
||||||
delete m_SingleLensReflexCameraOperation;
|
delete m_SingleLensReflexCameraOperation;
|
||||||
m_SingleLensReflexCameraOperation = nullptr;
|
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()
|
void SingleLensReflexCameraWindow::openSLRCamera()
|
||||||
{
|
{
|
||||||
if (!m_SingleLensReflexCameraOperation->getRecordStatus())
|
if (!m_SingleLensReflexCameraOperation->getRecordStatus())
|
||||||
@ -38,46 +100,707 @@ void SingleLensReflexCameraWindow::openSLRCamera()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SingleLensReflexCameraWindow::takePhoto()
|
||||||
|
{
|
||||||
|
if (m_SingleLensReflexCameraOperation->getRecordStatus())
|
||||||
|
{
|
||||||
|
emit takePhotoSignal();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SingleLensReflexCameraWindow::stopTakePhoto()
|
||||||
|
{
|
||||||
|
if (m_SingleLensReflexCameraOperation->getRecordStatus())
|
||||||
|
{
|
||||||
|
emit stopTakePhotoSignal();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void SingleLensReflexCameraWindow::onCamOpened()
|
void SingleLensReflexCameraWindow::onCamOpened()
|
||||||
{
|
{
|
||||||
ui.openSLRCamera_btn->setEnabled(false);
|
ui.openSLRCamera_btn->setEnabled(false);
|
||||||
ui.closeSLRCamera_btn->setEnabled(true);
|
ui.closeSLRCamera_btn->setEnabled(true);
|
||||||
|
|
||||||
ui.openSLRCamera_btn->setText(QString::fromLocal8Bit("已打开"));
|
ui.openSLRCamera_btn->setText(QString::fromLocal8Bit("已打开"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SingleLensReflexCameraWindow::closeSLRCamera()
|
void SingleLensReflexCameraWindow::closeSLRCamera()
|
||||||
{
|
{
|
||||||
m_SingleLensReflexCameraOperation->CloseSLRCamera();
|
emit closeSLRCameraSignal();
|
||||||
|
//m_SingleLensReflexCameraOperation->CloseSLRCamera();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SingleLensReflexCameraWindow::onCamClosed()
|
void SingleLensReflexCameraWindow::onCamClosed()
|
||||||
{
|
{
|
||||||
ui.openSLRCamera_btn->setEnabled(true);
|
ui.openSLRCamera_btn->setEnabled(true);
|
||||||
ui.closeSLRCamera_btn->setEnabled(false);
|
ui.closeSLRCamera_btn->setEnabled(false);
|
||||||
|
|
||||||
ui.openSLRCamera_btn->setText(QString::fromLocal8Bit("打 开"));
|
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()
|
SingleLensReflexCameraOperation::SingleLensReflexCameraOperation()
|
||||||
{
|
{
|
||||||
m_func = nullptr;
|
m_func = nullptr;
|
||||||
record = false;
|
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()
|
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()
|
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::OpenSLRCamera_callback()
|
||||||
{
|
{
|
||||||
|
// 不使用信号而使用回调函数来通知界面刷新视频
|
||||||
}
|
}
|
||||||
|
|
||||||
void SingleLensReflexCameraOperation::setCallback(void(*func)())
|
void SingleLensReflexCameraOperation::setCallback(void(*func)())
|
||||||
@ -85,11 +808,111 @@ void SingleLensReflexCameraOperation::setCallback(void(*func)())
|
|||||||
m_func = 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()
|
void SingleLensReflexCameraOperation::CloseSLRCamera()
|
||||||
{
|
{
|
||||||
std::cout << "SingleLensReflexCameraOperation::CloseSLRCamera,关闭单反相机" << std::endl;
|
std::cout << "SingleLensReflexCameraOperation::CloseSLRCamera,关闭单反相机" << std::endl;
|
||||||
|
|
||||||
record = false;
|
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();
|
emit CamClosedSignal();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,8 +5,13 @@
|
|||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
#include <QNetworkAccessManager>
|
#include <QNetworkAccessManager>
|
||||||
#include <QImage>
|
#include <QImage>
|
||||||
#include <Qthread>
|
#include <QThread>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
#include <QTimer>
|
||||||
|
#include <QMutex>
|
||||||
|
#include <QDateTime>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QFileDialog>
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "ui_SingleLensReflexCamera.h"
|
#include "ui_SingleLensReflexCamera.h"
|
||||||
@ -14,6 +19,12 @@
|
|||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <opencv2/opencv.hpp>
|
#include <opencv2/opencv.hpp>
|
||||||
|
|
||||||
|
// 包含Canon EDSDK头文件
|
||||||
|
#include "EDSDK.h"
|
||||||
|
#include "EDSDKTypes.h"
|
||||||
|
#include "EDSDKErrors.h"
|
||||||
|
|
||||||
typedef void(*func)();
|
typedef void(*func)();
|
||||||
|
|
||||||
class SingleLensReflexCameraOperation : public QObject
|
class SingleLensReflexCameraOperation : public QObject
|
||||||
@ -27,25 +38,84 @@ public:
|
|||||||
QImage m_colorImage;
|
QImage m_colorImage;
|
||||||
QImage m_depthImage;
|
QImage m_depthImage;
|
||||||
void setCallback(void(*func)());
|
void setCallback(void(*func)());
|
||||||
bool getRecordStatus() const { return record; }
|
bool getRecordStatus() const { return m_isRecord; }
|
||||||
|
|
||||||
|
// 设置保存路径
|
||||||
|
void setSavePath(const QString& path);
|
||||||
|
|
||||||
|
// 获取当前实时取景图像
|
||||||
|
QImage getCurrentLiveViewImage();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
cv::Mat frame;
|
cv::Mat frame;
|
||||||
|
|
||||||
func m_func;
|
func m_func;
|
||||||
|
bool m_isRecord;
|
||||||
|
|
||||||
bool record;
|
// 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:
|
public slots:
|
||||||
void OpenSLRCamera();
|
void OpenSLRCamera();
|
||||||
void OpenSLRCamera_callback();//不使用信号而使用回调函数来通知界面刷新视频
|
void takePhoto();
|
||||||
|
void stopTakePhoto();
|
||||||
|
void OpenSLRCamera_callback();
|
||||||
void CloseSLRCamera();
|
void CloseSLRCamera();
|
||||||
|
void onCaptureTimer();
|
||||||
|
void onLiveViewTimer();
|
||||||
|
|
||||||
|
// 控制拍照
|
||||||
|
void startCapture(); // 开始定时拍照
|
||||||
|
void stopCapture(); // 停止定时拍照
|
||||||
|
void captureOnce(); // 拍一张照片
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void PlotSignal();
|
void PlotSignal();
|
||||||
|
|
||||||
void CamOpenedSignal();
|
void CamOpenedSignal();
|
||||||
void CamClosedSignal();
|
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
|
class SingleLensReflexCameraWindow : public QDialog
|
||||||
@ -59,18 +129,50 @@ public:
|
|||||||
SingleLensReflexCameraOperation* m_SingleLensReflexCameraOperation;
|
SingleLensReflexCameraOperation* m_SingleLensReflexCameraOperation;
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
|
void onSelectDataFolder();
|
||||||
|
|
||||||
void openSLRCamera();
|
void openSLRCamera();
|
||||||
|
void takePhoto();
|
||||||
|
void stopTakePhoto();
|
||||||
void onCamOpened();
|
void onCamOpened();
|
||||||
void closeSLRCamera();
|
void closeSLRCamera();
|
||||||
void onCamClosed();
|
void onCamClosed();
|
||||||
|
void onImageCaptured(const QString& filePath);
|
||||||
|
void onError(const QString& errorMsg);
|
||||||
|
|
||||||
|
// 拍照控制
|
||||||
|
void onStartCapture();
|
||||||
|
void onStopCapture();
|
||||||
|
void onCaptureOnce();
|
||||||
|
|
||||||
|
void onCaptureStarted();
|
||||||
|
void onCaptureStopped();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void openSLRCameraSignal();
|
void openSLRCameraSignal();
|
||||||
|
void takePhotoSignal();
|
||||||
|
void stopTakePhotoSignal();
|
||||||
|
void closeSLRCameraSignal();
|
||||||
void PlotSLRImageSignal();
|
void PlotSLRImageSignal();
|
||||||
void SLRCamClosedSignal();
|
void SLRCamClosedSignal();
|
||||||
|
|
||||||
|
// 控制信号
|
||||||
|
void startCaptureSignal();
|
||||||
|
void stopCaptureSignal();
|
||||||
|
void captureOnceSignal();
|
||||||
|
|
||||||
|
// 实时取景信号
|
||||||
|
void LiveViewImageReady(const QImage& image);
|
||||||
|
void LiveViewStarted();
|
||||||
|
void LiveViewStopped();
|
||||||
private:
|
private:
|
||||||
Ui::SingleLensReflexCameraClass ui;
|
Ui::SingleLensReflexCameraClass ui;
|
||||||
QThread* m_SLRCameraThread;
|
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);
|
||||||
|
};
|
||||||
@ -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)
|
||||||
|
|||||||
@ -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>
|
||||||
@ -121,14 +121,20 @@ void TwoMotorControl::run()
|
|||||||
}
|
}
|
||||||
|
|
||||||
qRegisterMetaType<QVector<PathLine>>("QVector<PathLine>");
|
qRegisterMetaType<QVector<PathLine>>("QVector<PathLine>");
|
||||||
m_coordinator = new TwoMotionCaptureCoordinator(m_multiAxisController, m_Imager);
|
m_coordinator = new TwoMotionCaptureCoordinator(m_multiAxisController);
|
||||||
m_coordinator->moveToThread(&m_coordinatorThread);
|
m_coordinator->moveToThread(&m_coordinatorThread);
|
||||||
connect(&m_coordinatorThread, SIGNAL(finished()), m_coordinator, SLOT(deleteLater()));
|
connect(&m_coordinatorThread, SIGNAL(finished()), m_coordinator, SLOT(deleteLater()));
|
||||||
connect(this, SIGNAL(start(QVector<PathLine>)), m_coordinator, SLOT(start(QVector<PathLine>)));
|
connect(this, SIGNAL(start(QVector<PathLine>)), m_coordinator, SLOT(start(QVector<PathLine>)));
|
||||||
|
|
||||||
connect(this, SIGNAL(stopSignal()), m_coordinator, SLOT(stop()));
|
connect(this, SIGNAL(stopSignal()), m_coordinator, SLOT(stop()));
|
||||||
connect(m_coordinator, SIGNAL(startRecordLineNumSignal(int)), this, SLOT(receiveStartRecordLineNum(int)));
|
connect(m_coordinator, SIGNAL(startRecordLineNumSignal(int)), this, SLOT(receiveStartRecordLineNum(int)));
|
||||||
connect(m_coordinator, SIGNAL(finishRecordLineNumSignal(int)), this, SLOT(receiveFinishRecordLineNum(int)));
|
connect(m_coordinator, SIGNAL(finishRecordLineNumSignal(int)), this, SLOT(receiveFinishRecordLineNum(int)));
|
||||||
connect(m_coordinator, SIGNAL(sequenceComplete(int)), this, SLOT(onSequenceComplete()));
|
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();
|
m_coordinatorThread.start();
|
||||||
|
|
||||||
QVector<PathLine> pathLines;
|
QVector<PathLine> pathLines;
|
||||||
@ -158,6 +164,11 @@ void TwoMotorControl::run()
|
|||||||
emit start(pathLines);
|
emit start(pathLines);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TwoMotorControl::stop_record()
|
||||||
|
{
|
||||||
|
m_Imager->stop_record();
|
||||||
|
}
|
||||||
|
|
||||||
void TwoMotorControl::stop()
|
void TwoMotorControl::stop()
|
||||||
{
|
{
|
||||||
emit stopSignal();
|
emit stopSignal();
|
||||||
|
|||||||
@ -70,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);
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
#include "imageControl.h"
|
#include "imageControl.h"
|
||||||
#include "RasterLayer.h"
|
#include "RasterImageLayer.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
@ -99,7 +99,7 @@ ImageControl::~ImageControl()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImageControl::setActiveLayer(RasterLayer* layer)
|
void ImageControl::setActiveLayer(RasterImageLayer* layer)
|
||||||
{
|
{
|
||||||
m_activeLayer = layer;
|
m_activeLayer = layer;
|
||||||
|
|
||||||
@ -110,8 +110,8 @@ void ImageControl::setActiveLayer(RasterLayer* layer)
|
|||||||
}
|
}
|
||||||
setEnabled(true);
|
setEnabled(true);
|
||||||
|
|
||||||
// Get band wavelengths from the layer's header
|
// Get band wavelengths from the underlying RasterLayer's header
|
||||||
m_wavelengths = layer->bandWavelengths();
|
m_wavelengths = layer->layer()->bandWavelengths();
|
||||||
std::sort(m_wavelengths.begin(), m_wavelengths.end());
|
std::sort(m_wavelengths.begin(), m_wavelengths.end());
|
||||||
|
|
||||||
if (m_wavelengths.empty()) {
|
if (m_wavelengths.empty()) {
|
||||||
@ -150,8 +150,8 @@ void ImageControl::setActiveLayer(RasterLayer* layer)
|
|||||||
ui.sliderBlue->setMinimum(0);
|
ui.sliderBlue->setMinimum(0);
|
||||||
ui.sliderBlue->setMaximum(maxIdx);
|
ui.sliderBlue->setMaximum(maxIdx);
|
||||||
|
|
||||||
// Set current values from layer's render params
|
// Set current values from layer's render params (multiband)
|
||||||
auto params = layer->currentRenderParams();
|
auto params = layer->multibandParams();
|
||||||
|
|
||||||
int rIdx = nearestBandIndex(params.rWave);
|
int rIdx = nearestBandIndex(params.rWave);
|
||||||
int gIdx = nearestBandIndex(params.gWave);
|
int gIdx = nearestBandIndex(params.gWave);
|
||||||
@ -168,7 +168,7 @@ void ImageControl::setActiveLayer(RasterLayer* layer)
|
|||||||
blockAllSignals(false);
|
blockAllSignals(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
RasterLayer* ImageControl::activeLayer() const
|
RasterImageLayer* ImageControl::activeLayer() const
|
||||||
{
|
{
|
||||||
return m_activeLayer;
|
return m_activeLayer;
|
||||||
}
|
}
|
||||||
@ -326,13 +326,13 @@ void ImageControl::emitBandChange()
|
|||||||
double g = ui.spinGreen->value();
|
double g = ui.spinGreen->value();
|
||||||
double b = ui.spinBlue->value();
|
double b = ui.spinBlue->value();
|
||||||
|
|
||||||
// Update active layer's stored render params
|
// Update active layer's stored render params (multiband)
|
||||||
if (m_activeLayer) {
|
if (m_activeLayer) {
|
||||||
auto params = m_activeLayer->currentRenderParams();
|
auto params = m_activeLayer->multibandParams();
|
||||||
params.rWave = r;
|
params.rWave = r;
|
||||||
params.gWave = g;
|
params.gWave = g;
|
||||||
params.bWave = b;
|
params.bWave = b;
|
||||||
m_activeLayer->setCurrentRenderParams(params);
|
m_activeLayer->setMultibandParams(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
emit bandSelectionChanged(r, g, b);
|
emit bandSelectionChanged(r, g, b);
|
||||||
|
|||||||
@ -6,9 +6,10 @@
|
|||||||
#include <QNetworkAccessManager>
|
#include <QNetworkAccessManager>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "RasterLayer.h"
|
||||||
#include "ui_imgControl.h"
|
#include "ui_imgControl.h"
|
||||||
|
|
||||||
class RasterLayer;
|
class RasterImageLayer;
|
||||||
|
|
||||||
class ImageControl : public QDialog
|
class ImageControl : public QDialog
|
||||||
{
|
{
|
||||||
@ -18,9 +19,9 @@ public:
|
|||||||
ImageControl(QWidget* parent = nullptr);
|
ImageControl(QWidget* parent = nullptr);
|
||||||
~ImageControl();
|
~ImageControl();
|
||||||
|
|
||||||
// Populate controls from a RasterLayer's wavelength info and current render params
|
// Populate controls from a RasterImageLayer's wavelength info and current render params
|
||||||
void setActiveLayer(RasterLayer* layer);
|
void setActiveLayer(RasterImageLayer* layer);
|
||||||
RasterLayer* activeLayer() const;
|
RasterImageLayer* activeLayer() const;
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
|
|
||||||
@ -62,7 +63,7 @@ private:
|
|||||||
void setControlsToBandIndex(QDoubleSpinBox* spin, QSlider* slider, int idx);
|
void setControlsToBandIndex(QDoubleSpinBox* spin, QSlider* slider, int idx);
|
||||||
|
|
||||||
Ui::ImageControl ui;
|
Ui::ImageControl ui;
|
||||||
RasterLayer* m_activeLayer = nullptr;
|
RasterImageLayer* m_activeLayer = nullptr;
|
||||||
double m_minWave = 374.5;
|
double m_minWave = 374.5;
|
||||||
double m_maxWave = 948.1;
|
double m_maxWave = 948.1;
|
||||||
std::vector<double> m_wavelengths; // band wavelengths from header
|
std::vector<double> m_wavelengths; // band wavelengths from header
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "recordFrameCounter.h"
|
#include "recordFrameCounter.h"
|
||||||
|
#include "RasterLayer.h"
|
||||||
|
|
||||||
recordFrameCounter::recordFrameCounter(QWidget* parent)
|
recordFrameCounter::recordFrameCounter(QWidget* parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
@ -16,19 +17,19 @@ recordFrameCounter::recordFrameCounter(QWidget* parent)
|
|||||||
layout->addWidget(m_stackedWidget);
|
layout->addWidget(m_stackedWidget);
|
||||||
}
|
}
|
||||||
|
|
||||||
void recordFrameCounter::addCounter(QWidget* tabWidget)
|
void recordFrameCounter::addCounter(RasterLayer* mapLayer)
|
||||||
{
|
{
|
||||||
QLabel* label = new QLabel("0");
|
QLabel* label = new QLabel("0");
|
||||||
label->setStyleSheet("color: white;");
|
label->setStyleSheet("color: white;");
|
||||||
label->setAlignment(Qt::AlignVCenter | Qt::AlignLeft);
|
label->setAlignment(Qt::AlignVCenter | Qt::AlignLeft);
|
||||||
m_labelMap.insert(tabWidget, label);
|
m_labelMap.insert(mapLayer, label);
|
||||||
m_stackedWidget->addWidget(label);
|
m_stackedWidget->addWidget(label);
|
||||||
m_stackedWidget->setCurrentWidget(label);
|
m_stackedWidget->setCurrentWidget(label);
|
||||||
}
|
}
|
||||||
|
|
||||||
void recordFrameCounter::removeCounter(QWidget* tabWidget)
|
void recordFrameCounter::removeCounter(RasterLayer* mapLayer)
|
||||||
{
|
{
|
||||||
auto it = m_labelMap.find(tabWidget);
|
auto it = m_labelMap.find(mapLayer);
|
||||||
if (it != m_labelMap.end())
|
if (it != m_labelMap.end())
|
||||||
{
|
{
|
||||||
QLabel* label = it.value();
|
QLabel* label = it.value();
|
||||||
@ -38,18 +39,18 @@ void recordFrameCounter::removeCounter(QWidget* tabWidget)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void recordFrameCounter::switchTo(QWidget* tabWidget)
|
void recordFrameCounter::switchTo(RasterLayer* mapLayer)
|
||||||
{
|
{
|
||||||
auto it = m_labelMap.find(tabWidget);
|
auto it = m_labelMap.find(mapLayer);
|
||||||
if (it != m_labelMap.end())
|
if (it != m_labelMap.end())
|
||||||
{
|
{
|
||||||
m_stackedWidget->setCurrentWidget(it.value());
|
m_stackedWidget->setCurrentWidget(it.value());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void recordFrameCounter::updateFrameCount(QWidget* tabWidget, int frameCount)
|
void recordFrameCounter::updateFrameCount(RasterLayer* mapLayer, int frameCount)
|
||||||
{
|
{
|
||||||
auto it = m_labelMap.find(tabWidget);
|
auto it = m_labelMap.find(mapLayer);
|
||||||
if (it != m_labelMap.end())
|
if (it != m_labelMap.end())
|
||||||
{
|
{
|
||||||
it.value()->setText(QString::number(frameCount));
|
it.value()->setText(QString::number(frameCount));
|
||||||
|
|||||||
@ -6,19 +6,20 @@
|
|||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
|
|
||||||
|
class RasterLayer;
|
||||||
|
|
||||||
class recordFrameCounter : public QWidget
|
class recordFrameCounter : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit recordFrameCounter(QWidget* parent = nullptr);
|
explicit recordFrameCounter(QWidget* parent = nullptr);
|
||||||
|
|
||||||
void addCounter(QWidget* tabWidget);
|
void addCounter(RasterLayer* mapLayer);
|
||||||
void removeCounter(QWidget* tabWidget);
|
void removeCounter(RasterLayer* mapLayer);
|
||||||
void switchTo(QWidget* tabWidget);
|
void switchTo(RasterLayer* mapLayer);
|
||||||
void updateFrameCount(QWidget* tabWidget, int frameCount);
|
void updateFrameCount(RasterLayer* mapLayer, int frameCount);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QStackedWidget* m_stackedWidget = nullptr;
|
QStackedWidget* m_stackedWidget = nullptr;
|
||||||
QMap<QWidget*, QLabel*> m_labelMap;
|
QMap<RasterLayer*, QLabel*> m_labelMap;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user