调焦窗口美化

This commit is contained in:
tangchao0503
2026-03-17 19:11:33 +08:00
parent 4af1187b7d
commit ca10848750
6 changed files with 679 additions and 252 deletions

View File

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>632</width> <width>557</width>
<height>444</height> <height>432</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -17,258 +17,597 @@
<iconset resource="HPPA.qrc"> <iconset resource="HPPA.qrc">
<normaloff>:/HPPA/HPPA.ico</normaloff>:/HPPA/HPPA.ico</iconset> <normaloff>:/HPPA/HPPA.ico</normaloff>:/HPPA/HPPA.ico</iconset>
</property> </property>
<layout class="QGridLayout" name="gridLayout_4"> <property name="styleSheet">
<item row="0" column="0" rowspan="2"> <string notr="true">QLineEdit {
<widget class="QGroupBox" name="connectFocusModule_groupBox"> background-color: #142D7F;
<property name="title"> color: #e6eeff;
<string>连接调焦模块</string> border: 1px solid #2f6bff;
border-radius: 6px;
padding: 4px 8px;
min-width: 70px;
min-height: 20px;
font-size: 13px;
}
QGroupBox
{
border: 12px solid transparent;
/*border-top: 12px solid transparent;
border-right: 0px solid transparent;
border-bottom: 0px solid transparent;
border-left: 0px solid transparent;*/
color: #ACCDFF;
}
QPushButton
{
/*width: 172px;
height: 56px;*/
font: 10pt &quot;新宋体&quot;;
background-color: qlineargradient(
spread:pad,
x1:0.5, y1:0, x2:0.5, y2:1,
stop:0 #283D86,
stop:1 #0F1A40
);
color: white;
border: none;
padding: 8px 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;
}</string>
</property>
<layout class="QGridLayout" name="gridLayout_6">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="spacing">
<number>10</number>
</property>
<item row="0" column="0">
<widget class="QWidget" name="contentWidget" native="true">
<property name="styleSheet">
<string notr="true">QWidget #contentWidget
{
background: #040125;
/*border-radius: 8px 8px 8px 8px;*/
border: 1px solid #2f6bff;
}</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout_7">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="spacing">
<number>10</number>
</property>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="label_2"> <widget class="QWidget" name="titlebarWidget" native="true">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>线性平台</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="motorPort_comboBox"/>
</item>
<item row="1" column="0">
<widget class="QRadioButton" name="ultrasound_radioButton">
<property name="text">
<string>超声</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="ultrasoundPort_comboBox">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="QRadioButton" name="is_new_version_radioButton">
<property name="text">
<string>新版</string>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="QPushButton" name="connectMotor_btn">
<property name="text">
<string>连接线性平台</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="1">
<widget class="QGroupBox" name="controlFocus_groupBox">
<property name="title">
<string>调焦</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QLabel" name="label_3">
<property name="enabled">
<bool>true</bool>
</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="sample_ratio_lineEdit">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>20</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QProgressBar" name="autoFocusProgress_progressBar">
<property name="value">
<number>24</number>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="autoFocus_btn">
<property name="text">
<string>自动调焦</string>
</property>
</widget>
</item>
<item row="2" column="0">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>171</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="1">
<widget class="QPushButton" name="manualFocus_btn">
<property name="text">
<string>手动调焦</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="0" column="1">
<widget class="QGroupBox" name="controlMotor_groupBox">
<property name="title">
<string>调整线性平台</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QPushButton" name="updateCurrentLocation_btn">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed"> <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="text">
<string>更新实时位置</string>
</property>
</widget>
</item>
<item row="0" column="1" colspan="2">
<widget class="QLineEdit" name="currentLocation_lineEdit">
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>0</width> <width>0</width>
<height>0</height> <height>43</height>
</size> </size>
</property> </property>
<property name="text"> <property name="maximumSize">
<string>null</string> <size>
<width>16777215</width>
<height>43</height>
</size>
</property> </property>
<property name="alignment"> <property name="styleSheet">
<set>Qt::AlignCenter</set> <string notr="true">QWidget #titlebarWidget
</property> {
<property name="readOnly"> background: #0E1C4C;
<bool>true</bool> border: 1px solid #2f6bff;
}
</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout_5">
<item row="0" column="0">
<widget class="QLabel" name="iconLabel">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label_7">
<property name="text">
<string>调焦</string>
</property>
</widget>
</item>
<item row="0" column="2">
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>505</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="3">
<widget class="QPushButton" name="closeBtn">
<property name="text">
<string/>
</property>
<property name="icon">
<iconset>
<normaloff>icon/all/close.svg</normaloff>icon/all/close.svg</iconset>
</property>
</widget>
</item>
</layout>
</widget> </widget>
</item> </item>
<item row="1" column="0"> <item row="1" column="0">
<widget class="QPushButton" name="moveto_btn"> <widget class="QWidget" name="widget" native="true">
<property name="text"> <layout class="QGridLayout" name="gridLayout_2">
<string>移动至</string> <property name="leftMargin">
</property> <number>10</number>
</widget> </property>
</item> <property name="topMargin">
<item row="1" column="1" colspan="2"> <number>10</number>
<widget class="QLineEdit" name="move2_lineEdit"> </property>
<property name="minimumSize"> <property name="rightMargin">
<size> <number>10</number>
<width>0</width> </property>
<height>0</height> <property name="bottomMargin">
</size> <number>10</number>
</property> </property>
<property name="text"> <property name="spacing">
<string>10</string> <number>10</number>
</property> </property>
<property name="alignment"> <item row="0" column="0" rowspan="2">
<set>Qt::AlignCenter</set> <widget class="QWidget" name="connectFocusModule_widget" native="true">
</property> <property name="styleSheet">
</widget> <string notr="true">QWidget #connectFocusModule_widget
</item> {
<item row="2" column="0"> background: #121945;
<widget class="QPushButton" name="add_btn"> border-radius: 5px 5px 5px 5px;
<property name="text"> }
<string>+</string>
</property> QRadioButton
</widget> {
</item> color: #E2EDFF;
<item row="2" column="1" colspan="2"> }</string>
<widget class="QLineEdit" name="addStepSize_lineEdit"> </property>
<property name="minimumSize"> <layout class="QGridLayout" name="gridLayout">
<size> <item row="0" column="0">
<width>0</width> <widget class="QLabel" name="label">
<height>0</height> <property name="sizePolicy">
</size> <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
</property> <horstretch>0</horstretch>
<property name="text"> <verstretch>0</verstretch>
<string>10</string> </sizepolicy>
</property> </property>
<property name="alignment"> <property name="text">
<set>Qt::AlignCenter</set> <string>连接调焦模块</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="0"> <item row="1" column="0">
<widget class="QPushButton" name="subtract_btn"> <widget class="QLabel" name="label_2">
<property name="text"> <property name="enabled">
<string>-</string> <bool>true</bool>
</property> </property>
</widget> <property name="text">
</item> <string>线性平台</string>
<item row="3" column="1" colspan="2"> </property>
<widget class="QLineEdit" name="subtractStepSize_lineEdit"> <property name="alignment">
<property name="minimumSize"> <set>Qt::AlignCenter</set>
<size> </property>
<width>0</width> </widget>
<height>0</height> </item>
</size> <item row="1" column="1">
</property> <widget class="QComboBox" name="motorPort_comboBox"/>
<property name="text"> </item>
<string>10</string> <item row="2" column="0">
</property> <widget class="QRadioButton" name="ultrasound_radioButton">
<property name="alignment"> <property name="text">
<set>Qt::AlignCenter</set> <string>超声</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="0"> <item row="2" column="1">
<widget class="QPushButton" name="logicZero_btn"> <widget class="QComboBox" name="ultrasoundPort_comboBox">
<property name="text"> <property name="enabled">
<string>LogicZero</string> <bool>false</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="1"> <item row="3" column="0">
<widget class="QPushButton" name="max_btn"> <widget class="QRadioButton" name="is_new_version_radioButton">
<property name="text"> <property name="text">
<string>max</string> <string>新版</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="2"> <item row="3" column="1">
<widget class="QPushButton" name="rangeMeasurement_btn"> <spacer name="horizontalSpacer_2">
<property name="text"> <property name="orientation">
<string>量程测量</string> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" stdset="0">
<size>
<width>107</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="4" column="0" colspan="2">
<widget class="QPushButton" name="connectMotor_btn">
<property name="text">
<string>连接线性平台</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="0" column="1">
<widget class="QWidget" name="controlMotor_widget" native="true">
<property name="styleSheet">
<string notr="true">QWidget #controlMotor_widget
{
background: #121945;
border-radius: 5px 5px 5px 5px;
}</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="2" column="0">
<widget class="QPushButton" name="moveto_btn">
<property name="text">
<string>移动至</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QPushButton" name="logicZero_btn">
<property name="text">
<string>LogicZero</string>
</property>
</widget>
</item>
<item row="2" column="1" colspan="2">
<widget class="QLineEdit" name="move2_lineEdit">
<property name="minimumSize">
<size>
<width>88</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>10</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QPushButton" name="add_btn">
<property name="text">
<string>+</string>
</property>
</widget>
</item>
<item row="4" column="1" colspan="2">
<widget class="QLineEdit" name="subtractStepSize_lineEdit">
<property name="minimumSize">
<size>
<width>88</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>10</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="updateCurrentLocation_btn">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>34</height>
</size>
</property>
<property name="text">
<string>更新实时位置</string>
</property>
</widget>
</item>
<item row="3" column="1" colspan="2">
<widget class="QLineEdit" name="addStepSize_lineEdit">
<property name="minimumSize">
<size>
<width>88</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>10</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="5" column="2">
<widget class="QPushButton" name="rangeMeasurement_btn">
<property name="text">
<string>量程测量</string>
</property>
</widget>
</item>
<item row="1" column="1" colspan="2">
<widget class="QLineEdit" name="currentLocation_lineEdit">
<property name="minimumSize">
<size>
<width>88</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>null</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QPushButton" name="subtract_btn">
<property name="text">
<string>-</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QPushButton" name="max_btn">
<property name="text">
<string>max</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_5">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>调整线性平台</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="1">
<widget class="QWidget" name="controlFocus_widget" native="true">
<property name="styleSheet">
<string notr="true">QWidget #controlFocus_widget
{
background: #121945;
border-radius: 5px 5px 5px 5px;
}</string>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
<widget class="QLabel" name="label_4">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>调焦</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_3">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>采样率</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="sample_ratio_lineEdit">
<property name="minimumSize">
<size>
<width>88</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>20</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QProgressBar" name="autoFocusProgress_progressBar">
<property name="styleSheet">
<string notr="true">QProgressBar {
border: 2px solid #08FACE; /* 边框颜色和宽度 */
border-radius: 8px; /* 圆角 */
background-color: #eee; /* 未完成部分颜色 */
text-align: center; /* 百分比文本居中 */
height: 13px; /* 高度 */
}
QProgressBar::chunk {
background-color: #08FACE; /* 渐变色进度块 */
border-radius: 8px; /* 保持和整体圆角一致 */
}</string>
</property>
<property name="value">
<number>24</number>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QPushButton" name="autoFocus_btn">
<property name="text">
<string>自动调焦</string>
</property>
</widget>
</item>
<item row="3" column="0">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>171</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="1">
<widget class="QPushButton" name="manualFocus_btn">
<property name="text">
<string>手动调焦</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget> </widget>
</item> </item>
</layout> </layout>

View File

@ -1882,8 +1882,9 @@ void HPPA::onFocus1()
{ {
focusWindow* w = new focusWindow(this, m_Imager); focusWindow* w = new focusWindow(this, m_Imager);
connect(w, SIGNAL(StartManualFocusSignal(int)), this, SLOT(onFocus2(int))); 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->show();
w->exec(); w->exec();
@ -1894,18 +1895,23 @@ void HPPA::onFocus2(int command)
{ {
if (command == 1) if (command == 1)
{ {
if (m_focusTab)
{
emit StartFocusSignal();
return;
}
//创建影像显示窗口 //创建影像显示窗口
QWidget* tabTmp = new QWidget(); m_focusTab = new QWidget();
QGridLayout* GridLayout = new QGridLayout(); 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->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() void HPPA::onAbout()
{ {
aboutWindow about; aboutWindow about;
@ -2062,13 +2081,16 @@ void HPPA::PlotSpectral(int state)
series->append(i, m_Imager->buffer[1368 * 150 + i]); series->append(i, m_Imager->buffer[1368 * 150 + i]);
} }
QChart* chart = new QChart(); series->setPen(QPen(QColor("#FF928A"), 2));
chart->legend()->hide();
chart->addSeries(series);
chart->createDefaultAxes();
//chart->setTitle("Simple line chart example");
m_chartView->setChart(chart); m_chart->removeAllSeries();
m_chart->addSeries(series);
m_chart->createDefaultAxes();
QValueAxis* axisX = qobject_cast<QValueAxis*>(m_chart->axisX());
QValueAxis* axisY = qobject_cast<QValueAxis*>(m_chart->axisY());
setAxis(axisX, axisY);
} }
else else
{ {

View File

@ -285,6 +285,8 @@ private:
void initMapTools(); void initMapTools();
void setMapTool(); void setMapTool();
QWidget* m_focusTab=nullptr;
public Q_SLOTS: public Q_SLOTS:
void onPlotHyperspectralImageRgbImage(int fileNumber, int frameNumber, QString filePath); void onPlotHyperspectralImageRgbImage(int fileNumber, int frameNumber, QString filePath);
void PlotSpectral(int state); void PlotSpectral(int state);
@ -300,6 +302,7 @@ public Q_SLOTS:
void onAutoExposure(); void onAutoExposure();
void onFocus1(); void onFocus1();
void onFocus2(int command); void onFocus2(int command);
void onFocusWindowClosed();
void onAbout(); void onAbout();
void onDark(); void onDark();
void recordDarkFinish(); void recordDarkFinish();

View File

@ -32,7 +32,7 @@
</ImportGroup> </ImportGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'" Label="QtSettings"> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'" Label="QtSettings">
<QtInstall>5.13.2_msvc2017_64</QtInstall> <QtInstall>5.13.2_msvc2017_64</QtInstall>
<QtModules>core;network;gui;widgets;serialport;websockets;3dcore;3danimation;3dextras;3dinput;3dlogic;3drender;3dquick;charts</QtModules> <QtModules>core;network;gui;svg;widgets;serialport;websockets;3dcore;3danimation;3dextras;3dinput;3dlogic;3drender;3dquick;charts</QtModules>
<QtBuildConfig>debug</QtBuildConfig> <QtBuildConfig>debug</QtBuildConfig>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'" Label="QtSettings"> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'" Label="QtSettings">

View File

@ -1,10 +1,22 @@
#include "stdafx.h" #include "stdafx.h"
#include "focusWindow.h" #include "focusWindow.h"
#include <QSvgRenderer>
#include <QMouseEvent>
focusWindow::focusWindow(QWidget *parent, ImagerOperationBase* imager) focusWindow::focusWindow(QWidget *parent, ImagerOperationBase* imager)
{ {
ui.setupUi(this); 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"; string HPPACfgFile = getPathofEXE() + "\\HPPA.cfg";
Configfile configfile; 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.moveto_btn, SIGNAL(clicked()), this, SLOT(onMoveto()));
connect(this->ui.rangeMeasurement_btn, SIGNAL(pressed()), this, SLOT(onx_rangeMeasurement())); 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()) foreach(const QSerialPortInfo &info, QSerialPortInfo::availablePorts())
@ -67,6 +80,7 @@ focusWindow::~focusWindow()
printf("destroy focusWindow-------------------------\n"); printf("destroy focusWindow-------------------------\n");
emit StartManualFocusSignal(0);//当用户没有点击停止调焦就关闭窗口 emit StartManualFocusSignal(0);//当用户没有点击停止调焦就关闭窗口
emit closeSignal();
delete m_ctrlFocusMotor; delete m_ctrlFocusMotor;
//delete thread1, progressThread; //delete thread1, progressThread;
@ -78,9 +92,50 @@ focusWindow::~focusWindow()
m_MotionCaptureCoordinatorThread.wait(); 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<QMouseEvent *>(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<QMouseEvent *>(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<QMouseEvent *>(event);
if (mouseEvent->button() == Qt::LeftButton)
{
m_bDrag = false;
return true;
}
}
}
return QDialog::eventFilter(obj, event);
}
void focusWindow::disableBeforeConnect(bool disable) void focusWindow::disableBeforeConnect(bool disable)
{ {
ui.controlMotor_groupBox->setDisabled(disable); ui.controlMotor_widget->setDisabled(disable);
ui.autoFocus_btn->setDisabled(disable); ui.autoFocus_btn->setDisabled(disable);
} }
@ -151,7 +206,7 @@ void focusWindow::onConnectMotor()
int motorPort = rx.cap(0).toInt(); int motorPort = rx.cap(0).toInt();
rx.indexIn(ultrasoundPortTmp, 0); rx.indexIn(ultrasoundPortTmp, 0);
int ultrasoundPort = rx.cap(0).toInt(); int ultrasoundPort = rx.cap(0).toInt();
if (isUltrasound) if (isUltrasound)

View File

@ -105,8 +105,13 @@ public:
ImagerOperationBase* m_Imager; ImagerOperationBase* m_Imager;
protected:
bool eventFilter(QObject *obj, QEvent *event) override;
private: private:
QPoint m_dragPosition;
bool m_bDrag = false;
Ui::focusDialog ui; Ui::focusDialog ui;
QThread *m_AutoFocusThread; QThread *m_AutoFocusThread;
int m_FocusState; int m_FocusState;
@ -151,6 +156,8 @@ public Q_SLOTS:
void moveAfterAutoFocus(int motorID, double location); void moveAfterAutoFocus(int motorID, double location);
void onExit();
signals: signals:
void StartManualFocusSignal(int);//1<><31><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0<EFBFBD><30>ֹͣ<CDA3><D6B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD> void StartManualFocusSignal(int);//1<><31><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0<EFBFBD><30>ֹͣ<CDA3><D6B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
@ -161,6 +168,7 @@ signals:
void zeroStartSignal(int); void zeroStartSignal(int);
void startStepMotion(double speed, int stepInterval = 100, double startPos = 0, double endPos = -1); void startStepMotion(double speed, int stepInterval = 100, double startPos = 0, double endPos = -1);
void closeSignal();
}; };
class WorkerThread2 : public QThread class WorkerThread2 : public QThread