ROI 手柄不改变它们的位置 while/after 拖动

ROI handles dont change their position while/after dragging

嘿嘿

情况

我在 pyqtgraph 的视图框中有多个散点图。因为我想要它的 'cut something out',所以我在情节中的某处创建了一个 PolyLineROI,初始三个句柄。当我开始将整个东西拖到目的地时(并附加可能附加另一个手柄)手柄的位置仍然从它开始的位置开始。即使我自己拖动手柄,它们也会改变它们相对于起始位置的值...这会导致错误的选择区域。

MWE

import pyqtgraph as pg

def roiMove():
    """Print the coordinates of the ROI."""
    print(roi.getState()['points'])

win = pg.GraphicsWindow()
vb = win.addViewBox()
# roi in rectangle shape
roi = pg.PolyLineROI([[1, 2], [1.5, 2], [1, 0]],
    closed=True,
    pen=pg.mkPen(color=(0, 201, 255, 255), width=3)
    )

# connect to printing function when moving something
# NOTE: when dragging the whole ROI the positions won't be updated
roi.sigRegionChanged.connect(roiMove)
vb.addItem(roi)
pg.QtGui.QApplication.exec_()

如果有人有想法那就太棒了:-)

干杯

我在现实世界中得到了答案...而不是状态点,而是需要映射到父级的 SceneHandlePositions:

MWE

import pyqtgraph as pg

def roiMove():
    """Print the coordinates of the ROI."""
    pts = roi.getSceneHandlePositions()
    print([roi.mapSceneToParent(pt[1]) for pt in pts])

win = pg.GraphicsWindow()
vb = win.addViewBox()
# roi in triangle shape
roi = pg.PolyLineROI([[1, 2], [1.5, 2], [1, 0]],
            closed=True,
            pen=pg.mkPen(color=(0, 201, 255, 255), width=3)
                )

# connect to printing function when moving something
roi.sigRegionChanged.connect(roiMove)
vb.addItem(roi)
vb.setXRange(-5, 5)
vb.setYRange(-5, 5)
pg.QtGui.QApplication.exec_()