def DrawBoundingBoxes(self, bboxes, dc=None):
"""
Draw a list of bounding box on Viewer in the order given using XOR
logical function
@param bboxes: List of bounding boxes to draw on viewer
@param dc: Device Context of Viewer (default None)
"""
# Get viewer Device Context if not given
if dc is None:
dc = self.Viewer.GetLogicalDC()
# Save current viewer scale factors before resetting them in order to
# avoid rubberband pen to be scaled
scalex, scaley = dc.GetUserScale()
dc.SetUserScale(1, 1)
# Set DC drawing style
dc.SetPen(wx.Pen(wx.WHITE, style=wx.DOT))
dc.SetBrush(wx.TRANSPARENT_BRUSH)
dc.SetLogicalFunction(wx.XOR)
# Draw the bounding boxes using viewer scale factor
for bbox in bboxes:
if bbox is not None:
dc.DrawRectangle(
bbox.x * scalex, bbox.y * scaley,
bbox.width * scalex, bbox.height * scaley)
dc.SetLogicalFunction(wx.COPY)
# Restore Viewer scale factor
dc.SetUserScale(scalex, scaley)
评论列表
文章目录