IDEFrame.py
changeset 1364 e9e17d3b2849
parent 1362 077bcba2d485
child 1401 611fded24ce4
equal deleted inserted replaced
1363:e87e0166d0a7 1364:e9e17d3b2849
     3 import cPickle
     3 import cPickle
     4 from types import TupleType
     4 from types import TupleType
     5 
     5 
     6 import wx, wx.grid
     6 import wx, wx.grid
     7 import wx.aui
     7 import wx.aui
     8 
       
     9 try:
       
    10     import matplotlib
       
    11     matplotlib.use('WX')
       
    12     USE_MPL = True
       
    13 except:
       
    14     USE_MPL = False
       
    15 
     8 
    16 from editors.EditorPanel import EditorPanel
     9 from editors.EditorPanel import EditorPanel
    17 from editors.SFCViewer import SFC_Viewer
    10 from editors.SFCViewer import SFC_Viewer
    18 from editors.LDViewer import LD_Viewer
    11 from editors.LDViewer import LD_Viewer
    19 from editors.TextViewer import TextViewer
    12 from editors.TextViewer import TextViewer
    20 from editors.Viewer import Viewer, ZOOM_FACTORS
    13 from editors.Viewer import Viewer, ZOOM_FACTORS
    21 from editors.GraphicViewer import GraphicViewer
       
    22 from editors.ResourceEditor import ConfigurationEditor, ResourceEditor
    14 from editors.ResourceEditor import ConfigurationEditor, ResourceEditor
    23 from editors.DataTypeEditor import DataTypeEditor
    15 from editors.DataTypeEditor import DataTypeEditor
    24 from PLCControler import *
    16 from PLCControler import *
    25 from controls import CustomTree, LibraryPanel, PouInstanceVariablesPanel, SearchResultPanel
    17 from controls import CustomTree, LibraryPanel, PouInstanceVariablesPanel, SearchResultPanel
    26 from controls.DebugVariablePanel import DebugVariablePanel
    18 from controls.DebugVariablePanel import DebugVariablePanel
    27 from dialogs import ProjectDialog, PouDialog, PouTransitionDialog, PouActionDialog, FindInPouDialog, SearchInProjectDialog
    19 from dialogs import ProjectDialog, PouDialog, PouTransitionDialog, PouActionDialog, FindInPouDialog, SearchInProjectDialog
    28 from util.BitmapLibrary import GetBitmap
    20 from util.BitmapLibrary import GetBitmap
    29 
       
    30 PouInstanceVariablesPanel.USE_MPL = USE_MPL
       
    31 
    21 
    32 # Define PLCOpenEditor controls id
    22 # Define PLCOpenEditor controls id
    33 [ID_PLCOPENEDITOR, ID_PLCOPENEDITORLEFTNOTEBOOK, 
    23 [ID_PLCOPENEDITOR, ID_PLCOPENEDITORLEFTNOTEBOOK, 
    34  ID_PLCOPENEDITORBOTTOMNOTEBOOK, ID_PLCOPENEDITORRIGHTNOTEBOOK, 
    24  ID_PLCOPENEDITORBOTTOMNOTEBOOK, ID_PLCOPENEDITORRIGHTNOTEBOOK, 
    35  ID_PLCOPENEDITORPROJECTTREE, ID_PLCOPENEDITORMAINSPLITTER, 
    25  ID_PLCOPENEDITORPROJECTTREE, ID_PLCOPENEDITORMAINSPLITTER, 
  1952                     self.TabsOpened.GetPage(old_selected).ResetBuffer()
  1942                     self.TabsOpened.GetPage(old_selected).ResetBuffer()
  1953                 self.TabsOpened.SetSelection(openedidx)
  1943                 self.TabsOpened.SetSelection(openedidx)
  1954         
  1944         
  1955         elif instance_category in ITEMS_VARIABLE:
  1945         elif instance_category in ITEMS_VARIABLE:
  1956             if self.Controler.IsNumType(instance_type, True):
  1946             if self.Controler.IsNumType(instance_type, True):
  1957                 if USE_MPL:
  1947                 self.AddDebugVariable(instance_path, True)
  1958                     self.AddDebugVariable(instance_path, True)
       
  1959                 else:
       
  1960                     new_window = GraphicViewer(self.TabsOpened, self, self.Controler, instance_path)
       
  1961                     icon = GetBitmap("GRAPH")
       
  1962         
  1948         
  1963         else:
  1949         else:
  1964             bodytype = self.Controler.GetEditedElementBodyType(instance_type, True)
  1950             bodytype = self.Controler.GetEditedElementBodyType(instance_type, True)
  1965             if bodytype == "FBD":
  1951             if bodytype == "FBD":
  1966                 new_window = Viewer(self.TabsOpened, instance_type, self, self.Controler, True, instance_path)
  1952                 new_window = Viewer(self.TabsOpened, instance_type, self, self.Controler, True, instance_path)
  1996             self.RefreshPageTitles()
  1982             self.RefreshPageTitles()
  1997         return new_window
  1983         return new_window
  1998 
  1984 
  1999     def ResetGraphicViewers(self):
  1985     def ResetGraphicViewers(self):
  2000         if self.EnableDebug:
  1986         if self.EnableDebug:
  2001             for i in xrange(self.TabsOpened.GetPageCount()):
       
  2002                 editor = self.TabsOpened.GetPage(i)
       
  2003                 if isinstance(editor, GraphicViewer):
       
  2004                     editor.ResetView()
       
  2005             self.DebugVariablePanel.ResetGraphicsValues()
  1987             self.DebugVariablePanel.ResetGraphicsValues()
  2006 
  1988 
  2007     def CloseObsoleteDebugTabs(self):
  1989     def CloseObsoleteDebugTabs(self):
  2008         if self.EnableDebug:
  1990         if self.EnableDebug:
  2009             idxs = range(self.TabsOpened.GetPageCount())
  1991             idxs = range(self.TabsOpened.GetPageCount())
  2010             idxs.reverse()
  1992             idxs.reverse()
  2011             for idx in idxs:
  1993             for idx in idxs:
  2012                 editor = self.TabsOpened.GetPage(idx)
  1994                 editor = self.TabsOpened.GetPage(idx)
  2013                 if isinstance(editor, (Viewer, GraphicViewer)) and editor.IsDebugging():
  1995                 if isinstance(editor, Viewer) and editor.IsDebugging():
  2014                     instance_infos = self.Controler.GetInstanceInfos(editor.GetInstancePath(), self.EnableDebug)
  1996                     instance_infos = self.Controler.GetInstanceInfos(editor.GetInstancePath(), self.EnableDebug)
  2015                     if instance_infos is None:
  1997                     if instance_infos is None:
  2016                         self.TabsOpened.DeletePage(idx)
  1998                         self.TabsOpened.DeletePage(idx)
  2017                     elif isinstance(editor, GraphicViewer):
       
  2018                         editor.ResetView(True)
       
  2019                     else:
  1999                     else:
  2020                         editor.SubscribeAllDataConsumers()
  2000                         editor.SubscribeAllDataConsumers()
  2021                 elif editor.IsDebugging():
  2001                 elif editor.IsDebugging():
  2022                     editor.SubscribeAllDataConsumers()
  2002                     editor.SubscribeAllDataConsumers()
  2023             self.DebugVariablePanel.SubscribeAllDataConsumers()
  2003             self.DebugVariablePanel.SubscribeAllDataConsumers()
  2074     def RefreshEditorToolBar(self):
  2054     def RefreshEditorToolBar(self):
  2075         selected = self.TabsOpened.GetSelection()
  2055         selected = self.TabsOpened.GetSelection()
  2076         menu = None
  2056         menu = None
  2077         if selected != -1:
  2057         if selected != -1:
  2078             window = self.TabsOpened.GetPage(selected)
  2058             window = self.TabsOpened.GetPage(selected)
  2079             if isinstance(window, (Viewer, TextViewer, GraphicViewer)):
  2059             if isinstance(window, (Viewer, TextViewer)):
  2080                 if not window.IsDebugging():
  2060                 if not window.IsDebugging():
  2081                     menu = self.Controler.GetEditedElementBodyType(window.GetTagName())
  2061                     menu = self.Controler.GetEditedElementBodyType(window.GetTagName())
  2082                 else:
  2062                 else:
  2083                     menu = "debug"
  2063                     menu = "debug"
  2084         if menu is not None and menu != self.CurrentMenu:
  2064         if menu is not None and menu != self.CurrentMenu: