예제 #1
0
    def InsertValue(self, iec_path, idx=None, force=False, graph=False):
        for panel in self.GraphicPanels:
            if panel.GetItem(iec_path) is not None:
                if graph and isinstance(panel, DebugVariableTextViewer):
                    self.ToggleViewerType(panel)
                return
        if idx is None:
            idx = len(self.GraphicPanels)
        item = DebugVariableItem(self, iec_path, True)
        result = self.AddDataConsumer(iec_path.upper(), item, True)
        if result is not None or force:

            self.Freeze()
            if item.IsNumVariable() and graph:
                panel = DebugVariableGraphicViewer(self.GraphicsWindow, self, [item], GRAPH_PARALLEL)
                if self.CursorTick is not None:
                    panel.SetCursorTick(self.CursorTick)
            else:
                panel = DebugVariableTextViewer(self.GraphicsWindow, self, [item])
            if idx is not None:
                self.GraphicPanels.insert(idx, panel)
            else:
                self.GraphicPanels.append(panel)
            self.ResetVariableNameMask()
            self.RefreshGraphicsSizer()
            self.Thaw()
            self.ForceRefresh()
    def MoveValue(self, iec_path, idx=None, graph=False):
        if idx is None:
            idx = len(self.GraphicPanels)
        source_panel = None
        item = None
        for panel in self.GraphicPanels:
            item = panel.GetItem(iec_path)
            if item is not None:
                source_panel = panel
                break
        if source_panel is not None:
            source_panel_idx = self.GraphicPanels.index(source_panel)

            if (len(source_panel.GetItems()) == 1):

                if source_panel_idx < idx:
                    self.GraphicPanels.insert(idx, source_panel)
                    self.GraphicPanels.pop(source_panel_idx)
                elif source_panel_idx > idx:
                    self.GraphicPanels.pop(source_panel_idx)
                    self.GraphicPanels.insert(idx, source_panel)
                else:
                    return

            else:
                source_panel.RemoveItem(item)
                source_size = source_panel.GetSize()
                if item.IsNumVariable() and graph:
                    panel = DebugVariableGraphicViewer(self.GraphicsWindow,
                                                       self, [item],
                                                       GRAPH_PARALLEL)
                    panel.SetCanvasHeight(source_size.height)
                    if self.CursorTick is not None:
                        panel.SetCursorTick(self.CursorTick)

                else:
                    panel = DebugVariableTextViewer(self.GraphicsWindow, self,
                                                    [item])

                self.GraphicPanels.insert(idx, panel)

                if source_panel.ItemsIsEmpty():
                    if source_panel.HasCapture():
                        source_panel.ReleaseMouse()
                    source_panel.Destroy()
                    self.GraphicPanels.remove(source_panel)

            self.ResetVariableNameMask()
            self.RefreshGraphicsSizer()
            self.ForceRefresh()
예제 #3
0
 def ToggleViewerType(self, panel):
     panel_idx = self.GetViewerIndex(panel)
     if panel_idx is not None:
         self.GraphicPanels.remove(panel)
         items = panel.GetItems()
         if isinstance(panel, DebugVariableGraphicViewer):
             for idx, item in enumerate(items):
                 new_panel = DebugVariableTextViewer(self.GraphicsWindow, self, [item])
                 self.GraphicPanels.insert(panel_idx + idx, new_panel)
         else:
             new_panel = DebugVariableGraphicViewer(self.GraphicsWindow, self, items, GRAPH_PARALLEL)
             self.GraphicPanels.insert(panel_idx, new_panel)
         panel.Destroy()
     self.RefreshGraphicsSizer()
     self.ForceRefresh()
예제 #4
0
 def StartDragNDrop(self, panel, item, x_mouse, y_mouse, x_mouse_start, y_mouse_start):
     if len(panel.GetItems()) > 1:
         self.DraggingAxesPanel = DebugVariableGraphicViewer(self.GraphicsWindow, self, [item], GRAPH_PARALLEL)
         self.DraggingAxesPanel.SetCursorTick(self.CursorTick)
         width, height = panel.GetSize()
         self.DraggingAxesPanel.SetSize(wx.Size(width, height))
         self.DraggingAxesPanel.ResetGraphics()
         self.DraggingAxesPanel.SetPosition(wx.Point(0, -height))
     else:
         self.DraggingAxesPanel = panel
     self.DraggingAxesBoundingBox = panel.GetAxesBoundingBox(parent_coordinate=True)
     self.DraggingAxesMousePos = wx.Point(
         x_mouse_start - self.DraggingAxesBoundingBox.x,
         y_mouse_start - self.DraggingAxesBoundingBox.y)
     self.MoveDragNDrop(x_mouse, y_mouse)