54 Commits

Author SHA1 Message Date
d326dabff7 add,深度相机:
1、采集惯导数据并写入文件;
2、轮播看板添加深度图像;
3、植物表型场景控制深度相机看板;

fix:
优化调焦时,图像像素的填充方式;
2026-04-14 13:14:55 +08:00
5009832b3a add
1、采集深度、彩色、rgb点云,并存储到文件;
2、界面操作逻辑控制,防止用户错误操作;
2026-04-09 16:29:12 +08:00
5350d9431a add
添加深度相机1:控制看板界面
2026-04-08 17:04:51 +08:00
87d9a7fe01 右下角控制看板:每个tab都通过QDialog进行添加 2026-04-08 11:07:25 +08:00
fa6ce1a606 fix
1、【相机----马达】双向意外断掉容错 + 提示:(1)ximea、pica l、pica nir(2)1轴/2轴马达,usb串口/wifi的马达通讯方式;
2、提示弹窗美化;
2026-04-03 19:32:51 +08:00
e3a778919a 改变文件编码:utf-8带bom 2026-04-02 10:34:57 +08:00
486a9defc1 fix:
1、配置页面3;
2、resononNirImager的bug修复;
2026-04-02 09:55:21 +08:00
ea1a666619 配置页面2 2026-04-01 17:04:03 +08:00
50989bcd5b 配置页面 2026-04-01 15:55:42 +08:00
7e119fbf91 fix
采集bug
2026-03-31 16:55:21 +08:00
e3f882d77b 消除状态栏中间的白色竖线 2026-03-31 13:56:38 +08:00
dac922eb29 打包
使用qrc和rc文件(exe文件图标)管理svg、png等资源
2026-03-25 10:51:00 +08:00
ae07b9c19e fix
1、相机参数有效性控制bug;
2、相机看板图像大小调整;
3、工程的realease模式修复;
2026-03-24 14:54:48 +08:00
2cf86df608 通过自定义控件实现功能:状态栏显示采集帧数; 2026-03-24 14:03:12 +08:00
d358989579 fix:
相机参数有效性控制3
2026-03-20 15:33:25 +08:00
0fb81ab3e8 相机参数有效性控制2 2026-03-20 11:52:32 +08:00
8bbe402a63 图像等比例缩放 2026-03-19 16:52:48 +08:00
b23aedc6c7 美化ui 2026-03-18 15:56:06 +08:00
06dffddfd0 美化窗口:关于+图像控制 2026-03-18 00:03:56 +08:00
ca10848750 调焦窗口美化 2026-03-17 19:11:33 +08:00
4af1187b7d 美化:
工具栏+图像控制看板
2026-03-17 17:22:44 +08:00
30fa211a22 tab切换,改变LayerTreeModel的setCurrentIndex 2026-03-16 17:13:17 +08:00
7473a45f41 修复点击显示光谱功能的问题:打开一副影像后,点击显示光谱出现十字架,然后移除图层后,再打开图层就会出现问题 2026-03-16 15:05:13 +08:00
6d8c2f0419 优化LayerTree的数据结构 2026-03-16 11:06:09 +08:00
1c7780eb14 完成maptool的功能:
1、工具在工具栏中的状态管理;
2、工具在mapcavas中的图标管理;
3、工具在多tab切换时的管理;
4、MapToolSpectral添加十字叉,显示点击位置;
2026-03-13 14:52:47 +08:00
741e0e6734 使用maptools管理maptool 2026-03-12 16:51:13 +08:00
5d5b440ba2 初步实现maptool,有很多细节没有做好 2026-03-12 14:41:09 +08:00
0b2744656b maptool:
报错,没实现;
2026-03-11 18:09:38 +08:00
ece7a34bfb 界面添加工具按钮 2026-03-11 17:57:23 +08:00
452f7c8e5f 完成功能:改变图像显示的rgb波段;
1、可改变图像显示波段,当修改完成参数时实时刷新图像;
2、TOC中切换选中的多图层时,刷新渲染信息;
3、界面中保存图像的波长信息,参数修改时的选项就是准确的波长信息;
2026-03-10 17:21:21 +08:00
0ac03f0eb5 改变图像显示的rgb波段:
实现界面逻辑,运行有错,没完成
2026-03-09 17:30:41 +08:00
edfb72eaef 改变图像显示的rgb波段:
添加界面
2026-03-09 16:41:18 +08:00
7987abf711 采集时去掉所有图层 2026-03-09 14:46:32 +08:00
09095592af fix
1、基于新框架实现点击显示光谱;
2、影像拉伸显示优化;
3、右键菜单新增:移除所有栅格图层;
2026-03-06 17:33:30 +08:00
4ad5c8b91e 解决昨天代码问题:内存泄露 2026-03-06 15:52:39 +08:00
7f94513a16 实现了TOC右键菜单:移除图层 2026-03-05 16:47:59 +08:00
8d2fe91043 初步统一了多航线采集和打开影像功能 2026-03-03 17:22:03 +08:00
bdf956ed99 1、为图层添加渲染器和读取器,分离图层基础信息、渲染和读写;
2、LayerTreeLayerNode持有MapLayer图层引用,为右键菜单做准备;
3、改名:imageviewer → mapcavas,mapcavas持有MapLayer图层引用,为刷新图像做准备;
2026-03-02 11:49:46 +08:00
e3b2d136d3 初步实现采集、图层和TOC联动 2026-02-12 16:10:17 +08:00
631216dc66 初步实现单独的图层管理器。
注意:没有和mapcavas通讯。
2026-02-05 15:32:34 +08:00
7d123ca11c toc的权宜简单实现 2026-01-29 14:25:27 +08:00
8595f7cad7 消除git中hppa.cpp中文乱码 2026-01-29 14:24:26 +08:00
30e63899a8 1、美化:轮播看板+3d模型看板;
2、优化3d模型看板:使用时加载3D模型,避免内存泄漏,使用QStackedWidget进行切换;
2026-01-29 14:17:27 +08:00
30306e9396 初步完成美化:
1、左下角3d模型预览看板;
2、右下角控制看板
2026-01-16 22:03:30 +08:00
f0f41f9a17 初步实现场景切换 2026-01-08 10:23:36 +08:00
f999d87da6 初步实现2轴的3D模型联动 2025-12-24 16:59:36 +08:00
36ad438608 增加轮播控件,并将rgb相机界面移入轮播控件中; 2025-11-25 17:30:48 +08:00
bb1a01f402 优化代码结构 2025-11-13 14:56:19 +08:00
797ff77f5f 修改界面:
1、右下角看板通过tabwidget管理很多可扩展控制页面;
2、定制右下角放大功能:占用右上角的看板空间;
2025-11-13 14:51:37 +08:00
83ef26a1e2 初步实现放大功能 2025-11-11 15:30:57 +08:00
e7a73430d0 修改界面 2025-11-04 18:02:41 +08:00
fd5571712a 修改界面 2025-10-31 17:31:57 +08:00
e14c5da80a 排除图标 2025-10-21 14:32:08 +08:00
c2a3c28cdd 为2轴控制界面添加“移动至”功能; 2025-10-13 14:17:26 +08:00
138 changed files with 13202 additions and 3386 deletions

3
.gitignore vendored
View File

@ -5,6 +5,9 @@ gdal202.dll
*.rej
HPPA类图.drawio
HPPA - 副本.ui
icon
ignore_*
resources
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.

35
HPPA/AppSettings.cpp Normal file
View File

@ -0,0 +1,35 @@
#include "AppSettings.h"
const QString AppSettings::kDefaultDataFolder = QStringLiteral("C:\\HPPA_image");
const QString AppSettings::kDefaultFileName = QStringLiteral("test_image");
AppSettings::AppSettings()
: m_settings(QSettings::IniFormat, QSettings::UserScope,
QStringLiteral("IRIS"), QStringLiteral("HPPA"))
{
}
AppSettings& AppSettings::instance()
{
static AppSettings s;
return s;
}
QString AppSettings::dataFolder() const
{
return m_settings.value("General/DataFolder", kDefaultDataFolder).toString();
}
void AppSettings::setDataFolder(const QString& path)
{
m_settings.setValue("General/DataFolder", path);
}
QString AppSettings::fileName() const
{
return m_settings.value("General/FileName", kDefaultFileName).toString();
}
void AppSettings::setFileName(const QString& path)
{
m_settings.setValue("General/FileName", path);
}

29
HPPA/AppSettings.h Normal file
View File

@ -0,0 +1,29 @@
#pragma once
#include <QSettings>
#include <QString>
class AppSettings
{
public:
static AppSettings& instance();
// 数据路径
QString dataFolder() const;
void setDataFolder(const QString& path);
QString fileName() const;
void setFileName(const QString& path);
// 在此处添加更多参数的 getter/setter ...
private:
AppSettings();
AppSettings(const AppSettings&) = delete;
AppSettings& operator=(const AppSettings&) = delete;
QSettings m_settings;
// 默认值
static const QString kDefaultDataFolder;
static const QString kDefaultFileName;
};

28
HPPA/AspectRatioLabel.cpp Normal file
View File

@ -0,0 +1,28 @@
#include "stdafx.h"
#include "AspectRatioLabel.h"
AspectRatioLabel::AspectRatioLabel(QWidget* parent)
: QLabel(parent)
{
setAlignment(Qt::AlignCenter);
}
void AspectRatioLabel::setOriginalPixmap(const QPixmap& pixmap)
{
m_originalPixmap = pixmap;
updateScaledPixmap();
}
void AspectRatioLabel::resizeEvent(QResizeEvent* event)
{
QLabel::resizeEvent(event);
updateScaledPixmap();
}
void AspectRatioLabel::updateScaledPixmap()
{
if (m_originalPixmap.isNull())
return;
setPixmap(m_originalPixmap.scaled(size(), Qt::KeepAspectRatio, Qt::SmoothTransformation));
}

22
HPPA/AspectRatioLabel.h Normal file
View File

@ -0,0 +1,22 @@
#pragma once
#include <QLabel>
#include <QPixmap>
#include <QResizeEvent>
class AspectRatioLabel : public QLabel
{
Q_OBJECT
public:
explicit AspectRatioLabel(QWidget* parent = nullptr);
void setOriginalPixmap(const QPixmap& pixmap);
protected:
void resizeEvent(QResizeEvent* event) override;
private:
void updateScaledPixmap();
QPixmap m_originalPixmap;
};

View File

@ -97,7 +97,6 @@ void TwoMotionCaptureCoordinator::stop()
std::cout << "The user manually stops the collection! " << std::endl;
savePathLinesToCsv();
emit sequenceComplete(1);
emit finishRecordLineNumSignal(m_numCurrentPathLine);
//emit stopRecordHSISignal(m_numCurrentPathLine);
if (m_cameraCtrl != nullptr)
@ -106,6 +105,8 @@ void TwoMotionCaptureCoordinator::stop()
}
move2LocBeforeStart();
emit sequenceComplete(1);
}
void TwoMotionCaptureCoordinator::getLocBeforeStart()
@ -471,7 +472,8 @@ OneMotionCaptureCoordinator::OneMotionCaptureCoordinator(
OneMotionCaptureCoordinator::~OneMotionCaptureCoordinator()
{
disconnect(m_motorCtrl, &IrisMultiMotorController::motorStopSignal,
this, &OneMotionCaptureCoordinator::handleMotorStoped);
}
void OneMotionCaptureCoordinator::startStepMotion(OneMotionCapturePathLine pathLine)
@ -585,6 +587,10 @@ void OneMotionCaptureCoordinator::handleMotorStoped(int motorID, double pos)
m_cameraCtrl->stop_record();
}
move2LocBeforeStart();
// emit sequenceComplete last: the slot connected to it may delete this object,
// so no member access is allowed after this point.
emit sequenceComplete(0);
}
void OneMotionCaptureCoordinator::handleCaptureComplete(double index)

285
HPPA/Carousel.cpp Normal file
View File

@ -0,0 +1,285 @@
#include "Carousel.h"
#include <QContextMenuEvent>
#include <QDebug>
MyCarousel::MyCarousel(QWidget* parent)
: QWidget(parent),
m_stackedWidget(new QStackedWidget(this)),
m_bottomButtonOverlay(nullptr),
m_bottomButtonLayout(nullptr),
m_bottomButtonGroup(nullptr),
m_currentIndex(0),
m_isPlaying(false),
m_isLocked(false),
m_lockedIndex(-1),
m_playInterval(2000),
m_intervalButtonSize(40)
{
QVBoxLayout* layout = new QVBoxLayout(this);
layout->addWidget(m_stackedWidget);
layout->setContentsMargins(0, 0, 0, 0);
m_autoPlayerTimer = new QTimer(this);
connect(m_autoPlayerTimer, &QTimer::timeout,
this, &MyCarousel::slideRight);
m_nomalQSS= R"(
QPushButton
{
background-color: #FFFFFF;
border-radius: 5px;
border: 1px solid #FFFFFF;
}
QPushButton:checked
{
background-color: #08F8E8;
border-radius: 5px;
border: 1px solid #08F8E8;
}
QPushButton:hover
{
background-color: red;
border-radius: 5px;
border: 1px solid red;
}
/*QPushButton:!checked {
background-color: #FFFFFF;
border-radius: 5px;
border: 1px solid #FFFFFF;
}*/
)";
m_lockedQSS = R"(
QPushButton
{
background-color: #FFFFFF;
border-radius: 5px;
border: 1px solid #FFFFFF;
}
QPushButton:checked
{
background-color: #08F8E8;
border-radius: 5px;
border: 1px solid #08F8E8;
}
QPushButton:hover
{
background-color: red;
border-radius: 5px;
border: 1px solid red;
}
)";
}
void MyCarousel::addWidget(QWidget* w)
{
m_widgets.append(w);
m_stackedWidget->addWidget(w);
updateStackedWidgetVisibility();
}
void MyCarousel::play()
{
if (m_widgets.isEmpty())
return;
m_isPlaying = true;
// 创建底部按钮
m_bottomButtonLayout = new QHBoxLayout();
m_bottomButtonGroup = new QButtonGroup(this);
m_bottomButtons.clear();
for (int i = 0; i < m_widgets.size(); ++i) {
QPushButton* btn = new QPushButton(this);
btn->setCheckable(true);
btn->setFixedSize(m_intervalButtonSize, 3);
btn->setStyleSheet(m_nomalQSS);
btn->setFixedHeight(10);
btn->setFixedWidth(10);
m_bottomButtonLayout->addWidget(btn);
m_bottomButtonGroup->addButton(btn, i);
m_bottomButtons.append(btn);
connect(btn, &QPushButton::clicked, this, [this, i]() {
onButtonClicked(i);
});
}
m_bottomButtonOverlay = new QWidget(this);
m_bottomButtonOverlay->setLayout(m_bottomButtonLayout);
m_bottomButtonOverlay->setAttribute(Qt::WA_TranslucentBackground);
m_bottomButtonOverlay->show();
m_autoPlayerTimer->setInterval(m_playInterval);
m_autoPlayerTimer->start();
updateStackedWidgetVisibility();
}
void MyCarousel::contextMenuEvent(QContextMenuEvent* event)
{
showContextMenu(event->globalPos());
}
void MyCarousel::showContextMenu(const QPoint& pos)
{
QMenu menu(this);
menu.setStyleSheet(R"(
QMenu {
background-color: #2a5dec;
color: white;
}
QMenu::item:selected {
background-color: #1a4ddc;
}
QMenu::separator {
height: 1px;
background: white;
}
)");
QAction* startAct = menu.addAction(QString::fromLocal8Bit("开始轮播"));
QAction* stopAct = menu.addAction(QString::fromLocal8Bit("停止轮播"));
menu.addSeparator();
QAction* incAct = menu.addAction("+1");
QAction* decAct = menu.addAction("-1");
if (!m_isLocked)
startAct->setEnabled(false);
if (m_isLocked)
stopAct->setEnabled(false);
QAction* act = menu.exec(pos);
if (act == startAct)
startAutoPlay();
else if (act == stopAct)
stopAutoPlay();
else if (act == incAct) {
m_playInterval += 1000;
m_autoPlayerTimer->setInterval(m_playInterval);
}
else if (act == decAct) {
if (m_playInterval > 1)
m_playInterval -= 1000;
m_autoPlayerTimer->setInterval(m_playInterval);
}
}
void MyCarousel::startAutoPlay()
{
updateButtonState(m_currentIndex);
}
void MyCarousel::stopAutoPlay()
{
updateButtonState(m_currentIndex);
}
void MyCarousel::onButtonClicked(int index)
{
updateButtonState(index);
gotoWidget(index);
}
void MyCarousel::updateButtonState(int index)
{
if (m_isLocked)
{
if (index == m_lockedIndex) {
// 解锁
m_isLocked = false;
m_lockedIndex = -1;
if (m_isPlaying)
m_autoPlayerTimer->start();
restoreButtonStyle(index);
}
else {
// 切换锁定
restoreButtonStyle(m_lockedIndex);
setButtonLocked(index);
m_lockedIndex = index;
}
}
else {
// 初次锁定
m_isLocked = true;
m_lockedIndex = index;
m_autoPlayerTimer->stop();
setButtonLocked(index);
}
}
void MyCarousel::setButtonLocked(int index)
{
QPushButton* btn = m_bottomButtons[index];
btn->setText("");
btn->setStyleSheet(m_lockedQSS);
}
void MyCarousel::restoreButtonStyle(int index)
{
if (index < 0)
return;
QPushButton* btn = m_bottomButtons[index];
btn->setText("");
btn->setStyleSheet(m_nomalQSS);
}
void MyCarousel::slideLeft()
{
if (m_widgets.isEmpty() || m_isLocked || !m_isPlaying)
return;
m_currentIndex = (m_currentIndex - 1 + m_widgets.size()) % m_widgets.size();
updateStackedWidgetVisibility();
}
void MyCarousel::slideRight()
{
if (m_widgets.isEmpty() || m_isLocked || !m_isPlaying)
return;
m_currentIndex = (m_currentIndex + 1) % m_widgets.size();
updateStackedWidgetVisibility();
}
void MyCarousel::gotoWidget(int index)
{
m_currentIndex = index;
updateStackedWidgetVisibility();
}
void MyCarousel::updateStackedWidgetVisibility()
{
if (m_widgets.isEmpty())
return;
m_stackedWidget->setCurrentIndex(m_currentIndex);
if (!m_isLocked) {
for (int i = 0; i < m_bottomButtons.size(); ++i)
m_bottomButtons[i]->setChecked(i == m_currentIndex);
}
}
void MyCarousel::resizeEvent(QResizeEvent*)
{
if (!m_bottomButtonOverlay)
return;
int count = m_widgets.size();
int totalWidth = m_intervalButtonSize * count + 10 * (count - 1);
int x = (width() - totalWidth) / 2;
int y = height() - m_intervalButtonSize;
m_bottomButtonOverlay->setGeometry(x, y, totalWidth, m_intervalButtonSize);
}

66
HPPA/Carousel.h Normal file
View File

@ -0,0 +1,66 @@
#pragma once
#include <QWidget>
#include <QPushButton>
#include <QStackedWidget>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QButtonGroup>
#include <QTimer>
#include <QMenu>
class MyCarousel : public QWidget
{
Q_OBJECT
public:
explicit MyCarousel(QWidget* parent = nullptr);
void addWidget(QWidget* w);
void play();
void gotoWidget(int index);
protected:
void contextMenuEvent(QContextMenuEvent* event) override;
void resizeEvent(QResizeEvent* event) override;
private slots:
void slideLeft();
void slideRight();
void onButtonClicked(int index);
private:
// UI
QStackedWidget* m_stackedWidget;
QWidget* m_bottomButtonOverlay;
QHBoxLayout* m_bottomButtonLayout;
QButtonGroup* m_bottomButtonGroup;
QVector<QWidget*> m_widgets;
QVector<QPushButton*> m_bottomButtons;
QString m_nomalQSS;
QString m_lockedQSS;
// 状态值
int m_currentIndex;
bool m_isPlaying;
bool m_isLocked;
int m_lockedIndex;
// 参数
int m_playInterval;
int m_intervalButtonSize;
QTimer* m_autoPlayerTimer;
private:
void updateStackedWidgetVisibility();
void updateButtonState(int index);
void setButtonLocked(int index);
void restoreButtonStyle(int index);
void showContextMenu(const QPoint& pos);
void startAutoPlay();
void stopAutoPlay();
};

View File

@ -1,8 +1,8 @@
#include "Corning410Imager.h"
#include "Corning410Imager.h"
Corning410Imager::Corning410Imager()
{
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD>У<EFBFBD><EFBFBD>ʹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
//配置文件:如果没有,就创建配置文件
string CfgFile = getPathofEXE() + "\\corning410.cfg";
m_configfile.setConfigfilePath(CfgFile);
if (!m_configfile.isConfigfileExist())
@ -18,7 +18,7 @@ Corning410Imager::~Corning410Imager()
{
if (buffer != nullptr)
{
std::cout << "<EFBFBD>ͷŶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD>" << std::endl;
std::cout << "释放堆上内存" << std::endl;
free(buffer);
free(dark);
free(white);
@ -70,7 +70,7 @@ void Corning410Imager::connectImager(const char* camera_sn)
{
m_imager.connect();
//<EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ò<EFBFBD><EFBFBD><EFBFBD>
//读取配置文件参数,并为相机设置参数
bool ret, ret1, ret2;
int spatialBin;
@ -82,8 +82,8 @@ void Corning410Imager::connectImager(const char* camera_sn)
bool haha = m_imager.setSpectralBin(spectralBin);
bool haha2 = m_imager.setSpatialBin(spatialBin);
std::cout << "spectralBin<EFBFBD><EFBFBD>" << spectralBin << std::endl;
std::cout << "spatialBin<EFBFBD><EFBFBD>" << spatialBin << std::endl;
std::cout << "spectralBin" << spectralBin << std::endl;
std::cout << "spatialBin" << spatialBin << std::endl;
}
float gain, offset;

View File

@ -1,4 +1,4 @@
#pragma once
#pragma once
#include <string>
#include <opencv2/core/core.hpp>

View File

@ -0,0 +1,204 @@
#include "CustomDockWidgetBase.h"
CustomDockWidgetBase::CustomDockWidgetBase(QMainWindow* parent)
: QDockWidget(parent),
m_mainWindow(parent),
m_isMaximized(false)
{
initialize();
}
CustomDockWidgetBase::CustomDockWidgetBase(QString title, QMainWindow* parent)
: QDockWidget(title, parent),
m_mainWindow(parent),
m_isMaximized(false)
{
initialize();
setTile(title);
}
void CustomDockWidgetBase::initialize()
{
QWidget* titleBar_Background = new QWidget(this);
titleBar_Background->setObjectName("titleBar_Background");
QGridLayout* layout_titleBar_Background = new QGridLayout(titleBar_Background);
layout_titleBar_Background->setContentsMargins(0, 0, 0, 0);
titleBar_Background->setStyleSheet(R"(
QWidget #titleBar_Background{
background: #040125;
}
)");
QWidget* titleBar = new QWidget(titleBar_Background);
titleBar->setObjectName("titleBar");
QHBoxLayout* layout = new QHBoxLayout(titleBar);
titleBar->setFixedHeight(30);
title_label = new QLabel(titleBar);
layout->setContentsMargins(10, 0, 10, 0);
layout->addWidget(title_label);
layout->addStretch();
m_maxButton = new QToolButton(titleBar);
m_maxButton->setIcon(style()->standardIcon(QStyle::SP_TitleBarMaxButton));
layout->addWidget(m_maxButton);
titleBar->setStyleSheet(R"(
QWidget #titleBar{
background: #0E1C4C;
/*border: 4px solid #2c586b;*/
/*padding-top: 10px;
padding-bottom: 10px;*/
border-top: 1px solid #2c586b;
border-left: 1px solid #2c586b;
border-right: 1px solid #2c586b;
border-bottom: none; /* 取消底部边框 */
border-top-left-radius: 5px;
border-top-right-radius: 5px;
}
)");
title_label->setStyleSheet("color: white;");
m_maxButton->setStyleSheet("");
layout_titleBar_Background->addWidget(titleBar);
setTitleBarWidget(titleBar_Background);
setFeatures(QDockWidget::DockWidgetClosable);
connect(m_maxButton, &QToolButton::clicked, this, &CustomDockWidgetBase::toggleMaximize);
}
void CustomDockWidgetBase::setTile(QString title)
{
title_label->setText(title);
}
void CustomDockWidgetBase::hideMaxButton()
{
m_maxButton->hide();
}
void CustomDockWidgetBase::toggleMaximize()
{
if (!m_isMaximized)
{
m_hiddenDocks.clear();
m_originalSizes.clear();
m_savedState = m_mainWindow->saveState();
const QList<QDockWidget*> docks = m_mainWindow->findChildren<QDockWidget*>();
for (QDockWidget* dock : docks)
{
m_originalSizes[dock] = dock->size();
if (dock != this && dock->isVisible())
{
dock->hide();
m_hiddenDocks.append(dock);
}
}
m_isMaximized = true;
emit maximizeStateChanged(m_isMaximized);
m_maxButton->setIcon(style()->standardIcon(QStyle::SP_TitleBarNormalButton));
}
else
{
for (QDockWidget* dock : m_hiddenDocks)
{
dock->show();
}
if (!m_savedState.isEmpty())
{
m_mainWindow->restoreState(m_savedState);
m_savedState.clear();
}
QList<QDockWidget*> docks;
QList<int> widths, heights;
for (auto it = m_originalSizes.begin(); it != m_originalSizes.end(); ++it)
{
docks.append(it.key());
widths.append(it.value().width());
heights.append(it.value().height());
}
m_mainWindow->resizeDocks(docks, widths, Qt::Horizontal);
m_mainWindow->resizeDocks(docks, heights, Qt::Vertical);
m_isMaximized = false;
emit maximizeStateChanged(m_isMaximized);
m_maxButton->setIcon(style()->standardIcon(QStyle::SP_TitleBarMaxButton));
}
}
CustomDockWidgetHideAbove::CustomDockWidgetHideAbove(QString title, QMainWindow* parent)
:CustomDockWidgetBase(title, parent)
{
}
CustomDockWidgetHideAbove::CustomDockWidgetHideAbove(QMainWindow* parent)
:CustomDockWidgetBase(parent)
{
}
void CustomDockWidgetHideAbove::toggleMaximize()
{
if (!m_isMaximized)
{
m_hiddenDocks.clear();
m_originalSizes.clear();
m_savedState = m_mainWindow->saveState();
const QList<QDockWidget*> docks = m_mainWindow->findChildren<QDockWidget*>();
for (QDockWidget* dock : docks)
{
m_originalSizes[dock] = dock->size();
if (dock->objectName().contains("mDockCarousel") && dock->isVisible())
{
dock->hide();
m_hiddenDocks.append(dock);
}
}
m_isMaximized = true;
emit maximizeStateChanged(m_isMaximized);
m_maxButton->setIcon(style()->standardIcon(QStyle::SP_TitleBarNormalButton));
}
else
{
for (QDockWidget* dock : m_hiddenDocks)
{
dock->show();
}
if (!m_savedState.isEmpty())
{
m_mainWindow->restoreState(m_savedState);
m_savedState.clear();
}
//QList<QDockWidget*> docks;
//QList<int> widths, heights;
//for (auto it = m_originalSizes.begin(); it != m_originalSizes.end(); ++it)
//{
// docks.append(it.key());
// widths.append(it.value().width());
// heights.append(it.value().height());
//}
//m_mainWindow->resizeDocks(docks, widths, Qt::Horizontal);
//m_mainWindow->resizeDocks(docks, heights, Qt::Vertical);
m_isMaximized = false;
emit maximizeStateChanged(m_isMaximized);
m_maxButton->setIcon(style()->standardIcon(QStyle::SP_TitleBarMaxButton));
}
}

View File

@ -0,0 +1,53 @@
#pragma once
#include <QDockWidget>
#include <QToolButton>
#include <QStyle>
#include <QHBoxLayout>
#include <QMainWindow>
#include <QMap>
#include <QSize>
#include <QLabel>
class CustomDockWidgetBase :
public QDockWidget
{
Q_OBJECT
public:
explicit CustomDockWidgetBase(QString title, QMainWindow* parent = nullptr);
explicit CustomDockWidgetBase(QMainWindow* parent = nullptr);
void setTile(QString title);
void hideMaxButton();
public slots:
virtual void toggleMaximize();
signals:
void maximizeStateChanged(bool isMaximized);
protected:
QMainWindow* m_mainWindow = nullptr;
QToolButton* m_maxButton = nullptr;
bool m_isMaximized = false;
QList<QDockWidget*> m_hiddenDocks;
QByteArray m_savedState;
QMap<QDockWidget*, QSize> m_originalSizes;
QLabel* title_label;
void initialize();
};
class CustomDockWidgetHideAbove :
public CustomDockWidgetBase
{
Q_OBJECT
public:
explicit CustomDockWidgetHideAbove(QString title, QMainWindow* parent = nullptr);
explicit CustomDockWidgetHideAbove(QMainWindow* parent = nullptr);
private slots:
void toggleMaximize();
private:
};

160
HPPA/DepthCamera.ui Normal file
View File

@ -0,0 +1,160 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DepthCameraClass</class>
<widget class="QDialog" name="DepthCameraClass">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>416</width>
<height>219</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>DepthCamera</string>
</property>
<property name="styleSheet">
<string notr="true">QGroupBox
{
border: 12px solid transparent;
/*border-top: 12px solid transparent;
border-right: 0px solid transparent;
border-bottom: 0px solid transparent;
border-left: 0px solid transparent;*/
color: #ACCDFF;
}
QPushButton
{
/*width: 172px;
height: 56px;*/
font: 19pt &quot;新宋体&quot;;
background-color: qlineargradient(
spread:pad,
x1:0.5, y1:0, x2:0.5, y2:1,
stop:0 #283D86,
stop:1 #0F1A40
);
color: white;
border: none;
padding: 8px 16px;
border-radius: 4px;
}
QPushButton:hover
{
background-color: qlineargradient(
spread:pad,
x1:0, y1:0, x2:1, y2:0,
stop:0 #3A4875,
stop:1 #5F6B91
);
}
/* 按下时的效果 */
QPushButton:pressed
{
background-color: qlineargradient(
spread:pad,
x1:0, y1:0, x2:1, y2:0,
stop:0 #1A254F,
stop:1 #3A466B
);
/* 可选:添加下压效果 */
padding-top: 9px;
padding-bottom: 7px;
}</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="1">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>18</width>
<height>100</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>135</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="1">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="1">
<widget class="QPushButton" name="closeDepthCamera_btn">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>关 闭</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QPushButton" name="openDepthCamera_btn">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>打 开</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="2">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>135</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="1">
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>18</width>
<height>100</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections/>
</ui>

323
HPPA/DepthCameraWindow.cpp Normal file
View File

@ -0,0 +1,323 @@
#include "DepthCameraWindow.h"
DepthCameraWindow::DepthCameraWindow(QWidget* parent)
: QDialog(parent)
{
ui.setupUi(this);
m_DepthCameraThread = new QThread();
m_DepthCameraOperation = new DepthCameraOperation();
m_DepthCameraOperation->moveToThread(m_DepthCameraThread);
m_DepthCameraThread->start();
connect(ui.openDepthCamera_btn, &QPushButton::clicked, this, &DepthCameraWindow::openDepthCamera);
connect(ui.closeDepthCamera_btn, &QPushButton::clicked, this, &DepthCameraWindow::closeDepthCamera);
connect(this, &DepthCameraWindow::openDepthCameraSignal, m_DepthCameraOperation, &DepthCameraOperation::OpenDepthCamera);
connect(m_DepthCameraOperation, &DepthCameraOperation::CamOpenedSignal, this, &DepthCameraWindow::onCamOpened);
connect(m_DepthCameraOperation, &DepthCameraOperation::CamClosedSignal, this, &DepthCameraWindow::onCamClosed);
connect(m_DepthCameraOperation, &DepthCameraOperation::PlotSignal, this, &DepthCameraWindow::PlotDepthImageSignal);
connect(m_DepthCameraOperation, &DepthCameraOperation::CamClosedSignal, this, &DepthCameraWindow::DepthCamClosedSignal);
}
DepthCameraWindow::~DepthCameraWindow()
{
m_DepthCameraThread->quit();
m_DepthCameraThread->wait();
delete m_DepthCameraOperation;
m_DepthCameraOperation = nullptr;
}
void DepthCameraWindow::openDepthCamera()
{
if (!m_DepthCameraOperation->getRecordStatus())
{
emit openDepthCameraSignal();
}
}
void DepthCameraWindow::onCamOpened()
{
ui.openDepthCamera_btn->setEnabled(false);
ui.closeDepthCamera_btn->setEnabled(true);
ui.openDepthCamera_btn->setText(QString::fromLocal8Bit("已打开"));
}
void DepthCameraWindow::closeDepthCamera()
{
m_DepthCameraOperation->CloseDepthCamera();
}
void DepthCameraWindow::onCamClosed()
{
ui.openDepthCamera_btn->setEnabled(true);
ui.closeDepthCamera_btn->setEnabled(false);
ui.openDepthCamera_btn->setText(QString::fromLocal8Bit("打 开"));
}
//-------------------------------------------------------------------------------------------------------------------------------
DepthCameraOperation::DepthCameraOperation()
{
m_pipe = nullptr;
m_func = nullptr;
record = false;
}
DepthCameraOperation::~DepthCameraOperation()
{
if (m_pipe)
{
m_pipe->stop();
delete m_pipe;
m_pipe = nullptr;
}
}
void DepthCameraOperation::OpenDepthCamera()
{
if (m_pipe)
{
return;
}
m_pipe = new ob::Pipeline();
std::shared_ptr<ob::Config> config = std::make_shared<ob::Config>();
// Get device from pipeline.
auto device = m_pipe->getDevice();
auto devInfo = device->getDeviceInfo();
auto pid = devInfo->getPid();
auto vid = devInfo->getVid();
//// Get sensorList from device.
//auto sensorList = device->getSensorList();
//for (uint32_t index = 0; index < sensorList->getCount(); index++) {
// // Query all supported infrared sensor type and enable the infrared stream.
// // For dual infrared device, enable the left and right infrared streams.
// // For single infrared device, enable the infrared stream.
// OBSensorType sensorType = sensorList->getSensorType(index);
// std::cout << "Supported Sensor type: " << sensorType << std::endl;
// // Enable the stream for the sensor type.
// config->enableStream(sensorType);
//}
config->enableVideoStream(OB_STREAM_DEPTH, 640, 480, 15, OB_FORMAT_Y16);
config->enableVideoStream(OB_STREAM_COLOR, 640, 480, 15, OB_FORMAT_YUYV);
config->enableAccelStream();
config->enableGyroStream();
config->setFrameAggregateOutputMode(OB_FRAME_AGGREGATE_OUTPUT_ALL_TYPE_FRAME_REQUIRE);
config->setAlignMode(ALIGN_D2C_HW_MODE);
m_pipe->enableFrameSync();
// Create a format converter filter.
auto formatConverter = std::make_shared<ob::FormatConvertFilter>();
m_pipe->start(config);
// Drop several frames
for (int i = 0; i < 15; ++i) {
auto lost = m_pipe->waitForFrameset(100);
}
auto pointCloud = std::make_shared<ob::PointCloudFilter>();
int frameIndex = 0;
record = true;
QString fileNamePrefix = AppSettings::instance().dataFolder() + QDir::separator() + AppSettings::instance().fileName();
QString imuFilePath = fileNamePrefix + "_IMU.txt";
std::ofstream imuFile(imuFilePath.toStdString(), std::ios::out | std::ios::trunc);
while (record)
{
if(frameIndex==0)
{
emit CamOpenedSignal();
std::cout << "Start recording..." << std::endl;
}
auto frameSet = m_pipe->waitForFrameset(100);
if (frameSet == nullptr)
{
std::cout << "No frames received in 100ms..." << std::endl;
continue;
}
std::cout << "DepthCamera frameIndex"<< frameIndex << std::endl;
// 彩色和深度图像
auto depthFrame = frameSet->getFrame(OB_FRAME_DEPTH)->as<ob::DepthFrame>();
auto colorFrame = frameSet->getFrame(OB_FRAME_COLOR)->as<ob::ColorFrame>();
// Convert the color frame to RGB format.
if (colorFrame->format() != OB_FORMAT_RGB) {
if (colorFrame->format() == OB_FORMAT_MJPG) {
formatConverter->setFormatConvertType(FORMAT_MJPG_TO_RGB);
}
else if (colorFrame->format() == OB_FORMAT_UYVY) {
formatConverter->setFormatConvertType(FORMAT_UYVY_TO_RGB);
}
else if (colorFrame->format() == OB_FORMAT_YUYV) {
formatConverter->setFormatConvertType(FORMAT_YUYV_TO_RGB);
}
else {
std::cout << "Color format is not support!" << std::endl;
continue;
}
colorFrame = formatConverter->process(colorFrame)->as<ob::ColorFrame>();
}
// Processed the color frames to BGR format, use OpenCV to save to disk.
formatConverter->setFormatConvertType(FORMAT_RGB_TO_BGR);
colorFrame = formatConverter->process(colorFrame)->as<ob::ColorFrame>();
saveDepthFrame(depthFrame, frameIndex, fileNamePrefix.toStdString());
saveColorFrame(colorFrame, frameIndex, fileNamePrefix.toStdString());
cv::Mat colorMat(colorFrame->height(), colorFrame->width(), CV_8UC3, colorFrame->data());
cv::Mat rgbMat;
cv::cvtColor(colorMat, rgbMat, cv::COLOR_BGR2RGB);
m_colorImage = QImage(rgbMat.data, rgbMat.cols, rgbMat.rows, static_cast<int>(rgbMat.step), QImage::Format_RGB888).copy();
cv::Mat depthMat(depthFrame->height(), depthFrame->width(), CV_16UC1, depthFrame->data());
cv::Mat depthMat8U;
depthMat.convertTo(depthMat8U, CV_8UC1, 255.0 / 4096.0);
cv::Mat depthColorMap;
cv::applyColorMap(depthMat8U, depthColorMap, cv::COLORMAP_JET);
cv::Mat depthRgbMat;
cv::cvtColor(depthColorMap, depthRgbMat, cv::COLOR_BGR2RGB);
m_depthImage = QImage(depthRgbMat.data, depthRgbMat.cols, depthRgbMat.rows, static_cast<int>(depthRgbMat.step), QImage::Format_RGB888).copy();
//m_depthImage = QImage(depthMat.data, depthMat.cols, depthMat.rows, static_cast<int>(depthMat.step), QImage::Format_Grayscale16).copy();
emit PlotSignal();
//点云
pointCloud->setCreatePointFormat(OB_FORMAT_RGB_POINT);
std::shared_ptr<ob::Frame> frame = pointCloud->process(frameSet);
QString plyPath = fileNamePrefix + "_"+ QString::number(frameIndex) + ".ply";
ob::PointCloudHelper::savePointcloudToPly(plyPath.toStdString().c_str(), frame, false, false, 50);
//惯导数据
auto accelFrameRaw = frameSet->getFrame(OB_FRAME_ACCEL);
auto accelFrame = accelFrameRaw->as<ob::AccelFrame>();
auto accelIndex = accelFrame->getIndex();
auto accelTimeStampUs = accelFrame->getTimeStampUs();
auto accelTemperature = accelFrame->getTemperature();
auto accelType = accelFrame->getType();
//if (frameIndex % 50 == 0)
//{ // print information every 50 frames.
// auto accelValue = accelFrame->getValue();
// printImuValue(accelValue, accelIndex, accelTimeStampUs, accelTemperature, accelType, "m/s^2");
//}
//auto accelValue = accelFrame->getValue();
//printImuValue(accelValue, accelIndex, accelTimeStampUs, accelTemperature, accelType, "m/s^2");
auto gyroFrameRaw = frameSet->getFrame(OB_FRAME_GYRO);
auto gyroFrame = gyroFrameRaw->as<ob::GyroFrame>();
auto gyroIndex = gyroFrame->getIndex();
auto gyroTimeStampUs = gyroFrame->getTimeStampUs();
auto gyroTemperature = gyroFrame->getTemperature();
auto gyroType = gyroFrame->getType();
//if (frameIndex % 50 == 0) { // print information every 50 frames.
// auto gyroValue = gyroFrame->getValue();
// printImuValue(gyroValue, gyroIndex, gyroTimeStampUs, gyroTemperature, gyroType, "rad/s");
//}
//auto gyroValue = gyroFrame->getValue();
//printImuValue(gyroValue, gyroIndex, gyroTimeStampUs, gyroTemperature, gyroType, "rad/s");
saveImuData(imuFile, accelFrame, gyroFrame);
frameIndex++;
}
imuFile.close();
m_pipe->stop();
delete m_pipe;
m_pipe = nullptr;
}
void DepthCameraOperation::saveDepthFrame(const std::shared_ptr<ob::DepthFrame> depthFrame, const uint32_t frameIndex, std::string fileNamePrefix_)
{
std::vector<int> params;
params.push_back(cv::IMWRITE_PNG_COMPRESSION);
params.push_back(0);
params.push_back(cv::IMWRITE_PNG_STRATEGY);
params.push_back(cv::IMWRITE_PNG_STRATEGY_DEFAULT);
std::string depthName = fileNamePrefix_ + "_Depth_" + std::to_string(depthFrame->width()) + "x" + std::to_string(depthFrame->height()) + "_" + std::to_string(frameIndex) + "_"
+ std::to_string(depthFrame->timeStamp()) + "ms.png";
cv::Mat depthMat(depthFrame->height(), depthFrame->width(), CV_16UC1, depthFrame->data());
cv::imwrite(depthName, depthMat, params);
//std::cout << "Depth saved:" << depthName << std::endl;
}
void DepthCameraOperation::saveColorFrame(const std::shared_ptr<ob::ColorFrame> colorFrame, const uint32_t frameIndex, std::string fileNamePrefix_)
{
std::vector<int> params;
params.push_back(cv::IMWRITE_PNG_COMPRESSION);
params.push_back(0);
params.push_back(cv::IMWRITE_PNG_STRATEGY);
params.push_back(cv::IMWRITE_PNG_STRATEGY_DEFAULT);
std::string colorName = fileNamePrefix_ + "_Color_" + std::to_string(colorFrame->width()) + "x" + std::to_string(colorFrame->height()) + "_" + std::to_string(frameIndex) + "_"
+ std::to_string(colorFrame->timeStamp()) + "ms.png";
cv::Mat depthMat(colorFrame->height(), colorFrame->width(), CV_8UC3, colorFrame->data());
cv::imwrite(colorName, depthMat, params);
//std::cout << "Color saved:" << colorName << std::endl;
}
void DepthCameraOperation::printImuValue(OBFloat3D obFloat3d, uint64_t index, uint64_t timeStampUs, float temperature, OBFrameType type, const std::string& unitStr)
{
std::cout << "frame index: " << index << std::endl;
auto typeStr = ob::TypeHelper::convertOBFrameTypeToString(type);
std::cout << typeStr << " Frame: \n\r{\n\r"
<< " tsp = " << timeStampUs << "\n\r"
<< " temperature = " << temperature << "\n\r"
<< " " << typeStr << ".x = " << obFloat3d.x << unitStr << "\n\r"
<< " " << typeStr << ".y = " << obFloat3d.y << unitStr << "\n\r"
<< " " << typeStr << ".z = " << obFloat3d.z << unitStr << "\n\r"
<< "}\n\r" << std::endl;
}
void DepthCameraOperation::saveImuData(std::ofstream& imuFile, const std::shared_ptr<ob::AccelFrame>& accelFrame, const std::shared_ptr<ob::GyroFrame>& gyroFrame)
{
if (!imuFile.is_open())
return;
auto accelValue = accelFrame->getValue();
auto gyroValue = gyroFrame->getValue();
// position (acceleration): ax, ay, az
// attitude (angular velocity): gx, gy, gz
imuFile << accelFrame->getIndex() << ","
<< accelFrame->getTimeStampUs() << ","
<< accelValue.x << "," << accelValue.y << "," << accelValue.z << ","
<< gyroFrame->getIndex() << ","
<< gyroFrame->getTimeStampUs() << ","
<< gyroValue.x << "," << gyroValue.y << "," << gyroValue.z << "\n";
}
void DepthCameraOperation::OpenDepthCamera_callback()
{
}
void DepthCameraOperation::setCallback(void(*func)())
{
m_func = func;
}
void DepthCameraOperation::CloseDepthCamera()
{
std::cout << "DepthCameraOperation::CloseDepthCamera关闭深度相机" << std::endl;
record = false;
emit CamClosedSignal();
}

84
HPPA/DepthCameraWindow.h Normal file
View File

@ -0,0 +1,84 @@
#pragma once
#include <QDialog>
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QNetworkAccessManager>
#include <QImage>
#include <Qthread>
#include <QDir>
#include <iostream>
#include "ui_DepthCamera.h"
#include "AppSettings.h"
#include <fstream>
#include <opencv2/opencv.hpp>
#include <libobsensor/ObSensor.hpp>
#include "libobsensor/hpp/Utils.hpp"
typedef void(*func)();
class DepthCameraOperation :public QObject
{
Q_OBJECT
public:
DepthCameraOperation();
~DepthCameraOperation();
QImage m_colorImage;
QImage m_depthImage;
void setCallback(void(*func)());
bool getRecordStatus() const { return record; }
private:
ob::Pipeline* m_pipe;
cv::Mat frame;
func m_func;
void saveDepthFrame(const std::shared_ptr<ob::DepthFrame> depthFrame, const uint32_t frameIndex, std::string fileNamePrefix_);
void saveColorFrame(const std::shared_ptr<ob::ColorFrame> colorFrame, const uint32_t frameIndex, std::string fileNamePrefix_);
void printImuValue(OBFloat3D obFloat3d, uint64_t index, uint64_t timeStampUs, float temperature, OBFrameType type, const std::string& unitStr);
void saveImuData(std::ofstream& imuFile, const std::shared_ptr<ob::AccelFrame>& accelFrame, const std::shared_ptr<ob::GyroFrame>& gyroFrame);
bool record;
public slots:
void OpenDepthCamera();
void OpenDepthCamera_callback();//不使用信号而使用回调函数来通知界面刷新视频
void CloseDepthCamera();
signals:
void PlotSignal();
void CamOpenedSignal();
void CamClosedSignal();
};
class DepthCameraWindow : public QDialog
{
Q_OBJECT
public:
DepthCameraWindow(QWidget* parent = nullptr);
~DepthCameraWindow();
DepthCameraOperation* m_DepthCameraOperation;
public Q_SLOTS:
void openDepthCamera();
void onCamOpened();
void closeDepthCamera();
void onCamClosed();
signals:
void openDepthCameraSignal();
void PlotDepthImageSignal();
void DepthCamClosedSignal();
private:
Ui::DepthCameraClass ui;
QThread* m_DepthCameraThread;
};

46
HPPA/FileNameLineEdit.cpp Normal file
View File

@ -0,0 +1,46 @@
#include "FileNameLineEdit.h"
FileNameLineEdit::FileNameLineEdit(QWidget* parent)
: QLineEdit(parent)
{
setText(AppSettings::instance().fileName());
connect(this, &QLineEdit::textChanged, this, &FileNameLineEdit::onTextChanged);
}
void FileNameLineEdit::keyPressEvent(QKeyEvent* event)
{
if (event->key() == Qt::Key_Space)
{
event->ignore();
return;
}
QLineEdit::keyPressEvent(event);
}
void FileNameLineEdit::inputMethodEvent(QInputMethodEvent* event)
{
QString commitString = event->commitString();
if (commitString.contains(' '))
{
commitString.remove(' ');
QInputMethodEvent filtered(event->preeditString(), event->attributes());
filtered.setCommitString(commitString);
QLineEdit::inputMethodEvent(&filtered);
return;
}
QLineEdit::inputMethodEvent(event);
}
void FileNameLineEdit::onTextChanged(const QString& text)
{
QString cleaned = text;
if (cleaned.contains(' '))
{
int pos = cursorPosition();
cleaned.remove(' ');
setText(cleaned);
setCursorPosition(qMin(pos, cleaned.length()));
return;
}
AppSettings::instance().setFileName(cleaned);
}

21
HPPA/FileNameLineEdit.h Normal file
View File

@ -0,0 +1,21 @@
#pragma once
#include <QLineEdit>
#include <QKeyEvent>
#include "AppSettings.h"
class FileNameLineEdit : public QLineEdit
{
Q_OBJECT
public:
explicit FileNameLineEdit(QWidget* parent = nullptr);
protected:
void keyPressEvent(QKeyEvent* event) override;
void inputMethodEvent(QInputMethodEvent* event) override;
private slots:
void onTextChanged(const QString& text);
};

View File

@ -6,25 +6,299 @@
<rect>
<x>0</x>
<y>0</y>
<width>632</width>
<height>444</height>
<width>557</width>
<height>432</height>
</rect>
</property>
<property name="windowTitle">
<string>调焦</string>
</property>
<property name="windowIcon">
<iconset resource="HPPA.qrc">
<normaloff>:/HPPA/HPPA.ico</normaloff>:/HPPA/HPPA.ico</iconset>
<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;
}
QGroupBox
{
border: 12px solid transparent;
/*border-top: 12px solid transparent;
border-right: 0px solid transparent;
border-bottom: 0px solid transparent;
border-left: 0px solid transparent;*/
color: #ACCDFF;
}
QPushButton
{
/*width: 172px;
height: 56px;*/
font: 10pt &quot;新宋体&quot;;
background-color: qlineargradient(
spread:pad,
x1:0.5, y1:0, x2:0.5, y2:1,
stop:0 #283D86,
stop:1 #0F1A40
);
color: white;
border: none;
padding: 8px 8px;
border-radius: 4px;
}
QPushButton:hover
{
background-color: qlineargradient(
spread:pad,
x1:0, y1:0, x2:1, y2:0,
stop:0 #3A4875,
stop:1 #5F6B91
);
}
/* 按下时的效果 */
QPushButton:pressed
{
background-color: qlineargradient(
spread:pad,
x1:0, y1:0, x2:1, y2:0,
stop:0 #1A254F,
stop:1 #3A466B
);
/* 可选:添加下压效果 */
padding-top: 9px;
padding-bottom: 7px;
}
QLabel {
color: rgb(255, 255, 255);
}
QSlider::groove:horizontal {
height: 10px;
background: #1e2a44;
border-radius: 3px;
}
/* 已滑过:渐变蓝 */
QSlider::sub-page:horizontal {
background: qlineargradient(
x1:0, y1:0, x2:1, y2:0,
stop:0 #1f4fff,
stop:0.5 #2f6bff,
stop:1 #5fa0ff
);
border-radius: 3px;
}
/* 未滑过 */
QSlider::add-page:horizontal {
height: 10px;
background: #2a3550;
border-radius: 3px;
}
/* ===== 滑块按钮 ===== */
QSlider::handle:horizontal {
width: 15px;
height: 10px;
/* 蓝色实心 */
background: #2f6bff;
/* 白色外圈 */
border: 2px solid #ffffff;
border-radius: 5px;
/* 垂直居中 */
margin: -5px 0;
}
/* 悬停 */
QSlider::handle:horizontal:hover {
background: #4d8dff;
}
/* 按下 */
QSlider::handle:horizontal:pressed {
background: #1f4fff;
}</string>
</property>
<layout class="QGridLayout" name="gridLayout_6">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="spacing">
<number>10</number>
</property>
<item row="0" column="0">
<widget class="QWidget" name="contentWidget" native="true">
<property name="styleSheet">
<string notr="true">QWidget #contentWidget
{
background: #040125;
/*border-radius: 8px 8px 8px 8px;*/
border: 1px solid #2f6bff;
}</string>
</property>
<layout class="QGridLayout" name="gridLayout_7">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="spacing">
<number>10</number>
</property>
<item row="0" column="0">
<widget class="QWidget" name="titlebarWidget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>43</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>43</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">QWidget #titlebarWidget
{
background: #0E1C4C;
border: 1px solid #2f6bff;
}
</string>
</property>
<layout class="QGridLayout" name="gridLayout_5">
<item row="0" column="0">
<widget class="QLabel" name="iconLabel">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label_7">
<property name="text">
<string>调焦</string>
</property>
</widget>
</item>
<item row="0" column="2">
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>505</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="3">
<widget class="QPushButton" name="closeBtn">
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="HPPA.qrc">
<normaloff>:/svg/resources/icons/svg/close.svg</normaloff>:/svg/resources/icons/svg/close.svg</iconset>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="0">
<widget class="QWidget" name="widget" native="true">
<layout class="QGridLayout" name="gridLayout_2">
<property name="leftMargin">
<number>10</number>
</property>
<property name="topMargin">
<number>10</number>
</property>
<property name="rightMargin">
<number>10</number>
</property>
<property name="bottomMargin">
<number>10</number>
</property>
<property name="spacing">
<number>10</number>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0" rowspan="2">
<widget class="QGroupBox" name="connectFocusModule_groupBox">
<property name="title">
<string>连接调焦模块</string>
<widget class="QWidget" name="connectFocusModule_widget" native="true">
<property name="styleSheet">
<string notr="true">QWidget #connectFocusModule_widget
{
background: #121945;
border-radius: 5px 5px 5px 5px;
}
QRadioButton
{
color: #E2EDFF;
}</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="leftMargin">
<number>9</number>
</property>
<property name="topMargin">
<number>9</number>
</property>
<property name="rightMargin">
<number>9</number>
</property>
<property name="bottomMargin">
<number>9</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>连接调焦模块</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="enabled">
<bool>true</bool>
@ -37,31 +311,44 @@
</property>
</widget>
</item>
<item row="0" column="1">
<item row="1" column="1">
<widget class="QComboBox" name="motorPort_comboBox"/>
</item>
<item row="1" column="0">
<item row="2" column="0">
<widget class="QRadioButton" name="ultrasound_radioButton">
<property name="text">
<string>超声</string>
</property>
</widget>
</item>
<item row="1" column="1">
<item row="2" column="1">
<widget class="QComboBox" name="ultrasoundPort_comboBox">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<item row="3" column="0">
<widget class="QRadioButton" name="is_new_version_radioButton">
<property name="text">
<string>新版</string>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<item row="3" column="1">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>107</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="4" column="0" colspan="2">
<widget class="QPushButton" name="connectMotor_btn">
<property name="text">
<string>连接线性平台</string>
@ -71,35 +358,63 @@
</layout>
</widget>
</item>
<item row="1" column="1">
<widget class="QGroupBox" name="controlFocus_groupBox">
<property name="title">
<string>调焦</string>
<item row="0" column="1">
<widget class="QWidget" name="controlMotor_widget" native="true">
<property name="styleSheet">
<string notr="true">QWidget #controlMotor_widget
{
background: #121945;
border-radius: 5px 5px 5px 5px;
}</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QLabel" name="label_3">
<property name="enabled">
<bool>true</bool>
<item row="2" column="0">
<widget class="QPushButton" name="moveto_btn">
<property name="text">
<string>移动至</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QPushButton" name="logicZero_btn">
<property name="text">
<string>LogicZero</string>
</property>
</widget>
</item>
<item row="2" column="1" colspan="2">
<widget class="QLineEdit" name="move2_lineEdit">
<property name="minimumSize">
<size>
<width>88</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>采样率</string>
<string>10</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="sample_ratio_lineEdit">
<item row="3" column="0">
<widget class="QPushButton" name="add_btn">
<property name="text">
<string>+</string>
</property>
</widget>
</item>
<item row="4" column="1" colspan="2">
<widget class="QLineEdit" name="subtractStepSize_lineEdit">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
<width>88</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>20</string>
<string>10</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
@ -107,67 +422,53 @@
</widget>
</item>
<item row="1" column="0">
<widget class="QProgressBar" name="autoFocusProgress_progressBar">
<property name="value">
<number>24</number>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="autoFocus_btn">
<property name="text">
<string>自动调焦</string>
</property>
</widget>
</item>
<item row="2" column="0">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>171</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="1">
<widget class="QPushButton" name="manualFocus_btn">
<property name="text">
<string>手动调焦</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="0" column="1">
<widget class="QGroupBox" name="controlMotor_groupBox">
<property name="title">
<string>调整线性平台</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QPushButton" name="updateCurrentLocation_btn">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>34</height>
</size>
</property>
<property name="text">
<string>更新实时位置</string>
</property>
</widget>
</item>
<item row="0" column="1" colspan="2">
<item row="3" column="1" colspan="2">
<widget class="QLineEdit" name="addStepSize_lineEdit">
<property name="minimumSize">
<size>
<width>88</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>10</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="5" column="2">
<widget class="QPushButton" name="rangeMeasurement_btn">
<property name="text">
<string>量程测量</string>
</property>
</widget>
</item>
<item row="1" column="1" colspan="2">
<widget class="QLineEdit" name="currentLocation_lineEdit">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
<width>88</width>
<height>30</height>
</size>
</property>
<property name="text">
@ -181,23 +482,82 @@
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="moveto_btn">
<item row="4" column="0">
<widget class="QPushButton" name="subtract_btn">
<property name="text">
<string>移动至</string>
<string>-</string>
</property>
</widget>
</item>
<item row="1" column="1" colspan="2">
<widget class="QLineEdit" name="move2_lineEdit">
<item row="5" column="1">
<widget class="QPushButton" name="max_btn">
<property name="text">
<string>max</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_5">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>调整线性平台</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="1">
<widget class="QWidget" name="controlFocus_widget" native="true">
<property name="styleSheet">
<string notr="true">QWidget #controlFocus_widget
{
background: #121945;
border-radius: 5px 5px 5px 5px;
}</string>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
<widget class="QLabel" name="label_4">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>调焦</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_3">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>采样率</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="sample_ratio_lineEdit">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
<width>88</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>10</string>
<string>20</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
@ -205,70 +565,57 @@
</widget>
</item>
<item row="2" column="0">
<widget class="QPushButton" name="add_btn">
<property name="text">
<string>+</string>
<widget class="QProgressBar" name="autoFocusProgress_progressBar">
<property name="styleSheet">
<string notr="true">QProgressBar {
border: 2px solid #08FACE; /* 边框颜色和宽度 */
border-radius: 8px; /* 圆角 */
background-color: #eee; /* 未完成部分颜色 */
text-align: center; /* 百分比文本居中 */
height: 13px; /* 高度 */
}
QProgressBar::chunk {
background-color: #08FACE; /* 渐变色进度块 */
border-radius: 8px; /* 保持和整体圆角一致 */
}</string>
</property>
<property name="value">
<number>24</number>
</property>
</widget>
</item>
<item row="2" column="1" colspan="2">
<widget class="QLineEdit" name="addStepSize_lineEdit">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<item row="2" column="1">
<widget class="QPushButton" name="autoFocus_btn">
<property name="text">
<string>10</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
<string>自动调焦</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QPushButton" name="subtract_btn">
<property name="text">
<string>-</string>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="3" column="1" colspan="2">
<widget class="QLineEdit" name="subtractStepSize_lineEdit">
<property name="minimumSize">
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
<width>171</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="1">
<widget class="QPushButton" name="manualFocus_btn">
<property name="text">
<string>10</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
<string>手动调焦</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QPushButton" name="logicZero_btn">
<property name="text">
<string>LogicZero</string>
</property>
</layout>
</widget>
</item>
<item row="4" column="1">
<widget class="QPushButton" name="max_btn">
<property name="text">
<string>max</string>
</property>
</widget>
</item>
<item row="4" column="2">
<widget class="QPushButton" name="rangeMeasurement_btn">
<property name="text">
<string>量程测量</string>
</property>
</layout>
</widget>
</item>
</layout>

861
HPPA/HPPA - 副本 (2).ui Normal file
View File

@ -0,0 +1,861 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>HPPAClass</class>
<widget class="QMainWindow" name="HPPAClass">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1486</width>
<height>898</height>
</rect>
</property>
<property name="windowTitle">
<string>Spectral Insight</string>
</property>
<property name="windowIcon">
<iconset resource="HPPA.qrc">
<normaloff>:/ico/resources/icons/ico/Spectral_Insight_128.ico</normaloff>:/ico/resources/icons/ico/Spectral_Insight_128.ico</iconset>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<widget class="QWidget" name="centralWidget"/>
<widget class="QMenuBar" name="menuBar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1486</width>
<height>30</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>-1</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">QMenuBar{
background:#F0F0F0;
color:rgb(0,0,0);
font-size:14px;
padding:1px;
border:1px solid rgb(165,171,184);
}
QMenuBar::item{
background:#F0F0F0;
width:30px;
height:15px;
}
QMenuBar::item:selected{
background:rgb(185,196,221);
}
QMenu{
background:rgb(255,255,255);
color:rgb(0,0,0);
border:1px solid rgb(165,171,184);
}
QMenu::item:selected{
background:rgb(69,123,255);
color:white;
}
</string>
</property>
<widget class="QMenu" name="file">
<property name="title">
<string>文件</string>
</property>
<addaction name="mActionOpenImg"/>
<addaction name="separator"/>
<addaction name="mSetting"/>
<addaction name="action_exit"/>
</widget>
<widget class="QMenu" name="menuspectrometer">
<property name="title">
<string>光谱仪</string>
</property>
<widget class="QMenu" name="menu">
<property name="font">
<font>
<family>宋体</family>
</font>
</property>
<property name="title">
<string>选择相机类型</string>
</property>
<addaction name="mActionPica_L"/>
<addaction name="mActionPica_NIR"/>
<addaction name="mActionPika_XC2"/>
<addaction name="separator"/>
<addaction name="mActionCorning_410"/>
</widget>
<addaction name="menu"/>
<addaction name="action_connect_imager"/>
<addaction name="separator"/>
<addaction name="action_auto_exposure"/>
<addaction name="action_focus"/>
<addaction name="action_dark"/>
<addaction name="action_reference"/>
<addaction name="separator"/>
<addaction name="action_start_recording"/>
<addaction name="separator"/>
<addaction name="actionOpenDirectory"/>
</widget>
<widget class="QMenu" name="menuhelp">
<property name="title">
<string>帮助</string>
</property>
<addaction name="action_about"/>
</widget>
<widget class="QMenu" name="mWindowsMenu">
<property name="title">
<string>窗口</string>
</property>
</widget>
<widget class="QMenu" name="menu_2">
<property name="title">
<string>扫描平台</string>
</property>
<addaction name="mAction_is_no_motor"/>
<addaction name="mAction_1AxisMotor"/>
<addaction name="mAction_2AxisMotor_new"/>
<addaction name="separator"/>
<addaction name="mAction_RobotArm"/>
</widget>
<widget class="QMenu" name="mMenuScenario">
<property name="title">
<string>应用场景</string>
</property>
<addaction name="mActionOneMotorScenario"/>
<addaction name="mActionPlantPhenotypeScenario"/>
</widget>
<widget class="QMenu" name="menu_4">
<property name="title">
<string>数据处理</string>
</property>
<addaction name="action_4"/>
<addaction name="action_5"/>
<addaction name="action_13"/>
</widget>
<addaction name="file"/>
<addaction name="menuspectrometer"/>
<addaction name="mMenuScenario"/>
<addaction name="menu_4"/>
<addaction name="menu_2"/>
<addaction name="mWindowsMenu"/>
<addaction name="menuhelp"/>
</widget>
<widget class="QToolBar" name="mainToolBar">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<family>宋体</family>
<pointsize>2</pointsize>
</font>
</property>
<property name="windowTitle">
<string>相机控制</string>
</property>
<property name="styleSheet">
<string notr="true">QToolBar{
background-color: #f5f5f5;
color:rgb(0,0,0);
}
QToolBar QToolButton {
background: #f5f5f5; /* 按钮背景颜色 */
font-size:15px;
border-radius: 3px; /* 按钮圆角 */
padding: 4px; /* 按钮内边距 */
}
QToolBar QToolButton:hover {
background: rgb(185,196,221); /* 按钮悬停背景颜色 */
color: white; /* 按钮悬停文字颜色 */
}
</string>
</property>
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
<addaction name="action_connect_imager"/>
<addaction name="action_auto_exposure"/>
<addaction name="action_focus"/>
<addaction name="action_dark"/>
<addaction name="action_reference"/>
<addaction name="action_start_recording"/>
<addaction name="actionOpenDirectory"/>
<addaction name="mActionPan"/>
<addaction name="mActionSpectral"/>
</widget>
<widget class="QStatusBar" name="statusBar">
<property name="styleSheet">
<string notr="true">QStatusBar
{
background-color: #0D1233;
color: white;
}
QStatusBar::item
{
border: none;
}</string>
</property>
</widget>
<widget class="CustomDockWidgetBase" name="mDockWidgetSimulator">
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="features">
<set>QDockWidget::AllDockWidgetFeatures</set>
</property>
<property name="windowTitle">
<string>3D模型</string>
</property>
<attribute name="dockWidgetArea">
<number>1</number>
</attribute>
<widget class="QWidget" name="dockWidgetContents_2">
<layout class="QGridLayout" name="gridLayout_7">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="verticalSpacing">
<number>0</number>
</property>
</layout>
</widget>
</widget>
<widget class="CustomDockWidgetHideAbove" name="mDockWidgetSpectrometer">
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="windowTitle">
<string>控制</string>
</property>
<attribute name="dockWidgetArea">
<number>2</number>
</attribute>
<widget class="QWidget" name="controlContents">
<property name="styleSheet">
<string notr="true">QWidget #controlContents
{
background-color: #0E1C4C;
border-top: 1px solid #2c586b;
border-left: 1px solid #2c586b;
border-right: 1px solid #2c586b;
border-bottom: 1px solid #2c586b;
border-top-left-radius: 0px;
border-top-right-radius: 0px;
border-bottom-left-radius: 10px;
border-bottom-right-radius: 10px;
}
</string>
</property>
<layout class="QGridLayout" name="gridLayout_5">
<property name="leftMargin">
<number>2</number>
</property>
<property name="topMargin">
<number>2</number>
</property>
<property name="rightMargin">
<number>2</number>
</property>
<property name="bottomMargin">
<number>2</number>
</property>
<property name="horizontalSpacing">
<number>6</number>
</property>
<item row="0" column="0">
<widget class="QTabWidget" name="controlTabWidget">
<property name="styleSheet">
<string notr="true">QTabBar::tab {
background: #0E1C4C;
color: white;
padding: 6px 12px;
border: none;
border-top: 1px solid #27376C;
height: 41;
}
QTabBar::tab:selected {
background: #0D1233;
color: white;
border: none;
}
/*QTabBar::tab:hover {
background: #141A45;
}*/
QTabWidget::pane {
border: none;
border-top: 1px solid #27376C;
background: #0D1233;
top: -1px;
}
</string>
</property>
<property name="tabPosition">
<enum>QTabWidget::South</enum>
</property>
<property name="tabShape">
<enum>QTabWidget::Rounded</enum>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<property name="elideMode">
<enum>Qt::ElideNone</enum>
</property>
<widget class="QWidget" name="rgbCameraWidget">
<property name="styleSheet">
<string notr="true">QGroupBox
{
border: 12px solid transparent;
color: #ACCDFF;
}
QPushButton
{
/*width: 172px;
height: 56px;*/
font: 19pt &quot;新宋体&quot;;
background-color: qlineargradient(
spread:pad,
x1:0.5, y1:0, x2:0.5, y2:1,
stop:0 #283D86,
stop:1 #0F1A40
);
color: white;
border: none;
padding: 8px 16px;
border-radius: 4px;
}
QPushButton:hover
{
background-color: qlineargradient(
spread:pad,
x1:0, y1:0, x2:1, y2:0,
stop:0 #3A4875,
stop:1 #5F6B91
);
}
/* 按下时的效果 */
QPushButton:pressed
{
background-color: qlineargradient(
spread:pad,
x1:0, y1:0, x2:1, y2:0,
stop:0 #1A254F,
stop:1 #3A466B
);
/* 可选:添加下压效果 */
padding-top: 9px;
padding-bottom: 7px;
}</string>
</property>
<attribute name="title">
<string>rgb相机</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_4" rowstretch="2,4,2" columnstretch="1,3,1">
<item row="0" column="1">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>174</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>115</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="1">
<layout class="QGridLayout" name="gridLayout_3" columnstretch="1,1">
<property name="spacing">
<number>20</number>
</property>
<item row="1" column="0">
<widget class="QPushButton" name="take_video_btn">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>录制视频</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="take_photo_btn">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>拍照</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="close_rgb_camera_btn">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>关闭</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QPushButton" name="open_rgb_camera_btn">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>打开</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="2">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>115</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="1">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>173</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
</widget>
<widget class="QToolBar" name="toolBar">
<property name="minimumSize">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
<property name="windowTitle">
<string>toolBar</string>
</property>
<property name="styleSheet">
<string notr="true">QToolBar {
background: #040125;/*transparent*/
border: 1px solid #040125;
}</string>
</property>
<property name="movable">
<bool>false</bool>
</property>
<attribute name="toolBarArea">
<enum>LeftToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
</widget>
<widget class="QToolBar" name="toolBar_2">
<property name="minimumSize">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
<property name="windowTitle">
<string>toolBar_2</string>
</property>
<property name="styleSheet">
<string notr="true">QToolBar {
background: #040125;/*transparent*/
border: 1px solid #040125;
}</string>
</property>
<property name="movable">
<bool>false</bool>
</property>
<attribute name="toolBarArea">
<enum>RightToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
</widget>
<widget class="QToolBar" name="toolBar_3">
<property name="minimumSize">
<size>
<width>0</width>
<height>20</height>
</size>
</property>
<property name="windowTitle">
<string>toolBar_3</string>
</property>
<property name="styleSheet">
<string notr="true">QToolBar {
background: #040125;/*transparent*/
border: 1px solid #040125;
}</string>
</property>
<property name="movable">
<bool>false</bool>
</property>
<attribute name="toolBarArea">
<enum>BottomToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
</widget>
<action name="action_exit">
<property name="text">
<string>退出</string>
</property>
<property name="font">
<font>
<family>Adobe Devanagari</family>
</font>
</property>
</action>
<action name="action_open">
<property name="text">
<string>open</string>
</property>
<property name="iconText">
<string>open</string>
</property>
</action>
<action name="actionpreference">
<property name="text">
<string>preference...</string>
</property>
</action>
<action name="action_start_recording">
<property name="text">
<string>采集</string>
</property>
</action>
<action name="action_focus">
<property name="text">
<string>调焦</string>
</property>
</action>
<action name="action_auto_exposure">
<property name="text">
<string>曝光</string>
</property>
</action>
<action name="action_dark">
<property name="text">
<string>暗电流</string>
</property>
</action>
<action name="action_reference">
<property name="text">
<string>白板</string>
</property>
</action>
<action name="action_connect_imager">
<property name="text">
<string>连接相机</string>
</property>
<property name="font">
<font>
<family>宋体</family>
</font>
</property>
</action>
<action name="actionOpenDirectory">
<property name="text">
<string>打开文件夹</string>
</property>
</action>
<action name="mActionPica_L">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Pika L</string>
</property>
<property name="font">
<font>
<family>宋体</family>
</font>
</property>
</action>
<action name="mActionCorning_410">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Corning 410</string>
</property>
</action>
<action name="mActionPika_XC2">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Pika XC2</string>
</property>
<property name="font">
<font>
<family>宋体</family>
</font>
</property>
</action>
<action name="action_about">
<property name="text">
<string>关于</string>
</property>
</action>
<action name="mActionPica_NIR">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Pika NIR</string>
</property>
<property name="font">
<font>
<family>宋体</family>
</font>
</property>
</action>
<action name="actionpanel">
<property name="text">
<string>面板</string>
</property>
</action>
<action name="action">
<property name="text">
<string>工具栏</string>
</property>
</action>
<action name="action_2">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>马达</string>
</property>
</action>
<action name="mAction_is_no_motor">
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>无</string>
</property>
</action>
<action name="mAction_2AxisMotor">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>2 轴线性马达</string>
</property>
</action>
<action name="mAction_RobotArm">
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<property name="text">
<string>机械臂</string>
</property>
</action>
<action name="mAction_1AxisMotor">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>1 轴线性马达</string>
</property>
</action>
<action name="mActionOneMotorScenario">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>室内1轴线性平台</string>
</property>
</action>
<action name="action_4">
<property name="text">
<string>辐亮度</string>
</property>
</action>
<action name="action_5">
<property name="text">
<string>反射率</string>
</property>
</action>
<action name="action_6">
<property name="text">
<string>机械臂</string>
</property>
</action>
<action name="action_7">
<property name="text">
<string>显微镜</string>
</property>
</action>
<action name="action_8">
<property name="text">
<string>三脚架(旋转平台)</string>
</property>
</action>
<action name="mActionOpenImg">
<property name="text">
<string>打开影像</string>
</property>
</action>
<action name="action_10">
<property name="text">
<string>关闭影像</string>
</property>
</action>
<action name="mSetting">
<property name="text">
<string>设置</string>
</property>
</action>
<action name="action_13">
<property name="text">
<string>拼接</string>
</property>
</action>
<action name="mActionPlantPhenotypeScenario">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>植物表型</string>
</property>
</action>
<action name="action2">
<property name="text">
<string>2轴旋转平台</string>
</property>
</action>
<action name="mAction_2AxisMotor_new">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>2 轴线性马达</string>
</property>
</action>
<action name="mActionPan">
<property name="text">
<string>漫游</string>
</property>
</action>
<action name="mActionSpectral">
<property name="text">
<string>光谱</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>
<customwidget>
<class>CustomDockWidgetBase</class>
<extends>QDockWidget</extends>
<header>customdockwidgetbase.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>CustomDockWidgetHideAbove</class>
<extends>QDockWidget</extends>
<header>CustomDockWidgetBase.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources>
<include location="HPPA.qrc"/>
</resources>
<connections/>
</ui>

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
#pragma once
#pragma once
#include <cstdio>
#include <iostream>
@ -12,11 +12,14 @@
#include <QLineSeries>
#include <QChart>
#include <QChartView>
#include <QValueAxis>
#include <QFileDialog>
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QNetworkAccessManager>
#include <QVector>
#include <QItemSelection>
#include "ui_HPPA.h"
#include "resononImager.h"
@ -35,6 +38,7 @@
#include "RobotArmControl.h"
#include "OneMotorControl.h"
#include "TwoMotorControl.h"
#include "imageControl.h"
#include "hppaConfigFile.h"
#include "path_tc.h"
@ -42,9 +46,43 @@
#include "ResononNirImager.h"
#include "Corning410Imager.h"
#include "CustomDockWidgetBase.h"
#include "Carousel.h"
#include "View3D.h"
#include "TabManager.h"
#include "View3DModelManager.h"
#include "LayerTreeModel.h"
#include "LayerTree.h"
#include "MapLayer.h"
#include "MapLayerStore.h"
#include "LayerTreeView.h"
#include "LayerTreeViewMenuProvider.h"
#include "MapTool.h"
#include "MapToolPan.h"
#include "MapToolSpectral.h"
#include "MapTools.h"
#include "AspectRatioLabel.h"
#include "HyperImagerControl.h"
#include "recordFrameCounter.h"
#include "setWindow.h"
#include "AppSettings.h"
#include "FileNameLineEdit.h"
#include "rgbCameraWindow.h"
#include "DepthCameraWindow.h"
#define PI 3.1415926
QT_CHARTS_USE_NAMESPACE//QChartView ʹ<EFBFBD><EFBFBD> <20><>Ҫ<EFBFBD>Ӻ꣬ <20><><EFBFBD><EFBFBD><EFBFBD>޷<EFBFBD>ʹ<EFBFBD><CAB9>
QT_CHARTS_USE_NAMESPACE//QChartView 使用 需要加宏, 否则无法使用
class WorkerThread : public QThread
{
@ -71,11 +109,11 @@ public:
// //double x = m_Imager->m_ResononImager.get_framerate();
// int x = m_Imager->m_ResononImager.get_band_count();
// std::cout << "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>slopeΪ<EFBFBD><EFBFBD>" << x << std::endl;
// std::cout << "相机连接正常!slope为:" << x << std::endl;
// }
// catch (std::runtime_error *e)//CException *e
// {
// std::cout << "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ͽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӣ<EFBFBD>" << e->what() << std::endl;
// std::cout << "相机断开连接!" << e->what() << std::endl;
// }
// Sleep(1000);
// }
@ -123,6 +161,31 @@ signals:
void threadSignal(QString s);
};
class WidgetWithBackgroundPicture : public QWidget
{
Q_OBJECT
public:
explicit WidgetWithBackgroundPicture(QWidget* parent = nullptr)
: QWidget(parent),
m_pixmap(":/png/resources/icons/png/titile_bar_bgp.png") // 使用资源或绝对路径
{
// 可选:设置初始大小
resize(800, 600);
}
protected:
void paintEvent(QPaintEvent* event) override
{
QPainter painter(this);
QPixmap scaled = m_pixmap.scaled(size(), Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation);
painter.drawPixmap(rect(), scaled);
}
private:
QPixmap m_pixmap;
};
class HPPA : public QMainWindow
{
Q_OBJECT
@ -131,20 +194,26 @@ public:
HPPA(QWidget *parent = Q_NULLPTR);
~HPPA();
void CalculateIntegratioinTimeRange();//ͨ<><CDA8>֡<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>Χ<E4B7B6><CEA7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>slider<65><72><EFBFBD><EFBFBD>ֵ
static HPPA* instance();
LayerTreeNode* rasterGroupNode() const;
WorkerThread * m_TestImagerStausThread;//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬<EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD>
WorkerThread * m_TestImagerStausThread;//检测相机连接状态的线程
private:
static HPPA* s_instance;
Ui::HPPAClass ui;
QTabWidget* m_imageViewerTabWidget;
QMenu* mPanelMenu = nullptr;
QMenu* mToolbarMenu = nullptr;
void initMenubarToolbar();
void initPanelToolbar();
void initControlTabwidget();
QWidget* tmp(QWidget* a);
QLineEdit * frame_number;
QLineEdit * m_FilenameLineEdit;
FileNameLineEdit * m_FilenameLineEdit;
QLabel * xmotor_state_label1;
QLabel * ymotor_state_label1;
@ -152,82 +221,129 @@ private:
ImagerOperationBase* m_Imager;//
int m_RecordState;//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>̣<EFBFBD>ȡ2<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>1 <20><> <20><><EFBFBD>ڲɼ<DAB2><C9BC><EFBFBD>0 <20><> ֹͣ<CDA3>ɼ<EFBFBD>
int m_RecordState;//用来控制相机采集流程取2的余数1 → 正在采集0 → 停止采集
QThread * m_RecordThread;//Ӱ<EFBFBD><EFBFBD><EFBFBD>ɼ<EFBFBD><EFBFBD>߳<EFBFBD>
QThread * m_RgbCameraThread;//rgb<67><62><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡͼ<C8A1><CDBC><EFBFBD>߳<EFBFBD>
QThread * m_CopyFileThread;//Ӱ<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD>
QThread * m_RecordThread;//影像采集线程
QThread * m_CopyFileThread;//影像文件复制线程
FileOperation * m_FileOperation;
QChartView * m_chartView;
QChart* m_chart;
//QLineSeries *series;
//QChart *chart;
QString operateWidget;//<EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀؼ<EFBFBD><EFBFBD><EFBFBD>
QString operateWidget;//当前操作的控件名
//ģ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD>
double widthScale;//QGraphicsView<EFBFBD><EFBFBD>viewport<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>widthScale = rect.width() / maxDistance;
double heightScale;//QGraphicsView<EFBFBD><EFBFBD>viewport<EFBFBD>ߺ<EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>heightScale = rect.height() / maxDistance;
//模拟相机位置
double widthScale;//QGraphicsViewviewport宽和真实距离比例:widthScale = rect.width() / maxDistance;
double heightScale;//QGraphicsViewviewport高和真实距离比例:heightScale = rect.height() / maxDistance;
void setImagerSimulationPos(double x, double y);//ui.graphicsView->imager->setPos(x, y);
//<EFBFBD>ɼ<EFBFBD><EFBFBD>߹滮
int m_numberOfRecording;//<EFBFBD><EFBFBD>ʾui.recordLine_tableWidget<EFBFBD>еĵڼ<EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD>ڲɼ<DAB2><C9BC>ڼ<EFBFBD><DABC><EFBFBD><EFBFBD><EFBFBD>
//采集线规划
int m_numberOfRecording;//表示ui.recordLine_tableWidget中的第几行 → 正在采集第几条线
//
int m_TabWidgetCurrentIndex;//<EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD>ѡ<EFBFBD><EFBFBD>TabWidget<EFBFBD>ı<EFBFBD>ǩʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>tab index
RgbCameraOperation *m_RgbCamera;
int m_TabWidgetCurrentIndex;//当手动选择TabWidget的标签时,记录变化后的tab index
void getRequest(QString str);
QActionGroup* mImagerGroup = nullptr;
void createActionGroups();
void selectingImager(QAction* selectedAction);
void updateImagerPicture(const QString& actionName);
QActionGroup* moveplatformActionGroup = nullptr;
void createMoveplatformActionGroup();
void selectingMoveplatform(QAction* selectedAction);
RobotArmControl* rac;
OneMotorControl* omc;
QDockWidget* dock_omc;
QActionGroup* m_ScenarioActionGroup = nullptr;
void createScenarioActionGroup();
void selectScenario(QAction* selectedAction);
TwoMotorControl* tmc;
QDockWidget* dock_tmc;
FILE* m_hTimesFile;
CustomDockWidgetBase* m_dock_carousel;
MyCarousel* m_carousel;
QLabel* m_cam_label;
QLabel* m_depthCamera_label;
QPushButton* m_open_rgb_camera_btn;
QPushButton* m_close_rgb_camera_btn;
TabManager* m_tabManager;
HyperImagerControl* m_hic;
rgbCameraWindow* m_rgbCameraControlWindow;
ImageControl* m_ic;
DepthCameraWindow* m_depthCameraWindow;
adjustTable* m_adt;
PowerControl* m_pc;
RobotArmControl* m_rac;
OneMotorControl* m_omc;
TwoMotorControl* m_tmc;
View3DModelManager* m_view3DModelManager;
LayerTreeView* m_layerTreeView;
LayerTree* m_LayerTree = nullptr;
LayerTreeModel* m_LayerTreeModel = nullptr;
LayerTreeNode* m_RasterGroup = nullptr; // 指向 "Raster" 分组,便于后续添加 layer
MapLayerStore* m_MapLayerStore = nullptr;
// Map tools
MapTools* m_mapTools = nullptr;
QActionGroup* m_mapToolActionGroup = nullptr;
void initMapTools();
void setMapTool();
QWidget* m_focusTab=nullptr;
recordFrameCounter* m_recordFrameCounter = nullptr;
bool testImagerVality();
void showMessageBox(QString msg, QString title= QString::fromLocal8Bit("提示"));
bool showResultMessageBox(QString title, QString msg);
void disconnectImagerAndCleanup();
public Q_SLOTS:
void onPlotHyperspectralImageRgbImage(int fileNumber, int frameNumber);
void PlotSpectral(int state);
void onPlotHyperspectralImageRgbImage(int fileNumber, int frameNumber, QString filePath);
void focusPlotSpectralImg(int state);
void onRecordFinishedSignal_WhenFrameNumberMeet();
void onRecordFinishedSignal_WhenFrameNumberNotMeet();
void onsequenceComplete();
void onExit();
void onconnect();//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
void testImagerStatus();//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>״̬<D7B4><CCAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>
void onOpenImg();
void onconnect();//连接相机
void testImagerStatus();//获取相机状态:连接是否正常
void autoExposureFinished();
void onAutoExposure();
void onFocus1();
void onFocus2(int command);
void onFocusWindowClosed();
void onAbout();
void settingWindow();
void onDark();
void recordDarkFinish();
void onReference();
void recordWhiteFinish();
void onStartRecordStep1();
void onCreateTab(int trackNumber);
QWidget* onCreateTab(QString tabName);
void onTabWidgetCurrentChanged(int index);
void onActionOpenDirectory();
void OnFramerateLineeditEditingFinished();//
void OnFramerateSliderChanged(double framerate);//
void onFramerateChanged(double framerate);
void onIntegrationTimeChanged(double integrationTime);
void onGainChanged(double gain);
void OnIntegratioinTimeEditingFinished();//
void OnIntegratioinTimeSliderChanged(double IntegratioinTime);//
void OnGainEditingFinished();//
void OnGainSliderChanged(double Gain);//
void onLeftMouseButtonPressed(int x, int y);//<2F><><EFBFBD><EFBFBD>Ӱ<EFBFBD><D3B0><EFBFBD><EFBFBD>Ԫ<EFBFBD><D4AA>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>
void onLeftMouseButtonPressed(int x, int y, QVector<double> wavelengths, QVector<double> spectrum);//点击影像像元显示光谱
void setAxis(QValueAxis* axisX, QValueAxis* axisY);
void timerEvent(QTimerEvent *event);
@ -236,8 +352,10 @@ public Q_SLOTS:
void OnSendLogToCallClass(QString str);
void onPlotRgbImage();
void onCloseRgbCamera();
void onPlotDepthImage();
void onClearLabel();
void onClearDepthLabel();
void onCopyFinished();
@ -246,6 +364,23 @@ public Q_SLOTS:
void recordFromRobotArm(int fileCounter);
void createOneMotorScenario();
void createPlantPhenotypeScenario();
void onCreated3DModelPlantPhenotype();
void onCreated3DModelOneMotor();
void addLayer(const QString& baseName, const QString& filePath, bool refresh);
void onLayerCreatedFromFile(const QString& baseName, const QString& filePath, int fileIndex);
void removeLayerByTreeIndex();
void removeAllLayersInRasterGroup();
void onLayerTreeSelectionChanged(const QItemSelection& selected, const QItemSelection& deselected);
void onBandSelectionChanged(double rWave, double gWave, double bWave);
void onMapToolPanTriggered();
void onMapToolSpectralTriggered();
protected:
void closeEvent(QCloseEvent* event) override;
signals:
void StartFocusSignal();
void StartRecordSignal();
@ -253,5 +388,6 @@ signals:
void RecordWhiteSignal();
void RecordDarlSignal();
};
void updateRecordingFileInfoSignal(const QString& filePath, const QString& baseName, int frameNumber);
};

Binary file not shown.

Before

Width:  |  Height:  |  Size: 66 KiB

View File

@ -1,5 +1,53 @@
<RCC>
<qresource prefix="/HPPA">
<file>HPPA.ico</file>
<qresource prefix="/svg">
<file>resources/icons/svg/arrow_down.svg</file>
<file>resources/icons/svg/arrow_up.svg</file>
<file>resources/icons/svg/close.svg</file>
<file>resources/icons/svg/connect_imager.svg</file>
<file>resources/icons/svg/connect_imager_done.svg</file>
<file>resources/icons/svg/connect_imager_ing.svg</file>
<file>resources/icons/svg/dark.svg</file>
<file>resources/icons/svg/dark_done.svg</file>
<file>resources/icons/svg/dark_ing.svg</file>
<file>resources/icons/svg/exposure.svg</file>
<file>resources/icons/svg/exposure_done.svg</file>
<file>resources/icons/svg/exposure_ing.svg</file>
<file>resources/icons/svg/focus.svg</file>
<file>resources/icons/svg/focus_done.svg</file>
<file>resources/icons/svg/focus_ing.svg</file>
<file>resources/icons/svg/openDirectory.svg</file>
<file>resources/icons/svg/openDirectory_done.svg</file>
<file>resources/icons/svg/pan.svg</file>
<file>resources/icons/svg/pan_done.svg</file>
<file>resources/icons/svg/record.svg</file>
<file>resources/icons/svg/record_done.svg</file>
<file>resources/icons/svg/record_ing.svg</file>
<file>resources/icons/svg/reference.svg</file>
<file>resources/icons/svg/reference_done.svg</file>
<file>resources/icons/svg/reference_ing.svg</file>
<file>resources/icons/svg/software_icon.svg</file>
<file>resources/icons/svg/software_icon_small.svg</file>
<file>resources/icons/svg/spectral.svg</file>
<file>resources/icons/svg/spectral_done.svg</file>
<file>resources/icons/svg/tree_tri_down.svg</file>
<file>resources/icons/svg/tree_tri_right.svg</file>
<file>resources/icons/svg/mIconRaster.svg</file>
</qresource>
<qresource prefix="/png">
<file>resources/icons/png/Spectral_Insight_27.png</file>
<file>resources/icons/png/Spectral_Insight_54.png</file>
<file>resources/icons/png/Spectral_Insight_170.png</file>
<file>resources/icons/png/Spectral_Insight_340.png</file>
<file>resources/icons/png/titile_bar_bgp.png</file>
<file>resources/icons/png/titile_bar_bgp2x.png</file>
</qresource>
<qresource prefix="/imagerPicture">
<file>resources/icons/imagerPicture/corning410.png</file>
<file>resources/icons/imagerPicture/IR.png</file>
<file>resources/icons/imagerPicture/L.png</file>
<file>resources/icons/imagerPicture/XC2.png</file>
</qresource>
<qresource prefix="/ico">
<file>resources/icons/ico/Spectral_Insight_128.ico</file>
</qresource>
</RCC>

Binary file not shown.

View File

@ -6,85 +6,27 @@
<rect>
<x>0</x>
<y>0</y>
<width>1194</width>
<height>834</height>
<width>1486</width>
<height>898</height>
</rect>
</property>
<property name="windowTitle">
<string>Hyper Plant Phenotypic Analysis</string>
<string>Spectral Insight</string>
</property>
<property name="windowIcon">
<iconset resource="HPPA.qrc">
<normaloff>:/HPPA/HPPA.ico</normaloff>:/HPPA/HPPA.ico</iconset>
<normaloff>:/ico/resources/icons/ico/Spectral_Insight_128.ico</normaloff>:/ico/resources/icons/ico/Spectral_Insight_128.ico</iconset>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<widget class="QWidget" name="centralWidget">
<layout class="QGridLayout" name="gridLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QTabWidget" name="ImageViewerTabWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>5</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tab_4">
<attribute name="title">
<string>Tab 1</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_5">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
</layout>
</widget>
<widget class="QWidget" name="tab_5">
<attribute name="title">
<string>Tab 2</string>
</attribute>
</widget>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="centralWidget"/>
<widget class="QMenuBar" name="menuBar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1194</width>
<width>1486</width>
<height>30</height>
</rect>
</property>
@ -128,10 +70,9 @@ color:white;
<property name="title">
<string>文件</string>
</property>
<addaction name="action_9"/>
<addaction name="action_10"/>
<addaction name="mActionOpenImg"/>
<addaction name="separator"/>
<addaction name="action_11"/>
<addaction name="mSetting"/>
<addaction name="action_exit"/>
</widget>
<widget class="QMenu" name="menuspectrometer">
@ -191,11 +132,7 @@ color:white;
<string>应用场景</string>
</property>
<addaction name="mActionOneMotorScenario"/>
<addaction name="action_8"/>
<addaction name="action2"/>
<addaction name="action_7"/>
<addaction name="action_3"/>
<addaction name="action_6"/>
<addaction name="mActionPlantPhenotypeScenario"/>
</widget>
<widget class="QMenu" name="menu_4">
<property name="title">
@ -260,138 +197,32 @@ QToolBar QToolButton:hover {
<addaction name="action_reference"/>
<addaction name="action_start_recording"/>
<addaction name="actionOpenDirectory"/>
<addaction name="mActionPan"/>
<addaction name="mActionSpectral"/>
</widget>
<widget class="QStatusBar" name="statusBar">
<property name="styleSheet">
<string notr="true">QStatusBar {
background-color: rgb(255, 255, 255);
color: white; /* 文字颜色 */
border-top: 1px solid #ccc; /* 顶部边框 */
padding: 5px; /* 内边距 */
}
</string>
</property>
</widget>
<widget class="QDockWidget" name="mDockWidgetRGBCamera">
<property name="styleSheet">
<string notr="true">/* 标题设置 */
QDockWidget::title {
text-align: left;
background-color: rgb(240, 240, 240);
/*padding-left: 35px;*/
}</string>
</property>
<property name="windowTitle">
<string>RGB 相机</string>
</property>
<attribute name="dockWidgetArea">
<number>1</number>
</attribute>
<widget class="QWidget" name="dockWidgetContents">
<layout class="QGridLayout" name="gridLayout_2">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QGroupBox" name="groupBox_4">
<property name="mouseTracking">
<bool>false</bool>
</property>
<property name="styleSheet">
<string notr="true">QGroupBox {
/* border: 2px solid #3498db; 边框颜色 */
border-radius: 5px; /* 圆角 */
padding: 10px; /* 内边距 */
background-color: rgb(255, 255, 255);
<string notr="true">QStatusBar
{
background-color: #0D1233;
color: white;
}
QGroupBox:title {
subcontrol-position: top left; /* 标题位置 */
padding: 0 10px; /* 标题内边距 */
font-weight: bold; /* 标题字体加粗 */
color: #3498db; /* 标题文字颜色 */
}
</string>
</property>
<property name="title">
<string/>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item row="1" column="1">
<widget class="QPushButton" name="close_rgb_camera_btn">
<property name="text">
<string>关闭</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="open_rgb_camera_btn">
<property name="text">
<string>打开</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="cam_label">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="text">
<string>摄像头关闭!</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</widget>
<widget class="QDockWidget" name="mDockWidgetSimulator">
<property name="styleSheet">
<string notr="true">/* 标题设置 */
QDockWidget::title {
text-align: left;
background-color: rgb(240, 240, 240);
/*padding-left: 35px;*/
QStatusBar::item
{
border: none;
}</string>
</property>
</widget>
<widget class="CustomDockWidgetBase" name="mDockWidgetSimulator">
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="features">
<set>QDockWidget::AllDockWidgetFeatures</set>
</property>
<property name="windowTitle">
<string>线性平台位置模拟</string>
<string>3D模型</string>
</property>
<attribute name="dockWidgetArea">
<number>1</number>
@ -413,317 +244,228 @@ QDockWidget::title {
<property name="verticalSpacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="ImagerPositionSimulation" name="graphicsView">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
<widget class="QDockWidget" name="mDockWidgetSpectralViewer">
<widget class="CustomDockWidgetHideAbove" name="mDockWidgetSpectrometer">
<property name="styleSheet">
<string notr="true">/* 标题设置 */
QDockWidget::title {
text-align: left;
background-color: rgb(240, 240, 240);
/*padding-left: 35px;*/
}</string>
<string notr="true"/>
</property>
<property name="windowTitle">
<string>光谱曲线</string>
<string>控制</string>
</property>
<attribute name="dockWidgetArea">
<number>2</number>
</attribute>
<widget class="QWidget" name="dockWidgetContents_3">
<layout class="QGridLayout" name="gridLayout_10">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
</layout>
</widget>
</widget>
<widget class="QDockWidget" name="mDockWidgetSpectrometer">
<widget class="QWidget" name="controlContents">
<property name="styleSheet">
<string notr="true">/* 标题设置 */
QDockWidget::title {
text-align: left;
background-color: rgb(240, 240, 240);
/*padding-left: 35px;*/
}</string>
<string notr="true">QWidget #controlContents
{
background-color: #0E1C4C;
border-top: 1px solid #2c586b;
border-left: 1px solid #2c586b;
border-right: 1px solid #2c586b;
border-bottom: 1px solid #2c586b;
border-top-left-radius: 0px;
border-top-right-radius: 0px;
border-bottom-left-radius: 10px;
border-bottom-right-radius: 10px;
}
</string>
</property>
<property name="windowTitle">
<string>光谱仪</string>
</property>
<attribute name="dockWidgetArea">
<number>2</number>
</attribute>
<widget class="QWidget" name="dockWidgetContents_4">
<layout class="QGridLayout" name="gridLayout_13">
<layout class="QGridLayout" name="gridLayout_5">
<property name="leftMargin">
<number>9</number>
<number>2</number>
</property>
<property name="topMargin">
<number>9</number>
<number>2</number>
</property>
<property name="rightMargin">
<number>9</number>
<number>2</number>
</property>
<property name="bottomMargin">
<number>9</number>
<number>2</number>
</property>
<property name="spacing">
<property name="horizontalSpacing">
<number>6</number>
</property>
<item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_11">
<item>
<spacer name="horizontalSpacer_16">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<item row="0" column="0">
<widget class="QTabWidget" name="controlTabWidget">
<property name="styleSheet">
<string notr="true">QTabBar::tab {
background: #0E1C4C;
color: white;
padding: 6px 12px;
border: none;
border-top: 1px solid #27376C;
height: 41;
}
QTabBar::tab:selected {
background: #0D1233;
color: white;
border: none;
}
/*QTabBar::tab:hover {
background: #141A45;
}*/
QTabWidget::pane {
border: none;
border-top: 1px solid #27376C;
background: #0D1233;
top: -1px;
}
</string>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
<property name="tabPosition">
<enum>QTabWidget::South</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>100</width>
<height>20</height>
</size>
<property name="tabShape">
<enum>QTabWidget::Rounded</enum>
</property>
</spacer>
</item>
<item>
<widget class="QDoubleSlider" name="FramerateSlider">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<property name="currentIndex">
<number>0</number>
</property>
<property name="elideMode">
<enum>Qt::ElideNone</enum>
</property>
<widget class="QWidget" name="rgbCameraWidget">
<property name="styleSheet">
<string notr="true">QGroupBox
{
border: 12px solid transparent;
color: #ACCDFF;
}
QPushButton
{
/*width: 172px;
height: 56px;*/
font: 19pt &quot;新宋体&quot;;
background-color: qlineargradient(
spread:pad,
x1:0.5, y1:0, x2:0.5, y2:1,
stop:0 #283D86,
stop:1 #0F1A40
);
color: white;
border: none;
padding: 8px 16px;
border-radius: 4px;
}
QPushButton:hover
{
background-color: qlineargradient(
spread:pad,
x1:0, y1:0, x2:1, y2:0,
stop:0 #3A4875,
stop:1 #5F6B91
);
}
/* 按下时的效果 */
QPushButton:pressed
{
background-color: qlineargradient(
spread:pad,
x1:0, y1:0, x2:1, y2:0,
stop:0 #1A254F,
stop:1 #3A466B
);
/* 可选:添加下压效果 */
padding-top: 9px;
padding-bottom: 7px;
}</string>
</property>
<attribute name="title">
<string>rgb相机</string>
</attribute>
</widget>
</widget>
</item>
</layout>
</item>
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_10">
<item>
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</widget>
</widget>
<widget class="QToolBar" name="toolBar">
<property name="minimumSize">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
<property name="windowTitle">
<string>toolBar</string>
</property>
<property name="styleSheet">
<string notr="true">QToolBar {
background: #040125;/*transparent*/
border: 1px solid #040125;
}</string>
</property>
<property name="movable">
<bool>false</bool>
</property>
<attribute name="toolBarArea">
<enum>LeftToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
</widget>
<widget class="QToolBar" name="toolBar_2">
<property name="minimumSize">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
<property name="windowTitle">
<string>toolBar_2</string>
</property>
<property name="styleSheet">
<string notr="true">QToolBar {
background: #040125;/*transparent*/
border: 1px solid #040125;
}</string>
</property>
<property name="movable">
<bool>false</bool>
</property>
<attribute name="toolBarArea">
<enum>RightToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
</widget>
<widget class="QToolBar" name="toolBar_3">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>100</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>帧率</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="framerate_lineEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(255, 255, 255);</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_12">
<item>
<widget class="QLabel" name="label_2">
<property name="maximumSize">
<size>
<width>100</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>积分时间</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="integratioin_time_lineEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(255, 255, 255);</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="3" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_13">
<item>
<spacer name="horizontalSpacer_17">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>100</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QDoubleSlider" name="IntegratioinTimeSlider">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
</layout>
</item>
<item row="4" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_14">
<item>
<widget class="QLabel" name="label_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>100</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>gain</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="gain_lineEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
<property name="windowTitle">
<string>toolBar_3</string>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(255, 255, 255);</string>
<string notr="true">QToolBar {
background: #040125;/*transparent*/
border: 1px solid #040125;
}</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="5" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_15">
<item>
<spacer name="horizontalSpacer_18">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<property name="movable">
<bool>false</bool>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>100</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QDoubleSlider" name="GainSlider">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
</layout>
</item>
<item row="6" column="0">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>123</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<attribute name="toolBarArea">
<enum>BottomToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
</widget>
<action name="action_exit">
<property name="text">
@ -900,6 +642,9 @@ QDockWidget::title {
</property>
</action>
<action name="mActionOneMotorScenario">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>室内1轴线性平台</string>
</property>
@ -929,7 +674,7 @@ QDockWidget::title {
<string>三脚架(旋转平台)</string>
</property>
</action>
<action name="action_9">
<action name="mActionOpenImg">
<property name="text">
<string>打开影像</string>
</property>
@ -939,7 +684,7 @@ QDockWidget::title {
<string>关闭影像</string>
</property>
</action>
<action name="action_11">
<action name="mSetting">
<property name="text">
<string>设置</string>
</property>
@ -949,7 +694,10 @@ QDockWidget::title {
<string>拼接</string>
</property>
</action>
<action name="action_3">
<action name="mActionPlantPhenotypeScenario">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>植物表型</string>
</property>
@ -967,18 +715,30 @@ QDockWidget::title {
<string>2 轴线性马达</string>
</property>
</action>
<action name="mActionPan">
<property name="text">
<string>漫游</string>
</property>
</action>
<action name="mActionSpectral">
<property name="text">
<string>光谱</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>
<customwidget>
<class>QDoubleSlider</class>
<extends>QSlider</extends>
<header>qdoubleslider.h</header>
<class>CustomDockWidgetBase</class>
<extends>QDockWidget</extends>
<header>customdockwidgetbase.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>ImagerPositionSimulation</class>
<extends>QGraphicsView</extends>
<header location="global">imagerpositionsimulation.h</header>
<class>CustomDockWidgetHideAbove</class>
<extends>QDockWidget</extends>
<header>CustomDockWidgetBase.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources>

View File

@ -14,16 +14,16 @@
<ProjectGuid>{E7886664-B69E-4781-BCBE-804574FB4033}</ProjectGuid>
<Keyword>QtVS_v304</Keyword>
<QtMsBuild Condition="'$(QtMsBuild)'=='' OR !Exists('$(QtMsBuild)\qt.targets')">$(MSBuildProjectDirectory)\QtMsBuild</QtMsBuild>
<WindowsTargetPlatformVersion>10.0.22000.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<PlatformToolset>v141</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<PlatformToolset>v141</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<UseOfMfc>false</UseOfMfc>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
@ -32,12 +32,12 @@
</ImportGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'" Label="QtSettings">
<QtInstall>5.13.2_msvc2017_64</QtInstall>
<QtModules>core;network;gui;widgets;serialport;websockets;charts</QtModules>
<QtModules>core;network;gui;svg;widgets;serialport;websockets;3dcore;3danimation;3dextras;3dinput;3dlogic;3drender;3dquick;charts</QtModules>
<QtBuildConfig>debug</QtBuildConfig>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'" Label="QtSettings">
<QtInstall>5.9_msvc2017_64</QtInstall>
<QtModules>core;network;gui;widgets;serialport;websockets;charts</QtModules>
<QtInstall>5.13.2_msvc2017_64</QtInstall>
<QtModules>core;network;gui;svg;widgets;serialport;websockets;3dcore;3danimation;3dextras;3dinput;3dlogic;3drender;3dquick;charts</QtModules>
<QtBuildConfig>release</QtBuildConfig>
</PropertyGroup>
<Target Name="QtMsBuildNotFound" BeforeTargets="CustomBuild;ClCompile" Condition="!Exists('$(QtMsBuild)\qt.targets') or !Exists('$(QtMsBuild)\qt.props')">
@ -55,16 +55,18 @@
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<IncludePath>D:\cpp_library\gdal2.2.3_vs2017\include;C:\Program Files\ResononAPI\include;D:\cpp_library\opencv3.4.11\opencv\build\include;D:\cpp_library\opencv3.4.11\opencv\build\include\opencv;D:\cpp_library\opencv3.4.11\opencv\build\include\opencv2;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL\SDKs\PCOMM\Include;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL\SDKs\PortControl;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL;D:\cpp_project_vs2022\HPPA\HPPA;D:\cpp_library\libconfig-1.7.3\lib;D:\cpp_project_vs2022\HPPA\vincecontrol;D:\cpp_library\vincecontrol_vs2017;C:\XIMEA\API\xiAPI;D:\cpp_project_vs2022\HPPA\IrisMultiMotorController\IrisMultiMotorController;D:\cpp_library\eigen-3.4-rc1;$(IncludePath)</IncludePath>
<LibraryPath>D:\cpp_library\opencv3.4.11\opencv\build\x64\vc15\lib;D:\cpp_library\gdal2.2.3_vs2017\lib;C:\Program Files\ResononAPI\lib64;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\x64\Debug;D:\cpp_library\libconfig-1.7.3\build\x64;D:\cpp_project_vs2022\HPPA\x64\Debug;C:\XIMEA\API\xiAPI;D:\cpp_project_vs2022\HPPA\IrisMultiMotorController\x64\Debug;$(LibraryPath)</LibraryPath>
<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>
<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>
<TargetName>Spectral Insight</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<IncludePath>D:\cpp_library\gdal2.2.3_vs2017\include;C:\Program Files\ResononAPI\include;D:\cpp_library\opencv3.4.11\opencv\build\include;D:\cpp_library\opencv3.4.11\opencv\build\include\opencv;D:\cpp_library\opencv3.4.11\opencv\build\include\opencv2;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL\SDKs\PCOMM\Include;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL\SDKs\PortControl;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL;D:\cpp_project_vs2022\HPPA\HPPA;D:\cpp_library\libconfig-1.7.3\lib;D:\cpp_project_vs2022\HPPA\vincecontrol;C:\XIMEA\API\xiAPI;D:\cpp_project_vs2022\HPPA\IrisMultiMotorController\IrisMultiMotorController;D:\cpp_library\eigen-3.4-rc1;$(IncludePath)</IncludePath>
<LibraryPath>D:\cpp_library\opencv3.4.11\opencv\build\x64\vc15\lib;D:\cpp_library\vincecontrol_vs2017_release;D:\cpp_library\gdal2.2.3_vs2017\lib;C:\Program Files\ResononAPI\lib64;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\x64\Release;D:\cpp_library\libconfig-1.7.3\build\x64;D:\cpp_project_vs2022\IrisMultiMotorController\x64\Release;C:\XIMEA\API\xiAPI;$(LibraryPath)</LibraryPath>
<TargetName>Spectral Insight</TargetName>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Link>
<AdditionalDependencies>opencv_world3411.lib;opencv_world3411d.lib;gdal_i.lib;resonon-basler.lib;AutoFocus_InspireLinearMotor_DLL.lib;libconfig++d.lib;vincecontrol.lib;resonon-allied.lib;xiapi64.lib;IrisMultiMotorController.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>opencv_world3411.lib;opencv_world3411d.lib;gdal_i.lib;resonon-basler.lib;AutoFocus_InspireLinearMotor_DLL.lib;libconfig++d.lib;vincecontrol.lib;resonon-allied.lib;xiapi64.lib;IrisMultiMotorController.lib;OrbbecSDK.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>D:\cpp_project_vs2022\HPPA\x64\Debug;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
<ClCompile>
@ -106,30 +108,62 @@
<ItemGroup>
<ClCompile Include="aboutWindow.cpp" />
<ClCompile Include="adjustTable.cpp" />
<ClCompile Include="AppSettings.cpp" />
<ClCompile Include="AspectRatioLabel.cpp" />
<ClCompile Include="CaptureCoordinator.cpp" />
<ClCompile Include="Carousel.cpp" />
<ClCompile Include="Corning410Imager.cpp" />
<ClCompile Include="CustomDockWidgetBase.cpp" />
<ClCompile Include="DepthCameraWindow.cpp" />
<ClCompile Include="FileNameLineEdit.cpp" />
<ClCompile Include="hppaConfigFile.cpp" />
<ClCompile Include="HyperImagerControl.cpp" />
<ClCompile Include="imageControl.cpp" />
<ClCompile Include="ImagerOperationBase.cpp" />
<ClCompile Include="imager_base.cpp" />
<ClCompile Include="irisximeaimager.cpp" />
<ClCompile Include="LayerTree.cpp" />
<ClCompile Include="LayerTreeGroupNode.cpp" />
<ClCompile Include="LayerTreeLayerNode.cpp" />
<ClCompile Include="LayerTreeModel.cpp" />
<ClCompile Include="LayerTreeNode.cpp" />
<ClCompile Include="LayerTreeView.cpp" />
<ClCompile Include="LayerTreeViewMenuProvider.cpp" />
<ClCompile Include="MapLayer.cpp" />
<ClCompile Include="MapLayerStore.cpp" />
<ClCompile Include="MapTool.cpp" />
<ClCompile Include="MapToolPan.cpp" />
<ClCompile Include="MapTools.cpp" />
<ClCompile Include="MapToolSpectral.cpp" />
<ClCompile Include="MotorWindowBase.cpp" />
<ClCompile Include="OneMotorControl.cpp" />
<ClCompile Include="path_tc.cpp" />
<ClCompile Include="PowerControl.cpp" />
<ClCompile Include="QDoubleSlider.cpp" />
<ClCompile Include="QMotorDoubleSlider.cpp" />
<ClCompile Include="RasterDataProvider.cpp" />
<ClCompile Include="RasterLayer.cpp" />
<ClCompile Include="RasterRenderer.cpp" />
<ClCompile Include="recordFrameCounter.cpp" />
<ClCompile Include="resononImager.cpp" />
<ClCompile Include="ResononNirImager.cpp" />
<ClCompile Include="RgbCameraOperation.cpp" />
<ClCompile Include="rgbCameraWindow.cpp" />
<ClCompile Include="RobotArmControl.cpp" />
<ClCompile Include="setWindow.cpp" />
<ClCompile Include="stdafx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="TabManager.cpp" />
<ClCompile Include="TwoMotorControl.cpp" />
<ClCompile Include="utility_tc.cpp" />
<ClCompile Include="View3D.cpp" />
<ClCompile Include="View3DModelManager.cpp" />
<QtRcc Include="HPPA.qrc" />
<QtUic Include="about.ui" />
<QtUic Include="adjustTable.ui" />
<QtUic Include="DepthCamera.ui" />
<QtUic Include="FocusDialog.ui" />
<QtUic Include="HPPA.ui" />
<QtMoc Include="HPPA.h" />
@ -143,12 +177,16 @@
<ClCompile Include="imagerSimulatioin.cpp" />
<ClCompile Include="ImageViewer.cpp" />
<ClCompile Include="main.cpp" />
<QtUic Include="hyperImagerControl.ui" />
<QtUic Include="imgControl.ui" />
<QtUic Include="oneMotorControl.ui" />
<QtUic Include="PathPlan.ui" />
<QtUic Include="PowerControl.ui" />
<QtUic Include="RadianceConversion.ui" />
<QtUic Include="ReflectanceConversion.ui" />
<QtUic Include="rgbCamera.ui" />
<QtUic Include="RobotArmControl.ui" />
<QtUic Include="set.ui" />
<QtUic Include="twoMotorControl.ui" />
</ItemGroup>
<ItemGroup>
@ -161,15 +199,46 @@
<QtMoc Include="image2display.h" />
</ItemGroup>
<ItemGroup>
<QtMoc Include="View3DModelManager.h" />
<QtMoc Include="View3D.h" />
<QtMoc Include="adjustTable.h" />
<QtMoc Include="PowerControl.h" />
<QtMoc Include="RobotArmControl.h" />
<QtMoc Include="Corning410Imager.h" />
<QtMoc Include="CaptureCoordinator.h" />
<QtMoc Include="CustomDockWidgetBase.h" />
<QtMoc Include="Carousel.h" />
<QtMoc Include="imageControl.h" />
<QtMoc Include="AspectRatioLabel.h" />
<QtMoc Include="HyperImagerControl.h" />
<ClInclude Include="AppSettings.h" />
<QtMoc Include="FileNameLineEdit.h" />
<QtMoc Include="DepthCameraWindow.h" />
<ClInclude Include="imager_base.h" />
<ClInclude Include="irisximeaimager.h" />
<QtMoc Include="OneMotorControl.h" />
<QtMoc Include="TwoMotorControl.h" />
<QtMoc Include="TabManager.h" />
<QtMoc Include="LayerTreeModel.h" />
<QtMoc Include="LayerTreeNode.h" />
<QtMoc Include="LayerTree.h" />
<QtMoc Include="LayerTreeGroupNode.h" />
<QtMoc Include="LayerTreeLayerNode.h" />
<QtMoc Include="MapLayer.h" />
<QtMoc Include="RasterLayer.h" />
<QtMoc Include="MapLayerStore.h" />
<ClInclude Include="LayerTreeView.h" />
<QtMoc Include="LayerTreeViewMenuProvider.h" />
<QtMoc Include="MapTool.h" />
<QtMoc Include="MapToolPan.h" />
<QtMoc Include="MapToolSpectral.h" />
<QtMoc Include="MapTools.h" />
<ClInclude Include="MotorWindowBase.h" />
<ClInclude Include="RasterDataProvider.h" />
<ClInclude Include="RasterRenderer.h" />
<QtMoc Include="recordFrameCounter.h" />
<QtMoc Include="setWindow.h" />
<QtMoc Include="rgbCameraWindow.h" />
<ClInclude Include="utility_tc.h" />
<QtMoc Include="aboutWindow.h" />
<ClInclude Include="hppaConfigFile.h" />
@ -195,7 +264,7 @@
<ResourceCompile Include="HPPA.rc" />
</ItemGroup>
<ItemGroup>
<Image Include="HPPA.ico" />
<Image Include="resources\icons\ico\Spectral_Insight_128.ico" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Condition="Exists('$(QtMsBuild)\qt.targets')">

View File

@ -21,15 +21,6 @@
<UniqueIdentifier>{639EADAA-A684-42e4-A9AD-28FC9BCB8F7C}</UniqueIdentifier>
<Extensions>ts</Extensions>
</Filter>
<Filter Include="Header Files\motor">
<UniqueIdentifier>{eadfac5f-f4f9-49e2-9f99-0849bf074cf8}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\motor">
<UniqueIdentifier>{4672856c-86fb-46e3-94ff-0a296dcc6111}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\focus">
<UniqueIdentifier>{f2bfb93e-9ef8-4fdd-a776-db93b81af553}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<QtRcc Include="HPPA.qrc">
@ -133,6 +124,99 @@
<ClCompile Include="TwoMotorControl.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="CustomDockWidgetBase.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Carousel.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="View3D.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="TabManager.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="View3DModelManager.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="LayerTreeNode.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="LayerTreeModel.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="LayerTree.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="LayerTreeGroupNode.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="LayerTreeLayerNode.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="MapLayer.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="RasterLayer.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="RasterDataProvider.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="RasterRenderer.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="MapLayerStore.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="LayerTreeView.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="LayerTreeViewMenuProvider.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="imageControl.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="MapTool.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="MapToolPan.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="MapToolSpectral.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="MapTools.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="AspectRatioLabel.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="HyperImagerControl.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="recordFrameCounter.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="setWindow.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="AppSettings.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="FileNameLineEdit.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="MotorWindowBase.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="rgbCameraWindow.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="DepthCameraWindow.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<QtMoc Include="fileOperation.h">
@ -192,6 +276,84 @@
<QtMoc Include="CaptureCoordinator.h">
<Filter>Header Files</Filter>
</QtMoc>
<QtMoc Include="CustomDockWidgetBase.h">
<Filter>Header Files</Filter>
</QtMoc>
<QtMoc Include="Carousel.h">
<Filter>Header Files</Filter>
</QtMoc>
<QtMoc Include="View3D.h">
<Filter>Header Files</Filter>
</QtMoc>
<QtMoc Include="TabManager.h">
<Filter>Header Files</Filter>
</QtMoc>
<QtMoc Include="View3DModelManager.h">
<Filter>Header Files</Filter>
</QtMoc>
<QtMoc Include="LayerTreeModel.h">
<Filter>Header Files</Filter>
</QtMoc>
<QtMoc Include="LayerTreeNode.h">
<Filter>Header Files</Filter>
</QtMoc>
<QtMoc Include="LayerTree.h">
<Filter>Header Files</Filter>
</QtMoc>
<QtMoc Include="LayerTreeGroupNode.h">
<Filter>Header Files</Filter>
</QtMoc>
<QtMoc Include="LayerTreeLayerNode.h">
<Filter>Header Files</Filter>
</QtMoc>
<QtMoc Include="MapLayer.h">
<Filter>Header Files</Filter>
</QtMoc>
<QtMoc Include="RasterLayer.h">
<Filter>Header Files</Filter>
</QtMoc>
<QtMoc Include="MapLayerStore.h">
<Filter>Header Files</Filter>
</QtMoc>
<QtMoc Include="LayerTreeViewMenuProvider.h">
<Filter>Header Files</Filter>
</QtMoc>
<QtMoc Include="imageControl.h">
<Filter>Header Files</Filter>
</QtMoc>
<QtMoc Include="MapToolSpectral.h">
<Filter>Header Files</Filter>
</QtMoc>
<QtMoc Include="MapToolPan.h">
<Filter>Header Files</Filter>
</QtMoc>
<QtMoc Include="MapTool.h">
<Filter>Header Files</Filter>
</QtMoc>
<QtMoc Include="MapTools.h">
<Filter>Header Files</Filter>
</QtMoc>
<QtMoc Include="AspectRatioLabel.h">
<Filter>Header Files</Filter>
</QtMoc>
<QtMoc Include="HyperImagerControl.h">
<Filter>Header Files</Filter>
</QtMoc>
<QtMoc Include="recordFrameCounter.h">
<Filter>Header Files</Filter>
</QtMoc>
<QtMoc Include="setWindow.h">
<Filter>Header Files</Filter>
</QtMoc>
<QtMoc Include="FileNameLineEdit.h">
<Filter>Header Files</Filter>
</QtMoc>
<QtMoc Include="rgbCameraWindow.h">
<Filter>Header Files</Filter>
</QtMoc>
<QtMoc Include="DepthCameraWindow.h">
<Filter>Header Files</Filter>
</QtMoc>
</ItemGroup>
<ItemGroup>
<ClInclude Include="imageProcessor.h">
@ -224,6 +386,21 @@
<ClInclude Include="irisximeaimager.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="RasterDataProvider.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="RasterRenderer.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="LayerTreeView.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="AppSettings.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="MotorWindowBase.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<QtUic Include="FocusDialog.ui">
@ -256,6 +433,21 @@
<QtUic Include="twoMotorControl.ui">
<Filter>Form Files</Filter>
</QtUic>
<QtUic Include="imgControl.ui">
<Filter>Form Files</Filter>
</QtUic>
<QtUic Include="hyperImagerControl.ui">
<Filter>Form Files</Filter>
</QtUic>
<QtUic Include="set.ui">
<Filter>Form Files</Filter>
</QtUic>
<QtUic Include="rgbCamera.ui">
<Filter>Form Files</Filter>
</QtUic>
<QtUic Include="DepthCamera.ui">
<Filter>Form Files</Filter>
</QtUic>
</ItemGroup>
<ItemGroup>
<None Include="cpp.hint" />
@ -266,7 +458,7 @@
</ResourceCompile>
</ItemGroup>
<ItemGroup>
<Image Include="HPPA.ico">
<Image Include="resources\icons\ico\Spectral_Insight_128.ico">
<Filter>Resource Files</Filter>
</Image>
</ItemGroup>

195
HPPA/HyperImagerControl.cpp Normal file
View File

@ -0,0 +1,195 @@
#include "HyperImagerControl.h"
HyperImagerControl::HyperImagerControl(QWidget* parent)
: QDialog(parent)
{
ui.setupUi(this);
connect(ui.framerate_spinBox, &QDoubleSpinBox::editingFinished, this, &HyperImagerControl::onFramerateSpinBoxEditingFinished);
connect(ui.FramerateSlider, &QDoubleSlider::valueChanged, this, &HyperImagerControl::onFramerateSliderChanged);
connect(ui.FramerateSlider, &QDoubleSlider::sliderReleased, this, &HyperImagerControl::onFramerateSliderReleased);
connect(ui.integratioin_time_spinBox, &QDoubleSpinBox::editingFinished, this, &HyperImagerControl::onIntegrationTimeSpinBoxEditingFinished);
connect(ui.IntegratioinTimeSlider, &QDoubleSlider::valueChanged, this, &HyperImagerControl::onIntegrationTimeSliderChanged);
connect(ui.IntegratioinTimeSlider, &QDoubleSlider::sliderReleased, this, &HyperImagerControl::onIntegrationTimeSliderReleased);
connect(ui.gain_spinBox, &QDoubleSpinBox::editingFinished, this, &HyperImagerControl::onGainSpinBoxEditingFinished);
connect(ui.GainSlider, &QSlider::valueChanged, this, &HyperImagerControl::onGainSliderChanged);
connect(ui.GainSlider, &QSlider::sliderReleased, this, &HyperImagerControl::onGainSliderReleased);
ui.GainSlider->setMaximum(12);
ui.GainSlider->setMinimum(0);
ui.gain_spinBox->setMaximum(12);
ui.gain_spinBox->setMinimum(0);
ui.widget_3->setStyleSheet(R"(
QDoubleSpinBox {
border: 1px solid #999;
border-radius: 4px;
padding: 2px 20px 2px 6px; /* 右侧留空间给按钮 */
background: #0e1c4c;
selection-background-color: #0078d7;
font-size: 12px;
color:#ACCDFF ;
}
QDoubleSpinBox::up-button {
subcontrol-origin: border;
subcontrol-position: top right;
width: 16px;
border-left: 1px solid #ccc;
}
QDoubleSpinBox::down-button {
subcontrol-origin: border;
subcontrol-position: bottom right;
width: 16px;
border-left: 1px solid #ccc;
}
QDoubleSpinBox::up-arrow {
image: url(:/svg/resources/icons/svg/arrow_up.svg);
width: 10px;
height: 10px;
}
QDoubleSpinBox::down-arrow {
image: url(:/svg/resources/icons/svg/arrow_down.svg);
width: 10px;
height: 10px;
}
QDoubleSpinBox::up-button:hover,
QDoubleSpinBox::down-button:hover {
background: #e6f2ff;
}
QDoubleSpinBox::up-button:pressed,
QDoubleSpinBox::down-button:pressed {
background: #cce4ff;
}
)");
}
HyperImagerControl::~HyperImagerControl()
{
}
void HyperImagerControl::setFrameRate(double frameRate)
{
ui.framerate_spinBox->setValue(frameRate);
ui.FramerateSlider->setValue(frameRate);
updateIntegrationTimeRange(frameRate);
}
void HyperImagerControl::setIntegrationTime(double integrationTime)
{
ui.integratioin_time_spinBox->setValue(integrationTime);
ui.IntegratioinTimeSlider->setValue(integrationTime);
updateFramerateRange(integrationTime);
}
void HyperImagerControl::setGain(double gain)
{
ui.gain_spinBox->setValue(gain);
ui.GainSlider->setValue(gain);
}
void HyperImagerControl::onFramerateSpinBoxEditingFinished()
{
double framerate = ui.framerate_spinBox->value();
ui.FramerateSlider->setValue(framerate);
emit framerateChanged(framerate);
}
void HyperImagerControl::onFramerateSliderChanged(double framerate)
{
ui.framerate_spinBox->blockSignals(true);
ui.framerate_spinBox->setValue(framerate);
ui.framerate_spinBox->blockSignals(false);
}
void HyperImagerControl::onFramerateSliderReleased()
{
double framerate = ui.framerate_spinBox->value();
emit framerateChanged(framerate);
}
void HyperImagerControl::onIntegrationTimeSpinBoxEditingFinished()
{
double integrationTime = ui.integratioin_time_spinBox->value();
ui.IntegratioinTimeSlider->setValue(integrationTime);
emit integrationTimeChanged(integrationTime);
}
void HyperImagerControl::onIntegrationTimeSliderChanged(double integrationTime)
{
ui.integratioin_time_spinBox->blockSignals(true);
ui.integratioin_time_spinBox->setValue(integrationTime);
ui.integratioin_time_spinBox->blockSignals(false);
}
void HyperImagerControl::onIntegrationTimeSliderReleased()
{
double integrationTime = ui.integratioin_time_spinBox->value();
emit integrationTimeChanged(integrationTime);
}
void HyperImagerControl::onGainSpinBoxEditingFinished()
{
double gain = ui.gain_spinBox->value();
ui.GainSlider->setValue(gain);
emit gainChanged(gain);
}
void HyperImagerControl::onGainSliderChanged(double gain)
{
ui.gain_spinBox->blockSignals(true);
ui.gain_spinBox->setValue(gain);
ui.gain_spinBox->blockSignals(false);
}
void HyperImagerControl::onGainSliderReleased()
{
double gain = ui.gain_spinBox->value();
emit gainChanged(gain);
}
void HyperImagerControl::updateIntegrationTimeRange(double frameRate)
{
double maxIntegrationTime = 1.0 / frameRate * 1000.0; // 毫秒
ui.IntegratioinTimeSlider->blockSignals(true);
ui.IntegratioinTimeSlider->setMaximum(maxIntegrationTime);
ui.IntegratioinTimeSlider->setMinimum(1);
ui.IntegratioinTimeSlider->blockSignals(false);
ui.integratioin_time_spinBox->blockSignals(true);
ui.integratioin_time_spinBox->setMaximum(maxIntegrationTime);
ui.integratioin_time_spinBox->setMinimum(1);
ui.integratioin_time_spinBox->blockSignals(false);
}
void HyperImagerControl::updateFramerateRange(double integrationTime)
{
double maxFramerate = 1.0 / (integrationTime / 1000.0); // 积分时间(毫秒)转帧率
if(maxFramerate > m_frameRateLimit)
{
maxFramerate = m_frameRateLimit;
}
ui.FramerateSlider->blockSignals(true);
ui.FramerateSlider->setMaximum(maxFramerate);
ui.FramerateSlider->setMinimum(1);
ui.FramerateSlider->blockSignals(false);
ui.framerate_spinBox->blockSignals(true);
ui.framerate_spinBox->setMaximum(maxFramerate);
ui.framerate_spinBox->setMinimum(1);
ui.framerate_spinBox->blockSignals(false);
}

47
HPPA/HyperImagerControl.h Normal file
View File

@ -0,0 +1,47 @@
#pragma once
#include <QDialog>
#include "ui_hyperImagerControl.h"
#include "AspectRatioLabel.h"
class QDoubleSlider;
class HyperImagerControl : public QDialog
{
Q_OBJECT
public:
HyperImagerControl(QWidget* parent = nullptr);
~HyperImagerControl();
AspectRatioLabel* imagerPictureLabel() const { return ui.imagerPictureLabel; }
void setFrameRate(double frameRate);
void setIntegrationTime(double integrationTime);
void setGain(double gain);
signals:
void framerateChanged(double framerate);
void integrationTimeChanged(double integrationTime);
void gainChanged(double gain);
private Q_SLOTS:
void onFramerateSpinBoxEditingFinished();
void onFramerateSliderChanged(double framerate);
void onFramerateSliderReleased();
void onIntegrationTimeSpinBoxEditingFinished();
void onIntegrationTimeSliderChanged(double integrationTime);
void onIntegrationTimeSliderReleased();
void onGainSpinBoxEditingFinished();
void onGainSliderChanged(double gain);
void onGainSliderReleased();
private:
void updateIntegrationTimeRange(double frameRate);
void updateFramerateRange(double integrationTime);
double m_frameRateLimit = 150;//相机的最大帧率限制为250fps
Ui::HyperImagerControl ui;
};

View File

@ -1,4 +1,4 @@
#include "stdafx.h"
#include "stdafx.h"
#include <iostream>
#include "ImageReaderWriter.h"
@ -11,11 +11,11 @@ ImageReaderWriter::ImageReaderWriter(const char * fileName)
m_poDataset = (GDALDataset *)GDALOpen(fileName, GA_ReadOnly);
if (m_poDataset == NULL)
{
std::cout << "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӱ<EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>" << std::endl;
std::cout << "打开影像失败!" << std::endl;
return;
}
//<EFBFBD><EFBFBD>ȡӰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
//获取影像信息
m_DataType = m_poDataset->GetRasterBand(1)->GetRasterDataType();
m_iBands = m_poDataset->GetRasterCount();
m_iXCount = m_poDataset->GetRasterXSize();
@ -47,11 +47,11 @@ float * ImageReaderWriter::ReadImage(int nXOff, int nYOff, int nXSize, int nYSiz
float *pDataBuffer = (float*)CPLMalloc(sizeof(float)*(1)*(1)*(m_iBands));
memset(pDataBuffer, 0, 1 * 1 * m_iBands * sizeof(float));
CPLErr status = m_poDataset->RasterIO(GF_Read, nXOff, nYOff, nXSize, nYSize, pDataBuffer, xBuff, yBuff, GDT_Float32, m_iBands, NULL, 0, 0, 0); //<EFBFBD>ȸߺ<EFBFBD><EFBFBD><EFBFBD>
CPLErr status = m_poDataset->RasterIO(GF_Read, nXOff, nYOff, nXSize, nYSize, pDataBuffer, xBuff, yBuff, GDT_Float32, m_iBands, NULL, 0, 0, 0); //先高后宽
if (status != CE_None)
{
std::cout << "<EFBFBD><EFBFBD>ȡӰ<EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>" << std::endl;
std::cout << "读取影像失败!" << std::endl;
return 0;
}

View File

@ -1,4 +1,4 @@
#ifndef IMAGE_READER_WRITER
#ifndef IMAGE_READER_WRITER
#define IMAGE_READER_WRITER
#include "stdafx.h"
#include "gdal_priv.h"

View File

@ -1,24 +1,26 @@
#include "stdafx.h"
#include "stdafx.h"
#include <iostream>
#include <cmath>
#include <QWheelEvent>
#include <QPoint>
#include "ImageViewer.h"
#include "RasterLayer.h"
#include "MapTool.h"
#define VIEW_CENTER viewport()->rect().center()
#define VIEW_WIDTH viewport()->rect().width()
#define VIEW_HEIGHT viewport()->rect().height()
ImageViewer::ImageViewer(QWidget* pParent) :QGraphicsView(pParent)
Mapcavas::Mapcavas(QWidget* pParent) :QGraphicsView(pParent)
{
setRenderHint(QPainter::Antialiasing);
setRenderHint(QPainter::SmoothPixmapTransform);
setDragMode(QGraphicsView::ScrollHandDrag);
// <20>ؼ<EFBFBD><D8BC><EFBFBD><E3A3BA>ʹ<EFBFBD><CAB9> Qt Ĭ<>ϵ<EFBFBD> anchor<6F><72><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Լ<EFBFBD><D4BC><EFBFBD><EFBFBD><EFBFBD>
// 使用 Qt 默认 anchor 行为以外的配置
setTransformationAnchor(QGraphicsView::NoAnchor);
setResizeAnchor(QGraphicsView::NoAnchor);
@ -43,24 +45,23 @@ ImageViewer::ImageViewer(QWidget* pParent) :QGraphicsView(pParent)
m_translateSpeed = 1.0;
m_bMouseTranslate = false;
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setFrameShape(QFrame::NoFrame);
}
ImageViewer::~ImageViewer()
Mapcavas::~Mapcavas()
{
}
void ImageViewer::DisplayFrameNumber(int frameNumber)
void Mapcavas::DisplayFrameNumber(int frameNumber)
{
m_framNumberLabel->setText(QString::number(frameNumber));
m_framNumberLabel->adjustSize();
}
void ImageViewer::SetImage(QPixmap *image)
void Mapcavas::SetImage(QPixmap *image)
{
if (!HasImage())
{
@ -73,7 +74,7 @@ void ImageViewer::SetImage(QPixmap *image)
ensureSceneVisible();
}
void ImageViewer::ensureSceneVisible()
void Mapcavas::ensureSceneVisible()
{
resetTransform();
@ -90,7 +91,7 @@ void ImageViewer::ensureSceneVisible()
centerOn(scene_rect.center());
}
bool ImageViewer::HasImage()
bool Mapcavas::HasImage()
{
if (m_GraphicsPixmapItemHandle == nullptr)
{
@ -102,38 +103,57 @@ bool ImageViewer::HasImage()
}
}
void ImageViewer::wheelEvent(QWheelEvent *event)
void Mapcavas::updateCrosshair(double sceneX, double sceneY)
{
//qDebug() << "---------------+++++++++++++++++++++++++++++++++++++++++++++++++++ ";
//if (true)//HasImage()
//{
// //Χ<><CEA7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŵ<EFBFBD><C5B4><EFBFBD>https://blog.csdn.net/GoForwardToStep/article/details/77035287?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-3.channel_param&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-3.channel_param
// // <20><>ȡ<EFBFBD><C8A1>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>view<65><77>λ<EFBFBD><CEBB>;
// QPointF cursorPoint = event->pos();
// // <20><>ȡ<EFBFBD><C8A1>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>scene<6E><65>λ<EFBFBD><CEBB>;
// QPointF scenePos = this->mapToScene(QPoint(cursorPoint.x(), cursorPoint.y()));
QPen pen(Qt::red, 2.0);
pen.setCosmetic(true); // constant screen-width regardless of zoom
// // <20><>ȡview<65>Ŀ<EFBFBD><C4BF><EFBFBD>;
// qreal viewWidth = this->viewport()->width();
// qreal viewHeight = this->viewport()->height();
if (!m_hLine)
{
m_hLine = m_qtGraphicsScene->addLine(0, 0, 0, 0, pen);
m_hLine->setZValue(1e9);
}
if (!m_vLine)
{
m_vLine = m_qtGraphicsScene->addLine(0, 0, 0, 0, pen);
m_vLine->setZValue(1e9);
}
// // <20><>ȡ<EFBFBD><C8A1>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><E0B5B1>view<65><77>С<EFBFBD>ĺ<EFBFBD><C4BA>ݱ<EFBFBD><DDB1><EFBFBD>;
// qreal hScale = cursorPoint.x() / viewWidth;
// qreal vScale = cursorPoint.y() / viewHeight;
m_hLine->setPen(pen);
m_vLine->setPen(pen);
m_hLine->setLine(sceneX - m_CrosshairHalfLen, sceneY,
sceneX + m_CrosshairHalfLen, sceneY);
m_vLine->setLine(sceneX, sceneY - m_CrosshairHalfLen,
sceneX, sceneY + m_CrosshairHalfLen);
}
void Mapcavas::removeCrosshair()
{
if (m_hLine)
{
if (m_hLine->scene())
m_hLine->scene()->removeItem(m_hLine);
delete m_hLine;
m_hLine = nullptr;
}
if (m_vLine)
{
if (m_vLine->scene())
m_vLine->scene()->removeItem(m_vLine);
delete m_vLine;
m_vLine = nullptr;
}
}
// // <20><><EFBFBD>ֵĹ<D6B5><C4B9><EFBFBD><EFBFBD><EFBFBD>
// QPoint scrollAmount = event->angleDelta();
// // <20><>ֵ<EFBFBD><D6B5>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>Զ<EFBFBD><D4B6>ʹ<EFBFBD><CAB9><EFBFBD>߷Ŵ<DFB7><C5B4><EFBFBD>ֵ<EFBFBD><D6B5>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С
// scrollAmount.y() > 0 ? zoomIn() : zoomOut();
// // <20><>scene<6E><65><EFBFBD><EFBFBD>ת<EFBFBD><D7AA>Ϊ<EFBFBD>Ŵ<EFBFBD><C5B4><EFBFBD>С<EFBFBD><D0A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
// QPointF viewPoint = this->matrix().map(scenePos);
// // ͨ<><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>view<65>Ŵ<EFBFBD><C5B4><EFBFBD>С<EFBFBD><D0A1><EFBFBD><EFBFBD>չʾscene<6E><65>λ<EFBFBD><CEBB>;
// horizontalScrollBar()->setValue(int(viewPoint.x() - viewWidth * hScale));
// verticalScrollBar()->setValue(int(viewPoint.y() - viewHeight * vScale));
//}
void Mapcavas::wheelEvent(QWheelEvent *event)
{
// Always let the tool have a chance first
if (m_mapTool)
{
m_mapTool->canvasWheelEvent(event);
}
if (HasImage())
{
@ -147,68 +167,71 @@ void ImageViewer::wheelEvent(QWheelEvent *event)
QPointF delta = newPos - oldPos;
translate(delta.x(), delta.y());
}
//QGraphicsView::wheelEvent(event);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
}
void ImageViewer::scaling(qreal scaleFactor)
void Mapcavas::scaling(qreal scaleFactor)
{
//qDebug() << this->sceneRect();
scale(scaleFactor, scaleFactor);
}
void ImageViewer::mousePressEvent(QMouseEvent *event)
void Mapcavas::mousePressEvent(QMouseEvent *event)
{
if (event->button()==Qt::LeftButton)
if (m_mapTool)
{
m_bMouseTranslate = true;
m_lastMousePos = event->pos();
//qDebug() << mapToScene(m_lastMousePos);
emit leftMouseButtonPressed(mapToScene(m_lastMousePos).x(), mapToScene(m_lastMousePos).y());
m_mapTool->canvasMousePressEvent(event);
QGraphicsView::mousePressEvent(event);
return;
}
//If you do not perform all the necessary work in your implementation of the virtual function, you may need to call the base class's implementation.
QGraphicsView::mousePressEvent(event);
}
void ImageViewer::mouseMoveEvent(QMouseEvent *event)
void Mapcavas::mouseMoveEvent(QMouseEvent *event)
{
if (m_bMouseTranslate){
QPointF mouseDelta = mapToScene(event->pos()) - mapToScene(m_lastMousePos);
translate(mouseDelta.x(),mouseDelta.y());
if (m_mapTool)
{
m_mapTool->canvasMouseMoveEvent(event);
QGraphicsView::mousePressEvent(event);
return;
}
m_lastMousePos = event->pos();
QGraphicsView::mousePressEvent(event);
}
void ImageViewer::mouseReleaseEvent(QMouseEvent *event)
void Mapcavas::mouseReleaseEvent(QMouseEvent *event)
{
m_bMouseTranslate = false;
if (m_mapTool)
{
m_mapTool->canvasMouseReleaseEvent(event);
QGraphicsView::mouseReleaseEvent(event);
return;
}
QGraphicsView::mouseReleaseEvent(event);
}
void ImageViewer::mouseDoubleClickEvent(QMouseEvent *event)
void Mapcavas::mouseDoubleClickEvent(QMouseEvent *event)
{
if (m_mapTool)
{
m_mapTool->canvasMouseDoubleClickEvent(event);
return;
}
QGraphicsView::mouseDoubleClickEvent(event);
}
void ImageViewer::zoomIn()
void Mapcavas::zoomIn()
{
zoom(1 + m_zoomDelta);
}
void ImageViewer::zoomOut()
void Mapcavas::zoomOut()
{
zoom(1 - m_zoomDelta);
}
void ImageViewer::zoom(float scaleFactor)
void Mapcavas::zoom(float scaleFactor)
{
// <20><>ֹ<EFBFBD><D6B9>С<EFBFBD><D0A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
qreal factor = transform().scale(scaleFactor, scaleFactor).mapRect(QRectF(0, 0, 1, 1)).width();
if (factor < 0.07 || factor > 100)
return;
@ -217,28 +240,99 @@ void ImageViewer::zoom(float scaleFactor)
m_scale *= scaleFactor;
}
void ImageViewer::setTranslateSpeed(qreal speed)
void Mapcavas::setTranslateSpeed(qreal speed)
{
// <20><><EFBFBD><EFBFBD><EFBFBD>ٶȷ<D9B6>Χ
Q_ASSERT_X(speed >= 0.0 && speed <= 2.0,
"InteractiveView::setTranslateSpeed", "Speed should be in range [0.0, 2.0].");
m_translateSpeed = speed;
}
qreal ImageViewer::translateSpeed() const
qreal Mapcavas::translateSpeed() const
{
return m_translateSpeed;
}
void ImageViewer::setZoomDelta(qreal delta)
void Mapcavas::setZoomDelta(qreal delta)
{
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Χ
Q_ASSERT_X(delta >= 0.0 && delta <= 1.0,
"InteractiveView::setZoomDelta", "Delta should be in range [0.0, 1.0].");
m_zoomDelta = delta;
}
qreal ImageViewer::zoomDelta() const
qreal Mapcavas::zoomDelta() const
{
return m_zoomDelta;
}
// new: set associated raster layer
void Mapcavas::setLayers(RasterLayer* layer)
{
m_rasterLayer = layer;
}
RasterLayer* Mapcavas::rasterLayer() const
{
return m_rasterLayer;
}
// new: refresh the map by rendering using the RasterLayer's render method
void Mapcavas::freshmap()
{
if (!m_rasterLayer) return;
RasterLayer::RenderParams params = m_rasterLayer->currentRenderParams();
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;
QPixmap pm = QPixmap::fromImage(img);
SetImage(&pm);
}
// MapTool management
void Mapcavas::setMapTool(MapTool* tool)
{
if (m_mapTool)
{
m_mapTool->deactivate();
}
m_mapTool = tool;
if (m_mapTool)
{
// Disable built-in drag mode so the tool controls everything
setDragMode(QGraphicsView::NoDrag);
m_mapTool->activate();
}
else
{
// Restore legacy drag mode when no tool
setDragMode(QGraphicsView::ScrollHandDrag);
}
}
void Mapcavas::unsetMapTool(MapTool* tool)
{
if (m_mapTool && m_mapTool == tool)
{
m_mapTool->deactivate();
m_mapTool = nullptr;
setDragMode(QGraphicsView::ScrollHandDrag);
}
}
MapTool* Mapcavas::mapTool() const
{
return m_mapTool;
}

View File

@ -1,15 +1,20 @@
#ifndef IMAGE_VIEWER
#define IMAGE_VIEWER
#ifndef MAPCAVAS_H
#define MAPCAVAS_H
#include "QGraphicsView"
#include "qlabel.h"
class ImageViewer :public QGraphicsView
#include <QVector>
#include "RasterLayer.h"
class MapTool;
class Mapcavas : public QGraphicsView
{
Q_OBJECT
public:
ImageViewer(QWidget* pParent = NULL);
~ImageViewer();
Mapcavas(QWidget* pParent = NULL);
~Mapcavas();
void DisplayFrameNumber(int frameNumber);
@ -24,35 +29,57 @@ public:
bool HasImage();
void ensureSceneVisible();
void updateCrosshair(double sceneX, double sceneY);
void removeCrosshair();
void wheelEvent(QWheelEvent *event) Q_DECL_OVERRIDE;
void scaling(qreal scaleFactor);
void zoomIn(); // <EFBFBD>Ŵ<EFBFBD>
void zoomOut(); // <EFBFBD><EFBFBD>С
void zoom(float scaleFactor); // <EFBFBD><EFBFBD><EFBFBD><EFBFBD> - scaleFactor<EFBFBD><EFBFBD><EFBFBD>ŵı<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
void zoomIn(); // 放大
void zoomOut(); // 缩小
void zoom(float scaleFactor); // 缩放 - scaleFactor缩放的比例因子
// ƽ<EFBFBD><EFBFBD><EFBFBD>ٶ<EFBFBD>
// 平移速度
void setTranslateSpeed(qreal speed);
qreal translateSpeed() const;
// <EFBFBD><EFBFBD><EFBFBD>ŵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// 缩放的增量
void setZoomDelta(qreal delta);
qreal zoomDelta() const;
// new: set raster layer and refresh map
void setLayers(RasterLayer* layer);
void freshmap();
void freshmap(const RasterLayer::RenderParams& params);
RasterLayer* rasterLayer() const;
// MapTool management
void setMapTool(MapTool* tool);
void unsetMapTool(MapTool* tool);
MapTool* mapTool() const;
protected:
QGraphicsScene *m_qtGraphicsScene;
private:
QGraphicsPixmapItem *m_GraphicsPixmapItemHandle;
QLabel *m_framNumberLabel;//<EFBFBD><EFBFBD>ʾʵʱ<EFBFBD>ɼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֡<EFBFBD><EFBFBD>
QLabel *m_framNumberLabel;//显示实时采集到的帧数
RasterLayer* m_rasterLayer = nullptr; // associated raster layer
MapTool* m_mapTool = nullptr; // current active map tool
qreal m_translateSpeed; // ƽ<EFBFBD><EFBFBD><EFBFBD>ٶ<EFBFBD>
qreal m_zoomDelta; // <EFBFBD><EFBFBD><EFBFBD>ŵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
bool m_bMouseTranslate; // ƽ<EFBFBD>Ʊ<EFBFBD>ʶ
QPoint m_lastMousePos; // <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD>λ<EFBFBD><EFBFBD>
qreal m_scale; // <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
qreal m_translateSpeed; // 平移速度
qreal m_zoomDelta; // 缩放的增量
bool m_bMouseTranslate; // 平移标识
QPoint m_lastMousePos; // 鼠标最后按下的位置
qreal m_scale; // 缩放值
double m_CrosshairHalfLen = 10.0;
QGraphicsLineItem* m_hLine = nullptr; // horizontal line
QGraphicsLineItem* m_vLine = nullptr; // vertical line
signals:
void leftMouseButtonPressed(int, int);
void leftMouseButtonPressed(int, int, QVector<double>, QVector<double>);
};
#endif

View File

@ -1,4 +1,5 @@
#include "ImagerOperationBase.h"
#include "ImagerOperationBase.h"
#include <QDir>
ImagerOperationBase::ImagerOperationBase()
{
@ -44,11 +45,11 @@ void ImagerOperationBase::connect_imager(int frameNumber)
double ImagerOperationBase::auto_exposure()
{
//<EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ع<EFBFBD>ʱ<EFBFBD><EFBFBD>Ϊ<EFBFBD>ڵ<EFBFBD>ǰ֡<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
double x = 1 / getFramerate() * 1000;//<EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ع<EFBFBD>ʱ<EFBFBD><EFBFBD>
//第一步:先设置曝光时间为在当前帧率情况下最大
double x = 1 / getFramerate() * 1000;//获取最大毫秒曝光时间
setIntegrationTime(x);
//<EFBFBD>ڶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><EFBFBD>ѭ<EFBFBD><EFBFBD>Ѱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ع<EFBFBD>ʱ<EFBFBD><EFBFBD>
//第二步:通过循环寻找最佳曝光时间
imagerStartCollect();
while (true)
@ -57,7 +58,7 @@ double ImagerOperationBase::auto_exposure()
if (GetMaxValue(buffer, m_FrameSize) >= 4094)
{
setIntegrationTime(getIntegrationTime() * 0.95);
std::cout << "<EFBFBD>Զ<EFBFBD><EFBFBD>ع<EFBFBD>-----------" << std::endl;
std::cout << "自动曝光-----------" << std::endl;
}
else
{
@ -67,7 +68,9 @@ double ImagerOperationBase::auto_exposure()
imagerStopCollect();
//std::cout << "<22>Զ<EFBFBD><D4B6>ع⣺" << getIntegrationTime() << std::endl;
emit autoExposureSignal();
//std::cout << "自动曝光:" << getIntegrationTime() << std::endl;
return getIntegrationTime();
}
@ -77,7 +80,7 @@ void ImagerOperationBase::focus()
m_iFocusFramesNumber = 0;
m_iFocusFrameCounter = 1;
//std::cout << "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>-----------" << std::endl;
//std::cout << "调焦-----------" << std::endl;
double tmpFrmerate = getFramerate();
double tmpIntegrationTime = getIntegrationTime();
@ -85,7 +88,7 @@ void ImagerOperationBase::focus()
setFramerate(5);
auto_exposure();
std::cout << "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD><EFBFBD>ع<EFBFBD>ʱ<EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>" << getIntegrationTime() << std::endl;
std::cout << "调焦获得的曝光时间为:" << getIntegrationTime() << std::endl;
int iWidth, iHeight;
GetFrameSize(iWidth, iHeight);
@ -97,7 +100,7 @@ void ImagerOperationBase::focus()
m_bFocusControlState = true;
while (m_bFocusControlState)
{
////<EFBFBD><EFBFBD>֡ƽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֡<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
////多帧平均,减弱单帧跳动
//memset((void*)buffer, 0, m_FrameSize * sizeof(unsigned short));
//int fn = 5;
//for (int i = 0; i < fn; i++)
@ -121,7 +124,7 @@ void ImagerOperationBase::focus()
double focusIndex = calcFocusIndexSobelPrivate(buffer);
emit FocusIndexSobelSignal(focusIndex);
std::cout << "focusIndex<EFBFBD><EFBFBD>" << focusIndex << std::endl;
std::cout << "focusIndex" << focusIndex << std::endl;
emit SpectralSignal(1);
@ -138,7 +141,7 @@ void ImagerOperationBase::focus()
void ImagerOperationBase::record_dark()
{
std::cout << "<EFBFBD>ɼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>" << std::endl;
std::cout << "采集暗电流!!!!!!!!!" << std::endl;
imagerStartCollect();
unsigned int* dark_tmp = new unsigned int[m_FrameSize];
@ -170,7 +173,7 @@ void ImagerOperationBase::record_dark()
void ImagerOperationBase::record_white()
{
std::cout << "<EFBFBD>ɼ<EFBFBD><EFBFBD>װ壡<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>" << std::endl;
std::cout << "采集白板!!!!!!!!!" << std::endl;
imagerStartCollect();
unsigned int* white_tmp = new unsigned int[m_FrameSize];
@ -195,7 +198,7 @@ void ImagerOperationBase::record_white()
imagerStopCollect();
//<EFBFBD>װ<EFBFBD><EFBFBD>۰<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//白板扣暗电流
if (m_HasDark)
{
for (size_t i = 0; i < m_FrameSize; i++)
@ -223,17 +226,23 @@ void ImagerOperationBase::start_record()
//std::cout << "------------------------------------------------------" << std::endl;
m_iFrameCounter = 0;
m_RgbImage->m_iFrameCounter = 0;//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>rgbͼ<EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD>0<EFBFBD><EFBFBD>
m_RgbImage->m_iFrameCounter = 0;//设置填充rgb图像的第0行
m_bRecordControlState = true;
//<EFBFBD>ж<EFBFBD><EFBFBD>ڴ<EFBFBD>buffer<EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//判断内存buffer是否正常分配
if (buffer == 0)
{
std::cerr << "Error: memory could not be allocated for datacube";
exit(EXIT_FAILURE);
}
// 在开始采集时仅发出文件信息UI 层自行创建 MapLayer 并管理生命周期
// prepare file name that will be used for saving
m_FileName2Save2 = m_FileName2Save + "_" + std::to_string(m_FileSavedCounter) + ".bil";
QString baseName = QString::fromStdString(getFileNameFromPath(m_FileName2Save2));
QString filePath = QString::fromStdString(m_FileName2Save2);
emit LayerFileCreated(baseName, filePath, m_FileSavedCounter);
FILE* m_fImage = fopen(m_FileName2Save2.c_str(), "w+b");
size_t x;
@ -242,6 +251,7 @@ void ImagerOperationBase::start_record()
string timesFile = removeFileExtension(m_FileName2Save2) + ".times";
FILE* hTimesFile = fopen(timesFile.c_str(), "w+");
imagerStartCollect();
while (m_bRecordControlState)
{
@ -249,8 +259,9 @@ void ImagerOperationBase::start_record()
getFrame(buffer);
long long timeOs = getNanosecondsSinceMidnight();
//qDebug() << "time ns-------------------: " << timeOs;
//<EFBFBD><EFBFBD>ȥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӦΪbuffer<EFBFBD><EFBFBD>dark<EFBFBD><EFBFBD><EFBFBD><EFBFBD>unsigned short<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ե<EFBFBD>dark>bufferʱ<EFBFBD><EFBFBD>buffer-dark=65535
//减去暗电流,应为bufferdark都是unsigned short,所以当dark>buffer时,buffer-dark=65535
if (m_HasDark)
{
for (size_t i = 0; i < m_FrameSize; i++)
@ -268,12 +279,12 @@ void ImagerOperationBase::start_record()
}
//ת<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//转反射率
if (m_HasWhite)
{
for (size_t i = 0; i < m_FrameSize; i++)
{
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>װ壩Ϊ0<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//处理除数白板为0的情况
if (white[i] != 0)
{
pixelValueTmp = buffer[i];
@ -289,17 +300,17 @@ void ImagerOperationBase::start_record()
}
x = fwrite(buffer, 2, m_FrameSize, m_fImage);
fprintf(hTimesFile, "%d\n", timeOs);
fprintf(hTimesFile, "%ll\n", timeOs);
//<EFBFBD><EFBFBD>rgb<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><EFBFBD>ڽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
//rgb波段提取出来,以便在界面中显示
m_RgbImage->FillRgbImage(buffer);//??????????????????????????????????????????????????????????????????????????????????????????????????????
//std::cout << "<EFBFBD><EFBFBD>" << m_iFrameCounter << "֡д<EFBFBD><EFBFBD>" << x << "<EFBFBD><EFBFBD>unsigned short<EFBFBD><EFBFBD>" << std::endl;
//std::cout << "" << m_iFrameCounter << "帧写了" << x << "unsigned short" << std::endl;
//ÿ<EFBFBD><EFBFBD>1s<EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>ν<EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD>λ<EFBFBD><EFBFBD><EFBFBD>
//每隔1s进行一次界面图形绘制
if (m_iFrameCounter % (int)getFramerate() == 0)
{
emit PlotSignal(m_FileSavedCounter, m_iFrameCounter);
emit PlotSignal(m_FileSavedCounter, m_iFrameCounter, filePath);
}
if (m_iFrameCounter >= m_iFrameNumber)
@ -310,12 +321,17 @@ void ImagerOperationBase::start_record()
}
imagerStopCollect();
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>λ<EFBFBD>ͼǰ<EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//在最后一次画图前需要进行一次拉伸
//m_RgbImage
emit PlotSignal(m_FileSavedCounter, -1);//<2F><>1<EFBFBD><31><EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD>ɺ<EFBFBD><C9BA><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>λ<EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD>Է<EFBFBD><D4B7>ɼ<EFBFBD>֡<EFBFBD><D6A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֡<EFBFBD>ʵı<CAB5><C4B1><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>ȫ<EFBFBD><C8AB>2<EFBFBD><32>ʹ<EFBFBD>û<EFBFBD>е<EFBFBD>۲ɼ<DBB2>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֹͣ<CDA3>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD>˲<EFBFBD>ʼ<E4BFAA>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD><E1B5BC><EFBFBD>ϴβɼ<CEB2><C9BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><C4B4>źŵ<C5BA><C5B5>õIJۺ<C4B2><DBBA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>˼<EFBFBD><CBBC>ݣ<EFBFBD>ע<EFBFBD>͵<EFBFBD>
emit PlotSignal(m_FileSavedCounter, -1, filePath);//采集完成后进行一次画图,以防采集帧数不是帧率的倍数时,画图不全
m_bRecordControlState = false;
WriteHdr();
// 发射 ImageFileSaved 信号,通知 UI 层把该文件加入图层管理器
// m_FileName2Save2 保存了本次写入的 .bil 文件名(例如 "tmp_image_0.bil"
emit ImageFileSaved(QString::fromStdString(m_FileName2Save2), m_FileSavedCounter);
m_FileSavedCounter++;
if (m_iFrameCounter >= m_iFrameNumber)
@ -344,6 +360,14 @@ void ImagerOperationBase::setFileName2Save(string FileName)
m_FileSavedCounter = 0;
}
void ImagerOperationBase::updateRecordingFileInfo(const QString& filePath, const QString& baseName, int frameNumber)
{
m_FileName2Save = (filePath + QDir::separator() + baseName).toStdString();
m_FileSavedCounter = 0;
setFrameNumber(frameNumber);
}
void ImagerOperationBase::setFocusControlState(bool FocusControlState)
{
m_bFocusControlState = FocusControlState;
@ -384,7 +408,7 @@ double ImagerOperationBase::calcFocusIndexSobelPrivate(void* pvData)
unsigned short* psData;
psData = (unsigned short*)pvData;
cv::Mat gray(iHeight, iWidth, CV_16UC1, psData);//<EFBFBD><EFBFBD><EFBFBD><EFBFBD>֤<EFBFBD><EFBFBD>gray.data<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݺ<EFBFBD>psDataһ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
cv::Mat gray(iHeight, iWidth, CV_16UC1, psData);//经验证,gray.data的数据和psData一样;
/*string rgbFilePathNoStrech = "E:\\hppa\\delete\\focusImg_";
string tmp1 = std::to_string(m_iFocusFramesNumber);
string tmp2 = ".png";*/
@ -394,7 +418,7 @@ double ImagerOperationBase::calcFocusIndexSobelPrivate(void* pvData)
//cv::imwrite(rgbFilePathNoStrech, gray);
m_iFocusFramesNumber++;
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˲<EFBFBD>
//进行滤波
//cv::Mat outputImage;
//cv::Size kernelSize(5, 5);
//double sigmaX = 1.5;
@ -404,7 +428,7 @@ double ImagerOperationBase::calcFocusIndexSobelPrivate(void* pvData)
cv::Mat gradX, gradY, absGradX, absGradY;
cv::Sobel(outputImage, gradX, CV_32F, 1, 0);//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ΪCV_16S<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>cv::magnitude<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
cv::Sobel(outputImage, gradX, CV_32F, 1, 0);//如果参数为CV_16S则函数cv::magnitude报错
cv::Sobel(outputImage, gradY, CV_32F, 0, 1);
cv::convertScaleAbs(gradX, absGradX);
cv::convertScaleAbs(gradY, absGradY);
@ -413,7 +437,7 @@ double ImagerOperationBase::calcFocusIndexSobelPrivate(void* pvData)
cv::Mat magnitude, direction;
cv::magnitude(gradX, gradY, magnitude);//
cv::phase(gradX, gradY, direction, true); // true<EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD>ؽǶȶ<EFBFBD><EFBFBD>ǻ<EFBFBD><EFBFBD><EFBFBD>
cv::phase(gradX, gradY, direction, true); // true表示返回角度而非弧度
return cv::mean(magnitude)[0];
@ -466,23 +490,23 @@ int ImagerOperationBase::getFocusFrameCounter() const
void ImagerOperationBase::set_buffer()
{
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//如果
if (buffer != nullptr)
{
std::cout << "<EFBFBD>ͷŶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD>" << std::endl;
std::cout << "释放堆上内存" << std::endl;
free(buffer);
}
m_FrameSize = getBandCount() * getSampleCount();
//std::cout << "m_FrameSize<EFBFBD><EFBFBD>СΪ" << m_FrameSize << std::endl;
//std::cout << "m_FrameSize大小为" << m_FrameSize << std::endl;
buffer = new unsigned short[m_FrameSize];
dark = new unsigned short[m_FrameSize];
white = new unsigned short[m_FrameSize];
std::cout << "buffer<EFBFBD>ڴ<EFBFBD><EFBFBD><EFBFBD>ַ" << buffer << std::endl;
std::cout << "dark<EFBFBD>ڴ<EFBFBD><EFBFBD><EFBFBD>ַ" << dark << std::endl;
std::cout << "white<EFBFBD>ڴ<EFBFBD><EFBFBD><EFBFBD>ַ" << white << std::endl;
std::cout << "buffer内存地址" << buffer << std::endl;
std::cout << "dark内存地址" << dark << std::endl;
std::cout << "white内存地址" << white << std::endl;
}
void ImagerOperationBase::WriteHdr()
@ -527,6 +551,6 @@ unsigned short ImagerOperationBase::GetMaxValue(unsigned short* dark, int number
max = dark[i];
}
}
//std::cout << "<EFBFBD><EFBFBD>֡<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵΪ" << max << std::endl;
//std::cout << "本帧最大值为" << max << std::endl;
return max;
}

View File

@ -1,4 +1,4 @@
#pragma once
#pragma once
#include <QObject>
#include <QString>
@ -9,6 +9,8 @@
#include "ImagerOperationBase.h"
#include "utility_tc.h"
class MapLayer; // forward declaration
class ImagerOperationBase :public QObject
{
Q_OBJECT
@ -47,7 +49,7 @@ public:
int getFrameCounter() const;
int getFocusFrameCounter() const;
unsigned short* buffer;//<EFBFBD><EFBFBD>ɼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>м<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD>д<EFBFBD>뵽Ӳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
unsigned short* buffer;//存储采集到的影像的中间变量,下一步写入到硬盘中
void set_buffer();
void setFileName2Save(string FileName);
@ -58,25 +60,25 @@ public:
protected:
CImage* m_RgbImage;//<EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD>rgbͼ<EFBFBD><EFBFBD>
bool m_bRecordControlState;//<EFBFBD>ɼ<EFBFBD>״̬<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD><EFBFBD>ֹͣ<EFBFBD>ɼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
int m_iFrameCounter;//<EFBFBD><EFBFBD>¼<EFBFBD>ɼ<EFBFBD><EFBFBD><EFBFBD>֡<EFBFBD><EFBFBD>
int m_iFocusFrameCounter;//<EFBFBD><EFBFBD>¼<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>ɼ<EFBFBD><EFBFBD><EFBFBD>֡<EFBFBD><EFBFBD>
int m_FrameSize;//<EFBFBD><EFBFBD>ʾһ֡<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><EFBFBD>ٸ<EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD>m_FrameSize = m_imager.get_band_count()*m_imager.get_sample_count();
int m_iFrameNumber;//<EFBFBD><EFBFBD>Ҫ<EFBFBD>ɼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֡<EFBFBD><EFBFBD>
CImage* m_RgbImage;//显示的rgb图像
bool m_bRecordControlState;//采集状态;可用于执行停止采集操作
int m_iFrameCounter;//记录采集的帧数
int m_iFocusFrameCounter;//记录调焦时采集的帧数
int m_FrameSize;//表示一帧代表有多少个数值:m_FrameSize = m_imager.get_band_count()*m_imager.get_sample_count();
int m_iFrameNumber;//需要采集的总帧数
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڸ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӱ<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
string m_FileName2Save;//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӱ<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>
//以下两个参数用于给保存的影像文件命名
string m_FileName2Save;//保存的影像文件名
string m_FileName2Save2;
int m_FileSavedCounter;//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˼<EFBFBD><EFBFBD><EFBFBD>Ӱ<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
int m_FileSavedCounter;//保存了几个影像文件
bool m_HasDark;//<EFBFBD><EFBFBD><EFBFBD>ɼ<EFBFBD><EFBFBD>˰<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֮<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊtrue
bool m_HasWhite;//<EFBFBD><EFBFBD><EFBFBD>ɼ<EFBFBD><EFBFBD>˰װ<EFBFBD>֮<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊtrue
bool m_HasDark;//当采集了暗电流之后,设置为true
bool m_HasWhite;//当采集了白板之后,设置为true
unsigned short* dark;//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
unsigned short* white;//<EFBFBD><EFBFBD>װ<EFBFBD>
unsigned short* dark;//存储暗电流
unsigned short* white;//存储白板
bool m_bFocusControlState;//<EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
bool m_bFocusControlState;//控制调焦结束
@ -90,7 +92,7 @@ private:
double calcFocusIndexSobelPrivate(void* pvData);
public slots:
virtual void connect_imager(int frameNumber);//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٻ<EFBFBD><EFBFBD><EFBFBD>
virtual void connect_imager(int frameNumber);//连接相机、开辟缓存
virtual double auto_exposure();
virtual void focus();
virtual void start_record();
@ -99,11 +101,14 @@ public slots:
virtual void record_white();
void getFocusIndexSobel();
void updateRecordingFileInfo(const QString& filePath, const QString& baseName, int frameNumber);
signals:
void PlotSignal(int, int);//<2F><><EFBFBD><EFBFBD>Ӱ<EFBFBD><D3B0><EFBFBD>źţ<C5BA><C5A3><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڼ<EFBFBD><DABC><EFBFBD>Ӱ<EFBFBD>񣻵ڶ<F1A3BBB5><DAB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD>֡<EFBFBD><D6A1><EFBFBD><EFBFBD>-1<><31><EFBFBD><EFBFBD><EFBFBD>˴βɼ<CEB2><C9BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>λ<EFBFBD><CEBB><EFBFBD>
void RecordFinishedSignal_WhenFrameNumberMeet();//<EFBFBD>ɼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>źţ<EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>ɼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֡<EFBFBD><EFBFBD><EFBFBD><EFBFBD>m_iFrameNumber<EFBFBD><EFBFBD><EFBFBD>ɼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
void RecordFinishedSignal_WhenFrameNumberNotMeet();//<EFBFBD>ɼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>źţ<EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>ɼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֡<EFBFBD><EFBFBD><EFBFBD><EFBFBD>m_iFrameNumber<EFBFBD><EFBFBD>û<EFBFBD>вɼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɣ<EFBFBD><EFBFBD><EFBFBD>;ֹͣ<EFBFBD>ɼ<EFBFBD>
void SpectralSignal(int);//<EFBFBD><EFBFBD><EFBFBD><EFBFBD>1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƹ<EFBFBD><EFBFBD>ף<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0<EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɣ<EFBFBD>
void PlotSignal(int, int, QString);//绘制影像信号,第一个参数:第几个影像;第二个参数:采集到的帧数,-1代表此次采集的最后一次绘制
void RecordFinishedSignal_WhenFrameNumberMeet();//采集完成信号:需要采集的总帧数(m_iFrameNumber)采集完成
void RecordFinishedSignal_WhenFrameNumberNotMeet();//采集完成信号需要采集的总帧数m_iFrameNumber没有采集完成中途停止采集
void SpectralSignal(int);//发射1代表正在调焦绘制光谱发射0表示调焦完成
void RecordWhiteFinishSignal();
void RecordDarlFinishSignal();
@ -111,5 +116,12 @@ signals:
void FocusIndexSobelSignal(double);
void testImagerStatus();//<EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD>Բ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬<EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
void testImagerStatus();//表示可以测试相机连接状态:是否连接,并反映到界面上
void autoExposureSignal();
// 新增:当一组影像文件(.bil/.hdr写入完成后发出会从采集线程发出Qt 会做 queued connection
void ImageFileSaved(const QString& path, int fileIndex);
// 修改:不再直接发送 MapLayer*而是发送文件名与文件路径UI 层负责创建 MapLayer 对象并管理生命周期
void LayerFileCreated(const QString& baseName, const QString& filePath, int fileIndex);
};

View File

@ -1,4 +1,4 @@
#include "stdafx.h"
#include "stdafx.h"
#include "ImagerPositionSimulation.h"
@ -61,7 +61,7 @@ void ImagerPositionSimulation::mouseReleaseEvent(QMouseEvent *event)
{
QPoint viewPos = event->pos();
////<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
////输出类型
//const type_info &x = typeid(imager);
//qDebug() << "---------------type_info: " << x.name() << x.raw_name() << x.hash_code();

View File

@ -1,4 +1,4 @@
#ifndef IMAGER_POSITION_SIMULATION
#ifndef IMAGER_POSITION_SIMULATION
#define IMAGER_POSITION_SIMULATION
#include <QGraphicsView>
#include <QGraphicsScene>
@ -16,7 +16,7 @@ public:
void drawX();
void setSceneRect();//<EFBFBD><EFBFBD>QGraphicsView<EFBFBD><EFBFBD>viewport<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ΪsceneRect
void setSceneRect();//QGraphicsViewviewport设置为sceneRect
QRectF sceneRect();

47
HPPA/LayerTree.cpp Normal file
View File

@ -0,0 +1,47 @@
#include "LayerTree.h"
LayerTree::LayerTree(QObject* parent)
: LayerTreeGroup("__root__", parent)
{
setVisible(Qt::Checked);
}
LayerTree::~LayerTree()
{
}
void LayerTree::setChildrenVisible(LayerTreeNode* n, Qt::CheckState state)
{
if (!n) return;
const auto& cs = n->children();
for (LayerTreeNode* c : cs) {
c->setVisible(state);
setChildrenVisible(c, state);
}
}
void LayerTree::updateParentVisibleFromChildren(LayerTreeNode* p)
{
if (!p) return;
if (p->childCount() == 0) return;
int checked = 0, unchecked = 0, partial = 0;
const auto& cs = p->children();
for (LayerTreeNode* c : cs) {
auto s = c->visible();
if (s == Qt::Checked) checked++;
else if (s == Qt::Unchecked) unchecked++;
else partial++;
}
Qt::CheckState newState;
if (partial > 0) newState = Qt::PartiallyChecked;
else if (checked > 0 && unchecked == 0) newState = Qt::Checked;
else if (unchecked > 0 && checked == 0) newState = Qt::Unchecked;
else newState = Qt::PartiallyChecked;
if (p->visible() != newState) {
p->setVisible(newState);
updateParentVisibleFromChildren(p->parentNode());
}
}

26
HPPA/LayerTree.h Normal file
View File

@ -0,0 +1,26 @@
#pragma once
#include "LayerTreeGroupNode.h"
/**
* LayerTree图层树根节点
* - 继承自 LayerTreeGroup本身就是树的根节点
* - 提供可见性级联与父节点三态更新的静态工具
*
* 注意beginInsertRows/endInsertRows 等 Qt Model 变更通知应由 Model 驱动调用,
* LayerTree 只负责维护数据结构正确性。
*/
class LayerTree : public LayerTreeGroup
{
Q_OBJECT
public:
explicit LayerTree(QObject* parent = nullptr);
~LayerTree() override;
LayerTree(const LayerTree&) = delete;
LayerTree& operator=(const LayerTree&) = delete;
// 可见性逻辑(供 Model 调用)
static void setChildrenVisible(LayerTreeNode* n, Qt::CheckState state);
static void updateParentVisibleFromChildren(LayerTreeNode* parent);
};

103
HPPA/LayerTreeGroupNode.cpp Normal file
View File

@ -0,0 +1,103 @@
#include "LayerTreeGroupNode.h"
#include "LayerTreeLayerNode.h"
LayerTreeGroup::LayerTreeGroup(const QString& name, QObject* parent)
: LayerTreeNode(name, parent)
{
}
LayerTreeGroup* LayerTreeGroup::insertGroup(int index, const QString& name)
{
auto* group = new LayerTreeGroup(name);
insertChildNode(index, group);
return group;
}
LayerTreeGroup* LayerTreeGroup::addGroup(const QString& name)
{
return insertGroup(childCount(), name);
}
LayerTreeLayer* LayerTreeGroup::insertLayer(int index, LayerTreeLayer* layer)
{
if (!layer) return nullptr;
insertChildNode(index, layer);
return layer;
}
LayerTreeLayer* LayerTreeGroup::addLayer(LayerTreeLayer* layer)
{
return insertLayer(childCount(), layer);
}
void LayerTreeGroup::insertChildNode(int index, LayerTreeNode* node)
{
insertChild(index, node);
}
void LayerTreeGroup::addChildNode(LayerTreeNode* node)
{
appendChild(node);
}
LayerTreeNode* LayerTreeGroup::removeChildNode(LayerTreeNode* node)
{
if (!node) return nullptr;
int row = -1;
for (int i = 0; i < childCount(); ++i)
{
if (childAt(i) == node)
{
row = i;
break;
}
}
if (row < 0) return nullptr;
removeChild(row, 1, false);
return node;
}
LayerTreeLayer* LayerTreeGroup::findLayer(const QString& name) const
{
const auto layers = findLayers();
for (auto* l : layers)
{
if (l->name() == name)
return l;
}
return nullptr;
}
QList<LayerTreeLayer*> LayerTreeGroup::findLayers() const
{
QList<LayerTreeLayer*> result;
for (int i = 0; i < childCount(); ++i)
{
LayerTreeNode* child = childAt(i);
if (LayerTreeNode::isLayer(child))
{
result.append(static_cast<LayerTreeLayer*>(child));
}
else if (LayerTreeNode::isGroup(child))
{
result.append(static_cast<LayerTreeGroup*>(child)->findLayers());
}
}
return result;
}
QList<LayerTreeGroup*> LayerTreeGroup::findGroups() const
{
QList<LayerTreeGroup*> result;
for (int i = 0; i < childCount(); ++i)
{
LayerTreeNode* child = childAt(i);
if (LayerTreeNode::isGroup(child))
{
auto* g = static_cast<LayerTreeGroup*>(child);
result.append(g);
result.append(g->findGroups());
}
}
return result;
}

44
HPPA/LayerTreeGroupNode.h Normal file
View File

@ -0,0 +1,44 @@
#pragma once
#include "LayerTreeNode.h"
class LayerTreeLayer;
/**
* LayerTreeGroup图层组节点
* - 基类为 LayerTreeNode
* - 提供插入图层节点LayerTreeLayer或图层组LayerTreeGroup的便利方法
*/
class LayerTreeGroup : public LayerTreeNode
{
Q_OBJECT
public:
explicit LayerTreeGroup(const QString& name = QString(),
QObject* parent = nullptr);
Type type() const override { return Type::Group; }
// 便利方法:插入子组
LayerTreeGroup* insertGroup(int index, const QString& name);
LayerTreeGroup* addGroup(const QString& name);
// 便利方法:插入图层节点
LayerTreeLayer* insertLayer(int index, LayerTreeLayer* layer);
LayerTreeLayer* addLayer(LayerTreeLayer* layer);
// 插入任意节点
void insertChildNode(int index, LayerTreeNode* node);
void addChildNode(LayerTreeNode* node);
// 移除子节点(不 delete返回被移除节点
LayerTreeNode* removeChildNode(LayerTreeNode* node);
// 查找
LayerTreeLayer* findLayer(const QString& name) const;
QList<LayerTreeLayer*> findLayers() const;
QList<LayerTreeGroup*> findGroups() const;
// 以后可扩展collapsed / groupOpacity 等
};
// 保持向后兼容
using LayerTreeGroupNode = LayerTreeGroup;

View File

@ -0,0 +1,22 @@
#include "LayerTreeLayerNode.h"
LayerTreeLayer::LayerTreeLayer(MapLayer* layer, QObject* parent)
: LayerTreeNode(layer ? layer->name() : QString(), parent), m_layer(layer)
{
}
LayerTreeNode::Type LayerTreeLayer::type() const
{
return Type::Layer;
}
// 持有一个 MapLayer 指针(不拥有)
void LayerTreeLayer::setMapLayer(MapLayer* layer)
{
m_layer = layer;
}
MapLayer* LayerTreeLayer::mapLayer() const
{
return m_layer;
}

28
HPPA/LayerTreeLayerNode.h Normal file
View File

@ -0,0 +1,28 @@
#pragma once
#include "LayerTreeNode.h"
#include "MapLayer.h"
/**
* LayerTreeLayer图层节点
* - 基类为 LayerTreeNode
* - 持有一个 MapLayer 指针(不拥有)
*/
class LayerTreeLayer : public LayerTreeNode
{
Q_OBJECT
public:
explicit LayerTreeLayer(MapLayer* layer, QObject* parent = nullptr);
Type type() const override;
void setMapLayer(MapLayer* layer);
MapLayer* mapLayer() const;
private:
MapLayer* m_layer = nullptr;
// 可扩展layerId / pointer / legendItems 等
};
// 保持向后兼容
using LayerTreeLayerNode = LayerTreeLayer;

183
HPPA/LayerTreeModel.cpp Normal file
View File

@ -0,0 +1,183 @@
#include "LayerTreeModel.h"
#include "LayerTreeGroupNode.h"
#include "LayerTreeLayerNode.h"
#include <QtGlobal>
LayerTreeModel::LayerTreeModel(LayerTree* tree, QObject* parent, bool cascadeCheck)
: QAbstractItemModel(parent),
m_tree(tree),
m_cascadeCheck(cascadeCheck)
{
Q_ASSERT(m_tree && "LayerTreeModel requires a valid LayerTree*");
}
QModelIndex LayerTreeModel::index(int row, int column, const QModelIndex& parent) const
{
if (column != 0 || row < 0) return {};
LayerTreeNode* parentNode = nodeFromIndex(parent);
if (!parentNode) return {};
LayerTreeNode* child = parentNode->childAt(row);
if (!child) return {};
return createIndex(row, column, child);
}
QModelIndex LayerTreeModel::parent(const QModelIndex& child) const
{
LayerTreeNode* node = nodeFromIndex(child);
if (!node || node == m_tree) return {};
LayerTreeNode* p = node->parentNode();
if (!p || p == m_tree) return {};
return createIndex(p->rowInParent(), 0, p);
}
int LayerTreeModel::rowCount(const QModelIndex& parent) const
{
LayerTreeNode* p = nodeFromIndex(parent);
return p ? p->childCount() : 0;
}
int LayerTreeModel::columnCount(const QModelIndex&) const
{
return 1;
}
QVariant LayerTreeModel::data(const QModelIndex& index, int role) const
{
LayerTreeNode* n = nodeFromIndex(index);
if (!n || n == m_tree) return {};
switch (role) {
case Qt::DisplayRole:
return n->name();
case Qt::DecorationRole:
{
auto* tmp = nodeFromIndex(index);
if (LayerTreeNode::isGroup(tmp))
return QIcon();
else if (LayerTreeNode::isLayer(tmp))
{
QString basePath = QCoreApplication::applicationDirPath();
return QIcon(":/svg/resources/icons/svg/mIconRaster.svg");
}
}
//case Qt::CheckStateRole:
// return static_cast<int>(n->visible());
case Qt::ToolTipRole:
return (n->type() == LayerTreeNode::Type::Group) ? "Group" : "Layer";
default:
return {};
}
}
bool LayerTreeModel::setData(const QModelIndex& index, const QVariant& value, int role)
{
LayerTreeNode* n = nodeFromIndex(index);
if (!n || n == m_tree) return false;
if (role == Qt::CheckStateRole) {
auto newState = static_cast<Qt::CheckState>(value.toInt());
if (n->visible() == newState) return true;
n->setVisible(newState);
// 1) 父 -> 子 级联
if (m_cascadeCheck) {
LayerTree::setChildrenVisible(n, newState);
}
// 2) 子 -> 父 更新 PartiallyChecked
LayerTree::updateParentVisibleFromChildren(n->parentNode());
// 简化:整体刷新(你后续可替换为精准 dataChanged
emit layoutChanged();
return true;
}
return false;
}
Qt::ItemFlags LayerTreeModel::flags(const QModelIndex& index) const
{
if (!index.isValid()) return Qt::NoItemFlags;
LayerTreeNode* n = nodeFromIndex(index);
if (!n || n == m_tree) return Qt::NoItemFlags;
return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable;
}
LayerTreeNode* LayerTreeModel::root() const
{
return m_tree;
}
LayerTreeNode* LayerTreeModel::addGroup(LayerTreeNode* parent, const QString& name, const QIcon& icon)
{
if (!parent) parent = m_tree;
const int row = parent->childCount();
beginInsertRows(indexFromNode(parent), row, row);
LayerTreeNode* g = m_tree->addGroup(name);
endInsertRows();
return g;
}
LayerTreeNode* LayerTreeModel::addLayer(LayerTreeNode* parent, LayerTreeLayer* layerNode, const QIcon& icon)
{
if (!parent) parent = m_tree;
if (!layerNode) return nullptr;
const int row = parent->childCount();
beginInsertRows(indexFromNode(parent), row, row);
parent->insertChild(row, layerNode);
endInsertRows();
return layerNode;
}
void LayerTreeModel::setCascadeCheckEnabled(bool enabled)
{
m_cascadeCheck = enabled;
}
bool LayerTreeModel::cascadeCheckEnabled() const
{
return m_cascadeCheck;
}
// 新增实现:移除子节点并在 model 上发出 begin/endRemoveRows
LayerTreeNode* LayerTreeModel::removeNode(LayerTreeNode* parent, int row)
{
if (!parent) parent = m_tree;
if (row < 0 || row >= parent->childCount()) return nullptr;
LayerTreeNode* removed = parent->childAt(row);
beginRemoveRows(indexFromNode(parent), row, row);
parent->removeChild(row, 1, false);
endRemoveRows();
return removed;
}
LayerTreeNode* LayerTreeModel::nodeFromIndex(const QModelIndex& index) const
{
if (!index.isValid()) return m_tree;
return static_cast<LayerTreeNode*>(index.internalPointer());
}
QModelIndex LayerTreeModel::indexFromNode(LayerTreeNode* n) const
{
if (!n || n == m_tree) return {};
return createIndex(n->rowInParent(), 0, n);
}

52
HPPA/LayerTreeModel.h Normal file
View File

@ -0,0 +1,52 @@
#pragma once
#include <QCoreApplication>
#include <QAbstractItemModel>
#include "LayerTree.h"
class LayerTreeLayer; // forward declare
/**
* LayerTreeModelQt 适配层(不再管理树)
* - 1 列:名称(带图标)+ checkbox
* - 勾选可见性(可选级联勾选)
*/
class LayerTreeModel : public QAbstractItemModel
{
Q_OBJECT
public:
explicit LayerTreeModel(LayerTree* tree,
QObject* parent = nullptr,
bool cascadeCheck = true);
~LayerTreeModel() override = default;
// QAbstractItemModel 必须接口
QModelIndex index(int row, int column,
const QModelIndex& parent = QModelIndex()) const override;
QModelIndex parent(const QModelIndex& child) const override;
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
int columnCount(const QModelIndex& parent = QModelIndex()) const override;
QVariant data(const QModelIndex& index, int role) const override;
bool setData(const QModelIndex& index, const QVariant& value, int role) override;
Qt::ItemFlags flags(const QModelIndex& index) const override;
// 对外 API构建树内部会正确调用 begin/endInsertRows
LayerTreeNode* root() const;
LayerTreeNode* addGroup(LayerTreeNode* parent, const QString& name, const QIcon& icon = QIcon());
LayerTreeNode* addLayer(LayerTreeNode* parent, LayerTreeLayer* layerNode, const QIcon& icon = QIcon());
void setCascadeCheckEnabled(bool enabled);
bool cascadeCheckEnabled() const;
// 新增:从父节点移除子节点(包装 LayerTree::removeNode 并发出 model 通知)
LayerTreeNode* removeNode(LayerTreeNode* parent, int row);
private:
LayerTree* m_tree = nullptr; // not owned
bool m_cascadeCheck = true;
private:
LayerTreeNode* nodeFromIndex(const QModelIndex& index) const;
QModelIndex indexFromNode(LayerTreeNode* n) const;
};

135
HPPA/LayerTreeNode.cpp Normal file
View File

@ -0,0 +1,135 @@
#include "LayerTreeNode.h"
#include <QtGlobal>
LayerTreeNode::LayerTreeNode(const QString& name, QObject* parent)
: QObject(parent), m_name(name)
{
}
LayerTreeNode::~LayerTreeNode()
{
qDeleteAll(m_children);
m_children.clear();
}
QString LayerTreeNode::name() const
{
return m_name;
}
void LayerTreeNode::setName(const QString& name)
{
if (m_name != name)
{
m_name = name;
emit nameChanged(this, name);
}
}
QIcon LayerTreeNode::icon() const
{
return m_icon;
}
void LayerTreeNode::setIcon(const QIcon& icon)
{
m_icon = icon;
}
Qt::CheckState LayerTreeNode::visible() const
{
return m_visible;
}
void LayerTreeNode::setVisible(Qt::CheckState s)
{
m_visible = s;
}
LayerTreeNode* LayerTreeNode::parentNode() const
{
return m_parentNode;
}
void LayerTreeNode::setParentNode(LayerTreeNode* p)
{
m_parentNode = p;
// 让 QObject 的 parent 也跟随(便于 Qt 对象层次管理,且不会影响我们手动 delete children
if (p) this->setParent(p);
else this->setParent(nullptr);
}
int LayerTreeNode::rowInParent() const
{
if (!m_parentNode) return 0;
const auto& siblings = m_parentNode->m_children;
for (int i = 0; i < siblings.size(); ++i)
{
if (siblings[i] == this) return i;
}
return 0;
}
int LayerTreeNode::childCount() const
{
return m_children.size();
}
LayerTreeNode* LayerTreeNode::childAt(int row) const
{
if (row < 0 || row >= m_children.size()) return nullptr;
return m_children[row];
}
const QVector<LayerTreeNode*>& LayerTreeNode::children() const
{
return m_children;
}
void LayerTreeNode::appendChild(LayerTreeNode* child)
{
insertChild(m_children.size(), child);
}
void LayerTreeNode::insertChild(int row, LayerTreeNode* child)
{
if (!child) return;
if (row < 0 || row > m_children.size())
row = m_children.size();
emit willAddChildren(this, row, row);
child->setParentNode(this);
m_children.insert(row, child);
emit addedChildren(this, row, row);
}
void LayerTreeNode::removeChild(int from, int count, bool destroy)
{
if (from < 0 || count <= 0 || from + count > m_children.size()) return;
emit willRemoveChildren(this, from, from + count - 1);
QVector<LayerTreeNode*> removed;
removed.reserve(count);
for (int i = 0; i < count; ++i)
{
removed.append(m_children.at(from));
m_children.removeAt(from);
}
for (LayerTreeNode* node : removed)
{
node->setParentNode(nullptr);
}
emit removedChildren(this, from, from + count - 1);
if (destroy)
{
qDeleteAll(removed);
}
}

91
HPPA/LayerTreeNode.h Normal file
View File

@ -0,0 +1,91 @@
#pragma once
#include <QObject>
#include <QVector>
#include <QIcon>
#include <QString>
/**
* LayerTreeNode节点基类抽象
* - 仅包含通用属性:名称/图标/可见性/父子关系
* - Group / Layer 节点通过继承实现
* - 提供插入/删除节点的信号通知
*
* 说明:
* - 这里同时维护"树父指针"m_parentNode与 QObject parent可选
* - children 由节点自己持有并负责释放(析构时 delete children
*/
class LayerTreeNode : public QObject
{
Q_OBJECT
public:
enum class Type { Group, Layer };
explicit LayerTreeNode(const QString& name,
QObject* parent = nullptr);
~LayerTreeNode() override;
LayerTreeNode(const LayerTreeNode&) = delete;
LayerTreeNode& operator=(const LayerTreeNode&) = delete;
virtual Type type() const = 0;
// ---- properties ----
QString name() const;
void setName(const QString& name);
QIcon icon() const;
void setIcon(const QIcon& icon);
Qt::CheckState visible() const;
void setVisible(Qt::CheckState s);
// ---- tree relations ----
LayerTreeNode* parentNode() const;
int rowInParent() const;
int childCount() const;
LayerTreeNode* childAt(int row) const;
const QVector<LayerTreeNode*>& children() const;
// ---- structure mutation (used by LayerTree / Model) ----
void appendChild(LayerTreeNode* child);
void insertChild(int row, LayerTreeNode* child);
// 基于 QgsLayerTreeNode::removeChildrenPrivate 改进
// from: 起始索引, count: 移除数量, destroy: true 则 delete 被移除节点
void removeChild(int from, int count, bool destroy = true);
// ---- static type helpers ----
static inline bool isLayer(LayerTreeNode* node)
{
return node && node->type() == LayerTreeNode::Type::Layer;
}
static inline bool isGroup(LayerTreeNode* node)
{
return node && node->type() == LayerTreeNode::Type::Group;
}
signals:
// 在插入子节点之前/之后发出
void willAddChildren(LayerTreeNode* node, int indexFrom, int indexTo);
void addedChildren(LayerTreeNode* node, int indexFrom, int indexTo);
// 在移除子节点之前/之后发出
void willRemoveChildren(LayerTreeNode* node, int indexFrom, int indexTo);
void removedChildren(LayerTreeNode* node, int indexFrom, int indexTo);
void nameChanged(LayerTreeNode* node, const QString& name);
protected:
void setParentNode(LayerTreeNode* p);
private:
QString m_name;
QIcon m_icon;
Qt::CheckState m_visible = Qt::Checked;
LayerTreeNode* m_parentNode = nullptr;
QVector<LayerTreeNode*> m_children;
};

52
HPPA/LayerTreeView.cpp Normal file
View File

@ -0,0 +1,52 @@
#include "LayerTreeView.h"
#include "LayerTreeViewMenuProvider.h"
#include <QContextMenuEvent>
#include <QMenu>
LayerTreeView::LayerTreeView(QWidget* parent)
: QTreeView(parent), m_menuProvider(nullptr)
{
}
LayerTreeView::~LayerTreeView()
{
delete m_menuProvider;
}
void LayerTreeView::setMenuProvider(LayerTreeViewMenuProvider* provider)
{
m_menuProvider = provider;
}
void LayerTreeView::contextMenuEvent(QContextMenuEvent* event)
{
if (!m_menuProvider)
return;
const QModelIndex idx = indexAt(event->pos());
if (idx.isValid())
setCurrentIndex(idx);
else
setCurrentIndex(QModelIndex());
QMenu* menu = m_menuProvider->createContextMenu();
menu->setStyleSheet(R"(
QMenu {
background-color: #2a5dec;
color: white;
}
QMenu::item:selected {
background-color: #1a4ddc;
}
QMenu::separator {
height: 1px;
background: white;
}
)");
if (menu)
{
menu->exec(event->globalPos());
delete menu;
}
//QTreeView::contextMenuEvent(event);
}

20
HPPA/LayerTreeView.h Normal file
View File

@ -0,0 +1,20 @@
#pragma once
#include <QTreeView>
class LayerTreeViewMenuProvider;
class LayerTreeView : public QTreeView
{
public:
explicit LayerTreeView(QWidget* parent = nullptr);
~LayerTreeView() override;
void setMenuProvider(LayerTreeViewMenuProvider* provider);
protected:
void contextMenuEvent(QContextMenuEvent* event) override;
private:
LayerTreeViewMenuProvider* m_menuProvider = nullptr; // not owned
};

View File

@ -0,0 +1,55 @@
#include "LayerTreeViewMenuProvider.h"
#include "LayerTreeView.h"
#include "LayerTreeModel.h"
#include "LayerTreeNode.h"
#include "HPPA.h"
#include <QAction>
#include <QDebug>
LayerTreeViewMenuProvider::LayerTreeViewMenuProvider(LayerTreeView* view, QObject* parent)
: QObject(parent), m_view(view)
{
}
QMenu* LayerTreeViewMenuProvider::createContextMenu()
{
m_contextIndex = m_view->currentIndex();
QMenu* menu = new QMenu();
if (!m_contextIndex.isValid())
{
return menu;
}
const LayerTreeModel* model = static_cast<const LayerTreeModel*>(m_contextIndex.model());
if (!model)
{
return menu;
}
LayerTreeNode* node = static_cast<LayerTreeNode*>(m_contextIndex.internalPointer());
if (!node)
{
return menu;
}
if (node->type() == LayerTreeNode::Type::Layer)
{
QAction* removeAction = new QAction(QStringLiteral("移除图层"), menu);
connect(removeAction, &QAction::triggered, HPPA::instance(), &HPPA::removeLayerByTreeIndex);
menu->addAction(removeAction);
}
else if (node->type() == LayerTreeNode::Type::Group)
{
HPPA* app = HPPA::instance();
if (app && node == app->rasterGroupNode())
{
QAction* removeAllAction = new QAction(QStringLiteral("移除所有图层"), menu);
connect(removeAllAction, &QAction::triggered, app, &HPPA::removeAllLayersInRasterGroup);
menu->addAction(removeAllAction);
}
}
return menu;
}

View File

@ -0,0 +1,24 @@
#pragma once
#include <QMenu>
#include <QObject>
#include <QModelIndex>
class LayerTreeView;
class LayerTreeModel;
class MapLayer;
class LayerTreeViewMenuProvider : public QObject
{
Q_OBJECT
public:
explicit LayerTreeViewMenuProvider(LayerTreeView* view, QObject* parent = nullptr);
~LayerTreeViewMenuProvider() override = default;
// 根据给定 index 创建一个菜单,调用者负责删除返回的 QMenu*
QMenu* createContextMenu();
private:
LayerTreeView* m_view = nullptr; // not owned
QModelIndex m_contextIndex;
};

26
HPPA/MapLayer.cpp Normal file
View File

@ -0,0 +1,26 @@
#include "MapLayer.h"
MapLayer::MapLayer(const QString& name, const QString& uri)
: QObject(nullptr), m_name(name), m_uri(uri)
{
}
QString MapLayer::name() const
{
return m_name;
}
void MapLayer::setName(const QString& n)
{
m_name = n;
}
QString MapLayer::dataPath() const
{
return m_uri;
}
void MapLayer::setDataPath(const QString& p)
{
m_uri = p;
}

30
HPPA/MapLayer.h Normal file
View File

@ -0,0 +1,30 @@
#pragma once
#include <QObject>
#include <QString>
#include <QMetaType>
class MapLayer : public QObject
{
Q_OBJECT
public:
enum class LayerType { Raster, Vector };
explicit MapLayer(const QString& name, const QString& uri);
virtual ~MapLayer() override = default;
QString name() const;
void setName(const QString& n);
QString dataPath() const;
void setDataPath(const QString& p);
virtual LayerType layerType() const = 0;
private:
QString m_name;
QString m_uri;
};
Q_DECLARE_METATYPE(MapLayer*)

92
HPPA/MapLayerStore.cpp Normal file
View File

@ -0,0 +1,92 @@
#include "MapLayerStore.h"
#include "MapLayer.h"
MapLayerStore::MapLayerStore(QObject* parent)
: QObject(parent)
{
int a = 1;
}
void MapLayerStore::addLayer(MapLayer* layer, QWidget* widget)
{
if (!layer) return;
MapLayer* raw = layer;
m_layers.emplace_back(std::shared_ptr<MapLayer>(layer));
if (widget)
m_layerWidgets[raw] = widget;
emit layerAdded(raw);
}
void MapLayerStore::removeLayer(MapLayer* layer)
{
if (!layer) return;
for (auto it = m_layers.begin(); it != m_layers.end(); ++it) {
if (it->get() == layer) {
emit layerAboutToBeRemoved(layer);
m_layers.erase(it);
m_layerWidgets.erase(layer);
return;
}
}
}
void MapLayerStore::removeLayerByName(const QString& name)
{
for (auto it = m_layers.begin(); it != m_layers.end(); ++it) {
if ((*it)->name() == name) {
MapLayer* raw = it->get();
emit layerAboutToBeRemoved(raw);
m_layers.erase(it);
m_layerWidgets.erase(raw);
return;
}
}
}
MapLayer* MapLayerStore::getLayer(const QString& name) const
{
for (const auto& l : m_layers) {
if (l->name() == name) return l.get();
}
return nullptr;
}
MapLayer* MapLayerStore::getLayerAt(int index) const
{
if (index < 0 || index >= (int)m_layers.size()) return nullptr;
return m_layers[index].get();
}
int MapLayerStore::layerCount() const
{
return (int)m_layers.size();
}
QWidget* MapLayerStore::widgetForLayer(MapLayer* layer) const
{
auto it = m_layerWidgets.find(layer);
if (it == m_layerWidgets.end()) return nullptr;
return it->second;
}
QWidget* MapLayerStore::widgetForLayer(const QString& absolutePath) const
{
for (const auto& sp : m_layers) {
if (sp && sp->dataPath() == absolutePath) {
MapLayer* raw = sp.get();
auto it = m_layerWidgets.find(raw);
if (it != m_layerWidgets.end()) return it->second;
return nullptr;
}
}
return nullptr;
}
MapLayer* MapLayerStore::layerForWidget(QWidget* widget) const
{
if (!widget) return nullptr;
for (const auto& kv : m_layerWidgets) {
if (kv.second == widget) return kv.first;
}
return nullptr;
}

51
HPPA/MapLayerStore.h Normal file
View File

@ -0,0 +1,51 @@
#pragma once
#include <QObject>
#include <QString>
#include <vector>
#include <memory>
#include <unordered_map>
class MapLayer;
class QWidget;
class MapLayerStore : public QObject
{
Q_OBJECT
public:
explicit MapLayerStore(QObject* parent = nullptr);
~MapLayerStore() override = default;
// Take ownership of the layer (store will own and manage its lifetime)
// Now also accept the associated QWidget so UI widget can be retrieved by layer pointer
void addLayer(MapLayer* layer, QWidget* widget = nullptr);
// Remove by pointer or by name. Destruction happens when removed from store.
public slots:
void removeLayer(MapLayer* layer);
void removeLayerByName(const QString& name);
// Queries
MapLayer* getLayer(const QString& name) const;
MapLayer* getLayerAt(int index) const;
int layerCount() const;
// Get associated widget for a layer (or nullptr if none)
QWidget* widgetForLayer(MapLayer* layer) const;
// Get associated widget by layer absolute data path
QWidget* widgetForLayer(const QString& absolutePath) const;
// Reverse lookup: find the MapLayer associated with a given widget (or nullptr)
MapLayer* layerForWidget(QWidget* widget) const;
signals:
void layerAdded(MapLayer* layer);
// Emitted just before the layer is destroyed/removed from store
void layerAboutToBeRemoved(MapLayer* layer);
private:
// store shared ownership so other parts can keep raw pointers safely (or use QPointer)
std::vector<std::shared_ptr<MapLayer>> m_layers;
// mapping from raw MapLayer pointer to associated QWidget*
std::unordered_map<MapLayer*, QWidget*> m_layerWidgets;
};

110
HPPA/MapTool.cpp Normal file
View File

@ -0,0 +1,110 @@
#include "stdafx.h"
#include "MapTool.h"
#include "ImageViewer.h"
#include <QAction>
MapTool::MapTool(QObject* parent)
: QObject(parent)
, m_cursor(Qt::ArrowCursor)
{
}
MapTool::~MapTool()
{
if (m_canvas && m_canvas->mapTool() == this)
{
m_canvas->unsetMapTool(this);
}
}
QAction* MapTool::action() const
{
return m_action;
}
void MapTool::setAction(QAction* action)
{
m_action = action;
}
void MapTool::setMapcavas(Mapcavas* canvas)
{
if (m_canvas == canvas)
return;
if (m_isActive && m_canvas)
{
//deactivate();
}
m_canvas = canvas;
}
Mapcavas* MapTool::canvas() const
{
return m_canvas;
}
void MapTool::setCursor(const QCursor& cursor)
{
m_cursor = cursor;
}
QCursor MapTool::cursor() const
{
return m_cursor;
}
void MapTool::activate()
{
if (m_canvas)
{
m_canvas->viewport()->setCursor(m_cursor);
}
if (m_action)
{
m_action->setChecked(true);
}
m_isActive = true;
emit activated();
}
void MapTool::deactivate()
{
if (m_action)
{
m_action->setChecked(false);
}
m_isActive = false;
emit deactivated();
}
bool MapTool::isActive() const
{
return m_isActive;
}
void MapTool::canvasMousePressEvent(QMouseEvent* e)
{
Q_UNUSED(e);
}
void MapTool::canvasMouseReleaseEvent(QMouseEvent* e)
{
Q_UNUSED(e);
}
void MapTool::canvasMouseMoveEvent(QMouseEvent* e)
{
Q_UNUSED(e);
}
void MapTool::canvasMouseDoubleClickEvent(QMouseEvent* e)
{
Q_UNUSED(e);
}
void MapTool::canvasWheelEvent(QWheelEvent* e)
{
Q_UNUSED(e);
}

63
HPPA/MapTool.h Normal file
View File

@ -0,0 +1,63 @@
#ifndef MAPTOOL_H
#define MAPTOOL_H
#include <QObject>
#include <QCursor>
#include <QMouseEvent>
#include <QAction>
class Mapcavas;
class QAction;
class MapTool : public QObject
{
Q_OBJECT
public:
enum Flag
{
NoFlags = 0,
Transient = 1 << 1,
};
Q_DECLARE_FLAGS(Flags, Flag)
MapTool(QObject* parent = nullptr);
virtual ~MapTool();
virtual Flags flags() const { return NoFlags; }
QAction* action() const;
void setAction(QAction* action);
void setMapcavas(Mapcavas* canvas);
Mapcavas* canvas() const;
virtual void setCursor(const QCursor& cursor);
QCursor cursor() const;
virtual void activate();
virtual void deactivate();
bool isActive() const;
virtual void canvasMousePressEvent(QMouseEvent* e);
virtual void canvasMouseReleaseEvent(QMouseEvent* e);
virtual void canvasMouseMoveEvent(QMouseEvent* e);
virtual void canvasMouseDoubleClickEvent(QMouseEvent* e);
virtual void canvasWheelEvent(QWheelEvent* e);
signals:
void activated();
void deactivated();
protected:
Mapcavas* m_canvas = nullptr;
private:
QAction* m_action = nullptr;
QCursor m_cursor;
bool m_isActive = false;
};
Q_DECLARE_OPERATORS_FOR_FLAGS(MapTool::Flags)
#endif // MAPTOOL_H

65
HPPA/MapToolPan.cpp Normal file
View File

@ -0,0 +1,65 @@
#include "stdafx.h"
#include "MapToolPan.h"
#include "ImageViewer.h"
#include <QMouseEvent>
#include <QGraphicsView>
MapToolPan::MapToolPan(QObject* parent)
: MapTool(parent)
{
setCursor(Qt::OpenHandCursor);
}
MapToolPan::~MapToolPan()
{
}
void MapToolPan::activate()
{
MapTool::activate();
if (canvas())
{
canvas()->setDragMode(QGraphicsView::NoDrag);
}
}
void MapToolPan::deactivate()
{
m_dragging = false;
MapTool::deactivate();
}
void MapToolPan::canvasMousePressEvent(QMouseEvent* e)
{
if (e->button() == Qt::LeftButton)
{
m_dragging = true;
m_lastPos = e->pos();
if (canvas())
{
canvas()->viewport()->setCursor(Qt::ClosedHandCursor);
}
}
}
void MapToolPan::canvasMouseMoveEvent(QMouseEvent* e)
{
if (m_dragging && canvas())
{
QPointF delta = canvas()->mapToScene(e->pos()) - canvas()->mapToScene(m_lastPos);
canvas()->translate(delta.x(), delta.y());
m_lastPos = e->pos();
}
}
void MapToolPan::canvasMouseReleaseEvent(QMouseEvent* e)
{
if (e->button() == Qt::LeftButton)
{
m_dragging = false;
if (canvas())
{
canvas()->viewport()->setCursor(Qt::OpenHandCursor);
}
}
}

27
HPPA/MapToolPan.h Normal file
View File

@ -0,0 +1,27 @@
#ifndef MAPTOOLPAN_H
#define MAPTOOLPAN_H
#include "MapTool.h"
#include <QPoint>
class MapToolPan : public MapTool
{
Q_OBJECT
public:
MapToolPan(QObject* parent = nullptr);
~MapToolPan();
void activate() override;
void deactivate() override;
void canvasMousePressEvent(QMouseEvent* e) override;
void canvasMouseMoveEvent(QMouseEvent* e) override;
void canvasMouseReleaseEvent(QMouseEvent* e) override;
private:
bool m_dragging = false;
QPoint m_lastPos;
};
#endif // MAPTOOLPAN_H

57
HPPA/MapToolSpectral.cpp Normal file
View File

@ -0,0 +1,57 @@
#include "stdafx.h"
#include "MapToolSpectral.h"
#include "ImageViewer.h"
#include "RasterLayer.h"
#include <QMouseEvent>
#include <QGraphicsScene>
#include <QGraphicsLineItem>
#include <QPen>
#include <cmath>
MapToolSpectral::MapToolSpectral(QObject* parent)
: MapTool(parent)
{
setCursor(Qt::CrossCursor);
}
MapToolSpectral::~MapToolSpectral()
{
}
void MapToolSpectral::activate()
{
MapTool::activate();
}
void MapToolSpectral::deactivate()
{
canvas()->removeCrosshair();
MapTool::deactivate();
}
void MapToolSpectral::canvasMousePressEvent(QMouseEvent* e)
{
if (e->button() != Qt::LeftButton)
return;
if (!canvas())
return;
const QPointF scenePt = canvas()->mapToScene(e->pos());
const int x = static_cast<int>(std::floor(scenePt.x()));
const int y = static_cast<int>(std::floor(scenePt.y()));
RasterLayer* rl = canvas()->rasterLayer();
if (rl && rl->isValidPixel(x, y))
{
// Place crosshair at pixel center
canvas()->updateCrosshair(x + 0.5, y + 0.5);
QVector<double> wavelengths;
QVector<double> spectrum;
if (rl->readPixelSpectrum(x, y, wavelengths, spectrum))
{
emit spectralClicked(x, y, wavelengths, spectrum);
}
}
}

28
HPPA/MapToolSpectral.h Normal file
View File

@ -0,0 +1,28 @@
#ifndef MAPTOOLSPECTRAL_H
#define MAPTOOLSPECTRAL_H
#include "MapTool.h"
#include <QVector>
class QGraphicsLineItem;
class MapToolSpectral : public MapTool
{
Q_OBJECT
public:
MapToolSpectral(QObject* parent = nullptr);
~MapToolSpectral();
void canvasMousePressEvent(QMouseEvent* e) override;
void activate() override;
void deactivate() override;
signals:
void spectralClicked(int x, int y, QVector<double> wavelengths, QVector<double> spectrum);
private:
};
#endif // MAPTOOLSPECTRAL_H

50
HPPA/MapTools.cpp Normal file
View File

@ -0,0 +1,50 @@
#include "stdafx.h"
#include "MapTools.h"
#include "MapToolPan.h"
#include "MapToolSpectral.h"
MapTools::MapTools(QObject* parent)
: QObject(parent)
{
m_tools.insert(Pan, new MapToolPan(this));
m_tools.insert(Spectral, new MapToolSpectral(this));
}
MapTools::~MapTools()
{
qDeleteAll(m_tools);
m_tools.clear();
}
MapToolPan* MapTools::mapToolPan() const
{
return qobject_cast<MapToolPan*>(m_tools.value(Pan));
}
MapToolSpectral* MapTools::mapToolSpectral() const
{
return qobject_cast<MapToolSpectral*>(m_tools.value(Spectral));
}
MapTool* MapTools::mapTool(Tool tool) const
{
return m_tools.value(tool, nullptr);
}
MapTool* MapTools::activeTool() const
{
return m_activeTool;
}
void MapTools::setActiveTool(MapTool* tool)
{
m_activeTool = tool;
}
void MapTools::setMapcavas(Mapcavas* canvas)
{
if (m_activeTool)
{
m_activeTool->setMapcavas(canvas);
}
}

41
HPPA/MapTools.h Normal file
View File

@ -0,0 +1,41 @@
#ifndef MAPTOOLS_H
#define MAPTOOLS_H
#include <QObject>
#include <QHash>
class MapTool;
class MapToolPan;
class MapToolSpectral;
class Mapcavas;
class MapTools : public QObject
{
Q_OBJECT
public:
enum Tool
{
Pan,
Spectral,
};
MapTools(QObject* parent = nullptr);
~MapTools();
MapToolPan* mapToolPan() const;
MapToolSpectral* mapToolSpectral() const;
MapTool* mapTool(Tool tool) const;
MapTool* activeTool() const;
void setActiveTool(MapTool* tool);
void setMapcavas(Mapcavas* canvas);
private:
QHash<Tool, MapTool*> m_tools;
MapTool* m_activeTool = nullptr;
};
#endif // MAPTOOLS_H

11
HPPA/MotorWindowBase.cpp Normal file
View File

@ -0,0 +1,11 @@
#include "MotorWindowBase.h"
MotorWindowBase::MotorWindowBase()
{
}
MotorWindowBase::~MotorWindowBase()
{
}

15
HPPA/MotorWindowBase.h Normal file
View File

@ -0,0 +1,15 @@
#pragma once
class MotorWindowBase
{
public:
MotorWindowBase();
~MotorWindowBase();
protected:
virtual bool getMotorsConnectionStatus()=0;
private:
};

View File

@ -1,4 +1,4 @@
#include "OneMotorControl.h"
#include "OneMotorControl.h"
OneMotorControl::OneMotorControl(QWidget* parent) : QDialog(parent)
{
@ -6,6 +6,16 @@ OneMotorControl::OneMotorControl(QWidget* parent) : QDialog(parent)
connect(this->ui.connect_btn, SIGNAL(pressed()), this, SLOT(onConnectMotor()));
connect(this->ui.right_btn, SIGNAL(pressed()), this, SLOT(onxMotorRight()));
connect(this->ui.right_btn, SIGNAL(released()), this, SLOT(onxMotorStop()));
connect(this->ui.left_btn, SIGNAL(pressed()), this, SLOT(onxMotorLeft()));
connect(this->ui.left_btn, SIGNAL(released()), this, SLOT(onxMotorStop()));
connect(this->ui.move2loc_pushButton, SIGNAL(pressed()), this, SLOT(onxMove2Loc()));
connect(this->ui.zero_start_btn, SIGNAL(released()), this, SLOT(zeroStart()));
connect(this->ui.rangeMeasurement_btn, SIGNAL(pressed()), this, SLOT(onx_rangeMeasurement()));
}
OneMotorControl::~OneMotorControl()
@ -16,6 +26,31 @@ OneMotorControl::~OneMotorControl()
void OneMotorControl::onConnectMotor()
{
if (getMotorsConnectionStatus())
{
QMessageBox msgBox;
msgBox.setText(QString::fromLocal8Bit("马达已连接!"));
msgBox.exec();
return;
}
if (m_multiAxisController != nullptr)
{
disconnect(m_multiAxisController, SIGNAL(broadcastLocationSignal(std::vector<double>)), this, SLOT(display_x_loc(std::vector<double>)));
disconnect(this, SIGNAL(moveSignal(int, bool, double, int)), m_multiAxisController, SLOT(move(int, bool, double, int)));
disconnect(this, SIGNAL(move2LocSignal(int, double, double, int)), m_multiAxisController, SLOT(moveTo(int, double, double, int)));
disconnect(this, SIGNAL(stopSignal(int)), m_multiAxisController, SLOT(stop(int)));
disconnect(this, SIGNAL(zeroStartSignal(int)), m_multiAxisController, SLOT(zeroStart(int)));
disconnect(this, SIGNAL(rangeMeasurement(int, double, int)), m_multiAxisController, SLOT(rangeMeasurement(int, double, int)));
disconnect(this, SIGNAL(testConnectivitySignal(int, int)), m_multiAxisController, SLOT(testConnectivity(int, int)));
disconnect(m_multiAxisController, SIGNAL(broadcastConnectivity(std::vector<int>)), this, SLOT(display_motors_connectivity(std::vector<int>)));
m_motorThread.quit();
m_motorThread.wait();
m_multiAxisController = nullptr;
}
try
{
FileOperation* fileOperation = new FileOperation();
@ -27,30 +62,22 @@ void OneMotorControl::onConnectMotor()
catch (std::exception const& e)
{
QMessageBox msgBox;
msgBox.setText(QString::fromLocal8Bit("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"));
msgBox.setText(QString::fromLocal8Bit("请连接马达!"));
msgBox.exec();
return;
}
m_multiAxisController->moveToThread(&m_motorThread);
connect(&m_motorThread, SIGNAL(finished()), m_multiAxisController, SLOT(deleteLater()));
connect(this->ui.right_btn, SIGNAL(pressed()), this, SLOT(onxMotorRight()));
connect(this->ui.right_btn, SIGNAL(released()), this, SLOT(onxMotorStop()));
connect(this->ui.left_btn, SIGNAL(pressed()), this, SLOT(onxMotorLeft()));
connect(this->ui.left_btn, SIGNAL(released()), this, SLOT(onxMotorStop()));
connect(this->ui.move2loc_pushButton, SIGNAL(pressed()), this, SLOT(onxMove2Loc()));
connect(m_multiAxisController, SIGNAL(broadcastLocationSignal(std::vector<double>)), this, SLOT(display_x_loc(std::vector<double>)));
connect(this, SIGNAL(moveSignal(int, bool, double, int)), m_multiAxisController, SLOT(move(int, bool, double, int)));
connect(this, SIGNAL(move2LocSignal(int, double, double, int)), m_multiAxisController, SLOT(moveTo(int, double, double, int)));
connect(this, SIGNAL(stopSignal(int)), m_multiAxisController, SLOT(stop(int)));
connect(this->ui.zero_start_btn, SIGNAL(released()), this, SLOT(zeroStart()));
connect(this, SIGNAL(zeroStartSignal(int)), m_multiAxisController, SLOT(zeroStart(int)));
connect(this->ui.rangeMeasurement_btn, SIGNAL(pressed()), this, SLOT(onx_rangeMeasurement()));
connect(this, SIGNAL(rangeMeasurement(int, double, int)), m_multiAxisController, SLOT(rangeMeasurement(int, double, int)));
connect(this, SIGNAL(testConnectivitySignal(int, int)), m_multiAxisController, SLOT(testConnectivity(int, int)));
@ -64,6 +91,8 @@ void OneMotorControl::display_x_loc(std::vector<double> loc)
{
double tmp = round(loc[0] * 100) / 100;
this->ui.realTimeLoc_lineEdit->setText(QString::number(tmp));
emit broadcastLocationSignal(loc);
}
void OneMotorControl::display_motors_connectivity(std::vector<int> connectivity)
@ -71,11 +100,36 @@ void OneMotorControl::display_motors_connectivity(std::vector<int> connectivity)
//std::cout << "-----------------------------------"<<connectivity.size()<< std::endl;
if (connectivity[0])
{
this->ui.motor_state_label->setStyleSheet("QLabel{background-color:rgb(0,255,0);}");
m_xMotorConnectionStatus = true;
this->ui.motor_state_label->setStyleSheet(R"(
QLabel
{
background-color: #08FACE;
border-radius: 4px;
}
)");
}
else
{
this->ui.motor_state_label->setStyleSheet("QLabel{background-color:rgb(255,0,0);}");
m_xMotorConnectionStatus = false;
this->ui.motor_state_label->setStyleSheet(R"(
QLabel
{
background-color: red;
border-radius: 4px;
}
)");
}
if (getMotorsConnectionStatus())
{
this->ui.connect_btn->setText(QString::fromLocal8Bit("已连接"));
}
else
{
this->ui.connect_btn->setText(QString::fromLocal8Bit("重新连接"));
}
}
@ -148,15 +202,12 @@ void OneMotorControl::record_white()
void OneMotorControl::run()
{
if (m_coordinator == nullptr)
{
qRegisterMetaType<OneMotionCapturePathLine>("OneMotionCapturePathLine");
m_coordinator = new OneMotionCaptureCoordinator(m_multiAxisController, m_Imager);
connect(this, SIGNAL(start(OneMotionCapturePathLine)), m_coordinator, SLOT(startStepMotion(OneMotionCapturePathLine)));
connect(this, SIGNAL(stopStepMotionSignal()), m_coordinator, SLOT(stopStepMotion()));
connect(m_coordinator, SIGNAL(sequenceComplete(int)), this, SLOT(onSequenceComplete()));
}
connect(m_coordinator, SIGNAL(sequenceComplete(int)), this, SLOT(onSequenceComplete(int)));
OneMotionCapturePathLine tmp;
tmp.speedRecord = ui.speed_lineEdit->text().toDouble();
@ -170,7 +221,22 @@ void OneMotorControl::stop()
emit stopStepMotionSignal();
}
void OneMotorControl::onSequenceComplete()
void OneMotorControl::onSequenceComplete(int state)
{
emit sequenceComplete();
disconnect(this, SIGNAL(start(OneMotionCapturePathLine)), m_coordinator, SLOT(startStepMotion(OneMotionCapturePathLine)));
disconnect(this, SIGNAL(stopStepMotionSignal()), m_coordinator, SLOT(stopStepMotion()));
disconnect(m_coordinator, SIGNAL(sequenceComplete(int)), this, SLOT(onSequenceComplete(int)));
// Use deleteLater() instead of delete: this slot may have been called directly
// from OneMotionCaptureCoordinator's call stack (direct connection), so deleting
// the object here would cause a crash when execution returns to the destroyed object.
m_coordinator->deleteLater();
m_coordinator = nullptr;
}
bool OneMotorControl::getMotorsConnectionStatus()
{
return m_xMotorConnectionStatus;
}

View File

@ -1,4 +1,4 @@
#pragma once
#pragma once
#include <QThread>
#include <QMessageBox>
@ -7,8 +7,9 @@
#include "IrisMultiMotorController.h"
#include "fileOperation.h"
#include "CaptureCoordinator.h"
#include "MotorWindowBase.h"
class OneMotorControl : public QDialog
class OneMotorControl : public QDialog, public MotorWindowBase
{
Q_OBJECT
@ -24,6 +25,7 @@ public:
void record_dark();
void record_white();
bool getMotorsConnectionStatus();
public Q_SLOTS:
void onConnectMotor();
@ -38,7 +40,7 @@ public Q_SLOTS:
void onxMotorLeft();
void onxMotorStop();
void onSequenceComplete();
void onSequenceComplete(int state);
signals:
void moveSignal(int, bool, double, int);
@ -55,15 +57,19 @@ signals:
void sequenceComplete();
void broadcastLocationSignal(std::vector<double>);
private:
Ui::OneMotorControl_UI ui;
QThread m_motorThread;
IrisMultiMotorController* m_multiAxisController;
IrisMultiMotorController* m_multiAxisController = nullptr;
OneMotionCaptureCoordinator* m_coordinator = nullptr;
ImagerOperationBase* m_Imager;
DarkAndWhiteCaptureCoordinator* m_darkCaptureCoordinator = nullptr;
DarkAndWhiteCaptureCoordinator* m_whiteCaptureCoordinator = nullptr;
bool m_xMotorConnectionStatus = false;
};

View File

@ -1,4 +1,4 @@
#include "PowerControl.h"
#include "PowerControl.h"
PowerControl::PowerControl(QWidget *parent)
: QDialog(parent)

View File

@ -1,4 +1,4 @@
#pragma once
#pragma once
#include <QDialog>
#include <QNetworkRequest>

View File

@ -6,19 +6,103 @@
<rect>
<x>0</x>
<y>0</y>
<width>294</width>
<height>119</height>
<width>432</width>
<height>346</height>
</rect>
</property>
<property name="windowTitle">
<string>PowerControl</string>
</property>
<property name="styleSheet">
<string notr="true">QGroupBox
{
border: 12px solid transparent;
color: #ACCDFF;
}
QPushButton
{
/*width: 172px;
height: 56px;*/
font: 19pt &quot;新宋体&quot;;
background-color: qlineargradient(
spread:pad,
x1:0.5, y1:0, x2:0.5, y2:1,
stop:0 #283D86,
stop:1 #0F1A40
);
color: white;
border: none;
padding: 8px 16px;
border-radius: 4px;
}
QPushButton:hover
{
background-color: qlineargradient(
spread:pad,
x1:0, y1:0, x2:1, y2:0,
stop:0 #3A4875,
stop:1 #5F6B91
);
}
/* 按下时的效果 */
QPushButton:pressed
{
background-color: qlineargradient(
spread:pad,
x1:0, y1:0, x2:1, y2:0,
stop:0 #1A254F,
stop:1 #3A466B
);
/* 可选:添加下压效果 */
padding-top: 9px;
padding-bottom: 7px;
}</string>
</property>
<layout class="QGridLayout" name="gridLayout_3" rowstretch="1,1,1,1" columnstretch="1,3,1">
<item row="0" column="1">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>145</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>151</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="1">
<widget class="QGroupBox" name="groupBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>卤素灯</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
<number>10</number>
</property>
<property name="rightMargin">
<number>0</number>
@ -26,94 +110,142 @@
<property name="bottomMargin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
<property name="horizontalSpacing">
<number>20</number>
</property>
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_20">
<item>
<widget class="QLabel" name="label_17">
<property name="text">
<string>卤素灯</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="lamp_power_open_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>
<item row="0" column="1">
<widget class="QPushButton" name="lamp_power_close_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>
<spacer name="horizontalSpacer_19">
</layout>
</widget>
</item>
<item row="1" column="2">
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<width>151</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_21">
<item>
<widget class="QLabel" name="label_18">
<property name="text">
<string>马 达</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="motor_power_open_btn">
<property name="text">
<string>打开</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="motor_power_close_btn">
<property name="text">
<string>关闭</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_20">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="2" column="0">
<spacer name="verticalSpacer_3">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>151</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="1">
<widget class="QGroupBox" name="groupBox_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>马 达</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>10</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="horizontalSpacing">
<number>20</number>
</property>
<item row="0" column="0">
<widget class="QPushButton" name="motor_power_open_btn">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>打开</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="motor_power_close_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>
</widget>
</item>
<item row="2" column="2">
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>151</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="1">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>42</height>
<height>144</height>
</size>
</property>
</spacer>

View File

@ -1,4 +1,4 @@
#include "stdafx.h"
#include "stdafx.h"
#include "qDoubleSlider.h"
QDoubleSlider::QDoubleSlider(QWidget* pParent /*= NULL*/) :
QSlider(pParent),
@ -7,18 +7,19 @@ m_Multiplier(100.0)
connect(this, SIGNAL(valueChanged(int)), this, SLOT(notifyValueChanged(int)));
setSingleStep(1);
setRange(1, 500);
setOrientation(Qt::Horizontal);
setFocusPolicy(Qt::NoFocus);
}
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//向外发射
void QDoubleSlider::notifyValueChanged(int Value)
{
emit valueChanged((double)Value / m_Multiplier);
}
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//接收外边
void QDoubleSlider::setValue(double Value, bool BlockSignals)
{
QSlider::blockSignals(BlockSignals);

View File

@ -1,4 +1,4 @@
#ifndef Q_DOUBLE_SLIDER_H
#ifndef Q_DOUBLE_SLIDER_H
#define Q_DOUBLE_SLIDER_H
#include <QtGui/QtGui>
#include <QSlider>
@ -17,14 +17,14 @@ public:
double value() const;
public slots:
void notifyValueChanged(int value);//<EFBFBD>ź<EFBFBD>valueChanged(int)<EFBFBD><EFBFBD>wrap
void setValue(double Value, bool BlockSignals = true);//QSlider::setValue<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>wrap
void notifyValueChanged(int value);//信号valueChanged(int)wrap
void setValue(double Value, bool BlockSignals = true);//QSlider::setValue函数的wrap
private slots:
signals :
void valueChanged(double Value);
void rangeChanged(double Min, double Max);
void valueChanged(double Value);//QSlider的valueChanged信号的参数为整型
void rangeChanged(double Min, double Max);//QSlider的rangeChanged信号的参数为整型
private:
double m_Multiplier;

View File

@ -1,4 +1,4 @@
#include "stdafx.h"
#include "stdafx.h"
#include "QMotorDoubleSlider.h"
QMotorDoubleSlider::QMotorDoubleSlider(QWidget* pParent /*= NULL*/) :QSlider(pParent)
{
@ -14,9 +14,9 @@ QMotorDoubleSlider::QMotorDoubleSlider(QWidget* pParent /*= NULL*/) :QSlider(pPa
void QMotorDoubleSlider::setMultiplier(float lead, float stepAnglemar, float scaleFactor, int subdivisionParam)
{
//<EFBFBD><EFBFBD><EFBFBD>ݹ<EFBFBD>ʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD>룺1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(m_Multiplier)=<EFBFBD><EFBFBD><EFBFBD><EFBFBD>/(360/<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><>ֱ<EFBFBD><D6B1><EFBFBD>)<29><><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7>https://wenku.baidu.com/view/4b2ea88bd0d233d4b14e69b8.html
//m_Multiplier(0.00054496986),//<EFBFBD>Ϻ<EFBFBD>ũ<EFBFBD><EFBFBD>Ժ<EFBFBD><EFBFBD><EFBFBD>޸<EFBFBD>ǰ<EFBFBD><EFBFBD>0.00052734375/5=0.00010546875<EFBFBD><EFBFBD><EFBFBD>޸ĺ<EFBFBD>׼ȷֵΪ0.000544969862759644<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ0.00054496986/5=0.000108993972<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>и<EFBFBD><EFBFBD><EFBFBD>еװ<EFBFBD><EFBFBD>1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>5<EFBFBD><EFBFBD>
//m_Multiplier(0.00054496986)//<EFBFBD>˰<EFBFBD><EFBFBD><EFBFBD>ũ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//根据公式将脉冲换算为距离1脉冲距离(m_Multiplier)=导程/(360/步距角*细分倍数);网址:https://wenku.baidu.com/view/4b2ea88bd0d233d4b14e69b8.html
//m_Multiplier(0.00054496986),//上海农科院,修改前:0.00052734375/5=0.00010546875;修改后准确值为0.000544969862759644,近似为0.00054496986/5=0.000108993972因为有个机械装置1脉冲距离需要除以5
//m_Multiplier(0.00054496986)//兴安盟农研所
m_Multiplier = lead / (360 / stepAnglemar * getValidSubdivision(subdivisionParam)) * scaleFactor;
}
@ -38,13 +38,13 @@ int QMotorDoubleSlider::getValidSubdivision(int subdivisionParam)
return 256;
}
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//向外发射
void QMotorDoubleSlider::notifyValueChanged(int Value)
{
emit valueChanged((double)Value * m_Multiplier);//////////
}
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//接收外边
void QMotorDoubleSlider::setValue(double Value, bool BlockSignals)
{
QSlider::blockSignals(BlockSignals);

View File

@ -1,4 +1,4 @@
#ifndef Q_MOTOR_DOUBLE_SLIDER_H
#ifndef Q_MOTOR_DOUBLE_SLIDER_H
#define Q_MOTOR_DOUBLE_SLIDER_H
#include <QtGui/QtGui>
#include <QSlider>
@ -15,7 +15,7 @@ public:
void setMultiplier(float lead, float stepAnglemar, float scaleFactor, int subdivisionParam);
int getValidSubdivision(int subdivisionParam);
double m_Multiplier;//<EFBFBD><EFBFBD><EFBFBD>ݹ<EFBFBD>ʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD>룺1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(m_Multiplier)=<EFBFBD><EFBFBD><EFBFBD><EFBFBD>/(360/<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><>ֱ<EFBFBD><D6B1><EFBFBD>)<29><><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7>https://wenku.baidu.com/view/4b2ea88bd0d233d4b14e69b8.html
double m_Multiplier;//根据公式将脉冲换算为距离1脉冲距离(m_Multiplier)=导程/(360/步距角*细分倍数);网址:https://wenku.baidu.com/view/4b2ea88bd0d233d4b14e69b8.html
void setRange(double Min, double Max);
void setMinimum(double Min);
@ -23,13 +23,13 @@ public:
void setMaximum(double Max);
double maximum() const;
double value() const;
double OriginalValue() const;//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫʵ<EFBFBD>ʵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ǿ<EFBFBD><EFBFBD><EFBFBD>
long getPositionPulse(double position);//<EFBFBD><EFBFBD><EFBFBD>ݴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ľ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
double OriginalValue() const;//返回脉冲值:马达需要实际的脉冲值,而不是距离
long getPositionPulse(double position);//根据传入的距离返回脉冲值
double getDistanceFromPulse(int pulse);
public slots:
void notifyValueChanged(int value);//<EFBFBD>ź<EFBFBD>valueChanged(int)<EFBFBD><EFBFBD>wrap
void setValue(double Value, bool BlockSignals = true);//QSlider::setValue<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>wrap
void notifyValueChanged(int value);//信号valueChanged(int)wrap
void setValue(double Value, bool BlockSignals = true);//QSlider::setValue函数的wrap
signals:
void valueChanged(double Value);

225
HPPA/RasterDataProvider.cpp Normal file
View File

@ -0,0 +1,225 @@
#include "RasterDataProvider.h"
#include <QString>
#include <QDebug>
#include <QFile>
#include <QFileInfo>
#include <QRegularExpression>
#if HPPA_HAVE_GDAL
#include <gdal_priv.h>
#include <cpl_conv.h>
#endif
RasterDataProvider::RasterDataProvider(const QString& uri)
: m_uri(uri), m_dataset(nullptr)
{
}
RasterDataProvider::~RasterDataProvider()
{
close();
}
bool RasterDataProvider::open()
{
#if HPPA_HAVE_GDAL
GDALAllRegister();
m_dataset = (GDALDataset*)GDALOpen((const char*)m_uri.toLocal8Bit().constData(), GA_ReadOnly);
if (!m_dataset) {
qWarning() << "RasterDataProvider: failed to open dataset:" << m_uri;
return false;
}
return true;
#else
Q_UNUSED(m_uri);
qWarning() << "RasterDataProvider: GDAL not available, open will fail.";
return false;
#endif
}
void RasterDataProvider::close()
{
#if HPPA_HAVE_GDAL
if (m_dataset) {
GDALClose((GDALDatasetH)m_dataset);
m_dataset = nullptr;
}
#else
m_dataset = nullptr;
#endif
}
int RasterDataProvider::bandCount() const
{
#if HPPA_HAVE_GDAL
if (!m_dataset) return 0;
return m_dataset->GetRasterCount();
#else
Q_UNUSED(this);
return 0;
#endif
}
int RasterDataProvider::width() const
{
#if HPPA_HAVE_GDAL
if (!m_dataset) return 0;
return m_dataset->GetRasterXSize();
#else
Q_UNUSED(this);
return 0;
#endif
}
int RasterDataProvider::height() const
{
#if HPPA_HAVE_GDAL
if (!m_dataset) return 0;
return m_dataset->GetRasterYSize();
#else
Q_UNUSED(this);
return 0;
#endif
}
bool RasterDataProvider::isValidPixel(int x, int y) const
{
const int w = width();
const int h = height();
return x >= 0 && y >= 0 && x < w && y < h;
}
std::vector<double> RasterDataProvider::parseEnviHdrWavelengths() const
{
std::vector<double> res;
QFileInfo fi(m_uri);
QString hdrPath = fi.path() + "/" + fi.completeBaseName() + ".hdr";
QFile hdr(hdrPath);
if (!hdr.open(QIODevice::ReadOnly | QIODevice::Text)) {
return res;
}
QString text = QString::fromLocal8Bit(hdr.readAll());
hdr.close();
QRegularExpression rx("wavelength\\s*=\\s*\\{([^}]*)\\}", QRegularExpression::CaseInsensitiveOption | QRegularExpression::DotMatchesEverythingOption);
QRegularExpressionMatch m = rx.match(text);
if (!m.hasMatch()) {
return res;
}
const QString body = m.captured(1);
const QStringList parts = body.split(',', QString::SkipEmptyParts);
res.reserve(parts.size());
for (const QString& p : parts) {
bool ok = false;
double v = p.trimmed().toDouble(&ok);
if (ok) {
res.push_back(v);
}
}
return res;
}
std::vector<double> RasterDataProvider::bandWavelengths() const
{
std::vector<double> res;
#if HPPA_HAVE_GDAL
if (!m_dataset) return res;
// 1) Try ENVI dataset-level metadata first: wavelength = { ... }
const char* dsWave = m_dataset->GetMetadataItem("wavelength", "ENVI");
if (!dsWave) dsWave = m_dataset->GetMetadataItem("Wavelength", "ENVI");
if (dsWave) {
QString dsWaveStr = QString::fromLocal8Bit(dsWave);
dsWaveStr.remove('{').remove('}');
const QStringList parts = dsWaveStr.split(',', QString::SkipEmptyParts);
res.reserve(parts.size());
for (const QString& p : parts) {
bool ok = false;
double v = p.trimmed().toDouble(&ok);
if (ok) res.push_back(v);
}
if (!res.empty()) return res;
}
// 2) Try per-band metadata
for (int i = 1; i <= m_dataset->GetRasterCount(); ++i) {
GDALRasterBand* band = m_dataset->GetRasterBand(i);
if (!band) continue;
const char* val = band->GetMetadataItem("Wavelength");
if (!val) val = band->GetMetadataItem("wavelength");
if (val) {
bool ok = false;
double v = QString::fromLocal8Bit(val).trimmed().toDouble(&ok);
res.push_back(ok ? v : -1.0);
} else {
res.push_back(-1.0);
}
}
if (!res.empty()) return res;
#endif
// 3) Fallback: parse ENVI .hdr directly
return parseEnviHdrWavelengths();
}
bool RasterDataProvider::readPixelSpectrum(int x, int y, std::vector<double>& outSpectrum) const
{
#if HPPA_HAVE_GDAL
outSpectrum.clear();
if (!m_dataset) return false;
if (!isValidPixel(x, y)) return false;
const int bands = m_dataset->GetRasterCount();
if (bands <= 0) return false;
outSpectrum.resize(bands);
for (int i = 0; i < bands; ++i) {
GDALRasterBand* band = m_dataset->GetRasterBand(i + 1);
if (!band) return false;
float value = 0.0f;
CPLErr err = band->RasterIO(
GF_Read,
x, y,
1, 1,
&value,
1, 1,
GDT_Float32,
0, 0);
if (err != CE_None) return false;
outSpectrum[i] = static_cast<double>(value);
}
return true;
#else
Q_UNUSED(x);
Q_UNUSED(y);
Q_UNUSED(outSpectrum);
return false;
#endif
}
bool RasterDataProvider::readBandAsFloat(int bandIndex, std::vector<float>& outBuffer) const
{
#if HPPA_HAVE_GDAL
if (!m_dataset) return false;
int bands = m_dataset->GetRasterCount();
if (bandIndex < 0 || bandIndex >= bands) return false;
GDALRasterBand* band = m_dataset->GetRasterBand(bandIndex + 1);
if (!band) return false;
int w = m_dataset->GetRasterXSize();
int h = m_dataset->GetRasterYSize();
outBuffer.assign(w * h, 0.0f);
CPLErr err = band->RasterIO(GF_Read, 0, 0, w, h, outBuffer.data(), w, h, GDT_Float32, 0, 0);
return err == CE_None;
#else
Q_UNUSED(bandIndex);
Q_UNUSED(outBuffer);
return false;
#endif
}

50
HPPA/RasterDataProvider.h Normal file
View File

@ -0,0 +1,50 @@
#pragma once
#include <QString>
#include <vector>
#if __has_include(<gdal_priv.h>)
#define HPPA_HAVE_GDAL 1
#include <gdal_priv.h>
#include <cpl_conv.h>
#else
#define HPPA_HAVE_GDAL 0
#endif
class RasterDataProvider
{
public:
explicit RasterDataProvider(const QString& uri);
~RasterDataProvider();
bool open();
void close();
int bandCount() const;
int width() const;
int height() const;
bool isValidPixel(int x, int y) const;
// Returns per-band wavelength metadata if available. If not available, returns empty vector.
std::vector<double> bandWavelengths() const;
// Read spectrum of one pixel (x,y) across all bands.
bool readPixelSpectrum(int x, int y, std::vector<double>& outSpectrum) const;
// Read a single band (0-based index) into a float buffer of size width()*height().
// Returns true on success.
bool readBandAsFloat(int bandIndex, std::vector<float>& outBuffer) const;
QString uri() const { return m_uri; }
private:
QString m_uri;
std::vector<double> parseEnviHdrWavelengths() const;
#if HPPA_HAVE_GDAL
GDALDataset* m_dataset = nullptr;
#else
// no-op when GDAL not available
void* m_dataset = nullptr;
#endif
};

116
HPPA/RasterLayer.cpp Normal file
View File

@ -0,0 +1,116 @@
#include "RasterLayer.h"
#include "RasterDataProvider.h"
#include "RasterRenderer.h"
#include <algorithm>
RasterLayer::RasterLayer(const QString& name, const QString& uri)
: MapLayer(name, uri)
{
// lazy creation
}
RasterLayer::~RasterLayer()
{
}
MapLayer::LayerType RasterLayer::layerType() const
{
return MapLayer::LayerType::Raster;
}
RasterDataProvider* RasterLayer::dataProvider() const
{
return m_provider ? m_provider.get() : nullptr;
}
RasterRenderer* RasterLayer::renderer() const
{
return m_renderer ? m_renderer.get() : nullptr;
}
bool RasterLayer::openDataProvider()
{
if (!m_provider) m_provider = std::make_unique<RasterDataProvider>(dataPath());
if (!m_provider) return false;
bool ok = 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)
{
if (!m_provider) {
if (!openDataProvider()) return false;
}
return m_provider->isValidPixel(x, y);
}
bool RasterLayer::readPixelSpectrum(int x, int y, QVector<double>& wavelengths, QVector<double>& spectrum)
{
if (!m_provider) {
if (!openDataProvider()) return false;
}
std::vector<double> wl;
std::vector<double> sp;
if (!m_provider->readPixelSpectrum(x, y, sp)) return false;
wl = m_provider->bandWavelengths();
wavelengths = QVector<double>::fromStdVector(wl);
spectrum = QVector<double>::fromStdVector(sp);
if (wavelengths.size() != spectrum.size()) {
wavelengths.resize(spectrum.size());
for (int i = 0; i < wavelengths.size(); ++i) {
wavelengths[i] = i;
}
}
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
{
auto wl = bandWavelengths();
if (wl.empty()) return false;
minWave = *std::min_element(wl.begin(), wl.end());
maxWave = *std::max_element(wl.begin(), wl.end());
return true;
}
std::vector<double> RasterLayer::bandWavelengths() const
{
if (!m_provider) {
// need to open provider to read wavelengths - cast away const for lazy init
auto* self = const_cast<RasterLayer*>(this);
if (!self->openDataProvider()) return {};
}
return m_provider->bandWavelengths();
}

55
HPPA/RasterLayer.h Normal file
View File

@ -0,0 +1,55 @@
#pragma once
#include "MapLayer.h"
#include <memory>
#include <QImage>
#include <QVector>
class RasterDataProvider;
class RasterRenderer;
class RasterLayer : public MapLayer
{
Q_OBJECT
public:
explicit RasterLayer(const QString& name, const QString& uri);
~RasterLayer();
LayerType layerType() const override;
// Access provider/renderer
RasterDataProvider* dataProvider() const;
RasterRenderer* renderer() const;
// Create or open provider based on this layer's uri
bool openDataProvider();
bool isValidPixel(int x, int y);
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.
bool wavelengthRange(double& minWave, double& maxWave) const;
// Get all band wavelengths
std::vector<double> bandWavelengths() const;
private:
std::unique_ptr<RasterDataProvider> m_provider;
std::unique_ptr<RasterRenderer> m_renderer;
RenderParams m_currentParams;
};

86
HPPA/RasterRenderer.cpp Normal file
View File

@ -0,0 +1,86 @@
#include "RasterRenderer.h"
#include "RasterDataProvider.h"
#include <QDebug>
#include <algorithm>
RasterRenderer::RasterRenderer(RasterDataProvider* provider)
: m_provider(provider)
{
}
void RasterRenderer::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);
}
}
QImage RasterRenderer::render(const Params& params)
{
if (!m_provider) return QImage();
int bands = m_provider->bandCount();
int w = m_provider->width();
int h = m_provider->height();
if (w <= 0 || h <= 0) return QImage();
// Find nearest bands for requested wavelengths if wavelengths available
std::vector<double> wavelengths = m_provider->bandWavelengths();
auto chooseBandIndexForWave = [&](double wave)->int {
if (wavelengths.empty()) {
// fallback: select R,G,B as first three bands
if (bands >= 3) return (wave==params.rWave?0:(wave==params.gWave?1:2));
if (bands >= 1) return 0;
return -1;
}
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; }
}
if (best >= 0) return best;
// fallback
return std::min(2, bands-1);
};
int rIdx = chooseBandIndexForWave(params.rWave);
int gIdx = chooseBandIndexForWave(params.gWave);
int bIdx = chooseBandIndexForWave(params.bWave);
std::vector<float> rbuf, gbuf, bbuf;
if (rIdx >= 0) m_provider->readBandAsFloat(rIdx, rbuf);
if (gIdx >= 0) m_provider->readBandAsFloat(gIdx, gbuf);
if (bIdx >= 0) m_provider->readBandAsFloat(bIdx, bbuf);
std::vector<unsigned char> r8, g8, b8;
float minV = static_cast<float>(params.minValue);
float maxV = static_cast<float>(params.maxValue);
if (!rbuf.empty()) stretchTo8bit(rbuf, r8, minV, maxV);
if (!gbuf.empty()) stretchTo8bit(gbuf, g8, minV, maxV);
if (!bbuf.empty()) stretchTo8bit(bbuf, b8, minV, maxV);
QImage out(w, h, QImage::Format_RGB888);
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;
unsigned char rc = (r8.size() > (size_t)idx) ? r8[idx] : 0;
unsigned char gc = (g8.size() > (size_t)idx) ? g8[idx] : 0;
unsigned char bc = (b8.size() > (size_t)idx) ? b8[idx] : 0;
scan[x*3 + 0] = rc;
scan[x*3 + 1] = gc;
scan[x*3 + 2] = bc;
}
}
return out;
}

29
HPPA/RasterRenderer.h Normal file
View File

@ -0,0 +1,29 @@
#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);
};

View File

@ -1,4 +1,4 @@
#include "stdafx.h"
#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <iomanip>
@ -14,7 +14,7 @@ ResononNirImager::~ResononNirImager()
{
if (buffer != nullptr)
{
std::cout << "<EFBFBD>ͷŶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD>" << std::endl;
std::cout << "释放堆上内存" << std::endl;
free(buffer);
free(dark);
free(white);
@ -40,12 +40,12 @@ double ResononNirImager::getIntegrationTime()
double ResononNirImager::getGain()
{
//return m_ResononNirImager.get_gain();
return 0.0;//nir<EFBFBD><EFBFBD>֧<EFBFBD><EFBFBD>gian
return 0.0;//nir不支持gian
}
void ResononNirImager::setGain(const double gain)
{
//m_ResononNirImager.set_gain(gain);//nir<EFBFBD><EFBFBD>֧<EFBFBD><EFBFBD>gian
//m_ResononNirImager.set_gain(gain);//nir不支持gian
}
void ResononNirImager::setFramerate(const double frames_per_second)
@ -103,12 +103,12 @@ void ResononNirImager::setSpectraBin(int new_spectral_bin)
double ResononNirImager::auto_exposure()
{
//<EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ع<EFBFBD>ʱ<EFBFBD><EFBFBD>Ϊ<EFBFBD>ڵ<EFBFBD>ǰ֡<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
double x = 1 / getFramerate() * 1000;//<EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ع<EFBFBD>ʱ<EFBFBD><EFBFBD>
//第一步:先设置曝光时间为在当前帧率情况下最大
double x = 1 / getFramerate() * 1000;//获取最大毫秒曝光时间
reConnectImage();
setIntegrationTime(x);
//<EFBFBD>ڶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><EFBFBD>ѭ<EFBFBD><EFBFBD>Ѱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ع<EFBFBD>ʱ<EFBFBD><EFBFBD>
//第二步:通过循环寻找最佳曝光时间
imagerStartCollect();
while (true)
@ -117,7 +117,7 @@ double ResononNirImager::auto_exposure()
if (GetMaxValue(buffer, m_FrameSize) >= 4095)
{
setIntegrationTime(getIntegrationTime() * 0.8);
std::cout << "<EFBFBD>Զ<EFBFBD><EFBFBD>ع<EFBFBD>-----------" << std::endl;
std::cout << "自动曝光-----------" << std::endl;
}
else
{
@ -128,7 +128,7 @@ double ResononNirImager::auto_exposure()
reConnectImage();
//imagerStopCollect();
//std::cout << "<EFBFBD>Զ<EFBFBD><EFBFBD>ع⣺" << getIntegrationTime() << std::endl;
//std::cout << "自动曝光:" << getIntegrationTime() << std::endl;
return getIntegrationTime();
}
@ -151,7 +151,7 @@ int ResononNirImager::getSampleCount()
void ResononNirImager::focus()
{
m_iFocusFrameCounter = 1;
//std::cout << "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>-----------" << std::endl;
//std::cout << "调焦-----------" << std::endl;
double tmpFrmerate = getFramerate();
double tmpIntegrationTime = getIntegrationTime();
@ -159,7 +159,7 @@ void ResononNirImager::focus()
setFramerate(5);
auto_exposure();
std::cout << "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD><EFBFBD>ع<EFBFBD>ʱ<EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>" << getIntegrationTime() << std::endl;
std::cout << "调焦获得的曝光时间为:" << getIntegrationTime() << std::endl;
reConnectImage();
imagerStartCollect();
@ -183,12 +183,12 @@ void ResononNirImager::focus()
reConnectImage();
setIntegrationTime(tmpIntegrationTime);
setFramerate(tmpFrmerate);//<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
setFramerate(tmpFrmerate);//必须要放在这里,如果不放这里,这行代码就要出错。。。。。。
}
void ResononNirImager::record_dark()
{
std::cout << "<EFBFBD>ɼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>" << std::endl;
std::cout << "采集暗电流!!!!!!!!!" << std::endl;
reConnectImage();
imagerStartCollect();
@ -221,7 +221,7 @@ void ResononNirImager::record_dark()
void ResononNirImager::record_white()
{
std::cout << "<EFBFBD>ɼ<EFBFBD><EFBFBD>װ壡<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>" << std::endl;
std::cout << "采集白板!!!!!!!!!" << std::endl;
reConnectImage();
imagerStartCollect();
@ -247,7 +247,7 @@ void ResononNirImager::record_white()
imagerStopCollect();
//<EFBFBD>װ<EFBFBD><EFBFBD>۰<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//白板扣暗电流
if (m_HasDark)
{
for (size_t i = 0; i < m_FrameSize; i++)
@ -275,17 +275,23 @@ void ResononNirImager::start_record()
//std::cout << "------------------------------------------------------" << std::endl;
m_iFrameCounter = 0;
m_RgbImage->m_iFrameCounter = 0;//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>rgbͼ<EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD>0<EFBFBD><EFBFBD>
m_RgbImage->m_iFrameCounter = 0;//设置填充rgb图像的第0行
m_bRecordControlState = true;
//<EFBFBD>ж<EFBFBD><EFBFBD>ڴ<EFBFBD>buffer<EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//判断内存buffer是否正常分配
if (buffer == 0)
{
std::cerr << "Error: memory could not be allocated for datacube";
exit(EXIT_FAILURE);
}
// 在开始采集时仅发出文件信息UI 层自行创建 MapLayer 并管理生命周期
// prepare file name that will be used for saving
m_FileName2Save2 = m_FileName2Save + "_" + std::to_string(m_FileSavedCounter) + ".bil";
QString baseName = QString::fromStdString(getFileNameFromPath(m_FileName2Save2));
QString filePath = QString::fromStdString(m_FileName2Save2);
emit LayerFileCreated(baseName, filePath, m_FileSavedCounter);
FILE* m_fImage = fopen(m_FileName2Save2.c_str(), "w+b");
size_t x;
@ -294,7 +300,7 @@ void ResononNirImager::start_record()
string timesFile = removeFileExtension(m_FileName2Save2) + ".times";
FILE* hTimesFile = fopen(timesFile.c_str(), "w+");
reConnectImage();//nir<EFBFBD>ڶ<EFBFBD><EFBFBD>βɼ<EFBFBD>ʱ<EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>imagerStartCollect()<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
reConnectImage();//nir第二次采集时需要重新连接相机,否则函数imagerStartCollect()会报错。。。。。。
imagerStartCollect();
while (m_bRecordControlState)
{
@ -304,7 +310,7 @@ void ResononNirImager::start_record()
long long timeOs = getNanosecondsSinceMidnight();
//qDebug() << "time ns-------------------: " << timeOs;
//<EFBFBD><EFBFBD>ȥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӦΪbuffer<EFBFBD><EFBFBD>dark<EFBFBD><EFBFBD><EFBFBD><EFBFBD>unsigned short<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ե<EFBFBD>dark>bufferʱ<EFBFBD><EFBFBD>buffer-dark=65535
//减去暗电流,应为bufferdark都是unsigned short,所以当dark>buffer时,buffer-dark=65535
if (m_HasDark)
{
for (size_t i = 0; i < m_FrameSize; i++)
@ -322,12 +328,12 @@ void ResononNirImager::start_record()
}
//ת<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//转反射率
if (m_HasWhite)
{
for (size_t i = 0; i < m_FrameSize; i++)
{
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>װ壩Ϊ0<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//处理除数白板为0的情况
if (white[i] != 0)
{
pixelValueTmp = buffer[i];
@ -343,34 +349,38 @@ void ResononNirImager::start_record()
}
x = fwrite(buffer, 2, m_FrameSize, m_fImage);
fprintf(hTimesFile, "%lld\n", timeOs);
fprintf(hTimesFile, "%ll\n", timeOs);
//<EFBFBD><EFBFBD>rgb<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><EFBFBD>ڽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
//rgb波段提取出来,以便在界面中显示
m_RgbImage->FillRgbImage(buffer);//??????????????????????????????????????????????????????????????????????????????????????????????????????
//std::cout << "<EFBFBD><EFBFBD>" << m_iFrameCounter << "֡д<EFBFBD><EFBFBD>" << x << "<EFBFBD><EFBFBD>unsigned short<EFBFBD><EFBFBD>" << std::endl;
//std::cout << "" << m_iFrameCounter << "帧写了" << x << "unsigned short" << std::endl;
//ÿ<EFBFBD><EFBFBD>1s<EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>ν<EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD>λ<EFBFBD><EFBFBD><EFBFBD>
//每隔1s进行一次界面图形绘制
if (m_iFrameCounter % (int)getFramerate() == 0)
{
emit PlotSignal(m_FileSavedCounter, m_iFrameCounter);
emit PlotSignal(m_FileSavedCounter, m_iFrameCounter, filePath);
}
if (m_iFrameCounter >= m_iFrameNumber)
{
break;
//qDebug() << "<22><><EFBFBD><EFBFBD>ֹͣ<CDA3>ɼ<EFBFBD><C9BC><EFBFBD>֡<EFBFBD><D6A1><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD><C6B5>";
}
}
imagerStopCollect();
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>λ<EFBFBD>ͼǰ<EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//在最后一次画图前需要进行一次拉伸
//m_RgbImage
emit PlotSignal(m_FileSavedCounter, -1);//<2F>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD>ɺ<EFBFBD><C9BA><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>λ<EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD>Է<EFBFBD><D4B7>ɼ<EFBFBD>֡<EFBFBD><D6A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֡<EFBFBD>ʵı<CAB5><C4B1><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>ȫ
emit PlotSignal(m_FileSavedCounter, -1, filePath);//采集完成后进行一次画图,以防采集帧数不是帧率的倍数时,画图不全
m_bRecordControlState = false;
WriteHdr();
// 发射 ImageFileSaved 信号,通知 UI 层把该文件加入图层管理器
// m_FileName2Save2 保存了本次写入的 .bil 文件名(例如 "tmp_image_0.bil"
emit ImageFileSaved(QString::fromStdString(m_FileName2Save2), m_FileSavedCounter);
m_FileSavedCounter++;
if (m_iFrameCounter >= m_iFrameNumber)

View File

@ -1,4 +1,4 @@
#pragma once
#pragma once
#include <string>
#include <opencv2/core/core.hpp>

View File

@ -1,4 +1,4 @@
#include "stdafx.h"
#include "stdafx.h"
#include "RgbCameraOperation.h"
RgbCameraOperation::RgbCameraOperation()
@ -14,14 +14,14 @@ RgbCameraOperation::~RgbCameraOperation()
void RgbCameraOperation::OpenCamera()
{
std::cout << "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ+++++++++++++++++++++++++++++++++++++++++++" << std::endl;
std::cout << "打开摄像头+++++++++++++++++++++++++++++++++++++++++++" << std::endl;
cam = new cv::VideoCapture(0);
record = true;
while (record)
{
//std::cout << "<EFBFBD>ɼ<EFBFBD>Ӱ<EFBFBD><EFBFBD>+++++++++++++++++++++++++++++++++++++++++++" << std::endl;
//std::cout << "采集影像+++++++++++++++++++++++++++++++++++++++++++" << std::endl;
cam->read(frame);
m_qImage = m_ImageProcessor->Mat2QImage(frame);
@ -30,20 +30,20 @@ void RgbCameraOperation::OpenCamera()
cam->release();
emit CamClosed();
emit CamOpenedSignal();
}
void RgbCameraOperation::OpenCamera_callback()
{
std::cout << "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ+++++++++++++++++++++++++++++++++++++++++++" << std::endl;
std::cout << "打开摄像头+++++++++++++++++++++++++++++++++++++++++++" << std::endl;
cam = new cv::VideoCapture(0);
record = true;
while (record)
{
//std::cout << "<EFBFBD>ɼ<EFBFBD>Ӱ<EFBFBD><EFBFBD>+++++++++++++++++++++++++++++++++++++++++++" << std::endl;
//std::cout << "采集影像+++++++++++++++++++++++++++++++++++++++++++" << std::endl;
cam->read(frame);
m_qImage = m_ImageProcessor->Mat2QImage(frame);
@ -62,7 +62,9 @@ void RgbCameraOperation::setCallback(void(*func)())
void RgbCameraOperation::CloseCamera()
{
std::cout << "<EFBFBD>ر<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ+++++++++++++++++++++++++++++++++++++++++++" << std::endl;
std::cout << "关闭摄像头+++++++++++++++++++++++++++++++++++++++++++" << std::endl;
record = false;
emit CamClosedSignal();
}

View File

@ -1,4 +1,4 @@
#pragma once
#pragma once
#ifndef RGBCAMERAOPERATION_H
#define RGBCAMERAOPERATION_H
@ -36,12 +36,13 @@ private:
public slots:
void OpenCamera();
void OpenCamera_callback();//<EFBFBD><EFBFBD>ʹ<EFBFBD><EFBFBD><EFBFBD>źŶ<EFBFBD>ʹ<EFBFBD>ûص<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֪ͨ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˢ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƶ
void OpenCamera_callback();//不使用信号而使用回调函数来通知界面刷新视频
void CloseCamera();
signals:
void PlotSignal();
void CamClosed();
void CamOpenedSignal();
void CamClosedSignal();
};
#endif // !RGBCAMERAOPERATION_H

View File

@ -1,4 +1,4 @@
#include "RobotArmControl.h"
#include "RobotArmControl.h"
RobotArmControl::RobotArmControl(QWidget* parent): QDialog(parent)
{
@ -82,7 +82,7 @@ void RobotArmControl::getTaskList()
files.append(line.trimmed());
}
////<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD>Ȼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
////先清除数据,然后添加数据
//for (size_t i = 0; i < files.length(); i++)
//{
// int row = m_pModel->rowCount();
@ -112,7 +112,7 @@ void RobotArmControl::executeTaskWithHyperImager()
QModelIndex index = ui.taskList_listView->currentIndex();
if (-1 == index.row())
{
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD>û<EFBFBD>ѡ<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
//弹窗提示用户选择文件
ui.textEdit->append("Please select file on the left!");
return;
}
@ -148,7 +148,7 @@ void RobotArmControl::executeTaskWithoutHyperImager()
QModelIndex index = ui.taskList_listView->currentIndex();
if (-1 == index.row())
{
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD>û<EFBFBD>ѡ<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
//弹窗提示用户选择文件
ui.textEdit->append("Please select file on the left!");
return;
}
@ -290,7 +290,7 @@ bool RobotController::processResponse_getJbiState(QJsonObject response, QString&
void RobotController::getPoint()
{
QJsonObject response;
getJbiState(response);//0 ֹͣ״̬,1 <20><>ͣ״̬,2 <20><>ͣ״̬,3 <20><><EFBFBD><EFBFBD>״̬,4 <20><><EFBFBD><EFBFBD>״̬
getJbiState(response);//0 停止状态,1 暂停状态,2 急停状态,3 运行状态,4 错误状态
QString result;
bool x = processResponse_getJbiState(response, result);
//qDebug() << "getJbiState:" << result;
@ -302,7 +302,7 @@ void RobotController::getPoint()
m_iCurrentJbiJobLine = 0;
m_iFileCounter = 0;
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>źţ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֹͣ<EFBFBD>ɼ<EFBFBD>
//发射信号,相机停止采集
emit hsiRecordSignal(-1);
return;
@ -321,12 +321,12 @@ void RobotController::getPoint()
m_iFileCounter++;
qDebug() << "Changed! CurrentJobLine:" << m_iCurrentJbiJobLine_tmp;
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>źţ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֹͣ<EFBFBD>ɼ<EFBFBD>
//发射信号,相机停止采集
emit hsiRecordSignal(-1);
m_iCurrentJbiJobLine = m_iCurrentJbiJobLine_tmp;
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>źţ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD>ɼ<EFBFBD>
//发射信号,相机开始采集
emit hsiRecordSignal(m_iFileCounter);
}
}
@ -421,7 +421,7 @@ bool RobotController::getRobotMode(QJsonObject& re)
bool RobotController::checkJbiExist(const QString& jbiFilename, QJsonObject& re)
{
QJsonObject paramsRunJbi;
paramsRunJbi["filename"] = jbiFilename;//ʹ<EFBFBD>ö<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
paramsRunJbi["filename"] = jbiFilename;//使用对象结构
sendCommand("checkJbiExist", paramsRunJbi);
socket->waitForReadyRead(m_iTimeout);
@ -432,7 +432,7 @@ bool RobotController::checkJbiExist(const QString& jbiFilename, QJsonObject& re)
bool RobotController::setServoStatus(int status, QJsonObject& re)
{
QJsonObject params_set_servo_status;
params_set_servo_status["status"] = status;//ʹ<EFBFBD>ö<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
params_set_servo_status["status"] = status;//使用对象结构
sendCommand("set_servo_status", params_set_servo_status);
socket->waitForReadyRead(m_iTimeout);
@ -443,7 +443,7 @@ bool RobotController::setServoStatus(int status, QJsonObject& re)
bool RobotController::runJbi(const QString& jbiFilename, QJsonObject& re, bool isRecordHsi)
{
QJsonObject paramsRunJbi;
paramsRunJbi["filename"] = jbiFilename;//ʹ<EFBFBD>ö<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
paramsRunJbi["filename"] = jbiFilename;//使用对象结构
sendCommand("runJbi", paramsRunJbi);
socket->waitForReadyRead(m_iTimeout);

View File

@ -1,4 +1,4 @@
#pragma once
#pragma once
#include <qdialog.h>
#include <QTcpSocket>
#include <QJsonDocument>
@ -26,33 +26,33 @@ struct ECData
quint32 msgSize;
quint64 timeStamp;
quint8 auto_cycle;
double machinePos[8];//<EFBFBD>ؽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
double machinePose[6];//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
double machineUserPose[6];//<EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
double torque[8];//<EFBFBD>ؽڶ<EFBFBD><EFBFBD><EFBFBD>ذٷֱ<EFBFBD>
quint32 robotState;//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬
quint32 servoReady;//<EFBFBD>ŷ<EFBFBD>ʹ<EFBFBD><EFBFBD>״̬
quint32 can_motor_run;//ͬ<EFBFBD><EFBFBD>״̬
qint32 motor_speed[8];//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><EFBFBD>
quint32 robotMode;//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ
double analog_ioInput[3];//ģ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
double analog_ioOutput[5];//ģ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
quint64 digital_ioInput;//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵĶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ
quint64 digital_ioOutput;//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵĶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ
quint8 collision;//<EFBFBD><EFBFBD>ײ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬
double machineFlangePose[6];//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD>µķ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD>
double machineUserFlangePose[6];//<EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD>µķ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD>
quint8 emergencyStopState;//<EFBFBD><EFBFBD>ǰ<EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڼ<EFBFBD>ͣ״̬
double tcpSpeed;//tcp<EFBFBD>˶<EFBFBD><EFBFBD>ٶ<EFBFBD>
double joIntSpeed[8];//<EFBFBD>ؽ<EFBFBD><EFBFBD>˶<EFBFBD><EFBFBD>¸<EFBFBD><EFBFBD>ؽ<EFBFBD><EFBFBD>˶<EFBFBD><EFBFBD>ٶ<EFBFBD>
double tcpAcc;//tcp<EFBFBD><EFBFBD><EFBFBD>ٶ<EFBFBD>
double joIntAcc[8];//<EFBFBD>ؽ<EFBFBD><EFBFBD>˶<EFBFBD><EFBFBD>¸<EFBFBD><EFBFBD>ؽڼ<EFBFBD><EFBFBD>ٶ<EFBFBD>
double joIntTemperature[6];//<EFBFBD><EFBFBD>
double joIntTorque[6];//<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ť<EFBFBD><EFBFBD>
double extJoIntTorques[6];//<EFBFBD>ⲿ<EFBFBD>ؽ<EFBFBD>Ť<EFBFBD><EFBFBD>ֵ
double exTcpForceIntool[6];//<EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD>µ<EFBFBD><EFBFBD>ⲿĩ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>/<2F><><EFBFBD>ع<EFBFBD><D8B9><EFBFBD>ֵ
quint8 dragState;//<EFBFBD>϶<EFBFBD>ʹ<EFBFBD><EFBFBD>״̬
quint8 sensor_connected_state;//<EFBFBD><EFBFBD><EFBFBD>ش<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬
double machinePos[8];//关节坐标
double machinePose[6];//基座坐标
double machineUserPose[6];//用户坐标
double torque[8];//关节额定力矩百分比
quint32 robotState;//机器人状态
quint32 servoReady;//伺服使能状态
quint32 can_motor_run;//同步状态
qint32 motor_speed[8];//各轴电机转速
quint32 robotMode;//机器人模式
double analog_ioInput[3];//模拟量输入口数据
double analog_ioOutput[5];//模拟量输出口数据
quint64 digital_ioInput;//数字量输入口数据的二进制形式
quint64 digital_ioOutput;//数字量输出口数据的二进制形式
quint8 collision;//碰撞报警状态
double machineFlangePose[6];//基座坐标系下的法兰盘中心位姿
double machineUserFlangePose[6];//用户坐标系下的法兰盘中心位姿
quint8 emergencyStopState;//当前是否处于急停状态
double tcpSpeed;//tcp运动速度
double joIntSpeed[8];//关节运动下各关节运动速度
double tcpAcc;//tcp加速度
double joIntAcc[8];//关节运动下各关节加速度
double joIntTemperature[6];//温度
double joIntTorque[6];//输出扭矩
double extJoIntTorques[6];//外部关节扭矩值
double exTcpForceIntool[6];//当前工具坐标系下的外部末端力/力矩估计值
quint8 dragState;//拖动使能状态
quint8 sensor_connected_state;//力控传感器连接状态
quint8 reserved;
quint32 matchingWord;
};
@ -98,10 +98,10 @@ public:
bool processResponse_getJbiState(QJsonObject response, QString& result);
bool getRobotPose(QJsonObject& re);
bool getRobotState(QJsonObject& re);//ֹͣ״̬ 0<><30><EFBFBD><EFBFBD>ͣ״̬ 1<><31><EFBFBD><EFBFBD>ͣ״̬ 2<><32><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬ 3<><33><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬ 4<><34><EFBFBD><EFBFBD>ײ״̬ 5
bool getJbiState(QJsonObject& re);//0 ֹͣ״̬,1 <20><>ͣ״̬,2 <20><>ͣ״̬,3 <20><><EFBFBD><EFBFBD>״̬,4 <20><><EFBFBD><EFBFBD>״̬
bool getRobotState(QJsonObject& re);//停止状态 0暂停状态 1急停状态 2运行状态 3报警状态 4碰撞状态 5
bool getJbiState(QJsonObject& re);//0 停止状态,1 暂停状态,2 急停状态,3 运行状态,4 错误状态
bool getCurrentJobLine(QJsonObject& re);
bool getRobotMode(QJsonObject& re);//ʾ<EFBFBD><EFBFBD>ģʽ 0<><30><EFBFBD>Զ<EFBFBD>ģʽ 1<><31>Զ<EFBFBD><D4B6>ģʽ 2
bool getRobotMode(QJsonObject& re);//示教模式 0自动模式 1远程模式 2
bool checkJbiExist(const QString& jbiFilename, QJsonObject& re);
bool setServoStatus(int status, QJsonObject& re);
bool runJbi(const QString& jbiFilename, QJsonObject& re, bool isRecordHsi);

62
HPPA/TabManager.cpp Normal file
View File

@ -0,0 +1,62 @@
#include "TabManager.h"
TabManager::TabManager(QTabWidget* tabWidget, QObject* parent)
: QObject(parent),
m_tabWidget(tabWidget)
{
Q_ASSERT(m_tabWidget);
}
void TabManager::hideTab(QWidget* page)
{
if (!page || !m_tabWidget)
return;
int index = m_tabWidget->indexOf(page);
if (index == -1)
return;
if (m_hiddenTabs.contains(page))
return;
TabInfo info;
info.index = index;
info.text = m_tabWidget->tabText(index);
info.icon = m_tabWidget->tabIcon(index);
info.toolTip = m_tabWidget->tabToolTip(index);
m_hiddenTabs.insert(page, info);
// 如果隐藏的是当前页,先切换,避免空白
if (m_tabWidget->currentIndex() == index)
{
int next = (index > 0) ? index - 1 : 0;
m_tabWidget->setCurrentIndex(next);
}
m_tabWidget->removeTab(index);
emit tabHidden(page);
}
void TabManager::showTab(QWidget* page)
{
if (!page || !m_tabWidget)
return;
if (!m_hiddenTabs.contains(page))
return;
TabInfo info = m_hiddenTabs.take(page);
//int insertIndex = qMin(info.index, m_tabWidget->count());
int insertIndex = m_tabWidget->count();
m_tabWidget->insertTab(insertIndex, page, info.icon, info.text);
m_tabWidget->setTabToolTip(insertIndex, info.toolTip);
emit tabShown(page);
}
bool TabManager::isHidden(QWidget* page) const
{
return m_hiddenTabs.contains(page);
}

32
HPPA/TabManager.h Normal file
View File

@ -0,0 +1,32 @@
#pragma once
#include <QObject>
#include <QTabWidget>
#include <QHash>
class TabManager : public QObject
{
Q_OBJECT
public:
explicit TabManager(QTabWidget* tabWidget, QObject* parent = nullptr);
void hideTab(QWidget* page);
void showTab(QWidget* page);
bool isHidden(QWidget* page) const;
signals:
void tabHidden(QWidget* page);
void tabShown(QWidget* page);
private:
struct TabInfo
{
int index;
QString text;
QIcon icon;
QString toolTip;
};
QTabWidget* m_tabWidget = nullptr;
QHash<QWidget*, TabInfo> m_hiddenTabs;
};

View File

@ -5,7 +5,6 @@ TwoMotorControl::TwoMotorControl(QWidget* parent) : QDialog(parent)
ui.setupUi(this);
ui.recordLine_tableWidget->setFocusPolicy(Qt::NoFocus);
ui.recordLine_tableWidget->setStyleSheet("selection-background-color:rgb(255,209,128)");//设置选择的行高亮
ui.recordLine_tableWidget->setSelectionBehavior(QAbstractItemView::SelectRows);//设置选择行为,以行为单位
//ui.recordLine_tableWidget->setSelectionMode(QAbstractItemView::SingleSelection);//设置选择模式,选择单行
@ -16,13 +15,25 @@ TwoMotorControl::TwoMotorControl(QWidget* parent) : QDialog(parent)
connect(ui.addRecordLine_btn, SIGNAL(clicked()), this, SLOT(onAddRecordLine_btn()));
connect(ui.removeRecordLine_btn, SIGNAL(clicked()), this, SLOT(onRemoveRecordLine_btn()));
connect(ui.generateRecordLine_btn, SIGNAL(clicked()), this, SLOT(onGenerateRecordLine_btn()));
connect(ui.deleteRecordLine_btn, SIGNAL(clicked()), this, SLOT(onDeleteRecordLine_btn()));
connect(ui.saveRecordLine2File_btn, SIGNAL(clicked()), this, SLOT(onSaveRecordLine2File_btn()));
connect(ui.readRecordLineFile_btn, SIGNAL(clicked()), this, SLOT(onReadRecordLineFile_btn()));
connect(ui.run_btn, SIGNAL(clicked()), this, SLOT(run()));
connect(ui.stop_btn, SIGNAL(clicked()), this, SLOT(stop()));
connect(this->ui.xmotor_right_btn, SIGNAL(pressed()), this, SLOT(onxMotorRight()));
connect(this->ui.xmotor_right_btn, SIGNAL(released()), this, SLOT(onxMotorStop()));
connect(this->ui.xmotor_left_btn, SIGNAL(pressed()), this, SLOT(onxMotorLeft()));
connect(this->ui.xmotor_left_btn, SIGNAL(released()), this, SLOT(onxMotorStop()));
connect(this->ui.ymotor_forward_btn, SIGNAL(pressed()), this, SLOT(onyMotorforward()));
connect(this->ui.ymotor_forward_btn, SIGNAL(released()), this, SLOT(onyMotorStop()));
connect(this->ui.ymotor_backward_btn, SIGNAL(pressed()), this, SLOT(onyMotorbackward()));
connect(this->ui.ymotor_backward_btn, SIGNAL(released()), this, SLOT(onyMotorStop()));
connect(this->ui.move2loc_x_pushButton, SIGNAL(pressed()), this, SLOT(onxMove2Loc()));
connect(this->ui.move2loc_y_pushButton, SIGNAL(pressed()), this, SLOT(onyMove2Loc()));
connect(this->ui.zero_start_btn, SIGNAL(released()), this, SLOT(zeroStart()));
connect(this->ui.rangeMeasurement_btn, SIGNAL(pressed()), this, SLOT(on_rangeMeasurement()));
}
void TwoMotorControl::setImager(ImagerOperationBase* imager)
@ -39,6 +50,9 @@ void TwoMotorControl::setPosFileName(QString posFileName)
bool TwoMotorControl::getState()
{
if (m_coordinator == nullptr)
return false;
QEventLoop loop;
bool tmp = false;
bool received = false;
@ -91,8 +105,21 @@ void TwoMotorControl::record_white()
void TwoMotorControl::run()
{
if (m_coordinator==nullptr)
if (getState())
{
QMessageBox::information(this, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("已经开始运行,请勿重复点击!"));
return;
}
int rowCount = ui.recordLine_tableWidget->rowCount();
if(rowCount == 0)
{
QMessageBox::information(this, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("请至少添加一行采集线!"));
emit sequenceComplete();
return;
}
qRegisterMetaType<QVector<PathLine>>("QVector<PathLine>");
m_coordinator = new TwoMotionCaptureCoordinator(m_multiAxisController, m_Imager);
m_coordinator->moveToThread(&m_coordinatorThread);
@ -103,17 +130,8 @@ void TwoMotorControl::run()
connect(m_coordinator, SIGNAL(finishRecordLineNumSignal(int)), this, SLOT(receiveFinishRecordLineNum(int)));
connect(m_coordinator, SIGNAL(sequenceComplete(int)), this, SLOT(onSequenceComplete()));
m_coordinatorThread.start();
}
if (getState())
{
//std::cout << "已经开始运行,请勿重复点击!!!!!!!!" << std::endl;
QMessageBox::information(this, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("已经开始运行,请勿重复点击!!!!!!!!!"));
return;
}
QVector<PathLine> pathLines;
int rowCount = ui.recordLine_tableWidget->rowCount();
//int columnCount = ui.recordLine_tableWidget->columnCount();
for (size_t i = 0; i < rowCount; i++)
{
@ -133,7 +151,7 @@ void TwoMotorControl::run()
{
for (size_t j = 0; j < ui.recordLine_tableWidget->columnCount(); j++)
{
ui.recordLine_tableWidget->item(i, j)->setBackgroundColor(QColor(240, 240, 240));
ui.recordLine_tableWidget->item(i, j)->setBackgroundColor(QColor("#0E1C4C"));
}
}
@ -156,6 +174,30 @@ TwoMotorControl::~TwoMotorControl()
void TwoMotorControl::onConnectMotor()
{
if (getMotorsConnectionStatus())
{
QMessageBox msgBox;
msgBox.setText(QString::fromLocal8Bit("马达已连接!"));
msgBox.exec();
return;
}
if (m_multiAxisController != nullptr)
{
disconnect(m_multiAxisController, SIGNAL(broadcastLocationSignal(std::vector<double>)), this, SLOT(displayRealTimeLoc(std::vector<double>)));
disconnect(this, SIGNAL(moveSignal(int, bool, double, int)), m_multiAxisController, SLOT(move(int, bool, double, int)));
disconnect(this, SIGNAL(move2LocSignal(int, double, double, int)), m_multiAxisController, SLOT(moveTo(int, double, double, int)));
disconnect(this, SIGNAL(stopSignal(int)), m_multiAxisController, SLOT(stop(int)));
disconnect(this, SIGNAL(zeroStartSignal(int)), m_multiAxisController, SLOT(zeroStart(int)));
disconnect(this, SIGNAL(rangeMeasurement(int, double, int)), m_multiAxisController, SLOT(rangeMeasurement(int, double, int)));
disconnect(this, SIGNAL(testConnectivitySignal(int, int)), m_multiAxisController, SLOT(testConnectivity(int, int)));
disconnect(m_multiAxisController, SIGNAL(broadcastConnectivity(std::vector<int>)), this, SLOT(display_motors_connectivity(std::vector<int>)));
m_motorThread.quit();
m_motorThread.wait();
m_multiAxisController = nullptr;
}
try
{
FileOperation* fileOperation = new FileOperation();
@ -169,33 +211,20 @@ void TwoMotorControl::onConnectMotor()
QMessageBox msgBox;
msgBox.setText(QString::fromLocal8Bit("请连接马达!"));
msgBox.exec();
return;
}
m_multiAxisController->moveToThread(&m_motorThread);
connect(&m_motorThread, SIGNAL(finished()), m_multiAxisController, SLOT(deleteLater()));
connect(this->ui.xmotor_right_btn, SIGNAL(pressed()), this, SLOT(onxMotorRight()));
connect(this->ui.xmotor_right_btn, SIGNAL(released()), this, SLOT(onxMotorStop()));
connect(this->ui.xmotor_left_btn, SIGNAL(pressed()), this, SLOT(onxMotorLeft()));
connect(this->ui.xmotor_left_btn, SIGNAL(released()), this, SLOT(onxMotorStop()));
connect(this->ui.ymotor_forward_btn, SIGNAL(pressed()), this, SLOT(onyMotorforward()));
connect(this->ui.ymotor_forward_btn, SIGNAL(released()), this, SLOT(onyMotorStop()));
connect(this->ui.ymotor_backward_btn, SIGNAL(pressed()), this, SLOT(onyMotorbackward()));
connect(this->ui.ymotor_backward_btn, SIGNAL(released()), this, SLOT(onyMotorStop()));
//connect(this->ui.move2loc_pushButton, SIGNAL(pressed()), this, SLOT(onxMove2Loc()));
connect(m_multiAxisController, SIGNAL(broadcastLocationSignal(std::vector<double>)), this, SLOT(displayRealTimeLoc(std::vector<double>)));
connect(this, SIGNAL(moveSignal(int, bool, double, int)), m_multiAxisController, SLOT(move(int, bool, double, int)));
//connect(this, SIGNAL(move2LocSignal(int, double, double, int)), m_multiAxisController, SLOT(moveTo(int, double, double, int)));
connect(this, SIGNAL(move2LocSignal(int, double, double, int)), m_multiAxisController, SLOT(moveTo(int, double, double, int)));
connect(this, SIGNAL(stopSignal(int)), m_multiAxisController, SLOT(stop(int)));
connect(this->ui.zero_start_btn, SIGNAL(released()), this, SLOT(zeroStart()));
connect(this, SIGNAL(zeroStartSignal(int)), m_multiAxisController, SLOT(zeroStart(int)));
connect(this->ui.rangeMeasurement_btn, SIGNAL(pressed()), this, SLOT(on_rangeMeasurement()));
connect(this, SIGNAL(rangeMeasurement(int, double, int)), m_multiAxisController, SLOT(rangeMeasurement(int, double, int)));
connect(this, SIGNAL(testConnectivitySignal(int, int)), m_multiAxisController, SLOT(testConnectivity(int, int)));
@ -228,28 +257,78 @@ void TwoMotorControl::onSequenceComplete()
isWritePosFile = false;
fclose(m_posFileHandle);
m_coordinatorThread.quit();
m_coordinatorThread.wait();
m_coordinator = nullptr;
emit sequenceComplete();
}
bool TwoMotorControl::getMotorsConnectionStatus()
{
return m_xMotorConnectionStatus && m_yMotorConnectionStatus;
}
void TwoMotorControl::display_motors_connectivity(std::vector<int> connectivity)
{
//std::cout << "-----------------------------------"<<connectivity.size()<< std::endl;
if (connectivity[0])
{
this->ui.xMotorStateLabel->setStyleSheet("QLabel{background-color:rgb(0,255,0);}");
m_xMotorConnectionStatus = true;
this->ui.xMotorStateLabel->setStyleSheet(R"(
QLabel
{
background-color: #08FACE;
border-radius: 4px;
}
)");
}
else
{
this->ui.xMotorStateLabel->setStyleSheet("QLabel{background-color:rgb(255,0,0);}");
m_xMotorConnectionStatus = false;
this->ui.xMotorStateLabel->setStyleSheet(R"(
QLabel
{
background-color: red;
border-radius: 4px;
}
)");
}
if (connectivity[1])
{
this->ui.yMotorStateLabel->setStyleSheet("QLabel{background-color:rgb(0,255,0);}");
m_yMotorConnectionStatus = true;
this->ui.yMotorStateLabel->setStyleSheet(R"(
QLabel
{
background-color: #08FACE;
border-radius: 4px;
}
)");
}
else
{
this->ui.yMotorStateLabel->setStyleSheet("QLabel{background-color:rgb(255,0,0);}");
m_yMotorConnectionStatus = false;
this->ui.yMotorStateLabel->setStyleSheet(R"(
QLabel
{
background-color: red;
border-radius: 4px;
}
)");
}
if(getMotorsConnectionStatus())
{
this->ui.connect_btn->setText(QString::fromLocal8Bit("已连接"));
}
else
{
this->ui.connect_btn->setText(QString::fromLocal8Bit("重新连接"));
}
}
@ -291,6 +370,22 @@ void TwoMotorControl::onyMotorStop()
emit stopSignal(1);
}
void TwoMotorControl::onxMove2Loc()
{
double s = ui.xmotor_move_speed_lineEdit->text().toDouble();
double l = ui.move2loc_x_lineEdit->text().toDouble();
emit move2LocSignal(0, l, s, 1000);
}
void TwoMotorControl::onyMove2Loc()
{
double s = ui.ymotor_move_speed_lineEdit->text().toDouble();
double l = ui.move2loc_y_lineEdit->text().toDouble();
emit move2LocSignal(1, l, s, 1000);
}
void TwoMotorControl::displayRealTimeLoc(std::vector<double> loc)
{
double tmp = round(loc[0] * 100) / 100;
@ -303,6 +398,8 @@ void TwoMotorControl::displayRealTimeLoc(std::vector<double> loc)
tmp = round(loc[1] * 100) / 100;
this->ui.ymotor_realTimeLoc_lineEdit->setText(QString::number(tmp));
emit broadcastLocationSignal(loc);
}
void TwoMotorControl::zeroStart()
@ -376,93 +473,6 @@ void TwoMotorControl::onRemoveRecordLine_btn()
ui.recordLine_tableWidget->removeRow(rowIndex);
}
void TwoMotorControl::onGenerateRecordLine_btn()
{
//求幅宽
double height = ui.height_lineEdit->text().toDouble();
double fov = ui.fov_lineEdit->text().toDouble();
double swath = (height * tan(fov / 2 * PI / 180)) * 2;//tan输入是弧度
ui.swath_lineEdit->setText(QString::number(swath));
//读取马达测量范围
double xMotorRange = 50;
double yMotorRange = 500;
//确定有多少条采集线公式numberOfRecordLine_tmp * swath - repetitiveLengthnumberOfRecordLine_tmp - 1 = overallLength
double overallLength = yMotorRange + swath;
double repetitiveRate = ui.repetitiveRate_lineEdit->text().toDouble() / 100;
double repetitiveLength = repetitiveRate * swath;
double offset = ui.offset_lineEdit->text().toDouble();
double numberOfRecordLine_tmp = (overallLength - repetitiveLength - offset) / (swath - repetitiveLength);
double tmp = numberOfRecordLine_tmp - (int)numberOfRecordLine_tmp;
int numberOfRecordLine;
double threshold = ui.LastLineThreshold_lineEdit->text().toDouble();//当numberOfRecordLine_tmp为小数时判断是否多加一条采集线
if (tmp > threshold)
{
numberOfRecordLine = (int)numberOfRecordLine_tmp + 1;
//std::cout << "大于:" << threshold << std::endl;
}
else
{
numberOfRecordLine = (int)numberOfRecordLine_tmp;
}
//去掉tableWidget中所有的行
int rowCount = ui.recordLine_tableWidget->rowCount();
for (size_t i = 0; i < rowCount; i++)
{
ui.recordLine_tableWidget->removeRow(0);
}
//向tableWidget添加行采集线
QTableWidgetItem* tmpItem;
for (size_t i = 0; i < numberOfRecordLine; i++)
{
//增加一行
int RowCount = ui.recordLine_tableWidget->rowCount();
ui.recordLine_tableWidget->insertRow(RowCount);
//设置yPosition
if (tmp > threshold && i == numberOfRecordLine - 1)//设置最后一行的yPosition
{
tmpItem = new QTableWidgetItem(QString::number(yMotorRange, 10, 2));
tmpItem->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
ui.recordLine_tableWidget->setItem(i, 0, tmpItem);
}
else
{
double x = swath * i - i * repetitiveLength + offset;
tmpItem = new QTableWidgetItem(QString::number(x, 10, 2));
tmpItem->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
ui.recordLine_tableWidget->setItem(i, 0, tmpItem);
}
tmpItem = new QTableWidgetItem(QString::number(1, 10, 2));
tmpItem->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
ui.recordLine_tableWidget->setItem(i, 1, tmpItem);
tmpItem = new QTableWidgetItem(QString::number(0, 10, 2));
tmpItem->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
ui.recordLine_tableWidget->setItem(i, 2, tmpItem);
tmpItem = new QTableWidgetItem(QString::number(1, 10, 2));
tmpItem->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
ui.recordLine_tableWidget->setItem(i, 3, tmpItem);
//设置x马达最大运动位置 → 值设置为x马达量程
tmpItem = new QTableWidgetItem(QString::number(xMotorRange, 10, 2));
tmpItem->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
ui.recordLine_tableWidget->setItem(i, 4, tmpItem);
tmpItem = new QTableWidgetItem(QString::number(1, 10, 2));
tmpItem->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
ui.recordLine_tableWidget->setItem(i, 5, tmpItem);
}
}
void TwoMotorControl::onDeleteRecordLine_btn()
{
int rowCount = ui.recordLine_tableWidget->rowCount();
@ -481,19 +491,12 @@ void TwoMotorControl::onSaveRecordLine2File_btn()
return;
}
double height = ui.height_lineEdit->text().toDouble();
double fov = ui.fov_lineEdit->text().toDouble();
double swath = ui.swath_lineEdit->text().toDouble();
double offset = ui.offset_lineEdit->text().toDouble();
double repetitiveRate = ui.repetitiveRate_lineEdit->text().toDouble();
double LastLineThreshold = ui.LastLineThreshold_lineEdit->text().toDouble();
FileOperation* fileOperation = new FileOperation();
string directory = fileOperation->getDirectoryOfExe();
QString RecordLineFilePath = QFileDialog::getSaveFileName(this, tr("Save RecordLine2 File"),
QString RecordLineFilePath = QFileDialog::getSaveFileName(this, tr("Save RecordLine3 File"),
QString::fromStdString(directory),
tr("RecordLineFile2 (*.RecordLine2)"));
tr("RecordLineFile3 (*.RecordLine3)"));
if (RecordLineFilePath.isEmpty())
{
@ -502,13 +505,6 @@ void TwoMotorControl::onSaveRecordLine2File_btn()
FILE* RecordLineFileHandle = fopen(RecordLineFilePath.toStdString().c_str(), "wb+");
fwrite(&height, sizeof(double), 1, RecordLineFileHandle);
fwrite(&fov, sizeof(double), 1, RecordLineFileHandle);
fwrite(&swath, sizeof(double), 1, RecordLineFileHandle);
fwrite(&offset, sizeof(double), 1, RecordLineFileHandle);
fwrite(&repetitiveRate, sizeof(double), 1, RecordLineFileHandle);
fwrite(&LastLineThreshold, sizeof(double), 1, RecordLineFileHandle);
double number = ui.recordLine_tableWidget->rowCount() * ui.recordLine_tableWidget->columnCount();
fwrite(&number, sizeof(double), 1, RecordLineFileHandle);
@ -527,7 +523,7 @@ void TwoMotorControl::onSaveRecordLine2File_btn()
fclose(RecordLineFileHandle);
delete[] data;
QMessageBox::information(this, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("保存成功!"));
//QMessageBox::information(this, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("保存成功!"));
}
void TwoMotorControl::onReadRecordLineFile_btn()
@ -536,9 +532,9 @@ void TwoMotorControl::onReadRecordLineFile_btn()
FileOperation* fileOperation = new FileOperation();
string directory = fileOperation->getDirectoryOfExe();
QString RecordLineFilePath = QFileDialog::getOpenFileName(this, tr("Open RecordLine2 File"),
QString RecordLineFilePath = QFileDialog::getOpenFileName(this, tr("Open RecordLine3 File"),
QString::fromStdString(directory),
tr("RecordLineFile (*.RecordLine2)"));
tr("RecordLineFile (*.RecordLine3)"));
if (RecordLineFilePath.isEmpty())
{
@ -546,15 +542,9 @@ void TwoMotorControl::onReadRecordLineFile_btn()
}
FILE* RecordLineFileHandle = fopen(RecordLineFilePath.toStdString().c_str(), "rb");
double height, fov, swath, offset, repetitiveRate, LastLineThreshold, number;
double number;
//读取数据
fread(&height, sizeof(double), 1, RecordLineFileHandle);
fread(&fov, sizeof(double), 1, RecordLineFileHandle);
fread(&swath, sizeof(double), 1, RecordLineFileHandle);
fread(&offset, sizeof(double), 1, RecordLineFileHandle);
fread(&repetitiveRate, sizeof(double), 1, RecordLineFileHandle);
fread(&LastLineThreshold, sizeof(double), 1, RecordLineFileHandle);
fread(&number, sizeof(double), 1, RecordLineFileHandle);
double* data = new double[number];
@ -564,15 +554,6 @@ void TwoMotorControl::onReadRecordLineFile_btn()
//std::cout << *(data + i) << std::endl;
}
//向界面中填写
ui.height_lineEdit->setText(QString::number(height));
ui.fov_lineEdit->setText(QString::number(fov));
ui.swath_lineEdit->setText(QString::number(swath));
ui.offset_lineEdit->setText(QString::number(offset));
ui.repetitiveRate_lineEdit->setText(QString::number(repetitiveRate));
ui.LastLineThreshold_lineEdit->setText(QString::number(LastLineThreshold));
//向tableWidget添加采集线
//1去掉tableWidget中所有的行
int rowCount = ui.recordLine_tableWidget->rowCount();
@ -601,5 +582,5 @@ void TwoMotorControl::onReadRecordLineFile_btn()
fclose(RecordLineFileHandle);
delete[] data;
QMessageBox::information(this, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("读取成功!"));
//QMessageBox::information(this, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("读取成功!"));
}

View File

@ -8,12 +8,11 @@
#include "IrisMultiMotorController.h"
#include "fileOperation.h"
#include "CaptureCoordinator.h"
#include "MotorWindowBase.h"
#define PI 3.1415926
class TwoMotorControl : public QDialog
class TwoMotorControl : public QDialog, public MotorWindowBase
{
Q_OBJECT
@ -27,6 +26,8 @@ public:
void record_dark();
void record_white();
bool getMotorsConnectionStatus();
private:
ImagerOperationBase* m_Imager;
bool getState();
@ -35,6 +36,8 @@ private:
QString m_posFileName;
FILE* m_posFileHandle;
bool m_xMotorConnectionStatus = false;
bool m_yMotorConnectionStatus = false;
public Q_SLOTS:
void onConnectMotor();
@ -48,14 +51,15 @@ public Q_SLOTS:
void onxMotorRight();
void onxMotorLeft();
void onxMotorStop();
void onxMove2Loc();
void onyMotorforward();
void onyMotorbackward();
void onyMotorStop();
void onyMove2Loc();
void onAddRecordLine_btn();
void onRemoveRecordLine_btn();
void onGenerateRecordLine_btn();
void onDeleteRecordLine_btn();
void onSaveRecordLine2File_btn();
void onReadRecordLineFile_btn();
@ -82,6 +86,8 @@ signals:
void startLineNumSignal(int lineNum);
void sequenceComplete();//所有采集线正常运行完成
void broadcastLocationSignal(std::vector<double>);
private:
Ui::twoMotorControl_UI ui;
QThread m_coordinatorThread;
@ -91,5 +97,5 @@ private:
DarkAndWhiteCaptureCoordinator* m_whiteCaptureCoordinator = nullptr;
QThread m_motorThread;
IrisMultiMotorController* m_multiAxisController;
IrisMultiMotorController* m_multiAxisController = nullptr;
};

375
HPPA/View3D.cpp Normal file
View File

@ -0,0 +1,375 @@
#include "View3D.h"
#include <QHBoxLayout>
#include <QShowEvent>
#include <QMouseEvent>
#include <QWheelEvent>
#include <Qt3DExtras/QForwardRenderer>
#include <QtMath>
#include <Qt3DRender/QAttribute>
#include <QGeometryRenderer>
View3DBase::View3DBase(const QString& baseModelPath,
const QString& armModelPath,
QWidget* parent)
: QWidget(parent),
m_container(nullptr),
m_baseModelPath(baseModelPath),
m_armModelPath(armModelPath)
{
m_view = new Qt3DExtras::Qt3DWindow();
// 部分 Qt5.9 构建可能需要强转 frame graph但 defaultFrameGraph() 通常可用
QColor c1("#0D1233");
m_view->defaultFrameGraph()->setClearColor(c1);
m_rootEntity = new Qt3DCore::QEntity();
initScene();
initCamera();
// 自动旋转臂(如果不需要可注释掉 timer/connect
//connect(&m_timer, &QTimer::timeout, this, [=]() {
// m_angle += 1.0f;
// m_t += 1.0f;
// if (m_angle >= 360.0f) m_angle = 0.0f;
// if (m_armTransform)
// {
// //m_armTransform->setRotationX(m_angle);
// //m_armTransform->setTranslation(QVector3D(m_t, 0, 0));
//
// Qt3DCore::QTransform transform;
// transform.setTranslation(QVector3D(2, 0, 0));
// QMatrix4x4 M = m_armTransform->matrix();
// M = transform.matrix() * M; // 左乘:在世界坐标系叠加
// m_armTransform->setMatrix(M);
// qDebug() << m_armTransform->matrix();
// }
// });
}
void View3DBase::setViewCenter(float x, float y, float z)
{
m_viewCenter.setX(x);
m_viewCenter.setY(y);
m_viewCenter.setZ(z);
}
void View3DBase::setDistance(float distance)
{
m_distance = distance;
}
void View3DBase::initScene()
{
/*auto* lightEntity = new Qt3DCore::QEntity(m_rootEntity);
auto* light = new Qt3DRender::QPointLight(lightEntity);
light->setColor(Qt::white);
light->setIntensity(1.2f);
auto* lightTransform = new Qt3DCore::QTransform(lightEntity);
lightTransform->setTranslation(QVector3D(500, 500, 500));
lightEntity->addComponent(light);
lightEntity->addComponent(lightTransform);*/
// ===== 创建 base 根节点 =====
auto* baseModel = new Qt3DCore::QEntity(m_rootEntity);
auto* baseLoader = new Qt3DRender::QSceneLoader(baseModel);
baseLoader->setSource(QUrl::fromLocalFile(m_baseModelPath));
//connect(baseLoader, &Qt3DRender::QSceneLoader::statusChanged,
// this, &View3DBase::onSceneLoaderStatusChanged);
m_baseTransform = new Qt3DCore::QTransform();
m_baseTransform->setTranslation(QVector3D(0, 0, 0));
baseModel->addComponent(baseLoader);
baseModel->addComponent(m_baseTransform);
connect(baseLoader, &Qt3DRender::QSceneLoader::statusChanged,
this, [=](Qt3DRender::QSceneLoader::Status status) {
if (status == Qt3DRender::QSceneLoader::Ready) {
applyWhiteMaterialRecursive(baseModel);
}
});
// ===== 创建 arm 根节点 =====
auto* armModel = new Qt3DCore::QEntity(m_rootEntity);
auto* armLoader = new Qt3DRender::QSceneLoader(armModel);
armLoader->setSource(QUrl::fromLocalFile(m_armModelPath));
m_armTransform = new Qt3DCore::QTransform();
m_armTransform->setTranslation(QVector3D(0, 0, 0));
armModel->addComponent(armLoader);
armModel->addComponent(m_armTransform);
connect(armLoader, &Qt3DRender::QSceneLoader::statusChanged,
this, [=](Qt3DRender::QSceneLoader::Status status) {
if (status == Qt3DRender::QSceneLoader::Ready) {
applyWhiteMaterialRecursive(armModel);
}
});
// 坐标轴依然挂在 root不会被移动
//createAxes();
m_view->setRootEntity(m_rootEntity);
qDebug() << m_baseTransform->matrix();
qDebug() << m_armTransform->matrix();
//m_armTransform->setTranslation(QVector3D(2000, 0, 0));
//m_baseTransform->setTranslation(QVector3D(-1000, -1000, -1000));
qDebug() << m_baseTransform->matrix();
qDebug() << m_armTransform->matrix();
}
void View3DBase::applyWhiteMaterialRecursive(Qt3DCore::QEntity* entity)
{
// 如果这个 entity 有 mesh就给它加白色材质
auto meshes = entity->componentsOfType<Qt3DRender::QGeometryRenderer>();
if (!meshes.isEmpty()) {
auto* mat = new Qt3DExtras::QPhongMaterial(entity);
QColor c1("#cccccc");
mat->setDiffuse(c1);
mat->setAmbient(c1);
mat->setSpecular(c1);
mat->setShininess(50.0f);
entity->addComponent(mat);
}
// 递归处理子节点
const auto children = entity->children();
for (QObject* obj : children) {
auto* childEntity = qobject_cast<Qt3DCore::QEntity*>(obj);
if (childEntity)
applyWhiteMaterialRecursive(childEntity);
}
}
void View3DBase::createAxes()
{
// 参数
float axisLength = 500.0f;
float axisRadius = 50.0f;
// ----- X axis (red) -----
Qt3DCore::QEntity* xAxis = new Qt3DCore::QEntity(m_rootEntity);
auto* xMesh = new Qt3DExtras::QCylinderMesh();
xMesh->setRadius(axisRadius);
xMesh->setLength(axisLength);
xMesh->setRings(16);
xMesh->setSlices(16);
auto* xTrans = new Qt3DCore::QTransform();
// cylinder 默认沿 Y 轴,绕 Z 轴 90 度让其沿 X
xTrans->setRotation(QQuaternion::fromAxisAndAngle(QVector3D(0, 0, 1), 90.0f));
xTrans->setTranslation(QVector3D(axisLength / 2.0f, 0.0f, 0.0f));
auto* xMat = new Qt3DExtras::QPhongMaterial();
xMat->setDiffuse(QColor(Qt::red));
xAxis->addComponent(xMesh);
xAxis->addComponent(xTrans);
xAxis->addComponent(xMat);
// ----- Y axis (green) -----
Qt3DCore::QEntity* yAxis = new Qt3DCore::QEntity(m_rootEntity);
auto* yMesh = new Qt3DExtras::QCylinderMesh();
yMesh->setRadius(axisRadius);
yMesh->setLength(axisLength*2);
yMesh->setRings(16);
yMesh->setSlices(16);
auto* yTrans = new Qt3DCore::QTransform();
// Y 轴无需旋转cylinder 默认沿 Y
yTrans->setTranslation(QVector3D(0.0f, axisLength / 2.0f, 0.0f));
auto* yMat = new Qt3DExtras::QPhongMaterial();
yMat->setDiffuse(QColor(Qt::green));
yAxis->addComponent(yMesh);
yAxis->addComponent(yTrans);
yAxis->addComponent(yMat);
// ----- Z axis (blue) -----
Qt3DCore::QEntity* zAxis = new Qt3DCore::QEntity(m_rootEntity);
auto* zMesh = new Qt3DExtras::QCylinderMesh();
zMesh->setRadius(axisRadius);
zMesh->setLength(axisLength*3);
zMesh->setRings(16);
zMesh->setSlices(16);
auto* zTrans = new Qt3DCore::QTransform();
// 让 cylinder 沿 Z绕 X 轴 90 度
zTrans->setRotation(QQuaternion::fromAxisAndAngle(QVector3D(1, 0, 0), 90.0f));
zTrans->setTranslation(QVector3D(0.0f, 0.0f, axisLength / 2.0f));
auto* zMat = new Qt3DExtras::QPhongMaterial();
zMat->setDiffuse(QColor(Qt::blue));
zAxis->addComponent(zMesh);
zAxis->addComponent(zTrans);
zAxis->addComponent(zMat);
}
void View3DBase::initCamera()
{
m_camera = m_view->camera();
// 16:10 假设窗口比例,后续 resize 时相机透视会保持
m_camera->lens()->setPerspectiveProjection(50.0f, 16.0f / 10.0f, 0.1f, 10000.0f);
updateCameraPosition();
}
void View3DBase::updateCameraPosition()
{
float yaw = qDegreesToRadians(m_yawDeg);
float pitch = qDegreesToRadians(m_pitchDeg);
float x = m_distance * qCos(pitch) * qSin(yaw);
float y = m_distance * qSin(pitch);
float z = m_distance * qCos(pitch) * qCos(yaw);
QVector3D camPos = m_viewCenter + QVector3D(x, y, z);
m_camera->setPosition(camPos);
m_camera->setViewCenter(m_viewCenter);
}
void View3DBase::showEvent(QShowEvent* event)
{
QWidget::showEvent(event);
if (!m_container) {
m_container = QWidget::createWindowContainer(m_view, this);
m_view->installEventFilter(this);
auto* layout = new QHBoxLayout(this);
layout->addWidget(m_container);
layout->setMargin(0);
setLayout(layout);
// 启动自动旋转 timer如果你不需要可以注释
m_timer.start(100);
}
}
bool View3DBase::eventFilter(QObject* obj, QEvent* event)
{
if (obj == m_view)
{
// 鼠标按下
if (event->type() == QEvent::MouseButtonPress) {
auto* e = static_cast<QMouseEvent*>(event);
if (e->button() == Qt::LeftButton) {
m_mouseDragging = true;
m_lastMousePos = e->pos();
}
else if (e->button() == Qt::MiddleButton) {
m_middleDragging = true;
m_lastMousePos = e->pos();
}
}
// 鼠标释放
else if (event->type() == QEvent::MouseButtonRelease) {
auto* e = static_cast<QMouseEvent*>(event);
if (e->button() == Qt::LeftButton) {
m_mouseDragging = false;
}
else if (e->button() == Qt::MiddleButton) {
m_middleDragging = false;
}
}
// 鼠标移动
else if (event->type() == QEvent::MouseMove) {
auto* e = static_cast<QMouseEvent*>(event);
QPoint pos = e->pos();
QPoint delta = pos - m_lastMousePos;
// 左键orbit旋转
if (m_mouseDragging) {
float sensitivity = 0.3f;
m_yawDeg -= delta.x() * sensitivity;
m_pitchDeg += delta.y() * sensitivity;
if (m_pitchDeg > 89.0f) m_pitchDeg = 89.0f;
if (m_pitchDeg < -89.0f) m_pitchDeg = -89.0f;
updateCameraPosition();
}
// 中键pan平移 viewCenter
if (m_middleDragging) {
float speed = 2.0f;
// 根据摄像机方向计算平移方向
QVector3D camPos = m_camera->position();
QVector3D forward = (m_viewCenter - camPos).normalized();
QVector3D up(0, 1, 0);
QVector3D right = QVector3D::crossProduct(forward, up).normalized();
// 世界坐标变化量
QVector3D deltaMove =
-right * (delta.x() * speed) +
up * (delta.y() * speed);
// 将平移应用到两个模型根 Transform
if (m_baseRootTransform)
m_baseRootTransform->setTranslation(
m_baseRootTransform->translation() + deltaMove*-1);
if (m_armRootTransform)
m_armRootTransform->setTranslation(
m_armRootTransform->translation() + deltaMove*-1);
}
m_lastMousePos = pos;
}
// 滚轮缩放
else if (event->type() == QEvent::Wheel) {
auto* e = static_cast<QWheelEvent*>(event);
// Qt5: angleDelta 返回像素值(通常为 120 per notch
int delta = e->angleDelta().y();
if (delta == 0) delta = e->delta(); // 备选
m_distance -= delta * 2.0f; // 缩放速度
if (m_distance < 2.0f) m_distance = 2.0f;
if (m_distance > 10000.0f) m_distance = 10000.0f;
updateCameraPosition();
}
}
// 让 Qt 继续处理(保持原行为)
return QWidget::eventFilter(obj, event);
}
View3DPlantPhenotype::View3DPlantPhenotype(const QString& baseModelPath, const QString& armModelPath, QWidget* parent)
:View3DBase(baseModelPath, armModelPath, parent)
{
}
void View3DPlantPhenotype::setLoc(std::vector<double> loc)
{
double x = round(loc[0] * 100) / 100;
double y = round(loc[1] * 100) / 100;
m_armTransform->setTranslation(QVector3D(x, y, 0));
}
View3DLinearStage::View3DLinearStage(const QString& baseModelPath, const QString& armModelPath, QWidget* parent)
:View3DBase(baseModelPath, armModelPath, parent)
{
}
void View3DLinearStage::setLoc(std::vector<double> loc)
{
double x = round(loc[0] * 100) / 100;
m_armTransform->setTranslation(QVector3D(x, 0, 0));
}

112
HPPA/View3D.h Normal file
View File

@ -0,0 +1,112 @@
#ifndef VIEW3D_H
#define VIEW3D_H
#include <QWidget>
#include <QTimer>
#include <QPoint>
#include <QString>
#include <QQuaternion>
#include <QColor>
#include <Qt3DCore/QEntity>
#include <Qt3DCore/QTransform>
#include <Qt3DExtras/Qt3DWindow>
#include <Qt3DRender/QCamera>
#include <Qt3DExtras/QOrbitCameraController>
#include <Qt3DExtras/QPhongMaterial>
#include <Qt3DRender/QSceneLoader>
#include <Qt3DExtras/QCylinderMesh>
#include <QPointLight>
class View3DBase : public QWidget
{
Q_OBJECT
public:
explicit View3DBase(const QString& baseModelPath,
const QString& armModelPath,
QWidget* parent = nullptr);
void setViewCenter(float x, float y, float z);
void setDistance(float distance);
protected:
void showEvent(QShowEvent* event) override;
bool eventFilter(QObject* obj, QEvent* event) override;
void initScene();
void initCamera();
void updateCameraPosition();
void createAxes();
QString m_baseModelPath;
QString m_armModelPath;
Qt3DExtras::Qt3DWindow* m_view;
QWidget* m_container;
Qt3DCore::QEntity* m_rootEntity;
Qt3DCore::QEntity* m_baseEntity;
Qt3DCore::QEntity* m_armEntity;
Qt3DCore::QTransform* m_armTransform;
Qt3DCore::QTransform* m_baseTransform;
QTimer m_timer;
float m_angle = 0; // arm auto rotation
float m_t = 0;
// ----- Camera control -----
Qt3DRender::QCamera* m_camera = nullptr;
float m_distance = 5000.0f;
float m_yawDeg = 0.0f;
float m_pitchDeg = 0.0f;
QVector3D m_viewCenter = QVector3D(1000, 1000, -1000);
// Mouse state
bool m_mouseDragging = false; // left button: orbit
bool m_middleDragging = false; // middle button: pan
QPoint m_lastMousePos;
Qt3DCore::QTransform* m_baseRootTransform = nullptr;
Qt3DCore::QTransform* m_armRootTransform = nullptr;
void applyWhiteMaterialRecursive(Qt3DCore::QEntity* entity);
public Q_SLOTS:
virtual void setLoc(std::vector<double> loc) = 0;
};
class View3DPlantPhenotype : public View3DBase
{
Q_OBJECT
public:
View3DPlantPhenotype(const QString& baseModelPath,
const QString& armModelPath,
QWidget* parent = nullptr);
protected:
private:
private:
public Q_SLOTS:
void setLoc(std::vector<double> loc);
};
class View3DLinearStage : public View3DBase
{
Q_OBJECT
public:
View3DLinearStage(const QString& baseModelPath,
const QString& armModelPath,
QWidget* parent = nullptr);
protected:
private:
private:
public Q_SLOTS:
void setLoc(std::vector<double> loc);
};
#endif // VIEW3D_H

View File

@ -0,0 +1,68 @@
#include "View3DModelManager.h"
View3DModelManager::View3DModelManager(QWidget* parent)
: QWidget(parent)
{
m_stackedWidget = new QStackedWidget();
m_stackedWidget->setContentsMargins(0, 0, 0, 0);
QVBoxLayout* layout = new QVBoxLayout(this);
layout->addWidget(m_stackedWidget);
layout->setContentsMargins(0, 0, 0, 0);
}
void View3DModelManager::switchScenario(ScenarioType type)
{
if (type == ScenarioType::PlantPhenotype) {
ensurePlantPhenotypeView();
m_stackedWidget->setCurrentWidget(m_viewPlant);
}
else {
ensureOneMotorView();
m_stackedWidget->setCurrentWidget(m_viewMotor);
}
emit scenarioChanged(type);
}
void View3DModelManager::ensurePlantPhenotypeView()
{
if (m_viewPlant)
return;
QString basePath = QCoreApplication::applicationDirPath();
m_viewPlant = new View3DPlantPhenotype(
basePath + "/3DModel/HPPA_frame.obj",
basePath + "/3DModel/HPPA_camera.obj",
m_stackedWidget
);
m_viewPlant->setViewCenter(1000, 1000, -1000);
m_viewPlant->setDistance(5000);
m_stackedWidget->addWidget(m_viewPlant);
emit created3DModelPlantPhenotype();
}
void View3DModelManager::ensureOneMotorView()
{
if (m_viewMotor)
return;
QString basePath = QCoreApplication::applicationDirPath();
m_viewMotor = new View3DLinearStage(
basePath + "/3DModel/linear_stage_indoor1.obj",
basePath + "/3DModel/linear_stage_indoor2.obj",
m_stackedWidget
);
m_viewMotor->setViewCenter(500, 100, 500);
m_viewMotor->setDistance(1000);
m_stackedWidget->addWidget(m_viewMotor);
emit created3DModelOneMotor();
}

40
HPPA/View3DModelManager.h Normal file
View File

@ -0,0 +1,40 @@
#pragma once
#include <QObject>
#include <QStackedWidget>
#include <QCoreApplication>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include "View3D.h"
class View3DPlantPhenotype;
class View3DLinearStage;
class View3DModelManager : public QWidget
{
Q_OBJECT
public:
enum class ScenarioType {
PlantPhenotype,
OneMotor
};
explicit View3DModelManager(QWidget* parent = nullptr);
void switchScenario(ScenarioType type);
View3DPlantPhenotype* m_viewPlant = nullptr;
View3DLinearStage* m_viewMotor = nullptr;
signals:
void scenarioChanged(ScenarioType type);
void created3DModelPlantPhenotype();
void created3DModelOneMotor();
private:
void ensurePlantPhenotypeView();
void ensureOneMotorView();
private:
QStackedWidget* m_stackedWidget = nullptr;
};

View File

@ -9,103 +9,300 @@
<rect>
<x>0</x>
<y>0</y>
<width>629</width>
<height>463</height>
<width>486</width>
<height>401</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<property name="windowIcon">
<iconset>
<normaloff>HPPA.ico</normaloff>HPPA.ico</iconset>
<layout class="QGridLayout" name="gridLayout">
<property name="leftMargin">
<number>0</number>
</property>
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>90</x>
<y>250</y>
<width>434</width>
<height>134</height>
</rect>
<property name="topMargin">
<number>0</number>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="companylname_label">
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QWidget" name="contentWidget" native="true">
<property name="styleSheet">
<string notr="true">QWidget #contentWidget
{
background: #040125;
/*border-radius: 8px 8px 8px 8px;*/
border: 1px solid #2f6bff;
}</string>
</property>
<layout class="QGridLayout" name="gridLayout_7">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="spacing">
<number>10</number>
</property>
<item row="0" column="0">
<widget class="QWidget" name="titlebarWidget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>43</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>43</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">QWidget #titlebarWidget
{
background: #0E1C4C;
border: 1px solid #2f6bff;
}</string>
</property>
<layout class="QGridLayout" name="gridLayout_6">
<item row="0" column="0">
<widget class="QLabel" name="iconLabel">
<property name="text">
<string>公司:北京依锐思遥感技术有限公司</string>
<string/>
</property>
<property name="pixmap">
<pixmap resource="HPPA.qrc">:/png/resources/icons/png/Spectral_Insight_27.png</pixmap>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_2">
<item row="0" column="1">
<widget class="QLabel" name="label_9">
<property name="styleSheet">
<string notr="true">QLabel
{
color:#E2EDFF;
}</string>
</property>
<property name="text">
<string>地址北京市海淀区清河安宁庄东路18号5号楼二层205</string>
<string>关于</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>电话010-51292601</string>
<item row="0" column="2">
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
<property name="sizeHint" stdset="0">
<size>
<width>505</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_5">
<item row="0" column="3">
<widget class="QPushButton" name="closeBtn">
<property name="styleSheet">
<string notr="true">QPushButton
{
/*width: 172px;
height: 56px;*/
font: 10pt &quot;新宋体&quot;;
background-color: qlineargradient(
spread:pad,
x1:0.5, y1:0, x2:0.5, y2:1,
stop:0 #283D86,
stop:1 #0F1A40
);
color: white;
border: none;
padding: 8px 8px;
border-radius: 4px;
}
QPushButton:hover
{
background-color: qlineargradient(
spread:pad,
x1:0, y1:0, x2:1, y2:0,
stop:0 #3A4875,
stop:1 #5F6B91
);
}
/* 按下时的效果 */
QPushButton:pressed
{
background-color: qlineargradient(
spread:pad,
x1:0, y1:0, x2:1, y2:0,
stop:0 #1A254F,
stop:1 #3A466B
);
/* 可选:添加下压效果 */
padding-top: 9px;
padding-bottom: 7px;
}</string>
</property>
<property name="text">
<string>邮箱hanshanlong@iris-rs.cn</string>
<string/>
</property>
<property name="icon">
<iconset resource="HPPA.qrc">
<normaloff>:/svg/resources/icons/svg/close.svg</normaloff>:/svg/resources/icons/svg/close.svg</iconset>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QLabel" name="label_6">
<property name="geometry">
<rect>
<x>270</x>
<y>150</y>
<width>141</width>
<height>24</height>
</rect>
</property>
<property name="text">
<string>版本2.0</string>
</property>
</widget>
<widget class="QLabel" name="label_4">
<property name="geometry">
<rect>
<x>270</x>
<y>70</y>
<width>391</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string>Hyper Plant Phenotypic Analysis</string>
</property>
<property name="textFormat">
<enum>Qt::PlainText</enum>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QWidget" name="widget" native="true">
<widget class="QLabel" name="label_7">
<property name="geometry">
<rect>
<x>90</x>
<y>50</y>
<width>141</width>
<height>141</height>
<x>70</x>
<y>20</y>
<width>171</width>
<height>171</height>
</rect>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap>HPPA.ico</pixmap>
<pixmap resource="HPPA.qrc">:/png/resources/icons/png/Spectral_Insight_170.png</pixmap>
</property>
</widget>
<widget class="QWidget" name="widget_2" native="true">
<property name="geometry">
<rect>
<x>70</x>
<y>210</y>
<width>306</width>
<height>111</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">QLabel
{
color: #E2EDFF;
font: 10pt &quot;Adobe Devanagari&quot;;
}</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<property name="spacing">
<number>10</number>
</property>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>地址北京市海淀区清河安宁庄东路18号5号楼二层205</string>
</property>
</widget>
<resources/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>电话010-51292601</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>邮箱hanshanlong@iris-rs.cn</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="companylname_label">
<property name="text">
<string>公司:北京依锐思遥感技术有限公司</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="widget_3" native="true">
<property name="geometry">
<rect>
<x>260</x>
<y>50</y>
<width>171</width>
<height>101</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<property name="verticalSpacing">
<number>30</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="nameLabel">
<property name="styleSheet">
<string notr="true">QLabel
{
color:#E2EDFF;
font: italic 18pt &quot;Adobe Devanagari&quot;;
}</string>
</property>
<property name="text">
<string>Spectral Insight</string>
</property>
<property name="textFormat">
<enum>Qt::PlainText</enum>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="versionLabel">
<property name="styleSheet">
<string notr="true">QLabel
{
color:#E2EDFF;
font: 10pt &quot;Adobe Devanagari&quot;;
}</string>
</property>
<property name="text">
<string>版本3.0.1</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="HPPA.qrc"/>
</resources>
<connections/>
</ui>

View File

@ -1,22 +1,31 @@
#include "aboutWindow.h"
#include "aboutWindow.h"
#include <QSvgRenderer>
#include <QPainter>
aboutWindow::aboutWindow(QWidget* parent)
{
ui.setupUi(this);
ui.companylname_label->setOpenExternalLinks(true);//<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊtrue<EFBFBD><EFBFBD><EFBFBD>ܴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҳ
ui.companylname_label->setOpenExternalLinks(true);//设置为true才能打开网页
QString text = ui.companylname_label->text();
ui.companylname_label->setText("<a style='color: green; text-decoration: none' href = http://www.iris-rs.cn/pr.jsp?_jcp=3_10>" + text);
Qt::WindowFlags flags = 0;
//flags |= Qt::WindowMinimizeButtonHint;
flags |= Qt::WindowCloseButtonHint;
flags |= Qt::MSWindowsFixedSizeDialogHint;
setWindowFlags(flags);
//Qt::WindowFlags flags = 0;
////flags |= Qt::WindowMinimizeButtonHint;
//flags |= Qt::WindowCloseButtonHint;
//flags |= Qt::MSWindowsFixedSizeDialogHint;
//setWindowFlags(flags);
setWindowFlags(Qt::FramelessWindowHint);
connect(this->ui.closeBtn, SIGNAL(released()), this, SLOT(onExit()));
}
aboutWindow::~aboutWindow()
{
}
void aboutWindow::onExit()
{
this->close();
}

View File

@ -1,7 +1,8 @@
#pragma once
#pragma once
#include <QtWidgets/qdialog.h>
#include <qstring.h>
#include "ui_about.h"
class aboutWindow :public QDialog
@ -19,6 +20,7 @@ private:
Ui::aboutDialog ui;
public Q_SLOTS:
void onExit();
signals:

View File

@ -1,4 +1,4 @@
#include "adjustTable.h"
#include "adjustTable.h"
adjustTable::adjustTable(QWidget *parent)
: QDialog(parent)

View File

@ -1,4 +1,4 @@
#pragma once
#pragma once
#include <QDialog>
#include <QNetworkRequest>

View File

@ -6,24 +6,127 @@
<rect>
<x>0</x>
<y>0</y>
<width>687</width>
<height>389</height>
<width>501</width>
<height>267</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>adjustTable</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<property name="styleSheet">
<string notr="true">QGroupBox
{
border: 12px solid transparent;
/*border-top: 12px solid transparent;
border-right: 0px solid transparent;
border-bottom: 0px solid transparent;
border-left: 0px solid transparent;*/
color: #ACCDFF;
}
QPushButton
{
/*width: 172px;
height: 56px;*/
font: 19pt &quot;新宋体&quot;;
background-color: qlineargradient(
spread:pad,
x1:0.5, y1:0, x2:0.5, y2:1,
stop:0 #283D86,
stop:1 #0F1A40
);
color: white;
border: none;
padding: 8px 16px;
border-radius: 4px;
}
QPushButton:hover
{
background-color: qlineargradient(
spread:pad,
x1:0, y1:0, x2:1, y2:0,
stop:0 #3A4875,
stop:1 #5F6B91
);
}
/* 按下时的效果 */
QPushButton:pressed
{
background-color: qlineargradient(
spread:pad,
x1:0, y1:0, x2:1, y2:0,
stop:0 #1A254F,
stop:1 #3A466B
);
/* 可选:添加下压效果 */
padding-top: 9px;
padding-bottom: 7px;
}</string>
</property>
<layout class="QGridLayout" name="gridLayout_4" rowstretch="1,2,2,2,1" columnstretch="1,10,1">
<item row="0" column="1">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>66</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>63</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="1">
<widget class="QGroupBox" name="groupBox_8">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>252号升降台</string>
</property>
<layout class="QGridLayout" name="gridLayout_10">
<layout class="QGridLayout" name="gridLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>10</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="horizontalSpacing">
<number>18</number>
</property>
<item row="0" column="0">
<widget class="QPushButton" name="objective_table252_up_btn">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -33,58 +136,10 @@
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="objective_table252_down_btn">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>下降</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QPushButton" name="objective_table252_stop_btn">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>停止</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="0" column="1">
<widget class="QGroupBox" name="groupBox_7">
<property name="title">
<string>253号升降台</string>
</property>
<layout class="QGridLayout" name="gridLayout_11">
<item row="0" column="0">
<widget class="QPushButton" name="objective_table1_up_btn">
<widget class="QPushButton" name="objective_table252_down_btn">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>上升</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="objective_table1_down_btn">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -94,58 +149,10 @@
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QPushButton" name="objective_table1_stop_btn">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>停止</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="0" column="2">
<widget class="QGroupBox" name="groupBox_6">
<property name="title">
<string>254号升降台</string>
</property>
<layout class="QGridLayout" name="gridLayout_9">
<item row="0" column="0">
<widget class="QPushButton" name="objective_table2_up_btn">
<widget class="QPushButton" name="objective_table252_stop_btn">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>上升</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="objective_table2_down_btn">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>下降</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QPushButton" name="objective_table2_stop_btn">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -158,6 +165,222 @@
</layout>
</widget>
</item>
<item row="1" column="2">
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>63</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="0">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>63</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="1">
<widget class="QGroupBox" name="groupBox_7">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>253号升降台</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>10</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="horizontalSpacing">
<number>18</number>
</property>
<item row="0" column="0">
<widget class="QPushButton" name="objective_table1_up_btn">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>上升</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="objective_table1_down_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="2">
<widget class="QPushButton" name="objective_table1_stop_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>
</widget>
</item>
<item row="2" column="2">
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>63</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="0">
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>63</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="1">
<widget class="QGroupBox" name="groupBox_6">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>254号升降台</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>10</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="horizontalSpacing">
<number>18</number>
</property>
<item row="0" column="0">
<widget class="QPushButton" name="objective_table2_up_btn">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>上升</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="objective_table2_down_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="2">
<widget class="QPushButton" name="objective_table2_stop_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>
</widget>
</item>
<item row="3" column="2">
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>63</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="4" column="1">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>65</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>

Some files were not shown because too many files have changed in this diff Show More