controls/DebugVariablePanel/DebugVariableViewer.py
author Laurent Bessard
Fri, 31 May 2013 14:22:15 +0200
changeset 1206 35046bc74554
parent 1202 3d8c87ab2b5d
child 1207 fb9799a0c0f7
permissions -rw-r--r--
Fixed bug when closing graph in Debug Variable Panel
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
     1
#!/usr/bin/env python
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
     2
# -*- coding: utf-8 -*-
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
     3
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
     4
#This file is part of PLCOpenEditor, a library implementing an IEC 61131-3 editor
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
     5
#based on the plcopen standard. 
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
     6
#
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
     7
#Copyright (C) 2012: Edouard TISSERANT and Laurent BESSARD
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
     8
#
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
     9
#See COPYING file for copyrights details.
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    10
#
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    11
#This library is free software; you can redistribute it and/or
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    12
#modify it under the terms of the GNU General Public
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    13
#License as published by the Free Software Foundation; either
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    14
#version 2.1 of the License, or (at your option) any later version.
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    15
#
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    16
#This library is distributed in the hope that it will be useful,
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    17
#but WITHOUT ANY WARRANTY; without even the implied warranty of
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    18
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    19
#General Public License for more details.
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    20
#
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    21
#You should have received a copy of the GNU General Public
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    22
#License along with this library; if not, write to the Free Software
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    23
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    24
1200
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
    25
from collections import OrderedDict
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    26
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    27
import wx
888
baf5dbfd28f4 Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents: 887
diff changeset
    28
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
    29
import matplotlib
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
    30
matplotlib.use('WX')
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
    31
import matplotlib.pyplot
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
    32
from matplotlib.backends.backend_wxagg import _convert_agg_to_wx_bitmap
1200
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
    33
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    34
from dialogs.ForceVariableDialog import ForceVariableDialog
1200
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
    35
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
    36
# Viewer highlight types
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
    37
[HIGHLIGHT_NONE,
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
    38
 HIGHLIGHT_BEFORE,
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
    39
 HIGHLIGHT_AFTER,
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
    40
 HIGHLIGHT_LEFT,
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
    41
 HIGHLIGHT_RIGHT,
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
    42
 HIGHLIGHT_RESIZE] = range(6)
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
    43
1200
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
    44
# Viewer highlight styles
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
    45
HIGHLIGHT_DROP_PEN = wx.Pen(wx.Colour(0, 128, 255))
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
    46
HIGHLIGHT_DROP_BRUSH = wx.Brush(wx.Colour(0, 128, 255, 128))
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
    47
HIGHLIGHT_RESIZE_PEN = wx.Pen(wx.Colour(200, 200, 200))
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
    48
HIGHLIGHT_RESIZE_BRUSH = wx.Brush(wx.Colour(200, 200, 200))
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
    49
1200
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
    50
#-------------------------------------------------------------------------------
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
    51
#                        Base Debug Variable Viewer Class
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
    52
#-------------------------------------------------------------------------------
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
    53
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
    54
"""
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
    55
Class that implements a generic viewer that display a list of variable values
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
    56
This class has to be inherited to effectively display variable values
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
    57
"""
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
    58
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
    59
class DebugVariableViewer:
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
    60
    
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
    61
    def __init__(self, window, items=[]):
1200
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
    62
        """
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
    63
        Constructor
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
    64
        @param window: Reference to the Debug Variable Panel
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
    65
        @param items: List of DebugVariableItem displayed by Viewer
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
    66
        """
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
    67
        self.ParentWindow = window
1200
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
    68
        self.ItemsDict = OrderedDict([(item.GetVariable(), item)
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
    69
                                      for item in items])
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
    70
        self.Items = self.ItemsDict.viewvalues()
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
    71
        
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
    72
        # Variable storing current highlight displayed in Viewer
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
    73
        self.Highlight = HIGHLIGHT_NONE
1200
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
    74
        # List of buttons
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
    75
        self.Buttons = []
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
    76
    
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
    77
    def __del__(self):
1200
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
    78
        """
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
    79
        Destructor
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
    80
        """
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
    81
        # Remove reference to Debug Variable Panel
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
    82
        self.ParentWindow = None
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
    83
    
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
    84
    def GetIndex(self):
1200
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
    85
        """
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
    86
        Return position of Viewer in Debug Variable Panel
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
    87
        @return: Position of Viewer
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
    88
        """
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
    89
        return self.ParentWindow.GetViewerIndex(self)
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
    90
    
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
    91
    def GetItem(self, variable):
1200
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
    92
        """
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
    93
        Return item storing values of a variable
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
    94
        @param variable: Variable path
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
    95
        @return: Item storing values of this variable
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
    96
        """
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
    97
        return self.ItemsDict.get(variable, None)
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
    98
    
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
    99
    def GetItems(self):
1200
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   100
        """
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   101
        Return items displayed by Viewer
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   102
        @return: List of items displayed in Viewer
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   103
        """
1202
3d8c87ab2b5d Fixed bug when export all items values to clipboard in DebugVariablePanel
Laurent Bessard
parents: 1200
diff changeset
   104
        return self.ItemsDict.values()
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   105
    
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   106
    def AddItem(self, item):
1200
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   107
        """
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   108
        Add an item to the list of items displayed by Viewer
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   109
        @param item: Item to add to the list
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   110
        """
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   111
        self.ItemsDict[item.GetVariable()] = item
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   112
        
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   113
    def RemoveItem(self, item):
1200
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   114
        """
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   115
        Remove an item from the list of items displayed by Viewer
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   116
        @param item: Item to remove from the list
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   117
        """
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   118
        self.ItemsDict.pop(item.GetVariable(), None)
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   119
    
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   120
    def ClearItems(self):
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   121
        """
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   122
        Clear list of items displayed by Viewer
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   123
        """
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   124
        # Unsubscribe every items of the list
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   125
        for item in self.Items:
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   126
            self.ParentWindow.RemoveDataConsumer(item)
1200
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   127
        
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   128
        # Clear list
1206
35046bc74554 Fixed bug when closing graph in Debug Variable Panel
Laurent Bessard
parents: 1202
diff changeset
   129
        self.ItemsDict.clear()
1200
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   130
        
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   131
    def ItemsIsEmpty(self):
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   132
        """
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   133
        Return if list of items displayed by Viewer is empty
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   134
        @return: True if list is empty
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   135
        """
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   136
        return len(self.Items) == 0
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   137
    
1200
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   138
    def UnsubscribeObsoleteData(self):
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   139
        """
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   140
        Function that unsubscribe and remove every item that store values of
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   141
        a variable that doesn't exist in PLC anymore
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   142
        """
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   143
        for item in self.ItemsDict.values()[:]:
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   144
            iec_path = item.GetVariable()
1200
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   145
            
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   146
            # Check that variablepath exist in PLC
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   147
            if self.ParentWindow.GetDataType(iec_path) is None:
1200
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   148
                # If not, unsubscribe and remove it
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   149
                self.ParentWindow.RemoveDataConsumer(item)
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   150
                self.RemoveItem(item)
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   151
            else:
1200
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   152
                # If it exist, resubscribe and refresh data type
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   153
                self.ParentWindow.AddDataConsumer(iec_path.upper(), item)
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   154
                item.RefreshVariableType()
1200
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   155
    
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   156
    def ResetItemsData(self):
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   157
        """
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   158
        Reset data stored in every items displayed in Viewer
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   159
        """
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   160
        for item in self.Items:
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   161
            item.ResetData()
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   162
    
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   163
    def RefreshViewer(self):
1200
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   164
        """
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   165
        Method that refresh the content displayed by Viewer
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   166
        Need to be overridden by inherited classes
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   167
        """
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   168
        pass
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   169
    
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   170
    def SetHighlight(self, highlight):
1200
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   171
        """
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   172
        Set Highlight type displayed in Viewer
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   173
        @return: True if highlight has changed
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   174
        """
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   175
        # Return immediately if highlight don't change
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   176
        if self.Highlight == highlight:
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   177
            return False
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   178
        
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   179
        self.Highlight = highlight
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   180
        return True
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   181
    
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   182
    def GetButtons(self):
1200
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   183
        """
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   184
        Return list of buttons defined in Viewer
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   185
        @return: List of buttons
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   186
        """
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   187
        return self.Buttons
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   188
    
1200
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   189
    def IsOverButton(self, x, y):
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   190
        """
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   191
        Return if point is over one button of Viewer
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   192
        @param x: X coordinate of point
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   193
        @param y: Y coordinate of point
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   194
        @return: button where point is over
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   195
        """
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   196
        for button in self.GetButtons():
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   197
            if button.HitTest(x, y):
1200
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   198
                return button
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   199
        return None
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   200
    
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   201
    def HandleButton(self, x, y):
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   202
        """
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   203
        Search for the button under point and if found execute associated
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   204
        callback
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   205
        @param x: X coordinate of point
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   206
        @param y: Y coordinate of point
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   207
        @return: True if a button was found and callback executed
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   208
        """
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   209
        button = self.IsOverButton(x, y)
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   210
        if button is None:
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   211
            return False
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   212
        
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   213
        button.ProcessCallback()
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   214
        return True
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   215
    
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   216
    def ShowButtons(self, show):
1200
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   217
        """
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   218
        Set display state of buttons in Viewer
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   219
        @param show: Display state (True if buttons must be displayed)
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   220
        """
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   221
        # Change display of every buttons
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   222
        for button in self.Buttons:
1200
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   223
            button.Show(show)
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   224
        
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   225
        # Refresh button positions
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   226
        self.RefreshButtonsPosition()
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   227
        self.RefreshViewer()
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   228
    
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   229
    def RefreshButtonsPosition(self):
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   230
        """
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   231
        Function that refresh buttons position in Viewer
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   232
        """
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   233
        # Get Viewer size
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   234
        width, height = self.GetSize()
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   235
        
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   236
        # Buttons are align right so we calculate buttons positions in
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   237
        # reverse order
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   238
        buttons = self.Buttons[:]
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   239
        buttons.reverse()
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   240
        
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   241
        # Position offset on x coordinate
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   242
        x_offset = 0
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   243
        for button in buttons:
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   244
            # Buttons are stacked right, removing those that are not active 
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   245
            if button.IsEnabled():
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   246
                # Update button position according to button width and offset
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   247
                # on x coordinate
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   248
                w, h = button.GetSize()
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   249
                button.SetPosition(width - 5 - w - x_offset, 5)
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   250
                # Update offset on x coordinate
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   251
                x_offset += w + 2
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   252
    
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   253
    def DrawCommonElements(self, dc, buttons=None):
1200
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   254
        """
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   255
        Function that draw common graphics for every Viewers
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   256
        @param dc: wx.DC object corresponding to Device context where drawing
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   257
        common graphics
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   258
        @param buttons: List of buttons to draw if different from default
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   259
        (default None)
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   260
        """
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   261
        # Get Viewer size
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   262
        width, height = self.GetSize()
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   263
        
1200
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   264
        # Set dc styling for drop before or drop after highlight
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   265
        dc.SetPen(HIGHLIGHT_DROP_PEN)
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   266
        dc.SetBrush(HIGHLIGHT_DROP_BRUSH)
1200
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   267
        
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   268
        # Draw line at upper side of Viewer if highlight is drop before
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   269
        if self.Highlight == HIGHLIGHT_BEFORE:
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   270
            dc.DrawLine(0, 1, width - 1, 1)
1200
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   271
        
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   272
        # Draw line at lower side of Viewer if highlight is drop before
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   273
        elif self.Highlight == HIGHLIGHT_AFTER:
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   274
            dc.DrawLine(0, height - 1, width - 1, height - 1)
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   275
        
1200
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   276
        # If no specific buttons are defined, get default buttons
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   277
        if buttons is None:
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   278
            buttons = self.Buttons
1200
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   279
        # Draw buttons
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   280
        for button in buttons:
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   281
            button.Draw(dc)
1200
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   282
        
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   283
        # If graph dragging is processing
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   284
        if self.ParentWindow.IsDragging():
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   285
            destBBox = self.ParentWindow.GetDraggingAxesClippingRegion(self)
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   286
            srcPos = self.ParentWindow.GetDraggingAxesPosition(self)
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   287
            if destBBox.width > 0 and destBBox.height > 0:
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   288
                srcPanel = self.ParentWindow.DraggingAxesPanel
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   289
                srcBBox = srcPanel.GetAxesBoundingBox()
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   290
                
1200
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   291
                srcX = srcBBox.x - (srcPos.x if destBBox.x == 0 else 0)
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   292
                srcY = srcBBox.y - (srcPos.y if destBBox.y == 0 else 0)
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   293
                
1200
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   294
                srcBmp = _convert_agg_to_wx_bitmap(
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   295
                            srcPanel.get_renderer(), None)
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   296
                srcDC = wx.MemoryDC()
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   297
                srcDC.SelectObject(srcBmp)
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   298
                
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   299
                dc.Blit(destBBox.x, destBBox.y, 
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   300
                        int(destBBox.width), int(destBBox.height), 
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   301
                        srcDC, srcX, srcY)
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   302
    
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   303
    def OnEnter(self, event):
1200
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   304
        """
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   305
        Function called when entering Viewer
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   306
        @param event: wx.MouseEvent 
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   307
        """
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   308
        # Display buttons
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   309
        self.ShowButtons(True)
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   310
        event.Skip()
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   311
        
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   312
    def OnLeave(self, event):
1200
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   313
        """
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   314
        Function called when leaving Viewer
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   315
        @param event: wx.MouseEvent 
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   316
        """
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   317
        # Check that mouse position is inside Viewer and hide buttons
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   318
        x, y = event.GetPosition()
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   319
        width, height = self.GetSize()
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   320
        if not (0 < x < width - 1 and 0 < y < height - 1):
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   321
            self.ShowButtons(False)
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   322
        event.Skip()
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   323
    
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   324
    def OnCloseButton(self):
1200
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   325
        """
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   326
        Function called when Close button is pressed
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   327
        """
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   328
        wx.CallAfter(self.ParentWindow.DeleteValue, self)
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   329
    
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   330
    def OnForceButton(self):
1200
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   331
        """
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   332
        Function called when Force button is pressed
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   333
        """
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   334
        self.ForceValue(self.ItemsDict.values()[0])
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   335
        
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   336
    def OnReleaseButton(self):
1200
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   337
        """
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   338
        Function called when Release button is pressed
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   339
        """
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   340
        self.ReleaseValue(self.ItemsDict.values()[0])
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   341
    
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   342
    def OnMouseDragging(self, x, y):
1200
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   343
        """
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   344
        Function called when mouse is dragged over Viewer
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   345
        @param x: X coordinate of mouse pointer
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   346
        @param y: Y coordinate of mouse pointer
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   347
        """
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   348
        xw, yw = self.GetPosition()
1200
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   349
        # Refresh highlight in Debug Variable Panel (highlight can be displayed
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   350
        # in another Viewer
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   351
        self.ParentWindow.RefreshHighlight(x + xw, y + yw)
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   352
    
1200
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   353
    def RefreshHighlight(self, x, y):
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   354
        """
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   355
        Function called by Debug Variable Panel asking Viewer to refresh
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   356
        highlight according to mouse position
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   357
        @param x: X coordinate of mouse pointer
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   358
        @param y: Y coordinate of mouse pointer
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   359
        """
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   360
        # Get Viewer size
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   361
        width, height = self.GetSize()
1200
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   362
        
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   363
        # Mouse is in the first half of Viewer
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   364
        if y < height / 2:
1200
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   365
            # If Viewer is the upper one, draw drop before highlight
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   366
            if self.ParentWindow.IsViewerFirst(self):
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   367
                self.SetHighlight(HIGHLIGHT_BEFORE)
1200
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   368
            
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   369
            # Else draw drop after highlight in previous Viewer
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   370
            else:
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   371
                self.SetHighlight(HIGHLIGHT_NONE)
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   372
                self.ParentWindow.HighlightPreviousViewer(self)
1200
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   373
        
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   374
        # Mouse is in the second half of Viewer, draw drop after highlight 
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   375
        else:
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   376
            self.SetHighlight(HIGHLIGHT_AFTER)
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   377
    
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   378
    def OnEraseBackground(self, event):
1200
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   379
        """
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   380
        Function called when Viewer background is going to be erase
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   381
        @param event: wx.EraseEvent
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   382
        """
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   383
        # Prevent flicker on Windows
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   384
        pass
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   385
    
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   386
    def OnResize(self, event):
1200
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   387
        """
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   388
        Function called when Viewer size changed
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   389
        @param event: wx.ResizeEvent
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   390
        """
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   391
        # Refresh button positions
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   392
        self.RefreshButtonsPosition()
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   393
        self.ParentWindow.ForceRefresh()
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   394
        event.Skip()
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   395
    
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   396
    def ForceValue(self, item):
1200
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   397
        """
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   398
        Force value of item given
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   399
        @param item: Item to force value
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   400
        """
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   401
        # Check variable data type
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   402
        iec_path = item.GetVariable()
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   403
        iec_type = self.ParentWindow.GetDataType(iec_path)
1200
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   404
        # Return immediately if not found
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   405
        if iec_type is None:
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   406
            return
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   407
        
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   408
        # Open a dialog to enter varaible forced value
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   409
        dialog = ForceVariableDialog(self, iec_type, str(item.GetValue()))
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   410
        if dialog.ShowModal() == wx.ID_OK:
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   411
            self.ParentWindow.ForceDataValue(iec_path.upper(),
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   412
                                             dialog.GetValue())
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   413
    
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   414
    def ReleaseValue(self, item):
1200
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   415
        """
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   416
        Release value of item given
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   417
        @param item: Item to release value
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   418
        """
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   419
        self.ParentWindow.ReleaseDataValue(
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   420
                item.GetVariable().upper())