editors/Viewer.py
changeset 1176 f4b434672204
parent 1170 074e46cdedbc
child 1201 3907f10efcf4
equal deleted inserted replaced
1175:01842255c9ff 1176:f4b434672204
    33 from plcopen.structures import *
    33 from plcopen.structures import *
    34 from PLCControler import ITEM_VAR_LOCAL, ITEM_POU, ITEM_PROGRAM, ITEM_FUNCTIONBLOCK
    34 from PLCControler import ITEM_VAR_LOCAL, ITEM_POU, ITEM_PROGRAM, ITEM_FUNCTIONBLOCK
    35 
    35 
    36 from dialogs import *
    36 from dialogs import *
    37 from graphics import *
    37 from graphics import *
       
    38 from editors.DebugViewer import DebugViewer
    38 from EditorPanel import EditorPanel
    39 from EditorPanel import EditorPanel
    39 
    40 
    40 SCROLLBAR_UNIT = 10
    41 SCROLLBAR_UNIT = 10
    41 WINDOW_BORDER = 10
    42 WINDOW_BORDER = 10
    42 SCROLL_ZONE = 10
    43 SCROLL_ZONE = 10
   373 """
   374 """
   374 Class that implements a Viewer based on a wx.ScrolledWindow for drawing and 
   375 Class that implements a Viewer based on a wx.ScrolledWindow for drawing and 
   375 manipulating graphic elements
   376 manipulating graphic elements
   376 """
   377 """
   377 
   378 
   378 class Viewer(EditorPanel, DebugViewer, DebugDataConsumer):
   379 class Viewer(EditorPanel, DebugViewer):
   379     
   380     
   380     if wx.VERSION < (2, 6, 0):
   381     if wx.VERSION < (2, 6, 0):
   381         def Bind(self, event, function, id = None):
   382         def Bind(self, event, function, id = None):
   382             if id is not None:
   383             if id is not None:
   383                 event(self, id, function)
   384                 event(self, id, function)
   554     def __init__(self, parent, tagname, window, controler, debug = False, instancepath = ""):
   555     def __init__(self, parent, tagname, window, controler, debug = False, instancepath = ""):
   555         self.VARIABLE_PANEL_TYPE = controler.GetPouType(tagname.split("::")[1])
   556         self.VARIABLE_PANEL_TYPE = controler.GetPouType(tagname.split("::")[1])
   556         
   557         
   557         EditorPanel.__init__(self, parent, tagname, window, controler, debug)
   558         EditorPanel.__init__(self, parent, tagname, window, controler, debug)
   558         DebugViewer.__init__(self, controler, debug)
   559         DebugViewer.__init__(self, controler, debug)
   559         DebugDataConsumer.__init__(self)
       
   560         
   560         
   561         # Adding a rubberband to Viewer
   561         # Adding a rubberband to Viewer
   562         self.rubberBand = RubberBand(viewer=self)
   562         self.rubberBand = RubberBand(viewer=self)
   563         self.Editor.SetBackgroundColour(wx.Colour(255,255,255))
   563         self.Editor.SetBackgroundColour(wx.Colour(255,255,255))
   564         self.Editor.SetBackgroundStyle(wx.BG_STYLE_CUSTOM)
   564         self.Editor.SetBackgroundStyle(wx.BG_STYLE_CUSTOM)
   890         self.SelectedElement = None
   890         self.SelectedElement = None
   891         self.HighlightedElement = None
   891         self.HighlightedElement = None
   892         self.ToolTipElement = None
   892         self.ToolTipElement = None
   893     
   893     
   894     def Flush(self):
   894     def Flush(self):
   895         self.DeleteDataConsumers()
   895         self.UnsubscribeAllDataConsumers()
   896         for block in self.Blocks.itervalues():
   896         for block in self.Blocks.itervalues():
   897             block.Flush()
   897             block.Flush()
   898     
   898     
   899     # Remove all elements
   899     # Remove all elements
   900     def CleanView(self):
   900     def CleanView(self):
  1046         if refresh_rect is not None:
  1046         if refresh_rect is not None:
  1047             self.RefreshRect(self.GetScrolledRect(refresh_rect), False)
  1047             self.RefreshRect(self.GetScrolledRect(refresh_rect), False)
  1048         else:
  1048         else:
  1049             DebugViewer.RefreshNewData(self)
  1049             DebugViewer.RefreshNewData(self)
  1050     
  1050     
  1051     def RegisterVariables(self):
  1051     def SubscribeAllDataConsumers(self):
  1052         DebugViewer.RegisterVariables(self)
  1052         DebugViewer.SubscribeAllDataConsumers(self)
  1053         self.RefreshView()
  1053         self.RefreshView()
  1054     
  1054     
  1055     # Refresh Viewer elements
  1055     # Refresh Viewer elements
  1056     def RefreshView(self, variablepanel=True, selection=None):
  1056     def RefreshView(self, variablepanel=True, selection=None):
  1057         EditorPanel.RefreshView(self, variablepanel)
  1057         EditorPanel.RefreshView(self, variablepanel)