diff --git a/HPPA/FocusDialog.ui b/HPPA/FocusDialog.ui index c90bc8b..668a0e7 100644 --- a/HPPA/FocusDialog.ui +++ b/HPPA/FocusDialog.ui @@ -6,8 +6,8 @@ 0 0 - 632 - 444 + 557 + 432 @@ -17,258 +17,597 @@ :/HPPA/HPPA.ico:/HPPA/HPPA.ico - - - - - 连接调焦模块 + + QLineEdit { + background-color: #142D7F; + color: #e6eeff; + border: 1px solid #2f6bff; + border-radius: 6px; + padding: 4px 8px; + min-width: 70px; + min-height: 20px; + font-size: 13px; +} + +QGroupBox +{ + border: 12px solid transparent; + /*border-top: 12px solid transparent; + border-right: 0px solid transparent; + border-bottom: 0px solid transparent; + border-left: 0px solid transparent;*/ + color: #ACCDFF; +} + +QPushButton +{ + /*width: 172px; + height: 56px;*/ + font: 10pt "新宋体"; + 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; +} + +QLabel { + color: rgb(255, 255, 255); +} + +QSlider::groove:horizontal { + height: 10px; + background: #1e2a44; + border-radius: 3px; +} + +/* 已滑过:渐变蓝 */ +QSlider::sub-page:horizontal { + background: qlineargradient( + x1:0, y1:0, x2:1, y2:0, + stop:0 #1f4fff, + stop:0.5 #2f6bff, + stop:1 #5fa0ff + ); + border-radius: 3px; +} + +/* 未滑过 */ +QSlider::add-page:horizontal { + height: 10px; + background: #2a3550; + border-radius: 3px; +} + +/* ===== 滑块按钮 ===== */ +QSlider::handle:horizontal { + width: 15px; + height: 10px; + + /* 蓝色实心 */ + background: #2f6bff; + + /* 白色外圈 */ + border: 2px solid #ffffff; + border-radius: 5px; + + /* 垂直居中 */ + margin: -5px 0; +} + +/* 悬停 */ +QSlider::handle:horizontal:hover { + background: #4d8dff; +} + +/* 按下 */ +QSlider::handle:horizontal:pressed { + background: #1f4fff; +} + + + + 0 + + + 0 + + + 0 + + + 0 + + + 10 + + + + + QWidget #contentWidget +{ + background: #040125; + /*border-radius: 8px 8px 8px 8px;*/ + border: 1px solid #2f6bff; +} - + + + 0 + + + 0 + + + 0 + + + 0 + + + 10 + - - - true - - - 线性平台 - - - Qt::AlignCenter - - - - - - - - - - 超声 - - - - - - - false - - - - - - - 新版 - - - - - - - 连接线性平台 - - - - - - - - - - 调焦 - - - - - - true - - - 采样率 - - - Qt::AlignCenter - - - - - - - - 0 - 0 - - - - 20 - - - Qt::AlignCenter - - - - - - - 24 - - - - - - - 自动调焦 - - - - - - - Qt::Horizontal - - - - 171 - 20 - - - - - - - - 手动调焦 - - - - - - - - - - 调整线性平台 - - - - + - + 0 0 - - 更新实时位置 - - - - - 0 - 0 + 43 - - null + + + 16777215 + 43 + - - Qt::AlignCenter - - - true + + QWidget #titlebarWidget +{ + background: #0E1C4C; + border: 1px solid #2f6bff; +} + + + + + + + + + + + + + 调焦 + + + + + + + Qt::Horizontal + + + + 505 + 20 + + + + + + + + + + + + icon/all/close.svgicon/all/close.svg + + + + - - - 移动至 - - - - - - - - 0 - 0 - - - - 10 - - - Qt::AlignCenter - - - - - - - + - - - - - - - - 0 - 0 - - - - 10 - - - Qt::AlignCenter - - - - - - - - - - - - - - - - 0 - 0 - - - - 10 - - - Qt::AlignCenter - - - - - - - LogicZero - - - - - - - max - - - - - - - 量程测量 - + + + + 10 + + + 10 + + + 10 + + + 10 + + + 10 + + + + + QWidget #connectFocusModule_widget +{ + background: #121945; + border-radius: 5px 5px 5px 5px; +} + +QRadioButton +{ + color: #E2EDFF; +} + + + + + + + 0 + 0 + + + + 连接调焦模块 + + + + + + + true + + + 线性平台 + + + Qt::AlignCenter + + + + + + + + + + 超声 + + + + + + + false + + + + + + + 新版 + + + + + + + Qt::Horizontal + + + + 107 + 20 + + + + + + + + 连接线性平台 + + + + + + + + + + QWidget #controlMotor_widget +{ + background: #121945; + border-radius: 5px 5px 5px 5px; +} + + + + + + 移动至 + + + + + + + LogicZero + + + + + + + + 88 + 30 + + + + 10 + + + Qt::AlignCenter + + + + + + + + + + + + + + + + 88 + 30 + + + + 10 + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + + 0 + 34 + + + + 更新实时位置 + + + + + + + + 88 + 30 + + + + 10 + + + Qt::AlignCenter + + + + + + + 量程测量 + + + + + + + + 88 + 30 + + + + null + + + Qt::AlignCenter + + + true + + + + + + + - + + + + + + + max + + + + + + + + 0 + 0 + + + + 调整线性平台 + + + + + + + + + + QWidget #controlFocus_widget +{ + background: #121945; + border-radius: 5px 5px 5px 5px; +} + + + + + + + 0 + 0 + + + + 调焦 + + + + + + + true + + + 采样率 + + + Qt::AlignCenter + + + + + + + + 88 + 30 + + + + 20 + + + Qt::AlignCenter + + + + + + + QProgressBar { + border: 2px solid #08FACE; /* 边框颜色和宽度 */ + border-radius: 8px; /* 圆角 */ + background-color: #eee; /* 未完成部分颜色 */ + text-align: center; /* 百分比文本居中 */ + height: 13px; /* 高度 */ + } + + QProgressBar::chunk { + background-color: #08FACE; /* 渐变色进度块 */ + border-radius: 8px; /* 保持和整体圆角一致 */ + } + + + 24 + + + + + + + 自动调焦 + + + + + + + Qt::Horizontal + + + + 171 + 20 + + + + + + + + 手动调焦 + + + + + + + diff --git a/HPPA/HPPA.cpp b/HPPA/HPPA.cpp index 0fc9da7..9942f84 100644 --- a/HPPA/HPPA.cpp +++ b/HPPA/HPPA.cpp @@ -1882,8 +1882,9 @@ void HPPA::onFocus1() { focusWindow* w = new focusWindow(this, m_Imager); connect(w, SIGNAL(StartManualFocusSignal(int)), this, SLOT(onFocus2(int))); + connect(w, SIGNAL(closeSignal()), this, SLOT(onFocusWindowClosed())); - //w->setModal(true);//设置窗口为模态:只能操作当前窗口 + w->setModal(true);//设置窗口为模态:只能操作当前窗口 w->show(); w->exec(); @@ -1894,18 +1895,23 @@ void HPPA::onFocus2(int command) { if (command == 1) { + if (m_focusTab) + { + emit StartFocusSignal(); + return; + } //创建影像显示窗口 - QWidget* tabTmp = new QWidget(); + m_focusTab = new QWidget(); QGridLayout* GridLayout = new QGridLayout(); - GridLayout->addWidget(new Mapcavas(tabTmp)); + GridLayout->addWidget(new Mapcavas(m_focusTab)); - tabTmp->setLayout(GridLayout); + m_focusTab->setLayout(GridLayout); - m_imageViewerTabWidget->addTab(tabTmp, QString::fromLocal8Bit("调焦")); + m_imageViewerTabWidget->addTab(m_focusTab, QString::fromLocal8Bit("调焦")); //m_imageViewerTabWidget->setCurrentIndex(trackNumber); - m_imageViewerTabWidget->setCurrentWidget(tabTmp); + m_imageViewerTabWidget->setCurrentWidget(m_focusTab); //开始调焦 @@ -1917,6 +1923,19 @@ void HPPA::onFocus2(int command) } } +void HPPA::onFocusWindowClosed() +{ + //关闭调焦窗口时,停止调焦功能 + m_Imager->setFocusControlState(false); + //关闭调焦窗口tab + int index = m_imageViewerTabWidget->indexOf(m_focusTab); + if (index != -1) + { + m_imageViewerTabWidget->removeTab(index); + } + m_focusTab = nullptr; +} + void HPPA::onAbout() { aboutWindow about; @@ -2062,13 +2081,16 @@ void HPPA::PlotSpectral(int state) series->append(i, m_Imager->buffer[1368 * 150 + i]); } - QChart* chart = new QChart(); - chart->legend()->hide(); - chart->addSeries(series); - chart->createDefaultAxes(); - //chart->setTitle("Simple line chart example"); + series->setPen(QPen(QColor("#FF928A"), 2)); - m_chartView->setChart(chart); + m_chart->removeAllSeries(); + m_chart->addSeries(series); + m_chart->createDefaultAxes(); + + QValueAxis* axisX = qobject_cast(m_chart->axisX()); + QValueAxis* axisY = qobject_cast(m_chart->axisY()); + + setAxis(axisX, axisY); } else { diff --git a/HPPA/HPPA.h b/HPPA/HPPA.h index fed1dc5..28ffa42 100644 --- a/HPPA/HPPA.h +++ b/HPPA/HPPA.h @@ -285,6 +285,8 @@ private: void initMapTools(); void setMapTool(); + QWidget* m_focusTab=nullptr; + public Q_SLOTS: void onPlotHyperspectralImageRgbImage(int fileNumber, int frameNumber, QString filePath); void PlotSpectral(int state); @@ -300,6 +302,7 @@ public Q_SLOTS: void onAutoExposure(); void onFocus1(); void onFocus2(int command); + void onFocusWindowClosed(); void onAbout(); void onDark(); void recordDarkFinish(); diff --git a/HPPA/HPPA.vcxproj b/HPPA/HPPA.vcxproj index 1eac651..7cf4959 100644 --- a/HPPA/HPPA.vcxproj +++ b/HPPA/HPPA.vcxproj @@ -32,7 +32,7 @@ 5.13.2_msvc2017_64 - core;network;gui;widgets;serialport;websockets;3dcore;3danimation;3dextras;3dinput;3dlogic;3drender;3dquick;charts + core;network;gui;svg;widgets;serialport;websockets;3dcore;3danimation;3dextras;3dinput;3dlogic;3drender;3dquick;charts debug diff --git a/HPPA/focusWindow.cpp b/HPPA/focusWindow.cpp index 888f318..1acf6a9 100644 --- a/HPPA/focusWindow.cpp +++ b/HPPA/focusWindow.cpp @@ -1,10 +1,22 @@ #include "stdafx.h" #include "focusWindow.h" +#include +#include focusWindow::focusWindow(QWidget *parent, ImagerOperationBase* imager) { ui.setupUi(this); + setWindowFlags(Qt::FramelessWindowHint); + ui.titlebarWidget->installEventFilter(this); + + QSvgRenderer svgRenderer(QString(".//icon//all//focus.svg")); + QPixmap pixmap(24, 24); + pixmap.fill(Qt::transparent); // 背景透明 + QPainter painter(&pixmap); + svgRenderer.render(&painter); + ui.iconLabel->setPixmap(pixmap); + //读取配置文件 string HPPACfgFile = getPathofEXE() + "\\HPPA.cfg"; Configfile configfile; @@ -39,6 +51,7 @@ focusWindow::focusWindow(QWidget *parent, ImagerOperationBase* imager) connect(this->ui.moveto_btn, SIGNAL(clicked()), this, SLOT(onMoveto())); connect(this->ui.rangeMeasurement_btn, SIGNAL(pressed()), this, SLOT(onx_rangeMeasurement())); + connect(this->ui.closeBtn, SIGNAL(released()), this, SLOT(onExit())); //查找可用串口,并显示 foreach(const QSerialPortInfo &info, QSerialPortInfo::availablePorts()) @@ -67,6 +80,7 @@ focusWindow::~focusWindow() printf("destroy focusWindow-------------------------\n"); emit StartManualFocusSignal(0);//当用户没有点击停止调焦就关闭窗口 + emit closeSignal(); delete m_ctrlFocusMotor; //delete thread1, progressThread; @@ -78,9 +92,50 @@ focusWindow::~focusWindow() m_MotionCaptureCoordinatorThread.wait(); } +void focusWindow::onExit() +{ + this->close(); +} + +bool focusWindow::eventFilter(QObject *obj, QEvent *event) +{ + if (obj == ui.titlebarWidget) + { + if (event->type() == QEvent::MouseButtonPress) + { + QMouseEvent *mouseEvent = static_cast(event); + if (mouseEvent->button() == Qt::LeftButton) + { + m_bDrag = true; + m_dragPosition = mouseEvent->globalPos() - frameGeometry().topLeft(); + return true; + } + } + else if (event->type() == QEvent::MouseMove) + { + QMouseEvent *mouseEvent = static_cast(event); + if (m_bDrag && (mouseEvent->buttons() & Qt::LeftButton)) + { + move(mouseEvent->globalPos() - m_dragPosition); + return true; + } + } + else if (event->type() == QEvent::MouseButtonRelease) + { + QMouseEvent *mouseEvent = static_cast(event); + if (mouseEvent->button() == Qt::LeftButton) + { + m_bDrag = false; + return true; + } + } + } + return QDialog::eventFilter(obj, event); +} + void focusWindow::disableBeforeConnect(bool disable) { - ui.controlMotor_groupBox->setDisabled(disable); + ui.controlMotor_widget->setDisabled(disable); ui.autoFocus_btn->setDisabled(disable); } @@ -151,7 +206,7 @@ void focusWindow::onConnectMotor() int motorPort = rx.cap(0).toInt(); rx.indexIn(ultrasoundPortTmp, 0); int ultrasoundPort = rx.cap(0).toInt(); - + if (isUltrasound) diff --git a/HPPA/focusWindow.h b/HPPA/focusWindow.h index 496a0a7..54c9199 100644 --- a/HPPA/focusWindow.h +++ b/HPPA/focusWindow.h @@ -105,8 +105,13 @@ public: ImagerOperationBase* m_Imager; +protected: + bool eventFilter(QObject *obj, QEvent *event) override; private: + QPoint m_dragPosition; + bool m_bDrag = false; + Ui::focusDialog ui; QThread *m_AutoFocusThread; int m_FocusState; @@ -151,6 +156,8 @@ public Q_SLOTS: void moveAfterAutoFocus(int motorID, double location); + void onExit(); + signals: void StartManualFocusSignal(int);//1ʼ0ֹͣ @@ -161,6 +168,7 @@ signals: void zeroStartSignal(int); void startStepMotion(double speed, int stepInterval = 100, double startPos = 0, double endPos = -1); + void closeSignal(); }; class WorkerThread2 : public QThread