editors/Viewer.py
changeset 1342 c17507a10807
parent 1338 c1e6c712cc35
child 1347 533741e5075c
equal deleted inserted replaced
1341:0923e602c603 1342:c17507a10807
   568         # Adding a rubberband to Viewer
   568         # Adding a rubberband to Viewer
   569         self.rubberBand = RubberBand(viewer=self)
   569         self.rubberBand = RubberBand(viewer=self)
   570         self.Editor.SetBackgroundColour(wx.Colour(255,255,255))
   570         self.Editor.SetBackgroundColour(wx.Colour(255,255,255))
   571         self.Editor.SetBackgroundStyle(wx.BG_STYLE_CUSTOM)
   571         self.Editor.SetBackgroundStyle(wx.BG_STYLE_CUSTOM)
   572         self.ResetView()
   572         self.ResetView()
       
   573         self.LastClientSize = None
   573         self.Scaling = None
   574         self.Scaling = None
   574         self.DrawGrid = True
   575         self.DrawGrid = True
   575         self.GridBrush = wx.TRANSPARENT_BRUSH
   576         self.GridBrush = wx.TRANSPARENT_BRUSH
   576         self.PageSize = None
   577         self.PageSize = None
   577         self.PagePen = wx.TRANSPARENT_PEN
   578         self.PagePen = wx.TRANSPARENT_PEN
  1341                     wire = Wire(self,
  1342                     wire = Wire(self,
  1342                         [wx.Point(*start_connector.GetPosition()), 
  1343                         [wx.Point(*start_connector.GetPosition()), 
  1343                          start_connector.GetDirection()],
  1344                          start_connector.GetDirection()],
  1344                         [wx.Point(*end_connector.GetPosition()),
  1345                         [wx.Point(*end_connector.GetPosition()),
  1345                          end_connector.GetDirection()])
  1346                          end_connector.GetDirection()])
  1346                 start_connector.Connect((wire, 0), False)
  1347                 start_connector.Wires.append((wire, 0))
  1347                 end_connector.Connect((wire, -1), False)
  1348                 end_connector.Wires.append((wire, -1))
  1348                 wire.ConnectStartPoint(None, start_connector)
  1349                 wire.StartConnected = start_connector
  1349                 wire.ConnectEndPoint(None, end_connector)
  1350                 wire.EndConnected = end_connector
  1350                 connected.RefreshConnectors()
  1351                 connected.RefreshConnectors()
  1351                 self.AddWire(wire)
  1352                 self.AddWire(wire)
  1352                 if selection is not None and (\
  1353                 if selection is not None and (\
  1353                    selection[1].get((id, refLocalId), False) or \
  1354                    selection[1].get((id, refLocalId), False) or \
  1354                    selection[1].get((refLocalId, id), False)):
  1355                    selection[1].get((refLocalId, id), False)):
  2221                         self.SelectedElement.HighlightPoint(pos)
  2222                         self.SelectedElement.HighlightPoint(pos)
  2222                 else:
  2223                 else:
  2223                     movex, movey = self.SelectedElement.OnMotion(event, dc, self.Scaling)
  2224                     movex, movey = self.SelectedElement.OnMotion(event, dc, self.Scaling)
  2224                     if movex != 0 or movey != 0:
  2225                     if movex != 0 or movey != 0:
  2225                         self.RefreshRect(self.GetScrolledRect(self.SelectedElement.GetRedrawRect(movex, movey)), False)
  2226                         self.RefreshRect(self.GetScrolledRect(self.SelectedElement.GetRedrawRect(movex, movey)), False)
  2226                     self.RefreshVisibleElements()
       
  2227             elif self.Debug and self.StartMousePos is not None and event.Dragging():
  2227             elif self.Debug and self.StartMousePos is not None and event.Dragging():
  2228                 pos = event.GetPosition()
  2228                 pos = event.GetPosition()
  2229                 if abs(self.StartMousePos.x - pos.x) > 5 or abs(self.StartMousePos.y - pos.y) > 5:
  2229                 if abs(self.StartMousePos.x - pos.x) > 5 or abs(self.StartMousePos.y - pos.y) > 5:
  2230                     element = self.SelectedElement
  2230                     element = self.SelectedElement
  2231                     if isinstance(self.SelectedElement, FBD_Block):
  2231                     if isinstance(self.SelectedElement, FBD_Block):
  3466                 yp = max(0, min(y - rotation * 3, self.Editor.GetVirtualSize()[1] / self.Editor.GetScrollPixelsPerUnit()[1]))
  3466                 yp = max(0, min(y - rotation * 3, self.Editor.GetVirtualSize()[1] / self.Editor.GetScrollPixelsPerUnit()[1]))
  3467                 self.RefreshVisibleElements(yp = yp)
  3467                 self.RefreshVisibleElements(yp = yp)
  3468                 self.Scroll(x, yp)
  3468                 self.Scroll(x, yp)
  3469             
  3469             
  3470     def OnMoveWindow(self, event):
  3470     def OnMoveWindow(self, event):
  3471         self.RefreshScrollBars()
  3471         client_size = self.GetClientSize()
  3472         self.RefreshVisibleElements()
  3472         if self.LastClientSize != client_size:
       
  3473             self.LastClientSize = client_size
       
  3474             self.RefreshScrollBars()
       
  3475             self.RefreshVisibleElements()
  3473         event.Skip()
  3476         event.Skip()
  3474 
  3477 
  3475     def DoDrawing(self, dc, printing = False):
  3478     def DoDrawing(self, dc, printing = False):
  3476         if printing:
  3479         if printing:
  3477             if getattr(dc, "printing", False):
  3480             if getattr(dc, "printing", False):