PyQt5 将线条延伸到正在绘制的图像之外。我怎样才能防止这种情况发生?

Posted

技术标签:

【中文标题】PyQt5 将线条延伸到正在绘制的图像之外。我怎样才能防止这种情况发生?【英文标题】:PyQt5 extending lines past the image being drawn. How can I prevent this from occuring? 【发布时间】:2021-12-06 18:22:51 【问题描述】:

我正在构建代码以根据检测数据呈现晶圆图。绘制骰子的循环功能似乎工作正常,除了有额外的线延伸到地图区域之外和下方。所有计算出来的数字看起来都是正确的。谁能帮我理解为什么会这样。

这是我想要实现的目标: enter image description here

代码显示如下:

enter image description here

这是绘图循环:

    # Creating image object
    self.image = QImage(512, 512, QImage.Format_RGB32)

    # Set the background color
    self.image.fill(Qt.white)

def _draw_die(self): # 设置 QPainter qp = QPainter(self.image)

    # Draw wafer die
    count = 0
    for item in self.mapCoords:
        color = Qt.blue if item[1] == "OFF" else Qt.lightGray
        pen = QPen(color, 1, Qt.SolidLine)
        qp.setPen(pen)
        brushcolor = Qt.white if item[1] == "OFF" else Qt.white
        brush = QBrush(brushcolor)
        qp.setBrush(brush)
        print(f'Point count: x0 = item[0][0],'
              f' y0 = item[0][1],'
              f' x1 = item[0][0] + self.dieX,'
              f' y1 = item[0][1] + self.dieY')

        qp.drawRect(item[0][0],
                    item[0][1],
                    item[0][0] + self.dieX,
                    item[0][1] + self.dieY)

        count += 1  # used for printing the plotted points only
    return

如果我没有上传足够的信息,请让我知道我需要添加什么。谢谢。

【问题讨论】:

请提供minimal reproducible example。 【参考方案1】:

我相信我已经找到了问题和解决方案。看来我计算的模具尺寸不正确,它生成的地图大约是它应该有的尺寸的 1/4。我已经更正了模具尺寸计算,现在地图显示正确。

这里是 PyQt5 Designer 生成的 .ui 文件:

# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'waferMain.ui'
#
# Created by: PyQt5 UI code generator 5.9.2
#
# WARNING! All changes made in this file will be lost!

from PyQt5 import QtCore, QtGui, QtWidgets

class Ui_MainWindow(object):
    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(618, 618)
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.gridLayout = QtWidgets.QGridLayout(self.centralwidget)
        self.gridLayout.setObjectName("gridLayout")
        self.lblImage = QtWidgets.QLabel(self.centralwidget)
        self.lblImage.setObjectName("lblImage")
        self.gridLayout.addWidget(self.lblImage, 0, 0, 1, 1)
        MainWindow.setCentralWidget(self.centralwidget)

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)

    def retranslateUi(self, MainWindow):
        _translate = QtCore.QCoreApplication.translate
        MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
        self.lblImage.setText(_translate("MainWindow", "TextLabel"))

这里是完整的来源:

# System libraries
import sys

# PyQt modules
from PyQt5.QtWidgets import QApplication, \
    QMainWindow, \
    QFileDialog, \
    QAction, \
    QLabel, \
    QDialog
from PyQt5.QtGui import QPainter, \
    QPen, \
    QImage, \
    QPainterPath, \
    QTransform, \
    QBrush, \
    QPixmap
from PyQt5.QtCore import Qt, \
    QPoint, \
    QRectF

from waferMain import Ui_MainWindow


class WaferMap:
    def __init__(self, imgW, imgH):

        self.imageWidth = imgW
        self.imageHeight = imgH

        self.nrows = 0
        self.ncols = 0
        self.coords = []
        self.edgeBuffer = 0
        self.rotation = 0

        # Creating image object
        self.image = QPixmap(self.imageWidth, self.imageHeight)

        # Setup QPainter
        self.qp = QPainter(self.image)

        return

    def _get_die_size(self):
        self.dieX = int(self.imageWidth / self.ncols)
        self.dieY = int(self.imageHeight / self.nrows)
        return

    def _remove_spaces(self, data):
        ndata = []
        for i in data:
            if (i == '0') or (i == '1'):
                ndata.append(int(i))

        return ndata

    def _get_data(self):
        self.map = []
        mf = open("ins.dat", 'r')
        for line in mf:
            data = line.split('\t')
            if '.nrow' in line:
                self.nrows = int(data[len(data) - 1].strip())
            elif '.ncols' in line:
                self.ncols = int(data[len(data) - 1].strip())
            elif '.map' in line:
                data2 = self._remove_spaces(data[len(data) - 1].strip())
                self.map.append(data2)
            elif '.run_orient' in line:
                self.notch = data[len(data) - 1].strip()
                break
            else:
                pass
        mf.close()
        self._get_die_size()
        self._build_wafer_coordinates()

        return

    def _build_wafer_coordinates(self):
        index = 0
        self.mapCoords = []  # list of tuples: (x, y) On/Off
        for y in range(self.nrows):
            for x in range(self.ncols):
                # print(f'x:5, y:5  "On" if self.map[y][x] == 1 else "Off"')
                die = "ON" if self.map[y][x] == 1 else "OFF"
                self.mapCoords.append([(x * self.dieX, y * self.dieY), die])
                index += 1

        return

    def _draw_notch(self):
        lineWidth = 2
        width = self.image.width() - self.edgeBuffer
        height = self.image.height() - self.edgeBuffer
        radius = int(width / 2)

        if self.notch.upper() == "D":  # Notch down
            # Clear area for the notch
            self.qp.setPen(QPen(Qt.white, lineWidth, Qt.SolidLine))
            self.qp.setBrush(QBrush(Qt.white, Qt.SolidPattern))
            rectangle = QRectF(radius + self.edgeBuffer / 2, height + self.edgeBuffer / 2 - 5, 10,
                               10)  # QRect(x, y, width, height)
            self.qp.drawEllipse(rectangle)
            # Draw the notch
            self.qp.setPen(QPen(Qt.black, lineWidth, Qt.SolidLine))
            # rectangle = QRectF(radius + self.edgeBuffer / 2, height + self.edgeBuffer / 2 - 5, 10, 10)  # QRect(x, y, width, height)
            startAngle = 0 * 16
            spanAngle = 180 * 16
            self.qp.drawArc(rectangle, startAngle, spanAngle)
        elif self.notch.upper() == "U":  # Notch up
            # Clear area for the notch
            self.qp.setPen(QPen(Qt.white, lineWidth, Qt.SolidLine))
            self.qp.setBrush(QBrush(Qt.white, Qt.SolidPattern))
            rectangle = QRectF(radius + self.edgeBuffer / 2, self.edgeBuffer / 2 - 5, 10,
                               10)  # QRect(x, y, width, height)
            self.qp.drawEllipse(rectangle)
            # Draw the notch
            self.qp.setPen(QPen(Qt.black, lineWidth, Qt.SolidLine))
            startAngle = 0 * 16
            spanAngle = -180 * 16
            self.qp.drawArc(rectangle, startAngle, spanAngle)

        elif self.notch.upper() == "L":  # Notch Left
            # Clear area for the notch
            self.qp.setPen(QPen(Qt.white, lineWidth, Qt.SolidLine))
            self.qp.setBrush(QBrush(Qt.white, Qt.SolidPattern))
            rectangle = QRectF(self.edgeBuffer / 2 - 5, radius + self.edgeBuffer / 2, 10,
                               10)  # QRect(x, y, width, height)
            self.qp.drawEllipse(rectangle)
            # Draw the notch
            self.qp.setPen(QPen(Qt.black, lineWidth, Qt.SolidLine))
            startAngle = -90 * 16
            spanAngle = 180 * 16
            self.qp.drawArc(rectangle, startAngle, spanAngle)
        else:  # Notch right
            # Clear area for the notch
            self.qp.setPen(QPen(Qt.white, lineWidth, Qt.SolidLine))
            self.qp.setBrush(QBrush(Qt.white, Qt.SolidPattern))
            rectangle = QRectF(width + self.edgeBuffer / 2 - 5, radius + self.edgeBuffer / 2, 10,
                               10)  # QRect(x, y, width, height)
            self.qp.drawEllipse(rectangle)
            # Draw the notch
            self.qp.setPen(QPen(Qt.black, lineWidth, Qt.SolidLine))
            startAngle = 90 * 16
            spanAngle = 180 * 16
            self.qp.drawArc(rectangle, startAngle, spanAngle)
        return

    def _draw_wafer(self):
        lineWidth = 2
        width = self.image.width() - self.edgeBuffer
        height = self.image.height() - self.edgeBuffer
        radius = int(width / 2)
        self.qp.setRenderHint(QPainter.HighQualityAntialiasing, True)
        self.qp.setBrush(QBrush(Qt.transparent))
        self.qp.setPen(QPen(Qt.black, lineWidth, Qt.SolidLine))

        # Find the wafer center
        wcX = int(((self.image.width() - width) / 2) + radius)
        wcY = int(((self.image.width() - height) / 2) + radius)

        # Draw the wafer
        self.qp.drawEllipse(QPoint(wcX, wcY), radius, radius)

        self._draw_notch()

        return

    def _draw_die(self):
        # Draw wafer die
        for item in self.mapCoords:
            color = Qt.white if item[1] == "OFF" else Qt.lightGray
            pen = QPen(color, 1, Qt.SolidLine)
            self.qp.setPen(pen)
            brushcolor = Qt.white if item[1] == "OFF" else Qt.gray
            brush = QBrush(brushcolor)
            self.qp.setBrush(brush)

            self.qp.drawRect(item[0][0],
                             item[0][1],
                             item[0][0] + self.dieX,
                             item[0][1] + self.dieY)
        return

    def get_pixmap(self):
        self._get_data()
        self._draw_die()
        self._draw_wafer()

        return self.image


class MainWindow(QMainWindow, Ui_MainWindow):
    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent=parent)

        # Initialize main window
        self.setupUi(self)
        self._center_window()

        # Setting the window title
        self.setWindowTitle("Wafer Map Testing")

        self.show()

        # Setup and call the WaferMap class
        self.wafermap = WaferMap(self.lblImage.width(), self.lblImage.height())
        image = self.wafermap.get_pixmap()

        self.lblImage.setPixmap(image)

    def _center_window(self):
        # Get screen information
        screen = QApplication.primaryScreen()
        size = screen.size()
        scrn_width = size.width()
        scrn_height = size.height()
        window_width = self.width()
        window_height = self.height()

        # Setup plot area for grid
        self.plotAreaX = self.lblImage.width()
        self.plotAreaY = self.lblImage.height()

        # Center the window on the screen
        self.left = int(scrn_width / 2) - int(window_width / 2)
        self.top = int(scrn_height / 2) - int(window_height / 2)

        # Setting the geometry to main window
        self.setGeometry(self.left, self.top, window_width, window_height)
        return


if __name__ == '__main__':
    app = QApplication(sys.argv)
    ex = MainWindow()
    ex.show()
    sys.exit(app.exec_())

以下数据需要保存在本地目录为“ins.dat”

## Kind INSPECTION
## Name KLARDEF
## RevCode 5    3   84
## Model KLA2xxx
## Model Number KLA2139
## Machine Number 1080
## Saved 2003 3 11 12 34 38
## Created 2003 3 11 12 34 38
## Version 5.3.084
## Copyright 1998 KLA-Tencor Corporation
## StepID None
fdata.
    .name   KLARDEF
    .revcode    5   3   84
    .lastmod    1047411278  (Tue Mar 11 12:34:38 2003)
    ..

wdat.
    .device_id  None
    .step_id    None
    .wr 100000.0000
    .fr 95000.0000
    .fon    n
    .bop    p
    .orient r
    .care_bdr   0.000000  0.000000
    .nFlatFindAlgo  0
    .adcsetup   
    .adc_enable 0
    ..

algndat[0].
    .nSiteAlgo  1
    .focus_ofst 0.0000
    .y  5232.6722
    .xPeriod    7237.3150
    .x0 999999.9999
    .x1 -72292.6265
    .x2 -57817.9286
    .x3 -43343.1306
    .x4 -28868.3716
    .x5 -14393.7115
    .x6 80.9520
    .x7 14555.5965
    .x8 29030.1150
    .x9 43504.6484
    .x10    57979.1642
    .x11    72453.6112
    .x12    999999.9999
    .x13    999999.9999
    .x14    999999.9999
    .x15    999999.9999
    .x16    999999.9999
    .x17    999999.9999
    .x18    999999.9999
    .x19    999999.9999
    .x20    999999.9999
    .x21    999999.9999
    .x22    999999.9999
    .x23    999999.9999
    .x24    999999.9999
    .x25    999999.9999
    .x26    999999.9999
    .x27    999999.9999
    .x28    999999.9999
    .x29    999999.9999
    .x30    999999.9999
    .x31    999999.9999
    .x32    999999.9999
    .x33    999999.9999
    .x34    999999.9999
    .x35    999999.9999
    .x36    999999.9999
    .x37    999999.9999
    .x38    999999.9999
    .x39    999999.9999
    .x40    999999.9999
    .x41    999999.9999
    .x42    999999.9999
    .x43    999999.9999
    .x44    999999.9999
    .x45    999999.9999
    .x46    999999.9999
    .x47    999999.9999
    .x48    999999.9999
    .x49    999999.9999
    .x0Index    5
    .y0 5232.9240
    .x1Index    6
    .y1 5233.1363
    .nFilter    1
    .algn.
        .obj_index  0
        .mch_index  1
        .ndf_ofst   101.041667
        .tdigain    5
        .bright_sensor_value    237.653152
        .ll_min_endpoint    24
        .ll_max_endpoint    215
        .tdigaindex 0
        .tdioffset  484
        .nNdsSize   32
        .nDsSize    32
        .image[0]   d 0 0 0 10 0 0 0 10 0 0 0 4 0 0 0 4 0 0 0 1e 4b 0 0 e2 2e 27 0 0 0 0 0
        .image[32]  c4 c4 c4 c4 c5 ce ce bb 1e 1a 1a 1a 29 c9 ce cd d0 cd 8e 8d 8f 90 91 90 1e 1a 1a 1a 2a ca cf cf
        .image[64]  67 75 30 26 25 25 26 4c 1f 1b 1b 1b 2a af b0 b0 27 3d 2f 24 24 24 24 4b 1f 1a 1b 1a 28 3c 2c 2c
        .image[96]  a2 a7 98 87 84 82 81 8b 21 1d 1d 1d 2b 3c 26 25 bc c3 ba bb bc b9 b8 a8 20 1c 1c 1c 2b 79 61 5e
        .image[128] d3 d3 c7 c5 c1 be bb ac 21 1c 1c 1c 2c b5 ba bc ce ce cf ce ce cd cd ba 20 1c 1d 1c 2b b5 b9 b6
        .image[160] 25 26 25 25 25 25 24 23 1b 1a 1b 1a 1b 24 24 23 1a 1a 1a 1a 19 19 19 19 1b 1b 1b 1b 1b 19 19 19
        .image[192] 1a 1a 1a 1a 1a 19 19 19 1b 1b 1c 1b 1b 19 19 19 1a 1a 1a 1a 19 19 19 19 1b 1b 1b 1b 1b 19 19 19
        .image[224] 1f 1f 1f 1f 1e 1e 1e 1d 1c 1c 1c 1c 1c 1d 1d 1d c0 bb 57 54 55 57 58 66 20 1c 1c 1c 28 44 39 3b
        .image[256] 41 57 32 26 24 25 26 4d 20 1c 1c 1c 2a 3b 24 23 39 4d 36 2b 2a 2c 2c 51 20 1c 1c 1c 2a 4d 38 38
        .image[288] e 0 0 0 10 0 0 0 10 0 0 0 1 0 0 0 1 0 0 0 b8 44 0 0 28 bf 25 0 0 0 0 0
        .image[320] b6 90 c2 cf b8 97 bd 82 2c 1e 1d 1d 1c 1c 1c 1c bb a4 c3 ca bb a8 c3 83 2c 1d 1d 1d 1c 1c 1c 1c
        .image[352] b2 ae b0 b0 ac b5 c5 83 2c 1d 1c 1d 1b 1c 1c 1c cb cb cb ca cb cd cc 83 2c 1d 1d 1d 1d 1c 1c 1c
        .image[384] d2 d2 d1 d2 d2 d4 cd 83 2b 1d 1d 1c 1c 1b 1c 1c d4 d3 d4 d3 d4 d6 ce 84 2b 1d 1c 1d 1c 1c 1c 1c
        .image[416] d5 d4 d4 d4 d4 d7 cf 84 2c 1d 1d 1d 1d 1d 1c 1c bd bc bc bb bc be b8 76 28 1d 1e 1d 1c 1c 1c 1c
        .image[448] 43 44 43 43 43 44 43 32 1e 1b 1b 1c 1b 1b 1c 1b 1e 1f 1f 1e 1e 1e 1e 1c 1a 1b 1b 1b 1b 1a 1a 1a
        .image[480] 18 18 18 18 18 18 18 18 19 1a 1a 1b 1a 1a 1a 19 18 18 18 18 18 18 17 18 19 1b 1a 1a 1a 1a 1a 19
        .image[512] 19 19 19 18 19 18 18 19 1b 1b 1a 1b 1a 1a 1a 1a 19 19 18 19 18 19 18 1a 1b 1b 1b 1b 1b 1b 1b 1a
        .image[544] 19 19 19 19 19 19 19 1a 1b 1b 1b 1c 1b 1b 1c 1b 19 19 19 19 19 19 1a 1a 1b 1b 1b 1b 1c 1b 1c 1b
        .vifinputfilter.
        .scale  4
        .coefs[0]   0   0   0   0   0
        .coefs[1]   0   0   0   0   0
        .coefs[2]   0   0   511 0   0
        .coefs[3]   0   0   0   0   0
        .coefs[4]   0   0   0   0   0
            ..
        .sobelfilter1.
        .scale  4
        .coefs[0]   0   0   0   0   0
        .coefs[1]   0   -1  0   1   0
        .coefs[2]   0   -2  0   2   0
        .coefs[3]   0   -1  0   1   0
        .coefs[4]   0   0   0   0   0
            ..
        .sobelfilter2.
        .scale  4
        .coefs[0]   0   0   0   0   0
        .coefs[1]   0   1   2   1   0
        .coefs[2]   0   0   0   0   0
        .coefs[3]   0   -1  -2  -1  0
        .coefs[4]   0   0   0   0   0
            ..
        ..
    ..

algndat[1].
    .nSiteAlgo  1
    .focus_ofst 0.0000
    .y  5229.3085
    .xPeriod    7237.3128
    .x0 999999.9999
    .x1 999999.9999
    .x2 -79546.0976
    .x3 -72308.8337
    .x4 -65071.5235
    .x5 -57834.2259
    .x6 -50596.8824
    .x7 -43359.5714
    .x8 -36122.1942
    .x9 -28884.9339
    .x10    -21647.5693
    .x11    -14410.2732
    .x12    -7172.9247
    .x13    64.4158
    .x14    7301.7816
    .x15    14539.0849
    .x16    21776.4384
    .x17    29013.6626
    .x18    36251.1021
    .x19    43488.2795
    .x20    50725.5693
    .x21    57962.8098
    .x22    65200.1386
    .x23    72437.3783
    .x24    79674.7196
    .x25    86911.9076
    .x26    999999.9999
    .x27    999999.9999
    .x28    999999.9999
    .x29    999999.9999
    .x30    999999.9999
    .x31    999999.9999
    .x32    999999.9999
    .x33    999999.9999
    .x34    999999.9999
    .x35    999999.9999
    .x36    999999.9999
    .x37    999999.9999
    .x38    999999.9999
    .x39    999999.9999
    .x40    999999.9999
    .x41    999999.9999
    .x42    999999.9999
    .x43    999999.9999
    .x44    999999.9999
    .x45    999999.9999
    .x46    999999.9999
    .x47    999999.9999
    .x48    999999.9999
    .x49    999999.9999
    .x0Index    11
    .y0 5229.3353
    .x1Index    12
    .y1 5229.4625
    .nFilter    1
    .algn.
        .obj_index  3
        .mch_index  2
        .ndf_ofst   123.376623
        .tdigain    9
        .bright_sensor_value    245.222656
        .ll_min_endpoint    26
        .ll_max_endpoint    220
        .tdigaindex 1
        .tdioffset  590
        .nNdsSize   32
        .nDsSize    32
        .image[0]   d 0 0 0 10 0 0 0 10 0 0 0 4 0 0 0 4 0 0 0 85 4d 0 0 5d b 31 0 0 0 0 0
        .image[32]  dc db db db db db da d9 b8 22 1d 1c 1c 1c 1c 1c dc dc db db db db db d9 b7 22 1c 1c 1c 1c 1b 1c
        .image[64]  dc dc db db db da db d9 b8 22 1d 1c 1c 1c 1c 1c db db db db db da da d9 b7 21 1c 1c 1c 1c 1c 1c
        .image[96]  db db db db db da db d9 b7 22 1d 1c 1c 1c 1c 1c db db db da da da da d9 b7 22 1d 1d 1c 1d 1d 1d
        .image[128] d9 d9 d9 d8 d8 d8 d8 d7 b5 22 1d 1c 1c 1c 1c 1d 8c 8c 8c 8c 8b 8b 8b 8a 71 1f 1d 1c 1c 1c 1c 1d
        .image[160] 1e 1e 1d 1e 1d 1d 1d 1d 1d 1c 1c 1c 1c 1c 1c 1c 1b 1b 1b 1b 1b 1b 1b 1b 1b 1b 1b 1b 1b 1b 1b 1b
        .image[192] 1b 1b 1b 1b 1b 1b 1b 1b 1b 1b 1c 1c 1b 1b 1b 1b 1b 1b 1b 1b 1b 1b 1b 1b 1b 1b 1b 1b 1b 1b 1b 1b
        .image[224] 1b 1b 1c 1b 1b 1b 1b 1b 1b 1b 1b 1b 1b 1b 1b 1b 1b 1b 1b 1b 1b 1b 1b 1b 1b 1b 1b 1b 1b 1b 1b 1b
        .image[256] 1b 1b 1b 1b 1b 1b 1b 1b 1b 1b 1b 1b 1b 1b 1b 1b 1b 1b 1b 1b 1b 1b 1b 1b 1b 1b 1b 1b 1b 1b 1b 1b
        .image[288] e 0 0 0 10 0 0 0 10 0 0 0 1 0 0 0 1 0 0 0 8f 50 0 0 bb b9 30 0 0 0 0 0
        .image[320] da d9 d9 da d8 d9 d8 d8 d4 cf c2 72 2a 21 1e 1e da d9 d9 d9 d8 d8 d8 d7 d4 d0 c2 72 2a 21 1f 1e
        .image[352] d8 d8 d7 d8 d8 d8 d6 d6 d4 d0 c0 70 2a 21 1e 1d d5 d6 d6 d6 d4 d5 d4 d3 d1 cd be 6d 28 20 1f 1d
        .image[384] d2 d2 d2 d1 d1 d1 d1 d0 ce c9 ba 6b 28 1f 1e 1d c0 c1 c0 c1 c0 bf c0 be bc b8 a4 56 24 1f 1d 1d
        .image[416] 70 70 6f 70 6f 6f 6e 6e 6b 65 54 2f 20 1e 1d 1c 2a 2a 2a 2a 2a 2a 2a 29 28 27 25 20 1e 1d 1c 1d
        .image[448] 20 21 20 21 20 1f 20 20 20 1f 1f 1e 1d 1d 1d 1d 1d 1d 1d 1d 1d 1d 1d 1d 1d 1d 1d 1d 1d 1c 1d 1c
        .image[480] 1d 1c 1d 1d 1c 1d 1c 1c 1d 1c 1c 1c 1c 1c 1c 1b 1b 1b 1b 1b 1b 1a 1b 1b 1b 1a 1b 1b 1b 1b 1b 1b
        .image[512] 1b 1b 1b 1b 1b 1a 1b 1b 1b 1a 1c 1b 1b 1c 1b 1b 1b 1b 1b 1b 1a 1b 1a 1b 1b 1b 1c 1b 1b 1b 1b 1b
        .image[544] 1b 1b 1b 1b 1b 1b 1b 1b 1b 1b 1c 1b 1b 1c 1b 1b 1b 1c 1b 1b 1b 1a 1a 1b 1b 1a 1a 1b 1c 1b 1c 1b
        .vifinputfilter.
        .scale  4
        .coefs[0]   0   0   0   0   0
        .coefs[1]   0   0   0   0   0
        .coefs[2]   0   0   511 0   0
        .coefs[3]   0   0   0   0   0
        .coefs[4]   0   0   0   0   0
            ..
        .sobelfilter1.
        .scale  4
        .coefs[0]   0   0   0   0   0
        .coefs[1]   0   -1  0   1   0
        .coefs[2]   0   -2  0   2   0
        .coefs[3]   0   -1  0   1   0
        .coefs[4]   0   0   0   0   0
            ..
        .sobelfilter2.
        .scale  4
        .coefs[0]   0   0   0   0   0
        .coefs[1]   0   1   2   1   0
        .coefs[2]   0   0   0   0   0
        .coefs[3]   0   -1  -2  -1  0
        .coefs[4]   0   0   0   0   0
            ..
        ..
    ..

dm.
    .xret   1
    .yret   1
    .x0 -108931.8181
    .y0 101596.1714
    .dsx    10370.0996
    .dsy    7237.3314
    .iox    10
    .ioy    13
    .ixtl   6
    .iytl   23
    .ifarxtl    18
    .ifarytl    11
    .nsl_pts    2
    .sl[0]  -36235.3712 -64957.3250
    .sl[1]  -36341.1211 -64862.4500
    .ndmm   0
    ..

cluster_param.
    .fdata.
        .name   _default
        .revcode    5   3   84
        .lastmod    762532380   (Tue Mar 01 07:33:00 1994)
        ..
    .threshold         1000
    .threshold_exp     0
    .thresh_ceiling    10000
    .thresh_ceil_exp   0
    .defect_count      10
    .depth             7
    .merge_tolerance   3
    .thres_step        1000
    .highlight         f
    .on_off            n
    .autothresh_enable n
    .protect_mode      0
    ..

review_sample_plan.
    .fdata.
        .name   _default
        .revcode    5   3   84
        .lastmod    762532380   (Tue Mar 01 07:33:00 1994)
        ..
    .defects_per_wafer     100
    .min_defects_per_wafer 50
    .defects_per_die       3
    .defects_per_cluster   5
    .percentage_cluster    50
    .size_threshold        0
    .on_off                f
    ..

rsp[0].
    .nskip  0
    .nrows  28
    .ncols  21
    .edge_cells 0
    .map[0]     0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
    .map[1]     0 0 0 0 0 0 0 0 1 1 1 1 1 0 0 0 0 0 0 0 0 
    .map[2]     0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 
    .map[3]     0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 
    .map[4]     0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 
    .map[5]     0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 
    .map[6]     0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 
    .map[7]     0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 
    .map[8]     0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 
    .map[9]     0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 
    .map[10]    0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 
    .map[11]    0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 
    .map[12]    0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 
    .map[13]    0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 
    .map[14]    0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 
    .map[15]    0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 
    .map[16]    0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 
    .map[17]    0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 
    .map[18]    0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 
    .map[19]    0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 
    .map[20]    0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 
    .map[21]    0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 
    .map[22]    0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 
    .map[23]    0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 
    .map[24]    0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 
    .map[25]    0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 
    .map[26]    0 0 0 0 0 0 0 0 1 1 1 1 1 0 0 0 0 0 0 0 0 
    .map[27]    0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
    ..

lls_algo_state.
    .lls_algo_version   ALGO_SVGL
    ..

test[0].
    .isvalid    r
    .run_orient r
    .ix 10
    .iy 14
    .care_bdr   15.000000  15.000000
    .narrays    1
    .ca_array[0].
        .mode   r
        .nacts  2
        .acts[0]    811.9437    5212.9047
        .acts[1]    3578.3147   10209.0320
        ..
    .lens_desc.
        .obj_label  50X
        .magchng_label  2.0H
        .pixel_size 0.2500
        ..
    .premap_sites.
        .x_die  13
        .y_die  10
        .use_light_settings 0
        .objective  50X
        .magchanger 2.0H
        .site[0].
            .x_coord    13.4259
            .y_coord    117.3203
            .good_site  1
            .failed_light_level 1
            .gain_index -1
            .gain_value -1
            .gain_offset    -1
            .ndf_position   -1
            .focus_offset   0.0000
            .bright_sensor  0.000000
            .min_endpoint   25
            .max_endpoint   225
            .use_edge_filter    1
            ..
        .site[1].
            .x_coord    7133.6759
            .y_coord    153.0721
            .good_site  1
            .failed_light_level 1
            .gain_index -1
            .gain_value -1
            .gain_offset    -1
            .ndf_position   -1
            .focus_offset   0.0000
            .bright_sensor  0.000000
            .min_endpoint   25
            .max_endpoint   225
            .use_edge_filter    1
            ..
        ..
    .premap_swathing    1
    .sens.
        .fdata.
            .name   
            .revcode    5   3   84
            .lastmod    1029370695  (Wed Aug 14 17:18:15 2002)
            ..
        .mag_setting    3   2
        .test_mode  r
        .comp_dir   88  (X)
        .focus_offset   0.0000
        .light_ratio    0.0000
        .microns_per_cell   0.0000
        .unit_pix_strength  0
        .ds_thresha 30
        .ds_threshb_xlo 0
        .ds_threshb_xhi 0
        .ds_threshb_yhi 0
        .ds_threshsz    1
        .ds_edge_thresh_scale   1.000000
        .nadr_wsz   40  40
        .nadr_thresh    41  41
        .nadr_grdband   3   3
        .thn_onoff  1
        .thn_merge_dist 5
        .conc_merge_dist    5
        .min_dfct_sz    500
        .gain_inx   1
        .gain_val   18
        .gain_offset    747
        .ndf_pos    424
        .thresh_mode    f
        .filter.
            .fdata.
                .name   
                .revcode    5   3   84
                .lastmod    1029370695  (Wed Aug 14 17:18:15 2002)
                ..
            .filt[0].
                .scale  4
                .coefs[0]   0   0   0   0   0
                .coefs[1]   0   0   0   0   0
                .coefs[2]   0   0   128 128 0
                .coefs[3]   0   0   128 128 0
                .coefs[4]   0   0   0   0   0
                ..
            .filt[1].
                .scale  32
                .coefs[0]   1   1   1   1   1
                .coefs[1]   1   1   1   1   1
                .coefs[2]   1   1   1   1   1
                .coefs[3]   1   1   1   1   1
                .coefs[4]   1   1   1   1   1
                ..
            .filt[2].
                .scale  128
                .coefs[0]   0   0   0   0   0
                .coefs[1]   0   0   0   0   0
                .coefs[2]   0   0   128 0   0
                .coefs[3]   0   0   0   0   0
                .coefs[4]   0   0   0   0   0
                ..
            .filt[3].
                .scale  2
                .coefs[0]   0   0   0   0   0
                .coefs[1]   0   8   8   8   0
                .coefs[2]   0   8   8   8   0
                .coefs[3]   0   8   8   8   0
                .coefs[4]   0   0   0   0   0
                ..
            ..
        .mean_threshold 0   0
        .range_threshold    0   0
        .brightdark_threshold   0
        .densesparse_threshold  0
        .search_range   0   0
        .mean_scale 1.0000  1.0000  1.0000  1.0000  1.0000
        .range_scale    1.0000  1.0000  1.0000  1.0000  1.0000
        .mean_flag  0
        .range_flag 0
        .brightdark_flag    0
        .densesparse_flag   0
        .lightlevel_corners_dark_ul 1614.0684   5241.2418
        .lightlevel_corners_dark_lr 1650.3184   5264.9918
        .lightlevel_corners_bright_ul   1614.0684   5241.2418
        .lightlevel_corners_bright_lr   1650.3184   5264.9918
        .lightlevel_corners_bright2_ul  0.0000  0.0000
        .lightlevel_corners_bright2_lr  0.0000  0.0000
        .hard_soft_threshold_array  h
        .hard_soft_threshold_random h
        .valid_light_level  t
        .light_mode l
        .endpoints_mode a
        .light_sensor_value 242.114838
        .random_selected_min_endpoint   25
        .random_selected_max_endpoint   225
        .random_actual_min_endpoint 26
        .random_actual_max_endpoint 221
        .array_selected_min_endpoint    25
        .array_selected_max_endpoint    225
        .array_actual_min_endpoint  25
        .array_actual_max_endpoint  225
        .gradient_threshold 16
        .correlation_threshold  0.60
        .resolution_mode

【讨论】:

以上是关于PyQt5 将线条延伸到正在绘制的图像之外。我怎样才能防止这种情况发生?的主要内容,如果未能解决你的问题,请参考以下文章

将图像插入 QGridLayout 并在 PyQt5 中的图像顶部绘制

无法在 pyqt5 中嵌入的 matplotlib 上绘制线条

HTML5绘制3D线条延伸动画特效

如何使用核心图形绘制带有自定义图案/图像的线条/笔划?

在 CImage 对象上使用设备上下文绘制线条

将线条延伸到屏幕边缘