graphics/RubberBand.py
branchwxPython4
changeset 3746 41be039fbb8c
parent 3306 841fb2ee1213
child 3750 f62625418bff
equal deleted inserted replaced
3745:8a393ba12cd7 3746:41be039fbb8c
   137         self.LastBBox = self.CurrentBBox
   137         self.LastBBox = self.CurrentBBox
   138         self.CurrentBBox = None
   138         self.CurrentBBox = None
   139 
   139 
   140         self.Redraw()
   140         self.Redraw()
   141 
   141 
       
   142     def SetRubberBandPen(self, dc):
       
   143         # Set DC drawing style
       
   144         dc.SetPen(wx.Pen(wx.WHITE, style=wx.DOT))
       
   145         dc.SetLogicalFunction(wx.XOR)
       
   146 
   142     def DrawBoundingBoxes(self, bboxes, dc=None):
   147     def DrawBoundingBoxes(self, bboxes, dc=None):
   143         """
   148         """
   144         Draw a list of bounding box on Viewer in the order given using XOR
   149         Draw a list of bounding box on Viewer in the order given using XOR
   145         logical function
   150         logical function
   146         @param bboxes: List of bounding boxes to draw on viewer
   151         @param bboxes: List of bounding boxes to draw on viewer
   153         # Save current viewer scale factors before resetting them in order to
   158         # Save current viewer scale factors before resetting them in order to
   154         # avoid rubberband pen to be scaled
   159         # avoid rubberband pen to be scaled
   155         scalex, scaley = dc.GetUserScale()
   160         scalex, scaley = dc.GetUserScale()
   156         dc.SetUserScale(1, 1)
   161         dc.SetUserScale(1, 1)
   157 
   162 
   158         # Set DC drawing style
   163         self.SetRubberBandPen(dc)
   159         dc.SetPen(wx.Pen(wx.WHITE, style=wx.DOT))
   164 
   160         dc.SetBrush(wx.TRANSPARENT_BRUSH)
   165         dc.SetBrush(wx.TRANSPARENT_BRUSH)
   161         dc.SetLogicalFunction(wx.XOR)
       
   162 
   166 
   163         # Draw the bounding boxes using viewer scale factor
   167         # Draw the bounding boxes using viewer scale factor
   164         for bbox in bboxes:
   168         for bbox in bboxes:
   165             if bbox is not None:
   169             if bbox is not None:
   166                 dc.DrawRectangle(
   170                 dc.DrawRectangle(
   212     def Erase(self, dc=None):
   216     def Erase(self, dc=None):
   213         self.Viewer.Refresh()
   217         self.Viewer.Refresh()
   214 
   218 
   215     RubberBand.Erase = Erase
   219     RubberBand.Erase = Erase
   216 
   220 
       
   221     def SetRubberBandPen(self, dc):
       
   222         dc.SetPen(wx.Pen(wx.BLACK, style=wx.DOT))
       
   223 
       
   224     RubberBand.SetRubberBandPen = SetRubberBandPen
   217 
   225 
   218 if "gtk3" in wx.PlatformInfo:
   226 if "gtk3" in wx.PlatformInfo:
   219     PatchRubberBandForGTK3()
   227     PatchRubberBandForGTK3()