Fix bug multiple graph viewer tab displaying values of the same variable can be opened
authorLaurent Bessard
Thu, 15 Nov 2012 23:32:54 +0100
changeset 885 fc91d3718b74
parent 884 e12228fd8773
child 886 ace92afe9100
Fix bug multiple graph viewer tab displaying values of the same variable can be opened
IDEFrame.py
controls/PouInstanceVariablesPanel.py
editors/Viewer.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):
--- 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
     
--- 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):