Переглянути джерело

同步代码,实现相机同步,修复缩放问题

yun 1 тиждень тому
батько
коміт
4a0f9a49da

+ 27 - 7
View/die-bonder-ui/OriginalWnd/MainAndSecondaryCamerasWnd.cpp

@@ -82,11 +82,23 @@ void MainAndSecondaryCamerasWnd::initFrom()
     int groupId = settings.value("GroupId", 0).toInt();
     int index = settings.value("Index", 0).toInt();
 
-    checkSettings();
+    
 
+    if (m_allGroup.size() == 1) {
+        if (lastGroupId == lastLastGroupId) {
+            GetCurrentSelectSlots(lastLastGroupId, lastLastIndex);
+            GetCurrentSelectSlots(lastGroupId, lastIndex);
+        }
+        else {
+            GetCurrentSelectSlots(lastGroupId, lastIndex);
+        }
+    }
+    else {
+        GetCurrentSelectSlots(lastLastGroupId, lastLastIndex);
+        GetCurrentSelectSlots(lastGroupId, lastIndex);
+    }
+    checkSettings();
 
-    GetCurrentSelectSlots(lastLastGroupId, lastLastIndex);
-    GetCurrentSelectSlots(lastGroupId, lastIndex);
 }
 
 void MainAndSecondaryCamerasWnd::InitPage()
@@ -485,7 +497,7 @@ void MainAndSecondaryCamerasWnd::GetCurrentSelectSlots(int groupId, int nIndex)
             //解绑
             disconnect(m_veCurrentSelectGroup_R.pSelectGroup, &Group::SetUpDataImageShowSig,
                 this, &MainAndSecondaryCamerasWnd::GetUpDataImageShowSignals4);
-            m_veCurrentSelectGroup_L = m_veCurrentSelectGroup_R;
+            
             //换绑
             connect(m_veCurrentSelectGroup_L.pSelectGroup, &Group::SetUpDataImageShowSig,
                 this, &MainAndSecondaryCamerasWnd::GetUpDataImageShowSignals0);
@@ -526,6 +538,10 @@ void MainAndSecondaryCamerasWnd::GetCurrentSelectSlots(int groupId, int nIndex)
 
         }else {
             if (m_veCurrentSelectGroup_R.isInitialed == true) {
+                if (m_veCurrentSelectGroup_L.isBond == true) {
+                    disconnect(m_veCurrentSelectGroup_L.pSelectGroup, &Group::SetUpDataImageShowSig,
+                        this, &MainAndSecondaryCamerasWnd::GetUpDataImageShowSignals0);
+                }
                 m_veCurrentSelectGroup_L = m_veCurrentSelectGroup_R;
                 UpdataLightJoystickSwitchPage(m_veCurrentSelectGroup_L.pSelectGroup->m_nGroupId, 1, false);
             }
@@ -677,7 +693,10 @@ void MainAndSecondaryCamerasWnd::GetUpDataImageShowSignals0(const QPixmap& image
     //lastIndex = 1;
     QSize size_left = ui->viewwidgetgroup_L->getOperatewidget()->size();
     QPixmap scaledPixmap_left = m_lastRightPixmap.scaled(size_left, Qt::KeepAspectRatio, Qt::SmoothTransformation);
-    ui->viewwidgetgroup_L->getOperatewidget()->setPixmap(scaledPixmap_left);
+    //ui->viewwidgetgroup_L->getOperatewidget()->setPixmap(scaledPixmap_left);
+    ui->viewwidgetgroup_L->setScaleFactorSize(scaledPixmap_left);
+
+
     m_lastRightPixmap = imageData;
     //UpdataGroupSettings(imageData);
 }
@@ -691,8 +710,9 @@ void MainAndSecondaryCamerasWnd::GetUpDataImageShowSignals1(const QPixmap& image
 void MainAndSecondaryCamerasWnd::GetUpDataImageShowSignals4(const QPixmap& imageData)
 {
     QSize size_left = ui->viewwidgetgroup_R->getOperatewidget()->size();
-    QPixmap scaledPixmap_left = imageData.scaled(size_left, Qt::KeepAspectRatio, Qt::SmoothTransformation);
-    ui->viewwidgetgroup_R->getOperatewidget()->setPixmap(scaledPixmap_left);
+    QPixmap scaledPixmap_right = imageData.scaled(size_left, Qt::KeepAspectRatio, Qt::SmoothTransformation);
+    //ui->viewwidgetgroup_R->getOperatewidget()->setPixmap(scaledPixmap_left);
+    ui->viewwidgetgroup_R->setScaleFactorSize(scaledPixmap_right);
     m_lastRightPixmap = imageData;
 }
 

+ 12 - 3
View/die-bonder-ui/Src/RewriteControl/ControlOperationPage.cpp

@@ -258,8 +258,17 @@ void ControlOperationPage::resizeSingleUI(bool bMax /*= false*/)
 void ControlOperationPage::resizeChartsAndCamerasUI() {
 
 }
+qreal ControlOperationPage::getScaleFactorValue() {
+    return m_scaleFactor;
+}
+void ControlOperationPage::setScaleFactorSize(QPixmap scaledImage) {
+    int newWidth = scaledImage.width() * m_scaleFactor;
+    int newHeight = scaledImage.height() * m_scaleFactor;
 
-
+    QPixmap curr_scaledImage = scaledImage.scaled(newWidth, newHeight, Qt::KeepAspectRatio, Qt::SmoothTransformation);
+    ui->Operatewidget->setPixmapAndPoint(curr_scaledImage, m_previousScaleFactor, m_scaleFactor, m_mousePos);
+    ui->Operatewidget->setPixmap(curr_scaledImage);
+}
 void ControlOperationPage::UpDateCameraBind(CameraBind* pCameraBind)
 {
     m_pCameraBindCopy = pCameraBind;
@@ -385,8 +394,8 @@ bool ControlOperationPage::eventFilter(QObject* obj, QEvent* event)
 
 void ControlOperationPage::wheelEvent(QWheelEvent* event) {
     if (ui->Operatewidget->rect().contains(ui->Operatewidget->mapFromGlobal(event->globalPos()))) {
-        QPoint              mousePos;
-        mousePos = ui->Operatewidget->mapFromGlobal(event->globalPos());
+        
+        m_mousePos = ui->Operatewidget->mapFromGlobal(event->globalPos());
         if (event->angleDelta().y() > 0) {
             updateScale(m_scaleFactor * 1.1); // 放大
         }

+ 3 - 1
View/die-bonder-ui/Src/RewriteControl/ControlOperationPage.h

@@ -46,7 +46,9 @@ public:
     ImageWidget* getOperatewidget();
     void resizeSingleUI(bool bMax = false);
     void resizeChartsAndCamerasUI();
-
+    qreal getScaleFactorValue();
+    void setScaleFactorSize(QPixmap scaledImage);
+        
     /**更新硬件指针
      */
     void UpDateCameraBind(CameraBind* pCameraBind);