# HG changeset patch # User Laurent Bessard # Date 1353018774 -3600 # Node ID fc91d3718b741d9f04f297718cabaeb9b80a9952 # Parent e12228fd8773de6ca2d5f71dc72c4a20c24db150 Fix bug multiple graph viewer tab displaying values of the same variable can be opened diff -r e12228fd8773 -r fc91d3718b74 IDEFrame.py --- a/IDEFrame.py Thu Nov 15 23:04:41 2012 +0100 +++ b/IDEFrame.py Thu Nov 15 23:32:54 2012 +0100 @@ -2023,7 +2023,8 @@ if self.Controler.IsOfType(instance_type, "ANY_NUM", True) or\ self.Controler.IsOfType(instance_type, "ANY_BIT", True): - return self.OpenGraphicViewer(instance_path) + new_window = GraphicViewer(self.TabsOpened, self, self.Controler, instance_path) + icon = GetBitmap("GRAPH") else: bodytype = self.Controler.GetEditedElementBodyType(instance_type, True) @@ -2044,13 +2045,8 @@ new_window.SetKeywords(IL_KEYWORDS) else: new_window.SetKeywords(ST_KEYWORDS) + if new_window is not None: - 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) - if instance_category in [ITEM_FUNCTIONBLOCK, ITEM_PROGRAM]: pou_type = self.Controler.GetEditedElementType(instance_type, True)[1].upper() icon = GetBitmap(pou_type, bodytype) @@ -2058,22 +2054,19 @@ icon = GetBitmap("TRANSITION", bodytype) elif instance_category == ITEM_ACTION: icon = GetBitmap("ACTION", bodytype) - new_window.SetIcon(icon) - self.AddPage(new_window, "") - new_window.RefreshView() - new_window.SetFocus() - self.RefreshPageTitles() - return new_window - - return None - - def OpenGraphicViewer(self, var_path): - new_window = GraphicViewer(self.TabsOpened, self, self.Controler, var_path) - new_window.SetIcon(GetBitmap("GRAPH")) - self.AddPage(new_window, "") - new_window.RefreshView() - new_window.SetFocus() - self.RefreshPageTitles() + + if new_window is not None: + 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() + new_window.SetFocus() + self.RefreshPageTitles() return new_window def ResetGraphicViewers(self): diff -r e12228fd8773 -r fc91d3718b74 controls/PouInstanceVariablesPanel.py --- a/controls/PouInstanceVariablesPanel.py Thu Nov 15 23:04:41 2012 +0100 +++ b/controls/PouInstanceVariablesPanel.py Thu Nov 15 23:32:54 2012 +0100 @@ -272,7 +272,7 @@ if infos["class"] in ITEMS_VARIABLE: var_path = "%s.%s" % (self.InstanceChoice.GetStringSelection(), infos["name"]) - self.ParentWindow.OpenGraphicViewer(var_path) + self.ParentWindow.OpenDebugViewer(infos["class"], var_path, infos["type"]) event.Skip() return GraphButtonCallback diff -r e12228fd8773 -r fc91d3718b74 editors/Viewer.py --- a/editors/Viewer.py Thu Nov 15 23:04:41 2012 +0100 +++ b/editors/Viewer.py Thu Nov 15 23:32:54 2012 +0100 @@ -31,7 +31,7 @@ import wx from plcopen.structures import * -from PLCControler import ITEM_POU, ITEM_PROGRAM, ITEM_FUNCTIONBLOCK +from PLCControler import ITEM_VAR_LOCAL, ITEM_POU, ITEM_PROGRAM, ITEM_FUNCTIONBLOCK from dialogs import * from graphics import * @@ -1879,12 +1879,10 @@ if iec_path is not None: if isinstance(self.SelectedElement, Wire): if self.SelectedElement.EndConnected is not None: - var_type = self.SelectedElement.EndConnected.GetType() - if self.Controler.IsOfType(var_type, "ANY_NUM", self.Debug) or\ - self.Controler.IsOfType(var_type, "ANY_BIT", self.Debug): - self.ParentWindow.OpenGraphicViewer(iec_path) + self.ParentWindow.OpenDebugViewer(ITEM_VAR_LOCAL, iec_path, + self.SelectedElement.EndConnected.GetType()) else: - self.ParentWindow.OpenGraphicViewer(iec_path) + self.ParentWindow.OpenDebugViewer(ITEM_VAR_LOCAL, iec_path, "BOOL") elif event.ControlDown() and not event.ShiftDown(): if not isinstance(self.SelectedElement, Graphic_Group): if isinstance(self.SelectedElement, FBD_Block):