--- a/Beremiz.py Wed Mar 13 23:49:19 2013 +0100
+++ b/Beremiz.py Thu Mar 14 09:20:07 2013 +0100
@@ -439,15 +439,6 @@
if projectOpen is not None:
projectOpen = DecodeFileSystemPath(projectOpen, False)
- if (self.EnableSaveProjectState() and ctr is None and
- projectOpen is None and self.Config.HasEntry("currenteditedproject")):
- try:
- projectOpen = DecodeFileSystemPath(self.Config.Read("currenteditedproject"))
- if projectOpen == "":
- projectOpen = None
- except:
- projectOpen = None
-
if projectOpen is not None and os.path.isdir(projectOpen):
self.CTR = ProjectController(self, self.Log)
self.Controler = self.CTR
@@ -603,13 +594,6 @@
self.SaveLastState()
- if self.CTR is not None:
- project_path = os.path.realpath(self.CTR.GetProjectPath())
- else:
- project_path = ""
- self.Config.Write("currenteditedproject", EncodeFileSystemPath(project_path))
- self.Config.Flush()
-
event.Skip()
else:
event.Veto()
@@ -814,10 +798,6 @@
IDEFrame.ResetPerspective(self)
self.RefreshStatusToolBar()
- def RestoreLastLayout(self):
- IDEFrame.RestoreLastLayout(self)
- self.RefreshStatusToolBar()
-
def OnNewProjectMenu(self, event):
if self.CTR is not None and not self.CheckSaveBeforeClosing():
return
@@ -884,8 +864,6 @@
self.RefreshConfigRecentProjects(projectpath)
if self.EnableDebug:
self.DebugVariablePanel.SetDataProducer(self.CTR)
- if self.EnableSaveProjectState():
- self.LoadProjectLayout()
self._Refresh(PROJECTTREE, POUINSTANCEVARIABLESPANEL, LIBRARYTREE)
else:
self.ResetView()
@@ -899,7 +877,6 @@
if self.CTR is not None and not self.CheckSaveBeforeClosing():
return
- self.SaveProjectLayout()
self.ResetView()
self._Refresh(TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU)
self.RefreshAll()
--- a/IDEFrame.py Wed Mar 13 23:49:19 2013 +0100
+++ b/IDEFrame.py Thu Mar 14 09:20:07 2013 +0100
@@ -308,8 +308,6 @@
class IDEFrame(wx.Frame):
- Starting = False
-
# Compatibility function for wx versions < 2.6
if wx.VERSION < (2, 6, 0):
def Bind(self, event, function, id = None):
@@ -457,7 +455,6 @@
style=wx.DEFAULT_FRAME_STYLE)
self.SetClientSize(wx.Size(1000, 600))
self.Bind(wx.EVT_ACTIVATE, self.OnActivated)
- self.Bind(wx.EVT_SIZE, self.OnResize)
self.TabsImageList = wx.ImageList(31, 16)
self.TabsImageListIndexes = {}
@@ -682,7 +679,18 @@
self.DrawingMode = FREEDRAWING_MODE
#self.DrawingMode = DRIVENDRAWING_MODE
self.AuiTabCtrl = []
- self.DefaultPerspective = None
+
+ # Save default perspective
+ notebooks = {}
+ for notebook, entry_name in [(self.LeftNoteBook, "leftnotebook"),
+ (self.BottomNoteBook, "bottomnotebook"),
+ (self.RightNoteBook, "rightnotebook")]:
+ notebooks[entry_name] = self.SaveTabLayout(notebook)
+ self.DefaultPerspective = {
+ "perspective": self.AUIManager.SavePerspective(),
+ "notebooks": notebooks,
+ }
+
# Initialize Printing configuring elements
self.PrintData = wx.PrintData()
@@ -713,53 +721,8 @@
# Saving and restoring frame organization functions
#-------------------------------------------------------------------------------
- def OnResize(self, event):
- if self.Starting:
- self.RestoreLastLayout()
- event.Skip()
-
- def EnableSaveProjectState(self):
- return False
-
- def GetProjectConfiguration(self):
- projects = {}
- try:
- if self.Config.HasEntry("projects"):
- projects = cPickle.loads(str(self.Config.Read("projects")))
- except:
- pass
-
- return projects.get(
- EncodeFileSystemPath(os.path.realpath(self.Controler.GetFilePath())), {})
-
- def SavePageState(self, page):
- state = page.GetState()
- if state is not None:
- if self.Config.HasEntry("projects"):
- projects = cPickle.loads(str(self.Config.Read("projects")))
- else:
- projects = {}
-
- project_infos = projects.setdefault(
- EncodeFileSystemPath(os.path.realpath(self.Controler.GetFilePath())), {})
- editors_state = project_infos.setdefault("editors_state", {})
-
- if page.IsDebugging():
- editors_state[page.GetInstancePath()] = state
- else:
- editors_state[page.GetTagName()] = state
-
- self.Config.Write("projects", cPickle.dumps(projects))
- self.Config.Flush()
-
def GetTabInfos(self, tab):
- if isinstance(tab, EditorPanel):
- if tab.IsDebugging():
- return ("debug", tab.GetInstancePath())
- else:
- return ("editor", tab.GetTagName())
- else:
- for page_name, (page_ref, page_title) in self.MainTabs.iteritems():
+ for page_name, (page_ref, page_title) in self.MainTabs.iteritems():
if page_ref == tab:
return ("main", page_name)
return None
@@ -859,110 +822,15 @@
self.Maximize()
else:
self.SetClientSize(frame_size)
- wx.CallAfter(self.RestoreLastLayout)
-
- def RestoreLastLayout(self):
- notebooks = {}
- for notebook, entry_name in [(self.LeftNoteBook, "leftnotebook"),
- (self.BottomNoteBook, "bottomnotebook"),
- (self.RightNoteBook, "rightnotebook")]:
- notebooks[entry_name] = self.SaveTabLayout(notebook)
- self.DefaultPerspective = {
- "perspective": self.AUIManager.SavePerspective(),
- "notebooks": notebooks,
- }
-
- try:
- if self.Config.HasEntry("perspective"):
- self.AUIManager.LoadPerspective(unicode(self.Config.Read("perspective")))
-
- if self.Config.HasEntry("notebooks"):
- notebooks = cPickle.loads(str(self.Config.Read("notebooks")))
-
- for notebook in [self.LeftNoteBook, self.BottomNoteBook, self.RightNoteBook]:
- for idx in xrange(notebook.GetPageCount()):
- notebook.RemovePage(0)
-
- for notebook, entry_name in [(self.LeftNoteBook, "leftnotebook"),
- (self.BottomNoteBook, "bottomnotebook"),
- (self.RightNoteBook, "rightnotebook")]:
- self.LoadTabLayout(notebook, notebooks.get(entry_name))
- except:
- self.ResetPerspective()
-
- if self.EnableSaveProjectState():
- self.LoadProjectLayout()
-
- self._Refresh(EDITORTOOLBAR)
-
- if wx.Platform == '__WXMSW__':
- wx.CallAfter(self.ResetStarting)
- else:
- self.ResetStarting()
- wx.CallAfter(self.RefreshEditor)
-
+
def SaveLastState(self):
if not self.IsMaximized():
self.Config.Write("framesize", cPickle.dumps(self.GetClientSize()))
elif self.Config.HasEntry("framesize"):
self.Config.DeleteEntry("framesize")
- notebooks = {}
- for notebook, entry_name in [(self.LeftNoteBook, "leftnotebook"),
- (self.BottomNoteBook, "bottomnotebook"),
- (self.RightNoteBook, "rightnotebook")]:
- notebooks[entry_name] = self.SaveTabLayout(notebook)
- self.Config.Write("notebooks", cPickle.dumps(notebooks))
-
- pane = self.AUIManager.GetPane(self.TabsOpened)
- if pane.IsMaximized():
- self.AUIManager.RestorePane(pane)
- self.Config.Write("perspective", self.AUIManager.SavePerspective())
-
- if self.EnableSaveProjectState():
- self.SaveProjectLayout()
-
- for i in xrange(self.TabsOpened.GetPageCount()):
- self.SavePageState(self.TabsOpened.GetPage(i))
-
self.Config.Flush()
- def SaveProjectLayout(self):
- if self.Controler is not None:
- tabs = []
-
- projects = {}
- try:
- if self.Config.HasEntry("projects"):
- projects = cPickle.loads(str(self.Config.Read("projects")))
- except:
- pass
-
- project_infos = projects.setdefault(
- EncodeFileSystemPath(os.path.realpath(self.Controler.GetFilePath())), {})
- project_infos["tabs"] = self.SaveTabLayout(self.TabsOpened)
- if self.EnableDebug:
- project_infos["debug_vars"] = self.DebugVariablePanel.GetDebugVariables()
-
- self.Config.Write("projects", cPickle.dumps(projects))
- self.Config.Flush()
-
- def LoadProjectLayout(self):
- if self.Controler is not None:
- project = self.GetProjectConfiguration()
-
- try:
- if project.has_key("tabs"):
- self.LoadTabLayout(self.TabsOpened, project["tabs"])
- except:
- self.DeleteAllPages()
-
- if self.EnableDebug:
- #try:
- self.DebugVariablePanel.SetDebugVariables(project.get("debug_vars", []))
- #except:
- # self.DebugVariablePanel.ResetView()
-
#-------------------------------------------------------------------------------
# General Functions
#-------------------------------------------------------------------------------
@@ -998,8 +866,6 @@
window = self.TabsOpened.GetPage(selected)
if window.CheckSaveBeforeClosing():
- if self.EnableSaveProjectState():
- self.SavePageState(window)
# Refresh all window elements that have changed
wx.CallAfter(self._Refresh, TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU, DISPLAYMENU)
@@ -1861,16 +1727,6 @@
new_window.SetIcon(GetBitmap("DATATYPE"))
self.AddPage(new_window, "")
if new_window is not None:
- if self.EnableSaveProjectState():
- project_infos = self.GetProjectConfiguration()
- if project_infos.has_key("editors_state"):
- if new_window.IsDebugging():
- state = project_infos["editors_state"].get(new_window.GetInstancePath())
- else:
- state = project_infos["editors_state"].get(tagname)
- if state is not None:
- wx.CallAfter(new_window.SetState, state)
-
openedidx = self.IsOpened(tagname)
old_selected = self.TabsOpened.GetSelection()
if old_selected != openedidx:
@@ -2073,13 +1929,6 @@
icon = GetBitmap("ACTION", bodytype)
if new_window is not None:
- if self.EnableSaveProjectState():
- project_infos = self.GetProjectConfiguration()
- if project_infos.has_key("editors_state"):
- state = project_infos["editors_state"].get(instance_path)
- if state is not None:
- wx.CallAfter(new_window.SetState, state)
-
new_window.SetIcon(icon)
self.AddPage(new_window, "")
new_window.RefreshView()
--- a/PLCOpenEditor.py Wed Mar 13 23:49:19 2013 +0100
+++ b/PLCOpenEditor.py Thu Mar 14 09:20:07 2013 +0100
@@ -303,7 +303,6 @@
self.LibraryPanel.SetController(controler)
self.ProjectTree.Enable(True)
self.PouInstanceVariablesPanel.SetController(controler)
- self.LoadProjectLayout()
self._Refresh(PROJECTTREE, LIBRARYTREE)
self._Refresh(TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU)
dialog.Destroy()
@@ -314,7 +313,6 @@
def OnCloseProjectMenu(self, event):
if not self.CheckSaveBeforeClosing():
return
- self.SaveProjectLayout()
self.ResetView()
self._Refresh(TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU)
--- a/controls/DebugVariablePanel.py Wed Mar 13 23:49:19 2013 +0100
+++ b/controls/DebugVariablePanel.py Thu Mar 14 09:20:07 2013 +0100
@@ -2201,43 +2201,6 @@
self.RefreshGraphicsSizer()
self.ForceRefresh()
- def GetDebugVariables(self):
- if USE_MPL:
- return [panel.GetVariables() for panel in self.GraphicPanels]
- else:
- return [item.GetVariable() for item in self.Table.GetData()]
-
- def SetDebugVariables(self, variables):
- if USE_MPL:
- for variable in variables:
- if isinstance(variable, (TupleType, ListType)):
- items = []
- for iec_path in variable:
- item = VariableTableItem(self, iec_path)
- if not item.IsNumVariable():
- continue
- self.AddDataConsumer(iec_path.upper(), item)
- items.append(item)
- if isinstance(variable, ListType):
- panel = DebugVariableGraphic(self.GraphicsWindow, self, items, GRAPH_PARALLEL)
- elif isinstance(variable, TupleType) and len(items) <= 3:
- panel = DebugVariableGraphic(self.GraphicsWindow, self, items, GRAPH_ORTHOGONAL)
- else:
- continue
- self.GraphicPanels.append(panel)
- self.ResetVariableNameMask()
- self.RefreshGraphicsSizer()
- else:
- self.InsertValue(variable, force=True)
- self.ForceRefresh()
- else:
- for variable in variables:
- if isinstance(variable, (ListType, TupleType)):
- for iec_path in variable:
- self.InsertValue(iec_path, force=True)
- else:
- self.InsertValue(variable, force=True)
-
def ResetGraphicsValues(self):
if USE_MPL:
self.Ticks = numpy.array([])
--- a/editors/EditorPanel.py Wed Mar 13 23:49:19 2013 +0100
+++ b/editors/EditorPanel.py Thu Mar 14 09:20:07 2013 +0100
@@ -88,12 +88,6 @@
def SetIcon(self, icon):
self.Icon = icon
- def GetState(self):
- return None
-
- def SetState(self, state):
- pass
-
def IsViewing(self, tagname):
return self.GetTagName() == tagname
--- a/editors/TextViewer.py Wed Mar 13 23:49:19 2013 +0100
+++ b/editors/TextViewer.py Thu Mar 14 09:20:07 2013 +0100
@@ -247,13 +247,6 @@
def GetCurrentPos(self):
return self.Editor.GetCurrentPos()
- def GetState(self):
- return {"cursor_pos": self.Editor.GetCurrentPos()}
-
- def SetState(self, state):
- if self and state.has_key("cursor_pos"):
- self.Editor.GotoPos(state.get("cursor_pos", 0))
-
def OnModification(self, event):
if not self.DisableEvents:
mod_type = event.GetModificationType()
--- a/editors/Viewer.py Wed Mar 13 23:49:19 2013 +0100
+++ b/editors/Viewer.py Thu Mar 14 09:20:07 2013 +0100
@@ -718,18 +718,6 @@
def GetViewScale(self):
return self.ViewScale
- def GetState(self):
- return {"position": self.Editor.GetViewStart(),
- "zoom": self.CurrentScale}
-
- def SetState(self, state):
- if self:
- if state.has_key("zoom"):
- self.SetScale(state["zoom"])
- if state.has_key("position"):
- self.Scroll(*state["position"])
- self.RefreshVisibleElements()
-
def GetLogicalDC(self, buffered=False):
if buffered:
bitmap = wx.EmptyBitmap(*self.Editor.GetClientSize())