Răsfoiți Sursa

修复其他窗口点击切换没效果的bug

yun 2 zile în urmă
părinte
comite
c424288995

+ 19 - 2
View/die-bonder-ui/ImageView.cpp

@@ -51,8 +51,25 @@ void ImageView::setPixmap(const QPixmap& newPixmap) {
 }
 
 void ImageView::setCurPixmap(const QPixmap& newPixmap) {
-    this->m_pixmap = newPixmap;
-    m_pixmapItem->setPixmap(m_pixmap);
+    if (this->m_pixmap.isNull()) {
+        this->m_pixmap = newPixmap;
+        scene()->clear();
+        m_pixmapItem = scene()->addPixmap(m_pixmap);
+        m_pixmapItem->setZValue(1);
+        QPointF pixmapCenter(m_pixmap.width() / 2.0, m_pixmap.height() / 2.0);
+        m_pixmapItem->setPos(-pixmapCenter);
+        QRectF sceneRect(-pixmapCenter.x(), -pixmapCenter.y(), m_pixmap.width(), m_pixmap.height());
+        scene()->setSceneRect(sceneRect);
+        setSceneRect(scene()->itemsBoundingRect());
+        this->resize(m_pixmap.width(), m_pixmap.height());
+        m_imageOffset = QPoint(0, 0); // 重置图片偏移量为(0, 0)
+        setCursor(Qt::ArrowCursor);
+        update(); // 触发重绘
+    }
+    else {
+        this->m_pixmap = newPixmap;
+        m_pixmapItem->setPixmap(m_pixmap);
+    }
 }
 
 void ImageView::startRuler()

+ 4 - 3
View/die-bonder-ui/OriginalWnd/ChartsAndCamerasWnd.cpp

@@ -252,7 +252,8 @@ void ChartsAndCamerasWnd::initFrom() {
             if (widget != nullptr)
             {
                 CameraConnectUpdateImageFun(i, widget);
-
+                connect(widget, &Group::sendUpdateGroupState,
+                    this, &ChartsAndCamerasWnd::checkSettings);
                 layout->addWidget(widget);
                 m_allGroup.append(widget);
             }
@@ -535,15 +536,15 @@ void ChartsAndCamerasWnd::GetCurrentSelectSlots(int groupId, int nIndex) {
         disconnect(m_veCurrentSelectGroup.pSelectGroup, &Group::SetUpDataImageShowSig,
             this, &ChartsAndCamerasWnd::GetGroupImageShowSignals);
     }
+    m_veCurrentSelectGroup.pSelectGroup = m_allGroup.at(nOnClickGroupId);
     //判断index是相机还是物料
     if (nIndex == 2) {
 
-        m_veCurrentSelectGroup.pSelectGroup = m_allGroup.at(nOnClickGroupId);
         BindImageOrMaterial(m_nMaterialIndex);
 
     }
     else if (nIndex == 1) {
-        m_veCurrentSelectGroup.pSelectGroup = m_allGroup.at(nOnClickGroupId);
+        
         BindImageOrMaterial(m_nImageIndex);
     }
 }

+ 10 - 8
View/die-bonder-ui/OriginalWnd/MainAndSecondaryCamerasWnd.cpp

@@ -235,10 +235,10 @@ void MainAndSecondaryCamerasWnd::initLeftAndRightWidget() {
     m_veCurrentSelectGroup_L.isInitialed = true;
 
     if (m_allGroup.size() == 1) {
-        if (lastIndex != lastLastIndex) {
 
-            m_veCurrentSelectGroup_L.pSelectGroup = m_allGroup.at(lastGroupId - 1);
-            m_veCurrentSelectGroup_R.pSelectGroup = m_allGroup.at(lastGroupId - 1);
+        m_veCurrentSelectGroup_L.pSelectGroup = m_allGroup.at(lastGroupId - 1);
+        m_veCurrentSelectGroup_R.pSelectGroup = m_allGroup.at(lastGroupId - 1);
+        if (lastIndex != lastLastIndex) {
 
             if (lastIndex == 1) {
                 BindImageOrMaterial(m_nCurrentRight, m_nImageIndex);
@@ -299,6 +299,7 @@ void MainAndSecondaryCamerasWnd::BindImageOrMaterial(int location, int index) {
             m_veCurrentSelectGroup_L.isBond = true;
             connect(m_veCurrentSelectGroup_L.pSelectGroup, &Group::SetUpDataImageShowSig,
                 this, &MainAndSecondaryCamerasWnd::GetGroupImageShowSignalsTo_L);
+            ui->viewwidgetgroup_L->initImage();
             UpdataLightJoystickSwitchPage(m_veCurrentSelectGroup_L.pSelectGroup->m_nGroupId, 1, true);
 
         }else {
@@ -318,6 +319,7 @@ void MainAndSecondaryCamerasWnd::BindImageOrMaterial(int location, int index) {
             m_veCurrentSelectGroup_R.isBond = true;
             connect(m_veCurrentSelectGroup_R.pSelectGroup, &Group::SetUpDataImageShowSig,
                 this, &MainAndSecondaryCamerasWnd::GetGroupImageShowSignalsTo_R);
+            ui->viewwidgetgroup_R->initImage();
             UpdataLightJoystickSwitchPage(m_veCurrentSelectGroup_R.pSelectGroup->m_nGroupId, 2, true);
 
         }
@@ -574,22 +576,22 @@ void MainAndSecondaryCamerasWnd::GetGroupImageShowSignalsTo_L(const QPixmap& ima
 {
     //lastIndex = 1;
     QSize size_left = ui->viewwidgetgroup_L->getOperatewidget()->size();
-    QPixmap scaledPixmap_left = m_lastRightPixmap.scaled(size_left, Qt::KeepAspectRatio, Qt::SmoothTransformation);
+    QPixmap scaledPixmap_left = imageData.scaled(size_left, Qt::KeepAspectRatio, Qt::SmoothTransformation);
     //ui->viewwidgetgroup_L->getOperatewidget()->setPixmap(scaledPixmap_left);
     ui->viewwidgetgroup_L->setScaleFactorSize(scaledPixmap_left);
 
 
-    m_lastRightPixmap = imageData;
+    // m_lastRightPixmap = imageData;
     //UpdataGroupSettings(imageData);
 }
 
 void MainAndSecondaryCamerasWnd::GetGroupImageShowSignalsTo_R(const QPixmap& imageData)
 {
-    QSize size_left = ui->viewwidgetgroup_R->getOperatewidget()->size();
-    QPixmap scaledPixmap_right = imageData.scaled(size_left, Qt::KeepAspectRatio, Qt::SmoothTransformation);
+    QSize size_right = ui->viewwidgetgroup_R->getOperatewidget()->size();
+    QPixmap scaledPixmap_right = imageData.scaled(size_right, Qt::KeepAspectRatio, Qt::SmoothTransformation);
     //ui->viewwidgetgroup_R->getOperatewidget()->setPixmap(scaledPixmap_left);
     ui->viewwidgetgroup_R->setScaleFactorSize(scaledPixmap_right);
-    m_lastRightPixmap = imageData;
+    // m_lastRightPixmap = imageData;
 }
 
 

+ 5 - 3
View/die-bonder-ui/OriginalWnd/SingleCameraOperationWnd.cpp

@@ -62,6 +62,8 @@ void SingleCameraOperationWnd::initFrom() {
             if (widget != nullptr)
             {
                 CameraConnectUpdateImageFun(i, widget);
+                connect(widget, &Group::sendUpdateGroupState,
+                    this, &SingleCameraOperationWnd::checkSettings);
                 layout->addWidget(widget);
                 m_allGroup.append(widget);
                 groupMap[num] = widget;
@@ -390,15 +392,15 @@ void SingleCameraOperationWnd::GetCurrentSelectSlots(int groupId, int nIndex) {
         disconnect(m_veCurrentSelectGroup.pSelectGroup, &Group::SetUpDataImageShowSig,
             this, &SingleCameraOperationWnd::GetGroupImageShowSignals);
     }
+    m_veCurrentSelectGroup.pSelectGroup = m_allGroup.at(nOnClickGroupId);
     //判断index是相机还是物料
     if (nIndex == 2) {
-
-        m_veCurrentSelectGroup.pSelectGroup = m_allGroup.at(nOnClickGroupId);
+        
         BindImageOrMaterial(m_nMaterialIndex);
 
     }
     else if (nIndex == 1) {
-        m_veCurrentSelectGroup.pSelectGroup = m_allGroup.at(nOnClickGroupId);
+
         BindImageOrMaterial(m_nImageIndex);
     }
 }

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

@@ -41,6 +41,23 @@ void ControlOperationPage::updateOperateWidget(const QPixmap& pixmap) {
 	applyScale();
 }
 
+void ControlOperationPage::initImage() {
+    clearLayout();
+    ImageView* customView = new ImageView(ui->Operatewidget);
+    
+    QVBoxLayout* layout = new QVBoxLayout(ui->Operatewidget);
+    layout->setContentsMargins(0, 0, 0, 0);
+    layout->addWidget(customView);
+    ui->Operatewidget->setLayout(layout);
+    m_scaleFactor = 1.0;
+    m_previousScaleFactor = 1.0;
+    ui->label_Percentage->setText("100%");
+
+    m_currentMode = ModeImage;
+    m_currentImageView = customView;
+    applyScale();
+}
+
 void ControlOperationPage::setDataSources(const QStringList& textList) {
     ui->DataSources->clear();
     ui->DataSources->addItems(textList);

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

@@ -57,6 +57,7 @@ public:
 
     void setEnableControls(bool enable);
     void setBlueBord();
+    void initImage();
 private slots:
     void on_ZoomUpButton_clicked();
     void on_ZoomOutButton_clicked();