Procházet zdrojové kódy

添加运动轴逻辑

JonYang před 6 hodinami
rodič
revize
65c4b561d7

+ 15 - 0
View/die-bonder-ui/SBTdie-bonder-ui.pro

@@ -15,6 +15,21 @@ SOURCES += $$files(*.cpp, $$PWD)
 HEADERS += $$files(*.h, $$PWD)
 FORMS   += $$files(*.ui, $$PWD)
 
+SOURCES += $$files(*.cpp, $$PWD) \
+    Src/RewriteControl/LightJoystickSwitchPage.cpp \
+    Src/RewriteControl/MsgDlg/CustomMessageDlg.cpp \
+    Src/RewriteControl/SpeedAdjPage.cpp \
+    Src/RewriteControl/SpeedAdjWnd.cpp
+HEADERS += $$files(*.h, $$PWD) \
+    Src/RewriteControl/LightJoystickSwitchPage.h \
+    Src/RewriteControl/MsgDlg/CustomMessageDlg.h \
+    Src/RewriteControl/SpeedAdjPage.h \
+    Src/RewriteControl/SpeedAdjWnd.h
+FORMS   += $$files(*.ui, $$PWD) \
+    Src/RewriteControl/LightJoystickSwitchPage.ui \
+    Src/RewriteControl/SpeedAdjPage.ui \
+    Src/RewriteControl/SpeedAdjWnd.ui
+
 # Default rules for deployment.
 qnx: target.path = /tmp/$${TARGET}/bin
 else: unix:!android: target.path = /opt/$${TARGET}/bin

+ 17 - 0
View/die-bonder-ui/Src/CameraBind.cpp

@@ -94,6 +94,23 @@ void CameraBind::SetModuleMove(const std::string& strModuleType, const std::stri
     }
 }
 
+void CameraBind::JModuleMove(std::string ModuleType, std::vector<ns_module::MODULE_COORD_MOVE> vecPos, bool bMoveTo)
+{
+    if (m_pCViewInterface == nullptr)
+    {
+        return;
+    }
+
+    if (bMoveTo)
+    {
+        m_pCViewInterface->ModuleMoveTo(ModuleType, vecPos);
+    }
+    else
+    {
+        m_pCViewInterface->ModuleMove(ModuleType, vecPos);
+    }
+}
+
 void CameraBind::JToHome()
 {
     if (m_pCViewInterface == nullptr)

+ 1 - 0
View/die-bonder-ui/Src/CameraBind.h

@@ -62,6 +62,7 @@ public:
     /**ÒÆ¶¯Öá
      */
     void SetModuleMove(const std::string& strModuleType, const std::string& enAxisType, double pos, bool bMoveTo);
+    void JModuleMove(std::string ModuleType, std::vector<ns_module::MODULE_COORD_MOVE> vecPos, bool bMoveTo);
 
     /**»ØÁã
      */

+ 29 - 4
View/die-bonder-ui/Src/RewriteControl/Controls/JReLineEdit.cpp

@@ -1,5 +1,4 @@
 #include "JReLineEdit.h"
-#include "../SpeedAdjPage.h"
 #include <QGroupBox>
 #include <QComboBox>
 #include <QCheckBox>
@@ -97,9 +96,35 @@ void JReLineEdit::CheckVal()
         }
     }
 
-    SpeedAdjPage* pNew = new SpeedAdjPage();
-    pNew->updateDefVal(m_stSavedefVal);
-    pNew->show();
+    CreateSpeedAdjPage();
+}
+
+void JReLineEdit::CreateSpeedAdjPage()
+{
+    if (m_pSpeedWnd)
+    {
+        m_pSpeedWnd->close();
+        m_pSpeedWnd->deleteLater();
+    }
+    m_pSpeedWnd = new SpeedAdjPage(this);
+    m_pSpeedWnd->updateDefVal(m_stSavedefVal);
+    m_pSpeedWnd->setAttribute(Qt::WA_DeleteOnClose);
+    {
+        QPoint mousePos = QCursor::pos();
+        QPoint newPos = QPoint(mousePos.x() - m_pSpeedWnd->width() / 2,
+            mousePos.y() - m_pSpeedWnd->height() - 10);
+        m_pSpeedWnd->move(newPos);
+    }
+    connect(m_pSpeedWnd, &SpeedAdjPage::CloseWnd, this, &JReLineEdit::GetCloseWndSlots);
+
+    m_pSpeedWnd->show();
+}
+
+void JReLineEdit::GetCloseWndSlots(int nVal)
+{
+    double doVal = text().toDouble();
+    doVal = doVal + nVal;
+    setText(QString::number(doVal, 'f', 2));
 }
 
 void JReLineEdit::mousePressEvent(QMouseEvent* event)

+ 11 - 1
View/die-bonder-ui/Src/RewriteControl/Controls/JReLineEdit.h

@@ -9,9 +9,10 @@
 // *****************************************************************************
 #ifndef JRELINEEDIT_H
 #define JRELINEEDIT_H
+
 #include <QLineEdit>
-#include <QMessageBox>
 #include <QMouseEvent>
+#include <QPointer>
 #include "../SpeedAdjPage.h"
 
 class JReLineEdit : public QLineEdit
@@ -30,11 +31,20 @@ public:
     /**修改控件值
      */
     void CheckVal();
+
+    /**速度修改窗口
+     */
+    void CreateSpeedAdjPage();
+private slots:
+    void GetCloseWndSlots(int nVal);
+
 protected:
     void mousePressEvent(QMouseEvent* event) override;
 
 private:
     ST_DEF_VAL      m_stSavedefVal;
+
+    QPointer<SpeedAdjPage> m_pSpeedWnd;
 };
 
 #endif // JRELINEEDIT_H

+ 153 - 7
View/die-bonder-ui/Src/RewriteControl/LightJoystickSwitchPage.cpp

@@ -2,6 +2,7 @@
 #include "ui_LightJoystickSwitchPage.h"
 #include "../common/JMessageTip.h"
 #include "../common/JQCommon.h"
+#include <QHash>
 
 LightJoystickSwitchPage::LightJoystickSwitchPage(QWidget *parent)
     : QWidget(parent)
@@ -24,7 +25,7 @@ void LightJoystickSwitchPage::InitForm()
     InitLineEdits();
     SliderBind();
 
-    JQCommon::SetQLineEditLimit(ui->valLineEdit);
+   // JQCommon::SetQLineEditLimit(ui->valLineEdit);
 }
 
 
@@ -59,6 +60,71 @@ void LightJoystickSwitchPage::InitLineEdits()
     }
 }
 
+void LightJoystickSwitchPage::MoveModule(const QString strAxis, const QString pos)
+{
+    if (m_pCameraBind)
+    {
+        // 目前没有测试多轴,多轴在用
+        std::vector<ns_module::MODULE_COORD_MOVE> vecPos;
+        vecPos.push_back({ strAxis.toStdString() ,pos.toDouble() });
+        m_pCameraBind->JModuleMove(ui->modeComboBox->currentText().toStdString(), vecPos, false);
+    }
+}
+
+void LightJoystickSwitchPage::DisableLayoutWidgets(QLayout* layout, bool isShow /*= false*/)
+{
+    for (int i = 0; i < layout->count(); ++i) 
+    {
+        QLayoutItem* item = layout->itemAt(i);
+        if (item->widget()) 
+        {
+            item->widget()->setEnabled(isShow);
+        }
+        else if (item->layout()) 
+        {
+            DisableLayoutWidgets(item->layout());
+        }
+    }
+}
+
+template<class T>
+void LightJoystickSwitchPage::DeduplicationBox(QComboBox* pCom, const T& veTemp, int nIndex)
+{
+    for (auto& a : veTemp)
+    {
+        QString strName;
+        if (nIndex == 0)
+        {
+            strName = a->GetModuleType().c_str();
+        }
+        else if (nIndex == 1)
+        {
+            strName = a->GetStringAxisType().c_str();
+        }
+
+        QStringList items;
+        for (int i = 0; i < pCom->count(); ++i)
+        {
+            items << pCom->itemText(i);
+        }
+
+        bool bMa = false; // 是否匹配
+        for (auto b : items)
+        {
+            if (b == strName)
+            {
+                bMa = true;
+                break;
+            }
+        }
+
+        if (!bMa)
+        {
+            pCom->addItem(strName);
+        }
+    }
+}
+
 void LightJoystickSwitchPage::BondSliderAndLineEdit(QSlider* slider, QLineEdit* lineEdit)
 {
     QIntValidator* validator = new QIntValidator(slider->minimum(), slider->maximum(), lineEdit);
@@ -182,6 +248,10 @@ void LightJoystickSwitchPage::InitMainCameraBind(CameraBind* pCameraBind, bool b
     {
         UpdataLightVal();
     }
+    if (m_pCameraBind)
+    {
+        DeduplicationBox(ui->modeComboBox, m_pCameraBind->m_vecCAxis, 0);
+    }
 }
 
 void LightJoystickSwitchPage::UpdatemPageGroup(Group* pGroup)
@@ -264,7 +334,7 @@ void LightJoystickSwitchPage::RealTimeUpdatesToU()
 {
     if (m_pCameraBind)
     {
-        ui->JTabShowLableLoop->setText(CombiningStr(true));
+       // ui->JTabShowLableLoop->setText(CombiningStr(true));
     }
 }
 
@@ -302,7 +372,7 @@ void LightJoystickSwitchPage::MoveJoystick()
 void LightJoystickSwitchPage::RunMoveOrMoveTo(bool isMoveTo)
 {
     QString strErrInfo = {};
-    QString strNum = ui->valLineEdit->text().trimmed();
+    QString strNum = "1";//ui->valLineEdit->text().trimmed();
     if (strNum.isEmpty())
     {
         strErrInfo = tr("please input value","请输入值");
@@ -413,9 +483,85 @@ void LightJoystickSwitchPage::resizeSingleUI() {
     ui->right_Button->setGeometry(QRect(90, 40, 41, 31));
     ui->up_Button->setGeometry(QRect(50, 10, 41, 31));
     ui->down_Button->setGeometry(QRect(50, 70, 41, 31));
-    ui->move_Button->setGeometry(QRect(170, 130, 60, 23));
-    ui->JTabShowLableLoop->setGeometry(QRect(10, 50, 200, 41));
-    ui->moveTo_Button->setGeometry(QRect(170, 170, 60, 23));
-    ui->valLineEdit->setGeometry(QRect(160, 100, 71, 21));
+    //ui->move_Button->setGeometry(QRect(170, 130, 60, 23));
+    //ui->JTabShowLableLoop->setGeometry(QRect(10, 50, 200, 41));
+    //ui->moveTo_Button->setGeometry(QRect(170, 170, 60, 23));
+    //ui->valLineEdit->setGeometry(QRect(160, 100, 71, 21));
+}
+
+
+void LightJoystickSwitchPage::on_xLineEdit_textChanged(const QString &arg1)
+{
+    MoveModule("X", arg1);
+}
+
+
+void LightJoystickSwitchPage::on_yLineEdit_textChanged(const QString &arg1)
+{
+    MoveModule("Y", arg1);
+}
+
+
+void LightJoystickSwitchPage::on_zLineEdit_textChanged(const QString &arg1)
+{
+    MoveModule("Z", arg1);
+}
+
+
+void LightJoystickSwitchPage::on_rLineEdit_textChanged(const QString &arg1)
+{
+    MoveModule("R", arg1);
+}
+
+
+void LightJoystickSwitchPage::on_forceLineEdit_textChanged(const QString &arg1)
+{
+    MoveModule("FORCE", arg1);
+}
+
+void LightJoystickSwitchPage::on_modeComboBox_currentIndexChanged(int index)
+{
+    QString strMod = ui->modeComboBox->itemText(index);
+    // 先禁用所有相关布局
+    const QList<QLayout*> allLayouts = {
+        ui->forceLayout,
+        ui->xLayout,
+        ui->yLayout,
+        ui->rLayout,
+        ui->zLayout,
+    };
+    for (auto* layout : allLayouts) 
+    {
+        DisableLayoutWidgets(layout, false);
+    }
+
+    // 收集当前模块支持的轴类型
+    QSet<QString> supportedAxes;
+    for (const auto& axis : m_pCameraBind->m_vecCAxis) 
+    {
+        if (strMod == axis->GetModuleType().c_str())
+        {
+            supportedAxes.insert(axis->GetStringAxisType().c_str());
+        }
+    }
+
+    // 根据支持的轴启用对应布局
+    const QHash<QString, QLayout*> axisToLayout = {
+        {"FORCE", ui->forceLayout},
+        {"X", ui->xLayout},
+        {"Y", ui->yLayout},
+        {"R", ui->rLayout},
+        {"Z", ui->zLayout},
+        {"Z1", ui->zLayout}
+    };
+
+
+    for (auto it = axisToLayout.constBegin(); it != axisToLayout.constEnd(); ++it) 
+    {
+        if (supportedAxes.contains(it.key())) 
+        {
+            DisableLayoutWidgets(it.value(), true);
+        }
+    }   
 }
 

+ 25 - 2
View/die-bonder-ui/Src/RewriteControl/LightJoystickSwitchPage.h

@@ -57,9 +57,23 @@ public:
     /**设置移动摇杆信息
     */
     void SetMoveJoystickInfo(const ST_MOVE_AXIS& movInfo);
+
 protected:
     void timerEvent(QTimerEvent* event) override;
 
+private slots:
+    void on_xLineEdit_textChanged(const QString &arg1);
+
+    void on_yLineEdit_textChanged(const QString &arg1);
+
+    void on_zLineEdit_textChanged(const QString &arg1);
+
+    void on_rLineEdit_textChanged(const QString &arg1);
+
+    void on_forceLineEdit_textChanged(const QString &arg1);
+
+    void on_modeComboBox_currentIndexChanged(int index);
+
 private:
     /**组合字符串
      */
@@ -96,14 +110,23 @@ private:
     void SliderBind();
 
     void InitLineEdits();
+
+    /**移动轴
+     */
+    void MoveModule(const QString strAxis, const QString pos);
+
+    void DisableLayoutWidgets(QLayout* layout, bool isShow = false);
+
+
+    template<class T>
+    void DeduplicationBox(QComboBox* pCom, const T& veTemp, int nIndex);
 private:
     Ui::LightJoystickSwitchPage *ui;
 
 
     /**硬件指针
      */
-    QPointer<CameraBind> m_pCameraBind;
-    
+    QPointer<CameraBind> m_pCameraBind; // 用这个是因为需要测试
 
     /**当前页面的Group
     */

+ 265 - 158
View/die-bonder-ui/Src/RewriteControl/LightJoystickSwitchPage.ui

@@ -412,10 +412,10 @@
      <widget class="JoystickPage" name="widgetPage" native="true">
       <property name="geometry">
        <rect>
-        <x>0</x>
-        <y>-10</y>
-        <width>141</width>
-        <height>91</height>
+        <x>20</x>
+        <y>0</y>
+        <width>131</width>
+        <height>121</height>
        </rect>
       </property>
      </widget>
@@ -435,12 +435,18 @@
      <widget class="QLabel" name="label">
       <property name="geometry">
        <rect>
-        <x>20</x>
+        <x>10</x>
         <y>10</y>
-        <width>61</width>
-        <height>21</height>
+        <width>71</width>
+        <height>31</height>
        </rect>
       </property>
+      <property name="font">
+       <font>
+        <family>宋体</family>
+        <pointsize>12</pointsize>
+       </font>
+      </property>
       <property name="text">
        <string>module:</string>
       </property>
@@ -451,195 +457,296 @@
      <widget class="QComboBox" name="modeComboBox">
       <property name="geometry">
        <rect>
-        <x>100</x>
+        <x>90</x>
         <y>10</y>
-        <width>71</width>
-        <height>21</height>
-       </rect>
-      </property>
-     </widget>
-     <widget class="QLabel" name="JTabShowLableLoop">
-      <property name="geometry">
-       <rect>
-        <x>10</x>
-        <y>80</y>
-        <width>231</width>
+        <width>91</width>
         <height>31</height>
        </rect>
       </property>
       <property name="font">
        <font>
-        <family>Agency FB</family>
+        <family>宋体</family>
         <pointsize>12</pointsize>
        </font>
       </property>
-      <property name="text">
-       <string>pos:</string>
-      </property>
-      <property name="alignment">
-       <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
-      </property>
      </widget>
-     <widget class="QPushButton" name="moveTo_Button">
+     <widget class="QWidget" name="layoutWidget">
       <property name="geometry">
        <rect>
-        <x>90</x>
-        <y>50</y>
-        <width>71</width>
-        <height>23</height>
+        <x>190</x>
+        <y>90</y>
+        <width>141</width>
+        <height>33</height>
        </rect>
       </property>
-      <property name="minimumSize">
-       <size>
-        <width>42</width>
-        <height>0</height>
-       </size>
-      </property>
-      <property name="text">
-       <string>MoveTo</string>
-      </property>
+      <layout class="QHBoxLayout" name="forceLayout">
+       <property name="spacing">
+        <number>0</number>
+       </property>
+       <item>
+        <widget class="QCheckBox" name="forceCheckBox">
+         <property name="minimumSize">
+          <size>
+           <width>67</width>
+           <height>30</height>
+          </size>
+         </property>
+         <property name="font">
+          <font>
+           <family>宋体</family>
+           <pointsize>12</pointsize>
+          </font>
+         </property>
+         <property name="text">
+          <string>FORCE</string>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <widget class="JReLineEdit" name="forceLineEdit">
+         <property name="minimumSize">
+          <size>
+           <width>0</width>
+           <height>30</height>
+          </size>
+         </property>
+         <property name="font">
+          <font>
+           <family>宋体</family>
+           <pointsize>12</pointsize>
+          </font>
+         </property>
+         <property name="text">
+          <string>0</string>
+         </property>
+         <property name="alignment">
+          <set>Qt::AlignCenter</set>
+         </property>
+        </widget>
+       </item>
+      </layout>
      </widget>
-     <widget class="QLineEdit" name="valLineEdit">
+     <widget class="QWidget" name="layoutWidget">
       <property name="geometry">
        <rect>
         <x>10</x>
         <y>50</y>
-        <width>71</width>
-        <height>21</height>
+        <width>161</width>
+        <height>32</height>
        </rect>
       </property>
+      <layout class="QHBoxLayout" name="xLayout">
+       <property name="spacing">
+        <number>0</number>
+       </property>
+       <item>
+        <widget class="QCheckBox" name="xCheckBox">
+         <property name="minimumSize">
+          <size>
+           <width>56</width>
+           <height>30</height>
+          </size>
+         </property>
+         <property name="font">
+          <font>
+           <family>宋体</family>
+           <pointsize>12</pointsize>
+          </font>
+         </property>
+         <property name="text">
+          <string>X</string>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <widget class="JReLineEdit" name="xLineEdit">
+         <property name="minimumSize">
+          <size>
+           <width>0</width>
+           <height>30</height>
+          </size>
+         </property>
+         <property name="font">
+          <font>
+           <family>宋体</family>
+           <pointsize>12</pointsize>
+          </font>
+         </property>
+         <property name="text">
+          <string>0</string>
+         </property>
+         <property name="alignment">
+          <set>Qt::AlignCenter</set>
+         </property>
+        </widget>
+       </item>
+      </layout>
      </widget>
-     <widget class="QPushButton" name="move_Button">
+     <widget class="QWidget" name="layoutWidget">
       <property name="geometry">
        <rect>
-        <x>90</x>
-        <y>80</y>
-        <width>71</width>
-        <height>23</height>
+        <x>10</x>
+        <y>90</y>
+        <width>161</width>
+        <height>32</height>
        </rect>
       </property>
-      <property name="minimumSize">
-       <size>
-        <width>42</width>
-        <height>0</height>
-       </size>
-      </property>
-      <property name="text">
-       <string>Move</string>
-      </property>
+      <layout class="QHBoxLayout" name="yLayout">
+       <property name="spacing">
+        <number>0</number>
+       </property>
+       <item>
+        <widget class="QCheckBox" name="yCheckBox">
+         <property name="minimumSize">
+          <size>
+           <width>56</width>
+           <height>30</height>
+          </size>
+         </property>
+         <property name="font">
+          <font>
+           <family>宋体</family>
+           <pointsize>12</pointsize>
+          </font>
+         </property>
+         <property name="text">
+          <string>Y</string>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <widget class="JReLineEdit" name="yLineEdit">
+         <property name="minimumSize">
+          <size>
+           <width>0</width>
+           <height>30</height>
+          </size>
+         </property>
+         <property name="font">
+          <font>
+           <family>宋体</family>
+           <pointsize>12</pointsize>
+          </font>
+         </property>
+         <property name="text">
+          <string>0</string>
+         </property>
+         <property name="alignment">
+          <set>Qt::AlignCenter</set>
+         </property>
+        </widget>
+       </item>
+      </layout>
      </widget>
-     <widget class="QGroupBox" name="axisGroupBox">
+     <widget class="QWidget" name="layoutWidget">
       <property name="geometry">
        <rect>
-        <x>180</x>
-        <y>-10</y>
-        <width>161</width>
-        <height>151</height>
+        <x>190</x>
+        <y>10</y>
+        <width>141</width>
+        <height>32</height>
        </rect>
       </property>
-      <property name="title">
-       <string/>
-      </property>
-      <layout class="QVBoxLayout" name="verticalLayout">
-       <item>
-        <layout class="QHBoxLayout" name="forceLayout">
-         <item>
-          <widget class="QCheckBox" name="forceCheckBox">
-           <property name="minimumSize">
-            <size>
-             <width>56</width>
-             <height>0</height>
-            </size>
-           </property>
-           <property name="text">
-            <string>FORCE</string>
-           </property>
-          </widget>
-         </item>
-         <item>
-          <widget class="JReLineEdit" name="forceLineEdit"/>
-         </item>
-        </layout>
-       </item>
+      <layout class="QHBoxLayout" name="zLayout">
+       <property name="spacing">
+        <number>0</number>
+       </property>
        <item>
-        <layout class="QHBoxLayout" name="xLayout">
-         <item>
-          <widget class="QCheckBox" name="xCheckBox">
-           <property name="minimumSize">
-            <size>
-             <width>56</width>
-             <height>0</height>
-            </size>
-           </property>
-           <property name="text">
-            <string>X</string>
-           </property>
-          </widget>
-         </item>
-         <item>
-          <widget class="JReLineEdit" name="xLineEdit"/>
-         </item>
-        </layout>
+        <widget class="QCheckBox" name="zCheckBox">
+         <property name="minimumSize">
+          <size>
+           <width>56</width>
+           <height>30</height>
+          </size>
+         </property>
+         <property name="font">
+          <font>
+           <family>宋体</family>
+           <pointsize>12</pointsize>
+          </font>
+         </property>
+         <property name="text">
+          <string>z</string>
+         </property>
+        </widget>
        </item>
        <item>
-        <layout class="QHBoxLayout" name="yLayout">
-         <item>
-          <widget class="QCheckBox" name="yCheckBox">
-           <property name="minimumSize">
-            <size>
-             <width>56</width>
-             <height>0</height>
-            </size>
-           </property>
-           <property name="text">
-            <string>y</string>
-           </property>
-          </widget>
-         </item>
-         <item>
-          <widget class="JReLineEdit" name="yLineEdit"/>
-         </item>
-        </layout>
+        <widget class="JReLineEdit" name="zLineEdit">
+         <property name="minimumSize">
+          <size>
+           <width>0</width>
+           <height>30</height>
+          </size>
+         </property>
+         <property name="font">
+          <font>
+           <family>宋体</family>
+           <pointsize>12</pointsize>
+          </font>
+         </property>
+         <property name="text">
+          <string>0</string>
+         </property>
+         <property name="alignment">
+          <set>Qt::AlignCenter</set>
+         </property>
+        </widget>
        </item>
+      </layout>
+     </widget>
+     <widget class="QWidget" name="layoutWidget">
+      <property name="geometry">
+       <rect>
+        <x>190</x>
+        <y>50</y>
+        <width>141</width>
+        <height>32</height>
+       </rect>
+      </property>
+      <layout class="QHBoxLayout" name="rLayout">
+       <property name="spacing">
+        <number>0</number>
+       </property>
        <item>
-        <layout class="QHBoxLayout" name="zLayout">
-         <item>
-          <widget class="QCheckBox" name="zCheckBox">
-           <property name="minimumSize">
-            <size>
-             <width>56</width>
-             <height>0</height>
-            </size>
-           </property>
-           <property name="text">
-            <string>z</string>
-           </property>
-          </widget>
-         </item>
-         <item>
-          <widget class="JReLineEdit" name="zLineEdit"/>
-         </item>
-        </layout>
+        <widget class="QCheckBox" name="rCheckBox">
+         <property name="minimumSize">
+          <size>
+           <width>56</width>
+           <height>30</height>
+          </size>
+         </property>
+         <property name="font">
+          <font>
+           <family>宋体</family>
+           <pointsize>12</pointsize>
+          </font>
+         </property>
+         <property name="text">
+          <string>R</string>
+         </property>
+        </widget>
        </item>
        <item>
-        <layout class="QHBoxLayout" name="rLayout">
-         <item>
-          <widget class="QCheckBox" name="rCheckBox">
-           <property name="minimumSize">
-            <size>
-             <width>56</width>
-             <height>0</height>
-            </size>
-           </property>
-           <property name="text">
-            <string>R</string>
-           </property>
-          </widget>
-         </item>
-         <item>
-          <widget class="JReLineEdit" name="rLineEdit"/>
-         </item>
-        </layout>
+        <widget class="JReLineEdit" name="rLineEdit">
+         <property name="minimumSize">
+          <size>
+           <width>0</width>
+           <height>30</height>
+          </size>
+         </property>
+         <property name="font">
+          <font>
+           <family>宋体</family>
+           <pointsize>12</pointsize>
+          </font>
+         </property>
+         <property name="text">
+          <string>0</string>
+         </property>
+         <property name="alignment">
+          <set>Qt::AlignCenter</set>
+         </property>
+        </widget>
        </item>
       </layout>
      </widget>

+ 79 - 12
View/die-bonder-ui/Src/RewriteControl/SpeedAdjPage.cpp

@@ -1,6 +1,9 @@
 #include "SpeedAdjPage.h"
 #include "ui_SpeedAdjPage.h"
 #include <QMouseEvent>
+#include <QRegularExpression>
+#include <QPropertyAnimation>
+#include <QScreen>
 
 SpeedAdjPage::SpeedAdjPage(QWidget *parent)
     : QMainWindow(parent)
@@ -13,6 +16,7 @@ SpeedAdjPage::SpeedAdjPage(QWidget *parent)
 
 SpeedAdjPage::~SpeedAdjPage()
 {
+    qApp->removeEventFilter(this);
     delete ui;
 }
 
@@ -30,30 +34,58 @@ void SpeedAdjPage::updateDefVal(const ST_DEF_VAL& val)
     }
     strTip += ")";
 
-    ui->speedTitleLabel->setText(strTip);
+    //ui->speedTitleLabel->setText(strTip);
 
 }
 
 void SpeedAdjPage::Init()
 {
+    qApp->installEventFilter(this);
     setWindowFlag(Qt::FramelessWindowHint);
-    setFocusPolicy(Qt::StrongFocus);
+    //setFocusPolicy(Qt::StrongFocus);
 
+    // 绑定按钮
 
-    // 设置默认值
-    ui->widget_1->SetSpeedVal(1);
-    ui->widget_100->SetSpeedVal(100);
-    ui->widget_1000->SetSpeedVal(1000);
-    ui->widget_10000->SetSpeedVal(1000);
-}
+    QList<QPushButton*> listPBut;
+    listPBut.push_back(ui->subBut_1);
+    listPBut.push_back(ui->addBut_1);
 
-void SpeedAdjPage::focusOutEvent(QFocusEvent* event)
-{
-    this->close();
+    listPBut.push_back(ui->subBut_10);
+    listPBut.push_back(ui->addBut_10);
+
+    listPBut.push_back(ui->subBut_100);
+    listPBut.push_back(ui->addBut_100);
+
+    listPBut.push_back(ui->subBut_1000);
+    listPBut.push_back(ui->addBut_1000);
+
+    listPBut.push_back(ui->subBut_10000);
+    listPBut.push_back(ui->addBut_10000);
+
+    listPBut.push_back(ui->subBut_100000);
+    listPBut.push_back(ui->addBut_100000);
+
+    // 连接每个按钮的clicked信号
+    for (QPushButton* pBut : listPBut)
+    {
+        connect(pBut, &QPushButton::clicked, [this, pBut]() 
+        {
+                QRegularExpression re("^(sub|add)But_(\\d+)$");
+                QRegularExpressionMatch match = re.match(pBut->objectName());
+                if (match.hasMatch()) 
+                {
+                    QString prefix = match.captured(1);
+                    int num = match.captured(2).toInt();
+                    int value = (prefix == "sub") ? -num : num;
+                    m_nVal = value; // 更新成员变量
+                    emit CloseWnd(m_nVal);
+                }
+        });
+    }
 }
 
 void SpeedAdjPage::mousePressEvent(QMouseEvent* event)
-{
+{    
     if (event->button() == Qt::LeftButton)
     {
         m_mousePressPosition = event->globalPos();
@@ -69,3 +101,38 @@ void SpeedAdjPage::mouseMoveEvent(QMouseEvent* event)
         this->move(m_windowPosition + delta);
     }
 }
+
+bool SpeedAdjPage::eventFilter(QObject* obj, QEvent* event)
+{
+    if (event->type() == QEvent::MouseButtonPress) 
+    {
+        QMouseEvent* mouseEvent = static_cast<QMouseEvent*>(event);
+        QPoint globalPos = mouseEvent->globalPos();
+        QRect dialogFrame = this->frameGeometry();
+        if (this->isVisible() && !dialogFrame.contains(globalPos)) 
+        {
+            this->close();
+        }
+    }
+    return false;
+}
+
+void SpeedAdjPage::changeEvent(QEvent* event)
+{
+    if (event->type() == QEvent::WindowActivate)
+    {
+        // 窗口被激活
+        //qDebug() << "Main window is now active";
+    }
+    else if (event->type() == QEvent::WindowDeactivate) 
+    {
+        // 窗口失去激活
+        //qDebug() << "Main window is no longer active";
+    }
+    QMainWindow::changeEvent(event);
+}
+
+void SpeedAdjPage::on_closeBut_clicked()
+{
+    this->close();
+}

+ 17 - 1
View/die-bonder-ui/Src/RewriteControl/SpeedAdjPage.h

@@ -28,15 +28,31 @@ public:
     void updateDefVal(const ST_DEF_VAL& val);
 private:
     void Init();
+   
+signals:
+    /**窗口关闭要返回值
+     */
+    void CloseWnd(int nVal);
 
 protected:
-    void focusOutEvent(QFocusEvent* event) override;
     void mousePressEvent(QMouseEvent* event) override;
     void mouseMoveEvent(QMouseEvent* event) override;
+
+    bool eventFilter(QObject* obj, QEvent* event) override;
+
+    void changeEvent(QEvent* event) override;
+
+private slots:
+    void on_closeBut_clicked();
+
 private:
     Ui::SpeedAdjPage *ui;
 
 private:
+    int     m_nVal = 1;
+
+    bool    m_isInit = true;
+
     QPoint m_mousePressPosition;
     QPoint m_windowPosition;
 };

+ 229 - 34
View/die-bonder-ui/Src/RewriteControl/SpeedAdjPage.ui

@@ -6,69 +6,264 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>529</width>
-    <height>509</height>
+    <width>564</width>
+    <height>180</height>
    </rect>
   </property>
   <property name="windowTitle">
    <string>MainWindow</string>
   </property>
   <widget class="QWidget" name="centralwidget">
-   <widget class="QLabel" name="speedTitleLabel">
+   <widget class="QLabel" name="speedLabel">
     <property name="geometry">
      <rect>
-      <x>11</x>
-      <y>11</y>
-      <width>511</width>
-      <height>91</height>
+      <x>0</x>
+      <y>0</y>
+      <width>561</width>
+      <height>31</height>
      </rect>
     </property>
-    <property name="font">
-     <font>
-      <pointsize>16</pointsize>
-     </font>
+    <property name="styleSheet">
+     <string notr="true">background-color: rgb(170, 170, 255);</string>
     </property>
     <property name="text">
-     <string>当前速度:100000</string>
-    </property>
-    <property name="alignment">
-     <set>Qt::AlignCenter</set>
+     <string extracomment="快捷键盘">Shortcut Keyboard</string>
     </property>
    </widget>
-   <widget class="QWidget" name="">
+   <widget class="QWidget" name="gridLayoutWidget">
     <property name="geometry">
      <rect>
-      <x>10</x>
-      <y>100</y>
-      <width>511</width>
-      <height>401</height>
+      <x>0</x>
+      <y>30</y>
+      <width>561</width>
+      <height>101</height>
      </rect>
     </property>
-    <layout class="QVBoxLayout" name="verticalLayout">
-     <item>
-      <widget class="SpeedAdjWnd" name="widget_1" native="true"/>
+    <layout class="QGridLayout" name="gridLayout">
+     <property name="spacing">
+      <number>0</number>
+     </property>
+     <item row="1" column="0">
+      <widget class="QPushButton" name="subBut_10000">
+       <property name="minimumSize">
+        <size>
+         <width>80</width>
+         <height>40</height>
+        </size>
+       </property>
+       <property name="text">
+        <string>-10000</string>
+       </property>
+      </widget>
+     </item>
+     <item row="2" column="1">
+      <widget class="QPushButton" name="subBut_1000">
+       <property name="minimumSize">
+        <size>
+         <width>80</width>
+         <height>40</height>
+        </size>
+       </property>
+       <property name="text">
+        <string>-1000</string>
+       </property>
+      </widget>
+     </item>
+     <item row="2" column="3">
+      <widget class="QPushButton" name="addBut_10">
+       <property name="minimumSize">
+        <size>
+         <width>80</width>
+         <height>40</height>
+        </size>
+       </property>
+       <property name="text">
+        <string>+10</string>
+       </property>
+      </widget>
+     </item>
+     <item row="1" column="4">
+      <widget class="QPushButton" name="addBut_100">
+       <property name="minimumSize">
+        <size>
+         <width>80</width>
+         <height>40</height>
+        </size>
+       </property>
+       <property name="text">
+        <string>+100</string>
+       </property>
+      </widget>
+     </item>
+     <item row="2" column="0">
+      <widget class="QPushButton" name="subBut_100000">
+       <property name="minimumSize">
+        <size>
+         <width>80</width>
+         <height>40</height>
+        </size>
+       </property>
+       <property name="text">
+        <string>-100000</string>
+       </property>
+      </widget>
+     </item>
+     <item row="2" column="2">
+      <widget class="QPushButton" name="subBut_10">
+       <property name="minimumSize">
+        <size>
+         <width>80</width>
+         <height>40</height>
+        </size>
+       </property>
+       <property name="text">
+        <string>-10</string>
+       </property>
+      </widget>
+     </item>
+     <item row="2" column="4">
+      <widget class="QPushButton" name="addBut_1000">
+       <property name="minimumSize">
+        <size>
+         <width>80</width>
+         <height>40</height>
+        </size>
+       </property>
+       <property name="text">
+        <string>+1000</string>
+       </property>
+      </widget>
+     </item>
+     <item row="2" column="5">
+      <widget class="QPushButton" name="addBut_100000">
+       <property name="minimumSize">
+        <size>
+         <width>80</width>
+         <height>40</height>
+        </size>
+       </property>
+       <property name="text">
+        <string>+100000</string>
+       </property>
+      </widget>
+     </item>
+     <item row="1" column="5">
+      <widget class="QPushButton" name="addBut_10000">
+       <property name="minimumSize">
+        <size>
+         <width>80</width>
+         <height>40</height>
+        </size>
+       </property>
+       <property name="text">
+        <string>+10000</string>
+       </property>
+      </widget>
+     </item>
+     <item row="1" column="2">
+      <widget class="QPushButton" name="subBut_1">
+       <property name="minimumSize">
+        <size>
+         <width>80</width>
+         <height>40</height>
+        </size>
+       </property>
+       <property name="text">
+        <string>-1</string>
+       </property>
+      </widget>
+     </item>
+     <item row="1" column="1">
+      <widget class="QPushButton" name="subBut_100">
+       <property name="minimumSize">
+        <size>
+         <width>80</width>
+         <height>40</height>
+        </size>
+       </property>
+       <property name="text">
+        <string>-100</string>
+       </property>
+      </widget>
+     </item>
+     <item row="1" column="3">
+      <widget class="QPushButton" name="addBut_1">
+       <property name="minimumSize">
+        <size>
+         <width>80</width>
+         <height>40</height>
+        </size>
+       </property>
+       <property name="text">
+        <string>+1</string>
+       </property>
+      </widget>
      </item>
+    </layout>
+   </widget>
+   <widget class="QWidget" name="layoutWidget">
+    <property name="geometry">
+     <rect>
+      <x>110</x>
+      <y>140</y>
+      <width>351</width>
+      <height>32</height>
+     </rect>
+    </property>
+    <layout class="QHBoxLayout" name="horizontalLayout">
      <item>
-      <widget class="SpeedAdjWnd" name="widget_100" native="true"/>
+      <widget class="QPushButton" name="subBut">
+       <property name="minimumSize">
+        <size>
+         <width>80</width>
+         <height>30</height>
+        </size>
+       </property>
+       <property name="text">
+        <string>&lt;&lt;</string>
+       </property>
+      </widget>
      </item>
      <item>
-      <widget class="SpeedAdjWnd" name="widget_1000" native="true"/>
+      <widget class="QLineEdit" name="valLineEdit">
+       <property name="minimumSize">
+        <size>
+         <width>80</width>
+         <height>30</height>
+        </size>
+       </property>
+      </widget>
      </item>
      <item>
-      <widget class="SpeedAdjWnd" name="widget_10000" native="true"/>
+      <widget class="QPushButton" name="addBut">
+       <property name="minimumSize">
+        <size>
+         <width>80</width>
+         <height>30</height>
+        </size>
+       </property>
+       <property name="text">
+        <string>&gt;&gt;</string>
+       </property>
+      </widget>
      </item>
     </layout>
    </widget>
+   <widget class="QPushButton" name="closeBut">
+    <property name="geometry">
+     <rect>
+      <x>527</x>
+      <y>2</y>
+      <width>31</width>
+      <height>23</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>X</string>
+    </property>
+   </widget>
   </widget>
  </widget>
- <customwidgets>
-  <customwidget>
-   <class>SpeedAdjWnd</class>
-   <extends>QWidget</extends>
-   <header>Src/RewriteControl/SpeedAdjWnd.h</header>
-   <container>1</container>
-  </customwidget>
- </customwidgets>
  <resources/>
  <connections/>
 </ui>