15 Commits

Author SHA1 Message Date
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
34 changed files with 5122 additions and 2107 deletions

2
.gitignore vendored
View File

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

259
HPPA/Carousel.cpp Normal file
View File

@ -0,0 +1,259 @@
#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);
QAction* startAct = menu.addAction(QString::fromLocal8Bit("开始轮播"));
QAction* stopAct = menu.addAction(QString::fromLocal8Bit("停止轮播"));
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();
}
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;
// <20><><EFBFBD><EFBFBD>
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

@ -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; /* ȡ<><C8A1><EFBFBD>ײ<EFBFBD><D7B2>߿<EFBFBD> */
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:
};

File diff suppressed because it is too large Load Diff

View File

@ -12,6 +12,7 @@
#include <QLineSeries>
#include <QChart>
#include <QChartView>
#include <QValueAxis>
#include <QFileDialog>
#include <QNetworkRequest>
@ -42,6 +43,17 @@
#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"
#define PI 3.1415926
QT_CHARTS_USE_NAMESPACE//QChartView ʹ<><CAB9> <20><>Ҫ<EFBFBD>Ӻ꣬ <20><><EFBFBD><EFBFBD><EFBFBD>޷<EFBFBD>ʹ<EFBFBD><CAB9>
@ -123,6 +135,31 @@ signals:
void threadSignal(QString s);
};
class WidgetWithBackgroundPicture : public QWidget
{
Q_OBJECT
public:
explicit WidgetWithBackgroundPicture(QWidget* parent = nullptr)
: QWidget(parent),
m_pixmap(".//icon//titile_bar_bgp.png") // ʹ<><CAB9><EFBFBD><EFBFBD>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><C2B7>
{
// <20><>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD>ó<EFBFBD>ʼ<EFBFBD><CABC>С
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
@ -137,11 +174,14 @@ public:
private:
Ui::HPPAClass ui;
QTabWidget* m_imageViewerTabWidget;
QMenu* mPanelMenu = nullptr;
QMenu* mToolbarMenu = nullptr;
void initMenubarToolbar();
void initPanelToolbar();
void initControlTabwidget();
QLineEdit * frame_number;
QLineEdit * m_FilenameLineEdit;
@ -160,6 +200,7 @@ private:
FileOperation * m_FileOperation;
QChartView * m_chartView;
QChart* m_chart;
//QLineSeries *series;
//QChart *chart;
@ -183,19 +224,37 @@ private:
QActionGroup* mImagerGroup = nullptr;
void createActionGroups();
void selectingImager(QAction* selectedAction);
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;
QPushButton* m_open_rgb_camera_btn;
QPushButton* m_close_rgb_camera_btn;
TabManager* m_tabManager;
adjustTable* m_adt;
PowerControl* m_pc;
RobotArmControl* m_rac;
OneMotorControl* m_omc;
TwoMotorControl* m_tmc;
View3DModelManager* m_view3DModelManager;
public Q_SLOTS:
void onPlotHyperspectralImageRgbImage(int fileNumber, int frameNumber);
void PlotSpectral(int state);
@ -228,6 +287,7 @@ public Q_SLOTS:
void OnGainSliderChanged(double Gain);//
void onLeftMouseButtonPressed(int x, int y);//<2F><><EFBFBD><EFBFBD>Ӱ<EFBFBD><D3B0><EFBFBD><EFBFBD>Ԫ<EFBFBD><D4AA>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>
void setAxis(QValueAxis* axisX, QValueAxis* axisY);
void timerEvent(QTimerEvent *event);
@ -246,6 +306,9 @@ public Q_SLOTS:
void recordFromRobotArm(int fileCounter);
void createOneMotorScenario();
void createPlantPhenotypeScenario();
void onCreated3DModelPlantPhenotype();
void onCreated3DModelOneMotor();
signals:
void StartFocusSignal();
void StartRecordSignal();

File diff suppressed because it is too large Load Diff

View File

@ -32,7 +32,7 @@
</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;widgets;serialport;websockets;3dcore;3danimation;3dextras;3dinput;3dlogic;3drender;3dquick;charts</QtModules>
<QtBuildConfig>debug</QtBuildConfig>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'" Label="QtSettings">
@ -107,11 +107,18 @@
<ClCompile Include="aboutWindow.cpp" />
<ClCompile Include="adjustTable.cpp" />
<ClCompile Include="CaptureCoordinator.cpp" />
<ClCompile Include="Carousel.cpp" />
<ClCompile Include="Corning410Imager.cpp" />
<ClCompile Include="CustomDockWidgetBase.cpp" />
<ClCompile Include="hppaConfigFile.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="OneMotorControl.cpp" />
<ClCompile Include="path_tc.cpp" />
<ClCompile Include="PowerControl.cpp" />
@ -125,8 +132,11 @@
<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" />
@ -161,15 +171,25 @@
<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" />
<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" />
<ClInclude Include="utility_tc.h" />
<QtMoc Include="aboutWindow.h" />
<ClInclude Include="hppaConfigFile.h" />

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,36 @@
<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>
</ItemGroup>
<ItemGroup>
<QtMoc Include="fileOperation.h">
@ -192,6 +213,36 @@
<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>
</ItemGroup>
<ItemGroup>
<ClInclude Include="imageProcessor.h">

73
HPPA/LayerTree.cpp Normal file
View File

@ -0,0 +1,73 @@
#include "LayerTree.h"
#include "LayerTreeGroupNode.h"
LayerTree::LayerTree(QObject* parent)
: QObject(parent)
{
// root <20><>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> view <20><><EFBFBD><EFBFBD>ʾ
m_root = new LayerTreeGroupNode("__root__", this);
m_root->setVisible(Qt::Checked);
}
LayerTree::~LayerTree()
{
delete m_root;
m_root = nullptr;
}
LayerTreeNode* LayerTree::root() const
{
return m_root;
}
LayerTreeNode* LayerTree::insertNode(LayerTreeNode* parent, int row, LayerTreeNode* node)
{
if (!node) return nullptr;
if (!parent) parent = m_root;
if (row < 0) row = parent->childCount();
parent->insertChild(row, node);
return node;
}
LayerTreeNode* LayerTree::removeNode(LayerTreeNode* parent, int row)
{
if (!parent) parent = m_root;
return parent->takeChild(row);
}
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());
}
}

49
HPPA/LayerTree.h Normal file
View File

@ -0,0 +1,49 @@
#pragma once
#include <QObject>
#include "LayerTreeNode.h"
/**
* LayerTree<65><65><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ¼<C4BF><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* - <20><><EFBFBD><EFBFBD> root
* - <20><EFBFBD><E1B9A9><EFBFBD><EFBFBD>/<2F>Ƴ<EFBFBD><C6B3>ڵ<EFBFBD><DAB5><EFBFBD> API
* - <20><EFBFBD>ɼ<EFBFBD><C9BC>Լ<EFBFBD><D4BC><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD>̬<EFBFBD><CCAC><EFBFBD>µľ<C2B5>̬<EFBFBD><CCAC><EFBFBD><EFBFBD>
*
* ע<>⣺beginInsertRows/endInsertRows <20><> Qt Model <20><><EFBFBD><EFBFBD>֪ͨӦ<D6AA><D3A6> Model <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ã<EFBFBD>
* LayerTree ֻ<><D6BB><EFBFBD><EFBFBD>ά<EFBFBD><CEAC><EFBFBD><EFBFBD><EFBFBD>ݽṹ<DDBD><E1B9B9>ȷ<EFBFBD>ԡ<EFBFBD>
*/
class LayerTree : public QObject
{
Q_OBJECT
public:
explicit LayerTree(QObject* parent = nullptr);
~LayerTree() override;
LayerTree(const LayerTree&) = delete;
LayerTree& operator=(const LayerTree&) = delete;
LayerTreeNode* root() const;
// <20><><EFBFBD>룺parent Ϊ nullptr <20><>ʾ root<6F><74>row=-1 <20><>ʾ append
LayerTreeNode* insertNode(LayerTreeNode* parent, int row, LayerTreeNode* node);
// <20>Ƴ<EFBFBD><C6B3><EFBFBD><EFBFBD><EFBFBD> delete<74><65><EFBFBD><EFBFBD><EFBFBD>ر<EFBFBD><D8B1>Ƴ<EFBFBD><C6B3>ڵ㣨<DAB5><E3A3A8><EFBFBD><EFBFBD><EFBFBD>߸<EFBFBD><DFB8><EFBFBD> delete <20><><EFBFBD><EFBFBD><EFBFBD>²<EFBFBD><C2B2>
LayerTreeNode* removeNode(LayerTreeNode* parent, int row);
// <20>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD>߼<EFBFBD><DFBC><EFBFBD><EFBFBD><EFBFBD> Model <20><><EFBFBD>ã<EFBFBD>
static void setChildrenVisible(LayerTreeNode* n, Qt::CheckState state);
static void updateParentVisibleFromChildren(LayerTreeNode* parent);
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;
}
private:
LayerTreeNode* m_root = nullptr; // owned
};

View File

@ -0,0 +1,6 @@
#include "LayerTreeGroupNode.h"
LayerTreeGroupNode::LayerTreeGroupNode(const QString& name, QObject* parent)
: LayerTreeNode(name, parent)
{
}

15
HPPA/LayerTreeGroupNode.h Normal file
View File

@ -0,0 +1,15 @@
#pragma once
#include "LayerTreeNode.h"
/** Group <20>ڵ<EFBFBD> */
class LayerTreeGroupNode : public LayerTreeNode
{
Q_OBJECT
public:
explicit LayerTreeGroupNode(const QString& name,
QObject* parent = nullptr);
Type type() const override { return Type::Group; }
// <20>Ժ<EFBFBD><D4BA><EFBFBD><EFBFBD><EFBFBD>չ<EFBFBD><D5B9>collapsed / groupOpacity <20><>
};

View File

@ -0,0 +1,6 @@
#include "LayerTreeLayerNode.h"
LayerTreeLayerNode::LayerTreeLayerNode(const QString& name, QObject* parent)
: LayerTreeNode(name, parent)
{
}

15
HPPA/LayerTreeLayerNode.h Normal file
View File

@ -0,0 +1,15 @@
#pragma once
#include "LayerTreeNode.h"
/** Layer <20>ڵ<EFBFBD> */
class LayerTreeLayerNode : public LayerTreeNode
{
Q_OBJECT
public:
explicit LayerTreeLayerNode(const QString& name,
QObject* parent = nullptr);
Type type() const override { return Type::Layer; }
// <20>Ժ<EFBFBD><D4BA><EFBFBD><EFBFBD><EFBFBD>չ<EFBFBD><D5B9>layerId / pointer / legendItems <20><>
};

168
HPPA/LayerTreeModel.cpp Normal file
View File

@ -0,0 +1,168 @@
#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->root()) return {};
LayerTreeNode* p = node->parentNode();
if (!p || p == m_tree->root()) 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->root()) return {};
switch (role) {
case Qt::DisplayRole:
return n->name();
case Qt::DecorationRole:
{
auto* tmp = nodeFromIndex(index);
if (LayerTree::isGroup(tmp))
return QIcon();
else if (LayerTree::isLayer(tmp))
{
QString basePath = QCoreApplication::applicationDirPath();
return QIcon(basePath + "/icons/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->root()) return false;
if (role == Qt::CheckStateRole) {
auto newState = static_cast<Qt::CheckState>(value.toInt());
if (n->visible() == newState) return true;
n->setVisible(newState);
// 1) <20><> -> <20><> <20><><EFBFBD><EFBFBD>
if (m_cascadeCheck) {
LayerTree::setChildrenVisible(n, newState);
}
// 2) <20><> -> <20><> <20><><EFBFBD><EFBFBD> PartiallyChecked
LayerTree::updateParentVisibleFromChildren(n->parentNode());
// <20>򻯣<EFBFBD><F2BBAFA3><EFBFBD><EFBFBD><EFBFBD>ˢ<EFBFBD>£<EFBFBD><C2A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>滻Ϊ<E6BBBB><CEAA>׼ dataChanged<65><64>
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->root()) return Qt::NoItemFlags;
return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable;
}
LayerTreeNode* LayerTreeModel::root() const
{
return m_tree->root();
}
LayerTreeNode* LayerTreeModel::addGroup(LayerTreeNode* parent, const QString& name, const QIcon& icon)
{
if (!parent) parent = m_tree->root();
const int row = parent->childCount();
beginInsertRows(indexFromNode(parent), row, row);
LayerTreeNode* g = m_tree->insertNode(parent, row, new LayerTreeGroupNode(name));
endInsertRows();
return g;
}
LayerTreeNode* LayerTreeModel::addLayer(LayerTreeNode* parent, const QString& name, const QIcon& icon)
{
if (!parent) parent = m_tree->root();
const int row = parent->childCount();
beginInsertRows(indexFromNode(parent), row, row);
LayerTreeNode* l = m_tree->insertNode(parent, row, new LayerTreeLayerNode(name));
endInsertRows();
return l;
}
void LayerTreeModel::setCascadeCheckEnabled(bool enabled)
{
m_cascadeCheck = enabled;
}
bool LayerTreeModel::cascadeCheckEnabled() const
{
return m_cascadeCheck;
}
LayerTreeNode* LayerTreeModel::nodeFromIndex(const QModelIndex& index) const
{
if (!index.isValid()) return m_tree->root();
return static_cast<LayerTreeNode*>(index.internalPointer());
}
QModelIndex LayerTreeModel::indexFromNode(LayerTreeNode* n) const
{
if (!n || n == m_tree->root()) return {};
return createIndex(n->rowInParent(), 0, n);
}

47
HPPA/LayerTreeModel.h Normal file
View File

@ -0,0 +1,47 @@
#pragma once
#include <QCoreApplication>
#include <QAbstractItemModel>
#include "LayerTree.h"
/**
* LayerTreeModel<65><6C>Qt <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E3A3A8><EFBFBD>ٹ<EFBFBD><D9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* - 1 <20>У<EFBFBD><D0A3><EFBFBD><EFBFBD>ƣ<EFBFBD><C6A3><EFBFBD>ͼ<EFBFBD>꣩+ checkbox
* - <20><>ѡ<EFBFBD>ɼ<EFBFBD><C9BC>ԣ<EFBFBD><D4A3><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>
*/
class LayerTreeModel : public QAbstractItemModel
{
Q_OBJECT
public:
explicit LayerTreeModel(LayerTree* tree,
QObject* parent = nullptr,
bool cascadeCheck = true);
~LayerTreeModel() override = default;
// QAbstractItemModel <20><><EFBFBD><EFBFBD><EFBFBD>ӿ<EFBFBD>
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;
// <20><><EFBFBD><EFBFBD> API<50><49><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD> begin/endInsertRows<77><73>
LayerTreeNode* root() const;
LayerTreeNode* addGroup(LayerTreeNode* parent, const QString& name, const QIcon& icon = QIcon());
LayerTreeNode* addLayer(LayerTreeNode* parent, const QString& name, const QIcon& icon = QIcon());
void setCascadeCheckEnabled(bool enabled);
bool cascadeCheckEnabled() const;
private:
LayerTree* m_tree = nullptr; // not owned
bool m_cascadeCheck = true;
private:
LayerTreeNode* nodeFromIndex(const QModelIndex& index) const;
QModelIndex indexFromNode(LayerTreeNode* n) const;
};

110
HPPA/LayerTreeNode.cpp Normal file
View File

@ -0,0 +1,110 @@
#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)
{
m_name = 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;
// <20><> QObject <20><> parent Ҳ<><D2B2><EFBFBD><EFBFBD><E6A3A8><EFBFBD><EFBFBD> Qt <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ι<EFBFBD><CEB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҳ<EFBFBD><D2B2><EFBFBD>Ӱ<EFBFBD><D3B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD> delete children<65><6E>
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();
child->setParentNode(this);
m_children.insert(row, child);
}
LayerTreeNode* LayerTreeNode::takeChild(int row)
{
if (row < 0 || row >= m_children.size()) return nullptr;
LayerTreeNode* taken = m_children.takeAt(row);
if (taken) taken->setParentNode(nullptr);
return taken;
}

65
HPPA/LayerTreeNode.h Normal file
View File

@ -0,0 +1,65 @@
#pragma once
#include <QObject>
#include <QVector>
#include <QIcon>
#include <QString>
/**
* LayerTreeNode<64><65><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD><EFBFBD><E0A3A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD><EFBFBD>ԣ<EFBFBD><D4A3><EFBFBD><EFBFBD><EFBFBD><><CDBC>/<2F>ɼ<EFBFBD><C9BC><EFBFBD>/<2F><><EFBFBD>ӹ<EFBFBD>ϵ
* - Group / Layer <20>ڵ<EFBFBD>ͨ<EFBFBD><CDA8><EFBFBD>̳<EFBFBD>ʵ<EFBFBD><CAB5>
*
* ˵<><CBB5><EFBFBD><EFBFBD>
* - <20><><EFBFBD><EFBFBD>ͬʱά<CAB1><CEAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EBA1B1>m_parentNode<64><65><EFBFBD><EFBFBD> QObject parent<6E><74><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>
* - children <20>ɽڵ<C9BD><DAB5>Լ<EFBFBD><D4BC><EFBFBD><EFBFBD>в<EFBFBD><D0B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷţ<CDB7><C5A3><EFBFBD><EFBFBD><EFBFBD>ʱ delete children<65><6E>
*/
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);
LayerTreeNode* takeChild(int row); // remove but not delete
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;
};

View File

@ -64,6 +64,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)

View File

@ -55,6 +55,8 @@ signals:
void sequenceComplete();
void broadcastLocationSignal(std::vector<double>);
private:
Ui::OneMotorControl_UI ui;

View File

@ -6,114 +6,246 @@
<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>
<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">
<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="text">
<string>打开</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="lamp_power_close_btn">
<property name="text">
<string>关闭</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_19">
<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="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">
<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>42</height>
<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>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="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 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>
</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>151</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>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>144</height>
</size>
</property>
</spacer>

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);
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD><D8B5>ǵ<EFBFBD>ǰҳ<C7B0><D2B3><EFBFBD><EFBFBD><EFBFBD>л<EFBFBD><D0BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>հ<EFBFBD>
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,9 @@ 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()));
}
void TwoMotorControl::setImager(ImagerOperationBase* imager)
@ -184,12 +179,13 @@ void TwoMotorControl::onConnectMotor()
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(this->ui.move2loc_x_pushButton, SIGNAL(pressed()), this, SLOT(onxMove2Loc()));
connect(this->ui.move2loc_y_pushButton, SIGNAL(pressed()), this, SLOT(onyMove2Loc()));
connect(m_multiAxisController, SIGNAL(broadcastLocationSignal(std::vector<double>)), this, SLOT(displayRealTimeLoc(std::vector<double>)));
connect(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()));
@ -291,6 +287,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 +315,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 +390,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 +408,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 +422,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);
@ -536,9 +449,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 +459,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 +471,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();

View File

@ -26,7 +26,7 @@ public:
void record_dark();
void record_white();
private:
ImagerOperationBase* m_Imager;
bool getState();
@ -48,14 +48,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 +83,8 @@ signals:
void startLineNumSignal(int lineNum);
void sequenceComplete();//所有采集线正常运行完成
void broadcastLocationSignal(std::vector<double>);
private:
Ui::twoMotorControl_UI ui;
QThread m_coordinatorThread;

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

@ -6,24 +6,127 @@
<rect>
<x>0</x>
<y>0</y>
<width>687</width>
<height>389</height>
<width>501</width>
<height>363</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,10 +136,10 @@
</property>
</widget>
</item>
<item row="1" column="0">
<item row="0" column="1">
<widget class="QPushButton" name="objective_table252_down_btn">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -46,10 +149,10 @@
</property>
</widget>
</item>
<item row="2" column="0">
<item row="0" column="2">
<widget class="QPushButton" name="objective_table252_stop_btn">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -62,16 +165,63 @@
</layout>
</widget>
</item>
<item row="0" column="1">
<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_11">
<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="Minimum" vsizetype="Expanding">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -81,10 +231,10 @@
</property>
</widget>
</item>
<item row="1" column="0">
<item row="0" column="1">
<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,10 +244,10 @@
</property>
</widget>
</item>
<item row="2" column="0">
<item row="0" column="2">
<widget class="QPushButton" name="objective_table1_stop_btn">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -110,16 +260,63 @@
</layout>
</widget>
</item>
<item row="0" column="2">
<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_9">
<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="Minimum" vsizetype="Expanding">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -129,10 +326,10 @@
</property>
</widget>
</item>
<item row="1" column="0">
<item row="0" column="1">
<widget class="QPushButton" name="objective_table2_down_btn">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -142,10 +339,10 @@
</property>
</widget>
</item>
<item row="2" column="0">
<item row="0" column="2">
<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 +355,32 @@
</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"/>

View File

@ -6,217 +6,313 @@
<rect>
<x>0</x>
<y>0</y>
<width>544</width>
<height>346</height>
<width>678</width>
<height>480</height>
</rect>
</property>
<property name="windowTitle">
<string>一轴马达控制</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>实时位置</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_6">
<property name="text">
<string>运行速度</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_7">
<property name="text">
<string>返回速度</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLineEdit" name="realTimeLoc_lineEdit">
<property name="text">
<string>0</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="speed_lineEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(255, 255, 255);</string>
</property>
<property name="text">
<string>0.1</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="return_speed_lineEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(255, 255, 255);</string>
</property>
<property name="text">
<string>2</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="move2loc_lineEdit">
<property name="text">
<string>0</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QPushButton" name="connect_btn">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>连接</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="zero_start_btn">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>归零</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="rangeMeasurement_btn">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>量程测量</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="move2loc_pushButton">
<property name="text">
<string>移动至</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<property name="styleSheet">
<string notr="true">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;
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;
}
QLabel
{
color: #ACCDFF;
background-color: transparent;
}
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;
}
QLineEdit:hover {
border: 1px solid #4d8dff;
}
QLineEdit:focus {
border: 1px solid #6aa2ff;
background-color: #23345c;
}</string>
</property>
<layout class="QGridLayout" name="gridLayout_2" rowstretch="1,3,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>87</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>161</width>
<width>127</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<item row="1" column="1">
<layout class="QGridLayout" name="gridLayout">
<property name="spacing">
<number>10</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>实时位置</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="realTimeLoc_lineEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>88</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>0</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="connect_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="0">
<widget class="QLabel" name="label_6">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</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="speed_lineEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>88</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string>0.1</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="zero_start_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="2" column="0">
<widget class="QLabel" name="label_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>返回速度</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="return_speed_lineEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>88</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>2</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QPushButton" name="rangeMeasurement_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="3" column="1">
<widget class="QLineEdit" name="move2loc_lineEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>88</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>0</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QPushButton" name="move2loc_pushButton">
<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="4" column="1">
<widget class="QPushButton" name="left_btn">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -226,10 +322,10 @@
</property>
</widget>
</item>
<item>
<item row="4" column="2">
<widget class="QPushButton" name="right_btn">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -239,41 +335,64 @@
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="motor_state_label">
<property name="text">
<string>马达状态</string>
</property>
</widget>
<item row="5" column="2">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>状态</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="motor_state_label">
<property name="maximumSize">
<size>
<width>8</width>
<height>8</height>
</size>
</property>
<property name="sizeIncrement">
<size>
<width>8</width>
<height>8</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">background-color: red;
border-radius: 4px;</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item row="3" column="0">
<spacer name="verticalSpacer">
<item row="1" column="2">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>127</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>191</height>
<height>87</height>
</size>
</property>
</spacer>

File diff suppressed because it is too large Load Diff